- wrapped all reads of sectortype::wallnum and renamed all other wallnum variables.

This commit is contained in:
Christoph Oelckers 2022-11-15 12:21:21 +01:00
parent b7a7584059
commit c23db8ea35
22 changed files with 44 additions and 45 deletions

View file

@ -250,7 +250,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
auto const sec = &sector[dasect]; auto const sec = &sector[dasect];
int const startwall = sec->wallptr; int const startwall = sec->wallptr;
int const endwall = startwall + sec->wallnum; int const endwall = startwall + sec->wall_count();
auto wal = &wall[startwall]; auto wal = &wall[startwall];
for (int j=startwall; j<endwall; j++, wal++) for (int j=startwall; j<endwall; j++, wal++)

View file

@ -712,7 +712,7 @@ double checkWallHit(walltype* wal, EWallFlags flagmask, const DVector3& start, c
double checkSectorPlaneHit(sectortype* sec, const DVector3& start, const DVector3& direction, DVector3& result, double maxfactor) double checkSectorPlaneHit(sectortype* sec, const DVector3& start, const DVector3& direction, DVector3& result, double maxfactor)
{ {
if (sec->wallnum < 3) return -1; if (sec->wall_count() < 3) return -1;
auto wal = sec->firstWall(); auto wal = sec->firstWall();
double len = wal->Length(); double len = wal->Length();
@ -1218,7 +1218,7 @@ int pushmove(DVector3& pos, sectortype** pSect, double walldist, double ceildist
while (auto sec = search.GetNext()) while (auto sec = search.GetNext())
{ {
// this must go both forward and backward so we cannot use wallsofsector. Pity // 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; auto wal = direction > 0 ? sec->firstWall() + i : sec->lastWall() - i;

View file

@ -465,7 +465,7 @@ inline int I_GetBuildTime()
inline TArrayView<walltype> wallsofsector(const sectortype* sec) inline TArrayView<walltype> wallsofsector(const sectortype* sec)
{ {
return TArrayView<walltype>(sec->firstWall(), sec->wallnum); return TArrayView<walltype>(sec->firstWall(), sec->wall_count());
} }
inline TArrayView<walltype> wallsofsector(int sec) inline TArrayView<walltype> wallsofsector(int sec)

View file

@ -250,11 +250,9 @@ static void SetWallPalV5()
{ {
for (unsigned i = 0; i < sector.Size(); i++) for (unsigned i = 0; i < sector.Size(); i++)
{ {
int startwall = sector[i].wallptr; for(auto& wal : wallsofsector(i))
int endwall = startwall + sector[i].wallnum;
for (int w = startwall; w < endwall; w++)
{ {
wall[w].pal = sector[i].floorpal; wal.pal = sector[i].floorpal;
} }
} }
} }
@ -757,11 +755,11 @@ void setWallSectors()
auto sect = &sector[i]; auto sect = &sector[i];
auto nextsect = &sector[i + 1]; auto nextsect = &sector[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 // We have overlapping wall ranges for two sectors. Do some analysis to see where these walls belong
int checkstart = nextsect->wallptr; 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. // for now assign the walls to the first sector. Final decisions are made below.
nextsect->wallnum -= checkend - checkstart; nextsect->wallnum -= checkend - checkstart;
@ -783,16 +781,16 @@ void setWallSectors()
sect->wallnum = checkstart - sect->wallptr; 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--; checkend--;
nextsect->wallnum += nextsect->wallptr - checkend; nextsect->wallnum += nextsect->wallptr - checkend;
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. // 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; sect->wallnum = nextsect->wallptr - sect->wallptr;
} }
} }

View file

@ -350,6 +350,7 @@ struct sectortype
int getceilingslope() const { return ceilingstat & CSTAT_SECTOR_SLOPE ? ceilingheinum : 0; } int getceilingslope() const { return ceilingstat & CSTAT_SECTOR_SLOPE ? ceilingheinum : 0; }
walltype* firstWall() const; walltype* firstWall() const;
walltype* lastWall() const; walltype* lastWall() const;
int wall_count() const { return wallnum; }
Blood::XSECTOR& xs() const { return *_xs; } Blood::XSECTOR& xs() const { return *_xs; }
@ -555,9 +556,9 @@ inline bool validSectorIndex(int sectnum)
return (unsigned)sectnum < sector.Size(); 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 inline sectortype* walltype::nextSector() const

View file

@ -124,8 +124,8 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SplitSector)
if (sectornum < sector.Size()) if (sectornum < sector.Size())
{ {
if (firstwall >= sector[sectornum].wallptr && firstwall < 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].wallnum) secondwall >= sector[sectornum].wallptr && secondwall < sector[sectornum].wallptr + sector[sectornum].wall_count())
hw_SetSplitSector(sectornum, firstwall, secondwall); hw_SetSplitSector(sectornum, firstwall, secondwall);
} }

