From 061f255be451300b9bbce56a40266cc5432a0486 Mon Sep 17 00:00:00 2001 From: Vlad Rud Date: Sun, 6 Oct 2024 00:42:22 +0300 Subject: [PATCH] Fixed crashes after game over or winning state --- gameover.odin | 10 +++++----- winning.odin | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gameover.odin b/gameover.odin index bfc861e..1250df4 100644 --- a/gameover.odin +++ b/gameover.odin @@ -33,14 +33,14 @@ gameover_update :: proc(state: ^GameState, delta: f32) { if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) { gameover.ready_to_go = false rl.StopMusicStream(current_music) - tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, nil, proc(data: rawptr) { + tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, state, proc(data: rawptr) { + state := transmute(^GameState)data stack_pop() - state := transmute(^GameState)stack_top() - fmt.println(state.variant) - game := transmute(^Game)stack_top() + game := transmute(^Game)state.previous game_setup(game) menu := menu_init(game) stack_push(menu) + free(state) tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out) }) } @@ -76,7 +76,7 @@ gameover_draw :: proc(state: ^GameState) { } gameover_free :: proc(state: ^GameState) { - free(state) + // free(state) } gameover_ready :: proc(state: rawptr) { diff --git a/winning.odin b/winning.odin index 1d1b36c..cb74178 100644 --- a/winning.odin +++ b/winning.odin @@ -34,13 +34,13 @@ winning_update :: proc(state: ^GameState, delta: f32) { winning.ready_to_go = false rl.StopMusicStream(current_music) tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, nil, proc(data: rawptr) { + state := transmute(^GameState)data stack_pop() - state := transmute(^GameState)stack_top() - fmt.println(state.variant) - game := transmute(^Game)stack_top() + game := transmute(^Game)state.previous game_setup(game) menu := menu_init(game) stack_push(menu) + free(state) tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out) }) } @@ -75,7 +75,7 @@ winning_draw :: proc(state: ^GameState) { } winning_free :: proc(state: ^GameState) { - free(state) + // free(state) } winning_ready :: proc(state: rawptr) {