- migrated Exhumed's sector extensions to the actual struct.

This commit is contained in:
Christoph Oelckers 2021-11-20 20:52:29 +01:00
parent e034635e12
commit a21f6b6240
18 changed files with 136 additions and 135 deletions

View file

@ -209,6 +209,12 @@ inline bool isSWALL()
return g_gameType & (GAMEFLAG_SW | GAMEFLAG_SWWANTON | GAMEFLAG_SWTWINDRAG); return g_gameType & (GAMEFLAG_SW | GAMEFLAG_SWWANTON | GAMEFLAG_SWTWINDRAG);
} }
inline bool isExhumed()
{
return g_gameType & GAMEFLAG_PSEXHUMED;
}
TArray<GrpEntry> GrpScan(); TArray<GrpEntry> GrpScan();
void S_PauseSound(bool notmusic, bool notsfx); void S_PauseSound(bool notmusic, bool notsfx);
void S_ResumeSound(bool notsfx); void S_ResumeSound(bool notsfx);

View file

@ -465,6 +465,15 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
case 6: ReadSectorV6(fr, sector[i]); break; case 6: ReadSectorV6(fr, sector[i]); break;
default: ReadSectorV7(fr, sector[i]); break; default: ReadSectorV7(fr, sector[i]); break;
} }
// If we do not do this here, we need to do a lot more contortions to exclude these defaults from getting written out to savegames.
// This way they just get copied to the sector backup array. These 4 are the only values in all games needing such treatment.
if (isExhumed())
{
sector[i].SoundSect = -1;
sector[i].Sound = -1;
sector[i].Above = -1;
sector[i].Below = -1;
}
} }
fr.Seek(wallpos, FileReader::SeekSet); fr.Seek(wallpos, FileReader::SeekSet);

View file

@ -570,6 +570,18 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
BLD_NS::Serialize(arc, "xsector", *c._xs, nullptr); BLD_NS::Serialize(arc, "xsector", *c._xs, nullptr);
} }
} }
}
else if (isExhumed())
{
arc("SoundSect", c.SoundSect, def->SoundSect)
("Depth", c.Depth, def->Depth)
("Above", c.Above, def->Above)
("Below", c.Below, def->Below)
("Sound", c.Sound, def->Sound)
("Flag", c.Flag, def->Flag)
("Damage", c.Damage, def->Damage)
("Speed", c.Speed, def->Speed);
} }
arc.EndObject(); arc.EndObject();

View file

@ -243,7 +243,7 @@ void BuildExplosion(DExhumedActor* pActor)
int edx = 36; int edx = 36;
if (SectFlag[nSector] & kSectUnderwater) if (sector[nSector].Flag & kSectUnderwater)
{ {
edx = 75; edx = 75;
} }
@ -271,7 +271,7 @@ void BuildSplash(DExhumedActor* actor, int nSector)
nSound = kSound1; nSound = kSound1;
} }
int bIsLava = SectFlag[nSector] & kSectLava; int bIsLava = sector[nSector].Flag & kSectLava;
int edx, nFlag; int edx, nFlag;

View file

