|
|
@@ -84,16 +84,23 @@ static void game_stop(void *ctx)
|
|
|
level_clear(game_context->levels[game_context->current_level]);
|
|
|
}
|
|
|
|
|
|
- if (game_context->player_context)
|
|
|
+ PlayerContext *player_context = malloc(sizeof(PlayerContext));
|
|
|
+ if (!player_context)
|
|
|
{
|
|
|
- if (!game_context->ended_early)
|
|
|
- easy_flipper_dialog(
|
|
|
- "Game Over",
|
|
|
- "Thanks for playing FlipWorld!\nHit BACK then wait for\nthe game to save.");
|
|
|
- else
|
|
|
- easy_flipper_dialog(
|
|
|
- "Game Over", "Ran out of memory so the\ngame ended early.\nHit BACK to exit.");
|
|
|
+ FURI_LOG_E("Game", "Failed to allocate PlayerContext");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ if (!game_context->ended_early)
|
|
|
+ easy_flipper_dialog(
|
|
|
+ "Game Over",
|
|
|
+ "Thanks for playing FlipWorld!\nHit BACK then wait for\nthe game to save.");
|
|
|
+ else
|
|
|
+ easy_flipper_dialog(
|
|
|
+ "Game Over", "Ran out of memory so the\ngame ended early.\nHit BACK to exit.");
|
|
|
+
|
|
|
+ if (load_player_context(player_context))
|
|
|
+ {
|
|
|
ViewPort *view_port = view_port_alloc();
|
|
|
view_port_draw_callback_set(view_port, thanks, NULL);
|
|
|
Gui *gui = furi_record_open(RECORD_GUI);
|
|
|
@@ -101,9 +108,9 @@ static void game_stop(void *ctx)
|
|
|
uint32_t tick_count = furi_get_tick();
|
|
|
furi_delay_ms(800);
|
|
|
|
|
|
- save_player_context_api(game_context->player_context);
|
|
|
+ save_player_context_api(player_context);
|
|
|
|
|
|
- const uint32_t delay = 2500;
|
|
|
+ const uint32_t delay = 3500;
|
|
|
tick_count = (tick_count + delay) - furi_get_tick();
|
|
|
if (tick_count <= delay)
|
|
|
{
|
|
|
@@ -117,6 +124,13 @@ static void game_stop(void *ctx)
|
|
|
gui_remove_view_port(gui, view_port);
|
|
|
furi_record_close(RECORD_GUI);
|
|
|
}
|
|
|
+
|
|
|
+ // free the player context
|
|
|
+ if (player_context)
|
|
|
+ {
|
|
|
+ free(player_context);
|
|
|
+ player_context = NULL;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|