From 51743bbb0107fa2ef611fbbed2a4f2e56cd644d5 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 29 Apr 2018 14:28:28 -0500 Subject: [PATCH] Improvements for dedicated camera followers (team follow1/2) Switching to dedicated camera follower with no possible players to follow would spawn at the intermission point and display "connection interrupted" HUD message. Pmove() was not run for the client so ps.commandTime was too far behind. I made it so that dedicated camera followers and scoreboard run Pmove() but cannot move (PM_FREEZE). When all players possible to follow leave, the dedicated camera follower would continue to display the old player state of the player they were following (along with "connection interrupted" HUD message). Unlike the regular case of a spectator following a specific player, dedicated camera followers did not reset their player state to the intermission point after the followed player was no longer valid. Now a client can be set as 'team follow1' to automatically switch between displaying the intermission point and following a player when possible. --- code/game/g_active.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/code/game/g_active.c b/code/game/g_active.c index 89c1a524..a506a1e0 100644 --- a/code/game/g_active.c +++ b/code/game/g_active.c @@ -320,11 +320,15 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) { client = ent->client; - if ( client->sess.spectatorState != SPECTATOR_FOLLOW ) { - if ( client->noclip ) { - client->ps.pm_type = PM_NOCLIP; + if ( client->sess.spectatorState != SPECTATOR_FOLLOW || !( client->ps.pm_flags & PMF_FOLLOW ) ) { + if ( client->sess.spectatorState == SPECTATOR_FREE ) { + if ( client->noclip ) { + client->ps.pm_type = PM_NOCLIP; + } else { + client->ps.pm_type = PM_SPECTATOR; + } } else { - client->ps.pm_type = PM_SPECTATOR; + client->ps.pm_type = PM_FREEZE; } client->ps.speed = 400; // faster than normal @@ -1074,14 +1078,17 @@ void SpectatorClientEndFrame( gentity_t *ent ) { ent->client->ps.pm_flags |= PMF_FOLLOW; ent->client->ps.eFlags = flags; return; - } else { - // drop them to free spectators unless they are dedicated camera followers - if ( ent->client->sess.spectatorClient >= 0 ) { - ent->client->sess.spectatorState = SPECTATOR_FREE; - ClientBegin( ent->client - level.clients ); - } } } + + if ( ent->client->ps.pm_flags & PMF_FOLLOW ) { + // drop them to free spectators unless they are dedicated camera followers + if ( ent->client->sess.spectatorClient >= 0 ) { + ent->client->sess.spectatorState = SPECTATOR_FREE; + } + + ClientBegin( ent->client - level.clients ); + } } if ( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {