- Blood: wrapped most write accesses to spr.pos

This commit is contained in:
Christoph Oelckers 2022-01-30 16:20:11 +01:00
parent 32dd061ab1
commit efc832ca5c
3 changed files with 24 additions and 22 deletions

View file

@ -807,7 +807,7 @@ void playerStart(int nPlayer, int bNewLevel)
actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED; actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
int top, bottom; int top, bottom;
GetActorExtents(actor, &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.pal = 11 + (pPlayer->teamId & 3);
actor->spr.ang = pStartZone->ang; actor->spr.ang = pStartZone->ang;
pPlayer->angle.ang = buildang(actor->spr.ang); pPlayer->angle.ang = buildang(actor->spr.ang);

View file

@ -960,8 +960,7 @@ void TranslateSector(sectortype* pSector, int a2, int a3, int a4, int a5, int a6
if (v14) if (v14)
RotatePoint((int*)&actor->spr.pos.X, (int*)&actor->spr.pos.Y, v14, v20, v24); RotatePoint((int*)&actor->spr.pos.X, (int*)&actor->spr.pos.Y, v14, v20, v24);
actor->spr.ang = (actor->spr.ang + v14) & 2047; actor->spr.ang = (actor->spr.ang + v14) & 2047;
actor->spr.pos.X += v28; actor->add_int_pos({ v28, v2c, 0 });
actor->spr.pos.Y += v2c;
} }
} }
} }
@ -1043,14 +1042,14 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
if (actor->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD)
{ {
viewBackupSpriteLoc(actor); viewBackupSpriteLoc(actor);
actor->spr.pos.Z += pSector->floorz - oldZ; actor->add_int_z(pSector->floorz - oldZ);
} }
else if (actor->spr.flags & 2) else if (actor->spr.flags & 2)
actor->spr.flags |= 4; actor->spr.flags |= 4;
else if (oldZ <= bottom && !(actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK)) else if (oldZ <= bottom && !(actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK))
{ {
viewBackupSpriteLoc(actor); 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) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE)
{ {
viewBackupSpriteLoc(actor); 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) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD)
{ {
viewBackupSpriteLoc(actor); 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) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE)
{ {
viewBackupSpriteLoc(actor); 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()); TeleFrag(pXSector->actordata, destactor->sector());
} }
actor->spr.pos.X = destactor->spr.pos.X; actor->set_int_xy(destactor->spr.pos.X, destactor->spr.pos.Y);
actor->spr.pos.Y = destactor->spr.pos.Y; actor->add_int_z(destactor->sector()->floorz - pSector->floorz);
actor->spr.pos.Z += destactor->sector()->floorz - pSector->floorz;
actor->spr.ang = destactor->spr.ang; actor->spr.ang = destactor->spr.ang;
ChangeActorSect(actor, destactor->sector()); ChangeActorSect(actor, destactor->sector());
sfxPlay3DSound(destactor, 201, -1, 0); sfxPlay3DSound(destactor, 201, -1, 0);
@ -2127,7 +2125,7 @@ void ProcessMotion(void)
if (actor->spr.cstat & CSTAT_SPRITE_MOVE_MASK) if (actor->spr.cstat & CSTAT_SPRITE_MOVE_MASK)
{ {
viewBackupSpriteLoc(actor); viewBackupSpriteLoc(actor);
actor->spr.pos.Z += vdi; actor->add_int_z(vdi);
} }
} }
if (pXSector->bobFloor) if (pXSector->bobFloor)
@ -2148,7 +2146,7 @@ void ProcessMotion(void)
if (bottom >= floorZ && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) if (bottom >= floorZ && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0)
{ {
viewBackupSpriteLoc(actor); 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) if (top <= ceilZ && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0)
{ {
viewBackupSpriteLoc(actor); viewBackupSpriteLoc(actor);
actor->spr.pos.Z += vdi; actor->add_int_z(vdi);
} }
} }
} }

View file

@ -147,7 +147,7 @@ void warpInit(TArray<DBloodActor*>& actors)
actor->sector()->upperLink = actor; actor->sector()->upperLink = actor;
actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; 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; break;
case kMarkerLowWater: case kMarkerLowWater:
case kMarkerLowStack: case kMarkerLowStack:
@ -155,7 +155,7 @@ void warpInit(TArray<DBloodActor*>& actors)
actor->sector()->lowerLink = actor; actor->sector()->lowerLink = actor;
actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; 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; break;
} }
} }
@ -219,14 +219,16 @@ int CheckLink(DBloodActor* actor)
assert(aLower); assert(aLower);
assert(aLower->insector()); assert(aLower->insector());
ChangeActorSect(actor, aLower->sector()); ChangeActorSect(actor, aLower->sector());
actor->spr.pos.X += aLower->spr.pos.X - aUpper->spr.pos.X; vec3_t add;
actor->spr.pos.Y += aLower->spr.pos.Y - aUpper->spr.pos.Y; add.X = aLower->spr.pos.X - aUpper->spr.pos.X;
add.Y = aLower->spr.pos.Y - aUpper->spr.pos.Y;
int z2; int z2;
if (aLower->spr.type == kMarkerLowLink) if (aLower->spr.type == kMarkerLowLink)
z2 = aLower->spr.pos.Z; z2 = aLower->spr.pos.Z;
else else
z2 = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y); 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; actor->interpolated = false;
return aUpper->spr.type; return aUpper->spr.type;
} }
@ -244,14 +246,16 @@ int CheckLink(DBloodActor* actor)
assert(aUpper); assert(aUpper);
assert(aUpper->insector()); assert(aUpper->insector());
ChangeActorSect(actor, aUpper->sector()); ChangeActorSect(actor, aUpper->sector());
actor->spr.pos.X += aUpper->spr.pos.X - aLower->spr.pos.X; vec3_t add;
actor->spr.pos.Y += aUpper->spr.pos.Y - aLower->spr.pos.Y; add.X = aUpper->spr.pos.X - aLower->spr.pos.X;
add.Y = aUpper->spr.pos.Y - aLower->spr.pos.Y;
int z2; int z2;
if (aUpper->spr.type == kMarkerUpLink) if (aUpper->spr.type == kMarkerUpLink)
z2 = aUpper->spr.pos.Z; z2 = aUpper->spr.pos.Z;
else else
z2 = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y); 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; actor->interpolated = false;
return aLower->spr.type; return aLower->spr.type;
} }