From fb53f326030637675a6765c5db83d3a0315c796a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Dec 2021 23:04:26 +0100 Subject: [PATCH] - handle the remaining write accesses to ceilingz and floorz. Everything is routed through the wrapper functions now. --- source/core/savegamehelp.cpp | 2 +- source/games/blood/src/_polymost.cpp | 4 ++-- source/games/blood/src/db.cpp | 4 ++-- source/games/blood/src/triggers.cpp | 12 ++++++------ source/games/exhumed/src/init.cpp | 2 +- source/games/exhumed/src/move.cpp | 8 ++++---- source/games/exhumed/src/object.cpp | 12 ++++++------ source/games/exhumed/src/runlist.cpp | 2 +- source/games/sw/src/_polymost.cpp | 4 ++-- source/games/sw/src/copysect.cpp | 4 ++-- source/games/sw/src/game.h | 4 ++-- source/games/sw/src/interpso.cpp | 4 ++-- source/games/sw/src/rooms.cpp | 4 ++-- source/games/sw/src/sector.cpp | 14 +++++++------- source/games/sw/src/sprite.cpp | 8 +++----- source/games/sw/src/track.cpp | 4 ++-- source/games/sw/src/vator.cpp | 8 ++++---- 17 files changed, 49 insertions(+), 51 deletions(-) diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index edba7ea2a..a7232ce2a 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -512,7 +512,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort ("lastentry", c.lastEntry) ("wallptr", c.wallptr, def->wallptr) ("wallnum", c.wallnum, def->wallnum) -#ifndef SECTOR_HACKJOB // +#ifndef SECTOR_HACKJOB // can't save these in test mode... ("ceilingz", c.ceilingz, def->ceilingz) ("floorz", c.floorz, def->floorz) #endif diff --git a/source/games/blood/src/_polymost.cpp b/source/games/blood/src/_polymost.cpp index 293a1eb23..940877387 100644 --- a/source/games/blood/src/_polymost.cpp +++ b/source/games/blood/src/_polymost.cpp @@ -228,8 +228,8 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int wallarr[mirrorwall[2]].pos.Y = wallarr[mirrorwall[1]].pos.Y + (wallarr[mirrorwall[1]].pos.Y - wallarr[mirrorwall[0]].pos.Y) * 16; wallarr[mirrorwall[3]].pos.X = wallarr[mirrorwall[0]].pos.X + (wallarr[mirrorwall[0]].pos.X - wallarr[mirrorwall[1]].pos.X) * 16; wallarr[mirrorwall[3]].pos.Y = wallarr[mirrorwall[0]].pos.Y + (wallarr[mirrorwall[0]].pos.Y - wallarr[mirrorwall[1]].pos.Y) * 16; - sector.Data()[mirrorsector].floorz = sector[nSector].floorz; - sector.Data()[mirrorsector].ceilingz = sector[nSector].ceilingz; + sector.Data()[mirrorsector].setfloorz(sector[nSector].floorz, true); + sector.Data()[mirrorsector].setceilingz(sector[nSector].ceilingz, true); int cx, cy, ca; if (pWall->type == kWallStack) { diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index e76034bc5..be8365f76 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -253,8 +253,8 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect } pSector->wallptr = LittleShort(load.wallptr); pSector->wallnum = LittleShort(load.wallnum); - pSector->ceilingz = LittleLong(load.ceilingz); - pSector->floorz = LittleLong(load.floorz); + pSector->setceilingz(LittleLong(load.ceilingz)); + pSector->setfloorz(LittleLong(load.floorz)); pSector->ceilingstat = ESectorFlags::FromInt(LittleShort(load.ceilingstat)); pSector->floorstat = ESectorFlags::FromInt(LittleShort(load.floorstat)); pSector->ceilingpicnum = LittleShort(load.ceilingpicnum); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index c50447730..6347373ae 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -903,7 +903,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR *pXSector, int a3, int a4) if (dz != 0) { int oldZ = pSector->floorz; - pSector->baseFloor = pSector->floorz = pXSector->offFloorZ + MulScale(dz, GetWaveValue(a3, a4), 16); + pSector->setfloorz((pSector->baseFloor = pXSector->offFloorZ + MulScale(dz, GetWaveValue(a3, a4), 16))); pSector->velFloor += (pSector->floorz-oldZ)<<8; BloodSectIterator it(pSector); @@ -931,7 +931,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR *pXSector, int a3, int a4) if (dz != 0) { int oldZ = pSector->ceilingz; - pSector->baseCeil = pSector->ceilingz = pXSector->offCeilZ + MulScale(dz, GetWaveValue(a3, a4), 16); + pSector->setceilingz((pSector->baseCeil = pXSector->offCeilZ + MulScale(dz, GetWaveValue(a3, a4), 16))); pSector->velCeil += (pSector->ceilingz-oldZ)<<8; BloodSectIterator it(pSector); @@ -1018,9 +1018,9 @@ int VCrushBusy(sectortype *pSector, unsigned int a2) return 1; viewInterpolateSector(pSector); if (dz1 != 0) - pSector->ceilingz = vc; + pSector->setceilingz(vc); if (dz2 != 0) - pSector->floorz = v10; + pSector->setfloorz(v10); pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) evSendSector(pSector,pXSector->txID, kCmdLink); @@ -1803,7 +1803,7 @@ void ProcessMotion(void) { int floorZ = pSector->floorz; viewInterpolateSector(pSector); - pSector->floorz = pSector->baseFloor + vdi; + pSector->setfloorz(pSector->baseFloor + vdi); BloodSectIterator itr(pSector); while (auto actor = itr.Next()) @@ -1826,7 +1826,7 @@ void ProcessMotion(void) { int ceilZ = pSector->ceilingz; viewInterpolateSector(pSector); - pSector->ceilingz = pSector->baseCeil + vdi; + pSector->setceilingz(pSector->baseCeil + vdi); BloodSectIterator itr(pSector); while (auto actor = itr.Next()) diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 2b72bb8d1..e9ab39425 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -251,7 +251,7 @@ void SnapSectors(sectortype* pSectorA, sectortype* pSectorB, int b) } if (b) { - pSectorB->ceilingz = pSectorA->floorz; + pSectorB->setceilingz(pSectorA->floorz); } if (pSectorA->Flag & 0x1000) { diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index a83cf9914..ccbc6c0a9 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -900,14 +900,14 @@ void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel) nZVal = pSector->ceilingz; pos.Z = pNextSector->ceilingz + 256; - pSector->ceilingz = pNextSector->ceilingz; + pSector->setceilingz(pNextSector->ceilingz); } else { nZVal = pSector->floorz; pos.Z = pNextSector->floorz - 256; - pSector->floorz = pNextSector->floorz; + pSector->setfloorz(pNextSector->floorz); } auto pSectorB = pSector; @@ -1061,10 +1061,10 @@ void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel) } if (nSectFlag & kSectUnderwater) { - pSector->ceilingz = nZVal; + pSector->setceilingz(nZVal); } else { - pSector->floorz = nZVal; + pSector->setfloorz(nZVal); } *nXVel = xvect; diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index d06260a6c..c09626696 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -857,7 +857,7 @@ void AIElev::Tick(RunListEvent* ev) } StartInterpolation(pSector, Interp_Sect_Ceilingz); - pSector->ceilingz = ceilZ; + pSector->setceilingz(ceilZ); } // maybe this doesn't go here? @@ -1663,7 +1663,7 @@ void ExplodeEnergyBlock(DExhumedActor* pActor) pSector->floorshade = 50; pSector->extra = -1; - pSector->floorz = pActor->spr.pos.Z; + pSector->setfloorz(pActor->spr.pos.Z); pActor->spr.pos.Z = (pActor->spr.pos.Z + pSector->floorz) / 2; @@ -1772,13 +1772,13 @@ void AIEnergyBlock::RadialDamage(RunListEvent* ev) int nFloorZ = pSector->floorz; - pSector->floorz = pActor->spr.pos.Z; + pSector->setfloorz(pActor->spr.pos.Z); pActor->spr.pos.Z -= 256; ev->nDamage = runlist_CheckRadialDamage(pActor); // restore previous values - pSector->floorz = nFloorZ; + pSector->setfloorz(nFloorZ); pActor->spr.pos.Z += 256; if (ev->nDamage <= 0) { @@ -2122,13 +2122,13 @@ void DoDrips() if (sBob[i].field_3) { - pSector->ceilingz = edx + sBob[i].z; + pSector->setceilingz(edx + sBob[i].z); } else { int nFloorZ = pSector->floorz; - pSector->floorz = edx + sBob[i].z; + pSector->setfloorz(edx + sBob[i].z); MoveSectorSprites(pSector, pSector->floorz - nFloorZ); } diff --git a/source/games/exhumed/src/runlist.cpp b/source/games/exhumed/src/runlist.cpp index dc0b46be3..cab42995a 100644 --- a/source/games/exhumed/src/runlist.cpp +++ b/source/games/exhumed/src/runlist.cpp @@ -706,7 +706,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag) runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second); - pSector->floorz = nextSectorP->floorz; + pSector->setfloorz(nextSectorP->floorz); return; } diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index ab3c3f2c3..6309c369d 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -51,7 +51,7 @@ void DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, // reset Z's for (int i = 0; i < save.zcount; i++) { - save.sect[i]->floorz = save.zval[i]; + save.sect[i]->setfloorz(save.zval[i], true); save.sect[i]->floorpicnum = save.pic[i]; save.sect[i]->setfloorslope(save.slope[i]); } @@ -76,7 +76,7 @@ void DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, // reset Z's for (int i = 0; i < save.zcount; i++) { - save.sect[i]->ceilingz = save.zval[i]; + save.sect[i]->setceilingz(save.zval[i], true); save.sect[i]->ceilingpicnum = save.pic[i]; save.sect[i]->setceilingslope(save.slope[i]); } diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index f30784954..587eed0b8 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -212,8 +212,8 @@ void CopySectorMatch(int match) dsectp->hitag = ssectp->hitag; dsectp->lotag = ssectp->lotag; - dsectp->floorz = ssectp->floorz; - dsectp->ceilingz = ssectp->ceilingz; + dsectp->setfloorz(ssectp->floorz); + dsectp->setceilingz(ssectp->ceilingz); dsectp->floorshade = ssectp->floorshade; dsectp->ceilingshade = ssectp->ceilingshade; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 3b2cd3a3b..a4bcf4b52 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2170,13 +2170,13 @@ struct ANIMstruct ANIM_CALLBACKp callback; SECTOR_OBJECTp callbackdata; // only gets used in one place for this so having a proper type makes serialization easier. - int& Addr() + int& Addr(bool write) { static int scratch; switch (animtype) { case ANIM_Floorz: - return sector[animindex].floorz; + return *sector[animindex].floorzptr(!write); case ANIM_SopZ: return SectorObject[animindex].zmid; case ANIM_Spritez: diff --git a/source/games/sw/src/interpso.cpp b/source/games/sw/src/interpso.cpp index 8ab45e2f1..850b662f5 100644 --- a/source/games/sw/src/interpso.cpp +++ b/source/games/sw/src/interpso.cpp @@ -102,9 +102,9 @@ static int &getvalue(so_interp::interp_data& element, bool write) if (write) wall[index].moved(); return wall[index].pos.Y; case soi_ceil: - return sector[index].ceilingz; + return *sector[index].ceilingzptr(!write); case soi_floor: - return sector[index].floorz; + return *sector[index].floorzptr(!write); case soi_sox: return SectorObject[index].xmid; case soi_soy: diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 596f11116..c45092526 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -725,7 +725,7 @@ bool FindCeilingView(int match, int* x, int* y, int z, sectortype** sect) save.pic[save.zcount] = actor->spr.sector()->floorpicnum; save.slope[save.zcount] = actor->spr.sector()->floorheinum; - actor->spr.sector()->floorz = newz; + actor->spr.sector()->setfloorz(newz, true); // don't change FAF_MIRROR_PIC - ConnectArea if (actor->spr.sector()->floorpicnum != FAF_MIRROR_PIC) actor->spr.sector()->floorpicnum = FAF_MIRROR_PIC + 1; @@ -814,7 +814,7 @@ bool FindFloorView(int match, int* x, int* y, int z, sectortype** sect) save.pic[save.zcount] = actor->spr.sector()->ceilingpicnum; save.slope[save.zcount] = actor->spr.sector()->ceilingheinum; - actor->spr.sector()->ceilingz = newz; + actor->spr.sector()->setceilingz(newz, true); // don't change FAF_MIRROR_PIC - ConnectArea if (actor->spr.sector()->ceilingpicnum != FAF_MIRROR_PIC) diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 8a82359f2..cbc2a91ad 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -879,7 +879,7 @@ void DoExplodeSector(short match) sectp = actor->spr.sector(); - sectp->ceilingz -= Z(SP_TAG4(actor)); + sectp->addceilingz(-Z(SP_TAG4(actor))); if (SP_TAG5(actor)) { @@ -1255,7 +1255,7 @@ void DoChangorMatch(short match) if (TEST_BOOL1(actor)) { sectp->ceilingpicnum = SP_TAG4(actor); - sectp->ceilingz += Z(SP_TAG5(actor)); + sectp->addceilingz(Z(SP_TAG5(actor))); sectp->ceilingheinum += SP_TAG6(actor); if (sectp->ceilingheinum) @@ -1269,7 +1269,7 @@ void DoChangorMatch(short match) else { sectp->floorpicnum = SP_TAG4(actor); - sectp->floorz += Z(SP_TAG5(actor)); + sectp->addfloorz(Z(SP_TAG5(actor))); sectp->floorheinum += SP_TAG6(actor); if (sectp->floorheinum) @@ -2342,13 +2342,13 @@ void DoSineWaveFloor(void) if (TEST(flags, SINE_FLOOR)) { newz = swf->floor_origz + MulScale(swf->range, bsin(swf->sintable_ndx), 14); - swf->sectp->floorz = newz; + swf->sectp->setfloorz(newz); } if (TEST(flags, SINE_CEILING)) { newz = swf->ceiling_origz + MulScale(swf->range, bsin(swf->sintable_ndx), 14); - swf->sectp->ceilingz = newz; + swf->sectp->setceilingz(newz); } } @@ -2423,7 +2423,7 @@ void DoAnim(int numtics) for (i = AnimCnt - 1; i >= 0; i--) { - animval = Anim[i].Addr(); + animval = Anim[i].Addr(true); // if LESS THAN goal if (animval < Anim[i].goal) @@ -2449,7 +2449,7 @@ void DoAnim(int numtics) animval = Anim[i].goal; } - Anim[i].Addr() =animval; + Anim[i].Addr(true) =animval; // EQUAL this entry has finished if (animval == Anim[i].goal) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index cba4f85cd..eb39b32ab 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -2054,8 +2054,7 @@ void SpriteSetup(void) amt = actor->spr.pos.Z - sectp->floorz; // start in the on position - //sectp->floorz = actor->spr.z; - sectp->floorz += amt; + sectp->addfloorz(amt); actor->user.z_tgt = actor->user.sz; MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor @@ -2075,8 +2074,7 @@ void SpriteSetup(void) amt = actor->spr.pos.Z - sectp->ceilingz; // starting in the on position - //sectp->ceilingz = actor->spr.z; - sectp->ceilingz += amt; + sectp->addceilingz(amt); actor->user.z_tgt = actor->user.sz; MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling @@ -2455,7 +2453,7 @@ void SpriteSetup(void) SP_TAG4(actor) = abs(sectp->ceilingz - sectp->floorz)>>8; - sectp->ceilingz = sectp->floorz; + sectp->setceilingz(sectp->floorz); change_actor_stat(actor, STAT_EXPLODING_CEIL_FLOOR); break; diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 3bdf98dc0..28bd6c31b 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -2042,7 +2042,7 @@ void MoveZ(SECTOR_OBJECTp sop) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB)) continue; - (*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff; + (*sectp)->setfloorz(sop->zorig_floor[i] + sop->bob_diff); } } @@ -2602,7 +2602,7 @@ void OperateSectorObjectForTics(SECTOR_OBJECTp sop, short newang, int newx, int if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB)) continue; - (*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff; + (*sectp)->setfloorz(sop->zorig_floor[i] + sop->bob_diff); } } diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index 3182087fa..e8083228e 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -370,13 +370,13 @@ int DoVator(DSWActor* actor) if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP)) { - lptr = §p->ceilingz; + lptr = sectp->ceilingzptr(); amt = DoVatorMove(actor, lptr); MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling } else { - lptr = §p->floorz; + lptr = sectp->floorzptr(); amt = DoVatorMove(actor, lptr); MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor } @@ -521,13 +521,13 @@ int DoVatorAuto(DSWActor* actor) if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP)) { - lptr = §p->ceilingz; + lptr = sectp->ceilingzptr(); amt = DoVatorMove(actor, lptr); MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling } else { - lptr = §p->floorz; + lptr = sectp->floorzptr(); amt = DoVatorMove(actor, lptr); MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor }