diff options
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 12 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 43 |
2 files changed, 34 insertions, 21 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index 0078ed2..b5a32d3 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -791,12 +791,6 @@ bool Dataloader::load_defines(GameManager& game_manager) { Logger::error("Failed to load graphical culture types!"); ret = false; } - if (!game_manager.get_pop_manager().get_culture_manager().load_culture_file( - parse_defines(lookup_file(culture_file)).get_file_node() - )) { - Logger::error("Failed to load cultures!"); - ret = false; - } if (!game_manager.get_pop_manager().get_religion_manager().load_religion_file( parse_defines(lookup_file(religion_file)).get_file_node() )) { @@ -928,6 +922,12 @@ bool Dataloader::load_defines(GameManager& game_manager) { Logger::error("Failed to load countries!"); ret = false; } + if (!game_manager.get_pop_manager().get_culture_manager().load_culture_file( + game_manager.get_country_manager(), parse_defines(lookup_file(culture_file)).get_file_node() + )) { + Logger::error("Failed to load cultures!"); + ret = false; + } if (!_load_decisions(game_manager)) { Logger::error("Failde to load decisions!"); ret = false; diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index b3fce16..4b33c6d 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -356,33 +356,46 @@ namespace OpenVic { }; } + template<typename... Args> + bool warn_or_error(bool warn, Args... args) { + if (warn) { + Logger::warning(args...); + return true; + } else { + Logger::error(args...); + return false; + } + } + template<typename T, typename U, typename...SetArgs> - Callback<T> auto set_callback(tsl::ordered_set<U, SetArgs...>& set) { - return [&set](T val) -> bool { - if (!set.emplace(std::move(val)).second) { - Logger::warning("Duplicate set entry: \"", val, "\""); + Callback<T> auto set_callback(tsl::ordered_set<U, SetArgs...>& set, bool warn = false) { + return [&set, warn](T val) -> bool { + if (set.emplace(std::move(val)).second) { + return true; } - return true; + return warn_or_error(warn, "Duplicate set entry: \"", val, "\""); }; } template<std::derived_from<HasIdentifier> T, typename...SetArgs> - Callback<T const&> auto set_callback_pointer(tsl::ordered_set<T const*, SetArgs...>& set) { - return [&set](T const& val) -> bool { - if (!set.emplace(&val).second) { - Logger::warning("Duplicate set entry: \"", &val, "\""); + Callback<T const&> auto set_callback_pointer(tsl::ordered_set<T const*, SetArgs...>& set, bool warn = false) { + return [&set, warn](T const& val) -> bool { + if (set.emplace(&val).second) { + return true; } - return true; + return warn_or_error(warn, "Duplicate set entry: \"", &val, "\""); }; } template<std::derived_from<HasIdentifier> Key, typename Value, typename... MapArgs> - Callback<Value> auto map_callback(tsl::ordered_map<Key const*, Value, MapArgs...>& map, Key const* key) { - return [&map, key](Value value) -> bool { - if (!map.emplace(key, std::move(value)).second) { - Logger::warning("Duplicate map entry with key: \"", key, "\""); + Callback<Value> auto map_callback( + tsl::ordered_map<Key const*, Value, MapArgs...>& map, Key const* key, bool warn = false + ) { + return [&map, key, warn](Value value) -> bool { + if (map.emplace(key, std::move(value)).second) { + return true; } - return true; + return warn_or_error(warn, "Duplicate map entry with key: \"", key, "\""); }; } } |