Don't autosave immediately after purchasing from a shop (#2079)

This commit is contained in:
Josh Bodner 2022-12-10 12:39:26 -08:00 committed by GitHub
commit 26ec69606a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 71 additions and 25 deletions

View file

@ -2715,8 +2715,9 @@ u8 Item_CheckObtainability(u8 item) {
return gSaveContext.inventory.items[slot];
}
// Save when receiving an item, unless it's purchased from a shop
void PerformAutosave(PlayState* play, u8 item) {
if (CVar_GetS32("gAutosave", 0) && (play && play->sceneNum != SCENE_KENJYANOMA)) {
if (CVar_GetS32("gAutosave", 0) && (play != NULL) && (play->sceneNum != SCENE_KENJYANOMA) && (gSaveContext.pendingSale == ITEM_NONE)) {
if (CVar_GetS32("gAutosaveAllItems", 0)) {
Play_PerformSave(play);
} else if (CVar_GetS32("gAutosaveMajorItems", 1)) {
@ -6301,6 +6302,11 @@ void Interface_Update(PlayState* play) {
gSaveContext.rupees--;
Audio_PlaySoundGeneral(NA_SE_SY_RUPY_COUNT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
if (gSaveContext.rupeeAccumulator == 0) {
u16 tempSaleItem = gSaveContext.pendingSale;
gSaveContext.pendingSale = ITEM_NONE;
PerformAutosave(play, tempSaleItem);
}
} else {
gSaveContext.rupeeAccumulator = 0;
}