aboutsummaryrefslogtreecommitdiff
path: root/src/headless
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-08-24 01:32:23 +0200
committer Hop311 <hop3114@gmail.com>2023-08-24 01:32:23 +0200
commitefa88c722fcb6c8fea7a86e1b3b8a83f1f59eb31 (patch)
tree0d64199bf4f19fabaaff083b35aa8625823d6c1e /src/headless
parent6f4a6c77c6f2613e65a403c3a2964d5041a538c7 (diff)
Big Dataloader Commit (openvic-simulation)
Diffstat (limited to 'src/headless')
-rw-r--r--src/headless/main.cpp64
1 files changed, 49 insertions, 15 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp
index 70a57a9..69e1e67 100644
--- a/src/headless/main.cpp
+++ b/src/headless/main.cpp
@@ -1,22 +1,56 @@
-#ifdef OPENVIC_HEADLESS_SIM
-#include <iostream>
-#include <string>
-#include "openvic/Simulation.hpp"
-#include "openvic/dataloader/Dataloader.hpp"
+#ifdef OPENVIC_SIM_HEADLESS
+#include <openvic/utility/Logger.hpp>
+#include <openvic/GameManager.hpp>
+#include <openvic/dataloader/Dataloader.hpp>
-int main() {
- std::cout << "HEADLESS SIMULATION" << std::endl;
+using namespace OpenVic;
+static char const* get_program_name(char const* name) {
+ static char const* const missing_name = "<program>";
+ if (name == nullptr) return missing_name;
+ char const* last_separator = name;
+ while (*name != '\0') {
+ if (*name == '/' || *name == '\\') {
+ last_separator = name + 1;
+ }
+ ++name;
+ }
+ if (*last_separator == '\0') return missing_name;
+ return last_separator;
+}
+
+int main(int argc, char const* argv[]) {
+ if (argc < 2) {
+ std::cout << "Usage: " << get_program_name(argc > 0 ? argv[0] : nullptr) << " <base defines dir> [[mod defines dir]+]" << std::endl;
+ std::cout << "Requires defines path(s) as arguments, starting with the base defines and continuing with mods (paths with spaces need to be enclosed in \"quotes\")." << std::endl;
+ return -1;
+ }
+
+ std::cout << "!!! HEADLESS SIMULATION START !!!" << std::endl;
- std::string vic2FolderLocation = "";
- if (vic2FolderLocation.length() <= 0) {
- std::cout << "Path to Victoria 2 folder not specified. Manually specify location: ";
- std::cin >> vic2FolderLocation;
+ Logger::set_info_func([](std::string&& str) { std::cout << str; });
+ Logger::set_error_func([](std::string&& str) { std::cerr << str; });
+
+ GameManager game_manager { []() {
+ Logger::info("State updated");
+ } };
+ Dataloader dataloader;
+
+ std::vector<std::filesystem::path> roots;
+ for (int i = 1; i < argc; ++i) {
+ roots.push_back(argv[i]);
+ }
+ dataloader.set_roots(roots);
+
+ if (dataloader.load_defines(game_manager) != SUCCESS) {
+ Logger::error("Failed to load defines!");
+ }
+ if (game_manager.load_hardcoded_defines() != SUCCESS) {
+ Logger::error("Failed to load hardcoded defines!");
}
- std::filesystem::path path(vic2FolderLocation);
- OpenVic::Simulation sim;
- std::cout << (OpenVic::Dataloader::loadDir(path, sim) ? "Dataloader suceeded" : "Dataloader failed") << std::endl;
+ std::cout << "!!! HEADLESS SIMULATION END !!!" << std::endl;
+ return 0;
}
-#endif \ No newline at end of file
+#endif