spectatorClientNum was hardcoded to MAX_CLIENTS-1 but the spectator
actually connected at a different slot. All skip checks using it
were no-ops protecting the wrong slot. Removed entirely:
- Zombie slots handle player slot reservation
- G_RunFrame recreates the spectator entity via ClientThink_real
- PlayerState injection writes all slots (spectator's ps gets
overwritten by ClientThink_real anyway)
- SVD_SpectatorClientNum accessor removed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A real map_restart sends SV_SendClientGameState to all clients,
which triggers CL_ParseGamestate → CL_ClearState on the client,
wiping all snapshot and entity history. Previously we only forced
non-delta snapshots which doesn't clear cgame's entity state.
Now we call SV_SendClientGameState for all active clients on the
restart frame, exactly matching real server behavior.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The recording resets its delta state on map_restart (writes from
zero baseline). The playback must do the same, otherwise the
delta decoder uses stale pre-restart state as baseline, producing
corrupt entity data and preventing EF_TELEPORT_BIT from being
decoded correctly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
snapFlagServerBit toggle alone doesn't clear client entity
interpolation state. Also reset deltaMessage=-1 for all active
clients, forcing the next snapshot to be full (non-delta). The
client receives deltaNum<=0, clears old entity state, and
renders all entities at their new positions without interpolation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Record a per-frame restart flag (1 byte) set by SVD_ResetDeltaState
when map_restart occurs. During playback, toggle svs.snapFlagServerBit
so the client treats the next snapshot as a fresh baseline — no
interpolation of entities from pre-restart positions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per-client chat is sent to every connected client in a loop.
Capture chat/tchat commands regardless of target clientNum, and
deduplicate by checking if the exact string is already buffered
for the current frame.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Chat messages use per-client trap_SendServerCommand (not broadcast),
so they weren't captured. Move capture hook to SV_GameSendServerCommand
which is the game module boundary. Capture broadcasts (clientNum=-1)
and chat/tchat commands sent to client 0 (first in the per-client
loop, deduplicated by only capturing once).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
spectatorClientNum was hardcoded to MAX_CLIENTS-1 (63) but the
spectator actually connects at the first free slot after zombie
reservations. Broadcasting with SV_SendServerCommand(NULL, ...)
reaches the spectator regardless of their actual slot number.
Zombie clients (< CS_PRIMED) are skipped by the broadcast loop.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reverting the svs.time change from the bugfix commit — entity
trajectories (rockets, grenades, bobbing items) need svs.time to
match recorded time for client-side interpolation. The zombie
timeout issue is already handled by skipping SV_CheckTimeouts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Capture broadcast server commands (chat, print, cp, etc.) from
SV_SendServerCommand when cl==NULL. Buffer up to 64 commands per
frame. Written after configstrings in the demo file, replayed to
the spectator client during playback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per-frame entity and playerState blocks are compressed with LZ4
when svdemo_compress is set (default: 1). The block format writes
[original_size][compressed_size][data] — compressed_size=0 means
uncompressed. Playback auto-detects based on header flags.
Demo format bumped to version 2 with SVDEMO_FLAG_COMPRESSED flag.
Version 1 (uncompressed) demos are no longer compatible.
Uses the lz4.c/lz4.h library already in the server code directory.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set svdemo_autorecord 1 to automatically record a demo on every
map load. Demo files are named <mapname>_YYYYMMDD_HHMMSS.svdm
in the svdemos/ directory.
Refactored SVD_Record_f to use SVD_StartRecording helper so both
manual and auto recording share the same code path. Also fixed
prevPlayers delta state not being cleared on recording start.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SV_SpawnServer reinitializes the game module, invalidating all
entity and configstring state. Recording across a map boundary
would produce corrupt deltas. Stop recording automatically at
the start of SV_SpawnServer (before game shutdown).
map_restart is unaffected — it has its own path (SV_MapRestart_f)
which doesn't call SV_SpawnServer.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The per-frame configstring path in SVD_ReadFrame was not filtering
dangerous configstrings like SVD_ApplyConfigstrings does. When a
recorded map_restart changed CS_SERVERINFO (containing maxclients),
applying it overwrote maxclients=64 with the recorded value,
triggering a latched restart loop.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1. File handle leak: SVD_Play_f opened file twice, first handle leaked.
Fix: memset demo state before opening.
2. svdemo_stop now handles both recording and playback via SVD_Stop_f.
Playback stop disconnects client to return to menu.
3. Zombie client timeout: skip SV_CheckTimeouts during playback so
reserved player slots aren't freed.
4. Buffer overflow: increase entity buffer to MAX_GENTITIES*300 and
playerState buffer to MAX_CLIENTS*600 for worst-case first frame.
Made static to avoid stack overflow.
5. svs.time jump: don't overwrite svs.time with recorded time.
Server time advances normally, avoiding timeout/heartbeat issues.
6. map_restart: SVD_ResetDeltaState clears entity/player delta state
so next frame writes full states, preventing corrupt deltas.
7. Demo end and manual stop both disconnect the client.
8. SV_Shutdown cleans up active recording/playback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract SVD_CleanupPlayback for shared cleanup logic
- Called on demo end (SVD_PlaybackFrame) and manual stop
- Frees zombie client slots, saved configstrings, file handle
- Clears sv_demoplaying cvar so game module exits demo mode
- Hook into SV_Shutdown to clean up on server shutdown/map change
- Allows playing another demo after one finishes
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>
Clear the game module's playerState when a recorded player
disconnects, so G_RunFrame sees commandTime=0 and marks them
as CON_DISCONNECTED. Without this, disconnected players stayed
visible on the scoreboard indefinitely.
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>
Use MSG_WriteDeltaEntity/MSG_ReadDeltaEntity for entity state
serialization. Only changed fields are written per frame. PVS
fields (svFlags, linked, origin, absmin, absmax) also use a
1-bit change flag to skip when unchanged.
Reduces a 10-second demo from ~1400KB to ~52KB (27x smaller).
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>
Add full QL-style PM_StepSlideMove with:
- Master gate: trace from start to final position filters micro-bumps
- Projected position validation: trace down at where player would be
without collision, rejects walls (startsolid) and confirms stairs
- Air-step friction: 3% horizontal penalty on airborne step-ups
- PM_Jump() call when all gates pass on valid stair geometry
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two changes to PM_StepSlideMove that transform stair traversal:
1. Remove Q3 velocity[2]>0 gate (QL pm_airSteps): allow step-ups
while airborne, enabling bunny-hop stair traversal.
2. Conditional velocity clip: only clip velocity to step-down surface
when moving INTO it (dot product < 0). Skip clip when velocity is
moving away (dot >= 0), preserving upward momentum through steps.
This is THE key mechanic for smooth QL-style stair hopping.
Also adds 100ms jump cooldown (lastJumpTime) to prevent same-frame
double-fires during rapid step-ups.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the PMF_JUMP_HELD gate from PM_CheckJump so players can
hold jump to bunny hop continuously without releasing between
hops. The existing Pmove() outer loop already forces upmove=20
when PMF_JUMP_HELD is set, making this the only change needed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Separate the jump execution (velocity, event, animation) from the
gate logic (respawn check, upmove threshold, jump-held check).
This prepares the code for QL features that need to trigger jumps
from contexts other than the normal ground jump path (step jump,
double jump, etc). No behavior change.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename output binary from quake3.exe to quake3live.exe across all configurations
- Add DLL_ONLY define to Release TA and Debug TA configs to force native DLL loading
(VM_CallCompiled was a stub returning 0, causing "ui version 0" errors)
- Default fs_game to "missionpack" so the engine loads from workdir/missionpack/
- Add AfterBuild copy for ui.vcxproj to deploy uix86.dll to workdir
- Fix .gitignore: add Debug_TA/, remove *.exe/*.dll/*.lib/*.map patterns that were
hiding real SDK tools in code/win32/mod-sdk-setup/bin/
- Remove q3_ui project from solution (not used in TA builds)
- Increase hunk/zone memory defaults for modern systems
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Debug TA and Release TA configs now copy their output DLLs to
workdir/missionpack/ instead of workdir/baseq3/, matching the
Q3 Team Arena directory layout. MISSIONPACK was already defined
for TA configs; this completes the baseline TA setup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Default was 2 (JIT/QVM), causing fallback to ui.qvm when DLL not found.
Use CVAR_INIT|CVAR_ROM to prevent config files from overriding back to QVM.
Mirrors the same pattern used for sv_pure in sv_init.c.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add unconditional ItemDefinitionGroup in quake3.vcxproj to define DLL_ONLY
for all configurations, disabling QVM interpreter/JIT in favour of DLLs.
Fix vm_x86.c: VM_Compile was outside the #ifndef DLL_ONLY guard while
VM_CallCompiled was inside it, causing a duplicate symbol link error.
Extend the guard to cover VM_Compile as well.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use DirectInput8Create() instead of dynamic dinput.dll loading
- Switch to LPDIRECTINPUT8 / LPDIRECTINPUTDEVICE8 types and DI8 macros
- Replace custom MYDATA data format with c_dfDIMouse2 (8-button support)
- Use DIMOUSESTATE2 in GetDeviceState (correct size, 8 buttons)
- Add MOUSE5 button mapping via DIMOFS_BUTTON4
- Link against dinput8.lib; define required GUIDs inline to avoid dxguid.lib conflicts
- Fix .gitignore: remove Win32/ pattern that was shadowing code/win32/ source dir
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>