- handle the remaining write accesses to ceilingz and floorz.

Everything is routed through the wrapper functions now.
This commit is contained in:
Christoph Oelckers 2021-12-27 23:04:26 +01:00
parent 059412b75e
commit fb53f32603
17 changed files with 49 additions and 51 deletions

View file

@ -512,7 +512,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
("lastentry", c.lastEntry) ("lastentry", c.lastEntry)
("wallptr", c.wallptr, def->wallptr) ("wallptr", c.wallptr, def->wallptr)
("wallnum", c.wallnum, def->wallnum) ("wallnum", c.wallnum, def->wallnum)
#ifndef SECTOR_HACKJOB // #ifndef SECTOR_HACKJOB // can't save these in test mode...
("ceilingz", c.ceilingz, def->ceilingz) ("ceilingz", c.ceilingz, def->ceilingz)
("floorz", c.floorz, def->floorz) ("floorz", c.floorz, def->floorz)
#endif #endif

View file

@ -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[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.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; 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].setfloorz(sector[nSector].floorz, true);
sector.Data()[mirrorsector].ceilingz = sector[nSector].ceilingz; sector.Data()[mirrorsector].setceilingz(sector[nSector].ceilingz, true);
int cx, cy, ca; int cx, cy, ca;
if (pWall->type == kWallStack) if (pWall->type == kWallStack)
{ {

View file

@ -253,8 +253,8 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
} }
pSector->wallptr = LittleShort(load.wallptr); pSector->wallptr = LittleShort(load.wallptr);
pSector->wallnum = LittleShort(load.wallnum); pSector->wallnum = LittleShort(load.wallnum);
pSector->ceilingz = LittleLong(load.ceilingz); pSector->setceilingz(LittleLong(load.ceilingz));
pSector->floorz = LittleLong(load.floorz); pSector->setfloorz(LittleLong(load.floorz));
pSector->ceilingstat = ESectorFlags::FromInt(LittleShort(load.ceilingstat)); pSector->ceilingstat = ESectorFlags::FromInt(LittleShort(load.ceilingstat));
pSector->floorstat = ESectorFlags::FromInt(LittleShort(load.floorstat)); pSector->floorstat = ESectorFlags::FromInt(LittleShort(load.floorstat));
pSector->ceilingpicnum = LittleShort(load.ceilingpicnum); pSector->ceilingpicnum = LittleShort(load.ceilingpicnum);

View file

