Skip to content

Feat/solucionar crash checkpoints#400

Merged
TheUnrealZaka merged 2 commits into
mainfrom
feat/solucionar-crash-checkpoints
Jun 11, 2026
Merged

Feat/solucionar crash checkpoints#400
TheUnrealZaka merged 2 commits into
mainfrom
feat/solucionar-crash-checkpoints

Conversation

@TheUnrealZaka

Copy link
Copy Markdown
Member

Canvis

Issues relacionades

Tipus de canvi

  • feat: Nova funcionalitat
  • fix: Correcció de bug
  • art: Asset gràfic
  • docs: Documentació
  • refactor: Refactorització de codi
  • build: Canvis al sistema de build

Checklist

  • El codi compila sense errors
  • He provat els canvis localment
  • He seguit les naming conventions (PascalCase classes, camelCase mètodes, m_ membres)
  • He usat Conventional Commits al títol del PR
  • He enllaçat la Issue corresponent

MarcPladellorensPerez and others added 2 commits June 12, 2026 01:05
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.
Copilot AI review requested due to automatic review settings June 11, 2026 23:11
@TheUnrealZaka TheUnrealZaka requested a review from a team as a code owner June 11, 2026 23:11
@TheUnrealZaka TheUnrealZaka merged commit 0998246 into main Jun 11, 2026
2 checks passed

Copilot AI 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.

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 calling QuickLoadImmediate().
  • 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 thread src/Scene.cpp
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;
}
}
}
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.

3 participants