- removed the now redundant wall() and sector() interator helper functions.

With both wall and sector now being TArrays they are not needed anymore.
This commit is contained in:
Christoph Oelckers 2021-12-21 09:23:39 +01:00
parent 6608096ea3
commit 65bc6e6aef
35 changed files with 79 additions and 90 deletions

View file

@ -422,7 +422,7 @@ void InitSpriteLists()
{
stat.firstEntry = stat.lastEntry = nullptr;
}
for (auto& sect : sectors())
for (auto& sect: sector)
{
sect.firstEntry = sect.lastEntry = nullptr;
}

View file

@ -167,7 +167,7 @@ static void CalcMapBounds()
y_max_bound = INT_MIN;
for(auto& wal : walls())
for(auto& wal : wall)
{
// get map min and max coordinates
if (wal.x < x_min_bound) x_min_bound = wal.x;

View file

@ -335,11 +335,10 @@ void GetFlatSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, bool
void checkRotatedWalls()
{
for (int i = 0; i < numwalls; ++i)
for (auto& w : wall)
{
if (wall[i].cstat & CSTAT_WALL_ROTATE_90)
if (w.cstat & CSTAT_WALL_ROTATE_90)
{
auto& w = wall[i];
auto& tile = RotTile(w.picnum + animateoffs(w.picnum, 16384));
if (tile.newtile == -1 && tile.owner == -1)

View file

@ -277,16 +277,6 @@ inline int32_t getangle(walltype* wal)
wal->point2Wall()->y - wal->y);
}
inline TArrayView<sectortype> sectors()
{
return TArrayView<sectortype>(&sector[0], numsectors);
}
inline TArrayView<walltype> walls()
{
return TArrayView<walltype>(&wall[0], numwalls);
}
inline TArrayView<walltype> wallsofsector(const sectortype* sec)
{
return TArrayView<walltype>(sec->firstWall(), sec->wallnum);

View file

@ -401,7 +401,7 @@ void allocateMapArrays(int numsprites)
void fixSectors()
{
for(auto& sect : sectors())
for(auto& sect: sector)
{
// Fix maps which do not set their wallptr to the first wall of the sector. Lo Wang In Time's map 11 is such a case.
auto wp = sect.firstWall();
@ -536,7 +536,7 @@ void loadMapBackup(const char* filename)
void setWallSectors()
{
int i = 0;
for (auto& wal : walls())
for (auto& wal : wall)
{
wal.sector = -1;
wal.lengthflags = 3;
@ -588,7 +588,7 @@ void setWallSectors()
}
}
for(auto& sect : sectors())
for(auto& sect: sector)
{
sect.dirty = EDirty::AllDirty;
sect.exflags = 0;
@ -612,7 +612,7 @@ void setWallSectors()
}
// validate 'nextsector' fields. Some maps have these wrong which can cause render glitches and occasionally even crashes.
for (auto& wal : walls())
for (auto& wal : wall)
{
if (validWallIndex(wal.nextwall))
{
@ -634,7 +634,7 @@ void MarkMap()
GC::Mark(stat.firstEntry);
GC::Mark(stat.lastEntry);
}
for (auto& sect : sectors())
for (auto& sect: sector)
{
GC::Mark(sect.firstEntry);
GC::Mark(sect.lastEntry);

View file

@ -645,7 +645,7 @@ inline walltype* walltype::lastWall() const
if (index > 0 && wall[index - 1].point2 == index) return &wall[index - 1];
int check = index;
for (int i = 0; i < numwalls; i++)
for (int i = 0; i < 16384; i++) // don't run endlessly in case of malformed sectors.
{
int next = wall[check].point2;
if (next == index) return &wall[check];

View file

@ -682,7 +682,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
switch (header.version & 0xff)
{
case 0:
for (auto& sect : sectors())
for (auto& sect: sector)
{
sectortype* pSector = &sect;
if (pSector->hasX())
@ -706,7 +706,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
}
[[fallthrough]];
case 1:
for (auto& sect : sectors())
for (auto& sect: sector)
{
sectortype* pSector = &sect;
if (pSector->hasX())

View file

@ -280,7 +280,7 @@ void evInit(TArray<DBloodActor*>& actors)
memset(rxBucket, 0, sizeof(rxBucket));
// add all the tags to the bucket array
for(auto& sect : sectors())
for(auto& sect: sector)
{
if (sect.hasX() && sect.xs().rxID > 0)
{
@ -290,7 +290,7 @@ void evInit(TArray<DBloodActor*>& actors)
}
}
for(auto& wal: walls())
for(auto& wal: wall)
{
if (wal.hasX() && wal.xw().rxID > 0)
{

View file

@ -60,7 +60,7 @@ bool FindSector(int nX, int nY, int nZ, sectortype** pSector)
}
}
}
for(auto& sec : sectors())
for(auto& sec: sector)
{
if (inside(nX, nY, &sec))
{
@ -91,7 +91,7 @@ bool FindSector(int nX, int nY, sectortype** pSector)
return 1;
}
}
for (auto& sec : sectors())
for (auto& sec: sector)
{
if (inside(nX, nY, &sec))
{

View file

@ -825,7 +825,7 @@ void nnExtInitModernStuff(TArray<DBloodActor*>& actors)
pCond->obj[count++].cmd = (uint8_t)pXSpr->command;
}
for (auto& sect : sectors())
for (auto& sect: sector)
{
if (!sect.hasX() || sect.xs().txID != pXSprite->rxID) continue;
else if (count >= kMaxTracedObjects)
@ -835,7 +835,7 @@ void nnExtInitModernStuff(TArray<DBloodActor*>& actors)
pCond->obj[count++].cmd = sect.xs().command;
}
for(auto& wal : walls())
for(auto& wal : wall)
{
if (!wal.hasX() || wal.xw().txID != pXSprite->rxID)
continue;
@ -2854,7 +2854,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
pXLower = &aLower->x();
// must be sure we found exact same upper link
for (auto& sec : sectors())
for (auto& sec: sector)
{
auto aUpper = barrier_cast<DBloodActor*>(sec.upperLink);
if (aUpper == nullptr || aUpper->x().data1 != pXLower->data1) continue;
@ -3026,7 +3026,7 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
if (aLink)
{
// must be sure we found exact same upper link
for(auto& sec : sectors())
for(auto& sec: sector)
{
auto aUpper = barrier_cast<DBloodActor*>(sec.upperLink);
if (aUpper == nullptr || aUpper->x().data1 != aLink->x().data1) continue;

View file

@ -246,14 +246,14 @@ void PreloadCache()
if (!r_precache) return;
int skyTile = -1;
// Fonts
for(auto& sect : sectors())
for(auto& sect: sector)
{
tilePrecacheTile(sect.floorpicnum, 0, sect.floorpal);
tilePrecacheTile(sect.ceilingpicnum, 0, sect.ceilingpal);
if ((sect.ceilingstat & CSTAT_SECTOR_SKY) != 0 && skyTile == -1)
skyTile = sect.ceilingpicnum;
}
for(auto& wal : walls())
for(auto& wal : wall)
{
tilePrecacheTile(wal.picnum, 0, wal.pal);
if (wal.overpicnum >= 0)

View file

@ -196,7 +196,7 @@ void DoSectorLighting(void)
void UndoSectorLighting(void)
{
for (auto& sect : sectors())
for (auto& sect: sector)
{
if (sect.hasX())
{
@ -307,7 +307,7 @@ void InitSectorFX(void)
shadeList.Clear();
panList.Clear();
wallPanList.Clear();
for (auto& sect : sectors())
for (auto& sect: sector)
{
if (sect.hasX())
{
@ -332,7 +332,7 @@ void InitSectorFX(void)
}
}
}
for(auto& wal : walls())
for(auto& wal : wall)
{
if (wal.hasX())
{

View file

@ -1817,7 +1817,7 @@ void trMessageSprite(DBloodActor* actor, EVENT event)
void ProcessMotion(void)
{
for(auto& sect : sectors())
for(auto& sect: sector)
{
sectortype* pSector = &sect;
@ -1892,7 +1892,7 @@ void ProcessMotion(void)
void AlignSlopes(void)
{
for(auto& sect : sectors())
for(auto& sect: sector)
{
if (sect.slopewallofs)
{
@ -1926,7 +1926,7 @@ int(*gBusyProc[])(sectortype*, unsigned int) =
void trProcessBusy(void)
{
for (auto& sect : sectors())
for (auto& sect: sector)
{
sect.velCeil = sect.velFloor = 0;
}
@ -1964,7 +1964,7 @@ void InitGenerator(DBloodActor*);
void trInit(TArray<DBloodActor*>& actors)
{
gBusy.Clear();
for(auto& wal : walls())
for(auto& wal : wall)
for (int i = 0; i < numwalls; i++)
{
wal.baseWall.x = wal.x;
@ -1977,7 +1977,7 @@ void trInit(TArray<DBloodActor*>& actors)
spr->inittype = spr->type;
actor->basePoint = spr->pos;
}
for(auto& wal : walls())
for(auto& wal : wall)
{
if (wal.hasX())
{
@ -1987,7 +1987,7 @@ void trInit(TArray<DBloodActor*>& actors)
}
}
for(auto& sect : sectors())
for(auto& sect: sector)
{
sectortype *pSector = &sect;
pSector->baseFloor = pSector->floorz;

View file

@ -38,7 +38,7 @@ ZONE gStartZone[8];
void validateLinks()
{
int snum = 0;
for (auto& sect : sectors())
for (auto& sect: sector)
{
DCoreActor* upper = sect.upperLink;
if (upper && !static_cast<DBloodActor*>(upper)->GetOwner())
@ -161,7 +161,7 @@ void warpInit(TArray<DBloodActor*>& actors)
}
#endif
for(auto& sect : sectors())
for(auto& sect: sector)
{
auto actor = barrier_cast<DBloodActor*>(sect.upperLink);
if (actor && actor->hasX())
@ -169,7 +169,7 @@ void warpInit(TArray<DBloodActor*>& actors)
spritetype *pSprite = &actor->s();
XSPRITE *pXSprite = &actor->x();
int nLink = pXSprite->data1;
for(auto& sect : sectors())
for(auto& sect: sector)
{
auto actor2 = barrier_cast<DBloodActor*>(sect.lowerLink);
if (actor2 && actor2->hasX())

View file

@ -101,7 +101,7 @@ static const char *cheatGod(int myconnectindex, int state)
static const char* cheatUnlock()
{
if (isShareware()) return nullptr;
for (auto&sect : sectors())
for (auto&sect: sector)
{
int j = sect.lotag;
if (j == -1 || j == 32767) continue;

View file

@ -686,7 +686,7 @@ void prelevel_common(int g)
memset(ambienthitag, -1, sizeof(ambienthitag));
memset(ambientlotag, -1, sizeof(ambientlotag));
for(auto&sec : sectors())
for(auto&sec: sector)
{
auto sectp = &sec;
sectp->extra = 256;
@ -819,7 +819,7 @@ void donewgame(MapRecord* map, int sk)
static void SpawnPortals()
{
for (auto& wal : walls())
for (auto& wal : wall)
{
if (wal.overpicnum == TILE_MIRROR && (wal.cstat & CSTAT_WALL_1WAY)) wal.portalflags |= PORTAL_WALL_MIRROR;
}
@ -1084,7 +1084,7 @@ void enterlevel(MapRecord *mi, int gamemode)
setLevelStarted(mi);
if (isRRRA() && ps[screenpeek].sea_sick_stat == 1)
{
for (auto& wal : walls())
for (auto& wal : wall)
{
if (wal.picnum == 7873 || wal.picnum == 7870)
StartInterpolation(&wal, Interp_Wall_PanX);

View file

@ -236,14 +236,14 @@ void cacheit_d(void)
cachegoodsprites();
for (auto& wal : walls())
for (auto& wal : wall)
{
tloadtile(wal.picnum, wal.pal);
if (wal.overpicnum >= 0)
tloadtile(wal.overpicnum, wal.pal);
}
for (auto& sect : sectors())
for (auto& sect: sector)
{
tloadtile(sect.floorpicnum, sect.floorpal);
tloadtile(sect.ceilingpicnum, sect.ceilingpal);
@ -381,7 +381,7 @@ void prelevel_d(int g, TArray<DDukeActor*>& actors)
mirrorcnt = 0;
for (auto& wal : walls())
for (auto& wal : wall)
{
if (wal.overpicnum == MIRROR && (wal.cstat & CSTAT_WALL_1WAY) != 0)
{

View file

@ -374,14 +374,14 @@ void cacheit_r(void)
cachegoodsprites();
for (auto& wal : walls())
for (auto& wal : wall)
{
tloadtile(wal.picnum, wal.pal);
if(wal.overpicnum >= 0)
tloadtile(wal.overpicnum, wal.pal);
}
for (auto& sect : sectors())
for (auto& sect: sector)
{
tloadtile(sect.floorpicnum, sect.floorpal);
tloadtile(sect.ceilingpicnum, sect.ceilingpal);
@ -454,7 +454,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
}
}
for (auto&sect : sectors())
for (auto&sect: sector)
{
auto sectp = &sect;
if (sectp->ceilingpicnum == RRTILE2577)
@ -481,7 +481,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
deletesprite(act);
}
}
for(auto& osect : sectors())
for(auto& osect: sector)
{
if (sectp->hitag == osect.hitag && &osect != sectp)
{
@ -716,7 +716,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
mirrorcnt = 0;
for (auto& wl : walls())
for (auto& wl : wall)
{
walltype* wal = &wl;

View file

@ -417,7 +417,7 @@ bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act)
}
}
for (auto& wal : walls())
for (auto& wal : wall)
{
if (lotag == wal.lotag)
switch (wal.picnum)

View file

@ -202,7 +202,7 @@ void animatewalls_r(void)
if (isRRRA() &&ps[screenpeek].sea_sick_stat == 1)
{
for (auto& wal : walls())
for (auto& wal : wall)
{
if (wal.picnum == RRTILE7873)
wal.addxpan(6);
@ -601,7 +601,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
}
}
for (auto& wal : walls())
for (auto& wal : wall)
{
if (lotag == wal.lotag)
switch (wal.picnum)

View file

@ -38,7 +38,7 @@ void precache()
{
if (!r_precache) return;
for (auto& sect: sectors())
for (auto& sect: sector)
{
int j = sect.ceilingpicnum;
markTileForPrecache(j, sect.ceilingpal);
@ -51,7 +51,7 @@ void precache()
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, sect.floorpal);
}
for(auto& wal : walls())
for(auto& wal : wall)
{
int j = wal.picnum;
markTileForPrecache(j, wal.pal);

View file

@ -783,7 +783,7 @@ void LoadObjects(TArray<DExhumedActor*>& actors)
InitElev();
InitWallFace();
for (auto& sect : sectors())
for (auto& sect: sector)
{
int hitag = sect.hitag;
int lotag = sect.lotag;
@ -801,7 +801,7 @@ void LoadObjects(TArray<DExhumedActor*>& actors)
}
}
for (auto& wal : walls())
for (auto& wal : wall)
{
wal.extra = -1;

View file

@ -32,7 +32,7 @@ bool bShowTowers = false;
void GrabMap()
{
for(auto&sec : sectors())
for(auto&sec: sector)
MarkSectorSeen(&sec);
}

View file

@ -1490,7 +1490,7 @@ void DimLights()
if (word_96786 == 0)
return;
for (auto&sect : sectors())
for (auto&sect: sector)
{
if (sect.ceilingshade < 100)
sect.ceilingshade++;
@ -1722,7 +1722,7 @@ void ExplodeEnergyBlock(DExhumedActor* pActor)
lFinaleStart = lFinaleStart + 1;
}
for(auto& sect : sectors())
for(auto& sect: sector)
{
if (sect.ceilingpal == 1) {
sect.ceilingpal = 0;
@ -2529,7 +2529,7 @@ void PostProcess()
if (!(currentLevel->gameflags & LEVEL_EX_COUNTDOWN))
{
for (auto& sect : sectors())
for (auto& sect: sector)
{
int var_20 = 30000;
@ -2540,7 +2540,7 @@ void PostProcess()
}
else
{
for (auto& sectj : sectors())
for (auto& sectj: sector)
{
// loc_23CA6:
@ -2562,7 +2562,7 @@ void PostProcess()
}
else // nMap == kMap20)
{
for(auto& sect : sectors())
for(auto& sect: sector)
{
sect.pSoundSect = &sect;
sect.Sound = StaticSound[kSound62];

View file

@ -346,7 +346,7 @@ void DrawView(double smoothRatio, bool sceneonly)
if (HavePLURemap())
{
auto p = paldata.Data();
for (auto& sect : sectors())
for (auto& sect: sector)
{
uint8_t v;
v = *p++ = sect.floorpal;
@ -354,7 +354,7 @@ void DrawView(double smoothRatio, bool sceneonly)
v = *p++ = sect.ceilingpal;
sect.ceilingpal = RemapPLU(v);
}
for (auto& wal : walls())
for (auto& wal : wall)
{
uint8_t v;
v = *p++ = wal.pal;
@ -377,12 +377,12 @@ void DrawView(double smoothRatio, bool sceneonly)
if (HavePLURemap())
{
auto p = paldata.Data();
for (auto& sect : sectors())
for (auto& sect: sector)
{
sect.floorpal = *p++;
sect.ceilingpal = *p++;
}
for (auto& wal : walls())
for (auto& wal : wall)
{
wal.pal = *p++;
}

View file

@ -1034,7 +1034,7 @@ void DoWallBreakMatch(int match)
int x,y,z;
int wall_ang;
for(auto& wal : walls())
for(auto& wal : wall)
{
if (wal.hitag == match)
{

View file

@ -77,7 +77,7 @@ void precacheMap(void)
WALLp wp;
SPRITEp sp;
for(auto& sec : sectors())
for(auto& sec: sector)
{
j = sec.ceilingpicnum;
markTileForPrecache(j, sec.ceilingpal);
@ -104,7 +104,7 @@ void precacheMap(void)
}
for (auto& wal : walls())
for (auto& wal : wall)
{
j = wal.picnum;

View file

@ -239,7 +239,7 @@ static void ItemCheat(int player)
PlayerUpdateInventory(p, p->InventoryNum);
for (auto& sect : sectors())
for (auto& sect: sector)
{
if (sect.hasU() && sect.stag == SECT_LOCK_DOOR)
sect.number = 0; // unlock all doors of this type

View file

@ -224,7 +224,7 @@ void JS_SpriteSetup(void)
}
}
// Check for certain walls to make sounds
for(auto& wal : walls())
for(auto& wal : wall)
{
int picnum = wal.picnum;
@ -279,7 +279,7 @@ void JS_InitMirrors(void)
mirror[i].ismagic = false;
}
for(auto& wal : walls())
for(auto& wal : wall)
{
if (wal.twoSided() && (wal.overpicnum == MIRROR) && (wal.cstat & CSTAT_WALL_1WAY))
{

View file

@ -3918,7 +3918,7 @@ int GetOverlapSector(int x, int y, sectortype** over, sectortype** under)
// if nothing was found, check them all
if (found == 0)
{
for (auto& sect : sectors())
for (auto& sect: sector)
{
if (inside(x, y, &sect))
{

View file

@ -617,7 +617,7 @@ void GetUpperLowerSector(short match, int x, int y, sectortype** upper, sectorty
int sln = 0;
SPRITEp sp;
for(auto& sect : sectors())
for(auto& sect: sector)
{
if (inside(x, y, &sect) == 1)
{

View file

@ -126,7 +126,7 @@ void WallSetupDontMove(void)
if (spu->lotag == spl->lotag)
{
for(auto& wal : walls())
for(auto& wal : wall)
{
if (wal.x < spl->x && wal.x > spu->x && wal.y < spl->y && wal.y > spu->y)
{
@ -169,7 +169,7 @@ void WallSetup(void)
extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound;
for (auto& wal : walls())
for (auto& wal : wall)
{
auto wp = &wal;
if (wp->picnum == FAF_PLACE_MIRROR_PIC)
@ -392,7 +392,7 @@ void SectorSetup(void)
LevelSecrets = 0;
for(auto&sect : sectors())
for(auto&sect: sector)
{
auto const sectp = &sect;
tag = sectp->lotag;
@ -1589,7 +1589,7 @@ int OperateSprite(DSWActor* actor, short player_is_operating)
key_num = sp->hitag;
if (pp->HasKey[key_num - 1])
{
for(auto& sect : sectors())
for(auto& sect: sector)
{
if (sect.hasU() && sect.stag == SECT_LOCK_DOOR && sect.number == key_num)
sect.number = 0; // unlock all doors of this type

View file

@ -1606,7 +1606,7 @@ void SpriteSetup(void)
// Clear Sprite Extension structure
// Clear all extra bits - they are set by sprites
for(auto& sect : sectors())
for(auto& sect: sector)
{
sect.extra = 0;
}

View file

@ -781,7 +781,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECTp sop)
// look through all sectors for whole sectors that are IN bounds
for (auto&sec : sectors())
for (auto&sec: sector)
{
auto sect = &sec;
@ -2197,7 +2197,7 @@ void CallbackSOsink(ANIMp ap, void *data)
tgt_depth = FixedToInt(srcsect->depth_fixed);
for(auto& sect : sectors())
for(auto& sect: sector)
{
if (&sect == destsect)
{

View file

@ -102,7 +102,7 @@ int DoWallMove(DSWActor* actor)
nx = MulScale(dist, bcos(ang), 14);
ny = MulScale(dist, bsin(ang), 14);
for(auto& wal : walls())
for(auto& wal : wall)
{
if (wal.x == sp->x && wal.y == sp->y)
{