Automatically save after every scene transition (#984)

* Automatically save after every scene transition

* Refactor and don't save in grottos

* Don't save in cutscenes

* Save after getting items as well

* Fix paren
This commit is contained in:
Josh Bodner 2022-08-04 21:15:49 -07:00 committed by GitHub
parent 2f5f089e7f
commit c23457d666
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 13 deletions

View file

@ -698,6 +698,11 @@ void Gameplay_Update(GlobalContext* globalCtx) {
gTrnsnUnkState = 0;
R_UPDATE_RATE = 3;
}
// Don't autosave in grottos or cutscenes
if (CVar_GetS32("gAutosave", 0) && (globalCtx->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (globalCtx->sceneNum != SCENE_KAKUSIANA) && (gSaveContext.cutsceneIndex == 0)) {
Gameplay_PerformSave(globalCtx);
}
}
globalCtx->sceneLoadFlag = 0;
} else {
@ -1972,3 +1977,19 @@ s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* pos) {
return false;
}
}
void Gameplay_PerformSave(GlobalContext* globalCtx) {
Gameplay_SaveSceneFlags(globalCtx);
gSaveContext.savedSceneNum = globalCtx->sceneNum;
if (gSaveContext.temporaryWeapon) {
gSaveContext.equips.buttonItems[0] = ITEM_NONE;
GET_PLAYER(globalCtx)->currentSwordItem = ITEM_NONE;
Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE);
Save_SaveFile();
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI;
GET_PLAYER(globalCtx)->currentSwordItem = ITEM_SWORD_KOKIRI;
Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI);
} else {
Save_SaveFile();
}
}