aboutsummaryrefslogtreecommitdiff
path: root/src/headless/main.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-06-13 18:59:47 +0200
committer GitHub <noreply@github.com>2024-06-13 18:59:47 +0200
commitbfd539513af435564daf70f94f6cce146dd5c948 (patch)
tree7ba5a06714c267185dd3a59aabc6556a105c122f /src/headless/main.cpp
parent01a8f60aaca9784d814f4cb35a3fc4be86e1dd20 (diff)
parent4b39e77304094708d5c503b6a221386408cc4409 (diff)
Merge pull request #165 from OpenVicProject/instance-definition-managers
Separated GameManager into Definition and Instance Managers
Diffstat (limited to 'src/headless/main.cpp')
-rw-r--r--src/headless/main.cpp36
1 files changed, 8 insertions, 28 deletions
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 <cstring>
-#include <openvic-simulation/GameManager.hpp>
#include <openvic-simulation/dataloader/Dataloader.hpp>
+#include <openvic-simulation/GameManager.hpp>
#include <openvic-simulation/testing/Testing.hpp>
#include <openvic-simulation/utility/Logger.hpp>
@@ -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();