-
Notifications
You must be signed in to change notification settings - Fork 145
feat(replay): Add checkpoint save and resume functionality for replays #2152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(replay): Add checkpoint save and resume functionality for replays #2152
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/Common/ReplaySimulation.cpp | Implemented checkpoint save at specified frame and resume functionality with proper error handling |
| GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | Implemented serialization methods for replay state, added file reopening logic, and proper CRCInfo cleanup in reset() |
| GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | Added CHUNK_Recorder snapshot block, headless mode checks for UI calls, and logic to skip visual blocks in headless saves |
Sequence Diagram
sequenceDiagram
participant CLI as Command Line
participant GM as GameMain
participant RS as ReplaySimulation
participant GS as GameState
participant RC as RecorderClass
participant GL as GameLogic
participant FS as FileSystem
Note over CLI,FS: Checkpoint Save Flow
CLI->>GM: -replay file.rep -saveAtFrame 49000 -saveTo checkpoint.sav
GM->>RS: simulateReplays([file.rep])
RS->>RC: playbackFile(file.rep)
RC->>FS: Open replay file
FS-->>RC: File handle
loop Until target frame or end
RS->>GL: UPDATE()
GL-->>RS: Current frame
alt Frame == saveAtFrame
RS->>GS: saveGame(checkpoint.sav)
GS->>RC: xfer(XFER_SAVE)
Note over RC: Saves replay filename,<br/>file position, CRC state
GS->>FS: Write checkpoint file
FS-->>GS: Success
RS->>RC: stopPlayback()
RC->>FS: Close replay file
end
end
Note over CLI,FS: Checkpoint Resume Flow
CLI->>GM: -loadCheckpoint checkpoint.sav
GM->>RS: continueReplayFromCheckpoint(checkpoint.sav)
RS->>GS: loadGame(checkpoint.sav)
GS->>FS: Read checkpoint file
FS-->>GS: Checkpoint data
GS->>RC: xfer(XFER_LOAD)
Note over RC: Restores replay filename,<br/>file position, CRC state
GS->>RC: loadPostProcess()
RC->>FS: reopenReplayFileAtPosition(position)
FS-->>RC: File handle at saved position
loop Until replay end or CRC mismatch
RS->>GL: UPDATE()
GL-->>RS: Current frame
RC->>FS: Read next commands from position
alt CRC mismatch detected
RS-->>GM: Exit with error
end
end
RS-->>GM: Exit code
| if ( xfer->getXferMode() == XFER_SAVE && m_file != nullptr ) | ||
| { | ||
| m_currentFilePosition = m_file->position(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to go before xfer->xferInt( &m_currentFilePosition ). Could probably be put at the start of the function.
| if (TheRecorder->sawCRCMismatch()) | ||
| { | ||
| numErrors++; | ||
| break; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some issues with the CRC computation for the replay from save game.
Summary
-saveAtFrame <frame> -saveTo <filename>saves game state at specified frame-loadCheckpoint <filename>loads a checkpoint and resumes replay playbackUsage