aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
author zaaarf <80046572+zaaarf@users.noreply.github.com>2023-12-10 21:22:55 +0100
committer GitHub <noreply@github.com>2023-12-10 21:22:55 +0100
commit1eb28bd4fb959b69a30013f6438f0257a2ee7b03 (patch)
tree911563514c661e9bdb5bad1e2c38f200ce4b5428 /src/openvic-simulation/dataloader
parentba390fec5a923f7c4b4ab7f85e803eb50bbf9e3a (diff)
parent13ffc9a12725b9dbcd3b957c74471356540ee716 (diff)
Merge pull request #90 from OpenVicProject/dataloading-decisions
Decision dataloading (kind of)
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp20
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.hpp1
2 files changed, 21 insertions, 0 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 8c6704b..f49ae2d 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -428,6 +428,22 @@ bool Dataloader::_load_inventions(GameManager& game_manager) const {
return ret;
}
+bool Dataloader::_load_decisions(GameManager& game_manager) const {
+ static constexpr std::string_view decisions_directory = "decisions";
+ DecisionManager& decision_manager = game_manager.get_decision_manager();
+
+ bool ret = apply_to_files(
+ lookup_files_in_dir(decisions_directory, ".txt"),
+ [&decision_manager](fs::path const& file) -> bool {
+ return decision_manager.load_decision_file(parse_defines(file).get_file_node());
+ }
+ );
+
+ decision_manager.lock_decisions();
+
+ return ret;
+}
+
bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_file_warnings) const {
/* Country History */
@@ -805,6 +821,10 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load countries!");
ret = false;
}
+ if (!_load_decisions(game_manager)) {
+ Logger::error("Failde to load decisions!");
+ ret = false;
+ }
if (!_load_history(game_manager, false)) {
Logger::error("Failed to load history!");
ret = false;
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp
index 884588a..78021b3 100644
--- a/src/openvic-simulation/dataloader/Dataloader.hpp
+++ b/src/openvic-simulation/dataloader/Dataloader.hpp
@@ -32,6 +32,7 @@ namespace OpenVic {
bool _load_inventions(GameManager& game_manager) const;
bool _load_events(GameManager& game_manager) const;
bool _load_map_dir(GameManager& game_manager) const;
+ bool _load_decisions(GameManager& game_manager) const;
bool _load_history(GameManager& game_manager, bool unused_history_file_warnings) const;
/* _DirIterator is fs::directory_iterator or fs::recursive_directory_iterator. _UniqueKey is the type of a callable