From 83802dfead4938e6f98b4b9961b286e06ab78b18 Mon Sep 17 00:00:00 2001 From: hop311 Date: Mon, 8 Jan 2024 22:19:39 +0000 Subject: Added map_callback and expect_item_dictionary_reserve_length --- src/openvic-simulation/military/Wargoal.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/openvic-simulation/military/Wargoal.cpp') diff --git a/src/openvic-simulation/military/Wargoal.cpp b/src/openvic-simulation/military/Wargoal.cpp index 174cd09..6351ce3 100644 --- a/src/openvic-simulation/military/Wargoal.cpp +++ b/src/openvic-simulation/military/Wargoal.cpp @@ -122,10 +122,15 @@ bool WargoalTypeManager::load_wargoal_file(ast::NodeCPtr root) { }; const decltype(peace_modifier_map)::const_iterator it = peace_modifier_map.find(key); if (it != peace_modifier_map.end()) { - return expect_fixed_point([&modifiers, peace_modifier = it->second](fixed_point_t val) -> bool { - modifiers[peace_modifier] = val; - return true; - })(value); + return expect_fixed_point( + [&modifiers, &identifier, &key, peace_modifier = it->second](fixed_point_t val) -> bool { + if (modifiers.emplace(peace_modifier, val).second) { + return true; + } + Logger::error("Duplicate peace modifier ", key, " in wargoal ", identifier, "!"); + return false; + } + )(value); } Logger::error("Modifier ", key, " in wargoal ", identifier, " is invalid."); -- cgit v1.2.3-56-ga3b1