From e2605ff16caa6658fcbf66572b3bd0e1837a531f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Nov 2023 15:24:32 +0100 Subject: [PATCH 1/4] center camera when joining from spec the camera never gets centered proper if you join from spectator --- src/p_user.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 94169754..99201bdd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8054,6 +8054,10 @@ 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; //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) @@ -8078,6 +8082,9 @@ boolean P_SpectatorJoinGame(player_t *player) player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; + + //center camera if its not already + if ((P_IsLocalPlayer(player)) && localaiming[0] != 0) //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) From aaaf09aea338a9461a04635289fe6c00f07a60b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Nov 2023 16:09:42 +0100 Subject: [PATCH 2/4] somehow forgor this in center camera --- src/p_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_user.c b/src/p_user.c index 99201bdd..e897fe75 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8085,6 +8085,7 @@ boolean P_SpectatorJoinGame(player_t *player) //center camera if its not already if ((P_IsLocalPlayer(player)) && localaiming[0] != 0) + localaiming[0] = 0; //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) From 65c3d90340672f6b1ae2c80b5a76bb6071070396 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 Mar 2024 02:17:30 +0100 Subject: [PATCH 3/4] forgot about splitscreen oops --- src/p_user.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index e897fe75..a47e72ca 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8054,10 +8054,16 @@ 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) + if ((P_IsLocalPlayer(player)) && player == &players[consoleplayer] && localaiming[0] != 0) localaiming[0] = 0; + else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[1]] && localaiming[1] != 0) + localaiming[1] = 0; + else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[2]] && localaiming[2] != 0) + localaiming[2] = 0; + else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[3]] && localaiming[3] != 0) + localaiming[3] = 0; //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) @@ -8082,10 +8088,16 @@ boolean P_SpectatorJoinGame(player_t *player) player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; - + //center camera if its not already - if ((P_IsLocalPlayer(player)) && localaiming[0] != 0) + if ((P_IsLocalPlayer(player)) && player == &players[consoleplayer] && localaiming[0] != 0) localaiming[0] = 0; + else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[1]] && localaiming[1] != 0) + localaiming[1] = 0; + else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[2]] && localaiming[2] != 0) + localaiming[2] = 0; + else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[3]] && localaiming[3] != 0) + localaiming[3] = 0; //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) From cf14f285a31a18f55060ded18827309899639197 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 Mar 2024 03:26:17 +0100 Subject: [PATCH 4/4] simplify this and make its own function P_ResetLocalCamAiming no more if else and weird checks c: --- src/p_local.h | 1 + src/p_user.c | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index cef7e736..642a1a64 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -150,6 +150,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 a47e72ca..cc9219d6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8005,6 +8005,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. @@ -8055,15 +8067,8 @@ boolean P_SpectatorJoinGame(player_t *player) player->ctfteam = changeto; player->playerstate = PST_REBORN; - //center camera if its not already - if ((P_IsLocalPlayer(player)) && player == &players[consoleplayer] && localaiming[0] != 0) - localaiming[0] = 0; - else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[1]] && localaiming[1] != 0) - localaiming[1] = 0; - else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[2]] && localaiming[2] != 0) - localaiming[2] = 0; - else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[3]] && localaiming[3] != 0) - localaiming[3] = 0; + //center camera + P_ResetLocalCamAiming(player); //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) @@ -8089,15 +8094,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)) && player == &players[consoleplayer] && localaiming[0] != 0) - localaiming[0] = 0; - else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[1]] && localaiming[1] != 0) - localaiming[1] = 0; - else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[2]] && localaiming[2] != 0) - localaiming[2] = 0; - else if ((P_IsLocalPlayer(player)) && player == &players[displayplayers[3]] && localaiming[3] != 0) - localaiming[3] = 0; + //center camera + P_ResetLocalCamAiming(player); //Reset away view if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)