Skip to content

refactor(client): extract demo subsystem into cl_demo module#155

Merged
timfox merged 3 commits intomainfrom
cursor/client-demo-module-f2d7
May 4, 2026
Merged

refactor(client): extract demo subsystem into cl_demo module#155
timfox merged 3 commits intomainfrom
cursor/client-demo-module-f2d7

Conversation

@timfox
Copy link
Copy Markdown
Owner

@timfox timfox commented Apr 27, 2026

Summary

This change modularizes a large, self-contained slice of the client: demo recording and playback (.dm_* files, record / demo / stoprecord console commands, and the logic that copies live server packets into an open demo file).

What changed

  • New src/client/cl_demo.c and cl_demo.h — all demo I/O, command registration, and helpers that previously lived in cl_main.c.
  • cl_main.c — calls CL_Demo_InitCommands() / CL_Demo_ShutdownCommands() from CL_Init / CL_Shutdown, and CL_Demo_WriteServerPacket() from CL_PacketEvent when recording a live connection.
  • Docsdocs/ARCHITECTURE.md lists cl_demo under src/client/.

Behavior

No intended gameplay or protocol changes: public symbols CL_ReadDemoMessage and CL_StopRecord_f remain for existing call sites (cl_parse.c, cl_cgame.c).

Validation

  • ./scripts/compile_engine.sh vulkan (Release)
  • ctest in build-vk-Release — 19/19 passed
Open in Web Open in Cursor 

cursoragent and others added 2 commits April 27, 2026 20:58
Move record/demo/stoprecord commands, demo file I/O, and net-packet
demowriting from cl_main.c into cl_demo.c. cl_main calls
CL_Demo_InitCommands/Shutdown and CL_Demo_WriteServerPacket for live
recording. Public entry points (CL_ReadDemoMessage, CL_StopRecord_f)
remain in cl_demo.c for cl_parse and cgame.

Co-authored-by: Tim Fox <timfox@outlook.com>
Co-authored-by: Tim Fox <timfox@outlook.com>
@timfox timfox marked this pull request as ready for review May 4, 2026 23:04
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e908a18138

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

RB_BeginDrawingView();

#ifdef USE_VULKAN
vk_forward_plus_upload_refdef();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Call Forward+ upload before entering render pass

vk_forward_plus_upload_refdef() records a transfer barrier and vkCmdCopyBuffer, but this call site runs after RB_BeginDrawingView(). In this renderer path the command buffer is already inside the main render pass (started in vk_begin_frame()), so recording transfer commands here violates Vulkan command-validity rules and can trigger validation errors or device loss when r_forwardPlus=1. Move the upload to a point before the main pass begins (or outside any active render pass).

Useful? React with 👍 / 👎.

@timfox timfox merged commit 53524a2 into main May 4, 2026
42 of 50 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Security review complete: no high-confidence medium-or-higher vulnerabilities found in the modified code.

Reviewed the demo command inputs, demo file open/write paths, pure-FS bypass usage, and moved playback/recording code against the prior implementation. The risky surfaces identified here appear to be pre-existing behavior preserved by the refactor rather than newly introduced or exposed by this PR. No new inline security findings.

Open in Web View Automation 

Sent by Cursor Automation: Find vulnerabilities

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security review complete. I did not find any high-confidence medium, high, or critical vulnerabilities introduced by this PR.

The demo filename/file parsing paths and nextdemo command execution remain the same behavior as the code previously in cl_main.c; this refactor primarily moves that logic into cl_demo.c and replaces call sites with module init/shutdown and CL_Demo_WriteServerPacket() delegation. No new finding comments are being left.

Open in Web View Automation 

Sent by Cursor Automation: Find vulnerabilities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants