From 4b39e77304094708d5c503b6a221386408cc4409 Mon Sep 17 00:00:00 2001 From: hop311 Date: Wed, 12 Jun 2024 23:24:00 +0100 Subject: Separated GameManager into Definition and Instance Managers --- src/headless/main.cpp | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'src/headless/main.cpp') diff --git a/src/headless/main.cpp b/src/headless/main.cpp index 68e0710..1acf581 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -1,7 +1,7 @@ #include -#include #include +#include #include #include @@ -18,42 +18,22 @@ static void print_help(std::ostream& stream, char const* program_name) { << "(Paths with spaces need to be enclosed in \"quotes\").\n"; } -static bool headless_load(GameManager& game_manager, Dataloader& dataloader) { - bool ret = true; - - if (!dataloader.load_defines(game_manager)) { - Logger::error("Failed to load defines!"); - ret = false; - } - if (!dataloader.load_localisation_files( - [](std::string_view key, Dataloader::locale_t locale, std::string_view localisation) -> bool { - return true; - } - )) { - Logger::error("Failed to load localisation!"); - ret = false; - } - - return ret; -} - static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) { bool ret = true; - Dataloader dataloader; - if (!dataloader.set_roots(roots)) { - Logger::error("Failed to set dataloader roots!"); - ret = false; - } - GameManager game_manager { []() { Logger::info("State updated"); }, nullptr }; - ret &= headless_load(game_manager, dataloader); + ret &= game_manager.load_definitions( + roots, + [](std::string_view key, Dataloader::locale_t locale, std::string_view localisation) -> bool { + return true; + } + ); if (run_tests) { - Testing testing = Testing(&game_manager); + Testing testing { game_manager.get_definition_manager() }; std::cout << std::endl << "Testing Loaded" << std::endl << std::endl; testing.execute_all_scripts(); testing.report_results(); -- cgit v1.2.3-56-ga3b1