@ -903,7 +903,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR *pXSector, int a3, int a4)
if (dz != 0) if (dz != 0)
{ {
int oldZ = pSector->floorz; 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; pSector->velFloor += (pSector->floorz-oldZ)<<8;
BloodSectIterator it(pSector); BloodSectIterator it(pSector);
@ -931,7 +931,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR *pXSector, int a3, int a4)
if (dz != 0) if (dz != 0)
{ {
int oldZ = pSector->ceilingz; 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; pSector->velCeil += (pSector->ceilingz-oldZ)<<8;
BloodSectIterator it(pSector); BloodSectIterator it(pSector);
@ -1018,9 +1018,9 @@ int VCrushBusy(sectortype *pSector, unsigned int a2)
return 1; return 1;
viewInterpolateSector(pSector); viewInterpolateSector(pSector);
if (dz1 != 0) if (dz1 != 0)
pSector->ceilingz = vc; pSector->setceilingz(vc);
if (dz2 != 0) if (dz2 != 0)
pSector->floorz = v10; pSector->setfloorz(v10);
pXSector->busy = a2; pXSector->busy = a2;
if (pXSector->command == kCmdLink && pXSector->txID) if (pXSector->command == kCmdLink && pXSector->txID)
evSendSector(pSector,pXSector->txID, kCmdLink); evSendSector(pSector,pXSector->txID, kCmdLink);
@ -1803,7 +1803,7 @@ void ProcessMotion(void)
{ {
int floorZ = pSector->floorz; int floorZ = pSector->floorz;
viewInterpolateSector(pSector); viewInterpolateSector(pSector);
pSector->floorz = pSector->baseFloor + vdi; pSector->setfloorz(pSector->baseFloor + vdi);
BloodSectIterator itr(pSector); BloodSectIterator itr(pSector);
while (auto actor = itr.Next()) while (auto actor = itr.Next())
@ -1826,7 +1826,7 @@ void ProcessMotion(void)
{ {
int ceilZ = pSector->ceilingz; int ceilZ = pSector->ceilingz;
viewInterpolateSector(pSector); viewInterpolateSector(pSector);
pSector->ceilingz = pSector->baseCeil + vdi; pSector->setceilingz(pSector->baseCeil + vdi);
BloodSectIterator itr(pSector); BloodSectIterator itr(pSector);
while (auto actor = itr.Next()) while (auto actor = itr.Next())

View file

@ -251,7 +251,7 @@ void SnapSectors(sectortype* pSectorA, sectortype* pSectorB, int b)
} }
if (b) { if (b) {
pSectorB->ceilingz = pSectorA->floorz; pSectorB->setceilingz(pSectorA->floorz);
} }
if (pSectorA->Flag & 0x1000) { if (pSectorA->Flag & 0x1000) {

View file

@ -900,14 +900,14 @@ void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel)
nZVal = pSector->ceilingz; nZVal = pSector->ceilingz;
pos.Z = pNextSector->ceilingz + 256; pos.Z = pNextSector->ceilingz + 256;
pSector->ceilingz = pNextSector->ceilingz; pSector->setceilingz(pNextSector->ceilingz);
} }
else else
{ {
nZVal = pSector->floorz; nZVal = pSector->floorz;
pos.Z = pNextSector->floorz - 256; pos.Z = pNextSector->floorz - 256;
pSector->floorz = pNextSector->floorz; pSector->setfloorz(pNextSector->floorz);
} }
auto pSectorB = pSector; auto pSectorB = pSector;
@ -1061,10 +1061,10 @@ void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel)
} }
if (nSectFlag & kSectUnderwater) { if (nSectFlag & kSectUnderwater) {
pSector->ceilingz = nZVal; pSector->setceilingz(nZVal);
} }
else { else {
pSector->floorz = nZVal; pSector->setfloorz(nZVal);
} }
*nXVel = xvect; *nXVel = xvect;

View file

@ -857,7 +857,7 @@ void AIElev::Tick(RunListEvent* ev)
} }
StartInterpolation(pSector, Interp_Sect_Ceilingz); StartInterpolation(pSector, Interp_Sect_Ceilingz);
pSector->ceilingz = ceilZ; pSector->setceilingz(ceilZ);
} }
// maybe this doesn't go here? // maybe this doesn't go here?
@ -1663,7 +1663,7 @@ void ExplodeEnergyBlock(DExhumedActor* pActor)
pSector->floorshade = 50; pSector->floorshade = 50;
pSector->extra = -1; 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; pActor->spr.pos.Z = (pActor->spr.pos.Z + pSector->floorz) / 2;
@ -1772,13 +1772,13 @@ void AIEnergyBlock::RadialDamage(RunListEvent* ev)
int nFloorZ = pSector->floorz; int nFloorZ = pSector->floorz;
pSector->floorz = pActor->spr.pos.Z; pSector->setfloorz(pActor->spr.pos.Z);
pActor->spr.pos.Z -= 256; pActor->spr.pos.Z -= 256;
ev->nDamage = runlist_CheckRadialDamage(pActor); ev->nDamage = runlist_CheckRadialDamage(pActor);
// restore previous values // restore previous values
pSector->floorz = nFloorZ; pSector->setfloorz(nFloorZ);
pActor->spr.pos.Z += 256; pActor->spr.pos.Z += 256;
if (ev->nDamage <= 0) { if (ev->nDamage <= 0) {
@ -2122,13 +2122,13 @@ void DoDrips()
if (sBob[i].field_3) if (sBob[i].field_3)
{ {
pSector->ceilingz = edx + sBob[i].z; pSector->setceilingz(edx + sBob[i].z);
} }
else else
{ {
int nFloorZ = pSector->floorz; int nFloorZ = pSector->floorz;
pSector->floorz = edx + sBob[i].z; pSector->setfloorz(edx + sBob[i].z);
MoveSectorSprites(pSector, pSector->floorz - nFloorZ); MoveSectorSprites(pSector, pSector->floorz - nFloorZ);
} }

View file

@ -706,7 +706,7 @@ void runlist_ProcessSectorTag(sectortype* pSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second); runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
pSector->floorz = nextSectorP->floorz; pSector->setfloorz(nextSectorP->floorz);
return; return;
} }

