From 9a1bfb3a92804cd32ce5f5f48b890e7b93ba96c9 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 17 Sep 2019 00:04:32 +0200 Subject: [PATCH] camera checks to avoid crashes --- src/p_user.c | 15 +++++++++------ src/r_main.c | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8d2eeaf9..4e85f078 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7418,6 +7418,9 @@ void P_DemoCameraMovement(camera_t *cam) awayviewmobj_hack->flags2 |= MF2_DONTDRAW; democam.soundmobj = awayviewmobj_hack; + + // update subsector to avoid crashes; + thiscam->subsector = R_PointInSubsector(cam->x, cam->y); } void P_ResetCamera(player_t *player, camera_t *thiscam) @@ -7485,12 +7488,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we - if (demo.freecam) - { - P_DemoCameraMovement(thiscam); - return true; - } - // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) return true; @@ -7499,6 +7496,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; + if (demo.freecam) + { + P_DemoCameraMovement(thiscam); + return true; + } + mo = player->mo; #ifndef NOCLIPCAM diff --git a/src/r_main.c b/src/r_main.c index 358a24bb..1735c8d8 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1176,7 +1176,7 @@ void R_SetupFrame(player_t *player, boolean skybox) viewx += quake.x; viewy += quake.y; - if (thiscam->subsector) + if (thiscam->subsector && thiscam->subsector->sector) viewsector = thiscam->subsector->sector; else viewsector = R_PointInSubsector(viewx, viewy)->sector; @@ -1188,7 +1188,7 @@ void R_SetupFrame(player_t *player, boolean skybox) viewx += quake.x; viewy += quake.y; - if (viewmobj->subsector) + if (viewmobj->subsector && thiscam->subsector->sector) viewsector = viewmobj->subsector->sector; else viewsector = R_PointInSubsector(viewx, viewy)->sector;