- Exhumed: Change doPlayerFloorDamage() to do an early return instead of nested branches.

This commit is contained in:
Mitchell Richters 2023-03-26 09:49:14 +11:00
parent 8d1531ba78
commit 838aebdfb7

View file

@ -1217,22 +1217,20 @@ static void updatePlayerViewSector(Player* const pPlayer, const Collision& nMove
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void doPlayerFloorDamage(Player* const pPlayer, const double nVelZ) static void doPlayerFloorDamage(Player* const pPlayer, const double nStartVelZ)
{ {
const auto pPlayerActor = pPlayer->pActor; const auto pPlayerActor = pPlayer->pActor;
pPlayer->nThrust /= 2; pPlayer->nThrust *= 0.5;
if (nStartVelZ < (6500 / 256.))
return;
if (nVelZ >= 6500 / 256.)
{
pPlayerActor->vel.XY() *= 0.25; pPlayerActor->vel.XY() *= 0.25;
runlist_DamageEnemy(pPlayerActor, nullptr, int(((nStartVelZ * 256) - 6500) * (1. / 128.)) + 10);
runlist_DamageEnemy(pPlayerActor, nullptr, int(((nVelZ * 256) - 6500) * (1. / 128.)) + 10);
if (pPlayer->nHealth <= 0) if (pPlayer->nHealth <= 0)
{ {
pPlayerActor->vel.X = 0; pPlayerActor->vel.Zero();
pPlayerActor->vel.Y = 0;
StopActorSound(pPlayerActor); StopActorSound(pPlayerActor);
PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerActor->spr.pos, CHANF_NONE, 1); // CHECKME PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerActor->spr.pos, CHANF_NONE, 1); // CHECKME
} }
@ -1240,7 +1238,6 @@ static void doPlayerFloorDamage(Player* const pPlayer, const double nVelZ)
{ {
D3PlayFX(StaticSound[kSound27] | 0x2000, pPlayerActor); D3PlayFX(StaticSound[kSound27] | 0x2000, pPlayerActor);
} }
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------