From c45ecdae738b0602546328c2c1afd09cf8cdf8de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2022 21:54:07 +0200 Subject: [PATCH] - wrapped all velocity access in Blood, except the places where an address of vel is taken --- source/core/coreactor.h | 7 +++++++ source/games/blood/src/actor.cpp | 10 +++++----- source/games/blood/src/bloodactor.h | 5 ----- source/games/blood/src/fx.cpp | 2 +- source/games/blood/src/nnexts.cpp | 12 ++++++------ 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index e73073a40..714755f11 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -261,6 +261,13 @@ public: __int_vel .X = __int_vel .Y = 0; } + void ZeroVelocity() + { + __int_vel = { 0,0,0 }; + } + + + // Same as above but with inverted y and z axes to match the renderer's coordinate system. double interpolatedx(double const smoothratio, int const scale = 16) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 5c0d6de48..e9786d894 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4661,7 +4661,7 @@ static Collision MoveThing(DBloodActor* actor) { actor->hit.ceilhit = ceilColl; actor->add_int_z(ClipLow(ceilZ - top, 0)); - if (actor->__int_vel.Z < 0) + if (actor->int_vel().Z < 0) { actor->set_int_bvel_x(MulScale(actor->int_vel().X, 0xc000, 16)); actor->set_int_bvel_y(MulScale(actor->int_vel().Y, 0xc000, 16)); @@ -4908,7 +4908,7 @@ void MoveDude(DBloodActor* actor) actor->add_int_bvel_z(vc); } } - if (pPlayer && actor->__int_vel.Z > 0x155555 && !pPlayer->fallScream && actor->xspr.height > 0) + if (pPlayer && actor->int_vel().Z > 0x155555 && !pPlayer->fallScream && actor->xspr.height > 0) { const bool playerAlive = (actor->xspr.health > 0) || VanillaMode(); // only trigger falling scream if player is alive or vanilla mode if (playerAlive) @@ -5164,7 +5164,7 @@ void MoveDude(DBloodActor* actor) actor->hit.ceilhit = ceilColl; actor->add_int_z(ClipLow(ceilZ - top, 0)); - if (actor->__int_vel.Z <= 0 && (actor->spr.flags & 4)) + if (actor->int_vel().Z <= 0 && (actor->spr.flags & 4)) actor->set_int_bvel_z(MulScale(-actor->int_vel().Z, 0x2000, 16)); } else @@ -6140,7 +6140,7 @@ void actCheckFlares() pos.Y += mulscale30r(Sin(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2) * inttoworld; pos.Z += actor->xspr.TargetPos.Z; SetActor(actor, pos); - actor->__int_vel = target->__int_vel; + actor->set_int_bvel(target->int_vel()); } else { @@ -6206,7 +6206,7 @@ DBloodActor* actSpawnSprite(DBloodActor* source, int nStat) DBloodActor* actor = InsertSprite(source->sector(), nStat); actor->spr.pos = source->spr.pos; - actor->__int_vel = source->__int_vel; + actor->set_int_bvel(source->int_vel()); actor->spr.flags = 0; actor->addX(); actor->hit.florhit.setNone(); diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 13ccbaad9..52412e604 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -118,11 +118,6 @@ public: return spr.type >= kItemAmmoBase && spr.type < kItemAmmoMax; } - void ZeroVelocity() - { - __int_vel = { 0,0,0 }; - } - bool isActive() { if (!hasX()) diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index 944be9ebb..7c0f40415 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -216,7 +216,7 @@ void CFX::fxProcess(void) actAirDrag(actor, pFXData->drag); actor->add_int_pos({ actor->int_vel().X >> 12, actor->int_vel().Y >> 12, actor->int_vel().Z >> 8 }); // Weird... - if (actor->int_vel().X != 0 || (actor->__int_vel.Y && actor->spr.pos.Z >= actor->sector()->floorz)) + if (actor->int_vel().X != 0 || (actor->int_vel().Y != 0 && actor->spr.pos.Z >= actor->sector()->floorz)) { updatesector(actor->spr.pos, &pSector); if (pSector == nullptr) diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 3f2da0777..9820c4839 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1054,13 +1054,13 @@ static void windGenDoVerticalWind(int factor, sectortype* pSector) if (maxZfound && actor->int_pos().Z <= maxZ) { zdiff = actor->int_pos().Z - maxZ; - if (actor->__int_vel.Z < 0) actor->add_int_bvel_z(MulScale(actor->int_vel().Z >> 4, zdiff, 16)); + if (actor->int_vel().Z < 0) actor->add_int_bvel_z(MulScale(actor->int_vel().Z >> 4, zdiff, 16)); continue; } val = -MulScale(factor * 64, 0x10000, 16); - if (actor->__int_vel.Z >= 0) actor->add_int_bvel_z(val); + if (actor->int_vel().Z >= 0) actor->add_int_bvel_z(val); else actor->set_int_bvel_z(val); actor->add_int_z(actor->int_vel().Z >> 12); @@ -1353,7 +1353,7 @@ void nnExtProcessSuperSprites() if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble); else if (Chance(0x1000 - mass)) { - if (debrisactor->__int_vel.Z > 0x100) debrisBubble(debrisactor); + if (debrisactor->int_vel().Z > 0x100) debrisBubble(debrisactor); if (ang == debrisactor->xspr.goalAng) { debrisactor->xspr.goalAng = (debrisactor->int_ang() + Random3(kAng60)) & 2047; @@ -1831,7 +1831,7 @@ void debrisMove(int listIndex) { actor->hit.ceilhit = moveHit = ceilColl; actor->add_int_z(ClipLow(ceilZ - top, 0)); - if (actor->__int_vel.Z <= 0 && (actor->xspr.physAttr & kPhysFalling)) + if (actor->int_vel().Z <= 0 && (actor->xspr.physAttr & kPhysFalling)) actor->set_int_bvel_z(MulScale(-actor->int_vel().Z, 0x2000, 16)); } @@ -1848,7 +1848,7 @@ void debrisMove(int listIndex) trTriggerSprite(actor, kCmdToggle, actor); } - if (!actor->__int_vel.X && !actor->int_vel().Y) return; + if (actor->int_vel().X == 0 && actor->int_vel().Y == 0) return; else if (floorColl.type == kHitSprite) { @@ -2782,7 +2782,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe if (targetactor->spr.statnum == kStatThing) ChangeActorStat(targetactor, 0); // set random goal ang for swimming so they start turning - if ((flags & kPhysDebrisSwim) && !targetactor->__int_vel.X && !targetactor->__int_vel.Y && !targetactor->int_vel().Z) + if ((flags & kPhysDebrisSwim) && targetactor->int_vel().X ==0 && targetactor->int_vel().Y == 0 && targetactor->int_vel().Z == 0) targetactor->xspr.goalAng = (targetactor->int_ang() + Random3(kAng45)) & 2047; if (targetactor->xspr.physAttr & kPhysDebrisVector)