View file

@ -51,7 +51,7 @@ void DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz,
// reset Z's // reset Z's
for (int i = 0; i < save.zcount; i++) 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]->floorpicnum = save.pic[i];
save.sect[i]->setfloorslope(save.slope[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 // reset Z's
for (int i = 0; i < save.zcount; i++) 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]->ceilingpicnum = save.pic[i];
save.sect[i]->setceilingslope(save.slope[i]); save.sect[i]->setceilingslope(save.slope[i]);
} }

View file

@ -212,8 +212,8 @@ void CopySectorMatch(int match)
dsectp->hitag = ssectp->hitag; dsectp->hitag = ssectp->hitag;
dsectp->lotag = ssectp->lotag; dsectp->lotag = ssectp->lotag;
dsectp->floorz = ssectp->floorz; dsectp->setfloorz(ssectp->floorz);
dsectp->ceilingz = ssectp->ceilingz; dsectp->setceilingz(ssectp->ceilingz);
dsectp->floorshade = ssectp->floorshade; dsectp->floorshade = ssectp->floorshade;
dsectp->ceilingshade = ssectp->ceilingshade; dsectp->ceilingshade = ssectp->ceilingshade;

View file

@ -2170,13 +2170,13 @@ struct ANIMstruct
ANIM_CALLBACKp callback; ANIM_CALLBACKp callback;
SECTOR_OBJECTp callbackdata; // only gets used in one place for this so having a proper type makes serialization easier. 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; static int scratch;
switch (animtype) switch (animtype)
{ {
case ANIM_Floorz: case ANIM_Floorz:
return sector[animindex].floorz; return *sector[animindex].floorzptr(!write);
case ANIM_SopZ: case ANIM_SopZ:
return SectorObject[animindex].zmid; return SectorObject[animindex].zmid;
case ANIM_Spritez: case ANIM_Spritez:

View file

@ -102,9 +102,9 @@ static int &getvalue(so_interp::interp_data& element, bool write)
if (write) wall[index].moved(); if (write) wall[index].moved();
return wall[index].pos.Y; return wall[index].pos.Y;
case soi_ceil: case soi_ceil:
return sector[index].ceilingz; return *sector[index].ceilingzptr(!write);
case soi_floor: case soi_floor:
return sector[index].floorz; return *sector[index].floorzptr(!write);
case soi_sox: case soi_sox:
return SectorObject[index].xmid; return SectorObject[index].xmid;
case soi_soy: case soi_soy:

View file

@ -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.pic[save.zcount] = actor->spr.sector()->floorpicnum;
save.slope[save.zcount] = actor->spr.sector()->floorheinum; 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 // don't change FAF_MIRROR_PIC - ConnectArea
if (actor->spr.sector()->floorpicnum != FAF_MIRROR_PIC) if (actor->spr.sector()->floorpicnum != FAF_MIRROR_PIC)
actor->spr.sector()->floorpicnum = FAF_MIRROR_PIC + 1; 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.pic[save.zcount] = actor->spr.sector()->ceilingpicnum;
save.slope[save.zcount] = actor->spr.sector()->ceilingheinum; 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 // don't change FAF_MIRROR_PIC - ConnectArea
if (actor->spr.sector()->ceilingpicnum != FAF_MIRROR_PIC) if (actor->spr.sector()->ceilingpicnum != FAF_MIRROR_PIC)

View file

@ -879,7 +879,7 @@ void DoExplodeSector(short match)
sectp = actor->spr.sector(); sectp = actor->spr.sector();
sectp->ceilingz -= Z(SP_TAG4(actor)); sectp->addceilingz(-Z(SP_TAG4(actor)));
if (SP_TAG5(actor)) if (SP_TAG5(actor))
{ {
@ -1255,7 +1255,7 @@ void DoChangorMatch(short match)
if (TEST_BOOL1(actor)) if (TEST_BOOL1(actor))
{ {
sectp->ceilingpicnum = SP_TAG4(actor); sectp->ceilingpicnum = SP_TAG4(actor);
sectp->ceilingz += Z(SP_TAG5(actor)); sectp->addceilingz(Z(SP_TAG5(actor)));
sectp->ceilingheinum += SP_TAG6(actor); sectp->ceilingheinum += SP_TAG6(actor);
if (sectp->ceilingheinum) if (sectp->ceilingheinum)
@ -1269,7 +1269,7 @@ void DoChangorMatch(short match)
else else
{ {
sectp->floorpicnum = SP_TAG4(actor); sectp->floorpicnum = SP_TAG4(actor);
sectp->floorz += Z(SP_TAG5(actor)); sectp->addfloorz(Z(SP_TAG5(actor)));
sectp->floorheinum += SP_TAG6(actor); sectp->floorheinum += SP_TAG6(actor);
if (sectp->floorheinum) if (sectp->floorheinum)
@ -2342,13 +2342,13 @@ void DoSineWaveFloor(void)
if (TEST(flags, SINE_FLOOR)) if (TEST(flags, SINE_FLOOR))
{ {
newz = swf->floor_origz + MulScale(swf->range, bsin(swf->sintable_ndx), 14); 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)) if (TEST(flags, SINE_CEILING))
{ {
newz = swf->ceiling_origz + MulScale(swf->range, bsin(swf->sintable_ndx), 14); 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--) for (i = AnimCnt - 1; i >= 0; i--)
{ {
animval = Anim[i].Addr(); animval = Anim[i].Addr(true);
// if LESS THAN goal // if LESS THAN goal
if (animval < Anim[i].goal) if (animval < Anim[i].goal)
@ -2449,7 +2449,7 @@ void DoAnim(int numtics)
animval = Anim[i].goal; animval = Anim[i].goal;
} }
Anim[i].Addr() =animval; Anim[i].Addr(true) =animval;
// EQUAL this entry has finished // EQUAL this entry has finished
if (animval == Anim[i].goal) if (animval == Anim[i].goal)

View file

@ -2054,8 +2054,7 @@ void SpriteSetup(void)
amt = actor->spr.pos.Z - sectp->floorz; amt = actor->spr.pos.Z - sectp->floorz;
// start in the on position // start in the on position
//sectp->floorz = actor->spr.z; sectp->addfloorz(amt);
sectp->floorz += amt;
actor->user.z_tgt = actor->user.sz; actor->user.z_tgt = actor->user.sz;
MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor
@ -2075,8 +2074,7 @@ void SpriteSetup(void)
amt = actor->spr.pos.Z - sectp->ceilingz; amt = actor->spr.pos.Z - sectp->ceilingz;
// starting in the on position // starting in the on position
//sectp->ceilingz = actor->spr.z; sectp->addceilingz(amt);
sectp->ceilingz += amt;
actor->user.z_tgt = actor->user.sz; actor->user.z_tgt = actor->user.sz;
MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling
@ -2455,7 +2453,7 @@ void SpriteSetup(void)
SP_TAG4(actor) = abs(sectp->ceilingz - sectp->floorz)>>8; 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); change_actor_stat(actor, STAT_EXPLODING_CEIL_FLOOR);
break; break;

View file

@ -2042,7 +2042,7 @@ void MoveZ(SECTOR_OBJECTp sop)
if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB))
continue; 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)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB))
continue; continue;
(*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff; (*sectp)->setfloorz(sop->zorig_floor[i] + sop->bob_diff);
} }
} }

View file

@ -370,13 +370,13 @@ int DoVator(DSWActor* actor)
if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP)) if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP))
{ {
lptr = &sectp->ceilingz; lptr = sectp->ceilingzptr();
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling
} }
else else
{ {
lptr = &sectp->floorz; lptr = sectp->floorzptr();
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor
} }
@ -521,13 +521,13 @@ int DoVatorAuto(DSWActor* actor)
if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP)) if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP))
{ {
lptr = &sectp->ceilingz; lptr = sectp->ceilingzptr();
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling MoveSpritesWithSector(actor->spr.sector(), amt, true); // ceiling
} }
else else
{ {
lptr = &sectp->floorz; lptr = sectp->floorzptr();
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor MoveSpritesWithSector(actor->spr.sector(), amt, false); // floor
} }