diff options
author | zaaarf <me@zaaarf.foo> | 2023-12-10 21:16:53 +0100 |
---|---|---|
committer | zaaarf <me@zaaarf.foo> | 2023-12-10 21:16:53 +0100 |
commit | 13ffc9a12725b9dbcd3b957c74471356540ee716 (patch) | |
tree | 911563514c661e9bdb5bad1e2c38f200ce4b5428 /src/openvic-simulation/dataloader | |
parent | ba390fec5a923f7c4b4ab7f85e803eb50bbf9e3a (diff) |
feat: decision dataloading
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 20 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.hpp | 1 |
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 |