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() {
|
errorret_t saveLoadSlot() {
|
||||||
assertTrue(SAVE.deviceCurrent != 0xFF, "No current device");
|
|
||||||
assertTrue(SAVE.slotCurrent < SAVE_SLOT_COUNT, "Invalid slot index");
|
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(
|
errorChain(saveDeviceSlotRead(
|
||||||
&SAVE.devices[SAVE.deviceCurrent],
|
&SAVE.devices[SAVE.deviceCurrent],
|
||||||
&SAVE.slot,
|
&SAVE.slot,
|
||||||
|
|||||||
@@ -99,20 +99,24 @@ void uiSelectSaveNameEntered(
|
|||||||
) {
|
) {
|
||||||
if(!confirmed) return;
|
if(!confirmed) return;
|
||||||
|
|
||||||
assertTrue(SAVE.deviceCurrent != 0xFF, "No current device");
|
|
||||||
const uint8_t index = UI_SELECT_SAVE.pendingNameIndex;
|
const uint8_t index = UI_SELECT_SAVE.pendingNameIndex;
|
||||||
|
|
||||||
saveslot_t slot;
|
saveslot_t slot;
|
||||||
saveSlotInit(&slot);
|
saveSlotInit(&slot);
|
||||||
stringCopy(slot.cachedData.name, text, SAVE_SLOT_NAME_LENGTH);
|
stringCopy(slot.cachedData.name, text, SAVE_SLOT_NAME_LENGTH);
|
||||||
|
|
||||||
errorret_t writeResult = saveDeviceSlotWrite(
|
// No save device available - proceed with an in-memory-only slot rather
|
||||||
&SAVE.devices[SAVE.deviceCurrent], &slot, index
|
// than writing to a device that doesn't exist (see saveLoadSlot()'s own
|
||||||
);
|
// comment on the same "continue without a save device" flow).
|
||||||
if(errorIsNotOk(writeResult)) {
|
if(SAVE.deviceCurrent != 0xFF) {
|
||||||
errorCatch(errorPrint(writeResult));
|
errorret_t writeResult = saveDeviceSlotWrite(
|
||||||
uiFatalErrorOpen(writeResult.state->message);
|
&SAVE.devices[SAVE.deviceCurrent], &slot, index
|
||||||
return;
|
);
|
||||||
|
if(errorIsNotOk(writeResult)) {
|
||||||
|
errorCatch(errorPrint(writeResult));
|
||||||
|
uiFatalErrorOpen(writeResult.state->message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SAVE.caches[index] = slot.cachedData;
|
SAVE.caches[index] = slot.cachedData;
|
||||||
|
|||||||
Reference in New Issue
Block a user