From 1f3cf01419be9d378dac53f9760e473117067f37 Mon Sep 17 00:00:00 2001 From: freezarite Date: Mon, 16 Dec 2024 06:08:52 +0100 Subject: [PATCH] fixed a bug with the implementation of the nlohmann library in the CMakeLists.txt fixed a bug where the config was not loaded correctly in the GameInternal.cpp --- CMakeLists.txt | 3 +-- src/GameInternal.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12d886d..2b44666 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ add_subdirectory(extern/SDL_image EXCLUDE_FROM_ALL) add_subdirectory(extern/SDL_mixer EXCLUDE_FROM_ALL) add_subdirectory(extern/SDL_ttf EXCLUDE_FROM_ALL) add_subdirectory(extern/tmxlite/tmxlite EXCLUDE_FROM_ALL) -add_subdirectory(extern/nlohmann_json EXCLUDE_FROM_ALL) +include_directories(extern/nlohmann_json/include) file(GLOB_RECURSE SOURCES ${ENGINE_SOURCE_DIR}/src/*.cpp) @@ -40,7 +40,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC # should be private when all SDL fu SDL3_mixer::SDL3_mixer-static SDL3_ttf::SDL3_ttf-static tmxlite - nlohmann_json::nlohmann_json ) if(CMAKE_BUILD_TYPE MATCHES "Debug") diff --git a/src/GameInternal.cpp b/src/GameInternal.cpp index 7d5f5fc..65619f2 100644 --- a/src/GameInternal.cpp +++ b/src/GameInternal.cpp @@ -31,11 +31,13 @@ GameInternal::~GameInternal() = default; SDL_AppResult GameInternal::init() { - this->gameInstance = GameFactory::instance().create(this); - ConfigLoader().setCustomConfig(this->gameInstance->getConfigFilePath()); - ConfigLoader().init(); + ConfigLoader* loader = new ConfigLoader(); - json config = ConfigLoader().getFinalConfig(); + this->gameInstance = GameFactory::instance().create(this); + loader->setCustomConfig(this->gameInstance->getConfigFilePath()); + loader->init(); + + json config = loader->getFinalConfig(); GameInternal::assets = new AssetManager(&manager); GameInternal::textureManager = new TextureManager(&manager);