Feature/sv demo cinema - mem leak fix + playdemo wait for clients#14
Open
sedawkgrep wants to merge 6 commits into
Open
Feature/sv demo cinema - mem leak fix + playdemo wait for clients#14sedawkgrep wants to merge 6 commits into
sedawkgrep wants to merge 6 commits into
Conversation
sv_playdemo now holds on the demo's first frame until a real client
reaches CS_ACTIVE, instead of burning through snapshots against an
empty server. SV_Frame gates the per-tick SV_DemoAdvance() call on a
new one-way latch (sv.demoWaitingForViewer), reusing the same
sv.time-only "hold" pattern already used for the end-of-demo case.
Also fixes a crash ("Hunk_Alloc failed") after replaying ~4-5 demos:
SV_SpawnDemoServer hunk-allocates snapshot entity storage on every
call but was skipping Hunk_Clear() beforehand, so each sv_playdemo
leaked another full snapshotEntities allocation until the hunk filled
up. Clear the hunk (and collision map, unused during demo cinema)
before that allocation, matching SV_SpawnServer's normal map-load path.
sv_playdemo sets sv.state = SS_GAME while leaving gvm null, so any unrecognized console command (e.g. accidentally typing "demo" on a dedicated server) fell through to VM_Call(gvm, GAME_CONSOLE_COMMAND) with gvm == NULL, crashing with "VM_Call with NULL vm". Also tag that fatal error with the callnum so a null-vm crash is diagnosable without a debugger next time. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
sv.demoPlayback was purely internal, so there was no way to tell a server was stuck in sv_playdemo cinema mode without checking logs. Add sv_playingDemo (CVAR_SERVERINFO | CVAR_ROM, same pattern as mapname) so it's queryable on the local console, in CS_SERVERINFO for connected clients, and via remote getinfo/getstatus. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SV_SpawnDemoServer intentionally skips CM_LoadMap (no collision data needed for snapshot replay), so unlike a normal map spawn it never got a missing-BSP check. Cinema would start anyway, leaving every connecting client to independently discover the map is missing and disconnect instead of one clear server-side error. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed: Server (demo cinema mode) crashes after too many consecutive sv_playdemo commands due to memory leak.
Fixed: an errant condition for unknown commands while in sv_playdemo mode.
Fixed: sv_playdemo will not attempt to play a demo for a map it does not have.
Improvement: Server will not begin playing a demo until it has at least one fully connected client.
Added sv_playingdemo command to see the status of the server.