Load the chosen save slot on selection, fix transition finished re-firing

Picking a save slot now sets SAVE.slotCurrent and calls saveLoadSlot()
before entering the overworld, same slotCurrent/saveSlotInit/saveLoadSlot
sequence saveLoadAllSlots uses per-slot; a load failure shows the fatal
error overlay instead of proceeding with stale/garbage slot data.

Also fixes uiTransitionUpdate firing its "finished" callback every frame
after a transition completes instead of once - latent since the generic
transition system had no real caller yet.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
2026-09-06 12:13:51 -05:00
co-authored by Claude Sonnet 5
parent 845a395ff1
commit 45c1f9004b
2 changed files with 20 additions and 2 deletions
+11 -1
View File
@@ -15,9 +15,11 @@
#include "locale/localemanager.h"
#include "asset/loader/locale/assetlocaleloader.h"
#include "ui/dialog/save/uiselectsave.h"
#include "ui/overlay/uifatalerror.h"
#include "rpg/cutscene/cutscenesystem.h"
#include "scene/scene.h"
#include "asset/asset.h"
#include "save/save.h"
#define UI_MAIN_MENU_INDEX_START_GAME 0
#define UI_MAIN_MENU_INDEX_OPTIONS 1
@@ -47,7 +49,15 @@ void uiMainMenuSelectSaveResult(const uint8_t slotIndex, void *user) {
return;
}
// TODO: load/start the game using the chosen save slot.
SAVE.slotCurrent = slotIndex;
saveSlotInit(&SAVE.slot);
errorret_t result = saveLoadSlot();
if(errorIsNotOk(result)) {
errorCatch(errorPrint(result));
uiFatalErrorOpen(result.state->message);
return;
}
sceneSet(SCENE_TYPE_OVERWORLD);
}
+9 -1
View File
@@ -54,7 +54,15 @@ errorret_t uiTransitionUpdate(void) {
);
if(UI_TRANSITION.data.t >= 1.0f && UI_TRANSITION.finished) {
UI_TRANSITION.finished(UI_TRANSITION.user);
// Saved and cleared before firing so a callback that immediately
// starts another transition isn't clobbered by this function's own
// cleanup running after it - same reentrancy hazard as uiFocusPop,
// see src/dusk/ui/focus/uifocus.c. Without this, finished would also
// just keep re-firing every frame forever once t reaches 1.0.
uitransitioncallback_t finished = UI_TRANSITION.finished;
void *user = UI_TRANSITION.user;
UI_TRANSITION.finished = NULL;
finished(user);
}
errorOk();