- refactored the global lines array into a more VM friendly form, moved it to FLevelLocals and exported it to ZScript.

- disabled the Build map loader after finding out that it has been completely broken and nonfunctional for a long time. Since this has no real value it will probably removed entirely in an upcoming commit.
This commit is contained in:
Christoph Oelckers 2017-01-08 14:39:16 +01:00
parent 5ee52f159e
commit 71d1138376
39 changed files with 378 additions and 379 deletions

View file

@ -601,23 +601,21 @@ CUSTOM_CVAR (Int, am_showalllines, -1, 0) // This is a cheat so don't save it.
{
int flagged = 0;
int total = 0;
if (self > 0 && numlines > 0)
if (self > 0 && level.lines.Size() > 0)
{
for(int i=0;i<numlines;i++)
for(auto &line : level.lines)
{
line_t *line = &lines[i];
// disregard intra-sector lines
if (line->frontsector == line->backsector) continue;
if (line.frontsector == line.backsector) continue;
// disregard control sectors for deep water
if (line->frontsector->e->FakeFloor.Sectors.Size() > 0) continue;
if (line.frontsector->e->FakeFloor.Sectors.Size() > 0) continue;
// disregard control sectors for 3D-floors
if (line->frontsector->e->XFloor.attached.Size() > 0) continue;
if (line.frontsector->e->XFloor.attached.Size() > 0) continue;
total++;
if (line->flags & ML_DONTDRAW) flagged++;
if (line.flags & ML_DONTDRAW) flagged++;
}
am_showallenabled = (flagged * 100 / total >= self);
}
@ -2382,7 +2380,6 @@ bool AM_isLockBoundary (line_t &line, int *lockptr = NULL)
void AM_drawWalls (bool allmap)
{
int i;
static mline_t l;
int lock, color;
@ -2393,18 +2390,18 @@ void AM_drawWalls (bool allmap)
if (p == MapPortalGroup) continue;
for (i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
int pg;
if (lines[i].sidedef[0]->Flags & WALLF_POLYOBJ)
if (line.sidedef[0]->Flags & WALLF_POLYOBJ)
{
// For polyobjects we must test the surrounding sector to get the proper group.
pg = P_PointInSector(lines[i].v1->fX() + lines[i].Delta().X / 2, lines[i].v1->fY() + lines[i].Delta().Y / 2)->PortalGroup;
pg = P_PointInSector(line.v1->fX() + line.Delta().X / 2, line.v1->fY() + line.Delta().Y / 2)->PortalGroup;
}
else
{
pg = lines[i].frontsector->PortalGroup;
pg = line.frontsector->PortalGroup;
}
DVector2 offset;
bool portalmode = numportalgroups > 0 && pg != MapPortalGroup;
@ -2418,10 +2415,10 @@ void AM_drawWalls (bool allmap)
}
else continue;
l.a.x = (lines[i].v1->fX() + offset.X);
l.a.y = (lines[i].v1->fY() + offset.Y);
l.b.x = (lines[i].v2->fX() + offset.X);
l.b.y = (lines[i].v2->fY() + offset.Y);
l.a.x = (line.v1->fX() + offset.X);
l.a.y = (line.v1->fY() + offset.Y);
l.b.x = (line.v2->fX() + offset.X);
l.b.y = (line.v2->fY() + offset.Y);
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
{
@ -2429,9 +2426,9 @@ void AM_drawWalls (bool allmap)
AM_rotatePoint(&l.b.x, &l.b.y);
}
if (am_cheat != 0 || (lines[i].flags & ML_MAPPED))
if (am_cheat != 0 || (line.flags & ML_MAPPED))
{
if ((lines[i].flags & ML_DONTDRAW) && (am_cheat == 0 || am_cheat >= 4))
if ((line.flags & ML_DONTDRAW) && (am_cheat == 0 || am_cheat >= 4))
{
if (!am_showallenabled || CheckCheatmode(false))
{
@ -2443,27 +2440,27 @@ void AM_drawWalls (bool allmap)
{
AM_drawMline(&l, AMColors.PortalColor);
}
else if (AM_CheckSecret(&lines[i]))
else if (AM_CheckSecret(&line))
{
// map secret sectors like Boom
AM_drawMline(&l, AMColors.SecretSectorColor);
}
else if (lines[i].flags & ML_SECRET)
else if (line.flags & ML_SECRET)
{ // secret door
if (am_cheat != 0 && lines[i].backsector != NULL)
if (am_cheat != 0 && line.backsector != NULL)
AM_drawMline(&l, AMColors.SecretWallColor);
else
AM_drawMline(&l, AMColors.WallColor);
}
else if (AM_isTeleportBoundary(lines[i]) && AMColors.isValid(AMColors.IntraTeleportColor))
else if (AM_isTeleportBoundary(line) && AMColors.isValid(AMColors.IntraTeleportColor))
{ // intra-level teleporters
AM_drawMline(&l, AMColors.IntraTeleportColor);
}
else if (AM_isExitBoundary(lines[i]) && AMColors.isValid(AMColors.InterTeleportColor))
else if (AM_isExitBoundary(line) && AMColors.isValid(AMColors.InterTeleportColor))
{ // inter-level/game-ending teleporters
AM_drawMline(&l, AMColors.InterTeleportColor);
}
else if (AM_isLockBoundary(lines[i], &lock))
else if (AM_isLockBoundary(line, &lock))
{
if (AMColors.displayLocks)
{
@ -2483,25 +2480,25 @@ void AM_drawWalls (bool allmap)
}
else if (am_showtriggerlines
&& AMColors.isValid(AMColors.SpecialWallColor)
&& AM_isTriggerBoundary(lines[i]))
&& AM_isTriggerBoundary(line))
{
AM_drawMline(&l, AMColors.SpecialWallColor); // wall with special non-door action the player can do
}
else if (lines[i].backsector == NULL)
else if (line.backsector == NULL)
{
AM_drawMline(&l, AMColors.WallColor); // one-sided wall
}
else if (lines[i].backsector->floorplane
!= lines[i].frontsector->floorplane)
else if (line.backsector->floorplane
!= line.frontsector->floorplane)
{
AM_drawMline(&l, AMColors.FDWallColor); // floor level change
}
else if (lines[i].backsector->ceilingplane
!= lines[i].frontsector->ceilingplane)
else if (line.backsector->ceilingplane
!= line.frontsector->ceilingplane)
{
AM_drawMline(&l, AMColors.CDWallColor); // ceiling level change
}
else if (AM_Check3DFloors(&lines[i]))
else if (AM_Check3DFloors(&line))
{
AM_drawMline(&l, AMColors.EFWallColor); // Extra floor border
}
@ -2512,7 +2509,7 @@ void AM_drawWalls (bool allmap)
}
else if (allmap)
{
if ((lines[i].flags & ML_DONTDRAW) && (am_cheat == 0 || am_cheat >= 4))
if ((line.flags & ML_DONTDRAW) && (am_cheat == 0 || am_cheat >= 4))
{
if (!am_showallenabled || CheckCheatmode(false))
{

View file

@ -475,9 +475,9 @@ void SetCompatibilityParams()
{
case CP_CLEARFLAGS:
{
if (CompatParams[i+1] < numlines)
if ((unsigned)CompatParams[i+1] < level.lines.Size())
{
line_t *line = &lines[CompatParams[i+1]];
line_t *line = &level.lines[CompatParams[i+1]];
line->flags &= ~CompatParams[i+2];
}
i+=3;
@ -485,9 +485,9 @@ void SetCompatibilityParams()
}
case CP_SETFLAGS:
{
if (CompatParams[i+1] < numlines)
if ((unsigned)CompatParams[i+1] < level.lines.Size())
{
line_t *line = &lines[CompatParams[i+1]];
line_t *line = &level.lines[CompatParams[i+1]];
line->flags |= CompatParams[i+2];
}
i+=3;
@ -495,9 +495,9 @@ void SetCompatibilityParams()
}
case CP_SETSPECIAL:
{
if (CompatParams[i+1] < numlines)
if ((unsigned)CompatParams[i+1] < level.lines.Size())
{
line_t *line = &lines[CompatParams[i+1]];
line_t *line = &level.lines[CompatParams[i+1]];
line->special = CompatParams[i+2];
for(int ii=0;ii<5;ii++)
{
@ -509,9 +509,9 @@ void SetCompatibilityParams()
}
case CP_CLEARSPECIAL:
{
if (CompatParams[i+1] < numlines)
if ((unsigned)CompatParams[i+1] < level.lines.Size())
{
line_t *line = &lines[CompatParams[i+1]];
line_t *line = &level.lines[CompatParams[i+1]];
line->special = 0;
memset(line->args, 0, sizeof(line->args));
}
@ -520,9 +520,9 @@ void SetCompatibilityParams()
}
case CP_SETACTIVATION:
{
if (CompatParams[i+1] < numlines)
if ((unsigned)CompatParams[i+1] < level.lines.Size())
{
line_t *line = &lines[CompatParams[i+1]];
line_t *line = &level.lines[CompatParams[i+1]];
line->activation = CompatParams[i+2];
}
i += 3;
@ -552,9 +552,9 @@ void SetCompatibilityParams()
}
case CP_SETWALLYSCALE:
{
if (CompatParams[i+1] < numlines)
if ((unsigned)CompatParams[i+1] < level.lines.Size())
{
side_t *side = lines[CompatParams[i+1]].sidedef[CompatParams[i+2]];
side_t *side = level.lines[CompatParams[i+1]].sidedef[CompatParams[i+2]];
if (side != NULL)
{
side->SetTextureYScale(CompatParams[i+3], CompatParams[i+4] / 65536.);

View file

@ -705,7 +705,7 @@ void ProcessEDLinedef(line_t *ld, int recordnum)
ld->flags = (ld->flags&~fmask) | eld->flags;
ld->setAlpha(eld->alpha);
memcpy(ld->args, eld->args, sizeof(ld->args));
tagManager.AddLineID(int(ld - lines), eld->tag);
tagManager.AddLineID(ld->Index(), eld->tag);
}
void ProcessEDSector(sector_t *sec, int recordnum)
@ -760,12 +760,12 @@ void ProcessEDSectors()
auto numsectors = level.sectors.Size();
int *sectorrecord = new int[numsectors];
memset(sectorrecord, -1, numsectors * sizeof(int));
for (int i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
if (lines[i].special == Static_Init && lines[i].args[1] == Init_EDSector)
if (line.special == Static_Init && line.args[1] == Init_EDSector)
{
sectorrecord[lines[i].frontsector->Index()] = lines[i].args[0];
lines[i].special = 0;
sectorrecord[line.frontsector->Index()] = line.args[0];
line.special = 0;
}
}
for (unsigned i = 0; i < numsectors; i++)

View file

@ -2171,7 +2171,7 @@ void FParser::SF_SetLineBlocking(void)
int i;
while ((i = itr.Next()) >= 0)
{
lines[i].flags = (lines[i].flags & ~(ML_BLOCKING | ML_BLOCKEVERYTHING)) | blocking;
level.lines[i].flags = (level.lines[i].flags & ~(ML_BLOCKING | ML_BLOCKEVERYTHING)) | blocking;
}
}
}
@ -2194,7 +2194,7 @@ void FParser::SF_SetLineMonsterBlocking(void)
int i;
while ((i = itr.Next()) >= 0)
{
lines[i].flags = (lines[i].flags & ~ML_BLOCKMONSTERS) | blocking;
level.lines[i].flags = (level.lines[i].flags & ~ML_BLOCKMONSTERS) | blocking;
}
}
}
@ -2251,11 +2251,11 @@ void FParser::SF_SetLineTexture(void)
while ((i = itr.Next()) >= 0)
{
// bad sidedef, Hexen just SEGV'd here!
if (lines[i].sidedef[side] != NULL)
if (level.lines[i].sidedef[side] != NULL)
{
if (position >= 0 && position <= 2)
{
lines[i].sidedef[side]->SetTexture(position, texturenum);
level.lines[i].sidedef[side]->SetTexture(position, texturenum);
}
}
}
@ -2270,7 +2270,7 @@ void FParser::SF_SetLineTexture(void)
FLineIdIterator itr(tag);
while ((i = itr.Next()) >= 0)
{
side_t *sided = lines[i].sidedef[side];
side_t *sided = level.lines[i].sidedef[side];
if(sided != NULL)
{
if(sections & 1) sided->SetTexture(side_t::top, picnum);
@ -3363,19 +3363,19 @@ void FParser::SF_ObjState()
void FParser::SF_LineFlag()
{
line_t* line;
int linenum;
unsigned linenum;
int flagnum;
if (CheckArgs(2))
{
linenum = intvalue(t_argv[0]);
if(linenum < 0 || linenum > numlines)
if(linenum >= level.lines.Size())
{
script_error("LineFlag: Invalid line number.\n");
return;
}
line = lines + linenum;
line = &level.lines[linenum];
flagnum = intvalue(t_argv[1]);
if(flagnum < 0 || (flagnum > 8 && flagnum!=15))
@ -3987,9 +3987,9 @@ void FParser::SF_SetLineTrigger()
mld.special = spec;
mld.tag = tag;
mld.flags = 0;
int f = lines[i].flags;
P_TranslateLineDef(&lines[i], &mld);
lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) |
int f = level.lines[i].flags;
P_TranslateLineDef(&level.lines[i], &mld);
level.lines[i].flags = (level.lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) |
(f & ~(ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY));
}

View file

@ -2241,7 +2241,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
// Do not even try, if we're not in a level. (Can happen after
// a demo finishes playback.)
if (lines == NULL || level.sectors.Size() == 0 || gamestate != GS_LEVEL)
if (level.lines.Size() == 0 || level.sectors.Size() == 0 || gamestate != GS_LEVEL)
{
return;
}

View file

@ -401,6 +401,7 @@ struct FLevelLocals
EMapType maptype;
TStaticArray<sector_t> sectors;
TStaticArray<line_t> lines;
DWORD flags;
DWORD flags2;

View file

@ -547,7 +547,7 @@ CCMD(dumpgeometry)
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d",
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(),
int(seg-segs), int(seg->linedef-lines), seg->sidedef != seg->linedef->sidedef[0]);
int(seg-segs), seg->linedef->Index(), seg->sidedef != seg->linedef->sidedef[0]);
}
else
{

View file

@ -405,17 +405,15 @@ static void InitVertexData()
vt_sectorlists = new TArray<int>[numvertexes];
for(i=0;i<numlines;i++)
for(auto &line : level.lines)
{
line_t * line = &lines[i];
for(j=0;j<2;j++)
{
vertex_t * v = j==0? line->v1 : line->v2;
vertex_t * v = j==0? line.v1 : line.v2;
for(k=0;k<2;k++)
{
sector_t * sec = k==0? line->frontsector : line->backsector;
sector_t * sec = k==0? line.frontsector : line.backsector;
if (sec)
{
@ -712,7 +710,7 @@ CCMD(listmapsections)
{
if (subsectors[j].mapsection == i)
{
Printf("Mapsection %d, sector %d, line %d\n", i, subsectors[j].render_sector->sectornum, int(subsectors[j].firstline->linedef-lines));
Printf("Mapsection %d, sector %d, line %d\n", i, subsectors[j].render_sector->Index(), subsectors[j].firstline->linedef->Index());
break;
}
}

View file

@ -87,7 +87,7 @@ static sector_t *currentsector;
static void AddLine (seg_t *seg, bool portalclip)
{
#ifdef _DEBUG
if (seg->linedef - lines == 38)
if (seg->linedef->Index() == 38)
{
int a = 0;
}

View file

@ -51,7 +51,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
memset(this, 0, sizeof(*this));
if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT - 1)))
{
const line_t *l = &lines[(sky1&(PL_SKYFLAT - 1)) - 1];
const line_t *l = &level.lines[(sky1&(PL_SKYFLAT - 1)) - 1];
const side_t *s = l->sidedef[0];
int pos;

View file

@ -326,7 +326,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent)
//::SplitWall.Clock();
#ifdef _DEBUG
if (seg->linedef-lines==1)
if (seg->linedef->Index() == 1)
{
int a = 0;
}
@ -1414,7 +1414,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
sector_t * segback;
#ifdef _DEBUG
if (seg->linedef - lines < 4)
if (seg->linedef->Index() == 1)
{
int a = 0;
}

View file

@ -850,16 +850,14 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li
void P_Spawn3DFloors (void)
{
static int flagvals[] = {512, 2+512, 512+1024};
int i;
line_t * line;
for (i=0,line=lines;i<numlines;i++,line++)
for (auto &line : level.lines)
{
switch(line->special)
switch(line.special)
{
case ExtraFloor_LightOnly:
if (line->args[1] < 0 || line->args[1] > 2) line->args[1] = 0;
P_Set3DFloor(line, 3, flagvals[line->args[1]], 0);
if (line.args[1] < 0 || line.args[1] > 2) line.args[1] = 0;
P_Set3DFloor(&line, 3, flagvals[line.args[1]], 0);
break;
case Sector_Set3DFloor:
@ -868,24 +866,24 @@ void P_Spawn3DFloors (void)
// In Doom format the translators can take full integers for the tag and the line ID always is the same as the tag.
if (level.maptype == MAPTYPE_HEXEN)
{
if (line->args[1]&8)
if (line.args[1]&8)
{
tagManager.AddLineID(i, line->args[4]);
tagManager.AddLineID(line.Index(), line.args[4]);
}
else
{
line->args[0]+=256*line->args[4];
line->args[4]=0;
line.args[0]+=256*line.args[4];
line.args[4]=0;
}
}
P_Set3DFloor(line, line->args[1]&~8, line->args[2], line->args[3]);
P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]);
break;
default:
continue;
}
line->special=0;
line->args[0] = line->args[1] = line->args[2] = line->args[3] = line->args[4] = 0;
line.special=0;
line.args[0] = line.args[1] = line.args[2] = line.args[3] = line.args[4] = 0;
}
// kg3D - do it in software
for (auto &sec : level.sectors)

View file

@ -121,10 +121,10 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
extsector_t::midtex::plane &scrollplane = ceiling? sector->e->Midtex.Ceiling : sector->e->Midtex.Floor;
// Bit arrays that mark whether a line or sector is to be attached.
BYTE *found_lines = new BYTE[(numlines+7)/8];
BYTE *found_lines = new BYTE[(level.lines.Size()+7)/8];
BYTE *found_sectors = new BYTE[(level.sectors.Size()+7)/8];
memset(found_lines, 0, sizeof (BYTE) * ((numlines+7)/8));
memset(found_lines, 0, sizeof (BYTE) * ((level.lines.Size()+7)/8));
memset(found_sectors, 0, sizeof (BYTE) * ((level.sectors.Size()+7)/8));
// mark all lines and sectors that are already attached to this one
@ -132,13 +132,13 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
// from the marker arrays.
for (unsigned i=0; i < scrollplane.AttachedLines.Size(); i++)
{
int line = int(scrollplane.AttachedLines[i] - lines);
int line = scrollplane.AttachedLines[i]->Index();
found_lines[line>>3] |= 1 << (line&7);
}
for (unsigned i=0; i < scrollplane.AttachedSectors.Size(); i++)
{
int sec = scrollplane.AttachedSectors[i]->sectornum;
int sec = scrollplane.AttachedSectors[i]->Index();
found_sectors[sec>>3] |= 1 << (sec&7);
}
@ -151,7 +151,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
int line;
while ((line = itr.Next()) >= 0)
{
line_t *ln = &lines[line];
line_t *ln = &level.lines[line];
if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX))
{
@ -176,24 +176,25 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
// Only consider two-sided lines with the 3DMIDTEX flag
continue;
}
int lineno = int(ln-lines);
found_lines[lineno>>3] |= 1 << (lineno&7);
int lineno = ln->Index();
found_lines[lineno >> 3] |= 1 << (lineno & 7);
}
}
}
for(int i=0; i < numlines; i++)
for(unsigned i=0; i < level.lines.Size(); i++)
{
if (found_lines[i>>3] & (1 << (i&7)))
{
scrollplane.AttachedLines.Push(&lines[i]);
auto &line = level.lines[i];
scrollplane.AttachedLines.Push(&line);
v = lines[i].frontsector->sectornum;
v = line.frontsector->Index();
assert(v < (int)level.sectors.Size());
found_sectors[v>>3] |= 1 << (v&7);
v = lines[i].backsector->sectornum;
v = line.backsector->Index();
assert(v < (int)level.sectors.Size());
found_sectors[v>>3] |= 1 << (v&7);
}

View file

@ -3284,7 +3284,7 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name)
int linenum = -1;
const char *texname = FBehavior::StaticLookupString (name);
if (texname == NULL)
if (texname == nullptr)
return;
side = !!side;
@ -3296,8 +3296,8 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name)
{
side_t *sidedef;
sidedef = lines[linenum].sidedef[side];
if (sidedef == NULL)
sidedef = level.lines[linenum].sidedef[side];
if (sidedef == nullptr)
continue;
switch (position)
@ -4434,8 +4434,8 @@ int DLevelScript::SideFromID(int id, int side)
{
int line = P_FindFirstLineFromID(id);
if (line == -1) return -1;
if (lines[line].sidedef[side] == NULL) return -1;
return lines[line].sidedef[side]->Index;
if (level.lines[line].sidedef[side] == NULL) return -1;
return level.lines[line].sidedef[side]->Index;
}
}
@ -4444,7 +4444,7 @@ int DLevelScript::LineFromID(int id)
if (id == 0)
{
if (activationline == NULL) return -1;
return int(activationline - lines);
return activationline->Index();
}
else
{
@ -5695,7 +5695,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
FLineIdIterator itr(args[0]);
while ((line = itr.Next()) >= 0)
{
lines[line].activation = args[1];
level.lines[line].activation = args[1];
}
}
break;
@ -5704,7 +5704,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
if (argCount > 0)
{
int line = P_FindFirstLineFromID(args[0]);
return line >= 0 ? lines[line].activation : 0;
return line >= 0 ? level.lines[line].activation : 0;
}
break;
@ -7742,7 +7742,7 @@ scriptwait:
if (activationline != NULL)
{
activationline->special = 0;
DPrintf(DMSG_SPAMMY, "Cleared line special on line %d\n", (int)(activationline - lines));
DPrintf(DMSG_SPAMMY, "Cleared line special on line %d\n", activationline->Index());
}
break;
@ -8307,32 +8307,33 @@ scriptwait:
case PCD_SETLINEBLOCKING:
{
int line;
int lineno;
FLineIdIterator itr(STACK(2));
while ((line = itr.Next()) >= 0)
while ((lineno = itr.Next()) >= 0)
{
auto &line = level.lines[lineno];
switch (STACK(1))
{
case BLOCK_NOTHING:
lines[line].flags &= ~(ML_BLOCKING|ML_BLOCKEVERYTHING|ML_RAILING|ML_BLOCK_PLAYERS);
line.flags &= ~(ML_BLOCKING|ML_BLOCKEVERYTHING|ML_RAILING|ML_BLOCK_PLAYERS);
break;
case BLOCK_CREATURES:
default:
lines[line].flags &= ~(ML_BLOCKEVERYTHING|ML_RAILING|ML_BLOCK_PLAYERS);
lines[line].flags |= ML_BLOCKING;
line.flags &= ~(ML_BLOCKEVERYTHING|ML_RAILING|ML_BLOCK_PLAYERS);
line.flags |= ML_BLOCKING;
break;
case BLOCK_EVERYTHING:
lines[line].flags &= ~(ML_RAILING|ML_BLOCK_PLAYERS);
lines[line].flags |= ML_BLOCKING|ML_BLOCKEVERYTHING;
line.flags &= ~(ML_RAILING|ML_BLOCK_PLAYERS);
line.flags |= ML_BLOCKING|ML_BLOCKEVERYTHING;
break;
case BLOCK_RAILING:
lines[line].flags &= ~(ML_BLOCKEVERYTHING|ML_BLOCK_PLAYERS);
lines[line].flags |= ML_RAILING|ML_BLOCKING;
line.flags &= ~(ML_BLOCKEVERYTHING|ML_BLOCK_PLAYERS);
line.flags |= ML_RAILING|ML_BLOCKING;
break;
case BLOCK_PLAYERS:
lines[line].flags &= ~(ML_BLOCKEVERYTHING|ML_BLOCKING|ML_RAILING);
lines[line].flags |= ML_BLOCK_PLAYERS;
line.flags &= ~(ML_BLOCKEVERYTHING|ML_BLOCKING|ML_RAILING);
line.flags |= ML_BLOCK_PLAYERS;
break;
}
}
@ -8349,9 +8350,9 @@ scriptwait:
while ((line = itr.Next()) >= 0)
{
if (STACK(1))
lines[line].flags |= ML_BLOCKMONSTERS;
level.lines[line].flags |= ML_BLOCKMONSTERS;
else
lines[line].flags &= ~ML_BLOCKMONSTERS;
level.lines[line].flags &= ~ML_BLOCKMONSTERS;
}
sp -= 2;
@ -8374,7 +8375,7 @@ scriptwait:
FLineIdIterator itr(STACK(7));
while ((linenum = itr.Next()) >= 0)
{
line_t *line = &lines[linenum];
line_t *line = &level.lines[linenum];
line->special = specnum;
line->args[0] = arg0;
line->args[1] = STACK(4);

View file

@ -19,6 +19,7 @@
#include "gi.h"
#include "p_spec.h"
#if 0
// MACROS ------------------------------------------------------------------
//#define SHADE2LIGHT(s) (160-2*(s))
@ -487,7 +488,7 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
// Setting numvertexes to the same as numwalls is overly conservative,
// but the extra vertices will be removed during the BSP building pass.
numsides = numvertexes = numwalls;
numlines = 0;
int numlines = 0;
sides = new side_t[numsides];
memset (sides, 0, numsides*sizeof(side_t));
@ -562,8 +563,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
}
// Set line properties that Doom doesn't store per-sidedef
lines = new line_t[numlines];
memset (lines, 0, numlines*sizeof(line_t));
level.lines.Alloc(numlines);
memset (&level.lines[0], 0, numlines*sizeof(line_t));
for (i = 0, j = -1; i < numwalls; ++i)
{
@ -573,6 +574,7 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
}
j = int(intptr_t(sides[i].linedef));
auto &lines = level.lines;
lines[j].sidedef[0] = (side_t*)(intptr_t)i;
lines[j].sidedef[1] = (side_t*)(intptr_t)walls[i].nextwall;
lines[j].v1 = FindVertex (walls[i].x, walls[i].y);
@ -654,8 +656,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
slope.z[0] = slope.z[1] = slope.z[2] = -bsec->ceilingZ;
CalcPlane (slope, sec.ceilingplane);
}
int linenum = int(intptr_t(sides[bsec->wallptr].linedef));
int sidenum = int(intptr_t(lines[linenum].sidedef[1]));
int linenum = sides[bsec->wallptr].linedef->Index();
int sidenum = int(intptr_t(level.lines[linenum].sidedef[1] - sides));
if (bsec->floorstat & 64)
{ // floor is aligned to first wall
P_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
@ -667,8 +669,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
}
for (i = 0; i < numlines; i++)
{
intptr_t front = intptr_t(lines[i].sidedef[0]);
intptr_t back = intptr_t(lines[i].sidedef[1]);
intptr_t front = intptr_t(level.lines[i].sidedef[0]-sides);
intptr_t back = intptr_t(level.lines[i].sidedef[1]-sides);
lines[i].sidedef[0] = front >= 0 ? &sides[front] : NULL;
lines[i].sidedef[1] = back >= 0 ? &sides[back] : NULL;
}
@ -851,6 +853,7 @@ static void Decrypt (void *to_, const void *from_, int len, int key)
}
}
#endif
//==========================================================================
//
// Just an actor to make the Build sprites show up. It doesn't do anything
@ -892,3 +895,4 @@ void ACustomSprite::BeginPlay ()
// set face/wall/floor flags
renderflags |= ActorRenderFlags::FromInt (((cstat >> 4) & 3) << 12);
}

View file

@ -255,10 +255,10 @@ static bool LoadGLVertexes(FileReader * lump)
mgl = (mapglvertex_t *) (gldata + GL_VERT_OFFSET);
memcpy(vertexes, oldvertexes, firstglvertex * sizeof(vertex_t));
for(i=0;i<numlines;i++)
for(auto &line : level.lines)
{
lines[i].v1 = vertexes + (lines[i].v1 - oldvertexes);
lines[i].v2 = vertexes + (lines[i].v2 - oldvertexes);
line.v1 = vertexes + (line.v1 - oldvertexes);
line.v2 = vertexes + (line.v2 - oldvertexes);
}
for (i = firstglvertex; i < numvertexes; i++)
@ -328,7 +328,7 @@ static bool LoadGLSegs(FileReader * lump)
glsegextras[i].PartnerSeg = ml->partner == 0xFFFF ? DWORD_MAX : LittleShort(ml->partner);
if(ml->linedef != 0xffff)
{
ldef = &lines[LittleShort(ml->linedef)];
ldef = &level.lines[LittleShort(ml->linedef)];
segs[i].linedef = ldef;
@ -382,7 +382,7 @@ static bool LoadGLSegs(FileReader * lump)
if(ml->linedef != 0xffff) // skip minisegs
{
ldef = &lines[LittleLong(ml->linedef)];
ldef = &level.lines[LittleLong(ml->linedef)];
segs[i].linedef = ldef;
@ -1002,7 +1002,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
{
vertexes, numvertexes,
sides, numsides,
lines, numlines,
&level.lines[0], (int)level.lines.Size(),
0, 0, 0, 0
};
leveldata.FindMapBounds ();
@ -1114,7 +1114,7 @@ static void CreateCachedNodes(MapData *map)
else WriteLong(ZNodes, 0);
if (segs[i].linedef)
{
WriteLong(ZNodes, DWORD(segs[i].linedef - lines));
WriteLong(ZNodes, DWORD(segs[i].linedef->Index()));
WriteByte(ZNodes, segs[i].sidedef == segs[i].linedef->sidedef[0]? 0:1);
}
else
@ -1156,7 +1156,7 @@ static void CreateCachedNodes(MapData *map)
uLongf outlen = ZNodes.Size();
BYTE *compressed;
int offset = numlines * 8 + 12 + 16;
int offset = level.lines.Size() * 8 + 12 + 16;
int r;
do
{
@ -1171,13 +1171,13 @@ static void CreateCachedNodes(MapData *map)
while (r == Z_BUF_ERROR);
memcpy(compressed, "CACH", 4);
DWORD len = LittleLong(numlines);
DWORD len = LittleLong(level.lines.Size());
memcpy(compressed+4, &len, 4);
map->GetChecksum(compressed+8);
for(int i=0;i<numlines;i++)
for (unsigned i = 0; i < level.lines.Size(); i++)
{
DWORD ndx[2] = {LittleLong(DWORD(lines[i].v1 - vertexes)), LittleLong(DWORD(lines[i].v2 - vertexes)) };
memcpy(compressed+8+16+8*i, ndx, 8);
DWORD ndx[2] = { LittleLong(DWORD(level.lines[i].v1 - vertexes)), LittleLong(DWORD(level.lines[i].v2 - vertexes)) };
memcpy(compressed + 8 + 16 + 8 * i, ndx, 8);
}
memcpy(compressed + offset - 4, "ZGL3", 4);
@ -1219,7 +1219,7 @@ static bool CheckCachedNodes(MapData *map)
if (fread(&numlin, 4, 1, f) != 1) goto errorout;
numlin = LittleLong(numlin);
if ((int)numlin != numlines) goto errorout;
if (numlin != level.lines.Size()) goto errorout;
if (fread(md5, 1, 16, f) != 16) goto errorout;
map->GetChecksum(md5map);
@ -1261,10 +1261,11 @@ static bool CheckCachedNodes(MapData *map)
goto errorout;
}
for(int i=0;i<numlines;i++)
for(auto &line : level.lines)
{
lines[i].v1 = &vertexes[LittleLong(verts[i*2])];
lines[i].v2 = &vertexes[LittleLong(verts[i*2+1])];
int i = line.Index();
line.v1 = &vertexes[LittleLong(verts[i*2])];
line.v2 = &vertexes[LittleLong(verts[i*2+1])];
}
delete [] verts;

View file

@ -360,7 +360,7 @@ void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling)
int line;
while ((line = itr.Next()) >= 0)
{
line_t *ld = &lines[line];
line_t *ld = &level.lines[line];
if (ld->special == Static_Init && ld->args[1] == Init_SectorLink)
{

View file

@ -2604,7 +2604,7 @@ FUNC(LS_Line_SetTextureOffset)
int line;
while ((line = itr.Next()) >= 0)
{
side_t *side = lines[line].sidedef[arg3];
side_t *side = level.lines[line].sidedef[arg3];
if (side != NULL)
{
@ -2659,7 +2659,7 @@ FUNC(LS_Line_SetTextureScale)
int line;
while ((line = itr.Next()) >= 0)
{
side_t *side = lines[line].sidedef[arg3];
side_t *side = level.lines[line].sidedef[arg3];
if (side != NULL)
{
if ((arg4&8)==0)
@ -2733,7 +2733,7 @@ FUNC(LS_Line_SetBlocking)
int line;
while ((line = itr.Next()) >= 0)
{
lines[line].flags = (lines[line].flags & ~clearflags) | setflags;
level.lines[line].flags = (level.lines[line].flags & ~clearflags) | setflags;
}
return true;
}
@ -3028,14 +3028,14 @@ FUNC(LS_TranslucentLine)
int linenum;
while ((linenum = itr.Next()) >= 0)
{
lines[linenum].alpha = clamp(arg1, 0, 255) / 255.;
level.lines[linenum].alpha = clamp(arg1, 0, 255) / 255.;
if (arg2 == 0)
{
lines[linenum].flags &= ~ML_ADDTRANS;
level.lines[linenum].flags &= ~ML_ADDTRANS;
}
else if (arg2 == 1)
{
lines[linenum].flags |= ML_ADDTRANS;
level.lines[linenum].flags |= ML_ADDTRANS;
}
else
{

View file

@ -183,7 +183,7 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines
if (ffcf_verbose)
{
Printf("Hit line %d at position %f,%f, group %d\n",
int(ld - lines), cres.Position.X, cres.Position.Y, ld->frontsector->PortalGroup);
ld->Index(), cres.Position.X, cres.Position.Y, ld->frontsector->PortalGroup);
}
if (!ld->backsector)
@ -3296,7 +3296,6 @@ bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end)
}
li = in->d.line;
assert(((size_t)li - (size_t)lines) % sizeof(line_t) == 0);
if (li->flags & ML_BLOCKEVERYTHING)
{
goto bounceblocking;
@ -3907,7 +3906,7 @@ struct aim_t
int frontflag = P_PointOnLineSidePrecise(startpos, li);
if (aimdebug)
Printf("Found line %d: ___toppitch = %f, ___bottompitch = %f\n", int(li - lines), toppitch.Degrees, bottompitch.Degrees);
Printf("Found line %d: toppitch = %f, bottompitch = %f\n", li->Index(), toppitch.Degrees, bottompitch.Degrees);
if (li->isLinePortal() && frontflag == 0)
{
@ -3951,7 +3950,7 @@ struct aim_t
return;
if (aimdebug)
Printf("After line %d: toppitch = %f, bottompitch = %f, planestocheck = %d\n", int(li - lines), toppitch.Degrees, bottompitch.Degrees, planestocheck);
Printf("After line %d: toppitch = %f, bottompitch = %f, planestocheck = %d\n", li->Index(), toppitch.Degrees, bottompitch.Degrees, planestocheck);
sector_t *entersec = frontflag ? li->frontsector : li->backsector;
sector_t *exitsec = frontflag ? li->backsector : li->frontsector;

View file

@ -330,7 +330,7 @@ bool AActor::FixMapthingPos()
for (list = blockmaplump + blockmap[blocky*bmapwidth + blockx] + 1; *list != -1; ++list)
{
line_t *ldef = &lines[*list];
line_t *ldef = &level.lines[*list];
if (ldef->frontsector == ldef->backsector)
{ // Skip two-sided lines inside a single sector
@ -367,10 +367,10 @@ bool AActor::FixMapthingPos()
if (distance < radius)
{
DPrintf(DMSG_NOTIFY, "%s at (%f,%f) lies on %s line %td, distance = %f\n",
DPrintf(DMSG_NOTIFY, "%s at (%f,%f) lies on %s line %d, distance = %f\n",
this->GetClass()->TypeName.GetChars(), X(), Y(),
ldef->Delta().X == 0 ? "vertical" : ldef->Delta().Y == 0 ? "horizontal" : "diagonal",
ldef - lines, distance);
ldef->Index(), distance);
DAngle ang = ldef->Delta().Angle();
if (ldef->backsector != NULL && ldef->backsector == secstart)
{
@ -709,7 +709,7 @@ line_t *FBlockLinesIterator::Next()
{
while (*list != -1)
{
line_t *ld = &lines[*list];
line_t *ld = &level.lines[*list];
list++;
if (ld->validcount != validcount)

View file

@ -358,11 +358,10 @@ AActor *P_GetPushThing (int s)
void P_SpawnPushers ()
{
int i;
line_t *l = lines;
line_t *l = &level.lines[0];
int s;
for (i = 0; i < numlines; i++, l++)
for (unsigned i = 0; i < level.lines.Size(); i++, l++)
{
switch (l->special)
{

View file

@ -64,7 +64,7 @@
#include "serializer.h"
static TStaticArray<sector_t> loadsectors;
static TArray<line_t> loadlines;
static TStaticArray<line_t> loadlines;
static TArray<side_t> loadsides;
@ -902,7 +902,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
// deep down in the deserializer or just a crash if the few insufficient safeguards were not triggered.
BYTE chk[16] = { 0 };
arc.Array("checksum", chk, 16);
if (arc.GetSize("linedefs") != (unsigned)numlines ||
if (arc.GetSize("linedefs") != level.lines.Size() ||
arc.GetSize("sidedefs") != (unsigned)numsides ||
arc.GetSize("sectors") != level.sectors.Size() ||
arc.GetSize("polyobjs") != (unsigned)po_NumPolyobjs ||
@ -956,7 +956,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
FBehavior::StaticSerializeModuleStates(arc);
// The order here is important: First world state, then portal state, then thinkers, and last polyobjects.
arc.Array("linedefs", lines, &loadlines[0], numlines);
arc.Array("linedefs", &level.lines[0], &loadlines[0], level.lines.Size());
arc.Array("sidedefs", sides, &loadsides[0], numsides);
arc.Array("sectors", &level.sectors[0], &loadsectors[0], level.sectors.Size());
arc("zones", Zones);
@ -997,8 +997,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
void P_BackupMapData()
{
loadsectors = level.sectors;
loadlines.Resize(numlines);
memcpy(&loadlines[0], lines, numlines * sizeof(line_t));
loadlines = level.lines;
loadsides.Resize(numsides);
memcpy(&loadsides[0], sides, numsides * sizeof(side_t));
}

View file

@ -380,24 +380,23 @@ DScroller::DScroller (double dx, double dy, const line_t *l,
void P_SpawnScrollers(void)
{
int i;
line_t *l = lines;
line_t *l = &level.lines[0];
TArray<int> copyscrollers;
for (i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
if (lines[i].special == Sector_CopyScroller)
if (line.special == Sector_CopyScroller)
{
// don't allow copying the scroller if the sector has the same tag as it would just duplicate it.
if (!tagManager.SectorHasTag(lines[i].frontsector, lines[i].args[0]))
if (!tagManager.SectorHasTag(line.frontsector, line.args[0]))
{
copyscrollers.Push(i);
copyscrollers.Push(line.Index());
}
lines[i].special = 0;
line.special = 0;
}
}
for (i = 0; i < numlines; i++, l++)
for (unsigned i = 0; i < level.lines.Size(); i++, l++)
{
double dx; // direction and speed of scrolling
double dy;
@ -474,7 +473,7 @@ void P_SpawnScrollers(void)
}
for (unsigned j = 0; j < copyscrollers.Size(); j++)
{
line_t *line = &lines[copyscrollers[j]];
line_t *line = &level.lines[copyscrollers[j]];
if (line->args[0] == l->args[0] && (line->args[1] & 1))
{
@ -494,7 +493,7 @@ void P_SpawnScrollers(void)
}
for(unsigned j = 0;j < copyscrollers.Size(); j++)
{
line_t *line = &lines[copyscrollers[j]];
line_t *line = &level.lines[copyscrollers[j]];
if (line->args[0] == l->args[0] && (line->args[1] & 2))
{
@ -512,7 +511,7 @@ void P_SpawnScrollers(void)
}
for(unsigned j = 0;j < copyscrollers.Size(); j++)
{
line_t *line = &lines[copyscrollers[j]];
line_t *line = &level.lines[copyscrollers[j]];
if (line->args[0] == l->args[0] && (line->args[1] & 4))
{
@ -530,48 +529,48 @@ void P_SpawnScrollers(void)
while ((s = itr.Next()) >= 0)
{
if (s != i)
new DScroller(dx, dy, lines + s, control, accel);
new DScroller(dx, dy, &level.lines[s], control, accel);
}
break;
}
case Scroll_Texture_Offsets:
// killough 3/2/98: scroll according to sidedef offsets
s = int(lines[i].sidedef[0] - sides);
s = int(level.lines[i].sidedef[0] - sides);
new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffset(side_t::mid),
sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0]));
break;
case Scroll_Texture_Left:
l->special = special; // Restore the special, for compat_useblocking's benefit.
s = int(lines[i].sidedef[0] - sides);
s = int(level.lines[i].sidedef[0] - sides);
new DScroller (EScroll::sc_side, l->args[0] / 64., 0,
-1, s, accel, SCROLLTYPE(l->args[1]));
break;
case Scroll_Texture_Right:
l->special = special;
s = int(lines[i].sidedef[0] - sides);
s = int(level.lines[i].sidedef[0] - sides);
new DScroller (EScroll::sc_side, -l->args[0] / 64., 0,
-1, s, accel, SCROLLTYPE(l->args[1]));
break;
case Scroll_Texture_Up:
l->special = special;
s = int(lines[i].sidedef[0] - sides);
s = int(level.lines[i].sidedef[0] - sides);
new DScroller (EScroll::sc_side, 0, l->args[0] / 64.,
-1, s, accel, SCROLLTYPE(l->args[1]));
break;
case Scroll_Texture_Down:
l->special = special;
s = int(lines[i].sidedef[0] - sides);
s = int(level.lines[i].sidedef[0] - sides);
new DScroller (EScroll::sc_side, 0, -l->args[0] / 64.,
-1, s, accel, SCROLLTYPE(l->args[1]));
break;
case Scroll_Texture_Both:
s = int(lines[i].sidedef[0] - sides);
s = int(level.lines[i].sidedef[0] - sides);
if (l->args[0] == 0) {
dx = (l->args[1] - l->args[2]) / 64.;
dy = (l->args[4] - l->args[3]) / 64.;
@ -645,9 +644,9 @@ void SetWallScroller (int id, int sidechoice, double dx, double dy, EScrollPos W
FLineIdIterator itr(id);
while ((linenum = itr.Next()) >= 0)
{
if (lines[linenum].sidedef[sidechoice] != NULL)
if (level.lines[linenum].sidedef[sidechoice] != NULL)
{
int sidenum = int(lines[linenum].sidedef[sidechoice] - sides);
int sidenum = int(level.lines[linenum].sidedef[sidechoice] - sides);
unsigned int i;
for (i = 0; i < numcollected; i++)
{

View file

@ -1838,7 +1838,7 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons
bool P_AlignFlat (int linenum, int side, int fc)
{
line_t *line = lines + linenum;
line_t *line = &level.lines[linenum];
sector_t *sec = side ? line->backsector : line->frontsector;
if (!sec)
@ -1873,7 +1873,7 @@ void subsector_t::BuildPolyBSP()
// Set up level information for the node builder.
PolyNodeLevel.Sides = sides;
PolyNodeLevel.NumSides = numsides;
PolyNodeLevel.Lines = lines;
PolyNodeLevel.Lines = &level.lines[0];
PolyNodeLevel.NumLines = numlines;
// Feed segs to the nodebuilder and build the nodes.

View file

@ -89,7 +89,6 @@ void BloodCrypt (void *data, int key, int len);
void P_ClearUDMFKeys();
extern AActor *P_SpawnMapThing (FMapThing *mthing, int position);
extern bool P_LoadBuildMap (BYTE *mapdata, size_t len, FMapThing **things, int *numthings);
extern void P_TranslateTeleportThings (void);
@ -107,7 +106,15 @@ CVAR (Bool, showloadtimes, false, 0);
static void P_Shutdown ();
bool P_IsBuildMap(MapData *map);
inline bool P_IsBuildMap(MapData *map)
{
return false;
}
inline bool P_LoadBuildMap(BYTE *mapdata, size_t len, FMapThing **things, int *numthings)
{
return false;
}
//
@ -129,9 +136,6 @@ subsector_t* subsectors;
int numnodes;
node_t* nodes;
int numlines;
line_t* lines;
int numsides;
side_t* sides;
@ -589,11 +593,11 @@ static void SetTexture (side_t *side, int position, const char *name, FMissingTe
{
// Print an error that lists all references to this sidedef.
// We must scan the linedefs manually for all references to this sidedef.
for(int i = 0; i < numlines; i++)
for(unsigned i = 0; i < level.lines.Size(); i++)
{
for(int j = 0; j < 2; j++)
{
if (lines[i].sidedef[j] == side)
if (level.lines[i].sidedef[j] == side)
{
Printf(TEXTCOLOR_RED"Unknown %s texture '"
TEXTCOLOR_ORANGE "%s" TEXTCOLOR_RED
@ -878,7 +882,7 @@ void P_LoadZSegs (FileReaderBase &data)
segs[i].v1 = &vertexes[v1];
segs[i].v2 = &vertexes[v2];
segs[i].linedef = ldef = &lines[line];
segs[i].linedef = ldef = &level.lines[line];
segs[i].sidedef = ldef->sidedef[side];
segs[i].frontsector = ldef->sidedef[side]->sector;
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL)
@ -940,7 +944,7 @@ void P_LoadGLZSegs (FileReaderBase &data, int type)
{
line_t *ldef;
seg->linedef = ldef = &lines[line];
seg->linedef = ldef = &level.lines[line];
seg->sidedef = ldef->sidedef[side];
seg->frontsector = ldef->sidedef[side]->sector;
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL)
@ -999,10 +1003,10 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
}
if (vertexes != newvertarray)
{
for (i = 0; i < (DWORD)numlines; ++i)
for (auto &line : level.lines)
{
lines[i].v1 = lines[i].v1 - vertexes + newvertarray;
lines[i].v2 = lines[i].v2 - vertexes + newvertarray;
line.v1 = line.v1 - vertexes + newvertarray;
line.v2 = line.v2 - vertexes + newvertarray;
}
delete[] vertexes;
vertexes = newvertarray;
@ -1212,7 +1216,6 @@ void P_LoadSegs (MapData * map)
BYTE *data;
BYTE *vertchanged = new BYTE[numvertexes]; // phares 10/4/98
DWORD segangle;
line_t* line; // phares 10/4/98
//int ptp_angle; // phares 10/4/98
//int delta_angle; // phares 10/4/98
int vnum1,vnum2; // phares 10/4/98
@ -1247,10 +1250,9 @@ void P_LoadSegs (MapData * map)
// Mark those used by linedefs. A marked vertex is one that is not a
// candidate for movement further down.
line = lines;
for (i = 0; i < numlines ; i++, line++)
for (auto &line : level.lines)
{
vertchanged[line->v1 - vertexes] = vertchanged[line->v2 - vertexes] = 1;
vertchanged[line.v1 - vertexes] = vertchanged[line.v2 - vertexes] = 1;
}
try
@ -1327,14 +1329,14 @@ void P_LoadSegs (MapData * map)
}
linedef = LittleShort(ml->linedef);
if ((unsigned)linedef >= (unsigned)numlines)
if ((unsigned)linedef >= level.lines.Size())
{
throw badseg(1, i, linedef);
}
ldef = &lines[linedef];
ldef = &level.lines[linedef];
li->linedef = ldef;
side = LittleShort(ml->side);
if ((unsigned)(ldef->sidedef[side] - sides) >= (unsigned)numsides)
if ((unsigned)(ldef->sidedef[side] - sides) >= level.lines.Size())
{
throw badseg(2, i, int(ldef->sidedef[side] - sides));
}
@ -1362,7 +1364,7 @@ void P_LoadSegs (MapData * map)
break;
case 1:
Printf ("Seg %d references a nonexistant linedef %d (max %d).\n", bad.badsegnum, bad.baddata, numlines);
Printf ("Seg %d references a nonexistant linedef %d (max %u).\n", bad.badsegnum, bad.baddata, level.lines.Size());
break;
case 2:
@ -1998,7 +2000,7 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL;
double dx = (ld->v2->fX() - ld->v1->fX());
double dy = (ld->v2->fY() - ld->v1->fY());
int linenum = int(ld-lines);
int linenum = ld->Index();
if (ld->frontsector == NULL)
{
@ -2022,8 +2024,6 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
switch (ld->special)
{ // killough 4/11/98: handle special types
int j;
case TranslucentLine: // killough 4/11/98: translucent 2s textures
// [RH] Second arg controls how opaque it is.
if (alpha == SHRT_MIN)
@ -2048,14 +2048,14 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
}
else
{
for (j = 0; j < numlines; j++)
for (unsigned j = 0; j < level.lines.Size(); j++)
{
if (tagManager.LineHasID(j, ld->args[0]))
{
lines[j].alpha = dalpha;
level.lines[j].alpha = dalpha;
if (additive)
{
lines[j].flags |= ML_ADDTRANS;
level.lines[j].flags |= ML_ADDTRANS;
}
}
}
@ -2067,9 +2067,9 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
// killough 4/4/98: delay using sidedefs until they are loaded
void P_FinishLoadingLineDefs ()
{
for (int i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
P_FinishLoadingLineDef(&lines[i], sidetemp[lines[i].sidedef[0]-sides].a.alpha);
P_FinishLoadingLineDef(&line, sidetemp[line.sidedef[0]-sides].a.alpha);
}
}
@ -2098,10 +2098,10 @@ void P_LoadLineDefs (MapData * map)
char * mldf;
maplinedef_t *mld;
numlines = lumplen / sizeof(maplinedef_t);
lines = new line_t[numlines];
int numlines = lumplen / sizeof(maplinedef_t);
level.lines.Alloc(numlines);
linemap.Resize(numlines);
memset (lines, 0, numlines*sizeof(line_t));
memset (&level.lines[0], 0, numlines*sizeof(line_t));
mldf = new char[lumplen];
map->Read(ML_LINEDEFS, mldf);
@ -2151,7 +2151,7 @@ void P_LoadLineDefs (MapData * map)
P_AllocateSideDefs (sidecount);
mld = (maplinedef_t *)mldf;
ld = lines;
ld = &level.lines[0];
for (i = 0; i < numlines; i++, mld++, ld++)
{
ld->alpha = 1.; // [RH] Opaque by default
@ -2197,10 +2197,10 @@ void P_LoadLineDefs2 (MapData * map)
char * mldf;
maplinedef2_t *mld;
numlines = lumplen / sizeof(maplinedef2_t);
lines = new line_t[numlines];
int numlines = lumplen / sizeof(maplinedef2_t);
level.lines.Alloc(numlines);
linemap.Resize(numlines);
memset (lines, 0, numlines*sizeof(line_t));
memset (&level.lines[0], 0, numlines*sizeof(line_t));
mldf = new char[lumplen];
map->Read(ML_LINEDEFS, mldf);
@ -2243,7 +2243,7 @@ void P_LoadLineDefs2 (MapData * map)
P_AllocateSideDefs (sidecount);
mld = (maplinedef2_t *)mldf;
ld = lines;
ld = &level.lines[0];
for (i = 0; i < numlines; i++, mld++, ld++)
{
int j;
@ -2376,7 +2376,7 @@ static void P_LoopSidedefs (bool firstloop)
if (NULL == rightside)
{
// There is no right side!
if (firstloop) Printf ("Line %d's right edge is unconnected\n", linemap[unsigned(line-lines)]);
if (firstloop) Printf ("Line %d's right edge is unconnected\n", linemap[line->Index()]);
continue;
}
@ -2398,7 +2398,7 @@ static void P_LoopSidedefs (bool firstloop)
if (right == NO_SIDE)
{
// There is no right side!
if (firstloop) Printf ("Line %d's right edge is unconnected\n", linemap[unsigned(line-lines)]);
if (firstloop) Printf ("Line %d's right edge is unconnected\n", linemap[line->Index()]);
continue;
}
@ -2803,12 +2803,12 @@ static void P_CreateBlockMap ()
BlockLists = new TArray<int>[bmapwidth * bmapheight];
for (line = 0; line < numlines; ++line)
for (line = 0; line < (int)level.lines.Size(); ++line)
{
int x1 = int(lines[line].v1->fX());
int y1 = int(lines[line].v1->fY());
int x2 = int(lines[line].v2->fX());
int y2 = int(lines[line].v2->fY());
int x1 = int(level.lines[line].v1->fX());
int y1 = int(level.lines[line].v1->fY());
int x2 = int(level.lines[line].v2->fX());
int y2 = int(level.lines[line].v2->fY());
int dx = x2 - x1;
int dy = y2 - y1;
int bx = (x1 - minx) >> BLOCKBITS;
@ -2991,7 +2991,7 @@ static bool P_VerifyBlockMap(int count)
// scan the list for out-of-range linedef indicies in list
for(tmplist = list; *tmplist != -1; tmplist++)
{
if(*tmplist < 0 || *tmplist >= numlines)
if((unsigned)*tmplist >= level.lines.Size())
{
Printf(PRINT_HIGH, "P_VerifyBlockMap: index >= numlines\n");
return false;
@ -3115,9 +3115,9 @@ static void P_GroupLines (bool buildmap)
// count number of lines in each sector
times[1].Clock();
total = 0;
for (int i = 0; i < numlines; i++)
for (unsigned i = 0; i < level.lines.Size(); i++)
{
auto li = &lines[i];
auto li = &level.lines[i];
if (li->frontsector == NULL)
{
if (!flaggedNoFronts)
@ -3169,9 +3169,9 @@ static void P_GroupLines (bool buildmap)
}
}
for (int i = 0; i < numlines; i++)
for (unsigned i = 0; i < level.lines.Size(); i++)
{
auto li = &lines[i];
auto li = &level.lines[i];
if (li->frontsector != NULL)
{
li->frontsector->Lines[linesDoneInEachSector[li->frontsector->Index()]++] = li;
@ -3461,6 +3461,7 @@ void P_FreeLevelData ()
delete[] level.sectors[0].e;
}
level.sectors.Clear();
level.lines.Clear();
if (gamenodes != NULL && gamenodes != nodes)
{
@ -3489,12 +3490,6 @@ void P_FreeLevelData ()
numsubsectors = numgamesubsectors = 0;
nodes = gamenodes = NULL;
numnodes = numgamenodes = 0;
if (lines != NULL)
{
delete[] lines;
lines = NULL;
}
numlines = 0;
if (sides != NULL)
{
delete[] sides;
@ -3923,7 +3918,7 @@ void P_SetupLevel (const char *lumpname, int position)
{
vertexes, numvertexes,
sides, numsides,
lines, numlines,
&level.lines[0], (int)level.lines.Size(),
0, 0, 0, 0
};
leveldata.FindMapBounds ();

View file

@ -482,7 +482,7 @@ int SightCheck::P_SightBlockLinesIterator (int x, int y)
for (list = blockmaplump + offset + 1; *list != -1; list++)
{
if (!P_SightCheckLine (&lines[*list]))
if (!P_SightCheckLine (&level.lines[*list]))
{
if (!portalfound) return 0;
else res = -1;

View file

@ -52,7 +52,7 @@ static void P_SlopeLineToPoint (int lineid, const DVector3 &pos, bool slopeCeil)
FLineIdIterator itr(lineid);
while ((linenum = itr.Next()) >= 0)
{
const line_t *line = &lines[linenum];
const line_t *line = &level.lines[linenum];
sector_t *sec;
secplane_t *plane;
@ -516,14 +516,14 @@ static void P_AlignPlane(sector_t *sec, line_t *line, int which)
void P_SetSlopes ()
{
int i, s;
int s;
for (i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
if (lines[i].special == Plane_Align)
if (line.special == Plane_Align)
{
lines[i].special = 0;
if (lines[i].backsector != NULL)
line.special = 0;
if (line.backsector != nullptr)
{
// args[0] is for floor, args[1] is for ceiling
//
@ -531,15 +531,15 @@ void P_SetSlopes ()
// then args[0], bits 2-3 are for ceiling.
for (s = 0; s < 2; s++)
{
int bits = lines[i].args[s] & 3;
int bits = line.args[s] & 3;
if (s == 1 && bits == 0)
bits = (lines[i].args[0] >> 2) & 3;
bits = (line.args[0] >> 2) & 3;
if (bits == 1) // align front side to back
P_AlignPlane (lines[i].frontsector, lines + i, s);
P_AlignPlane (line.frontsector, &line, s);
else if (bits == 2) // align back side to front
P_AlignPlane (lines[i].backsector, lines + i, s);
P_AlignPlane (line.backsector, &line, s);
}
}
}
@ -554,9 +554,9 @@ void P_SetSlopes ()
void P_CopySlopes()
{
for (int i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
if (lines[i].special == Plane_Copy)
if (line.special == Plane_Copy)
{
// The args are used for the tags of sectors to copy:
// args[0]: front floor
@ -564,31 +564,31 @@ void P_CopySlopes()
// args[2]: back floor
// args[3]: back ceiling
// args[4]: copy slopes from one side of the line to the other.
lines[i].special = 0;
for (int s = 0; s < (lines[i].backsector ? 4 : 2); s++)
line.special = 0;
for (int s = 0; s < (line.backsector ? 4 : 2); s++)
{
if (lines[i].args[s])
P_CopyPlane(lines[i].args[s],
(s & 2 ? lines[i].backsector : lines[i].frontsector), s & 1);
if (line.args[s])
P_CopyPlane(line.args[s],
(s & 2 ? line.backsector : line.frontsector), s & 1);
}
if (lines[i].backsector != NULL)
if (line.backsector != NULL)
{
if ((lines[i].args[4] & 3) == 1)
if ((line.args[4] & 3) == 1)
{
lines[i].backsector->floorplane = lines[i].frontsector->floorplane;
line.backsector->floorplane = line.frontsector->floorplane;
}
else if ((lines[i].args[4] & 3) == 2)
else if ((line.args[4] & 3) == 2)
{
lines[i].frontsector->floorplane = lines[i].backsector->floorplane;
line.frontsector->floorplane = line.backsector->floorplane;
}
if ((lines[i].args[4] & 12) == 4)
if ((line.args[4] & 12) == 4)
{
lines[i].backsector->ceilingplane = lines[i].frontsector->ceilingplane;
line.backsector->ceilingplane = line.frontsector->ceilingplane;
}
else if ((lines[i].args[4] & 12) == 8)
else if ((line.args[4] & 12) == 8)
{
lines[i].frontsector->ceilingplane = lines[i].backsector->ceilingplane;
line.frontsector->ceilingplane = line.backsector->ceilingplane;
}
}
}

View file

@ -189,7 +189,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
// end of changed code
if (developer >= DMSG_SPAMMY && buttonSuccess)
{
Printf ("Line special %d activated on line %i\n", special, int(line - lines));
Printf ("Line special %d activated on line %i\n", special, line->Index());
}
return true;
}
@ -361,7 +361,7 @@ bool P_PredictLine(line_t *line, AActor *mo, int side, int activationType)
// end of changed code
if (developer >= DMSG_SPAMMY && buttonSuccess)
{
Printf("Line special %d predicted on line %i\n", special, int(line - lines));
Printf("Line special %d predicted on line %i\n", special, line->Index());
}
return true;
}
@ -790,14 +790,14 @@ DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags
FLineIdIterator itr(target);
while ((linenum = itr.Next()) >= 0)
{
if (flags & WLF_SIDE1 && lines[linenum].sidedef[0] != NULL)
if (flags & WLF_SIDE1 && level.lines[linenum].sidedef[0] != NULL)
{
lines[linenum].sidedef[0]->Flags |= wallflags;
level.lines[linenum].sidedef[0]->Flags |= wallflags;
}
if (flags & WLF_SIDE2 && lines[linenum].sidedef[1] != NULL)
if (flags & WLF_SIDE2 && level.lines[linenum].sidedef[1] != NULL)
{
lines[linenum].sidedef[1]->Flags |= wallflags;
level.lines[linenum].sidedef[1]->Flags |= wallflags;
}
}
ChangeStatNum(STAT_LIGHTTRANSFER);
@ -821,7 +821,7 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, BYTE flags)
FLineIdIterator itr(target);
while ((linenum = itr.Next()) >= 0)
{
line_t *line = &lines[linenum];
line_t *line = &level.lines[linenum];
if (flags & WLF_SIDE1 && line->sidedef[0] != NULL)
{
@ -958,42 +958,42 @@ static void CopyPortal(int sectortag, int plane, unsigned pnum, double alpha, bo
SetPortal(&level.sectors[s], plane, pnum, alpha);
}
for (int j=0;j<numlines;j++)
for (auto &line : level.lines)
{
// Check if this portal needs to be copied to other sectors
// This must be done here to ensure that it gets done only after the portal is set up
if (lines[j].special == Sector_SetPortal &&
lines[j].args[1] == 1 &&
(lines[j].args[2] == plane || lines[j].args[2] == 3) &&
lines[j].args[3] == sectortag)
if (line.special == Sector_SetPortal &&
line.args[1] == 1 &&
(line.args[2] == plane || line.args[2] == 3) &&
line.args[3] == sectortag)
{
if (lines[j].args[0] == 0)
if (line.args[0] == 0)
{
SetPortal(lines[j].frontsector, plane, pnum, alpha);
SetPortal(line.frontsector, plane, pnum, alpha);
}
else
{
FSectorTagIterator itr(lines[j].args[0]);
FSectorTagIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
{
SetPortal(&level.sectors[s], plane, pnum, alpha);
}
}
}
if (tolines && lines[j].special == Sector_SetPortal &&
lines[j].args[1] == 5 &&
lines[j].args[3] == sectortag)
if (tolines && line.special == Sector_SetPortal &&
line.args[1] == 5 &&
line.args[3] == sectortag)
{
if (lines[j].args[0] == 0)
if (line.args[0] == 0)
{
lines[j].portaltransferred = pnum;
line.portaltransferred = pnum;
}
else
{
FLineIdIterator itr(lines[j].args[0]);
FLineIdIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
{
lines[s].portaltransferred = pnum;
level.lines[s].portaltransferred = pnum;
}
}
}
@ -1004,20 +1004,20 @@ static void CopyPortal(int sectortag, int plane, unsigned pnum, double alpha, bo
void P_SpawnPortal(line_t *line, int sectortag, int plane, int bytealpha, int linked)
{
if (plane < 0 || plane > 2 || (linked && plane == 2)) return;
for (int i=0;i<numlines;i++)
for (auto &oline : level.lines)
{
// We must look for the reference line with a linear search unless we want to waste the line ID for it
// which is not a good idea.
if (lines[i].special == Sector_SetPortal &&
lines[i].args[0] == sectortag &&
lines[i].args[1] == linked &&
lines[i].args[2] == plane &&
lines[i].args[3] == 1)
if (oline.special == Sector_SetPortal &&
oline.args[0] == sectortag &&
oline.args[1] == linked &&
oline.args[2] == plane &&
oline.args[3] == 1)
{
// beware of overflows.
DVector2 pos1 = line->v1->fPos() + line->Delta() / 2;
DVector2 pos2 = lines[i].v1->fPos() + lines[i].Delta() / 2;
unsigned pnum = P_GetPortal(linked ? PORTS_LINKEDPORTAL : PORTS_PORTAL, plane, line->frontsector, lines[i].frontsector, pos2 - pos1);
DVector2 pos2 = oline.v1->fPos() + oline.Delta() / 2;
unsigned pnum = P_GetPortal(linked ? PORTS_LINKEDPORTAL : PORTS_PORTAL, plane, line->frontsector, oline.frontsector, pos2 - pos1);
CopyPortal(sectortag, plane, pnum, bytealpha / 255., false);
return;
}
@ -1266,9 +1266,9 @@ void P_SpawnSpecials (void)
P_SpawnSkybox(pt2);
}
for (int i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
switch (lines[i].special)
switch (line.special)
{
int s;
sector_t *sec;
@ -1277,16 +1277,16 @@ void P_SpawnSpecials (void)
// support for drawn heights coming from different sector
case Transfer_Heights:
{
sec = lines[i].frontsector;
if (lines[i].args[1] & 2)
sec = line.frontsector;
if (line.args[1] & 2)
{
sec->MoreFlags |= SECF_FAKEFLOORONLY;
}
if (lines[i].args[1] & 4)
if (line.args[1] & 4)
{
sec->MoreFlags |= SECF_CLIPFAKEPLANES;
}
if (lines[i].args[1] & 8)
if (line.args[1] & 8)
{
sec->MoreFlags |= SECF_UNDERWATER;
}
@ -1294,15 +1294,15 @@ void P_SpawnSpecials (void)
{
sec->MoreFlags |= SECF_FORCEDUNDERWATER;
}
if (lines[i].args[1] & 16)
if (line.args[1] & 16)
{
sec->MoreFlags |= SECF_IGNOREHEIGHTSEC;
}
if (lines[i].args[1] & 32)
if (line.args[1] & 32)
{
sec->MoreFlags |= SECF_NOFAKELIGHT;
}
FSectorTagIterator itr(lines[i].args[0]);
FSectorTagIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
{
level.sectors[s].heightsec = sec;
@ -1315,29 +1315,29 @@ void P_SpawnSpecials (void)
// killough 3/16/98: Add support for setting
// floor lighting independently (e.g. lava)
case Transfer_FloorLight:
new DLightTransfer (lines[i].frontsector, lines[i].args[0], true);
new DLightTransfer (line.frontsector, line.args[0], true);
break;
// killough 4/11/98: Add support for setting
// ceiling lighting independently
case Transfer_CeilingLight:
new DLightTransfer (lines[i].frontsector, lines[i].args[0], false);
new DLightTransfer (line.frontsector, line.args[0], false);
break;
// [Graf Zahl] Add support for setting lighting
// per wall independently
case Transfer_WallLight:
new DWallLightTransfer (lines[i].frontsector, lines[i].args[0], lines[i].args[1]);
new DWallLightTransfer (line.frontsector, line.args[0], line.args[1]);
break;
case Sector_Attach3dMidtex:
P_Attach3dMidtexLinesToSector(lines[i].frontsector, lines[i].args[0], lines[i].args[1], !!lines[i].args[2]);
P_Attach3dMidtexLinesToSector(line.frontsector, line.args[0], line.args[1], !!line.args[2]);
break;
case Sector_SetLink:
if (lines[i].args[0] == 0)
if (line.args[0] == 0)
{
P_AddSectorLinks(lines[i].frontsector, lines[i].args[1], lines[i].args[2], lines[i].args[3]);
P_AddSectorLinks(line.frontsector, line.args[1], line.args[2], line.args[3]);
}
break;
@ -1355,30 +1355,29 @@ void P_SpawnSpecials (void)
// arg 2 = 0:floor, 1:ceiling, 2:both
// arg 3 = 0: anchor, 1: reference line
// arg 4 = for the anchor only: alpha
if ((lines[i].args[1] == 0 || lines[i].args[1] == 6) && lines[i].args[3] == 0)
if ((line.args[1] == 0 || line.args[1] == 6) && line.args[3] == 0)
{
P_SpawnPortal(&lines[i], lines[i].args[0], lines[i].args[2], lines[i].args[4], lines[i].args[1]);
P_SpawnPortal(&line, line.args[0], line.args[2], line.args[4], line.args[1]);
}
else if (lines[i].args[1] == 3 || lines[i].args[1] == 4)
else if (line.args[1] == 3 || line.args[1] == 4)
{
line_t *line = &lines[i];
unsigned pnum = P_GetPortal(line->args[1] == 3 ? PORTS_PLANE : PORTS_HORIZON, line->args[2], line->frontsector, NULL, { 0,0 });
CopyPortal(line->args[0], line->args[2], pnum, 0, true);
unsigned pnum = P_GetPortal(line.args[1] == 3 ? PORTS_PLANE : PORTS_HORIZON, line.args[2], line.frontsector, NULL, { 0,0 });
CopyPortal(line.args[0], line.args[2], pnum, 0, true);
}
break;
case Line_SetPortal:
P_SpawnLinePortal(&lines[i]);
P_SpawnLinePortal(&line);
break;
// [RH] ZDoom Static_Init settings
case Static_Init:
switch (lines[i].args[1])
switch (line.args[1])
{
case Init_Gravity:
{
double grav = lines[i].Delta().Length() / 100.;
FSectorTagIterator itr(lines[i].args[0]);
double grav = line.Delta().Length() / 100.;
FSectorTagIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
level.sectors[s].gravity = grav;
}
@ -1389,8 +1388,8 @@ void P_SpawnSpecials (void)
case Init_Damage:
{
int damage = int(lines[i].Delta().Length());
FSectorTagIterator itr(lines[i].args[0]);
int damage = int(line.Delta().Length());
FSectorTagIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
{
sector_t *sec = &level.sectors[s];
@ -1416,8 +1415,8 @@ void P_SpawnSpecials (void)
break;
case Init_SectorLink:
if (lines[i].args[3] == 0)
P_AddSectorLinksByID(lines[i].frontsector, lines[i].args[0], lines[i].args[2]);
if (line.args[3] == 0)
P_AddSectorLinksByID(line.frontsector, line.args[0], line.args[2]);
break;
// killough 10/98:
@ -1431,9 +1430,9 @@ void P_SpawnSpecials (void)
case Init_TransferSky:
{
FSectorTagIterator itr(lines[i].args[0]);
FSectorTagIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
level.sectors[s].sky = (i + 1) | PL_SKYFLAT;
level.sectors[s].sky = (line.Index() + 1) | PL_SKYFLAT;
break;
}
}
@ -1499,10 +1498,9 @@ void P_SpawnSpecials (void)
static void P_SpawnFriction(void)
{
int i;
line_t *l = lines;
line_t *l = &level.lines[0];
for (i = 0 ; i < numlines ; i++,l++)
for (unsigned i = 0 ; i < level.lines.Size() ; i++,l++)
{
if (l->special == Sector_SetFriction)
{

View file

@ -47,7 +47,7 @@ FTagManager tagManager;
static inline int lineindex(const line_t *line)
{
return (int)(intptr_t)(line - lines);
return level.lines.Size();
}
//-----------------------------------------------------------------------------

View file

@ -447,10 +447,10 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
FLineIdIterator itr(id);
while ((i = itr.Next()) >= 0)
{
if (line-lines == i)
if (line->Index() == i)
continue;
if ((l=lines+i) != line && l->backsector)
if ((l=&level.lines[i]) != line && l->backsector)
{
// Get the thing's position along the source linedef
double pos;

View file

@ -1813,13 +1813,14 @@ public:
i++;
}
}
numlines = ParsedLines.Size();
unsigned numlines = ParsedLines.Size();
numsides = sidecount;
lines = new line_t[numlines];
level.lines.Alloc(numlines);
sides = new side_t[numsides];
int line, side;
auto lines = &level.lines[0];
for(line = 0, side = 0; line < numlines; line++)
for(line = 0, side = 0; line < (int)numlines; line++)
{
short tempalpha[2] = { SHRT_MIN, SHRT_MIN };

View file

@ -317,27 +317,27 @@ void P_TranslateTeleportThings ()
if (foundSomething)
{
for (int i = 0; i < numlines; ++i)
for (auto &line : level.lines)
{
if (lines[i].special == Teleport)
if (line.special == Teleport)
{
if (lines[i].args[1] == 0)
if (line.args[1] == 0)
{
lines[i].args[0] = 1;
line.args[0] = 1;
}
}
else if (lines[i].special == Teleport_NoFog)
else if (line.special == Teleport_NoFog)
{
if (lines[i].args[2] == 0)
if (line.args[2] == 0)
{
lines[i].args[0] = 1;
line.args[0] = 1;
}
}
else if (lines[i].special == Teleport_ZombieChanger)
else if (line.special == Teleport_ZombieChanger)
{
if (lines[i].args[1] == 0)
if (line.args[1] == 0)
{
lines[i].args[0] = 1;
line.args[0] = 1;
}
}
}

View file

@ -1575,7 +1575,7 @@ static void SpawnPolyobj (int index, int tag, int type)
{
if (!sides[i].linedef->args[1])
{
I_Error("SpawnPolyobj: Explicit line missing order number in poly %d, linedef %d.\n", tag, int(sides[i].linedef - lines));
I_Error("SpawnPolyobj: Explicit line missing order number in poly %d, linedef %d.\n", tag, sides[i].linedef->Index());
}
po->Sidedefs.Push (&sides[i]);
}
@ -1776,11 +1776,11 @@ void PO_Init (void)
}
}
// clear all polyobj specials so that they do not obstruct using other lines.
for (int i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
if (lines[i].special == Polyobj_ExplicitLine || lines[i].special == Polyobj_StartLine)
if (line.special == Polyobj_ExplicitLine || line.special == Polyobj_StartLine)
{
lines[i].special = 0;
line.special = 0;
}
}
}

View file

@ -115,7 +115,7 @@ static void BuildBlockmap()
while (*list != -1)
{
line_t *ld = &lines[*list++];
line_t *ld = &level.lines[*list++];
FLinePortal *port = ld->getPortal();
if (port && port->mType != PORTT_VISUAL)
{
@ -209,9 +209,9 @@ static line_t *FindDestination(line_t *src, int tag)
while ((lineno = it.Next()) >= 0)
{
if (&lines[lineno] != src)
if (&level.lines[lineno] != src)
{
return &lines[lineno];
return &level.lines[lineno];
}
}
}
@ -290,7 +290,7 @@ void P_SpawnLinePortal(line_t* line)
if (port->mType == PORTT_INTERACTIVE && port->mAlign != PORG_ABSOLUTE)
{
// Due to the way z is often handled, these pose a major issue for parts of the code that needs to transparently handle interactive portals.
Printf(TEXTCOLOR_RED "Warning: z-offsetting not allowed for interactive portals. Changing line %d to teleport-portal!\n", int(line - lines));
Printf(TEXTCOLOR_RED "Warning: z-offsetting not allowed for interactive portals. Changing line %d to teleport-portal!\n", line->Index());
port->mType = PORTT_TELEPORT;
}
}
@ -305,26 +305,26 @@ void P_SpawnLinePortal(line_t* line)
int mytag = tagManager.GetFirstLineID(line);
for (int i = 0; i < numlines; i++)
for (auto &ln : level.lines)
{
if (tagManager.GetFirstLineID(&lines[i]) == mytag && lines[i].args[0] == 1 && lines[i].special == Line_SetPortal)
if (tagManager.GetFirstLineID(&ln) == mytag && ln.args[0] == 1 && ln.special == Line_SetPortal)
{
line->portalindex = linePortals.Reserve(1);
FLinePortal *port = &linePortals.Last();
memset(port, 0, sizeof(FLinePortal));
port->mOrigin = line;
port->mDestination = &lines[i];
port->mDestination = &ln;
port->mType = PORTT_LINKED;
port->mAlign = PORG_ABSOLUTE;
port->mDefFlags = PORTF_TYPEINTERACTIVE;
// we need to create the backlink here, too.
lines[i].portalindex = linePortals.Reserve(1);
ln.portalindex = linePortals.Reserve(1);
port = &linePortals.Last();
memset(port, 0, sizeof(FLinePortal));
port->mOrigin = &lines[i];
port->mOrigin = &ln;
port->mDestination = line;
port->mType = PORTT_LINKED;
port->mAlign = PORG_ABSOLUTE;
@ -473,7 +473,7 @@ bool P_ChangePortal(line_t *ln, int thisid, int destid)
bool res = false;
while ((lineno = it.Next()) >= 0)
{
res |= ChangePortalLine(&lines[lineno], destid);
res |= ChangePortalLine(&level.lines[lineno], destid);
}
return res;
}
@ -868,13 +868,13 @@ static void AddDisplacementForPortal(FLinePortal *portal)
int othergroup = portal->mDestination->frontsector->PortalGroup;
if (thisgroup == othergroup)
{
Printf("Portal between lines %d and %d has both sides in same group\n", int(portal->mOrigin-lines), int(portal->mDestination-lines));
Printf("Portal between lines %d and %d has both sides in same group\n", portal->mOrigin->Index(), portal->mDestination->Index());
portal->mType = linePortals[portal->mDestination->portalindex].mType = PORTT_TELEPORT;
return;
}
if (thisgroup <= 0 || thisgroup >= Displacements.size || othergroup <= 0 || othergroup >= Displacements.size)
{
Printf("Portal between lines %d and %d has invalid group\n", int(portal->mOrigin - lines), int(portal->mDestination - lines));
Printf("Portal between lines %d and %d has invalid group\n", portal->mOrigin->Index(), portal->mDestination->Index());
portal->mType = linePortals[portal->mDestination->portalindex].mType = PORTT_TELEPORT;
return;
}
@ -889,7 +889,7 @@ static void AddDisplacementForPortal(FLinePortal *portal)
{
if (disp.pos != portal->mDisplacement)
{
Printf("Portal between lines %d and %d has displacement mismatch\n", int(portal->mOrigin - lines), int(portal->mDestination - lines));
Printf("Portal between lines %d and %d has displacement mismatch\n", portal->mOrigin->Index(), portal->mDestination->Index());
portal->mType = linePortals[portal->mDestination->portalindex].mType = PORTT_TELEPORT;
return;
}
@ -1057,11 +1057,11 @@ void P_CreateLinkedPortals()
bogus = true;
}
// mark everything that connects to a one-sided line
for (int i = 0; i < numlines; i++)
for (auto &line : level.lines)
{
if (lines[i].backsector == NULL && lines[i].frontsector->PortalGroup == 0)
if (line.backsector == nullptr && line.frontsector->PortalGroup == 0)
{
CollectSectors(-1, lines[i].frontsector);
CollectSectors(-1, line.frontsector);
}
}
// and now print a message for everything that still wasn't processed.

View file

@ -1337,6 +1337,11 @@ struct line_t
{
return portalindex >= linePortals.Size() ? 0 : linePortals[portalindex].mAlign;
}
int Index() const
{
return int(this - &level.lines[0]);
}
};
// phares 3/14/98

View file

@ -1347,7 +1347,7 @@ void R_DrawSkyPlane (visplane_t *pl)
else
{ // MBF's linedef-controlled skies
// Sky Linedef
const line_t *l = &lines[(pl->sky & ~PL_SKYFLAT)-1];
const line_t *l = &level.lines[(pl->sky & ~PL_SKYFLAT)-1];
// Sky transferred from first sidedef
const side_t *s = l->sidedef[0];

View file

@ -56,9 +56,6 @@ extern subsector_t* subsectors;
extern int numnodes;
extern node_t* nodes;
extern int numlines;
extern line_t* lines;
extern int numsides;
extern side_t* sides;

View file

@ -716,18 +716,23 @@ void InitThingdef()
auto secplanestruct = NewNativeStruct("Secplane", nullptr);
secplanestruct->Size = sizeof(secplane_t);
secplanestruct->Align = alignof(secplane_t);
auto sectorstruct = NewNativeStruct("Sector", nullptr);
sectorstruct->Size = sizeof(sector_t);
sectorstruct->Align = alignof(sector_t);
auto linestruct = NewNativeStruct("Line", nullptr);
linestruct->Size = sizeof(line_t);
linestruct->Align = alignof(line_t);
// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(NewNativeStruct("line", nullptr), false)), false), myoffsetof(sector_t, Lines), VARF_Native);
sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(linestruct, false)), false), myoffsetof(sector_t, Lines), VARF_Native);
// add the sector planes. These are value items of native structs so they have to be done here.
sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native);
sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native);
// add the sector planes. These are value items of native structs so they have to be done here. Write access should be through functions only to allow later optimization inside the renderer.
sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native|VARF_ReadOnly);
sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native|VARF_ReadOnly);
@ -747,6 +752,7 @@ void InitThingdef()
// Add the sector array to LevelLocals.
lstruct->AddNativeField("sectors", NewPointer(NewResizableArray(sectorstruct), false), myoffsetof(FLevelLocals, sectors), VARF_Native);
lstruct->AddNativeField("lines", NewPointer(NewResizableArray(linestruct), false), myoffsetof(FLevelLocals, lines), VARF_Native);
// set up a variable for the DEH data
PStruct *dstruct = NewNativeStruct("DehInfo", nullptr);

View file

@ -1478,7 +1478,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, player_t *&
template<> FSerializer &Serialize(FSerializer &arc, const char *key, line_t *&value, line_t **defval)
{
return SerializePointer(arc, key, value, defval, lines);
return SerializePointer(arc, key, value, defval, &level.lines[0]);
}
template<> FSerializer &Serialize(FSerializer &arc, const char *key, vertex_t *&value, vertex_t **defval)