Three issues fixed:
1. ClientThink called ClientThink_real during demo playback, which
ran server-side PmoveSingle and overwrote the client-owned
ps.origin. Now ClientThink returns early in demo mode after
updating pers.cmd (for button access).
2. Buttons never reached the server while paused: SV_UserMove
discards usercmds with duplicate serverTime (line 1421). During
pause, all usercmds have frozen serverTime. Fix: always process
the last usercmd in the packet during demo playback.
3. Spectator button handling in G_RunFrame demo mode processes
MOUSE1 (attack) to cycle follow targets via Cmd_FollowCycle_f.
Removed debug print.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cgame runs its own PmoveSingle for the free camera using real time,
independent of server time. Solves pause freezing — camera moves
smoothly while svs.time is frozen.
Changes:
- usercmd_t: add optional origin[3] with 1-bit flag (zero cost for
normal gameplay, 13 bytes during demo viewing)
- msg.c: serialize optional origin in usercmd delta encoding
- CG_SETCLIENTORIGIN trap: cgame sends camera origin to engine
- cl_input.c: CL_FinishMove writes cgame origin into usercmd
- cg_predict.c: CG_PredictPlayerState runs local PmoveSingle for
free camera in svDemo mode, sends origin via trap for PVS
- cg_snapshot.c: detect follow→free camera transition, init camera
from last known position
- cg_main.c: detect svDemo mode from CS_SVDEMO configstring,
lazy-init camera from first snapshot's spectator spawn
- g_main.c: G_InitGame sets CS_SVDEMO configstring, G_RunFrame
copies cmd.origin to ps.origin for PVS instead of ClientThink_real
- bg_public.h: CS_SVDEMO configstring index (26)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
Record delta-compressed playerState_t for each active player per
frame using MSG_WriteDeltaPlayerstate. During playback, inject
into game module via SV_GameClientNum and mark players as
CON_CONNECTED with correct team. CalculateRanks and the
scoreboard now show recorded players with scores.
This also lays the groundwork for player-follow spectating.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Records full entity state array each server frame, enabling
free-camera demo playback from any viewpoint.
Recording:
- svdemo_record <name> / svdemo_stop
- Captures entityState_t + PVS fields (svFlags, linked,
currentOrigin, absmin, absmax) for all active entities
- Records configstring changes per frame
- File format: svdemos/<name>.svdm
Playback:
- svdemo_play <name>
- Loads map with maxclients=64, reserves recorded player slots
(CS_ZOMBIE with safe rate/timing) so spectator gets a high slot
- Injects recorded entities into sv.gentities each frame with
SV_LinkEntity for PVS visibility
- Re-applies demo configstrings (CS_PLAYERS etc.) after map load,
skipping CS_SERVERINFO/CS_SYSTEMINFO to avoid latch restarts
- Game module runs in demo mode (sv_demoplaying cvar): G_RunFrame
only processes spectator movement, skips all entity logic
- Spectator forced to TEAM_SPECTATOR on connect (ClientBegin)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>