Skip to content

feat(cs2): auto-upgrade pre-AG2 demos and parallelize demo repair - #220

Merged
Wockstajit merged 1 commit into
mainfrom
feat/auto-upgrade-legacy-demos
Dec 2, 2026
Merged

Wockstajit merged 1 commit into
mainfrom
feat/auto-upgrade-legacy-demos

Conversation

@Wockstajit

Copy link
Copy Markdown
Owner

Closes #219.

Summary

  • Automatic pre-AG2 legacy demo upgrading (1.39.4.8..=1.41.4.1 / protocols 13948..=14141):
    • Extends \DemoRepair\ (\AfxHookSource2/Filmmaker/Demo/DemoRepair.{h,cpp}) to classify protocols \13948..=14141\ as \LegacyCheck\ whenever the staged standalone upgrade helper is available beside \AfxHookSource2.dll.
    • Runs the standalone upgrade CLI in headless --force --json\ mode under the cancellable job object, then automatically chains the output through \FilmmakerDemoRepair.exe\ so legacy type-138 decal messages are also stripped before caching
      epaired.dem\ and writing a 3-part .src\ cache marker.
    • Validates the repaired header, map name, file size, and upgraded protocol (> 14141) before exposing the cached copy to CS2.
  • 8x faster parallel \FilmmakerDemoRepairGo\ (5.22s -> 0.64s on a 228 MB demo):
    • Rewrites bitstream scanning/copying with uint64 fast paths and byte-chunked copies (\FilmmakerDemoRepairGo/bitstream.go).
    • Parallelizes frame snappy decode / packet scan / re-encode across up to 8 workers with per-worker scratch buffers and zero-allocation fast scan on untouched packets, preserving bit-for-bit identical output (\FilmmakerDemoRepairGo/main.go, \main_test.go).
  • Launcher bundle staging:
    • Adds pinned SHA-256 staging script \SourceMovieMakerLauncher/scripts/stage-bundled-demo-upgrade.ps1\ and wires it into \SourceMovieMakerLauncher/scripts/build-bundle.ps1\ (shipping the standalone helper with its license notices beside
      untime/x64/FilmmakerDemoUpgrade, matching the bundled FFmpeg pattern).

Verification

  • \go test -v ./...\ in \FilmmakerDemoRepairGo/\ passed.
  • Benchmarked \FilmmakerDemoRepair.exe\ on a 228 MB upgraded demo: \

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T12:14:54.638154Z 0f11271 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 0f112710ca

ℹ️ 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".

& powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'stage-bundled-ffmpeg.ps1') -Destination (Join-Path $runtime 'ffmpeg')
if ($LASTEXITCODE -ne 0) { throw 'Staging bundled FFmpeg failed.' }
# ---- Pre-AG2 legacy demo upgrader: standalone GPL-3.0 CLI helper with its LICENSE beside it -------
& powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'stage-bundled-demo-upgrade.ps1') -Destination (Join-Path $runtime 'x64\FilmmakerDemoUpgrade')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stage the upgrader for thin runtime payloads

For users of the supported thin installer, this staging call only adds the executable to the bundled runtime. build-release-payload.ps1 builds the downloadable runtime by copying bin/x64 and does not stage the upgrader, so that payload lacks the file FindUpgradeExe() looks for and protocols 13948–14141 remain unsupported. Stage the helper in the release-payload path as well.

Useful? React with 👍 / 👎.

const DemoHeaderInfo src = ReadDemoHeader(demoPath);
const DemoHeaderInfo out = ReadDemoHeader(repairedPath);
if (!out.ok) { outWhy = "the repaired copy has no readable demo header"; return false; }
if (requireProtocolUpgrade && out.networkProtocol > 0 && out.networkProtocol <= kRejectedAtOrBelowProtocol) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject upgraded headers without a protocol

If an upgraded output has a readable demo magic/header but lacks network_protocol, ReadDemoHeader can return ok with out.networkProtocol == 0; this condition then accepts it as upgraded. The caller may cache and serve a copy whose protocol was never verified. Reject zero or otherwise unknown protocols when an upgrade is required.

Useful? React with 👍 / 👎.

@Wockstajit
Wockstajit merged commit 12fe634 into main Dec 2, 2026
9 checks passed
@Wockstajit
Wockstajit deleted the feat/auto-upgrade-legacy-demos branch December 2, 2026 12:16
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.

Auto-upgrade pre-AG2 CS2 demos and parallelize demo repair

1 participant