- eliminated firstWall as well.

This commit is contained in:
Christoph Oelckers 2022-11-15 15:44:33 +01:00
parent 5798fa067f
commit 42e02d2956
23 changed files with 35 additions and 36 deletions

View file

@ -138,7 +138,7 @@ void calcSlope(const sectortype* sec, double xpos, double ypos, double* pceilz,
if ((bits & CSTAT_SECTOR_SLOPE) == CSTAT_SECTOR_SLOPE) if ((bits & CSTAT_SECTOR_SLOPE) == CSTAT_SECTOR_SLOPE)
{ {
auto wal = sec->firstWall(); auto wal = sec->walls.Data();
double len = wal->Length(); double len = wal->Length();
if (len != 0) if (len != 0)
{ {
@ -158,7 +158,7 @@ void calcSlope(const sectortype* sec, double xpos, double ypos, double* pceilz,
int getslopeval(sectortype* sect, const DVector3& pos, double basez) int getslopeval(sectortype* sect, const DVector3& pos, double basez)
{ {
auto wal = sect->firstWall(); auto wal = sect->walls.Data();
double i = (pos.XY() - wal->pos).dot(wal->delta().Rotated90CCW()); double i = (pos.XY() - wal->pos).dot(wal->delta().Rotated90CCW());
return i == 0? 0 : int(SLOPEVAL_FACTOR * (pos.Z - basez) * wal->Length() / i); return i == 0? 0 : int(SLOPEVAL_FACTOR * (pos.Z - basez) * wal->Length() / i);
} }
@ -713,7 +713,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->walls.Size() < 3) return -1; if (sec->walls.Size() < 3) return -1;
auto wal = sec->firstWall(); auto wal = sec->walls.Data();
double len = wal->Length(); double len = wal->Length();
DVector3 pt1, pt2, pt3; DVector3 pt1, pt2, pt3;

View file

@ -425,7 +425,7 @@ void fixSectors()
for(auto& sect: sector) for(auto& sect: sector)
{ {
// Fix maps which do not set their wall index to the first wall of the sector. Lo Wang In Time's map 11 is such a case. // Fix maps which do not set their wall index to the first wall of the sector. Lo Wang In Time's map 11 is such a case.
auto wp = sect.firstWall(); auto wp = sect.walls.Data();
// Note: we do not have the 'sector' index initialized here, it would not be helpful anyway for this fix. // Note: we do not have the 'sector' index initialized here, it would not be helpful anyway for this fix.
while (wp != wall.Data() && wp[-1].twoSided() && wp[-1].nextWall()->nextWall() == &wp[-1] && wp[-1].nextWall()->nextSector() == &sect) while (wp != wall.Data() && wp[-1].twoSided() && wp[-1].nextWall()->nextWall() == &wp[-1] && wp[-1].nextWall()->nextSector() == &sect)
{ {
@ -757,8 +757,8 @@ void setWallSectors()
auto sect = &sector[i]; auto sect = &sector[i];
auto nextsect = &sector[i + 1]; auto nextsect = &sector[i + 1];
unsigned int sectstart = wallindex(sect->firstWall()); unsigned int sectstart = wallindex(sect->walls.Data());
unsigned int nextsectstart = wallindex(sect->firstWall()); unsigned int nextsectstart = wallindex(sect->walls.Data());
if (sectstart < nextsectstart && sectstart + sect->walls.Size() > nextsectstart) if (sectstart < nextsectstart && sectstart + sect->walls.Size() > nextsectstart)
{ {
@ -784,7 +784,7 @@ void setWallSectors()
while (checkstart < checkend && belongs(checkstart, sectstart, checkstart, checkstart)) while (checkstart < checkend && belongs(checkstart, sectstart, checkstart, checkstart))
checkstart++; checkstart++;
sect->walls.Set(sect->firstWall(), checkstart - sectstart); sect->walls.Set(sect->walls.Data(), checkstart - sectstart);
while (checkstart < checkend && belongs(checkend - 1, checkend, nextsectstart + nextsect->walls.Size(), checkstart)) while (checkstart < checkend && belongs(checkend - 1, checkend, nextsectstart + nextsect->walls.Size(), checkstart))
checkend--; checkend--;
@ -797,7 +797,7 @@ void setWallSectors()
{ {
// 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->walls.Size(), 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->walls.Data(), nextsectstart - sectstart);
} }
} }
} }

View file

@ -427,7 +427,6 @@ struct sectortype
void setfloorslope(int heinum) { floorheinum = heinum; if (heinum) floorstat |= CSTAT_SECTOR_SLOPE; else floorstat &= ~CSTAT_SECTOR_SLOPE; } void setfloorslope(int heinum) { floorheinum = heinum; if (heinum) floorstat |= CSTAT_SECTOR_SLOPE; else floorstat &= ~CSTAT_SECTOR_SLOPE; }
int getfloorslope() const { return floorstat & CSTAT_SECTOR_SLOPE ? floorheinum : 0; } int getfloorslope() const { return floorstat & CSTAT_SECTOR_SLOPE ? floorheinum : 0; }
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(); }
Blood::XSECTOR& xs() const { return *_xs; } Blood::XSECTOR& xs() const { return *_xs; }

View file

@ -125,7 +125,7 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SplitSector)
if (sectornum < sector.Size()) if (sectornum < sector.Size())
{ {
unsigned sectstart = wallindex(sector[sectornum].firstWall()); unsigned sectstart = wallindex(sector[sectornum].walls.Data());
if (firstwall >= sectstart && firstwall < sectstart + sector[sectornum].walls.Size() && if (firstwall >= sectstart && firstwall < sectstart + sector[sectornum].walls.Size() &&
secondwall >= sectstart && secondwall < sectstart + sector[sectornum].walls.Size()) secondwall >= sectstart && secondwall < sectstart + sector[sectornum].walls.Size())

View file

@ -223,7 +223,7 @@ static void CollectLoops(TArray<loopcollect>& sectors)
int count = 0; int count = 0;
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].walls.Data());
int last = first + sector[i].walls.Size(); int last = first + sector[i].walls.Size();
sectors.Reserve(1); sectors.Reserve(1);
sectors.Last().bugged = 0; sectors.Last().bugged = 0;

View file

@ -63,7 +63,7 @@ static FVector3 CalcNormal(sectortype* sector, int plane)
if (plane == 1 && !(sector->ceilingstat & CSTAT_SECTOR_SLOPE)) return { 0.f, -1.f, 0.f }; if (plane == 1 && !(sector->ceilingstat & CSTAT_SECTOR_SLOPE)) return { 0.f, -1.f, 0.f };
auto wal = sector->firstWall(); auto wal = sector->walls.Data();
auto wal2 = wal->point2Wall(); auto wal2 = wal->point2Wall();
pt[0] = { (float)wal->pos.X, 0.f, -(float)wal->pos.Y}; pt[0] = { (float)wal->pos.X, 0.f, -(float)wal->pos.Y};
@ -122,7 +122,7 @@ public:
myplane = plane; myplane = plane;
offset = off; offset = off;
auto firstwall = sec->firstWall(); auto firstwall = sec->walls.Data();
ix1 = firstwall->pos.X; ix1 = firstwall->pos.X;
iy1 = firstwall->pos.Y; iy1 = firstwall->pos.Y;
ix2 = firstwall->point2Wall()->pos.X; ix2 = firstwall->point2Wall()->pos.X;

View file

@ -2530,7 +2530,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
pWall->allocX(); pWall->allocX();
break; break;
case 2: case 2:
pWall->sectorp()->slopewallofs = max<int>(int(pWall - pWall->sectorp()->firstWall()), 0); pWall->sectorp()->slopewallofs = max<int>(int(pWall - pWall->sectorp()->walls.Data()), 0);
break; break;
} }
} }

View file

@ -613,7 +613,7 @@ void fakeActProcessSprites(void)
speed = MulScale(speed, pXSector->busy, 16); speed = MulScale(speed, pXSector->busy, 16);
} }
if (pSector->floorstat & 64) if (pSector->floorstat & 64)
angle = (GetWallAngle(pSector->firstWall()) + 512) & 2047; angle = (GetWallAngle(pSector->walls.Data()) + 512) & 2047;
predict.xvel += MulScale(speed, Cos_(angle), 30); predict.xvel += MulScale(speed, Cos_(angle), 30);
predict.yvel += MulScale(speed, Sin_(angle), 30); predict.yvel += MulScale(speed, Sin_(angle), 30);
} }

