From c7d6efa3cdc39251d29450d2efa37da89cb8099a Mon Sep 17 00:00:00 2001 From: zlago Date: Sun, 26 Jan 2025 19:16:57 +0100 Subject: actually handle corrupt saves --- src/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index c10657a..c5f8359 100644 --- a/src/main.c +++ b/src/main.c @@ -420,7 +420,12 @@ int main(int const argc, char *const *const argv) { player_property(next_entities.player, "y", "64"); game_load_level("untitled"); } else { - game_load(file); + if (game_load(file)) { + fputs("the save file is corrupt!\n", stderr); + player_property(next_entities.player, "x", "40"); + player_property(next_entities.player, "y", "64"); + game_load_level("untitled"); + } } #if 0 struct blob blob = res_get_map("untitled"); @@ -641,7 +646,10 @@ void main_loop(void) { player_property(next_entities.player, "y", "64"); game_load_level("untitled"); } else { - game_load(file); + if (game_load(file)) { + fputs("the save file somehow corrupted itself!\n", stderr); + goto end; // better than freezing if the save file magically corrupts + } } } -- cgit 1.4.1-2-gfad0