Feat/solucionar crash checkpoints#400
Merged
Merged
Conversation
Before attempting a checkpoint QuickLoad, parse assets/saves/savedata.xml and compare the save's scene.currentMapPath to the currentMapFile_; only call QuickLoadImmediate() if they match. Adjust logging text to clarify when no checkpoint exists for this map. On clean restarts, always load currentMapFile_ and try to resolve a portal spawn (subMapSpawnId_ or pendingLevelSpawnId_); pass spawn coordinates into LoadEntities and position the player accordingly (centering with SetPosition). These changes prevent loading a checkpoint from a different map and improve spawn handling on restarts.
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent checkpoint-related crashes by only respawning from a checkpoint when the checkpoint save belongs to the currently loaded map; otherwise it performs a clean in-place reload of the current map (optionally applying a portal spawn).
Changes:
- Add logic in
ResolveCheckpointTransition()to validate that the checkpoint save corresponds to the current map before callingQuickLoadImmediate(). - Improve the clean-restart path to reload
currentMapFile_and optionally spawn the player at a portal/level spawn point when available. - Update log/comment text to clarify that the fallback is due to a checkpoint not existing for the current map.
Comment on lines
+3086
to
+3099
| bool useCheckpoint = false; | ||
| if (Engine::GetInstance().saveSystem->HasCheckpointSave()) { | ||
| pugi::xml_document doc; | ||
| if (doc.load_file("assets/saves/savedata.xml")) { | ||
| pugi::xml_node root = doc.child("savegame"); | ||
| pugi::xml_node sceneNode = root ? root.child("scene") : pugi::xml_node(); | ||
| std::string cpMap = sceneNode ? sceneNode.attribute("currentMapPath").as_string("") : ""; | ||
|
|
||
| if (cpMap.length() >= currentMapFile_.length() && | ||
| cpMap.compare(cpMap.length() - currentMapFile_.length(), currentMapFile_.length(), currentMapFile_) == 0) { | ||
| useCheckpoint = true; | ||
| } | ||
| } | ||
| } |
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.
Canvis
Issues relacionades
Tipus de canvi
feat: Nova funcionalitatfix: Correcció de bugart: Asset gràficdocs: Documentaciórefactor: Refactorització de codibuild: Canvis al sistema de buildChecklist