Repository navigation
Preserve game speed across singleplayer save and load - #106
Open
Mohsen-Tavakoli wants to merge 1 commit into
Open
Mohsen-Tavakoli wants to merge 1 commit into
Mohsen-Tavakoli wants to merge 1 commit into
Conversation
|
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. |
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.
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:
SessionClass::Save(0x69B560) writesGameModeOptionsClass::Instanceinto the save, andSessionClass::Load(0x69B5B0) reads it back, butLoad_Game(0x67E440) never restoresGameOptionsClass::Instance.GameSpeed(0xA8EB60) — and in-game speed slider changes aren't stored inGameModeOptionsClasseither. When loading from the CnCNet client,GameLoadingWindowalso passes[Options] GameSpeedfromRA2MD.INIinstead of the speed the match was played at.SpeedControl=True):SessionClass::Resume(0x69BAE2/0x69BAE7) unconditionally resetsGameOptionsClass::Instance.GameSpeedback to default (2/ 30 FPS) when resuming/loading a campaign mission, even when the user enabledSpeedControl(Control Campaign Speed).Changes
src/Misc/SavedGamesInSubdir.cpp:SavedGames::GameSpeed(OLE streamL"GameSpeed", matchingCustomMissionID) written on singleplayer save (SaveGame_AdditionalInfoForClient@0x67D2E3) and read on load (LoadGame_AdditionalInfoForClient@0x67E4DC).LoadGame_AfterInit_RestoreGameSpeed(0x67E6DA) to restoreGameOptionsClass::Instance.GameSpeedandGameModeOptionsClass::Instance.GameSpeedfor Skirmish saves and for Campaign saves whenMain::GetConfig()->SpeedControlis enabled..SAVfiles created before this change (without aGameSpeedstream), falls back to restoringGameModeOptionsClass::Instance.GameSpeedloaded from the save.src/Misc/GameSpeed.cpp:SessionClass_Resume_PreserveCampaignGameSpeed(0x69BAE2, 5 bytes — cleanly before Phobos's0x69BAE7hook) to skip the default speed reset onSessionClass::ResumewhenSessionClass::IsCampaign()andMain::GetConfig()->SpeedControlare both active.Verification
Editor Config CheckerandNightly Build(Nightly+Nightly-CnCNetYR) pass cleanly in CI.Nightly-CnCNetYRCnCNet-Spawner.dlllive in-game on CnCNet YR9.4.2(Windows 11):SpeedControl=True): saving and reloading preserves the selected game speed without snapping back to 30 FPS.