View file

@ -224,7 +224,7 @@ static void CollectLoops(TArray<loopcollect>& sectors)
for (unsigned i = 0; i < sector.Size(); i++) for (unsigned i = 0; i < sector.Size(); i++)
{ {
int first = sector[i].wallptr; int first = sector[i].wallptr;
int last = first + sector[i].wallnum; int last = first + sector[i].wall_count();
sectors.Reserve(1); sectors.Reserve(1);
sectors.Last().bugged = 0; sectors.Last().bugged = 0;

View file

@ -408,7 +408,7 @@ void HWDrawInfo::CreateScene(bool portal)
for (int i = 0; i < eff.geocnt; i++) for (int i = 0; i < eff.geocnt; i++)
{ {
auto sect = eff.geosectorwarp[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; auto wal = sect->firstWall() + w;
wal->pos.X += eff.geox[i]; wal->pos.X += eff.geox[i];
@ -427,7 +427,7 @@ void HWDrawInfo::CreateScene(bool portal)
for (int i = 0; i < eff.geocnt; i++) for (int i = 0; i < eff.geocnt; i++)
{ {
auto sect = eff.geosectorwarp[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; auto wal = sect->firstWall() + w;
wal->pos.X -= eff.geox[i]; wal->pos.X -= eff.geox[i];
@ -440,7 +440,7 @@ void HWDrawInfo::CreateScene(bool portal)
for (int i = 0; i < eff.geocnt; i++) for (int i = 0; i < eff.geocnt; i++)
{ {
auto sect = eff.geosectorwarp2[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; auto wal = sect->firstWall() + w;
wal->pos.X += eff.geox2[i]; wal->pos.X += eff.geox2[i];
@ -458,7 +458,7 @@ void HWDrawInfo::CreateScene(bool portal)
for (int i = 0; i < eff.geocnt; i++) for (int i = 0; i < eff.geocnt; i++)
{ {
auto sect = eff.geosectorwarp2[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; auto wal = sect->firstWall() + w;
wal->pos.X -= eff.geox2[i]; wal->pos.X -= eff.geox2[i];

View file

@ -478,7 +478,7 @@ int HWLinePortal::ClipSeg(walltype *seg, const DVector3 &viewpos)
int HWLinePortal::ClipSector(sectortype *sub) int HWLinePortal::ClipSector(sectortype *sub)
{ {
// this seg is completely behind the mirror // this seg is completely behind the mirror
for (int i = 0; i<sub->wallnum; i++) for (int i = 0; i<sub->wall_count(); i++)
{ {
if (PointOnLineSide(sub->firstWall()->pos, line) == 0) return PClip_Inside; if (PointOnLineSide(sub->firstWall()->pos, line) == 0) return PClip_Inside;
} }

View file

@ -88,7 +88,7 @@ struct MIRROR
int type; int type;
int link; int link;
DVector3 diff; DVector3 diff;
int wallnum; int mynum;
}; };
extern MIRROR mirror[16]; extern MIRROR mirror[16];

View file

@ -63,7 +63,7 @@ void InitMirrors(void)
{ {
pWalli->overpicnum = nTile; pWalli->overpicnum = nTile;
mirror[mirrorcnt].wallnum = i; mirror[mirrorcnt].mynum = i;
mirror[mirrorcnt].type = 0; mirror[mirrorcnt].type = 0;
pWalli->cstat |= CSTAT_WALL_1WAY; pWalli->cstat |= CSTAT_WALL_1WAY;
int tmp = pWalli->xw().data; int tmp = pWalli->xw().data;
@ -99,7 +99,7 @@ void InitMirrors(void)
if (pWalli->picnum == 504) if (pWalli->picnum == 504)
{ {
mirror[mirrorcnt].link = i; mirror[mirrorcnt].link = i;
mirror[mirrorcnt].wallnum = i; mirror[mirrorcnt].mynum = i;
pWalli->picnum = nTile; pWalli->picnum = nTile;
mirror[mirrorcnt].type = 0; mirror[mirrorcnt].type = 0;
pWalli->cstat |= CSTAT_WALL_1WAY; 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); I_Error("Lower link sector %d doesn't have mirror picnum\n", j);
mirror[mirrorcnt].type = 2; mirror[mirrorcnt].type = 2;
mirror[mirrorcnt].diff = link2->spr.pos - link->spr.pos; mirror[mirrorcnt].diff = link2->spr.pos - link->spr.pos;
mirror[mirrorcnt].wallnum = i; mirror[mirrorcnt].mynum = i;
mirror[mirrorcnt].link = j; mirror[mirrorcnt].link = j;
secti->floorpicnum = 4080 + mirrorcnt; secti->floorpicnum = 4080 + mirrorcnt;
secti->portalflags = PORTAL_SECTOR_FLOOR; secti->portalflags = PORTAL_SECTOR_FLOOR;
@ -137,7 +137,7 @@ void InitMirrors(void)
mirrorcnt++; mirrorcnt++;
mirror[mirrorcnt].type = 1; mirror[mirrorcnt].type = 1;
mirror[mirrorcnt].diff = link->spr.pos - link2->spr.pos; mirror[mirrorcnt].diff = link->spr.pos - link2->spr.pos;
mirror[mirrorcnt].wallnum = j; mirror[mirrorcnt].mynum = j;
mirror[mirrorcnt].link = i; mirror[mirrorcnt].link = i;
sectj->ceilingpicnum = 4080 + mirrorcnt; sectj->ceilingpicnum = 4080 + mirrorcnt;
sectj->portalflags = PORTAL_SECTOR_CEILING; sectj->portalflags = PORTAL_SECTOR_CEILING;
@ -162,7 +162,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRROR& w, MIRROR*
arc("type", w.type) arc("type", w.type)
("link", w.link) ("link", w.link)
("diff", w.diff) ("diff", w.diff)
("wallnum", w.wallnum) ("wallnum", w.mynum)
.EndObject(); .EndObject();
} }
return arc; return arc;

View file

@ -3466,7 +3466,7 @@ void moveeffectors_d(void) //STATNUM 3
{ {
if (act->spr.lotag != SE_29_WAVES) continue; if (act->spr.lotag != SE_29_WAVES) continue;
auto sc = act->sector(); auto sc = act->sector();
if (sc->wallnum != 4) continue; if (sc->wall_count() != 4) continue;
auto wal = sc->firstWall() + 2; auto wal = sc->firstWall() + 2;
if (wal->nextSector()) alignflorslope(act->sector(), DVector3(wal->pos, wal->nextSector()->floorz)); if (wal->nextSector()) alignflorslope(act->sector(), DVector3(wal->pos, wal->nextSector()->floorz));
} }

View file

@ -3385,7 +3385,7 @@ void moveeffectors_r(void) //STATNUM 3
{ {
if (act->spr.lotag != SE_29_WAVES) continue; if (act->spr.lotag != SE_29_WAVES) continue;
auto sc = act->sector(); auto sc = act->sector();
if (sc->wallnum != 4) continue; if (sc->wall_count() != 4) continue;
auto wal = sc->firstWall() + 2; auto wal = sc->firstWall() + 2;
if (wal->nextSector()) alignflorslope(act->sector(), DVector3(wal->pos, wal->nextSector()->floorz)); 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 destwal = destsect->firstWall();
auto srcwal = srcsect->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->picnum = srcwal->picnum;
destwal->overpicnum = srcwal->overpicnum; destwal->overpicnum = srcwal->overpicnum;

View file

@ -177,7 +177,7 @@ DDukeActor* SpawnActor(sectortype* whatsectp, const DVector3& pos, PClassActor*
void ceilingglass(DDukeActor* snum, sectortype* sectnum, int cnt); void ceilingglass(DDukeActor* snum, sectortype* sectnum, int cnt);
void spriteglass(DDukeActor* snum, int cnt); void spriteglass(DDukeActor* snum, int cnt);
void lotsofcolourglass(DDukeActor* snum, walltype* wallNum, 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_d(player_struct* p, const Collision& coll);
void checkplayerhurt_r(player_struct* p, const Collision& coll); void checkplayerhurt_r(player_struct* p, const Collision& coll);
DDukeActor* dospawnsprite(DDukeActor* actj, int pn); DDukeActor* dospawnsprite(DDukeActor* actj, int pn);

View file

@ -1055,7 +1055,7 @@ void DoSector(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
if (!bSet) SetGameVarID(lVar2, sectp->wallptr, sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, sectp->wallptr, sActor, sPlayer);
break; break;
case SECTOR_WALLNUM: case SECTOR_WALLNUM:
if (!bSet) SetGameVarID(lVar2, sectp->wallnum, sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, sectp->wall_count(), sActor, sPlayer);
break; break;
case SECTOR_CEILINGZ: case SECTOR_CEILINGZ:
if (bSet) sectp->setceilingz(lValue * zmaptoworld); if (bSet) sectp->setceilingz(lValue * zmaptoworld);

View file

@ -51,7 +51,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, animwalltype& w, a
{ {
if (arc.BeginObject(keyname)) if (arc.BeginObject(keyname))
{ {
arc("wallnum", w.wall) arc("wall", w.wall)
("tag", w.tag) ("tag", w.tag)
.EndObject(); .EndObject();
} }

View file

@ -537,8 +537,8 @@ static void handle_st09(sectortype* sptr, DDukeActor* actor)
dax += wal.pos.X; dax += wal.pos.X;
day += wal.pos.Y; day += wal.pos.Y;
} }
dax /= sptr->wallnum; dax /= sptr->wall_count();
day /= sptr->wallnum; day /= sptr->wall_count();
//find any points with either same x or same y coordinate //find any points with either same x or same y coordinate
// as center (dax, day) - should be 2 points found. // 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 //find what direction door should open by averaging the
// 2 neighboring points of wallfind[0] & wallfind[1]. // 2 neighboring points of wallfind[0] & wallfind[1].
auto prevwall = wal - 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)) 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; sect->floorshade = sect->ceilingshade = (int8_t)p->shade2;
wal = sect->firstWall(); 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; wal->shade = (int8_t)p->shade2;
} }
} }

View file

@ -723,7 +723,7 @@ void CreatePushBlock(sectortype* pSector)
sum += wal.pos; sum += wal.pos;
} }
DVector2 avg = sum / pSector->wallnum; DVector2 avg = sum / pSector->wall_count();
sBlockInfo[nBlock].pos = avg; sBlockInfo[nBlock].pos = avg;

View file

@ -1627,7 +1627,7 @@ DExhumedActor* BuildEnergyBlock(sectortype* pSector)
auto pActor = insertActor(pSector, 406); 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); pSector->extra = (int16_t)EnergyBlocks.Push(pActor);

View file

@ -130,7 +130,7 @@ void feebtag(const DVector3& pos, sectortype* pSector, DExhumedActor **nSprite,
int startwall = pSector->wallptr; int startwall = pSector->wallptr;
int nWalls = pSector->wallnum; int nWalls = pSector->wall_count();
int var_20 = nVal2 & 2; int var_20 = nVal2 & 2;
int var_14 = nVal2 & 1; int var_14 = nVal2 & 1;

View file

@ -643,7 +643,7 @@ DVector3 SectorMidPoint(sectortype* sectp)
{ {
sum += wal.pos; sum += wal.pos;
} }
sum /= sectp->wallnum; sum /= sectp->wall_count();
sum.Z = (sectp->floorz + sectp->ceilingz) * 0.5; sum.Z = (sectp->floorz + sectp->ceilingz) * 0.5;
return sum; return sum;
} }
@ -2606,7 +2606,7 @@ void DoSineWaveFloor(void)
if ((flags & SINE_SLOPED)) if ((flags & SINE_SLOPED))
{ {
walltype* wal; walltype* wal;
if (sect->wallnum == 4) if (sect->wall_count() == 4)
{ {
//Set wal to the wall on the opposite side of the sector //Set wal to the wall on the opposite side of the sector
wal = sect->firstWall() + 2; wal = sect->firstWall() + 2;

View file

@ -2193,7 +2193,7 @@ void SpriteSetup(void)
actor->user.rotator->vel = SP_TAG8(actor); actor->user.rotator->vel = SP_TAG8(actor);
actor->user.rotator->pos = 0; // closed actor->user.rotator->pos = 0; // closed
actor->user.rotator->tgt = actor->user.rotator->open_dest; // 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; actor->user.rotator->orig_speed = actor->user.rotator->speed;