aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/Dataloader.cpp
diff options
context:
space:
mode:
author BrickPi <49528459+BrickPi@users.noreply.github.com>2023-10-04 20:33:23 +0200
committer hop311 <hop3114@gmail.com>2023-12-10 14:57:14 +0100
commitf981159689aaff401a1bb9461fcb37b598730ab5 (patch)
treec6104733641ff03f650fe2b5ecd9f84925e6c719 /src/openvic-simulation/dataloader/Dataloader.cpp
parentabb0804b015d8444542af7a6c5db728c0fde4cfb (diff)
Generic Event Loading
Diffstat (limited to 'src/openvic-simulation/dataloader/Dataloader.cpp')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index c986a78..8c6704b 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -505,6 +505,20 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi
return ret;
}
+bool Dataloader::_load_events(GameManager& game_manager) const {
+ static constexpr std::string_view events_directory = "events";
+ const bool ret = apply_to_files(
+ lookup_files_in_dir(events_directory, ".txt"),
+ [&game_manager](fs::path const& file) -> bool {
+ return game_manager.get_event_manager().load_event_file(
+ game_manager.get_politics_manager().get_issue_manager(), parse_defines(file).get_file_node()
+ );
+ }
+ );
+ game_manager.get_event_manager().lock_events();
+ return ret;
+}
+
bool Dataloader::_load_map_dir(GameManager& game_manager) const {
static constexpr std::string_view map_directory = "map/";
Map& map = game_manager.get_map();
@@ -795,6 +809,10 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load history!");
ret = false;
}
+ if (!_load_events(game_manager)) {
+ Logger::error("Failed to load events!");
+ ret = false;
+ }
return ret;
}