diff --git a/src/p_local.h b/src/p_local.h index e93d4b411..dc473b648 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -156,6 +156,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); void P_DemoCameraMovement(camera_t *cam); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); +void P_ResetLocalCamAiming(player_t *player); void P_InitCameraCmd(void); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); diff --git a/src/p_user.c b/src/p_user.c index 315e551a4..b51fd4ec6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3970,6 +3970,18 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); } +void P_ResetLocalCamAiming(player_t *player) +{ + for (int i = 0; i <= splitscreen; i++) + { + UINT8 id = (i == 0) ? consoleplayer : displayplayers[i]; + if (player - players == id) + { + localaiming[i] = 0; + } + } +} + boolean P_SpectatorJoinGame(player_t *player) { // Team changing isn't allowed. @@ -4019,10 +4031,9 @@ boolean P_SpectatorJoinGame(player_t *player) player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; player->playerstate = PST_REBORN; - - //center camera if its not already - if ((P_IsLocalPlayer(player)) && localaiming[0] != 0) - localaiming[0] = 0; + + //center camera + P_ResetLocalCamAiming(player); //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) @@ -4048,9 +4059,8 @@ boolean P_SpectatorJoinGame(player_t *player) player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; - //center camera if its not already - if ((P_IsLocalPlayer(player)) && localaiming[0] != 0) - localaiming[0] = 0; + //center camera + P_ResetLocalCamAiming(player); //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)