Merge branch 'movechasecamera-crashfix' into 'next'

Fix for Chicmunk's weird camera related crash

See merge request STJr/SRB2!284
This commit is contained in:
Monster Iestyn 2018-10-09 15:20:06 -04:00
commit c469fc242f
1 changed files with 19 additions and 21 deletions

View File

@ -7853,7 +7853,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
subsector_t *newsubsec; subsector_t *newsubsec;
fixed_t f1, f2; fixed_t f1, f2;
cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (player->mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! // We probably shouldn't move the camera if there is no player or player mobj somehow
if (!player || !player->mo)
return true;
mo = player->mo;
cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!!
if (!(player->climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD)) if (!(player->climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD))
{ {
@ -7874,7 +7880,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
else if (player == &players[secondarydisplayplayer]) else if (player == &players[secondarydisplayplayer])
focusangle = localangle2; focusangle = localangle2;
else else
focusangle = player->mo->angle; focusangle = mo->angle;
if (thiscam == &camera) if (thiscam == &camera)
camrotate = cv_cam_rotate.value; camrotate = cv_cam_rotate.value;
else if (thiscam == &camera2) else if (thiscam == &camera2)
@ -7886,17 +7892,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
return true; return true;
} }
if (!player || !player->mo)
return true;
mo = player->mo;
thiscam->radius = FixedMul(20*FRACUNIT, mo->scale); thiscam->radius = FixedMul(20*FRACUNIT, mo->scale);
thiscam->height = FixedMul(16*FRACUNIT, mo->scale); thiscam->height = FixedMul(16*FRACUNIT, mo->scale);
if (!mo)
return true;
// Don't run while respawning from a starpost // Don't run while respawning from a starpost
// Inu 4/8/13 Why not?! // Inu 4/8/13 Why not?!
// if (leveltime > 0 && timeinmap <= 0) // if (leveltime > 0 && timeinmap <= 0)
@ -7904,7 +7902,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->pflags & PF_NIGHTSMODE) if (player->pflags & PF_NIGHTSMODE)
{ {
focusangle = player->mo->angle; focusangle = mo->angle;
focusaiming = 0; focusaiming = 0;
} }
else if (player == &players[consoleplayer]) else if (player == &players[consoleplayer])
@ -7919,7 +7917,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
} }
else else
{ {
focusangle = player->mo->angle; focusangle = mo->angle;
focusaiming = player->aiming; focusaiming = player->aiming;
} }
@ -7966,12 +7964,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
angle = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y); angle = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y);
angle += ANGLE_90; angle += ANGLE_90;
} }
else if (player->mo->target) else if (mo->target)
{ {
if (player->mo->target->flags & MF_AMBUSH) if (mo->target->flags & MF_AMBUSH)
angle = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); angle = R_PointToAngle2(mo->target->x, mo->target->y, mo->x, mo->y);
else else
angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y);
} }
} }
else if (P_AnalogMove(player)) // Analog else if (P_AnalogMove(player)) // Analog
@ -8066,7 +8064,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (twodlevel || (mo->flags2 & MF2_TWOD)) if (twodlevel || (mo->flags2 & MF2_TWOD))
{ {
// Camera doesn't ALWAYS need to move, only when running... // Camera doesn't ALWAYS need to move, only when running...
if (abs(player->mo->momx) > 10) if (abs(mo->momx) > 10)
{ {
// Move the camera all smooth-like, not jerk it around... // Move the camera all smooth-like, not jerk it around...
if (mo->momx > 0) if (mo->momx > 0)
@ -8384,13 +8382,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
vy = thiscam->y; vy = thiscam->y;
} }
if (P_AproxDistance(vx - player->mo->x, vy - player->mo->y) < FixedMul(48*FRACUNIT, mo->scale)) if (P_AproxDistance(vx - mo->x, vy - mo->y) < FixedMul(48*FRACUNIT, mo->scale))
player->mo->flags2 |= MF2_SHADOW; mo->flags2 |= MF2_SHADOW;
else else
player->mo->flags2 &= ~MF2_SHADOW; mo->flags2 &= ~MF2_SHADOW;
} }
else else
player->mo->flags2 &= ~MF2_SHADOW; mo->flags2 &= ~MF2_SHADOW;
/* if (!resetcalled && (player->pflags & PF_NIGHTSMODE && player->exiting)) /* if (!resetcalled && (player->pflags & PF_NIGHTSMODE && player->exiting))
{ {