From 722d24991632bd4666ab61d64dcaa7f952f7f928 Mon Sep 17 00:00:00 2001 From: Mauro Vietri Date: Mon, 29 May 2023 08:25:35 -0300 Subject: [PATCH] Autosave when quitting game (moronimo) --- src/minarch/minarch.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/minarch/minarch.c b/src/minarch/minarch.c index f969b42..a0b643b 100644 --- a/src/minarch/minarch.c +++ b/src/minarch/minarch.c @@ -504,12 +504,19 @@ static void State_autosave(void) { State_write(); state_slot = last_state_slot; } -static void State_resume(void) { - if (!exists(RESUME_SLOT_PATH)) return; - +static void State_resume(void) { int last_state_slot = state_slot; - state_slot = getInt(RESUME_SLOT_PATH); - unlink(RESUME_SLOT_PATH); + + if (exists(RESUME_SLOT_PATH)) { + state_slot = getInt(RESUME_SLOT_PATH); + unlink(RESUME_SLOT_PATH); + if( state_slot == 8 ) { + state_slot = AUTO_RESUME_SLOT; + } + } else { + state_slot = AUTO_RESUME_SLOT; + } + State_read(); state_slot = last_state_slot; } @@ -4357,6 +4364,7 @@ int main(int argc , char* argv[]) { Menu_quit(); finish: + State_autosave(); Game_close(); Core_unload();