summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/game.cpp b/src/game.cpp
index f5afa82..03ea495 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -149,10 +149,15 @@ void Game_Main(PKEWindowProperties windowProps, const char *executablePath) {
// if we were passed only a scene name, create a faux level.
if (!pkeSettings.args.levelName && pkeSettings.args.sceneName) {
- pkeSettings.rt.nextLevel = PkeLevel_Create("faux-level")->levelHandle;
- PkeLevel *lvl = PkeLevel_Get(pkeSettings.rt.nextLevel);
+ PkeLevel *lvl = PkeLevel_Create("faux-level");
+ pkeSettings.rt.nextLevel = lvl->levelHandle;
scene_instance si{};
- si.scene_handle = pke_scene_get_by_name(pkeSettings.args.sceneName)->scene_handle;
+ pke_scene *scn = pke_scene_get_by_path(pkeSettings.args.sceneName);
+ if (scn == nullptr) {
+ fprintf(stdout, "[Game_Main] Did not find scene by name: '%s'\n", pkeSettings.args.sceneName);
+ goto GAME_SHUTDOWN;
+ }
+ si.scene_handle = scn->scene_handle;
pk_arr_append_t(&lvl->scene_instances, si);
}
@@ -281,6 +286,7 @@ void Game_Main(PKEWindowProperties windowProps, const char *executablePath) {
} catch (...) {
fprintf(stderr, "Game_Main UNHANDLED EXCEPTION\n");
}
+GAME_SHUTDOWN:
fprintf(stdout, "Game_Main SHUTDOWN INITIATED\n");
#ifndef NDEBUG
pk_memory_debug_print();