- eliminate wall_count.

This commit is contained in:
Christoph Oelckers 2022-11-15 14:59:28 +01:00
parent bfae5ce1bc
commit 84b17a8a53
17 changed files with 35 additions and 36 deletions

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->wall_count() < 3) return -1; if (sec->walls.Size() < 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->wall_count(); i++) for (unsigned i = 0; i < sec->walls.Size(); 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->wall_count()); return TArrayView<walltype>(sec->firstWall(), sec->walls.Size());
} }
inline TArrayView<walltype> wallsofsector(int sec) inline TArrayView<walltype> wallsofsector(int sec)

View file

@ -757,14 +757,14 @@ void setWallSectors()
auto sect = &sector[i]; auto sect = &sector[i];
auto nextsect = &sector[i + 1]; auto nextsect = &sector[i + 1];
int sectstart = wallindex(sect->firstWall()); unsigned int sectstart = wallindex(sect->firstWall());
int nextsectstart = wallindex(sect->firstWall()); unsigned int nextsectstart = wallindex(sect->firstWall());
if (sectstart < nextsectstart && sectstart + sect->wall_count() > nextsectstart) if (sectstart < nextsectstart && sectstart + sect->walls.Size() > nextsectstart)
{ {
// 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 = nextsectstart; int checkstart = nextsectstart;
int checkend = sectstart + sect->wall_count(); int checkend = sectstart + sect->walls.Size();
// 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.
nextsectstart = checkend; nextsectstart = checkend;
@ -786,17 +786,17 @@ void setWallSectors()
sect->walls.Set(sect->firstWall(), checkstart - sectstart); sect->walls.Set(sect->firstWall(), checkstart - sectstart);
while (checkstart < checkend && belongs(checkend - 1, checkend, nextsectstart + nextsect->wall_count(), checkstart)) while (checkstart < checkend && belongs(checkend - 1, checkend, nextsectstart + nextsect->walls.Size(), checkstart))
checkend--; checkend--;
int cnt = nextsect->walls.Size() - (nextsectstart - checkend); int cnt = nextsect->walls.Size() - (nextsectstart - checkend);
nextsectstart = checkend; nextsectstart = checkend;
nextsect->walls.Set(&wall[nextsectstart], cnt); nextsect->walls.Set(&wall[nextsectstart], cnt);
if (nextsectstart > sectstart + sect->wall_count()) if (nextsectstart > sectstart + sect->walls.Size())
{ {
// 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", sectstart + sect->wall_count(), nextsectstart - 1, i, i + 1); Printf("Wall range %d - %d referenced by sectors %d and %d\n", sectstart + sect->walls.Size(), nextsectstart - 1, i, i + 1);
sect->walls.Set(sect->firstWall(), nextsectstart - sectstart); sect->walls.Set(sect->firstWall(), nextsectstart - sectstart);
} }
} }

View file

@ -429,7 +429,6 @@ 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 { return walls.Data(); } walltype* firstWall() const { return walls.Data(); }
walltype* lastWall() const { return &walls.Last(); } walltype* lastWall() const { return &walls.Last(); }
int wall_count() const { return walls.Size(); }
Blood::XSECTOR& xs() const { return *_xs; } Blood::XSECTOR& xs() const { return *_xs; }

View file

@ -120,14 +120,14 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SplitSector)
{ {
PARAM_SELF_PROLOGUE(DLevelPostProcessor); PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_UINT(sectornum); PARAM_UINT(sectornum);
PARAM_INT(firstwall); PARAM_UINT(firstwall);
PARAM_INT(secondwall); PARAM_UINT(secondwall);
if (sectornum < sector.Size()) if (sectornum < sector.Size())
{ {
int sectstart = wallindex(sector[sectornum].firstWall()); unsigned sectstart = wallindex(sector[sectornum].firstWall());
if (firstwall >= sectstart && firstwall < sectstart + sector[sectornum].wall_count() && if (firstwall >= sectstart && firstwall < sectstart + sector[sectornum].walls.Size() &&
secondwall >= sectstart && secondwall < sectstart + sector[sectornum].wall_count()) secondwall >= sectstart && secondwall < sectstart + sector[sectornum].walls.Size())
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 = wallindex(sector[i].firstWall()); int first = wallindex(sector[i].firstWall());
int last = first + sector[i].wall_count(); int last = first + sector[i].walls.Size();
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->wall_count(); w++) for (unsigned w = 0; w < sect->walls.Size(); 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->wall_count(); w++) for (unsigned w = 0; w < sect->walls.Size(); 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->wall_count(); w++) for (unsigned w = 0; w < sect->walls.Size(); 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->wall_count(); w++) for (unsigned w = 0; w < sect->walls.Size(); 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->wall_count(); i++) for (unsigned i = 0; i<sub->walls.Size(); i++)
{ {
if (PointOnLineSide(sub->firstWall()->pos, line) == 0) return PClip_Inside; if (PointOnLineSide(sub->firstWall()->pos, line) == 0) return PClip_Inside;
} }

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->wall_count() != 4) continue; if (sc->walls.Size() != 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->wall_count() != 4) continue; if (sc->walls.Size() != 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->wall_count(); i++, srcwal++, destwal++) for (unsigned i = 0; i < destsect->walls.Size(); i++, srcwal++, destwal++)
{ {
destwal->picnum = srcwal->picnum; destwal->picnum = srcwal->picnum;
destwal->overpicnum = srcwal->overpicnum; destwal->overpicnum = srcwal->overpicnum;

View file

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

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->wall_count(); dax /= sptr->walls.Size();
day /= sptr->wall_count(); day /= sptr->walls.Size();
//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->wall_count(); if (prevwall < sptr->firstWall()) prevwall += sptr->walls.Size();
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->wall_count(); j > 0; j--, wal++) for (j = sect->walls.Size(); 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->wall_count(); DVector2 avg = sum / pSector->walls.Size();
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->wall_count(); pActor->spr.pos.XY() = apos / pSector->walls.Size();
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,
auto startwall = pSector->firstWall(); auto startwall = pSector->firstWall();
int nWalls = pSector->wall_count(); int nWalls = pSector->walls.Size();
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->wall_count(); sum /= sectp->walls.Size();
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->wall_count() == 4) if (sect->walls.Size() == 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()->wall_count()); actor->user.rotator->SetNumWalls(actor->sector()->walls.Size());
actor->user.rotator->orig_speed = actor->user.rotator->speed; actor->user.rotator->orig_speed = actor->user.rotator->speed;