From ae84246721d221bd0b5e2ac6065f616d0a786af5 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 27 Nov 2019 13:37:03 +0000 Subject: [PATCH] Fix camera not being flipped when camera is stopped due to game design hack reasons (resolves #383). --- src/p_local.h | 1 + src/p_mobj.c | 39 +++++++++++++++++++++++---------------- src/p_user.c | 12 +++++++++++- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index b718c43f1..646fa70f2 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -323,6 +323,7 @@ SINT8 P_MobjFlip(mobj_t *mobj); fixed_t P_GetMobjGravity(mobj_t *mo); FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type); +void P_CalcChasePostImg(player_t *player, camera_t *thiscam); boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled); void P_Attract(mobj_t *source, mobj_t *enemy, boolean nightsgrab); diff --git a/src/p_mobj.c b/src/p_mobj.c index c31b88940..74df95cb2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3724,17 +3724,10 @@ void P_DestroyRobots(void) } } -// P_CameraThinker -// -// Process the mobj-ish required functions of the camera -boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) +// the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person +void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - boolean itsatwodlevel = false; postimg_t postimg = postimg_none; - if (twodlevel - || (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD)) - || (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD))) - itsatwodlevel = true; if (player->pflags & PF_FLIPCAM && !(player->powers[pw_carry] == CR_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP) postimg = postimg_flip; @@ -3762,13 +3755,27 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled postimg = postimg_heat; } - if (postimg != postimg_none) - { - if (splitscreen && player == &players[secondarydisplayplayer]) - postimgtype2 = postimg; - else - postimgtype = postimg; - } + if (postimg == postimg_none) + return; + + if (splitscreen && player == &players[secondarydisplayplayer]) + postimgtype2 = postimg; + else + postimgtype = postimg; +} + +// P_CameraThinker +// +// Process the mobj-ish required functions of the camera +boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) +{ + boolean itsatwodlevel = false; + if (twodlevel + || (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD)) + || (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD))) + itsatwodlevel = true; + + P_CalcChasePostImg(player, thiscam); if (thiscam->momx || thiscam->momy) { diff --git a/src/p_user.c b/src/p_user.c index b999f1f72..6f3981630 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9665,11 +9665,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall fixed_t f1, f2; // We probably shouldn't move the camera if there is no player or player mobj somehow - if (!player || !player->mo || player->playerstate == PST_REBORN) + if (!player || !player->mo) return true; mo = player->mo; + if (player->playerstate == PST_REBORN) + { + P_CalcChasePostImg(player, thiscam); + return true; + } + if (player->exiting) { if (mo->target && mo->target->type == MT_SIGN && mo->target->spawnpoint @@ -9678,7 +9684,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else if ((player->powers[pw_carry] == CR_NIGHTSMODE) && !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] && player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6])) + { + P_CalcChasePostImg(player, thiscam); return true; + } } cameranoclip = (player->powers[pw_carry] == CR_NIGHTSMODE || player->pflags & PF_NOCLIP) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! @@ -10419,6 +10428,7 @@ boolean P_SpectatorJoinGame(player_t *player) return false; } +// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam static void P_CalcPostImg(player_t *player) { sector_t *sector = player->mo->subsector->sector;