From 1a8dcda5b6165611c64d57ce7e68a8015e4fe26f Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 23 Mar 2023 19:47:11 +1100 Subject: [PATCH] - Exhumed: Split out player invisibility code. --- source/games/exhumed/src/player.cpp | 42 ++++++++++++++++++----------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index a08959f5b..c810333c0 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -922,6 +922,31 @@ static void doPlayerDouble(Player* const pPlayer) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void doPlayerInvisibility(Player* const pPlayer) +{ + pPlayer->nInvisible--; + + if (pPlayer->nInvisible == 0) + { + pPlayer->pActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible + + if (pPlayer->pPlayerFloorSprite) + { + pPlayer->pPlayerFloorSprite->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible + } + } + else if (pPlayer->nInvisible == 150 && pPlayer->nPlayer == nLocalPlayer) + { + PlayAlert(GStrings("TXT_EX_INVISEX")); + } +} + //--------------------------------------------------------------------------- // // this function is pure spaghetti madness... :( @@ -963,22 +988,7 @@ void AIPlayer::Tick(RunListEvent* ev) doPlayerDouble(pPlayer); if (pPlayer->nInvisible > 0) - { - pPlayer->nInvisible--; - if (pPlayer->nInvisible == 0) - { - pPlayerActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible - DExhumedActor* pFloorSprite = pPlayer->pPlayerFloorSprite; - - if (pFloorSprite != nullptr) { - pFloorSprite->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; // set visible - } - } - else if (pPlayer->nInvisible == 150 && nPlayer == nLocalPlayer) - { - PlayAlert(GStrings("TXT_EX_INVISEX")); - } - } + doPlayerInvisibility(pPlayer); if (pPlayer->invincibility > 0) {