From 62de240c27df4bcc3b6e29f06dab564e12617c23 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 24 Mar 2023 17:02:58 +1100 Subject: [PATCH] - Exhumed: Reduce branch depth in `CheckMovingBlocks()` to make next change more visible. --- source/games/exhumed/src/player.cpp | 49 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 967c97d19..a0f178c4f 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -776,37 +776,34 @@ bool CheckMovingBlocks(Player* const pPlayer, Collision& nMove, DVector3& spr_po // moving blocks - move this to a separate function! if (sect != nullptr) { - if ((sect->hitag == 45) && bTouchFloor) + const auto nDiff = absangle(nNormal, pPlayerActor->spr.Angles.Yaw + DAngle180); + + if ((sect->hitag == 45) && bTouchFloor && nDiff <= DAngle45) { - auto nDiff = absangle(nNormal, pPlayerActor->spr.Angles.Yaw + DAngle180); + pPlayer->pPlayerPushSect = sect; - if (nDiff <= DAngle45) + DVector2 vel = pPlayer->vel; + auto nMyAngle = vel.Angle().Normalized360(); + + setsectinterpolate(sect); + MoveSector(sect, nMyAngle, vel); + + if (pPlayer->nPlayerPushSound <= -1) { - pPlayer->pPlayerPushSect = sect; + pPlayer->nPlayerPushSound = 1; + int nBlock = pPlayer->pPlayerPushSect->extra; + DExhumedActor* pBlockActor = sBlockInfo[nBlock].pActor; - DVector2 vel = pPlayer->vel; - auto nMyAngle = vel.Angle().Normalized360(); - - setsectinterpolate(sect); - MoveSector(sect, nMyAngle, vel); - - if (pPlayer->nPlayerPushSound <= -1) - { - pPlayer->nPlayerPushSound = 1; - int nBlock = pPlayer->pPlayerPushSect->extra; - DExhumedActor* pBlockActor = sBlockInfo[nBlock].pActor; - - D3PlayFX(StaticSound[kSound23], pBlockActor, 0x4000); - } - else - { - pPlayerActor->spr.pos = spr_pos; - ChangeActorSect(pPlayerActor, spr_sect); - } - - movesprite(pPlayerActor, vel, zz, -20, CLIPMASK0); - return true; + D3PlayFX(StaticSound[kSound23], pBlockActor, 0x4000); } + else + { + pPlayerActor->spr.pos = spr_pos; + ChangeActorSect(pPlayerActor, spr_sect); + } + + movesprite(pPlayerActor, vel, zz, -20, CLIPMASK0); + return true; } } }