From efc832ca5cef77c7057830558bb90297bbaeef3d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 30 Jan 2022 16:20:11 +0100 Subject: [PATCH] - Blood: wrapped most write accesses to spr.pos --- source/games/blood/src/player.cpp | 2 +- source/games/blood/src/triggers.cpp | 24 +++++++++++------------- source/games/blood/src/warp.cpp | 20 ++++++++++++-------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index d9b3e712e..ff44f94b1 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -807,7 +807,7 @@ void playerStart(int nPlayer, int bNewLevel) actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED; int top, bottom; GetActorExtents(actor, &top, &bottom); - actor->spr.pos.Z -= bottom - actor->spr.pos.Z; + actor->add_int_z(-(bottom - actor->spr.pos.Z)); actor->spr.pal = 11 + (pPlayer->teamId & 3); actor->spr.ang = pStartZone->ang; pPlayer->angle.ang = buildang(actor->spr.ang); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index bd1f7307c..70940ad54 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -960,8 +960,7 @@ void TranslateSector(sectortype* pSector, int a2, int a3, int a4, int a5, int a6 if (v14) RotatePoint((int*)&actor->spr.pos.X, (int*)&actor->spr.pos.Y, v14, v20, v24); actor->spr.ang = (actor->spr.ang + v14) & 2047; - actor->spr.pos.X += v28; - actor->spr.pos.Y += v2c; + actor->add_int_pos({ v28, v2c, 0 }); } } } @@ -1043,14 +1042,14 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z += pSector->floorz - oldZ; + actor->add_int_z(pSector->floorz - oldZ); } else if (actor->spr.flags & 2) actor->spr.flags |= 4; else if (oldZ <= bottom && !(actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK)) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z += pSector->floorz - oldZ; + actor->add_int_z(pSector->floorz - oldZ); } } @@ -1088,7 +1087,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z += pSector->ceilingz - oldZ; + actor->add_int_z(pSector->ceilingz - oldZ); } } @@ -1241,7 +1240,7 @@ int VSpriteBusy(sectortype* pSector, unsigned int a2, DBloodActor* initiator) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z = actor->basePoint.Z + MulScale(dz1, GetWaveValue(a2, nWave), 16); + actor->set_int_z(actor->basePoint.Z + MulScale(dz1, GetWaveValue(a2, nWave), 16)); } } } @@ -1254,7 +1253,7 @@ int VSpriteBusy(sectortype* pSector, unsigned int a2, DBloodActor* initiator) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z = actor->basePoint.Z + MulScale(dz2, GetWaveValue(a2, nWave), 16); + actor->set_int_z(actor->basePoint.Z + MulScale(dz2, GetWaveValue(a2, nWave), 16)); } } } @@ -1633,9 +1632,8 @@ void OperateTeleport(sectortype* pSector) { TeleFrag(pXSector->actordata, destactor->sector()); } - actor->spr.pos.X = destactor->spr.pos.X; - actor->spr.pos.Y = destactor->spr.pos.Y; - actor->spr.pos.Z += destactor->sector()->floorz - pSector->floorz; + actor->set_int_xy(destactor->spr.pos.X, destactor->spr.pos.Y); + actor->add_int_z(destactor->sector()->floorz - pSector->floorz); actor->spr.ang = destactor->spr.ang; ChangeActorSect(actor, destactor->sector()); sfxPlay3DSound(destactor, 201, -1, 0); @@ -2127,7 +2125,7 @@ void ProcessMotion(void) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_MASK) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z += vdi; + actor->add_int_z(vdi); } } if (pXSector->bobFloor) @@ -2148,7 +2146,7 @@ void ProcessMotion(void) if (bottom >= floorZ && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z += vdi; + actor->add_int_z(vdi); } } } @@ -2167,7 +2165,7 @@ void ProcessMotion(void) if (top <= ceilZ && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) { viewBackupSpriteLoc(actor); - actor->spr.pos.Z += vdi; + actor->add_int_z(vdi); } } } diff --git a/source/games/blood/src/warp.cpp b/source/games/blood/src/warp.cpp index 8e2062237..34657f82c 100644 --- a/source/games/blood/src/warp.cpp +++ b/source/games/blood/src/warp.cpp @@ -147,7 +147,7 @@ void warpInit(TArray& actors) actor->sector()->upperLink = actor; actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; - actor->spr.pos.Z = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y); + actor->set_int_z(getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y)); break; case kMarkerLowWater: case kMarkerLowStack: @@ -155,7 +155,7 @@ void warpInit(TArray& actors) actor->sector()->lowerLink = actor; actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; - actor->spr.pos.Z = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y); + actor->set_int_z(getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y)); break; } } @@ -219,14 +219,16 @@ int CheckLink(DBloodActor* actor) assert(aLower); assert(aLower->insector()); ChangeActorSect(actor, aLower->sector()); - actor->spr.pos.X += aLower->spr.pos.X - aUpper->spr.pos.X; - actor->spr.pos.Y += aLower->spr.pos.Y - aUpper->spr.pos.Y; + vec3_t add; + add.X = aLower->spr.pos.X - aUpper->spr.pos.X; + add.Y = aLower->spr.pos.Y - aUpper->spr.pos.Y; int z2; if (aLower->spr.type == kMarkerLowLink) z2 = aLower->spr.pos.Z; else z2 = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y); - actor->spr.pos.Z += z2 - z; + add.Z = z2 - z; + actor->add_int_pos(add); actor->interpolated = false; return aUpper->spr.type; } @@ -244,14 +246,16 @@ int CheckLink(DBloodActor* actor) assert(aUpper); assert(aUpper->insector()); ChangeActorSect(actor, aUpper->sector()); - actor->spr.pos.X += aUpper->spr.pos.X - aLower->spr.pos.X; - actor->spr.pos.Y += aUpper->spr.pos.Y - aLower->spr.pos.Y; + vec3_t add; + add.X = aUpper->spr.pos.X - aLower->spr.pos.X; + add.Y = aUpper->spr.pos.Y - aLower->spr.pos.Y; int z2; if (aUpper->spr.type == kMarkerUpLink) z2 = aUpper->spr.pos.Z; else z2 = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y); - actor->spr.pos.Z += z2 - z; + add.Z = z2 - z; + actor->add_int_pos(add); actor->interpolated = false; return aLower->spr.type; }