View file

@ -271,7 +271,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
{ {
if ((dasectp->ceilingz- actor->spr.pos.Z) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly if ((dasectp->ceilingz- actor->spr.pos.Z) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly
{ {
auto wal = dasectp->firstWall(); auto wal = dasectp->walls.Data();
double d = (wal->pos - actor->spr.pos.XY()).Sum(); double d = (wal->pos - actor->spr.pos.XY()).Sum();
if (d < radius) if (d < radius)
fi.checkhitceiling(dasectp); fi.checkhitceiling(dasectp);

View file

@ -230,7 +230,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
{ {
if ((dasectp->ceilingz- actor->spr.pos.Z) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly if ((dasectp->ceilingz- actor->spr.pos.Z) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly
{ {
auto wal = dasectp->firstWall(); auto wal = dasectp->walls.Data();
double d = (wal->pos - actor->spr.pos.XY()).Sum(); double d = (wal->pos - actor->spr.pos.XY()).Sum();
if (d < radius) if (d < radius)
fi.checkhitceiling(dasectp); fi.checkhitceiling(dasectp);
@ -3848,8 +3848,8 @@ void destroyit(DDukeActor *actor)
auto destsect = spr->sector(); auto destsect = spr->sector();
auto srcsect = it_sect; auto srcsect = it_sect;
auto destwal = destsect->firstWall(); auto destwal = destsect->walls.Data();
auto srcwal = srcsect->firstWall(); auto srcwal = srcsect->walls.Data();
for (unsigned i = 0; i < destsect->walls.Size(); i++, srcwal++, destwal++) for (unsigned i = 0; i < destsect->walls.Size(); i++, srcwal++, destwal++)
{ {
destwal->picnum = srcwal->picnum; destwal->picnum = srcwal->picnum;

View file

@ -1052,7 +1052,7 @@ void DoSector(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
switch (lLabelID) switch (lLabelID)
{ {
case SECTOR_WALLPTR: case SECTOR_WALLPTR:
if (!bSet) SetGameVarID(lVar2, wallindex(sectp->firstWall()), sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, wallindex(sectp->walls.Data()), sActor, sPlayer);
break; break;
case SECTOR_WALLNUM: case SECTOR_WALLNUM:
if (!bSet) SetGameVarID(lVar2, sectp->walls.Size(), sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, sectp->walls.Size(), sActor, sPlayer);

View file

@ -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->walls.Size(); if (prevwall < sptr->walls.Data()) prevwall += sptr->walls.Size();
if ((wal->pos.X == dax) && (wal->pos.Y == day)) if ((wal->pos.X == dax) && (wal->pos.Y == day))
{ {
@ -1116,7 +1116,7 @@ void operateactivators(int low, int plnum)
p->state = !p->state; p->state = !p->state;
sect->floorshade = sect->ceilingshade = (int8_t)p->shade2; sect->floorshade = sect->ceilingshade = (int8_t)p->shade2;
wal = sect->firstWall(); wal = sect->walls.Data();
for (j = sect->walls.Size(); 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

@ -781,7 +781,7 @@ void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& nVel)
double nFloorZ = pSector->floorz; double nFloorZ = pSector->floorz;
walltype *pStartWall = pSector->firstWall(); walltype *pStartWall = pSector->walls.Data();
sectortype* pNextSector = pStartWall->nextSector(); sectortype* pNextSector = pStartWall->nextSector();
BlockInfo *pBlockInfo = &sBlockInfo[nBlock]; BlockInfo *pBlockInfo = &sBlockInfo[nBlock];

View file

@ -381,7 +381,7 @@ void InitElev()
DExhumedActor* BuildWallSprite(sectortype* pSector) DExhumedActor* BuildWallSprite(sectortype* pSector)
{ {
auto wal = pSector->firstWall(); auto wal = pSector->walls.Data();
auto pActor = insertActor(pSector, 401); auto pActor = insertActor(pSector, 401);

View file

@ -128,7 +128,7 @@ void feebtag(const DVector3& pos, sectortype* pSector, DExhumedActor **nSprite,
{ {
*nSprite = nullptr; *nSprite = nullptr;
auto startwall = pSector->firstWall(); auto startwall = pSector->walls.Data();
int nWalls = pSector->walls.Size(); int nWalls = pSector->walls.Size();

View file

@ -664,7 +664,7 @@ void CheckAmbience(sectortype* sect)
if (sect->Sound != -1) if (sect->Sound != -1)
{ {
auto pSector2 = sect->pSoundSect; auto pSector2 = sect->pSoundSect;
walltype* pWall = pSector2->firstWall(); walltype* pWall = pSector2->walls.Data();
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, &amb, 0)) if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, &amb, 0))
{ {
DVector3 v = { pWall->pos.X, pWall->pos.Y, pSector2->floorz }; DVector3 v = { pWall->pos.X, pWall->pos.Y, pSector2->floorz };

View file

@ -355,7 +355,7 @@ void AISWStepOn::TouchFloor(RunListEvent* ev)
if (var_14 != sRunChannels[nChannel].c) if (var_14 != sRunChannels[nChannel].c)
{ {
auto pWall = pSector->firstWall(); auto pWall = pSector->walls.Data();
PlayFXAtXYZ(StaticSound[nSwitchSound], DVector3(pWall->pos, pSector->floorz)); PlayFXAtXYZ(StaticSound[nSwitchSound], DVector3(pWall->pos, pSector->floorz));
assert(sRunChannels[nChannel].c < 8); assert(sRunChannels[nChannel].c < 8);

View file

@ -51,8 +51,8 @@ void CopySectorWalls(sectortype* dest_sect, sectortype* src_sect)
SECTOR_OBJECT* sop; SECTOR_OBJECT* sop;
sectortype* *sectp; sectortype* *sectp;
auto dwall = dest_sect->firstWall(); auto dwall = dest_sect->walls.Data();
auto swall = src_sect->firstWall(); auto swall = src_sect->walls.Data();
auto firstwall = dwall; auto firstwall = dwall;
// this looks broken. // this looks broken.

View file

@ -109,7 +109,7 @@ void SetWallWarpHitscan(sectortype* sect)
if (!sp_warp) if (!sp_warp)
return; return;
auto start_wall = sect->firstWall(); auto start_wall = sect->walls.Data();
auto wall_num = start_wall; auto wall_num = start_wall;
// Travel all the way around loop setting wall bits // Travel all the way around loop setting wall bits
@ -130,7 +130,7 @@ void SetWallWarpHitscan(sectortype* sect)
void ResetWallWarpHitscan(sectortype* sect) void ResetWallWarpHitscan(sectortype* sect)
{ {
auto start_wall = sect->firstWall(); auto start_wall = sect->walls.Data();
auto wall_num = start_wall; auto wall_num = start_wall;
// Travel all the way around loop setting wall bits // Travel all the way around loop setting wall bits

View file

@ -96,7 +96,7 @@ SPRING_BOARD SpringBoard[20];
void SetSectorWallBits(sectortype* sect, int bit_mask, bool set_sectwall, bool set_nextwall) void SetSectorWallBits(sectortype* sect, int bit_mask, bool set_sectwall, bool set_nextwall)
{ {
auto start_wall = sect->firstWall(); auto start_wall = sect->walls.Data();
auto wall_num = start_wall; auto wall_num = start_wall;
do do

View file

@ -431,7 +431,7 @@ int DoSlidorInstantClose(DSWActor* actor)
{ {
double diff; double diff;
auto startwall = actor->sector()->firstWall(); auto startwall = actor->sector()->walls.Data();
auto wal = startwall; auto wal = startwall;
do do

View file

@ -2706,7 +2706,7 @@ void SpriteSetup(void)
break; break;
// move the the next wall // move the the next wall
auto start_wall = actor->sector()->firstWall(); auto start_wall = actor->sector()->walls.Data();
auto wall_num = start_wall; auto wall_num = start_wall;
// Travel all the way around loop setting wall bits // Travel all the way around loop setting wall bits
@ -2819,7 +2819,7 @@ void SpriteSetup(void)
case SECT_ACTOR_BLOCK: case SECT_ACTOR_BLOCK:
{ {
// move the the next wall // move the the next wall
auto start_wall = actor->sector()->firstWall(); auto start_wall = actor->sector()->walls.Data();
auto wall_num = start_wall; auto wall_num = start_wall;
// Travel all the way around loop setting wall bits // Travel all the way around loop setting wall bits

View file

@ -8319,7 +8319,7 @@ bool SlopeBounce(DSWActor* actor, bool* hit_wall)
*hit_wall = false; *hit_wall = false;
// get angle of the first wall of the sector // get angle of the first wall of the sector
auto wallp = hit_sector->firstWall(); auto wallp = hit_sector->walls.Data();
DAngle daang = wallp->delta().Angle(); DAngle daang = wallp->delta().Angle();
// k is now the slope of the ceiling or floor // k is now the slope of the ceiling or floor