aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-12-10 20:16:49 +0100
committer GitHub <noreply@github.com>2023-12-10 20:16:49 +0100
commitba390fec5a923f7c4b4ab7f85e803eb50bbf9e3a (patch)
treebb0b9f3d43f105753a9b23800b1068e181079581 /src/openvic-simulation/dataloader
parentc422a344b618e89458c98759207067bada4ec542 (diff)
parentf981159689aaff401a1bb9461fcb37b598730ab5 (diff)
Merge pull request #45 from OpenVicProject/event-loading
Skeleton Event Loading
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp18
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.hpp4
2 files changed, 20 insertions, 2 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;
}
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp
index e98d220..884588a 100644
--- a/src/openvic-simulation/dataloader/Dataloader.hpp
+++ b/src/openvic-simulation/dataloader/Dataloader.hpp
@@ -13,9 +13,8 @@ namespace OpenVic {
class UIManager;
struct PopManager;
struct UnitManager;
- struct ModifierManager;
- struct TechnologyManager;
struct GoodManager;
+ struct EventManager;
class Dataloader {
public:
@@ -31,6 +30,7 @@ namespace OpenVic {
bool _load_rebel_types(GameManager& game_manager) const;
bool _load_technologies(GameManager& game_manager) const;
bool _load_inventions(GameManager& game_manager) const;
+ bool _load_events(GameManager& game_manager) const;
bool _load_map_dir(GameManager& game_manager) const;
bool _load_history(GameManager& game_manager, bool unused_history_file_warnings) const;