@ -97,7 +97,7 @@ void AIBubble::Tick(RunListEvent* ev)
if (pSprite->z <= sector[nSector].ceilingz) if (pSprite->z <= sector[nSector].ceilingz)
{ {
int nSectAbove = SectAbove[nSector]; int nSectAbove = sector[nSector].Above;
if (pSprite->hitag > -1 && nSectAbove != -1) { if (pSprite->hitag > -1 && nSectAbove != -1) {
BuildAnim(nullptr, 70, 0, pSprite->x, pSprite->y, sector[nSectAbove].floorz, nSectAbove, 64, 0); BuildAnim(nullptr, 70, 0, pSprite->x, pSprite->y, sector[nSectAbove].floorz, nSectAbove, 64, 0);

View file

@ -313,7 +313,7 @@ int MoveBullet(short nBullet)
int x = pSprite->x; int x = pSprite->x;
int y = pSprite->y; int y = pSprite->y;
int z = pSprite->z; // ebx int z = pSprite->z; // ebx
short nSectFlag = SectFlag[pSprite->sectnum]; short nSectFlag = pSprite->sector()->Flag;
int x2, y2, z2; int x2, y2, z2;
@ -412,7 +412,7 @@ MOVEEND:
nVal = coll.type || coll.exbits? 1:0; nVal = coll.type || coll.exbits? 1:0;
// pSprite->sectnum may have changed since we set nSectFlag ? // pSprite->sectnum may have changed since we set nSectFlag ?
short nFlagVal = nSectFlag ^ SectFlag[pSprite->sectnum]; short nFlagVal = nSectFlag ^ pSprite->sector()->Flag;
if (nFlagVal & kSectUnderwater) if (nFlagVal & kSectUnderwater)
{ {
DestroyBullet(nBullet); DestroyBullet(nBullet);
@ -504,7 +504,8 @@ HITWALL:
{ {
if (hitactor == nullptr && hitwall < 0) if (hitactor == nullptr && hitwall < 0)
{ {
if ((SectBelow[hitsect] >= 0 && (SectFlag[SectBelow[hitsect]] & kSectUnderwater)) || SectDepth[hitsect]) auto pHitSect = &sector[hitsect];
if ((pHitSect->Below >= 0 && (sector[pHitSect->Below].Flag & kSectUnderwater)) || pHitSect->Depth)
{ {
pSprite->x = x2; pSprite->x = x2;
pSprite->y = y2; pSprite->y = y2;
@ -711,13 +712,13 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
while (pBulletSprite->z < sector[nSector].ceilingz) while (pBulletSprite->z < sector[nSector].ceilingz)
{ {
if (SectAbove[nSector] == -1) if (sector[nSector].Above == -1)
{ {
pBulletSprite->z = sector[nSector].ceilingz; pBulletSprite->z = sector[nSector].ceilingz;
break; break;
} }
nSector = SectAbove[nSector]; nSector = sector[nSector].Above;
ChangeActorSect(pBulletActor, nSector); ChangeActorSect(pBulletActor, nSector);
} }

View file

@ -89,15 +89,6 @@ extern int Counters[kNumCounters];
void SnapSectors(int nSectorA, int nSectorB, int b); void SnapSectors(int nSectorA, int nSectorB, int b);
extern short SectSound[];
extern short SectDamage[];
extern short SectSpeed[];
extern int SectBelow[];
extern short SectFlag[];
extern int SectDepth[];
extern int SectSoundSect[];
extern int SectAbove[];
void LoadObjects(); void LoadObjects();
// light // light

View file

@ -326,7 +326,7 @@ void AIFish::Tick(RunListEvent* ev)
short nAction = pActor->nAction; short nAction = pActor->nAction;
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater)) if (!(pSprite->sector()->Flag & kSectUnderwater))
{ {
Gravity(pActor); Gravity(pActor);
} }
@ -442,7 +442,7 @@ void AIFish::Tick(RunListEvent* ev)
// loc_2EF54 // loc_2EF54
Collision coll = movesprite(pActor, pSprite->xvel << 13, pSprite->yvel << 13, pSprite->zvel << 2, 0, 0, CLIPMASK0); Collision coll = movesprite(pActor, pSprite->xvel << 13, pSprite->yvel << 13, pSprite->zvel << 2, 0, 0, CLIPMASK0);
if (!(SectFlag[pSprite->sectnum] & kSectUnderwater)) if (!(pSprite->sector()->Flag & kSectUnderwater))
{ {
ChangeActorSect(pActor, nSector); ChangeActorSect(pActor, nSector);
pSprite->x = x; pSprite->x = x;

View file

@ -153,7 +153,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
pActor->nFrame = 1; pActor->nFrame = 1;
if (SectFlag[nGrenadeSect] & kSectUnderwater) if (sector[nGrenadeSect].Flag & kSectUnderwater)
{ {
var_28 = 75; var_28 = 75;
var_20 = 60; var_20 = 60;
@ -300,7 +300,7 @@ void AIGrenade::Tick(RunListEvent* ev)
{ {
if (zVel) if (zVel)
{ {
if (SectDamage[pGrenadeSprite->sectnum] > 0) if (pGrenadeSprite->sector()->Damage > 0)
{ {
ExplodeGrenade(pActor); ExplodeGrenade(pActor);
return; return;

View file

@ -233,7 +233,7 @@ uint8_t WeaponCanFire(int nPlayer)
short nWeapon = PlayerList[nPlayer].nCurrentWeapon; short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
int nSector =PlayerList[nPlayer].nPlayerViewSect; int nSector =PlayerList[nPlayer].nPlayerViewSect;
if (!(SectFlag[nSector] & kSectUnderwater) || WeaponInfo[nWeapon].bFireUnderwater) if (!(sector[nSector].Flag & kSectUnderwater) || WeaponInfo[nWeapon].bFireUnderwater)
{ {
short nAmmoType = WeaponInfo[nWeapon].nAmmoType; short nAmmoType = WeaponInfo[nWeapon].nAmmoType;
@ -324,7 +324,7 @@ void MoveWeapons(int nPlayer)
{ {
static int dword_96E22 = 0; static int dword_96E22 = 0;
short nSectFlag = SectFlag[PlayerList[nPlayer].nPlayerViewSect]; int nSectFlag = sector[PlayerList[nPlayer].nPlayerViewSect].Flag;
if ((nSectFlag & kSectUnderwater) && (totalmoves & 1)) { if ((nSectFlag & kSectUnderwater) && (totalmoves & 1)) {
return; return;

View file

@ -51,15 +51,6 @@ int movefifopos;
short nCurBodyGunNum; short nCurBodyGunNum;
int SectSoundSect[kMaxSectors] = { 0 };
short SectSound[kMaxSectors] = { 0 };
short SectFlag[kMaxSectors] = { 0 };
int SectDepth[kMaxSectors] = { 0 };
int SectAbove[kMaxSectors] = { 0 };
short SectDamage[kMaxSectors] = { 0 };
short SectSpeed[kMaxSectors] = { 0 };
int SectBelow[kMaxSectors] = { 0 };
int Counters[kNumCounters]; int Counters[kNumCounters];
@ -205,12 +196,12 @@ void InitNewGame()
void SetBelow(short nCurSector, short nBelowSector) void SetBelow(short nCurSector, short nBelowSector)
{ {
SectBelow[nCurSector] = nBelowSector; sector[nCurSector].Below = nBelowSector;
} }
void SetAbove(short nCurSector, short nAboveSector) void SetAbove(short nCurSector, short nAboveSector)
{ {
SectAbove[nCurSector] = nAboveSector; sector[nCurSector].Above = nAboveSector;
} }
void SnapSectors(int nSectorA, int nSectorB, int b) void SnapSectors(int nSectorA, int nSectorB, int b)
@ -269,23 +260,19 @@ void SnapSectors(int nSectorA, int nSectorB, int b)
sector[nSectorB].ceilingz = sector[nSectorA].floorz; sector[nSectorB].ceilingz = sector[nSectorA].floorz;
} }
if (SectFlag[nSectorA] & 0x1000) { if (sector[nSectorA].Flag & 0x1000) {
SnapBobs(nSectorA, nSectorB); SnapBobs(nSectorA, nSectorB);
} }
} }
void InitSectFlag() void InitSectFlag()
{ {
for (int i = 0; i < kMaxSectors; i++) for(auto& Sect : sectors())
{ {
SectSoundSect[i] = -1; Sect.SoundSect = -1;
SectSound[i] = -1; Sect.Sound = -1;
SectAbove[i] = -1; Sect.Above = -1;
SectBelow[i] = -1; Sect.Below = -1;
SectDepth[i] = 0;
SectFlag[i] = 0;
SectSpeed[i] = 0;
SectDamage[i] = 0;
} }
} }
@ -603,7 +590,7 @@ void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
{ {
int nSector =pSprite->sectnum; int nSector =pSprite->sectnum;
SetAbove(nSector, nHitag); SetAbove(nSector, nHitag);
SectFlag[nSector] |= kSectUnderwater; sector[nSector].Flag |= kSectUnderwater;
DeleteActor(pActor); DeleteActor(pActor);
return; return;
@ -631,10 +618,10 @@ void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
nDamage = 1; nDamage = 1;
} }
int nSector =pSprite->sectnum; auto pSector =pSprite->sector();
SectDamage[nSector] = nDamage; pSector->Damage = nDamage;
SectFlag[nSector] |= kSectLava; pSector->Flag |= kSectLava;
DeleteActor(pActor); DeleteActor(pActor);
return; return;
@ -648,8 +635,8 @@ void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
} }
case 94: // water case 94: // water
{ {
int nSector =pSprite->sectnum; auto pSector = pSprite->sector();
SectDepth[nSector] = nHitag << 8; pSector->Depth = nHitag << 8;
DeleteActor(pActor); DeleteActor(pActor);
return; return;
@ -667,10 +654,9 @@ void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
case 79: case 79:
case 89: case 89:
{ {
int nSector =pSprite->sectnum; auto pSector = pSprite->sector();
pSector->Speed = nSpeed;
SectSpeed[nSector] = nSpeed; pSector->Flag |= pSprite->ang;
SectFlag[nSector] |= pSprite->ang;
DeleteActor(pActor); DeleteActor(pActor);
return; return;
@ -684,8 +670,8 @@ void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
} }
case 80: // underwater case 80: // underwater
{ {
int nSector =pSprite->sectnum; auto pSector = pSprite->sector();
SectFlag[nSector] |= kSectUnderwater; pSector->Flag |= kSectUnderwater;
DeleteActor(pActor); DeleteActor(pActor);
return; return;
@ -694,8 +680,8 @@ void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
{ {
AddFlow(pSprite->sectnum, nSpeed, 1, pSprite->ang); AddFlow(pSprite->sectnum, nSpeed, 1, pSprite->ang);
int nSector =pSprite->sectnum; auto pSector = pSprite->sector();
SectFlag[nSector] |= 0x8000; pSector->Flag |= 0x8000;
DeleteActor(pActor); DeleteActor(pActor);
return; return;
@ -879,14 +865,6 @@ void SerializeInit(FSerializer& arc)
("curchunk", nCurChunkNum) ("curchunk", nCurChunkNum)
.Array("bodygunsprite", nBodyGunSprite, countof(nBodyGunSprite)) .Array("bodygunsprite", nBodyGunSprite, countof(nBodyGunSprite))
("curbodygun", nCurBodyGunNum) ("curbodygun", nCurBodyGunNum)
.Array("soundsect", SectSoundSect, numsectors)
.Array("sectsound", SectSound, numsectors)
.Array("sectflag", SectFlag, numsectors)
.Array("sectdepth", SectDepth, numsectors)
.Array("sectabove", SectAbove, numsectors)
.Array("sectdamage", SectDamage, numsectors)
.Array("sectspeed", SectSpeed, numsectors)
.Array("sectbelow", SectBelow, numsectors)
.Array("counters", Counters, kNumCounters) .Array("counters", Counters, kNumCounters)
.EndObject(); .EndObject();
} }

View file

@ -237,7 +237,7 @@ int BelowNear(DExhumedActor* pActor, int x, int y, int walldist, int nSector)
} }
else else
{ {
z2 = sector[nSector].floorz + SectDepth[nSector]; z2 = sector[nSector].floorz + sector[nSector].Depth;
BFSSearch search(numsectors, nSector); BFSSearch search(numsectors, nSector);
@ -265,10 +265,10 @@ int BelowNear(DExhumedActor* pActor, int x, int y, int walldist, int nSector)
while (nSect2 >= 0) while (nSect2 >= 0)
{ {
edx = nSect2; edx = nSect2;
nSect2 = SectBelow[nSect2]; nSect2 = sector[nSect2].Below;
} }
int ecx = sector[edx].floorz + SectDepth[edx]; int ecx = sector[edx].floorz + sector[edx].Depth;
int eax = ecx - z; int eax = ecx - z;
if (eax < 0 && eax >= -5120) if (eax < 0 && eax >= -5120)
@ -312,7 +312,7 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
Collision nRet(0); Collision nRet(0);
short nSectFlags = SectFlag[nSector]; short nSectFlags = sector[nSector].Flag;
if (nSectFlags & kSectUnderwater) { if (nSectFlags & kSectUnderwater) {
z >>= 1; z >>= 1;
@ -329,18 +329,16 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
} }
// loc_151E7: // loc_151E7:
while (ebp > pSprite->sector()->floorz && SectBelow[pSprite->sectnum] >= 0) while (ebp > pSprite->sector()->floorz && pSprite->sector()->Below >= 0)
{ {
edi = SectBelow[pSprite->sectnum]; ChangeActorSect(pActor, pSprite->sector()->Below);
ChangeActorSect(pActor, edi);
} }
if (edi != nSector) if (edi != nSector)
{ {
pSprite->z = ebp; pSprite->z = ebp;
if (SectFlag[edi] & kSectUnderwater) if (sector[edi].Flag & kSectUnderwater)
{ {
if (pActor == PlayerList[nLocalPlayer].Actor()) { if (pActor == PlayerList[nLocalPlayer].Actor()) {
D3PlayFX(StaticSound[kSound2], pActor); D3PlayFX(StaticSound[kSound2], pActor);
@ -353,9 +351,9 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
} }
else else
{ {
while ((ebp < pSprite->sector()->ceilingz) && (SectAbove[pSprite->sectnum] >= 0)) while ((ebp < pSprite->sector()->ceilingz) && (pSprite->sector()->Above >= 0))
{ {
edi = SectAbove[pSprite->sectnum]; edi = pSprite->sector()->Above;
ChangeActorSect(pActor, edi); ChangeActorSect(pActor, edi);
} }
@ -374,7 +372,7 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
int mySprfloor = sprfloor; int mySprfloor = sprfloor;
if (loHit.type != kHitSprite) { if (loHit.type != kHitSprite) {
mySprfloor += SectDepth[pSprite->sectnum]; mySprfloor += pSprite->sector()->Depth;
} }
if (ebp > mySprfloor) if (ebp > mySprfloor)
@ -415,11 +413,11 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
else else
{ {
// Path B // Path B
if (SectBelow[pSprite->sectnum] == -1) if (pSprite->sector()->Below == -1)
{ {
nRet.exbits |= kHitAux2; nRet.exbits |= kHitAux2;
short nSectDamage = SectDamage[pSprite->sectnum]; int nSectDamage = pSprite->sector()->Damage;
if (nSectDamage != 0) if (nSectDamage != 0)
{ {
@ -446,7 +444,7 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
} }
else else
{ {
if ((ebp - height) < sprceiling && (hiHit.type == kHitSprite || SectAbove[pSprite->sectnum] == -1)) if ((ebp - height) < sprceiling && (hiHit.type == kHitSprite || pSprite->sector()->Above == -1))
{ {
ebp = sprceiling + height; ebp = sprceiling + height;
nRet.exbits |= kHitAux1; nRet.exbits |= kHitAux1;
@ -455,7 +453,7 @@ Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdis
if (spriteZ <= floorZ && ebp > floorZ) if (spriteZ <= floorZ && ebp > floorZ)
{ {
if ((SectDepth[nSector] != 0) || (edi != nSector && (SectFlag[edi] & kSectUnderwater))) if ((sector[nSector].Depth != 0) || (edi != nSector && (sector[edi].Flag & kSectUnderwater)))
{ {
assert(validSectorIndex(nSector)); assert(validSectorIndex(nSector));
BuildSplash(pActor, nSector); BuildSplash(pActor, nSector);
@ -503,7 +501,7 @@ Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist
int floorZ = sector[nSector].floorz; int floorZ = sector[nSector].floorz;
if ((SectFlag[nSector] & kSectUnderwater) || (floorZ < z)) if ((sector[nSector].Flag & kSectUnderwater) || (floorZ < z))
{ {
dx >>= 1; dx >>= 1;
dy >>= 1; dy >>= 1;
@ -574,7 +572,7 @@ void Gravity(DExhumedActor* actor)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
int nSector =pSprite->sectnum; int nSector =pSprite->sectnum;
if (SectFlag[nSector] & kSectUnderwater) if (sector[nSector].Flag & kSectUnderwater)
{ {
if (pSprite->statnum != 100) if (pSprite->statnum != 100)
{ {
@ -628,26 +626,26 @@ Collision MoveCreatureWithCaution(DExhumedActor* pActor)
int x = pSprite->x; int x = pSprite->x;
int y = pSprite->y; int y = pSprite->y;
int z = pSprite->z; int z = pSprite->z;
short nSectorPre = pSprite->sectnum; auto pSectorPre = pSprite->sector();
auto ecx = MoveCreature(pActor); auto ecx = MoveCreature(pActor);
int nSector =pSprite->sectnum; auto pSector =pSprite->sector();
if (nSector != nSectorPre) if (pSector != pSectorPre)
{ {
int zDiff = sector[nSectorPre].floorz - sector[nSector].floorz; int zDiff = pSectorPre->floorz - pSector->floorz;
if (zDiff < 0) { if (zDiff < 0) {
zDiff = -zDiff; zDiff = -zDiff;
} }
if (zDiff > 15360 || (SectFlag[nSector] & kSectUnderwater) || (SectBelow[nSector] > -1 && SectFlag[SectBelow[nSector]]) || SectDamage[nSector]) if (zDiff > 15360 || (pSector->Flag & kSectUnderwater) || (pSector->Below > -1 && sector[pSector->Below].Flag) || pSector->Damage)
{ {
pSprite->x = x; pSprite->x = x;
pSprite->y = y; pSprite->y = y;
pSprite->z = z; pSprite->z = z;
ChangeActorSect(pActor, nSectorPre); ChangeActorSect(pActor, sectnum(pSectorPre));
pSprite->ang = (pSprite->ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
@ -750,13 +748,14 @@ DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage)
void CheckSectorFloor(int nSector, int z, int *x, int *y) void CheckSectorFloor(int nSector, int z, int *x, int *y)
{ {
short nSpeed = SectSpeed[nSector]; auto pSector = &sector[nSector];
int nSpeed = pSector->Speed;
if (!nSpeed) { if (!nSpeed) {
return; return;
} }
short nFlag = SectFlag[nSector]; short nFlag = pSector->Flag;
short nAng = nFlag & kAngleMask; short nAng = nFlag & kAngleMask;
if (z >= sector[nSector].floorz) if (z >= sector[nSector].floorz)
@ -891,7 +890,7 @@ void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel)
short nBlock = pSector->extra; short nBlock = pSector->extra;
short nSectFlag = SectFlag[nSector]; short nSectFlag = sector[nSector].Flag;
int nFloorZ = pSector->floorz; int nFloorZ = pSector->floorz;
int startwall = pSector->wallptr; int startwall = pSector->wallptr;

View file

@ -2199,7 +2199,7 @@ void DoDrips()
short nSeqOffset = SeqOffsets[kSeqDrips]; short nSeqOffset = SeqOffsets[kSeqDrips];
if (!(SectFlag[pSprite->sectnum] & kSectLava)) { if (!(pSprite->sector()->Flag & kSectLava)) {
nSeqOffset++; nSeqOffset++;
} }
@ -2293,7 +2293,7 @@ void AddSectorBob(int nSector, int nHitag, int bx)
sBob[nBobs].nSector = nSector; sBob[nBobs].nSector = nSector;
StartInterpolation(nSector, bx == 0 ? Interp_Sect_Floorz : Interp_Sect_Ceilingz); StartInterpolation(nSector, bx == 0 ? Interp_Sect_Floorz : Interp_Sect_Ceilingz);
SectFlag[nSector] |= 0x0010; sector[nSector].Flag |= 0x0010;
} }
int FindTrail(int nVal) int FindTrail(int nVal)
@ -2555,7 +2555,7 @@ void PostProcess()
int nSector =sMoveSect[i].nSector; int nSector =sMoveSect[i].nSector;
if (SectFlag[nSector] & kSectUnderwater) if (sector[nSector].Flag & kSectUnderwater)
{ {
sector[nSector].ceilingstat |= 0x40; sector[nSector].ceilingstat |= 0x40;
sector[nSector].floorstat &= 0xBFFF; sector[nSector].floorstat &= 0xBFFF;
@ -2596,30 +2596,32 @@ void PostProcess()
// esi is i // esi is i
for (i = 0; i < numsectors; i++) for (i = 0; i < numsectors; i++)
{ {
auto secti = &sector[i];
int var_20 = 30000; int var_20 = 30000;
if (SectSpeed[i] && SectDepth[i] && !(SectFlag[i] & kSectLava)) if (secti->Speed && secti->Depth && !(secti->Flag & kSectLava))
{ {
SectSoundSect[i] = i; secti->SoundSect = i;
SectSound[i] = StaticSound[kSound43]; secti->Sound = StaticSound[kSound43];
} }
else else
{ {
// ebp and ecx are j // ebp and ecx are j
for (j = 0; j < numsectors; j++) for (j = 0; j < numsectors; j++)
{ {
auto sectj = &sector[j];
// loc_23CA6: // loc_23CA6:
if (i != j && SectSpeed[j] && !(SectFlag[i] & kSectLava)) if (i != j && sectj->Speed && !(secti->Flag & kSectLava))
{ {
int xVal = abs(sector[i].firstWall()->x - sector[j].firstWall()->x); int xVal = abs(secti->firstWall()->x - sectj->firstWall()->x);
int yVal = abs(sector[i].firstWall()->y - sector[j].firstWall()->y); int yVal = abs(secti->firstWall()->y - sectj->firstWall()->y);
if (xVal < 15000 && yVal < 15000 && (xVal + yVal < var_20)) if (xVal < 15000 && yVal < 15000 && (xVal + yVal < var_20))
{ {
var_20 = xVal + yVal; var_20 = xVal + yVal;
SectSoundSect[i] = j; secti->SoundSect = j;
SectSound[i] = StaticSound[kSound43]; secti->Sound = StaticSound[kSound43];
} }
} }
} }
@ -2633,8 +2635,9 @@ void PostProcess()
for (i = 0; i < numsectors; i++) for (i = 0; i < numsectors; i++)
{ {
SectSoundSect[i] = i; auto secti = &sector[i];
SectSound[i] = StaticSound[kSound62]; secti->SoundSect = i;
secti->Sound = StaticSound[kSound62];
int startwall = sector[ebp].wallptr; int startwall = sector[ebp].wallptr;
int endwall = sector[ebp].wallptr + sector[ebp].wallnum; int endwall = sector[ebp].wallptr + sector[ebp].wallnum;

View file

@ -458,8 +458,9 @@ void StartDeathSeq(int nPlayer, int nVal)
if (nWeapon > kWeaponSword && nWeapon <= kWeaponRing) if (nWeapon > kWeaponSword && nWeapon <= kWeaponRing)
{ {
int nSector =pSprite->sectnum; int nSector =pSprite->sectnum;
if (SectBelow[nSector] > -1) { auto pSector = pSprite->sector();
nSector = SectBelow[nSector]; if (pSector->Below > -1) {
nSector = pSector->Below;
} }
auto pGunActor = GrabBodyGunSprite(); auto pGunActor = GrabBodyGunSprite();
@ -490,7 +491,7 @@ void StartDeathSeq(int nPlayer, int nVal)
SetNewWeaponImmediate(nPlayer, -2); SetNewWeaponImmediate(nPlayer, -2);
if (SectDamage[pSprite->sectnum] <= 0) if (pSprite->sector()->Damage <= 0)
{ {
PlayerList[nPlayer].nDeathType = nVal; PlayerList[nPlayer].nDeathType = nVal;
} }
@ -501,7 +502,7 @@ void StartDeathSeq(int nPlayer, int nVal)
nVal *= 2; nVal *= 2;
if (nVal || !(SectFlag[pSprite->sectnum] & kSectUnderwater)) if (nVal || !(pSprite->sector()->Flag & kSectUnderwater))
{ {
PlayerList[nPlayer].nAction = nVal + 17; PlayerList[nPlayer].nAction = nVal + 17;
} }
@ -673,7 +674,7 @@ void AIPlayer::Damage(RunListEvent* ev)
return; return;
} }
if (SectFlag[pPlayerSprite->sectnum] & kSectUnderwater) if (pPlayerSprite->sector()->Flag & kSectUnderwater)
{ {
if (nAction != 12) if (nAction != 12)
{ {
@ -864,7 +865,7 @@ void AIPlayer::Tick(RunListEvent* ev)
// loc_1A4E6 // loc_1A4E6
int nSector =pPlayerSprite->sectnum; int nSector =pPlayerSprite->sectnum;
short nSectFlag = SectFlag[PlayerList[nPlayer].nPlayerViewSect]; int nSectFlag = sector[PlayerList[nPlayer].nPlayerViewSect].Flag;
int playerX = pPlayerSprite->x; int playerX = pPlayerSprite->x;
int playerY = pPlayerSprite->y; int playerY = pPlayerSprite->y;
@ -929,7 +930,7 @@ void AIPlayer::Tick(RunListEvent* ev)
} }
// int _bTouchFloor = bTouchFloor; // int _bTouchFloor = bTouchFloor;
short bUnderwater = SectFlag[pPlayerSprite->sectnum] & kSectUnderwater; short bUnderwater = pPlayerSprite->sector()->Flag & kSectUnderwater;
if (bUnderwater) if (bUnderwater)
{ {
@ -938,7 +939,7 @@ void AIPlayer::Tick(RunListEvent* ev)
} }
// Trigger Ramses? // Trigger Ramses?
if ((SectFlag[pPlayerSprite->sectnum] & 0x8000) && bTouchFloor) if ((pPlayerSprite->sector()->Flag & 0x8000) && bTouchFloor)
{ {
if (nTotalPlayers <= 1) if (nTotalPlayers <= 1)
{ {
@ -1121,10 +1122,10 @@ sectdone:
if (EyeZ >= nCeilZ) if (EyeZ >= nCeilZ)
break; break;
if (SectAbove[nViewSect] <= -1) if (sector[nViewSect].Above <= -1)
break; break;
nViewSect = SectAbove[nViewSect]; nViewSect = sector[nViewSect].Above;
} }
// Do underwater sector check // Do underwater sector check
@ -1171,7 +1172,7 @@ sectdone:
PlayerList[nPlayer].nPlayerDX = pPlayerSprite->x - spr_x; PlayerList[nPlayer].nPlayerDX = pPlayerSprite->x - spr_x;
PlayerList[nPlayer].nPlayerDY = pPlayerSprite->y - spr_y; PlayerList[nPlayer].nPlayerDY = pPlayerSprite->y - spr_y;
int var_5C = SectFlag[nViewSect] & kSectUnderwater; int var_5C = sector[nViewSect].Flag & kSectUnderwater;
auto actions = sPlayerInput[nPlayer].actions; auto actions = sPlayerInput[nPlayer].actions;
@ -1249,11 +1250,11 @@ sectdone:
} }
else else
{ {
int nTmpSectNum = pPlayerSprite->sectnum; auto pTmpSect = pPlayerSprite->sector();
if (PlayerList[nPlayer].totalvel > 25 && pPlayerSprite->z > sector[nTmpSectNum].floorz) if (PlayerList[nPlayer].totalvel > 25 && pPlayerSprite->z > pTmpSect->floorz)
{ {
if (SectDepth[nTmpSectNum] && !SectSpeed[nTmpSectNum] && !SectDamage[nTmpSectNum]) if (pTmpSect->Depth && !pTmpSect->Speed && !pTmpSect->Damage)
{ {
D3PlayFX(StaticSound[kSound42], pPlayerActor); D3PlayFX(StaticSound[kSound42], pPlayerActor);
} }
@ -2593,7 +2594,7 @@ sectdone:
} }
else if (PlayerList[nPlayer].horizon.horiz.asq16() <= 0) else if (PlayerList[nPlayer].horizon.horiz.asq16() <= 0)
{ {
if (!(SectFlag[pPlayerSprite->sectnum] & kSectUnderwater)) if (!(pPlayerSprite->sector()->Flag & kSectUnderwater))
{ {
SetNewWeapon(nPlayer, PlayerList[nPlayer].nDeathType + 8); SetNewWeapon(nPlayer, PlayerList[nPlayer].nDeathType + 8);
} }
@ -2607,10 +2608,10 @@ sectdone:
// loc_1C4E1 // loc_1C4E1
pDopple->s().pos = pPlayerSprite->pos; pDopple->s().pos = pPlayerSprite->pos;
if (SectAbove[pPlayerSprite->sectnum] > -1) if (pPlayerSprite->sector()->Above > -1)
{ {
pDopple->s().ang = pPlayerSprite->ang; pDopple->s().ang = pPlayerSprite->ang;
ChangeActorSect(pDopple, SectAbove[pPlayerSprite->sectnum]); ChangeActorSect(pDopple, pPlayerSprite->sector()->Above);
pDopple->s().cstat = 0x101; pDopple->s().cstat = 0x101;
} }
else else
@ -2764,7 +2765,7 @@ DEFINE_ACTION_FUNCTION(_ExhumedPlayer, IsUnderwater)
{ {
PARAM_SELF_STRUCT_PROLOGUE(Player); PARAM_SELF_STRUCT_PROLOGUE(Player);
auto nLocalPlayer = self - PlayerList; auto nLocalPlayer = self - PlayerList;
ACTION_RETURN_BOOL(SectFlag[PlayerList[nLocalPlayer].nPlayerViewSect] & kSectUnderwater); ACTION_RETURN_BOOL(sector[PlayerList[nLocalPlayer].nPlayerViewSect].Flag & kSectUnderwater);
} }
DEFINE_ACTION_FUNCTION(_ExhumedPlayer, GetAngle) DEFINE_ACTION_FUNCTION(_ExhumedPlayer, GetAngle)

View file

@ -1509,7 +1509,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
case 80: case 80:
{ {
SectFlag[nSector] |= 0x8000; sector[nSector].Flag |= 0x8000;
return; return;
} }
} }
@ -1784,7 +1784,7 @@ void runlist_DamageEnemy(DExhumedActor* pActor, DExhumedActor* pActor2, short nD
auto pPlayerActor = PlayerList[nPlayer].Actor(); auto pPlayerActor = PlayerList[nPlayer].Actor();
int nSector = pPlayerActor->s().sectnum; int nSector = pPlayerActor->s().sectnum;
if (!(SectFlag[nSector] & kSectUnderwater)) if (!(sector[nSector].Flag & kSectUnderwater))
{ {
int ebx = 0x4000; int ebx = 0x4000;

View file

@ -363,7 +363,7 @@ void seq_DrawPilotLightSeq(double xOffset, double yOffset)
{ {
short nSect = PlayerList[nLocalPlayer].nPlayerViewSect; short nSect = PlayerList[nLocalPlayer].nPlayerViewSect;
if (!(SectFlag[nSect] & kSectUnderwater)) if (!(sector[nSect].Flag & kSectUnderwater))
{ {
short nFrame = nPilotLightBase + nPilotLightFrame; short nFrame = nPilotLightBase + nPilotLightFrame;
short nFrameBase = FrameBase[nFrame]; short nFrameBase = FrameBase[nFrame];

View file

@ -238,7 +238,7 @@ void InitFX(void)
void GetSpriteSoundPitch(int* pVolume, int* pPitch) void GetSpriteSoundPitch(int* pVolume, int* pPitch)
{ {
int nSoundSect = PlayerList[nLocalPlayer].nPlayerViewSect; int nSoundSect = PlayerList[nLocalPlayer].nPlayerViewSect;
int nLocalSectFlags = SectFlag[nSoundSect]; int nLocalSectFlags = sector[nSoundSect].Flag;
if (nLocalSectFlags & kSectUnderwater) if (nLocalSectFlags & kSectUnderwater)
{ {
if (*pVolume == 255) if (*pVolume == 255)
@ -673,15 +673,16 @@ void PlayFXAtXYZ(unsigned short ax, int x, int y, int z, int nSector, EChanFlags
void CheckAmbience(int nSector) void CheckAmbience(int nSector)
{ {
if (!SoundEnabled()) return; if (!SoundEnabled()) return;
if (SectSound[nSector] != -1) auto sect = &sector[nSector];
if (sect->Sound != -1)
{ {
int nSector2 = SectSoundSect[nSector]; int nSector2 = sect->SoundSect;
walltype* pWall = &wall[sector[nSector2].wallptr]; walltype* pWall = sector[nSector2].firstWall();
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, &amb, 0)) if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, &amb, 0))
{ {
vec3_t v = { pWall->x, pWall->y, sector[nSector2].floorz }; vec3_t v = { pWall->x, pWall->y, sector[nSector2].floorz };
amb = GetSoundPos(&v); amb = GetSoundPos(&v);
soundEngine->StartSound(SOURCE_Ambient, &amb, nullptr, CHAN_BODY, CHANF_TRANSIENT, SectSound[nSector] + 1, 1.f, ATTN_NORM); soundEngine->StartSound(SOURCE_Ambient, &amb, nullptr, CHAN_BODY, CHANF_TRANSIENT, sect->Sound + 1, 1.f, ATTN_NORM);
return; return;
} }
soundEngine->EnumerateChannels([=](FSoundChan* chan) soundEngine->EnumerateChannels([=](FSoundChan* chan)
@ -725,7 +726,7 @@ void UpdateCreepySounds()
nCreepyTimer--; nCreepyTimer--;
if (nCreepyTimer <= 0) if (nCreepyTimer <= 0)
{ {
if (nCreaturesKilled < nCreaturesTotal && !(SectFlag[PlayerList[nLocalPlayer].nPlayerViewSect] & 0x2000)) if (nCreaturesKilled < nCreaturesTotal && !(sector[PlayerList[nLocalPlayer].nPlayerViewSect].Flag & 0x2000))
{ {
int vsi = seq_GetFrameSound(SeqOffsets[kSeqCreepy], totalmoves % SeqSize[SeqOffsets[kSeqCreepy]]); int vsi = seq_GetFrameSound(SeqOffsets[kSeqCreepy], totalmoves % SeqSize[SeqOffsets[kSeqCreepy]]);
if (vsi >= 0 && (vsi & 0x1ff) < kMaxSounds) if (vsi >= 0 && (vsi & 0x1ff) < kMaxSounds)

View file

@ -217,7 +217,7 @@ void AIWasp::Tick(RunListEvent* ev)
{ {
pTarget = pActor->pTarget; pTarget = pActor->pTarget;
if (pTarget && (!(pTarget->s().cstat & 0x101) || (SectFlag[pTarget->s().sectnum] & kSectUnderwater))) if (pTarget && (!(pTarget->s().cstat & 0x101) || (pTarget->s().sector()->Flag & kSectUnderwater)))
{ {
// goto pink // goto pink
pActor->pTarget = nullptr; pActor->pTarget = nullptr;
@ -344,7 +344,7 @@ void AIWasp::Tick(RunListEvent* ev)
if (pSprite->z >= sector[nSector].floorz) if (pSprite->z >= sector[nSector].floorz)
{ {
if (SectBelow[nSector] > -1) if (sector[nSector].Below > -1)
{ {
BuildSplash(pActor, nSector); BuildSplash(pActor, nSector);
pSprite->cstat |= 0x8000; pSprite->cstat |= 0x8000;