Fixed segfault that happend when you'd exit the ingame-state.
This commit is contained in:
11
src/main.c
11
src/main.c
@@ -1,5 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "presentation/states/state_ingame.h"
|
#include "presentation/states/state_ingame.h"
|
||||||
#include "presentation/states/state_main_menu.h"
|
#include "presentation/states/state_main_menu.h"
|
||||||
@@ -29,18 +30,16 @@ int main() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Presentation_State *state = presentation_state_machine.current;
|
|
||||||
|
|
||||||
// Tick.
|
// Tick.
|
||||||
if(state != NULL && state->tick != NULL) {
|
if(presentation_state_machine.current != NULL && presentation_state_machine.current->tick != NULL) {
|
||||||
state->tick(state);
|
presentation_state_machine.current->tick(presentation_state_machine.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render.
|
// Render.
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
{
|
{
|
||||||
if(state != NULL && state->render != NULL) {
|
if(presentation_state_machine.current != NULL && presentation_state_machine.current->render != NULL) {
|
||||||
state->render(state);
|
presentation_state_machine.current->render(presentation_state_machine.current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|||||||
@@ -91,7 +91,10 @@ static void state_render(Presentation_State *state) {
|
|||||||
ClearBackground((Color) { 240, 236, 226, 255 });
|
ClearBackground((Color) { 240, 236, 226, 255 });
|
||||||
|
|
||||||
Simulation_World *sim_world = &g_current_session->simulation_world;
|
Simulation_World *sim_world = &g_current_session->simulation_world;
|
||||||
|
assert(sim_world != NULL);
|
||||||
|
|
||||||
Game_World *world = sim_world->game_world;
|
Game_World *world = sim_world->game_world;
|
||||||
|
assert(world != NULL);
|
||||||
Grid *grid = &world->grid;
|
Grid *grid = &world->grid;
|
||||||
|
|
||||||
uint32_t grid_total_size = grid->width * grid->height;
|
uint32_t grid_total_size = grid->width * grid->height;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ static void state_enter(Presentation_State *state) {
|
|||||||
Presentation_State_Main_Menu_Context *ctx = (Presentation_State_Main_Menu_Context *)state->context;
|
Presentation_State_Main_Menu_Context *ctx = (Presentation_State_Main_Menu_Context *)state->context;
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
|
||||||
printf("Entered main menu\n");
|
ctx->mode = Main_Menu_Mode_Home;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void state_tick(Presentation_State *state) {
|
static void state_tick(Presentation_State *state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user