From c23db8ea3578a11f352b0d8ae284c53352c0dec9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2022 12:21:21 +0100 Subject: [PATCH] - wrapped all reads of sectortype::wallnum and renamed all other wallnum variables. --- source/build/src/clip.cpp | 2 +- source/core/gamefuncs.cpp | 4 ++-- source/core/gamefuncs.h | 2 +- source/core/maploader.cpp | 16 +++++++--------- source/core/maptypes.h | 5 +++-- source/core/postprocessor.cpp | 4 ++-- source/core/rendering/hw_sections.cpp | 2 +- source/core/rendering/scene/hw_drawinfo.cpp | 8 ++++---- source/core/rendering/scene/hw_portal.cpp | 2 +- source/games/blood/src/blood.h | 2 +- source/games/blood/src/mirrors.cpp | 10 +++++----- source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/actors_r.cpp | 4 ++-- source/games/duke/src/funct.h | 2 +- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/savegame.cpp | 2 +- source/games/duke/src/sectors.cpp | 8 ++++---- source/games/exhumed/src/move.cpp | 2 +- source/games/exhumed/src/object.cpp | 2 +- source/games/exhumed/src/player.cpp | 2 +- source/games/sw/src/sector.cpp | 4 ++-- source/games/sw/src/sprite.cpp | 2 +- 22 files changed, 44 insertions(+), 45 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index eccf4bbc2..60b9f4454 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -250,7 +250,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, auto const sec = §or[dasect]; int const startwall = sec->wallptr; - int const endwall = startwall + sec->wallnum; + int const endwall = startwall + sec->wall_count(); auto wal = &wall[startwall]; for (int j=startwall; jwallnum < 3) return -1; + if (sec->wall_count() < 3) return -1; auto wal = sec->firstWall(); double len = wal->Length(); @@ -1218,7 +1218,7 @@ int pushmove(DVector3& pos, sectortype** pSect, double walldist, double ceildist while (auto sec = search.GetNext()) { // this must go both forward and backward so we cannot use wallsofsector. Pity - for (int i = 0; i < sec->wallnum; i++) + for (int i = 0; i < sec->wall_count(); i++) { auto wal = direction > 0 ? sec->firstWall() + i : sec->lastWall() - i; diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 8e1d72d88..e52e473d1 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -465,7 +465,7 @@ inline int I_GetBuildTime() inline TArrayView wallsofsector(const sectortype* sec) { - return TArrayView(sec->firstWall(), sec->wallnum); + return TArrayView(sec->firstWall(), sec->wall_count()); } inline TArrayView wallsofsector(int sec) diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 72f1b0acf..0f13145ef 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -250,11 +250,9 @@ static void SetWallPalV5() { for (unsigned i = 0; i < sector.Size(); i++) { - int startwall = sector[i].wallptr; - int endwall = startwall + sector[i].wallnum; - for (int w = startwall; w < endwall; w++) + for(auto& wal : wallsofsector(i)) { - wall[w].pal = sector[i].floorpal; + wal.pal = sector[i].floorpal; } } } @@ -757,11 +755,11 @@ void setWallSectors() auto sect = §or[i]; auto nextsect = §or[i + 1]; - if (sect->wallptr < nextsect->wallptr && sect->wallptr + sect->wallnum > nextsect->wallptr) + if (sect->wallptr < nextsect->wallptr && sect->wallptr + sect->wall_count() > nextsect->wallptr) { // We have overlapping wall ranges for two sectors. Do some analysis to see where these walls belong int checkstart = nextsect->wallptr; - int checkend = sect->wallptr + sect->wallnum; + int checkend = sect->wallptr + sect->wall_count(); // for now assign the walls to the first sector. Final decisions are made below. nextsect->wallnum -= checkend - checkstart; @@ -783,16 +781,16 @@ void setWallSectors() sect->wallnum = checkstart - sect->wallptr; - while (checkstart < checkend && belongs(checkend - 1, checkend, nextsect->wallptr + nextsect->wallnum, checkstart)) + while (checkstart < checkend && belongs(checkend - 1, checkend, nextsect->wallptr + nextsect->wall_count(), checkstart)) checkend--; nextsect->wallnum += nextsect->wallptr - checkend; nextsect->wallptr = checkend; - if (nextsect->wallptr > sect->wallptr + sect->wallnum) + if (nextsect->wallptr > sect->wallptr + sect->wall_count()) { // If there's a gap, assign to the first sector. In this case we may only guess. - Printf("Wall range %d - %d referenced by sectors %d and %d\n", sect->wallptr + sect->wallnum, nextsect->wallptr - 1, i, i + 1); + Printf("Wall range %d - %d referenced by sectors %d and %d\n", sect->wallptr + sect->wall_count(), nextsect->wallptr - 1, i, i + 1); sect->wallnum = nextsect->wallptr - sect->wallptr; } } diff --git a/source/core/maptypes.h b/source/core/maptypes.h index c50836d6b..26c13f821 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -350,6 +350,7 @@ struct sectortype int getceilingslope() const { return ceilingstat & CSTAT_SECTOR_SLOPE ? ceilingheinum : 0; } walltype* firstWall() const; walltype* lastWall() const; + int wall_count() const { return wallnum; } Blood::XSECTOR& xs() const { return *_xs; } @@ -555,9 +556,9 @@ inline bool validSectorIndex(int sectnum) return (unsigned)sectnum < sector.Size(); } -inline bool validWallIndex(int wallnum) +inline bool validWallIndex(int wallno) { - return (unsigned)wallnum < wall.Size(); + return (unsigned)wallno < wall.Size(); } inline sectortype* walltype::nextSector() const diff --git a/source/core/postprocessor.cpp b/source/core/postprocessor.cpp index 2230a7beb..46bcd7eeb 100644 --- a/source/core/postprocessor.cpp +++ b/source/core/postprocessor.cpp @@ -124,8 +124,8 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SplitSector) if (sectornum < sector.Size()) { - if (firstwall >= sector[sectornum].wallptr && firstwall < sector[sectornum].wallptr + sector[sectornum].wallnum && - secondwall >= sector[sectornum].wallptr && secondwall < sector[sectornum].wallptr + sector[sectornum].wallnum) + if (firstwall >= sector[sectornum].wallptr && firstwall < sector[sectornum].wallptr + sector[sectornum].wall_count() && + secondwall >= sector[sectornum].wallptr && secondwall < sector[sectornum].wallptr + sector[sectornum].wall_count()) hw_SetSplitSector(sectornum, firstwall, secondwall); } diff --git a/source/core/rendering/hw_sections.cpp b/source/core/rendering/hw_sections.cpp index 3934dfc25..259fa9fb0 100644 --- a/source/core/rendering/hw_sections.cpp +++ b/source/core/rendering/hw_sections.cpp @@ -224,7 +224,7 @@ static void CollectLoops(TArray& sectors) for (unsigned i = 0; i < sector.Size(); i++) { int first = sector[i].wallptr; - int last = first + sector[i].wallnum; + int last = first + sector[i].wall_count(); sectors.Reserve(1); sectors.Last().bugged = 0; diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index 62e00aa3e..c2a0cf556 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -408,7 +408,7 @@ void HWDrawInfo::CreateScene(bool portal) for (int i = 0; i < eff.geocnt; i++) { auto sect = eff.geosectorwarp[i]; - for (auto w = 0; w < sect->wallnum; w++) + for (auto w = 0; w < sect->wall_count(); w++) { auto wal = sect->firstWall() + w; wal->pos.X += eff.geox[i]; @@ -427,7 +427,7 @@ void HWDrawInfo::CreateScene(bool portal) for (int i = 0; i < eff.geocnt; i++) { auto sect = eff.geosectorwarp[i]; - for (auto w = 0; w < sect->wallnum; w++) + for (auto w = 0; w < sect->wall_count(); w++) { auto wal = sect->firstWall() + w; wal->pos.X -= eff.geox[i]; @@ -440,7 +440,7 @@ void HWDrawInfo::CreateScene(bool portal) for (int i = 0; i < eff.geocnt; i++) { auto sect = eff.geosectorwarp2[i]; - for (auto w = 0; w < sect->wallnum; w++) + for (auto w = 0; w < sect->wall_count(); w++) { auto wal = sect->firstWall() + w; wal->pos.X += eff.geox2[i]; @@ -458,7 +458,7 @@ void HWDrawInfo::CreateScene(bool portal) for (int i = 0; i < eff.geocnt; i++) { auto sect = eff.geosectorwarp2[i]; - for (auto w = 0; w < sect->wallnum; w++) + for (auto w = 0; w < sect->wall_count(); w++) { auto wal = sect->firstWall() + w; wal->pos.X -= eff.geox2[i]; diff --git a/source/core/rendering/scene/hw_portal.cpp b/source/core/rendering/scene/hw_portal.cpp index 83129beb1..6b19e233d 100644 --- a/source/core/rendering/scene/hw_portal.cpp +++ b/source/core/rendering/scene/hw_portal.cpp @@ -478,7 +478,7 @@ int HWLinePortal::ClipSeg(walltype *seg, const DVector3 &viewpos) int HWLinePortal::ClipSector(sectortype *sub) { // this seg is completely behind the mirror - for (int i = 0; iwallnum; i++) + for (int i = 0; iwall_count(); i++) { if (PointOnLineSide(sub->firstWall()->pos, line) == 0) return PClip_Inside; } diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index af07206c6..4cd9cf5eb 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -88,7 +88,7 @@ struct MIRROR int type; int link; DVector3 diff; - int wallnum; + int mynum; }; extern MIRROR mirror[16]; diff --git a/source/games/blood/src/mirrors.cpp b/source/games/blood/src/mirrors.cpp index ceb4d09b1..83733955d 100644 --- a/source/games/blood/src/mirrors.cpp +++ b/source/games/blood/src/mirrors.cpp @@ -63,7 +63,7 @@ void InitMirrors(void) { pWalli->overpicnum = nTile; - mirror[mirrorcnt].wallnum = i; + mirror[mirrorcnt].mynum = i; mirror[mirrorcnt].type = 0; pWalli->cstat |= CSTAT_WALL_1WAY; int tmp = pWalli->xw().data; @@ -99,7 +99,7 @@ void InitMirrors(void) if (pWalli->picnum == 504) { mirror[mirrorcnt].link = i; - mirror[mirrorcnt].wallnum = i; + mirror[mirrorcnt].mynum = i; pWalli->picnum = nTile; mirror[mirrorcnt].type = 0; pWalli->cstat |= CSTAT_WALL_1WAY; @@ -129,7 +129,7 @@ void InitMirrors(void) I_Error("Lower link sector %d doesn't have mirror picnum\n", j); mirror[mirrorcnt].type = 2; mirror[mirrorcnt].diff = link2->spr.pos - link->spr.pos; - mirror[mirrorcnt].wallnum = i; + mirror[mirrorcnt].mynum = i; mirror[mirrorcnt].link = j; secti->floorpicnum = 4080 + mirrorcnt; secti->portalflags = PORTAL_SECTOR_FLOOR; @@ -137,7 +137,7 @@ void InitMirrors(void) mirrorcnt++; mirror[mirrorcnt].type = 1; mirror[mirrorcnt].diff = link->spr.pos - link2->spr.pos; - mirror[mirrorcnt].wallnum = j; + mirror[mirrorcnt].mynum = j; mirror[mirrorcnt].link = i; sectj->ceilingpicnum = 4080 + mirrorcnt; sectj->portalflags = PORTAL_SECTOR_CEILING; @@ -162,7 +162,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRROR& w, MIRROR* arc("type", w.type) ("link", w.link) ("diff", w.diff) - ("wallnum", w.wallnum) + ("wallnum", w.mynum) .EndObject(); } return arc; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index b797d2ab2..45def93ce 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -3466,7 +3466,7 @@ void moveeffectors_d(void) //STATNUM 3 { if (act->spr.lotag != SE_29_WAVES) continue; auto sc = act->sector(); - if (sc->wallnum != 4) continue; + if (sc->wall_count() != 4) continue; auto wal = sc->firstWall() + 2; if (wal->nextSector()) alignflorslope(act->sector(), DVector3(wal->pos, wal->nextSector()->floorz)); } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 68552199d..4b1ea32b9 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -3385,7 +3385,7 @@ void moveeffectors_r(void) //STATNUM 3 { if (act->spr.lotag != SE_29_WAVES) continue; auto sc = act->sector(); - if (sc->wallnum != 4) continue; + if (sc->wall_count() != 4) continue; auto wal = sc->firstWall() + 2; if (wal->nextSector()) alignflorslope(act->sector(), DVector3(wal->pos, wal->nextSector()->floorz)); } @@ -3850,7 +3850,7 @@ void destroyit(DDukeActor *actor) auto destwal = destsect->firstWall(); auto srcwal = srcsect->firstWall(); - for (int i = 0; i < destsect->wallnum; i++, srcwal++, destwal++) + for (int i = 0; i < destsect->wall_count(); i++, srcwal++, destwal++) { destwal->picnum = srcwal->picnum; destwal->overpicnum = srcwal->overpicnum; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 5ddfafda4..fbe4a4d39 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -177,7 +177,7 @@ DDukeActor* SpawnActor(sectortype* whatsectp, const DVector3& pos, PClassActor* void ceilingglass(DDukeActor* snum, sectortype* sectnum, int cnt); void spriteglass(DDukeActor* snum, int cnt); void lotsofcolourglass(DDukeActor* snum, walltype* wallNum, int cnt); -void lotsofglass(DDukeActor* snum, walltype* wallnum, int cnt); +void lotsofglass(DDukeActor* snum, walltype* wal, int cnt); void checkplayerhurt_d(player_struct* p, const Collision& coll); void checkplayerhurt_r(player_struct* p, const Collision& coll); DDukeActor* dospawnsprite(DDukeActor* actj, int pn); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 8a2c530f5..a432eae5d 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1055,7 +1055,7 @@ void DoSector(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, if (!bSet) SetGameVarID(lVar2, sectp->wallptr, sActor, sPlayer); break; case SECTOR_WALLNUM: - if (!bSet) SetGameVarID(lVar2, sectp->wallnum, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, sectp->wall_count(), sActor, sPlayer); break; case SECTOR_CEILINGZ: if (bSet) sectp->setceilingz(lValue * zmaptoworld); diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 5c7c8909d..5e84d50b9 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -51,7 +51,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, animwalltype& w, a { if (arc.BeginObject(keyname)) { - arc("wallnum", w.wall) + arc("wall", w.wall) ("tag", w.tag) .EndObject(); } diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index c59d3038e..df7d328c6 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -537,8 +537,8 @@ static void handle_st09(sectortype* sptr, DDukeActor* actor) dax += wal.pos.X; day += wal.pos.Y; } - dax /= sptr->wallnum; - day /= sptr->wallnum; + dax /= sptr->wall_count(); + day /= sptr->wall_count(); //find any points with either same x or same y coordinate // as center (dax, day) - should be 2 points found. @@ -560,7 +560,7 @@ static void handle_st09(sectortype* sptr, DDukeActor* actor) //find what direction door should open by averaging the // 2 neighboring points of wallfind[0] & wallfind[1]. auto prevwall = wal - 1; - if (prevwall < sptr->firstWall()) prevwall += sptr->wallnum; + if (prevwall < sptr->firstWall()) prevwall += sptr->wall_count(); if ((wal->pos.X == dax) && (wal->pos.Y == day)) { @@ -1117,7 +1117,7 @@ void operateactivators(int low, int plnum) sect->floorshade = sect->ceilingshade = (int8_t)p->shade2; wal = sect->firstWall(); - for (j = sect->wallnum; j > 0; j--, wal++) + for (j = sect->wall_count(); j > 0; j--, wal++) wal->shade = (int8_t)p->shade2; } } diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index 71557af36..2fba3dfa1 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -723,7 +723,7 @@ void CreatePushBlock(sectortype* pSector) sum += wal.pos; } - DVector2 avg = sum / pSector->wallnum; + DVector2 avg = sum / pSector->wall_count(); sBlockInfo[nBlock].pos = avg; diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index ece0a0671..667a17d9c 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1627,7 +1627,7 @@ DExhumedActor* BuildEnergyBlock(sectortype* pSector) auto pActor = insertActor(pSector, 406); - pActor->spr.pos.XY() = apos / pSector->wallnum; + pActor->spr.pos.XY() = apos / pSector->wall_count(); pSector->extra = (int16_t)EnergyBlocks.Push(pActor); diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 8265658d2..196dd3f6a 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -130,7 +130,7 @@ void feebtag(const DVector3& pos, sectortype* pSector, DExhumedActor **nSprite, int startwall = pSector->wallptr; - int nWalls = pSector->wallnum; + int nWalls = pSector->wall_count(); int var_20 = nVal2 & 2; int var_14 = nVal2 & 1; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 5d8113b89..8c309fc8b 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -643,7 +643,7 @@ DVector3 SectorMidPoint(sectortype* sectp) { sum += wal.pos; } - sum /= sectp->wallnum; + sum /= sectp->wall_count(); sum.Z = (sectp->floorz + sectp->ceilingz) * 0.5; return sum; } @@ -2606,7 +2606,7 @@ void DoSineWaveFloor(void) if ((flags & SINE_SLOPED)) { walltype* wal; - if (sect->wallnum == 4) + if (sect->wall_count() == 4) { //Set wal to the wall on the opposite side of the sector wal = sect->firstWall() + 2; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 0ce97966c..6c1c68562 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -2193,7 +2193,7 @@ void SpriteSetup(void) actor->user.rotator->vel = SP_TAG8(actor); actor->user.rotator->pos = 0; // closed actor->user.rotator->tgt = actor->user.rotator->open_dest; // closed - actor->user.rotator->SetNumWalls(actor->sector()->wallnum); + actor->user.rotator->SetNumWalls(actor->sector()->wall_count()); actor->user.rotator->orig_speed = actor->user.rotator->speed;