Add player follow mode during demo playback
Call CalculateRanks and ClientEndFrame for the spectator in demo mode G_RunFrame. SpectatorClientEndFrame copies the followed player's recorded playerState into the spectator's ps, giving first-person view with full HUD (health, armor, ammo, weapon). Standard spectator controls work: mouse1 to cycle, mouse2 to enter follow from free camera. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1a186eeb81
commit
0bd116982a
1 changed files with 12 additions and 1 deletions
|
|
@ -1737,6 +1737,8 @@ int start, end;
|
|||
|
||||
// demo playback: sync recorded player states and process spectator
|
||||
if ( g_svDemoPlaying.integer ) {
|
||||
gentity_t *specEnt = NULL;
|
||||
|
||||
// mark recorded players as connected based on their playerState.
|
||||
// the server injected playerStates via SV_GameClientNum before
|
||||
// calling G_RunFrame, so g_clients[i].ps is already populated.
|
||||
|
|
@ -1744,10 +1746,11 @@ int start, end;
|
|||
gclient_t *cl = &level.clients[i];
|
||||
gentity_t *e = &g_entities[i];
|
||||
|
||||
// skip the spectator slot — it's managed normally
|
||||
// find and process the spectator
|
||||
if ( e->client && cl->pers.connected == CON_CONNECTED
|
||||
&& cl->sess.sessionTeam == TEAM_SPECTATOR ) {
|
||||
ClientThink_real( e );
|
||||
specEnt = e;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1766,6 +1769,14 @@ int start, end;
|
|||
e->inuse = qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
// update rankings so follow mode can cycle through players
|
||||
CalculateRanks();
|
||||
|
||||
// run end-of-frame for spectator (handles follow mode PS copy)
|
||||
if ( specEnt ) {
|
||||
ClientEndFrame( specEnt );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue