Fixed crashes after game over or winning state

This commit is contained in:
Vlad Rud 2024-10-06 00:42:22 +03:00
parent 28d0951d08
commit 061f255be4
2 changed files with 9 additions and 9 deletions

View File

@ -33,14 +33,14 @@ gameover_update :: proc(state: ^GameState, delta: f32) {
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) { if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
gameover.ready_to_go = false gameover.ready_to_go = false
rl.StopMusicStream(current_music) 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() stack_pop()
state := transmute(^GameState)stack_top() game := transmute(^Game)state.previous
fmt.println(state.variant)
game := transmute(^Game)stack_top()
game_setup(game) game_setup(game)
menu := menu_init(game) menu := menu_init(game)
stack_push(menu) stack_push(menu)
free(state)
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out) 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) { gameover_free :: proc(state: ^GameState) {
free(state) // free(state)
} }
gameover_ready :: proc(state: rawptr) { gameover_ready :: proc(state: rawptr) {

View File

@ -34,13 +34,13 @@ winning_update :: proc(state: ^GameState, delta: f32) {
winning.ready_to_go = false winning.ready_to_go = false
rl.StopMusicStream(current_music) 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, nil, proc(data: rawptr) {
state := transmute(^GameState)data
stack_pop() stack_pop()
state := transmute(^GameState)stack_top() game := transmute(^Game)state.previous
fmt.println(state.variant)
game := transmute(^Game)stack_top()
game_setup(game) game_setup(game)
menu := menu_init(game) menu := menu_init(game)
stack_push(menu) stack_push(menu)
free(state)
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out) 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) { winning_free :: proc(state: ^GameState) {
free(state) // free(state)
} }
winning_ready :: proc(state: rawptr) { winning_ready :: proc(state: rawptr) {