From 240dae9a1ad08f342d4bf8d58a9230f5df1092ae Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 26 Oct 2024 16:12:43 +0200 Subject: [PATCH] move chasecam postimg stuff into own function + add comments for what stuff does lol shit got me really confused --- src/p_mobj.c | 51 ++++++++++++++++++++------------------------------- src/p_user.c | 1 + 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 793680cae..9f2ef8184 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3242,35 +3242,13 @@ 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 +static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - boolean itsatwodlevel = false; - boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); + const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT16 postimgflags = 0; UINT8 i; - // This can happen when joining - if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) - return true; - - if (twodlevel) - itsatwodlevel = true; - else - { - for (i = 0; i <= splitscreen; i++) - { - if (thiscam == &camera[i] && players[displayplayers[i]].mo - && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) - { - itsatwodlevel = true; - break; - } - } - } - if (encoremode) postimgflags |= POSTIMG_MIRROR; if (flipcam) @@ -3310,6 +3288,18 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled players[displayplayers[i]].postimgflags = postimgflags; break; } +} + +// P_CameraThinker +// +// Process the mobj-ish required functions of the camera +boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) +{ + // This can happen when joining + if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) + return true; + + P_CalcChasePostImg(player, thiscam); if (thiscam->momx || thiscam->momy) { @@ -3337,8 +3327,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } } - if (!itsatwodlevel) - P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); + P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; @@ -3350,7 +3339,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled thiscam->z += thiscam->momz + player->mo->pmomz; #ifndef NOCLIPCAM - if (!itsatwodlevel && !(player->pflags & PF_NOCLIP || leveltime < introtime)) + if (!(player->pflags & PF_NOCLIP || leveltime < introtime)) { // clip movement if (thiscam->z <= thiscam->floorz) // hit the floor @@ -3393,13 +3382,13 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled #endif } - if (itsatwodlevel - || (thiscam->ceilingz - thiscam->z < thiscam->height - && thiscam->ceilingz >= thiscam->z)) + if (thiscam->ceilingz - thiscam->z < thiscam->height + && thiscam->ceilingz >= thiscam->z) { thiscam->ceilingz = thiscam->z + thiscam->height; thiscam->floorz = thiscam->z; } + return false; } diff --git a/src/p_user.c b/src/p_user.c index 1a29f4a56..ff00dfb4b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4103,6 +4103,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;