From 7593114fc7b4cf8705e80b93341c8b5e6af93eb8 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 29 Dec 2022 14:26:13 +1100 Subject: [PATCH] - SW: Tidy up `UpdatePlayerSprite()` a bit. --- source/games/sw/src/player.cpp | 49 +++++++--------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 764dbf5eb..7645ab557 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1829,47 +1829,10 @@ void UpdatePlayerUnderSprite(PLAYER* pp) void UpdatePlayerSprite(PLAYER* pp) { - DSWActor* actor = pp->actor; - if (!actor) return; - - // there are multiple death functions - if (pp->Flags & (PF_DEAD)) + // Adjust player height according to the next action. + if (!(pp->Flags & PF_DEAD)) { - ChangeActorSect(pp->actor, pp->cursector); - UpdatePlayerUnderSprite(pp); - return; - } - - if (pp->sop_control) - { - pp->height = PLAYER_HEIGHTF; - } - else if (pp->DoPlayerAction == DoPlayerCrawl) - { - pp->height = PLAYER_CRAWL_HEIGHTF; - } - else if (pp->DoPlayerAction == DoPlayerWade) - { - pp->height = PLAYER_HEIGHTF; - - if (pp->WadeDepth > Z(29)) - { - DoPlayerSpriteBob(pp, pp->height, 3, 3); - } - } - else if (pp->DoPlayerAction == DoPlayerDive) - { - pp->height = PLAYER_DIVE_HEIGHTF; - } - else if (pp->DoPlayerAction == DoPlayerFly) - { - // bobbing and sprite position taken care of in DoPlayerFly - pp->height = PLAYER_HEIGHTF; - DoPlayerSpriteBob(pp, pp->height, 6, 3); - } - else - { - pp->height = PLAYER_HEIGHTF; + pp->height = (pp->DoPlayerAction == DoPlayerCrawl) ? PLAYER_CRAWL_HEIGHTF : (pp->DoPlayerAction == DoPlayerDive) ? PLAYER_DIVE_HEIGHTF : PLAYER_HEIGHTF; } ChangeActorSect(pp->actor, pp->cursector); @@ -3767,6 +3730,8 @@ void DoPlayerFly(PLAYER* pp) // Adjust view height moving up and down sectors DoPlayerViewOffset(pp); + + DoPlayerSpriteBob(pp, PLAYER_HEIGHTF, 6, 3); } @@ -5031,6 +4996,10 @@ void DoPlayerWade(PLAYER* pp) DoPlayerBeginRun(pp); return; } + else if (pp->WadeDepth > Z(29)) + { + DoPlayerSpriteBob(pp, PLAYER_HEIGHTF, 3, 3); + } }