# HG changeset patch # User Adam Kaminski # Date 1626739614 14400 # Mon Jul 19 20:06:54 2021 -0400 # Node ID 99e9bbf85c88125129a78533ce81dbce3098aeb4 # Parent acfe0e81776a2842525c7ae92d3a3e4fe61010da Fixed players from still being spied on when they're turned into dead spectators. Also respect cl_telespy when we're switching back to our view and spying on another player. diff -r acfe0e81776a -r 99e9bbf85c88 src/cl_main.cpp --- a/src/cl_main.cpp Mon Jul 19 18:40:07 2021 -0400 +++ b/src/cl_main.cpp Mon Jul 19 20:06:54 2021 -0400 @@ -151,6 +151,7 @@ EXTERN_CVAR( Bool, cl_hideaccount ) EXTERN_CVAR( Int, cl_ticsperupdate ) EXTERN_CVAR( String, name ) +EXTERN_CVAR( Bool, cl_telespy ) //***************************************************************************** // CONSOLE COMMANDS/VARIABLES @@ -2989,6 +2990,20 @@ // void CLIENT_ResetConsolePlayerCamera( void ) { + // [AK] Check if we were looking through another player's eyes. + if (( players[consoleplayer].camera ) && ( players[consoleplayer].camera->player )) + { + // [AK] Teleport to the player's body if we want to. + if (( cl_telespy ) && ( players[consoleplayer].bSpectating )) + { + AActor *pActor = players[consoleplayer].camera; + + P_TeleportMove( players[consoleplayer].mo, pActor->x, pActor->y, pActor->z, false ); + players[consoleplayer].mo->angle = pActor->angle; + players[consoleplayer].mo->pitch = pActor->pitch; + } + } + players[consoleplayer].camera = players[consoleplayer].mo; if ( players[consoleplayer].camera != NULL ) S_UpdateSounds( players[consoleplayer].camera ); diff -r acfe0e81776a -r 99e9bbf85c88 src/p_mobj.cpp --- a/src/p_mobj.cpp Mon Jul 19 18:40:07 2021 -0400 +++ b/src/p_mobj.cpp Mon Jul 19 20:06:54 2021 -0400 @@ -5563,12 +5563,14 @@ if ( NETWORK_GetState( ) != NETSTATE_SERVER ) { - for (int ii = 0; ii < MAXPLAYERS; ++ii) - { - if (playeringame[ii] && players[ii].camera == oldactor) - { - players[ii].camera = mobj; - } + // [AK] Only check if the local player is looking at the player being spawned. + if (( playeringame[consoleplayer] ) && ( players[consoleplayer].camera == oldactor )) + { + // [AK] If this player is actually a dead spectator, switch the view back to ourselves. + if (( mobj->player->bSpectating ) && ( players[consoleplayer].mo )) + CLIENT_ResetConsolePlayerCamera( ); + else + players[consoleplayer].camera = mobj; } }