summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzlago2025-01-26 19:16:57 +0100
committerzlago2025-01-26 19:16:57 +0100
commitc7d6efa3cdc39251d29450d2efa37da89cb8099a (patch)
tree44fd8b57842ca47ef22eaf9f18a6423f64997ac8 /src
parent1e792e1a30aeb9f19518b56936cc9154164c3f76 (diff)
actually handle corrupt saves
Diffstat (limited to 'src')
-rw-r--r--src/main.c12
1 files changed, 10 insertions, 2 deletions
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
+ }
}
}