Skip to content

Preserve game speed across singleplayer save and load - #106

Open
Mohsen-Tavakoli wants to merge 1 commit into
CnCNet:mainfrom
Mohsen-Tavakoli:fix-save-load-game-speed
Open

Mohsen-Tavakoli wants to merge 1 commit into
CnCNet:mainfrom
Mohsen-Tavakoli:fix-save-load-game-speed

Conversation

@Mohsen-Tavakoli

Copy link
Copy Markdown

Summary

I've been playing Red Alert 2 / Yuri's Revenge since I was a kid back in school — now I'm 33 and this bug has annoyed me like crazy for years, so I'm really happy to finally fix it myself. I know it's a bit late, but I did it anyway haha.

When saving and loading a singleplayer Skirmish or Campaign game, the active game speed is lost and reverts back to slow/default speed:

  1. Skirmish saves: SessionClass::Save (0x69B560) writes GameModeOptionsClass::Instance into the save, and SessionClass::Load (0x69B5B0) reads it back, but Load_Game (0x67E440) never restores GameOptionsClass::Instance.GameSpeed (0xA8EB60) — and in-game speed slider changes aren't stored in GameModeOptionsClass either. When loading from the CnCNet client, GameLoadingWindow also passes [Options] GameSpeed from RA2MD.INI instead of the speed the match was played at.
  2. Campaign saves (with SpeedControl=True): SessionClass::Resume (0x69BAE2/0x69BAE7) unconditionally resets GameOptionsClass::Instance.GameSpeed back to default (2 / 30 FPS) when resuming/loading a campaign mission, even when the user enabled SpeedControl (Control Campaign Speed).

Changes

  • src/Misc/SavedGamesInSubdir.cpp:
    • Added SavedGames::GameSpeed (OLE stream L"GameSpeed", matching CustomMissionID) written on singleplayer save (SaveGame_AdditionalInfoForClient @ 0x67D2E3) and read on load (LoadGame_AdditionalInfoForClient @ 0x67E4DC).
    • Added LoadGame_AfterInit_RestoreGameSpeed (0x67E6DA) to restore GameOptionsClass::Instance.GameSpeed and GameModeOptionsClass::Instance.GameSpeed for Skirmish saves and for Campaign saves when Main::GetConfig()->SpeedControl is enabled.
    • For legacy Skirmish .SAV files created before this change (without a GameSpeed stream), falls back to restoring GameModeOptionsClass::Instance.GameSpeed loaded from the save.
  • src/Misc/GameSpeed.cpp:
    • Added SessionClass_Resume_PreserveCampaignGameSpeed (0x69BAE2, 5 bytes — cleanly before Phobos's 0x69BAE7 hook) to skip the default speed reset on SessionClass::Resume when SessionClass::IsCampaign() and Main::GetConfig()->SpeedControl are both active.
  • Multiplayer matches are untouched.

Verification

  • Verified Editor Config Checker and Nightly Build (Nightly + Nightly-CnCNetYR) pass cleanly in CI.
  • Tested the compiled Nightly-CnCNetYR CnCNet-Spawner.dll live in-game on CnCNet YR 9.4.2 (Windows 11):
    • Skirmish at 60 FPS / MAX: saving and reloading (both via in-game Load Game and Client Load Game) preserves the game speed.
    • Campaign with Control Campaign Speed (SpeedControl=True): saving and reloading preserves the selected game speed without snapping back to 30 FPS.

@github-actions

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@Belonit
Belonit requested review from 11EJDE11 and Belonit November 28, 2026 16:44
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.

1 participant