diff options
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 15 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.cpp | 6 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 27 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/Vic2PathSearch.cpp | 2 |
4 files changed, 42 insertions, 8 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index 1be040f..2b438c7 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -683,7 +683,7 @@ bool Dataloader::_load_map_dir(DefinitionManager& definition_manager) const { static constexpr std::string_view default_provinces = "provinces.bmp"; static constexpr std::string_view default_positions = "positions.txt"; static constexpr std::string_view default_terrain = "terrain.bmp"; - static constexpr std::string_view default_rivers = "rivers.bmp"; // TODO - load rivers into map pixel data + static constexpr std::string_view default_rivers = "rivers.bmp"; static constexpr std::string_view default_terrain_definition = "terrain.txt"; static constexpr std::string_view default_tree_definition = "trees.txt"; /* Tree textures and density values (unused). */ static constexpr std::string_view default_continent = "continent.txt"; @@ -778,10 +778,15 @@ bool Dataloader::_load_map_dir(DefinitionManager& definition_manager) const { Logger::error("Failed to load terrain types!"); ret = false; } + if (!map_definition.get_terrain_type_manager().generate_modifiers(definition_manager.get_modifier_manager())) { + Logger::error("Failed to generate terrain-based modifiers!"); + ret = false; + } if (!map_definition.load_map_images( lookup_file(append_string_views(map_directory, provinces)), - lookup_file(append_string_views(map_directory, terrain)), false + lookup_file(append_string_views(map_directory, terrain)), + lookup_file(append_string_views(map_directory, rivers)), false )) { Logger::error("Failed to load map images!"); ret = false; @@ -963,11 +968,12 @@ bool Dataloader::load_defines(DefinitionManager& definition_manager) { Logger::error("Failed to load rebel types!"); ret = false; } + definition_manager.get_modifier_manager().lock_all_modifier_except_base_country_effects(); if (!_load_technologies(definition_manager)) { Logger::error("Failed to load technologies!"); ret = false; } - definition_manager.get_modifier_manager().lock_modifier_effects(); + definition_manager.get_modifier_manager().lock_base_country_modifier_effects(); if (!definition_manager.get_politics_manager().get_rule_manager().setup_rules( definition_manager.get_economy_manager().get_building_type_manager() )) { @@ -1007,6 +1013,7 @@ bool Dataloader::load_defines(DefinitionManager& definition_manager) { Logger::error("Failed to load crime modifiers!"); ret = false; } + if (!definition_manager.get_modifier_manager().load_event_modifiers( parse_defines(lookup_file(event_modifiers_file)).get_file_node() )) { @@ -1019,6 +1026,8 @@ bool Dataloader::load_defines(DefinitionManager& definition_manager) { Logger::error("Failed to load static modifiers!"); ret = false; } + definition_manager.get_modifier_manager().lock_event_modifiers(); + if (!definition_manager.get_modifier_manager().load_triggered_modifiers( parse_defines_cached(lookup_file(triggered_modifiers_file)).get_file_node() )) { diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp index ad130ad..b7b3e34 100644 --- a/src/openvic-simulation/dataloader/NodeTools.cpp +++ b/src/openvic-simulation/dataloader/NodeTools.cpp @@ -234,19 +234,19 @@ node_callback_t NodeTools::expect_date_identifier_or_string(callback_t<Date> cal } node_callback_t NodeTools::expect_years(callback_t<Timespan> callback) { - return expect_uint<Timespan::day_t>([callback](Timespan::day_t val) -> bool { + return expect_int<Timespan::day_t>([callback](Timespan::day_t val) -> bool { return callback(Timespan::from_years(val)); }); } node_callback_t NodeTools::expect_months(callback_t<Timespan> callback) { - return expect_uint<Timespan::day_t>([callback](Timespan::day_t val) -> bool { + return expect_int<Timespan::day_t>([callback](Timespan::day_t val) -> bool { return callback(Timespan::from_months(val)); }); } node_callback_t NodeTools::expect_days(callback_t<Timespan> callback) { - return expect_uint<Timespan::day_t>([callback](Timespan::day_t val) -> bool { + return expect_int<Timespan::day_t>([callback](Timespan::day_t val) -> bool { return callback(Timespan::from_days(val)); }); } diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index 51e3e82..43c5092 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -287,11 +287,14 @@ namespace OpenVic { ret &= add_key_map_entries(FWD(key_map), FWD(args)...); return ret; } + template<IsOrderedMap Map> NodeCallback auto expect_dictionary_key_map_and_length_and_default( Map&& key_map, LengthCallback auto&& length_callback, KeyValueCallback auto&& default_callback ) { - return [length_callback = FWD(length_callback), default_callback = FWD(default_callback), key_map = MOV(key_map)](ast::NodeCPtr node) mutable -> bool { + return [length_callback = FWD(length_callback), default_callback = FWD(default_callback), key_map = MOV(key_map)]( + ast::NodeCPtr node + ) mutable -> bool { bool ret = expect_dictionary_and_length( FWD(length_callback), dictionary_keys_callback(key_map, FWD(default_callback)) )(node); @@ -335,6 +338,28 @@ namespace OpenVic { return expect_dictionary_key_map_and_length_and_default(FWD(key_map), FWD(length_callback), FWD(default_callback)); } + template<IsOrderedMap Map, typename... Args> + NodeCallback auto expect_dictionary_key_map_and_length( + Map&& key_map, LengthCallback auto&& length_callback, Args&&... args + ) { + add_key_map_entries(FWD(key_map), FWD(args)...); + return expect_dictionary_key_map_and_length(FWD(key_map), FWD(length_callback)); + } + + template<IsOrderedMap Map, typename... Args> + NodeCallback auto expect_dictionary_key_map_and_default( + Map&& key_map, KeyValueCallback auto&& default_callback, Args&&... args + ) { + add_key_map_entries(FWD(key_map), FWD(args)...); + return expect_dictionary_key_map_and_default(FWD(key_map), FWD(default_callback)); + } + + template<IsOrderedMap Map, typename... Args> + NodeCallback auto expect_dictionary_key_map(Map&& key_map, Args&&... args) { + add_key_map_entries(FWD(key_map), FWD(args)...); + return expect_dictionary_key_map(FWD(key_map)); + } + template<StringMapCase Case = StringMapCaseSensitive, typename... Args> NodeCallback auto expect_dictionary_keys_and_length_and_default( LengthCallback auto&& length_callback, KeyValueCallback auto&& default_callback, Args&&... args diff --git a/src/openvic-simulation/dataloader/Vic2PathSearch.cpp b/src/openvic-simulation/dataloader/Vic2PathSearch.cpp index a23d0ce..a1a125d 100644 --- a/src/openvic-simulation/dataloader/Vic2PathSearch.cpp +++ b/src/openvic-simulation/dataloader/Vic2PathSearch.cpp @@ -206,7 +206,7 @@ static fs::path _search_for_game_path(fs::path hint_path = {}) { } return empty_fail_result_callback("Could not parse VDF at '", current_path, "'."); } - std::optional current_node = *(parser.get_key_values()); + std::optional current_node = *parser.get_key_values(); // check "libraryfolders" list auto it = current_node.value().find("libraryfolders"); |