Fix crash when continuing without a save device
saveLoadSlot() and uiSelectSaveNameEntered() both asserted SAVE.deviceCurrent != 0xFF unconditionally, crashing as soon as a player dismissed the "no save device found" prompt and tried to start a game or name a new save. Both now fall back to an in-memory-only slot (no device to persist to) instead of asserting, matching the "continue without a save device" flow the main menu cutscene already offers. Verified fixed on Dolphin/GameCube; built clean on Linux and GameCube (Docker). Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -208,9 +208,15 @@ errorret_t saveSaveSlot() {
|
||||
}
|
||||
|
||||
errorret_t saveLoadSlot() {
|
||||
assertTrue(SAVE.deviceCurrent != 0xFF, "No current device");
|
||||
assertTrue(SAVE.slotCurrent < SAVE_SLOT_COUNT, "Invalid slot index");
|
||||
|
||||
if(SAVE.deviceCurrent == 0xFF) {
|
||||
// No save device available, so we assume an empty slot.
|
||||
saveSlotInit(&SAVE.slot);
|
||||
SAVE.caches[SAVE.slotCurrent] = SAVE.slot.cachedData;
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorChain(saveDeviceSlotRead(
|
||||
&SAVE.devices[SAVE.deviceCurrent],
|
||||
&SAVE.slot,
|
||||
|
||||
@@ -99,13 +99,16 @@ void uiSelectSaveNameEntered(
|
||||
) {
|
||||
if(!confirmed) return;
|
||||
|
||||
assertTrue(SAVE.deviceCurrent != 0xFF, "No current device");
|
||||
const uint8_t index = UI_SELECT_SAVE.pendingNameIndex;
|
||||
|
||||
saveslot_t slot;
|
||||
saveSlotInit(&slot);
|
||||
stringCopy(slot.cachedData.name, text, SAVE_SLOT_NAME_LENGTH);
|
||||
|
||||
// No save device available - proceed with an in-memory-only slot rather
|
||||
// than writing to a device that doesn't exist (see saveLoadSlot()'s own
|
||||
// comment on the same "continue without a save device" flow).
|
||||
if(SAVE.deviceCurrent != 0xFF) {
|
||||
errorret_t writeResult = saveDeviceSlotWrite(
|
||||
&SAVE.devices[SAVE.deviceCurrent], &slot, index
|
||||
);
|
||||
@@ -114,6 +117,7 @@ void uiSelectSaveNameEntered(
|
||||
uiFatalErrorOpen(writeResult.state->message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SAVE.caches[index] = slot.cachedData;
|
||||
uiSelectSaveRefreshSlot(index);
|
||||
|
||||
Reference in New Issue
Block a user