aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/military
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-01-08 23:19:39 +0100
committer hop311 <hop3114@gmail.com>2024-01-08 23:19:39 +0100
commit83802dfead4938e6f98b4b9961b286e06ab78b18 (patch)
treeb0b404a1826d455767b16d3e3ae1d6bf7516e06d /src/openvic-simulation/military
parent79b8b73304753fedab822e6aa859fa15673f52cc (diff)
Added map_callback and expect_item_dictionary_reserve_length
Diffstat (limited to 'src/openvic-simulation/military')
-rw-r--r--src/openvic-simulation/military/Wargoal.cpp13
1 files changed, 9 insertions, 4 deletions
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.");