Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically save after every scene transition #984

Merged
merged 5 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libultraship/libultraship/ImGuiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,9 @@ namespace SohImGui {
ImGui::EndMenu();
}

EnhancementCheckbox("Autosave", "gAutosave");
Tooltip("Automatically save the game every time a new area is entered");

EXPERIMENTAL();

const char* fps_cvar = "gInterpolationFPS";
Expand Down
1 change: 1 addition & 0 deletions soh/include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,7 @@ s32 func_800C0CB8(GlobalContext* globalCtx);
s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx);
s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw);
s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* pos);
void Gameplay_PerformSave(GlobalContext* globalCtx);
void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg);
void PreRender_Init(PreRender* this);
void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf);
Expand Down
21 changes: 21 additions & 0 deletions soh/src/code/z_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,11 @@ void Gameplay_Update(GlobalContext* globalCtx) {
gTrnsnUnkState = 0;
R_UPDATE_RATE = 3;
}

// Same code lives in z_kaleido_scope_PAL.c to save the game manually
if (CVar_GetS32("gAutosave", 0) && (globalCtx->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (globalCtx->sceneNum != SCENE_KAKUSIANA)) {
Gameplay_PerformSave(globalCtx);
}
}
globalCtx->sceneLoadFlag = 0;
} else {
Expand Down Expand Up @@ -1940,3 +1945,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();
}
}
14 changes: 1 addition & 13 deletions soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c
Original file line number Diff line number Diff line change
Expand Up @@ -3837,19 +3837,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx)
} else {
Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0,
&D_801333E8);
Gameplay_SaveSceneFlags(globalCtx);
gSaveContext.savedSceneNum = globalCtx->sceneNum;
if (gSaveContext.temporaryWeapon) {
gSaveContext.equips.buttonItems[0] = ITEM_NONE;
player->currentSwordItem = ITEM_NONE;
Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE);
Save_SaveFile();
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI;
player->currentSwordItem = ITEM_SWORD_KOKIRI;
Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI);
} else {
Save_SaveFile();
}
Gameplay_PerformSave(globalCtx);
pauseCtx->unk_1EC = 4;
D_8082B25C = 3;
}
Expand Down