Fix deinitialization
This commit is contained in:
23
game/main.c
23
game/main.c
@@ -231,21 +231,25 @@ void deinit(void *userData) {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
InputState *input = ecs_singleton_get_mut(ECS, InputState);
|
||||
|
||||
unloadMap(game);
|
||||
bzTilesetDestroy(&game->tileset);
|
||||
// Destroy queries
|
||||
ecs_query_fini(input->queries.selected);
|
||||
|
||||
Game gameCopy = *game;
|
||||
InputState inputCopy = *input;
|
||||
|
||||
// Destroy queries
|
||||
ecs_query_fini(inputCopy.queries.selected);
|
||||
|
||||
// Destroy ECS
|
||||
ecs_fini(ECS);
|
||||
ECS = NULL;
|
||||
|
||||
bzStackAllocDestroy(&gameCopy.stackAlloc);
|
||||
bzObjectPoolDestroy(gameCopy.pools.pathData);
|
||||
bzObjectPoolDestroy(gameCopy.pools.actions);
|
||||
game = &gameCopy;
|
||||
input = &inputCopy;
|
||||
|
||||
unloadMap(game);
|
||||
bzTilesetDestroy(&game->tileset);
|
||||
|
||||
bzStackAllocDestroy(&game->stackAlloc);
|
||||
bzObjectPoolDestroy(game->pools.pathData);
|
||||
bzObjectPoolDestroy(game->pools.actions);
|
||||
|
||||
bzUIDestroy(UI);
|
||||
UI = NULL;
|
||||
@@ -375,8 +379,9 @@ static void renderMainMenu(Game *game, float dt) {
|
||||
.type = BZ_UI_LAYOUT_FLEX_BOX,
|
||||
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER
|
||||
});
|
||||
if (uiMainMenuButton("Play")) {
|
||||
if (uiMainMenuButton("Play") || true) {
|
||||
game->screen = SCREEN_GAME;
|
||||
loadMap(game, "assets/maps/map_01.tmj");
|
||||
}
|
||||
if (uiMainMenuButton("Settings")) {
|
||||
game->screen = SCREEN_SETTINGS;
|
||||
|
||||
Reference in New Issue
Block a user