Project Alice
Loading...
Searching...
No Matches
effect_parsing.hpp
Go to the documentation of this file.
1#pragma once
2#include "parsers.hpp"
4#include "trigger_parsing.hpp"
5#include "text.hpp"
6
7namespace economy {
8dcon::modifier_id get_province_selector_modifier(sys::state& state);
9dcon::modifier_id get_province_immigrator_modifier(sys::state& state);
10}
11
12namespace parsers {
13
16 std::vector<uint16_t> compiled_effect;
17 size_t limit_position = 0;
18 bool effect_is_for_event = false;
19
23
27
28 void add_float_to_payload(float f) {
29 union {
30 struct {
31 uint16_t low;
32 uint16_t high;
33 } v;
34 float f;
35 } pack_float;
36 pack_float.f = f;
37
38 compiled_effect.push_back(pack_float.v.low);
39 compiled_effect.push_back(pack_float.v.high);
40 }
41
42 void add_int32_t_to_payload(int32_t i) {
43 union {
44 struct {
45 uint16_t low;
46 uint16_t high;
47 } v;
48 int32_t i;
49 } pack_int;
50 pack_int.i = i;
51
52 compiled_effect.push_back(pack_int.v.low);
53 compiled_effect.push_back(pack_int.v.high);
54 }
55};
56
58 dcon::culture_id culture_;
59 dcon::religion_id religion_;
60 dcon::ideology_id ideology_;
61 dcon::rebel_type_id type_;
62 void culture(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
63 if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
64 it != context.outer_context.map_of_culture_names.end()) {
65 culture_ = it->second;
66 } else {
68 "Invalid culture " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
69 }
70 }
71 void religion(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
72 if(auto it = context.outer_context.map_of_religion_names.find(std::string(value));
73 it != context.outer_context.map_of_religion_names.end()) {
74 religion_ = it->second;
75 } else {
77 "Invalid religion " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
78 }
79 }
80 void ideology(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
81 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
82 it != context.outer_context.map_of_ideologies.end()) {
83 ideology_ = it->second.id;
84 } else {
86 "Invalid ideology " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
87 }
88 }
89 void type(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
90 if(auto it = context.outer_context.map_of_rebeltypes.find(std::string(value));
91 it != context.outer_context.map_of_rebeltypes.end()) {
92 type_ = it->second.id;
93 } else {
95 "Invalid rebel type " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
96 }
97 }
99};
100
102 std::string_view who;
103 int32_t value = 0;
105};
107 std::string_view who;
108 int32_t value = 0;
110};
112 dcon::modifier_id name_;
113 int32_t duration = 0;
114 void name(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
115 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
116 it != context.outer_context.map_of_modifiers.end()) {
117 name_ = it->second;
118 } else {
119 err.accumulated_errors +=
120 "Invalid modifier " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
121 }
122 }
124};
126 dcon::modifier_id name_;
127 int32_t duration = 0;
128 void name(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
129 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
130 it != context.outer_context.map_of_modifiers.end()) {
131 name_ = it->second;
132 } else {
133 err.accumulated_errors +=
134 "Invalid modifier " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
135 }
136 }
138};
140 dcon::cb_type_id type_;
141 std::string_view target;
142 int32_t months = 0;
143 void type(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
144 if(auto it = context.outer_context.map_of_cb_types.find(std::string(value));
145 it != context.outer_context.map_of_cb_types.end()) {
146 type_ = it->second.id;
147 } else {
148 err.accumulated_errors +=
149 "Invalid cb type " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
150 }
151 }
153};
155 dcon::cb_type_id type_;
156 std::string_view target;
157 int32_t months = 0;
158 void type(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
159 if(auto it = context.outer_context.map_of_cb_types.find(std::string(value));
160 it != context.outer_context.map_of_cb_types.end()) {
161 type_ = it->second.id;
162 } else {
163 err.accumulated_errors +=
164 "Invalid cb type " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
165 }
166 }
168};
170 dcon::cb_type_id type_;
171 std::string_view target;
172 void type(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
173 if(auto it = context.outer_context.map_of_cb_types.find(std::string(value));
174 it != context.outer_context.map_of_cb_types.end()) {
175 type_ = it->second.id;
176 } else {
177 err.accumulated_errors +=
178 "Invalid cb type " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
179 }
180 }
182};
184 dcon::cb_type_id type_;
185 std::string_view target;
186 void type(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
187 if(auto it = context.outer_context.map_of_cb_types.find(std::string(value));
188 it != context.outer_context.map_of_cb_types.end()) {
189 type_ = it->second.id;
190 } else {
191 err.accumulated_errors +=
192 "Invalid cb type " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
193 }
194 }
196};
198 dcon::cb_type_id casus_belli_;
199 dcon::national_identity_id country_;
202 dcon::province_id state_province_id_;
205
206 void country(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
207 if(is_this(value)) {
209 } else if(is_from(value)) {
211 } else if(value.length() == 3) {
212 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
213 it != context.outer_context.map_of_ident_names.end()) {
214 country_ = it->second;
215 } else {
216 err.accumulated_errors += "wargoal given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
217 return;
218 }
219 } else {
220 err.accumulated_errors += "wargoal given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
221 return;
222 }
223 }
224 void casus_belli(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
225 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "test_end_war")) {
226 special_end_wargoal = true;
227 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "call_allies_cb")) {
229 } else if(auto it = context.outer_context.map_of_cb_types.find(std::string(value)); it != context.outer_context.map_of_cb_types.end()) {
230 casus_belli_ = it->second.id;
231 } else {
232 err.accumulated_errors += "Invalid cb type " + std::string(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
233 }
234 }
235 void state_province_id(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
236 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
238 } else {
239 err.accumulated_errors += "wargoal given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
240 }
241 }
243};
244struct ef_war {
245 bool call_ally = true;
246 std::string_view target;
250};
252 int32_t days = -1;
253 dcon::national_event_id id_;
254 void id(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context);
256};
258 int32_t days = -1;
259 dcon::provincial_event_id id_;
260 void id(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context);
262};
264 std::string_view value;
265 dcon::unit_type_id type_;
266 void type(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
267 if(auto it = context.outer_context.map_of_unit_types.find(std::string(v)); it != context.outer_context.map_of_unit_types.end()) {
268 type_ = it->second;
269 } else {
270 err.accumulated_errors += "Invalid unit type " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
271 }
272 }
274};
276 float value = 0.0f;
277 dcon::national_variable_id which_;
278 void which(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
279 which_ = context.outer_context.get_national_variable(std::string(v));
280 }
282};
284 float value = 0.0f;
285 dcon::national_variable_id which_;
286 void which(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
287 which_ = context.outer_context.get_national_variable(std::string(v));
288 }
290};
292 float factor = 0.0f;
293 dcon::ideology_id value_;
294 void value(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
295 if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
296 value_ = it->second.id;
297 } else {
298 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
299 }
300 }
302};
304 float factor = 0.0f;
305 dcon::issue_option_id value_;
306 void value(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
307 if(auto it = context.outer_context.map_of_ioptions.find(std::string(v)); it != context.outer_context.map_of_ioptions.end()) {
308 value_ = it->second.id;
309 } else {
310 err.accumulated_errors += "Invalid issue option " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
311 }
312 }
314};
316 float value = 0.0f;
317 dcon::ideology_id ideology_;
318 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
319 if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
320 ideology_ = it->second.id;
321 } else {
322 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
323 }
324 }
326};
328 float factor = 0.0f;
329 float unemployment = 0.0f;
330 dcon::ideology_id ideology_;
331 dcon::issue_option_id issue_;
332 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
333 if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
334 ideology_ = it->second.id;
335 } else {
336 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
337 }
338 }
339 void issue(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
340 if(auto it = context.outer_context.map_of_ioptions.find(std::string(v)); it != context.outer_context.map_of_ioptions.end()) {
341 issue_ = it->second.id;
342 } else {
343 err.accumulated_errors += "Invalid issue option " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
344 }
345 }
347};
349 float factor = 0.0f;
350 float unemployment = 0.0f;
351 dcon::ideology_id ideology_;
352 dcon::issue_option_id issue_;
353 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
354 if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
355 ideology_ = it->second.id;
356 } else {
357 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
358 }
359 }
360 void issue(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
361 if(auto it = context.outer_context.map_of_ioptions.find(std::string(v)); it != context.outer_context.map_of_ioptions.end()) {
362 issue_ = it->second.id;
363 } else {
364 err.accumulated_errors += "Invalid issue option " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
365 }
366 }
368};
370 std::string_view name;
371 dcon::leader_trait_id background_;
372 dcon::leader_trait_id personality_;
373 void background(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
374 if(auto it = context.outer_context.map_of_leader_traits.find(std::string(v)); it != context.outer_context.map_of_leader_traits.end()) {
375 background_ = it->second;
376 } else {
377 err.accumulated_errors += "Invalid leader trait " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
378 }
379 }
380 void personality(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
381 if(auto it = context.outer_context.map_of_leader_traits.find(std::string(v)); it != context.outer_context.map_of_leader_traits.end()) {
382 personality_ = it->second;
383 } else {
384 err.accumulated_errors += "Invalid leader trait " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
385 }
386 }
388};
390 std::string_view name;
391 dcon::leader_trait_id background_;
392 dcon::leader_trait_id personality_;
393 void background(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
394 if(auto it = context.outer_context.map_of_leader_traits.find(std::string(v)); it != context.outer_context.map_of_leader_traits.end()) {
395 background_ = it->second;
396 } else {
397 err.accumulated_errors += "Invalid leader trait " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
398 }
399 }
400 void personality(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
401 if(auto it = context.outer_context.map_of_leader_traits.find(std::string(v)); it != context.outer_context.map_of_leader_traits.end()) {
402 personality_ = it->second;
403 } else {
404 err.accumulated_errors += "Invalid leader trait " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
405 }
406 }
408};
410 dcon::cb_type_id casus_belli_;
411 void casus_belli(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
412 if(auto it = context.outer_context.map_of_cb_types.find(std::string(v)); it != context.outer_context.map_of_cb_types.end()) {
413 casus_belli_ = it->second.id;
414 } else {
415 err.accumulated_errors += "Invalid cb type " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
416 }
417 }
419};
421 float value = 0.0f;
422 dcon::issue_option_id from_;
423 dcon::issue_option_id to_;
424 void from(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
425 if(auto it = context.outer_context.map_of_ioptions.find(std::string(v)); it != context.outer_context.map_of_ioptions.end()) {
426 from_ = it->second.id;
427 } else {
428 err.accumulated_errors += "Invalid issue option " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
429 }
430 }
431 void to(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
432 if(auto it = context.outer_context.map_of_ioptions.find(std::string(v)); it != context.outer_context.map_of_ioptions.end()) {
433 to_ = it->second.id;
434 } else {
435 err.accumulated_errors += "Invalid issue option " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
436 }
437 }
439};
441 float loyalty_value = 0.0f;
442 dcon::province_id province_id_;
443 dcon::ideology_id ideology_;
444 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
445 if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
446 ideology_ = it->second.id;
447 } else {
448 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
449 }
450 }
451 void province_id(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
452 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
454 } else {
455 err.accumulated_errors += "party_loyalty given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
456 }
457 }
459};
461 dcon::ideology_id ideology_;
462 dcon::text_key name_;
463 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
464 if(is_fixed_token_ci(v.data(), v.data() + v.length(), "ruling_party")) {
465 // leave invalid
466 } else if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
467 ideology_ = it->second.id;
468 } else {
469 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
470 }
471 }
472 void name(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
473 name_ = text::find_or_add_key(context.outer_context.state, v, false);
474 }
476};
478 dcon::ideology_id ideology_;
479 dcon::issue_option_id opt_;
480 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context) {
481 if(is_fixed_token_ci(v.data(), v.data() + v.length(), "ruling_party")) {
482 // leave invalid
483 } else if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
484 ideology_ = it->second.id;
485 } else {
486 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
487 }
488 }
489 void position(association_type t, std::string_view v, error_handler& err, int32_t line, effect_building_context& context);
491};
496};
501};
506};
511};
512
514 int32_t chances_sum = 0;
515 void any_group(std::string_view label, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
516 chances_sum += value;
517 }
519};
520
522 int32_t chance = 0;
524 void capital(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
526 context.compiled_effect.push_back(uint16_t(effect::capital));
527 } else {
528 err.accumulated_errors +=
529 "capital effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
530 return;
531 }
532 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
534 } else {
535 err.accumulated_errors +=
536 "capital effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
537 context.compiled_effect.push_back(trigger::payload(dcon::province_id()).value);
538 }
539 }
540 void add_core(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
541 if(is_integer(value.data(), value.data() + value.length())) {
543 context.compiled_effect.push_back(uint16_t(effect::add_core_int));
544 auto ivalue = parse_int(value, line, err);
545 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
547 } else {
548 err.accumulated_errors +=
549 "add_core = int effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
550 context.compiled_effect.push_back(trigger::payload(dcon::province_id()).value);
551 }
552 } else {
553 err.accumulated_errors +=
554 "add_core = int effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
555 return;
556 }
557 } else {
559 if(is_reb(value)) {
561 context.compiled_effect.push_back(uint16_t(effect::add_core_reb | effect::no_payload));
562 else {
563 err.accumulated_errors += "add_core = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
564 std::to_string(line) + ")\n";
565 return;
566 }
567 } else if(is_from(value)) {
569 context.compiled_effect.push_back(uint16_t(effect::add_core_from_nation | effect::no_payload));
571 context.compiled_effect.push_back(uint16_t(effect::add_core_from_province | effect::no_payload));
572 else {
573 err.accumulated_errors += "add_core = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
574 std::to_string(line) + ")\n";
575 return;
576 }
577 } else if(is_this(value)) {
579 context.compiled_effect.push_back(uint16_t(effect::add_core_this_nation | effect::no_payload));
581 context.compiled_effect.push_back(uint16_t(effect::add_core_this_province | effect::no_payload));
582 else if(context.this_slot == trigger::slot_contents::state)
583 context.compiled_effect.push_back(uint16_t(effect::add_core_this_state | effect::no_payload));
584 else if(context.this_slot == trigger::slot_contents::pop)
585 context.compiled_effect.push_back(uint16_t(effect::add_core_this_pop | effect::no_payload));
586 else {
587 err.accumulated_errors += "add_core = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
588 std::to_string(line) + ")\n";
589 return;
590 }
591 } else if(value.length() == 3) {
592 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
593 it != context.outer_context.map_of_ident_names.end()) {
594 context.compiled_effect.push_back(uint16_t(effect::add_core_tag));
595 context.compiled_effect.push_back(trigger::payload(it->second).value);
596 } else {
597 err.accumulated_errors +=
598 "add_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
599 return;
600 }
601 } else {
602 err.accumulated_errors +=
603 "add_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
604 return;
605 }
606 } else if(context.main_slot == trigger::slot_contents::state) {
607 if(is_reb(value)) {
609 context.compiled_effect.push_back(uint16_t(effect::add_core_state_reb | effect::no_payload));
610 else {
611 err.accumulated_errors += "add_core = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
612 std::to_string(line) + ")\n";
613 return;
614 }
615 } else if(is_from(value)) {
617 context.compiled_effect.push_back(uint16_t(effect::add_core_state_from_nation | effect::no_payload));
619 context.compiled_effect.push_back(uint16_t(effect::add_core_state_from_province | effect::no_payload));
620 else {
621 err.accumulated_errors += "add_core = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
622 std::to_string(line) + ")\n";
623 return;
624 }
625 } else if(is_this(value)) {
627 context.compiled_effect.push_back(uint16_t(effect::add_core_state_this_nation | effect::no_payload));
629 context.compiled_effect.push_back(uint16_t(effect::add_core_state_this_province | effect::no_payload));
630 else if(context.this_slot == trigger::slot_contents::state)
631 context.compiled_effect.push_back(uint16_t(effect::add_core_state_this_state | effect::no_payload));
632 else if(context.this_slot == trigger::slot_contents::pop)
633 context.compiled_effect.push_back(uint16_t(effect::add_core_state_this_pop | effect::no_payload));
634 else {
635 err.accumulated_errors += "add_core = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
636 std::to_string(line) + ")\n";
637 return;
638 }
639 } else if(value.length() == 3) {
640 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
641 it != context.outer_context.map_of_ident_names.end()) {
642 context.compiled_effect.push_back(uint16_t(effect::add_core_tag_state));
643 context.compiled_effect.push_back(trigger::payload(it->second).value);
644 } else {
645 err.accumulated_errors +=
646 "add_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
647 return;
648 }
649 } else {
650 err.accumulated_errors +=
651 "add_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
652 return;
653 }
654 } else {
655 err.accumulated_errors +=
656 "add_core effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
657 return;
658 }
659 }
660 }
661 void remove_core(association_type t, std::string_view value, error_handler& err, int32_t line,
662 effect_building_context& context) {
663 if(is_integer(value.data(), value.data() + value.length())) {
665 context.compiled_effect.push_back(uint16_t(effect::remove_core_int));
666 auto ivalue = parse_int(value, line, err);
667 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
669 } else {
670 err.accumulated_errors += "remove_core = int effect given an invalid province id (" + err.file_name + ", line " +
671 std::to_string(line) + ")\n";
672 context.compiled_effect.push_back(trigger::payload(dcon::province_id()).value);
673 }
674 } else {
675 err.accumulated_errors += "remove_core = int effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
676 std::to_string(line) + ")\n";
677 return;
678 }
679 } else {
681 if(is_reb(value)) {
683 context.compiled_effect.push_back(uint16_t(effect::remove_core_reb | effect::no_payload));
684 else {
685 err.accumulated_errors += "remove_core = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
686 std::to_string(line) + ")\n";
687 return;
688 }
689 } else if(is_from(value)) {
691 context.compiled_effect.push_back(uint16_t(effect::remove_core_from_nation | effect::no_payload));
693 context.compiled_effect.push_back(uint16_t(effect::remove_core_from_province | effect::no_payload));
694 else {
695 err.accumulated_errors += "remove_core = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
696 std::to_string(line) + ")\n";
697 return;
698 }
699 } else if(is_this(value)) {
701 context.compiled_effect.push_back(uint16_t(effect::remove_core_this_nation | effect::no_payload));
703 context.compiled_effect.push_back(uint16_t(effect::remove_core_this_province | effect::no_payload));
704 else if(context.this_slot == trigger::slot_contents::state)
705 context.compiled_effect.push_back(uint16_t(effect::remove_core_this_state | effect::no_payload));
706 else if(context.this_slot == trigger::slot_contents::pop)
707 context.compiled_effect.push_back(uint16_t(effect::remove_core_this_pop | effect::no_payload));
708 else {
709 err.accumulated_errors += "remove_core = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
710 std::to_string(line) + ")\n";
711 return;
712 }
713 } else if(value.length() == 3) {
714 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
715 it != context.outer_context.map_of_ident_names.end()) {
716 context.compiled_effect.push_back(uint16_t(effect::remove_core_tag));
717 context.compiled_effect.push_back(trigger::payload(it->second).value);
718 } else {
719 err.accumulated_errors +=
720 "remove_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
721 return;
722 }
723 } else {
724 err.accumulated_errors +=
725 "remove_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
726 return;
727 }
728 } else if(context.main_slot == trigger::slot_contents::state) {
729 if(is_reb(value)) {
731 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_reb | effect::no_payload));
732 else {
733 err.accumulated_errors += "remove_core = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
734 std::to_string(line) + ")\n";
735 return;
736 }
737 } else if(is_from(value)) {
739 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_from_nation | effect::no_payload));
741 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_from_province | effect::no_payload));
742 else {
743 err.accumulated_errors += "remove_core = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
744 std::to_string(line) + ")\n";
745 return;
746 }
747 } else if(is_this(value)) {
749 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_this_nation | effect::no_payload));
751 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_this_province | effect::no_payload));
752 else if(context.this_slot == trigger::slot_contents::state)
753 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_this_state | effect::no_payload));
754 else if(context.this_slot == trigger::slot_contents::pop)
755 context.compiled_effect.push_back(uint16_t(effect::remove_core_state_this_pop | effect::no_payload));
756 else {
757 err.accumulated_errors += "remove_core = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
758 std::to_string(line) + ")\n";
759 return;
760 }
761 } else if(value.length() == 3) {
762 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
763 it != context.outer_context.map_of_ident_names.end()) {
764 context.compiled_effect.push_back(uint16_t(effect::remove_core_tag_state));
765 context.compiled_effect.push_back(trigger::payload(it->second).value);
766 } else {
767 err.accumulated_errors +=
768 "remove_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
769 return;
770 }
771 } else {
772 err.accumulated_errors +=
773 "remove_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
774 return;
775 }
776 } else if(context.main_slot == trigger::slot_contents::nation) {
777 if(is_reb(value)) {
779 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_reb | effect::no_payload));
780 else {
781 err.accumulated_errors += "remove_core = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
782 std::to_string(line) + ")\n";
783 return;
784 }
785 } else if(is_from(value)) {
787 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_from_nation | effect::no_payload));
789 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_from_province | effect::no_payload));
790 else {
791 err.accumulated_errors += "remove_core = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
792 std::to_string(line) + ")\n";
793 return;
794 }
795 } else if(is_this(value)) {
797 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_this_nation | effect::no_payload));
799 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_this_province | effect::no_payload));
800 else if(context.this_slot == trigger::slot_contents::state)
801 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_this_state | effect::no_payload));
802 else if(context.this_slot == trigger::slot_contents::pop)
803 context.compiled_effect.push_back(uint16_t(effect::remove_core_nation_this_pop | effect::no_payload));
804 else {
805 err.accumulated_errors += "remove_core = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
806 std::to_string(line) + ")\n";
807 return;
808 }
809 } else if(value.length() == 3) {
810 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
811 it != context.outer_context.map_of_ident_names.end()) {
812 context.compiled_effect.push_back(uint16_t(effect::remove_core_tag_nation));
813 context.compiled_effect.push_back(trigger::payload(it->second).value);
814 } else {
815 err.accumulated_errors +=
816 "remove_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
817 return;
818 }
819 } else {
820 err.accumulated_errors +=
821 "remove_core effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
822 return;
823 }
824 } else {
825 err.accumulated_errors +=
826 "remove_core effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
827 return;
828 }
829 }
830 }
831 void change_region_name(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context);
832 void trade_goods(association_type t, std::string_view value, error_handler& err, int32_t line,
833 effect_building_context& context) {
834 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(value));
835 it != context.outer_context.map_of_commodity_names.end()) {
837 context.compiled_effect.push_back(uint16_t(effect::trade_goods));
838 context.compiled_effect.push_back(trigger::payload(it->second).value);
839 } else {
840 err.accumulated_errors +=
841 "trade_goods effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
842 return;
843 }
844 } else {
845 err.accumulated_errors += "trade_goods effect supplied with invalid commodity name " + std::string(value) + " (" +
846 err.file_name + ", line " + std::to_string(line) + ")\n";
847 return;
848 }
849 }
850 void add_accepted_culture(association_type t, std::string_view value, error_handler& err, int32_t line,
851 effect_building_context& context) {
853 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "union")) {
854 context.compiled_effect.push_back(uint16_t(effect::add_accepted_culture_union | effect::no_payload));
855 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "this_union")) {
856 context.compiled_effect.push_back(uint16_t(effect::add_accepted_culture_union_this | effect::no_payload));
857 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "from_union")) {
858 context.compiled_effect.push_back(uint16_t(effect::add_accepted_culture_union_from | effect::no_payload));
859 } else if(is_this(value)) {
860 context.compiled_effect.push_back(uint16_t(effect::add_accepted_culture_this | effect::no_payload));
861 } else if(is_from(value)) {
862 context.compiled_effect.push_back(uint16_t(effect::add_accepted_culture_from | effect::no_payload));
863 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
864 it != context.outer_context.map_of_culture_names.end()) {
865 context.compiled_effect.push_back(uint16_t(effect::add_accepted_culture));
866 context.compiled_effect.push_back(trigger::payload(it->second).value);
867 } else {
868 err.accumulated_errors += "add_accepted_culture effect supplied with invalid culture name " + std::string(value) + " (" +
869 err.file_name + ", line " + std::to_string(line) + ")\n";
870 return;
871 }
872 } else {
873 err.accumulated_errors += "add_accepted_culture effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
874 std::to_string(line) + ")\n";
875 return;
876 }
877 }
878 void primary_culture(association_type t, std::string_view value, error_handler& err, int32_t line,
879 effect_building_context& context) {
881 if(is_from(value)) {
883 context.compiled_effect.push_back(uint16_t(effect::primary_culture_from_nation | effect::no_payload));
884 else {
885 err.accumulated_errors += "primary_culture = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
886 ", line " + std::to_string(line) + ")\n";
887 return;
888 }
889 } else if(is_this(value)) {
891 context.compiled_effect.push_back(uint16_t(effect::primary_culture_this_nation | effect::no_payload));
892 else if(context.this_slot == trigger::slot_contents::state)
893 context.compiled_effect.push_back(uint16_t(effect::primary_culture_this_state | effect::no_payload));
895 context.compiled_effect.push_back(uint16_t(effect::primary_culture_this_province | effect::no_payload));
896 else if(context.this_slot == trigger::slot_contents::pop)
897 context.compiled_effect.push_back(uint16_t(effect::primary_culture_this_pop | effect::no_payload));
898 else {
899 err.accumulated_errors += "primary_culture = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
900 ", line " + std::to_string(line) + ")\n";
901 return;
902 }
903 } else {
904 if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
905 it != context.outer_context.map_of_culture_names.end()) {
906 context.compiled_effect.push_back(uint16_t(effect::primary_culture));
907 context.compiled_effect.push_back(trigger::payload(it->second).value);
908 } else {
909 err.accumulated_errors += "primary_culture effect supplied with invalid culture name " + std::string(value) + " (" +
910 err.file_name + ", line " + std::to_string(line) + ")\n";
911 }
912 }
913 } else {
914 err.accumulated_errors +=
915 "primary_culture effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
916 return;
917 }
918 }
919 void remove_accepted_culture(association_type t, std::string_view value, error_handler& err, int32_t line,
920 effect_building_context& context) {
922 if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
923 it != context.outer_context.map_of_culture_names.end()) {
924 context.compiled_effect.push_back(uint16_t(effect::remove_accepted_culture));
925 context.compiled_effect.push_back(trigger::payload(it->second).value);
926 } else {
927 err.accumulated_errors += "remove_accepted_culture effect supplied with invalid culture name " + std::string(value) +
928 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
929 return;
930 }
931 } else {
932 err.accumulated_errors += "remove_accepted_culture effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
933 std::to_string(line) + ")\n";
934 return;
935 }
936 }
937 void set_culture(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
939 if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
940 it != context.outer_context.map_of_culture_names.end()) {
941 context.compiled_effect.push_back(uint16_t(effect::set_culture_pop));
942 context.compiled_effect.push_back(trigger::payload(it->second).value);
943 } else {
944 err.accumulated_errors += "remove_accepted_culture effect supplied with invalid culture name " + std::string(value) +
945 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
946 return;
947 }
948 } else {
949 err.accumulated_errors +=
950 "set_culture effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
951 return;
952 }
953 }
954 void life_rating(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
956 context.compiled_effect.push_back(uint16_t(effect::life_rating));
957 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
958 } else if(context.main_slot == trigger::slot_contents::state) {
959 context.compiled_effect.push_back(uint16_t(effect::life_rating_state));
960 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
961 } else {
962 err.accumulated_errors +=
963 "life_rating effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
964 return;
965 }
966 }
967 void religion(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
969 if(auto it = context.outer_context.map_of_religion_names.find(std::string(value));
970 it != context.outer_context.map_of_religion_names.end()) {
971 context.compiled_effect.push_back(uint16_t(effect::religion));
972 context.compiled_effect.push_back(trigger::payload(it->second).value);
973 } else {
974 err.accumulated_errors += "religion effect supplied with invalid religion name " + std::string(value) + " (" +
975 err.file_name + ", line " + std::to_string(line) + ")\n";
976 return;
977 }
978 }
979 else if(context.main_slot == trigger::slot_contents::province) {
980 if(auto it = context.outer_context.map_of_religion_names.find(std::string(value));
981 it != context.outer_context.map_of_religion_names.end()) {
982 context.compiled_effect.push_back(uint16_t(effect::religion_province));
983 context.compiled_effect.push_back(trigger::payload(it->second).value);
984 } else {
985 err.accumulated_errors += "religion effect supplied with invalid religion name " + std::string(value) + " (" +
986 err.file_name + ", line " + std::to_string(line) + ")\n";
987 return;
988 }
989 }
990 else if(context.main_slot == trigger::slot_contents::pop) {
991 if(auto it = context.outer_context.map_of_religion_names.find(std::string(value));
992 it != context.outer_context.map_of_religion_names.end()) {
993 context.compiled_effect.push_back(uint16_t(effect::religion_pop));
994 context.compiled_effect.push_back(trigger::payload(it->second).value);
995 } else {
996 err.accumulated_errors += "religion effect supplied with invalid religion name " + std::string(value) + " (" +
997 err.file_name + ", line " + std::to_string(line) + ")\n";
998 return;
999 }
1000 }
1001 else {
1002 err.accumulated_errors +=
1003 "religion effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1004 return;
1005 }
1006 }
1007 void is_slave(association_type t, bool value, error_handler& err, int32_t line, effect_building_context& context) {
1009 if(value)
1010 context.compiled_effect.push_back(uint16_t(effect::is_slave_state_yes | effect::no_payload));
1011 else
1012 context.compiled_effect.push_back(uint16_t(effect::is_slave_state_no | effect::no_payload));
1013 } else if(context.main_slot == trigger::slot_contents::province) {
1014 if(value)
1015 context.compiled_effect.push_back(uint16_t(effect::is_slave_province_yes | effect::no_payload));
1016 else
1017 context.compiled_effect.push_back(uint16_t(effect::is_slave_province_no | effect::no_payload));
1018 } else if(context.main_slot == trigger::slot_contents::pop) {
1019 if(value)
1020 context.compiled_effect.push_back(uint16_t(effect::is_slave_pop_yes | effect::no_payload));
1021 else
1022 context.compiled_effect.push_back(uint16_t(effect::is_slave_pop_no | effect::no_payload));
1023 } else {
1024 err.accumulated_errors +=
1025 "is_slave effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1026 return;
1027 }
1028 }
1029 void research_points(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1031 context.compiled_effect.push_back(uint16_t(effect::research_points));
1032 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1033 } else {
1034 err.accumulated_errors +=
1035 "research_points effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1036 return;
1037 }
1038 }
1039 void tech_school(association_type t, std::string_view value, error_handler& err, int32_t line,
1040 effect_building_context& context) {
1042 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
1043 it != context.outer_context.map_of_modifiers.end()) {
1044 context.compiled_effect.push_back(uint16_t(effect::tech_school));
1045 context.compiled_effect.push_back(trigger::payload(it->second).value);
1046 } else {
1047 err.accumulated_errors += "tech_school effect supplied with invalid modifier name " + std::string(value) + " (" +
1048 err.file_name + ", line " + std::to_string(line) + ")\n";
1049 return;
1050 }
1051 } else {
1052 err.accumulated_errors +=
1053 "tech_school effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1054 return;
1055 }
1056 }
1057 void government(association_type t, std::string_view value, error_handler& err, int32_t line,
1058 effect_building_context& context) {
1060 if(is_reb(value)) {
1062 context.compiled_effect.push_back(uint16_t(effect::government_reb | effect::no_payload));
1063 else {
1064 err.accumulated_errors += "government = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1065 std::to_string(line) + ")\n";
1066 return;
1067 }
1068 } else if(auto it = context.outer_context.map_of_governments.find(std::string(value));
1069 it != context.outer_context.map_of_governments.end()) {
1070 context.compiled_effect.push_back(uint16_t(effect::government));
1071 context.compiled_effect.push_back(trigger::payload(it->second).value);
1072 } else {
1073 err.accumulated_errors += "government effect supplied with invalid government name " + std::string(value) + " (" +
1074 err.file_name + ", line " + std::to_string(line) + ")\n";
1075 return;
1076 }
1077 } else {
1078 err.accumulated_errors +=
1079 "government effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1080 return;
1081 }
1082 }
1083 void treasury(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
1085 context.compiled_effect.push_back(uint16_t(effect::treasury));
1086 context.add_float_to_payload(value);
1087 } else if(context.main_slot == trigger::slot_contents::province) {
1088 context.compiled_effect.push_back(uint16_t(effect::treasury_province));
1089 context.add_float_to_payload(value);
1090 } else {
1091 err.accumulated_errors +=
1092 "treasury effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1093 return;
1094 }
1095 }
1096 void war_exhaustion(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
1098 context.compiled_effect.push_back(uint16_t(effect::war_exhaustion));
1099 context.add_float_to_payload(value);
1100 } else {
1101 err.accumulated_errors +=
1102 "war_exhaustion effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1103 return;
1104 }
1105 }
1106 void prestige(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
1108 context.compiled_effect.push_back(uint16_t(effect::prestige));
1109 context.add_float_to_payload(value);
1110 } else {
1111 err.accumulated_errors +=
1112 "prestige effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1113 return;
1114 }
1115 }
1116 void change_tag(association_type t, std::string_view value, error_handler& err, int32_t line,
1117 effect_building_context& context) {
1119 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "culture")) {
1120 context.compiled_effect.push_back(uint16_t(effect::change_tag_culture | effect::no_payload));
1121 } else if(value.length() == 3) {
1122 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1123 it != context.outer_context.map_of_ident_names.end()) {
1124 context.compiled_effect.push_back(uint16_t(effect::change_tag));
1125 context.compiled_effect.push_back(trigger::payload(it->second).value);
1126 } else {
1127 err.accumulated_errors +=
1128 "change_tag effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1129 return;
1130 }
1131 } else {
1132 err.accumulated_errors +=
1133 "change_tag effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1134 return;
1135 }
1136
1137 } else {
1138 err.accumulated_errors +=
1139 "change_tag effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1140 return;
1141 }
1142 }
1143 void change_tag_no_core_switch(association_type t, std::string_view value, error_handler& err, int32_t line,
1144 effect_building_context& context) {
1146 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "culture")) {
1147 context.compiled_effect.push_back(uint16_t(effect::change_tag_no_core_switch_culture | effect::no_payload));
1148 } else if(value.length() == 3) {
1149 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1150 it != context.outer_context.map_of_ident_names.end()) {
1151 context.compiled_effect.push_back(uint16_t(effect::change_tag_no_core_switch));
1152 context.compiled_effect.push_back(trigger::payload(it->second).value);
1153 } else {
1154 err.accumulated_errors += "change_tag_no_core_switch effect given an invalid tag (" + err.file_name + ", line " +
1155 std::to_string(line) + ")\n";
1156 return;
1157 }
1158 } else {
1159 err.accumulated_errors +=
1160 "change_tag_no_core_switch effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1161 return;
1162 }
1163
1164 } else {
1165 err.accumulated_errors += "change_tag_no_core_switch effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1166 std::to_string(line) + ")\n";
1167 return;
1168 }
1169 }
1170 void set_country_flag(association_type t, std::string_view value, error_handler& err, int32_t line,
1171 effect_building_context& context) {
1173 context.compiled_effect.push_back(uint16_t(effect::set_country_flag));
1174 context.compiled_effect.push_back(trigger::payload(context.outer_context.get_national_flag(std::string(value))).value);
1175 } else if(context.main_slot == trigger::slot_contents::province) {
1176 context.compiled_effect.push_back(uint16_t(effect::set_country_flag_province));
1177 context.compiled_effect.push_back(trigger::payload(context.outer_context.get_national_flag(std::string(value))).value);
1178 } else if(context.main_slot == trigger::slot_contents::pop) {
1179 context.compiled_effect.push_back(uint16_t(effect::set_country_flag_pop));
1180 context.compiled_effect.push_back(trigger::payload(context.outer_context.get_national_flag(std::string(value))).value);
1181 } else {
1182 err.accumulated_errors +=
1183 "set_country_flag effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1184 return;
1185 }
1186 }
1187 void clr_country_flag(association_type t, std::string_view value, error_handler& err, int32_t line,
1188 effect_building_context& context) {
1190 context.compiled_effect.push_back(uint16_t(effect::clr_country_flag));
1191 context.compiled_effect.push_back(trigger::payload(context.outer_context.get_national_flag(std::string(value))).value);
1192 } else {
1193 err.accumulated_errors +=
1194 "clr_country_flag effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1195 return;
1196 }
1197 }
1198 void country_event(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context);
1199 void province_event(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context);
1200 void military_access(association_type t, std::string_view value, error_handler& err, int32_t line,
1201 effect_building_context& context) {
1203 if(is_this(value)) {
1205 context.compiled_effect.push_back(uint16_t(effect::military_access_this_nation | effect::no_payload));
1207 context.compiled_effect.push_back(uint16_t(effect::military_access_this_province | effect::no_payload));
1208 else {
1209 err.accumulated_errors += "military_access = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1210 ", line " + std::to_string(line) + ")\n";
1211 return;
1212 }
1213 } else if(is_from(value)) {
1215 context.compiled_effect.push_back(uint16_t(effect::military_access_from_nation | effect::no_payload));
1217 context.compiled_effect.push_back(uint16_t(effect::military_access_from_province | effect::no_payload));
1218 else {
1219 err.accumulated_errors += "military_access = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1220 ", line " + std::to_string(line) + ")\n";
1221 return;
1222 }
1223 } else if(value.length() == 3) {
1224 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1225 it != context.outer_context.map_of_ident_names.end()) {
1226 context.compiled_effect.push_back(uint16_t(effect::military_access));
1227 context.compiled_effect.push_back(trigger::payload(it->second).value);
1228 } else {
1229 err.accumulated_errors +=
1230 "military_access effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1231 return;
1232 }
1233 } else {
1234 err.accumulated_errors +=
1235 "military_access effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1236 return;
1237 }
1238
1239 } else {
1240 err.accumulated_errors +=
1241 "military_access effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1242 return;
1243 }
1244 }
1245 void badboy(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
1247 context.compiled_effect.push_back(uint16_t(effect::badboy));
1248 context.add_float_to_payload(value);
1249 } else {
1250 err.accumulated_errors +=
1251 "badboy effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1252 return;
1253 }
1254 }
1255 void secede_province(association_type t, std::string_view value, error_handler& err, int32_t line,
1256 effect_building_context& context) {
1258 if(is_this(value)) {
1260 context.compiled_effect.push_back(uint16_t(effect::secede_province_this_nation | effect::no_payload));
1262 context.compiled_effect.push_back(uint16_t(effect::secede_province_this_province | effect::no_payload));
1263 else if(context.this_slot == trigger::slot_contents::state)
1264 context.compiled_effect.push_back(uint16_t(effect::secede_province_this_state | effect::no_payload));
1265 else if(context.this_slot == trigger::slot_contents::pop)
1266 context.compiled_effect.push_back(uint16_t(effect::secede_province_this_pop | effect::no_payload));
1267 else {
1268 err.accumulated_errors += "secede_province = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1269 return;
1270 }
1271 } else if(is_from(value)) {
1273 context.compiled_effect.push_back(uint16_t(effect::secede_province_from_nation | effect::no_payload));
1275 context.compiled_effect.push_back(uint16_t(effect::secede_province_from_province | effect::no_payload));
1276 else {
1277 err.accumulated_errors += "secede_province = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1278 return;
1279 }
1280 } else if(is_reb(value)) {
1282 context.compiled_effect.push_back(uint16_t(effect::secede_province_reb | effect::no_payload));
1283 else {
1284 err.accumulated_errors += "secede_province = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1285 return;
1286 }
1287 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "---")) {
1288 context.compiled_effect.push_back(uint16_t(effect::annex_to_null_province | effect::no_payload));
1289 return;
1290 } else if(value.length() == 3) {
1291 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1292 it != context.outer_context.map_of_ident_names.end()) {
1293 context.compiled_effect.push_back(uint16_t(effect::secede_province));
1294 context.compiled_effect.push_back(trigger::payload(it->second).value);
1295 } else {
1296 context.compiled_effect.push_back(uint16_t(effect::annex_to_null_province | effect::no_payload));
1297 err.accumulated_warnings += "secede_province effect given an invalid tag '" + std::string(value) + "' will assume null (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1298 return;
1299 }
1300 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "null")) {
1301 context.compiled_effect.push_back(uint16_t(effect::annex_to_null_province | effect::no_payload));
1302 return;
1303 } else {
1304 err.accumulated_errors += "secede_province effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1305 return;
1306 }
1307 } else if(context.main_slot == trigger::slot_contents::state) {
1308 if(is_this(value)) {
1310 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_this_nation | effect::no_payload));
1312 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_this_province | effect::no_payload));
1313 else if(context.this_slot == trigger::slot_contents::state)
1314 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_this_state | effect::no_payload));
1315 else if(context.this_slot == trigger::slot_contents::pop)
1316 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_this_pop | effect::no_payload));
1317 else {
1318 err.accumulated_errors += "secede_province = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1319 return;
1320 }
1321 } else if(is_from(value)) {
1323 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_from_nation | effect::no_payload));
1325 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_from_province | effect::no_payload));
1326 else {
1327 err.accumulated_errors += "secede_province = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1328 return;
1329 }
1330 } else if(is_reb(value)) {
1332 context.compiled_effect.push_back(uint16_t(effect::secede_province_state_reb | effect::no_payload));
1333 else {
1334 err.accumulated_errors += "secede_province = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1335 return;
1336 }
1337 } else if(value.length() == 3) {
1338 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1339 it != context.outer_context.map_of_ident_names.end()) {
1340 context.compiled_effect.push_back(uint16_t(effect::secede_province_state));
1341 context.compiled_effect.push_back(trigger::payload(it->second).value);
1342 } else {
1343 err.accumulated_errors += "secede_province effect given an invalid tag '" + std::string(value) + "' (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1344 return;
1345 }
1346 } else {
1347 err.accumulated_errors += "secede_province effect given an invalid value '" + std::string(value) + "' (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1348 return;
1349 }
1350 } else {
1351 err.accumulated_errors += "secede_province effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1352 return;
1353 }
1354 }
1355 void inherit(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
1357 if(is_this(value)) {
1359 context.compiled_effect.push_back(uint16_t(effect::inherit_this_nation | effect::no_payload));
1361 context.compiled_effect.push_back(uint16_t(effect::inherit_this_province | effect::no_payload));
1362 else if(context.this_slot == trigger::slot_contents::state)
1363 context.compiled_effect.push_back(uint16_t(effect::inherit_this_state | effect::no_payload));
1364 else if(context.this_slot == trigger::slot_contents::pop)
1365 context.compiled_effect.push_back(uint16_t(effect::inherit_this_pop | effect::no_payload));
1366 else {
1367 err.accumulated_errors += "inherit = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1368 std::to_string(line) + ")\n";
1369 return;
1370 }
1371 } else if(is_from(value)) {
1373 context.compiled_effect.push_back(uint16_t(effect::inherit_from_nation | effect::no_payload));
1375 context.compiled_effect.push_back(uint16_t(effect::inherit_from_province | effect::no_payload));
1376 else {
1377 err.accumulated_errors += "inherit = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1378 std::to_string(line) + ")\n";
1379 return;
1380 }
1381 } else if(value.length() == 3) {
1382 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1383 it != context.outer_context.map_of_ident_names.end()) {
1384 context.compiled_effect.push_back(uint16_t(effect::inherit));
1385 context.compiled_effect.push_back(trigger::payload(it->second).value);
1386 } else {
1387 err.accumulated_errors +=
1388 "inherit effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1389 return;
1390 }
1391 } else {
1392 err.accumulated_errors +=
1393 "inherit effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1394 return;
1395 }
1396
1397 } else {
1398 err.accumulated_errors +=
1399 "inherit effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1400 return;
1401 }
1402 }
1403 void annex_to(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
1405 if(is_this(value)) {
1407 context.compiled_effect.push_back(uint16_t(effect::annex_to_this_nation | effect::no_payload));
1409 context.compiled_effect.push_back(uint16_t(effect::annex_to_this_province | effect::no_payload));
1410 else if(context.this_slot == trigger::slot_contents::state)
1411 context.compiled_effect.push_back(uint16_t(effect::annex_to_this_state | effect::no_payload));
1412 else if(context.this_slot == trigger::slot_contents::pop)
1413 context.compiled_effect.push_back(uint16_t(effect::annex_to_this_pop | effect::no_payload));
1414 else {
1415 err.accumulated_errors += "annex_to = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1416 std::to_string(line) + ")\n";
1417 return;
1418 }
1419 } else if(is_from(value)) {
1421 context.compiled_effect.push_back(uint16_t(effect::annex_to_from_nation | effect::no_payload));
1423 context.compiled_effect.push_back(uint16_t(effect::annex_to_from_province | effect::no_payload));
1424 else {
1425 err.accumulated_errors += "annex_to = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1426 std::to_string(line) + ")\n";
1427 return;
1428 }
1429 } else if(value.length() == 3) {
1430 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1431 it != context.outer_context.map_of_ident_names.end()) {
1432 context.compiled_effect.push_back(uint16_t(effect::annex_to));
1433 context.compiled_effect.push_back(trigger::payload(it->second).value);
1434 } else {
1435 err.accumulated_errors +=
1436 "annex_to effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1437 return;
1438 }
1439 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "null")) {
1440 context.compiled_effect.push_back(uint16_t(effect::annex_to_null_nation | effect::no_payload));
1441 return;
1442 } else {
1443 err.accumulated_errors +=
1444 "annex_to effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1445 return;
1446 }
1447 } else if(context.main_slot == trigger::slot_contents::province) {
1448 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "null")) {
1449 context.compiled_effect.push_back(uint16_t(effect::annex_to_null_province | effect::no_payload));
1450 return;
1451 } else {
1452 err.accumulated_errors += "annex_to effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1453 std::to_string(line) + ")\n";
1454 return;
1455 }
1456 } else {
1457 err.accumulated_errors +=
1458 "annex_to effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1459 return;
1460 }
1461 }
1462 void release(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
1464 if(is_this(value)) {
1466 context.compiled_effect.push_back(uint16_t(effect::release_this_nation | effect::no_payload));
1468 context.compiled_effect.push_back(uint16_t(effect::release_this_province | effect::no_payload));
1469 else if(context.this_slot == trigger::slot_contents::state)
1470 context.compiled_effect.push_back(uint16_t(effect::release_this_state | effect::no_payload));
1471 else if(context.this_slot == trigger::slot_contents::pop)
1472 context.compiled_effect.push_back(uint16_t(effect::release_this_pop | effect::no_payload));
1473 else {
1474 err.accumulated_errors += "release = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1475 std::to_string(line) + ")\n";
1476 return;
1477 }
1478 } else if(is_from(value)) {
1480 context.compiled_effect.push_back(uint16_t(effect::release_from_nation | effect::no_payload));
1482 context.compiled_effect.push_back(uint16_t(effect::release_from_province | effect::no_payload));
1483 else {
1484 err.accumulated_errors += "release = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1485 std::to_string(line) + ")\n";
1486 return;
1487 }
1488 } else if(value.length() == 3) {
1489 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1490 it != context.outer_context.map_of_ident_names.end()) {
1491 context.compiled_effect.push_back(uint16_t(effect::release));
1492 context.compiled_effect.push_back(trigger::payload(it->second).value);
1493 } else {
1494 err.accumulated_errors +=
1495 "release effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1496 return;
1497 }
1498 } else {
1499 err.accumulated_errors +=
1500 "release effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1501 return;
1502 }
1503
1504 } else {
1505 err.accumulated_errors +=
1506 "release effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1507 return;
1508 }
1509 }
1510 void change_controller(association_type t, std::string_view value, error_handler& err, int32_t line,
1511 effect_building_context& context) {
1513 if(is_this(value)) {
1515 context.compiled_effect.push_back(uint16_t(effect::change_controller_this_nation | effect::no_payload));
1517 context.compiled_effect.push_back(uint16_t(effect::change_controller_this_province | effect::no_payload));
1518 else {
1519 err.accumulated_errors += "change_controller = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1520 ", line " + std::to_string(line) + ")\n";
1521 return;
1522 }
1523 } else if(is_from(value)) {
1525 context.compiled_effect.push_back(uint16_t(effect::change_controller_from_nation | effect::no_payload));
1527 context.compiled_effect.push_back(uint16_t(effect::change_controller_from_province | effect::no_payload));
1528 else {
1529 err.accumulated_errors += "change_controller = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1530 ", line " + std::to_string(line) + ")\n";
1531 return;
1532 }
1533 } else if(value.length() == 3) {
1534 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1535 it != context.outer_context.map_of_ident_names.end()) {
1536 context.compiled_effect.push_back(uint16_t(effect::change_controller));
1537 context.compiled_effect.push_back(trigger::payload(it->second).value);
1538 } else {
1539 err.accumulated_errors +=
1540 "change_controller effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1541 return;
1542 }
1543 } else {
1544 err.accumulated_errors +=
1545 "change_controller effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1546 return;
1547 }
1548 } else if(context.main_slot == trigger::slot_contents::state) {
1549 if(is_this(value)) {
1551 context.compiled_effect.push_back(uint16_t(effect::change_controller_state_this_nation | effect::no_payload));
1553 context.compiled_effect.push_back(uint16_t(effect::change_controller_state_this_province | effect::no_payload));
1554 else {
1555 err.accumulated_errors += "change_controller = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1556 ", line " + std::to_string(line) + ")\n";
1557 return;
1558 }
1559 } else if(is_from(value)) {
1561 context.compiled_effect.push_back(uint16_t(effect::change_controller_state_from_nation | effect::no_payload));
1563 context.compiled_effect.push_back(uint16_t(effect::change_controller_state_from_province | effect::no_payload));
1564 else {
1565 err.accumulated_errors += "change_controller = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1566 ", line " + std::to_string(line) + ")\n";
1567 return;
1568 }
1569 } else if(value.length() == 3) {
1570 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1571 it != context.outer_context.map_of_ident_names.end()) {
1572 context.compiled_effect.push_back(uint16_t(effect::change_controller_state));
1573 context.compiled_effect.push_back(trigger::payload(it->second).value);
1574 } else {
1575 err.accumulated_errors +=
1576 "change_controller effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1577 return;
1578 }
1579 } else {
1580 err.accumulated_errors +=
1581 "change_controller effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1582 return;
1583 }
1584 } else {
1585 err.accumulated_errors +=
1586 "change_controller effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1587 return;
1588 }
1589 }
1590 void infrastructure(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1592 context.compiled_effect.push_back(uint16_t(effect::infrastructure));
1593 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1594 } else if(context.main_slot == trigger::slot_contents::state) {
1595 context.compiled_effect.push_back(uint16_t(effect::infrastructure_state));
1596 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1597 } else {
1598 err.accumulated_errors +=
1599 "infrastructure effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1600 return;
1601 }
1602 }
1603 void fort(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1605 context.compiled_effect.push_back(uint16_t(effect::fort));
1606 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1607 } else if(context.main_slot == trigger::slot_contents::state) {
1608 context.compiled_effect.push_back(uint16_t(effect::fort_state));
1609 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1610 } else {
1611 err.accumulated_errors +=
1612 "fort effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1613 return;
1614 }
1615 }
1616 void naval_base(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1618 context.compiled_effect.push_back(uint16_t(effect::naval_base));
1619 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1620 } else if(context.main_slot == trigger::slot_contents::state) {
1621 context.compiled_effect.push_back(uint16_t(effect::naval_base_state));
1622 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1623 } else {
1624 err.accumulated_errors +=
1625 "naval_base effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1626 return;
1627 }
1628 }
1629 void bank(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1631 context.compiled_effect.push_back(uint16_t(effect::bank));
1632 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1633 } else if(context.main_slot == trigger::slot_contents::state) {
1634 context.compiled_effect.push_back(uint16_t(effect::bank_state));
1635 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1636 } else {
1637 err.accumulated_errors +=
1638 "bank effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1639 return;
1640 }
1641 }
1642 void university(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1644 context.compiled_effect.push_back(uint16_t(effect::university));
1645 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1646 } else if(context.main_slot == trigger::slot_contents::state) {
1647 context.compiled_effect.push_back(uint16_t(effect::university_state));
1648 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1649 } else {
1650 err.accumulated_errors +=
1651 "university effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1652 return;
1653 }
1654 }
1655 void province_selector(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1657 if(value == 1) {
1658 context.compiled_effect.push_back(uint16_t(effect::add_province_modifier_no_duration));
1660 } else if(value == -1) {
1661 context.compiled_effect.push_back(uint16_t(effect::remove_province_modifier));
1663 } else {
1664 err.accumulated_errors +=
1665 "province_selector effect with invalid value " + std::to_string(value) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1666 }
1667 } else {
1668 err.accumulated_errors +=
1669 "province_selector effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1670 return;
1671 }
1672 }
1673 void province_immigrator(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1675 if(value == 1) {
1676 context.compiled_effect.push_back(uint16_t(effect::add_province_modifier_no_duration));
1678 } else if(value == -1) {
1679 context.compiled_effect.push_back(uint16_t(effect::remove_province_modifier));
1681 } else {
1682 err.accumulated_errors +=
1683 "province_immigrator effect with invalid value " + std::to_string(value) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1684 }
1685 } else {
1686 err.accumulated_errors +=
1687 "province_immigrator effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1688 return;
1689 }
1690 }
1691 void money(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
1693 context.compiled_effect.push_back(uint16_t(effect::treasury));
1694 context.add_float_to_payload(value);
1695 } else if(context.main_slot == trigger::slot_contents::province) {
1696 context.compiled_effect.push_back(uint16_t(effect::treasury_province));
1697 context.add_float_to_payload(value);
1698 } else if(context.main_slot == trigger::slot_contents::pop) {
1699 context.compiled_effect.push_back(uint16_t(effect::money));
1700 context.add_float_to_payload(value);
1701 } else {
1702 err.accumulated_errors +=
1703 "money effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1704 return;
1705 }
1706 }
1707 void leadership(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
1709 context.compiled_effect.push_back(uint16_t(effect::leadership));
1710 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
1711 } else {
1712 err.accumulated_errors +=
1713 "leadership effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1714 return;
1715 }
1716 }
1717 void create_vassal(association_type t, std::string_view value, error_handler& err, int32_t line,
1718 effect_building_context& context) {
1720 if(is_this(value)) {
1722 context.compiled_effect.push_back(uint16_t(effect::create_vassal_this_nation | effect::no_payload));
1724 context.compiled_effect.push_back(uint16_t(effect::create_vassal_this_province | effect::no_payload));
1725 else {
1726 err.accumulated_errors += "create_vassal = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1727 std::to_string(line) + ")\n";
1728 return;
1729 }
1730 } else if(is_from(value)) {
1732 context.compiled_effect.push_back(uint16_t(effect::create_vassal_from_nation | effect::no_payload));
1734 context.compiled_effect.push_back(uint16_t(effect::create_vassal_from_province | effect::no_payload));
1735 else {
1736 err.accumulated_errors += "create_vassal = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1737 std::to_string(line) + ")\n";
1738 return;
1739 }
1740 } else if(value.length() == 3) {
1741 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1742 it != context.outer_context.map_of_ident_names.end()) {
1743 context.compiled_effect.push_back(uint16_t(effect::create_vassal));
1744 context.compiled_effect.push_back(trigger::payload(it->second).value);
1745 } else {
1746 err.accumulated_errors +=
1747 "create_vassal effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1748 return;
1749 }
1750 } else {
1751 err.accumulated_errors +=
1752 "create_vassal effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1753 return;
1754 }
1755
1756 } else {
1757 err.accumulated_errors +=
1758 "create_vassal effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1759 return;
1760 }
1761 }
1762 void end_military_access(association_type t, std::string_view value, error_handler& err, int32_t line,
1763 effect_building_context& context) {
1765 if(is_this(value)) {
1767 context.compiled_effect.push_back(uint16_t(effect::end_military_access_this_nation | effect::no_payload));
1769 context.compiled_effect.push_back(uint16_t(effect::end_military_access_this_province | effect::no_payload));
1770 else {
1771 err.accumulated_errors += "end_military_access = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1772 ", line " + std::to_string(line) + ")\n";
1773 return;
1774 }
1775 } else if(is_from(value)) {
1777 context.compiled_effect.push_back(uint16_t(effect::end_military_access_from_nation | effect::no_payload));
1779 context.compiled_effect.push_back(uint16_t(effect::end_military_access_from_province | effect::no_payload));
1780 else {
1781 err.accumulated_errors += "end_military_access = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1782 ", line " + std::to_string(line) + ")\n";
1783 return;
1784 }
1785 } else if(value.length() == 3) {
1786 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1787 it != context.outer_context.map_of_ident_names.end()) {
1788 context.compiled_effect.push_back(uint16_t(effect::end_military_access));
1789 context.compiled_effect.push_back(trigger::payload(it->second).value);
1790 } else {
1791 err.accumulated_errors +=
1792 "end_military_access effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1793 return;
1794 }
1795 } else {
1796 err.accumulated_errors +=
1797 "end_military_access effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1798 return;
1799 }
1800
1801 } else {
1802 err.accumulated_errors += "end_military_access effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1803 std::to_string(line) + ")\n";
1804 return;
1805 }
1806 }
1807 void leave_alliance(association_type t, std::string_view value, error_handler& err, int32_t line,
1808 effect_building_context& context) {
1810 if(is_this(value)) {
1812 context.compiled_effect.push_back(uint16_t(effect::leave_alliance_this_nation | effect::no_payload));
1814 context.compiled_effect.push_back(uint16_t(effect::leave_alliance_this_province | effect::no_payload));
1815 else {
1816 err.accumulated_errors += "leave_alliance = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1817 std::to_string(line) + ")\n";
1818 return;
1819 }
1820 } else if(is_from(value)) {
1822 context.compiled_effect.push_back(uint16_t(effect::leave_alliance_from_nation | effect::no_payload));
1824 context.compiled_effect.push_back(uint16_t(effect::leave_alliance_from_province | effect::no_payload));
1825 else {
1826 err.accumulated_errors += "leave_alliance = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1827 std::to_string(line) + ")\n";
1828 return;
1829 }
1830 } else if(value.length() == 3) {
1831 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1832 it != context.outer_context.map_of_ident_names.end()) {
1833 context.compiled_effect.push_back(uint16_t(effect::leave_alliance));
1834 context.compiled_effect.push_back(trigger::payload(it->second).value);
1835 } else {
1836 err.accumulated_errors +=
1837 "leave_alliance effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1838 return;
1839 }
1840 } else {
1841 err.accumulated_errors +=
1842 "leave_alliance effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1843 return;
1844 }
1845
1846 } else {
1847 err.accumulated_errors += "end_military_access effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1848 std::to_string(line) + ")\n";
1849 return;
1850 }
1851 }
1852 void end_war(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
1854 if(is_this(value)) {
1856 context.compiled_effect.push_back(uint16_t(effect::end_war_this_nation | effect::no_payload));
1858 context.compiled_effect.push_back(uint16_t(effect::end_war_this_province | effect::no_payload));
1859 else {
1860 err.accumulated_errors += "end_war = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1861 std::to_string(line) + ")\n";
1862 return;
1863 }
1864 } else if(is_from(value)) {
1866 context.compiled_effect.push_back(uint16_t(effect::end_war_from_nation | effect::no_payload));
1868 context.compiled_effect.push_back(uint16_t(effect::end_war_from_province | effect::no_payload));
1869 else {
1870 err.accumulated_errors += "end_war = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1871 std::to_string(line) + ")\n";
1872 return;
1873 }
1874 } else if(value.length() == 3) {
1875 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
1876 it != context.outer_context.map_of_ident_names.end()) {
1877 context.compiled_effect.push_back(uint16_t(effect::end_war));
1878 context.compiled_effect.push_back(trigger::payload(it->second).value);
1879 } else {
1880 err.accumulated_errors +=
1881 "end_war effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1882 return;
1883 }
1884 } else {
1885 err.accumulated_errors +=
1886 "end_war effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1887 return;
1888 }
1889
1890 } else {
1891 err.accumulated_errors +=
1892 "end_war effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1893 return;
1894 }
1895 }
1896 void enable_ideology(association_type t, std::string_view value, error_handler& err, int32_t line,
1897 effect_building_context& context) {
1898 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
1899 it != context.outer_context.map_of_ideologies.end()) {
1900 context.compiled_effect.push_back(uint16_t(effect::enable_ideology));
1901 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
1902 } else {
1903 err.accumulated_errors += "enable_ideology effect supplied with invalid ideology name " + std::string(value) + " (" +
1904 err.file_name + ", line " + std::to_string(line) + ")\n";
1905 return;
1906 }
1907 }
1908 void ruling_party_ideology(association_type t, std::string_view value, error_handler& err, int32_t line,
1909 effect_building_context& context) {
1911 if(is_this(value)) {
1912 context.compiled_effect.push_back(uint16_t(effect::ruling_party_this));
1913 } else if(is_from(value)) {
1914 context.compiled_effect.push_back(uint16_t(effect::ruling_party_from));
1915 } else if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
1916 it != context.outer_context.map_of_ideologies.end()) {
1917 context.compiled_effect.push_back(uint16_t(effect::ruling_party_ideology));
1918 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
1919 } else {
1920 err.accumulated_errors += "ruling_party_ideology effect supplied with invalid ideology name " + std::string(value) +
1921 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1922 return;
1923 }
1924 } else {
1925 err.accumulated_errors += "ruling_party_ideology effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1926 std::to_string(line) + ")\n";
1927 return;
1928 }
1929 }
1930 void plurality(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
1932 context.compiled_effect.push_back(uint16_t(effect::plurality));
1933 context.add_float_to_payload(value);
1934 } else {
1935 err.accumulated_errors +=
1936 "plurality effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1937 return;
1938 }
1939 }
1940 void remove_province_modifier(association_type t, std::string_view value, error_handler& err, int32_t line,
1941 effect_building_context& context) {
1943 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
1944 it != context.outer_context.map_of_modifiers.end()) {
1945 context.compiled_effect.push_back(uint16_t(effect::remove_province_modifier));
1946 context.compiled_effect.push_back(trigger::payload(it->second).value);
1947 } else {
1948 err.accumulated_errors += "remove_province_modifier effect supplied with invalid modifier name " + std::string(value) +
1949 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1950 return;
1951 }
1952 } else if(context.main_slot == trigger::slot_contents::state) {
1953 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
1954 it != context.outer_context.map_of_modifiers.end()) {
1955 context.compiled_effect.push_back(uint16_t(effect::remove_province_modifier_state));
1956 context.compiled_effect.push_back(trigger::payload(it->second).value);
1957 } else {
1958 err.accumulated_errors += "remove_province_modifier effect supplied with invalid modifier name " + std::string(value) +
1959 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1960 return;
1961 }
1962 } else {
1963 err.accumulated_errors += "remove_province_modifier effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1964 std::to_string(line) + ")\n";
1965 return;
1966 }
1967 }
1968 void remove_country_modifier(association_type t, std::string_view value, error_handler& err, int32_t line,
1969 effect_building_context& context) {
1971 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
1972 it != context.outer_context.map_of_modifiers.end()) {
1973 context.compiled_effect.push_back(uint16_t(effect::remove_country_modifier));
1974 context.compiled_effect.push_back(trigger::payload(it->second).value);
1975 } else {
1976 err.accumulated_errors += "remove_country_modifier effect supplied with invalid modifier name " + std::string(value) +
1977 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1978 return;
1979 }
1980 } else {
1981 err.accumulated_errors += "remove_country_modifier effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1982 std::to_string(line) + ")\n";
1983 return;
1984 }
1985 }
1986 void create_alliance(association_type t, std::string_view value, error_handler& err, int32_t line,
1987 effect_building_context& context) {
1989 if(is_this(value)) {
1991 context.compiled_effect.push_back(uint16_t(effect::create_alliance_this_nation | effect::no_payload));
1993 context.compiled_effect.push_back(uint16_t(effect::create_alliance_this_province | effect::no_payload));
1994 else {
1995 err.accumulated_errors += "create_alliance = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
1996 ", line " + std::to_string(line) + ")\n";
1997 return;
1998 }
1999 } else if(is_from(value)) {
2001 context.compiled_effect.push_back(uint16_t(effect::create_alliance_from_nation | effect::no_payload));
2003 context.compiled_effect.push_back(uint16_t(effect::create_alliance_from_province | effect::no_payload));
2004 else {
2005 err.accumulated_errors += "create_alliance = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
2006 ", line " + std::to_string(line) + ")\n";
2007 return;
2008 }
2009 } else if(value.length() == 3) {
2010 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2011 it != context.outer_context.map_of_ident_names.end()) {
2012 context.compiled_effect.push_back(uint16_t(effect::create_alliance));
2013 context.compiled_effect.push_back(trigger::payload(it->second).value);
2014 } else {
2015 err.accumulated_errors +=
2016 "create_alliance effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2017 return;
2018 }
2019 } else {
2020 err.accumulated_errors +=
2021 "create_alliance effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2022 return;
2023 }
2024
2025 } else {
2026 err.accumulated_errors +=
2027 "create_alliance effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2028 return;
2029 }
2030 }
2031 void release_vassal(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
2033 if(is_this(value)) {
2035 context.compiled_effect.push_back(uint16_t(effect::release_vassal_this_nation | effect::no_payload));
2037 context.compiled_effect.push_back(uint16_t(effect::release_vassal_this_province | effect::no_payload));
2038 else {
2039 err.accumulated_errors += "release_vassal = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2040 std::to_string(line) + ")\n";
2041 return;
2042 }
2043 } else if(is_from(value)) {
2045 context.compiled_effect.push_back(uint16_t(effect::release_vassal_from_nation | effect::no_payload));
2047 context.compiled_effect.push_back(uint16_t(effect::release_vassal_from_province | effect::no_payload));
2048 else {
2049 err.accumulated_errors += "release_vassal = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2050 std::to_string(line) + ")\n";
2051 return;
2052 }
2053 } else if(is_reb(value)) {
2055 context.compiled_effect.push_back(uint16_t(effect::release_vassal_reb | effect::no_payload));
2056 else {
2057 err.accumulated_errors += "release_vassal = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2058 std::to_string(line) + ")\n";
2059 return;
2060 }
2061 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "random")) {
2062 context.compiled_effect.push_back(uint16_t(effect::release_vassal_random | effect::no_payload));
2063 } else if(value.length() == 3) {
2064 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2065 it != context.outer_context.map_of_ident_names.end()) {
2066 context.compiled_effect.push_back(uint16_t(effect::release_vassal));
2067 context.compiled_effect.push_back(trigger::payload(it->second).value);
2068 } else {
2069 err.accumulated_errors += "release_vassal effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2070 return;
2071 }
2072 } else {
2073 err.accumulated_errors += "release_vassal effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2074 return;
2075 }
2076 } else if(context.main_slot == trigger::slot_contents::province) {
2077 if(is_this(value)) {
2079 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province_this_nation | effect::no_payload));
2081 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province_this_province | effect::no_payload));
2082 else {
2083 err.accumulated_errors += "release_vassal = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2084 std::to_string(line) + ")\n";
2085 return;
2086 }
2087 } else if(is_from(value)) {
2089 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province_from_nation | effect::no_payload));
2091 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province_from_province | effect::no_payload));
2092 else {
2093 err.accumulated_errors += "release_vassal = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2094 std::to_string(line) + ")\n";
2095 return;
2096 }
2097 } else if(is_reb(value)) {
2099 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province_reb | effect::no_payload));
2100 else {
2101 err.accumulated_errors += "release_vassal = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2102 std::to_string(line) + ")\n";
2103 return;
2104 }
2105 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "random")) {
2106 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province_random | effect::no_payload));
2107 } else if(value.length() == 3) {
2108 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2109 it != context.outer_context.map_of_ident_names.end()) {
2110 context.compiled_effect.push_back(uint16_t(effect::release_vassal_province));
2111 context.compiled_effect.push_back(trigger::payload(it->second).value);
2112 } else {
2113 err.accumulated_errors += "release_vassal effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2114 return;
2115 }
2116 } else {
2117 err.accumulated_errors += "release_vassal effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2118 return;
2119 }
2120 } else {
2121 err.accumulated_errors += "release_vassal effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2122 return;
2123 }
2124 }
2125 void change_province_name(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context);
2126 void enable_canal(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context);
2127 void set_global_flag(association_type t, std::string_view value, error_handler& err, int32_t line,
2128 effect_building_context& context) {
2129 context.compiled_effect.push_back(uint16_t(effect::set_global_flag));
2130 context.compiled_effect.push_back(trigger::payload(context.outer_context.get_global_flag(std::string(value))).value);
2131 }
2132 void clr_global_flag(association_type t, std::string_view value, error_handler& err, int32_t line,
2133 effect_building_context& context) {
2134 context.compiled_effect.push_back(uint16_t(effect::clr_global_flag));
2135 context.compiled_effect.push_back(trigger::payload(context.outer_context.get_global_flag(std::string(value))).value);
2136 }
2137 void nationalvalue(association_type t, std::string_view value, error_handler& err, int32_t line,
2138 effect_building_context& context) {
2139 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
2140 it != context.outer_context.map_of_modifiers.end()) {
2142 context.compiled_effect.push_back(uint16_t(effect::nationalvalue_nation));
2143 context.compiled_effect.push_back(trigger::payload(it->second).value);
2144 } else if(context.main_slot == trigger::slot_contents::province) {
2145 context.compiled_effect.push_back(uint16_t(effect::nationalvalue_province));
2146 context.compiled_effect.push_back(trigger::payload(it->second).value);
2147 } else {
2148 err.accumulated_errors +=
2149 "nationalvalue effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2150 return;
2151 }
2152 } else {
2153 err.accumulated_errors += "nationalvalue effect supplied with invalid modifier name " + std::string(value) + " (" +
2154 err.file_name + ", line " + std::to_string(line) + ")\n";
2155 return;
2156 }
2157 }
2158 void civilized(association_type t, bool value, error_handler& err, int32_t line, effect_building_context& context) {
2160 if(value)
2161 context.compiled_effect.push_back(uint16_t(effect::civilized_yes | effect::no_payload));
2162 else
2163 context.compiled_effect.push_back(uint16_t(effect::civilized_no | effect::no_payload));
2164 } else {
2165 err.accumulated_errors +=
2166 "civilized effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2167 return;
2168 }
2169 }
2170 void election(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
2172 context.compiled_effect.push_back(uint16_t(effect::election | effect::no_payload));
2173 } else {
2174 err.accumulated_errors +=
2175 "election effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2176 return;
2177 }
2178 }
2179 void social_reform(association_type t, std::string_view value, error_handler& err, int32_t line,
2180 effect_building_context& context) {
2181 if(auto it = context.outer_context.map_of_ioptions.find(std::string(value));
2182 it != context.outer_context.map_of_ioptions.end()) {
2184 context.compiled_effect.push_back(uint16_t(effect::social_reform));
2185 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2186 } else if(context.main_slot == trigger::slot_contents::province) {
2187 context.compiled_effect.push_back(uint16_t(effect::social_reform_province));
2188 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2189 } else {
2190 err.accumulated_errors +=
2191 "social_reform effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2192 return;
2193 }
2194 } else {
2195 err.accumulated_errors += "social_reform effect supplied with invalid issue option name " + std::string(value) + " (" +
2196 err.file_name + ", line " + std::to_string(line) + ")\n";
2197 return;
2198 }
2199 }
2200 void political_reform(association_type t, std::string_view value, error_handler& err, int32_t line,
2201 effect_building_context& context) {
2202 if(auto it = context.outer_context.map_of_ioptions.find(std::string(value));
2203 it != context.outer_context.map_of_ioptions.end()) {
2205 context.compiled_effect.push_back(uint16_t(effect::political_reform));
2206 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2207 } else if(context.main_slot == trigger::slot_contents::province) {
2208 context.compiled_effect.push_back(uint16_t(effect::political_reform_province));
2209 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2210 } else {
2211 err.accumulated_errors += "political_reform effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2212 std::to_string(line) + ")\n";
2213 return;
2214 }
2215 } else {
2216 err.accumulated_errors += "political_reform effect supplied with invalid issue option name " + std::string(value) + " (" +
2217 err.file_name + ", line " + std::to_string(line) + ")\n";
2218 return;
2219 }
2220 }
2221 void add_tax_relative_income(association_type t, float value, error_handler& err, int32_t line,
2222 effect_building_context& context) {
2224 context.compiled_effect.push_back(uint16_t(effect::add_tax_relative_income));
2225 context.add_float_to_payload(value);
2226 } else {
2227 err.accumulated_errors += "add_tax_relative_income effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2228 std::to_string(line) + ")\n";
2229 return;
2230 }
2231 }
2232 void neutrality(association_type t, std::string_view value, error_handler& err, int32_t line,
2233 effect_building_context& context) {
2235 context.compiled_effect.push_back(uint16_t(effect::neutrality | effect::no_payload));
2236 } else {
2237 err.accumulated_errors +=
2238 "neutrality effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2239 return;
2240 }
2241 }
2242 void reduce_pop(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2243 if(value < 0.f) {
2245 "reduce_pop effect with a negative value (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2246 }
2247 value = std::max(0.0f, value);
2248 if(context.main_slot == trigger::slot_contents::pop) {
2249 context.compiled_effect.push_back(uint16_t(effect::reduce_pop));
2250 context.add_float_to_payload(value);
2251 } else if(context.main_slot == trigger::slot_contents::nation) {
2252 context.compiled_effect.push_back(uint16_t(effect::reduce_pop_nation));
2253 context.add_float_to_payload(value);
2254 } else if(context.main_slot == trigger::slot_contents::province) {
2255 context.compiled_effect.push_back(uint16_t(effect::reduce_pop_province));
2256 context.add_float_to_payload(value);
2257 } else if(context.main_slot == trigger::slot_contents::state) {
2258 context.compiled_effect.push_back(uint16_t(effect::reduce_pop_state));
2259 context.add_float_to_payload(value);
2260 } else {
2261 err.accumulated_errors +=
2262 "reduce_pop effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2263 return;
2264 }
2265 }
2266 void reduce_pop_abs(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
2267 if(context.main_slot == trigger::slot_contents::pop) {
2268 context.compiled_effect.push_back(uint16_t(effect::reduce_pop_abs));
2269 context.add_int32_t_to_payload(value);
2270 } else {
2271 err.accumulated_errors +=
2272 "reduce_pop effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2273 return;
2274 }
2275 }
2276 void move_pop(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
2277 if(context.main_slot == trigger::slot_contents::pop) {
2278 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
2279 context.compiled_effect.push_back(uint16_t(effect::move_pop));
2281 } else {
2282 err.accumulated_errors +=
2283 "move_pop effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2284 return;
2285 }
2286 } else {
2287 err.accumulated_errors +=
2288 "move_pop effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2289 return;
2290 }
2291 }
2292 void pop_type(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
2293 if(auto it = context.outer_context.map_of_poptypes.find(std::string(value));
2294 it != context.outer_context.map_of_poptypes.end()) {
2295 if(context.main_slot == trigger::slot_contents::pop) {
2296 context.compiled_effect.push_back(uint16_t(effect::pop_type));
2297 context.compiled_effect.push_back(trigger::payload(it->second).value);
2298 } else {
2299 err.accumulated_errors +=
2300 "pop_type effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2301 return;
2302 }
2303 } else {
2304 err.accumulated_errors += "pop_type effect supplied with invalid pop type " + std::string(value) + " (" + err.file_name +
2305 ", line " + std::to_string(line) + ")\n";
2306 return;
2307 }
2308 }
2309 void years_of_research(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2311 context.compiled_effect.push_back(uint16_t(effect::years_of_research));
2312 context.add_float_to_payload(value);
2313 } else {
2314 err.accumulated_errors +=
2315 "years_of_research effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2316 return;
2317 }
2318 }
2319 void prestige_factor(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2321 if(value >= 0.0f)
2322 context.compiled_effect.push_back(uint16_t(effect::prestige_factor_positive));
2323 else
2324 context.compiled_effect.push_back(uint16_t(effect::prestige_factor_negative));
2325 context.add_float_to_payload(value);
2326 } else {
2327 err.accumulated_errors +=
2328 "prestige_factor effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2329 return;
2330 }
2331 }
2332 void military_reform(association_type t, std::string_view value, error_handler& err, int32_t line,
2333 effect_building_context& context) {
2334 if(auto it = context.outer_context.map_of_roptions.find(std::string(value));
2335 it != context.outer_context.map_of_roptions.end()) {
2337 context.compiled_effect.push_back(uint16_t(effect::military_reform));
2338 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2339 } else {
2340 err.accumulated_errors +=
2341 "military_reform effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2342 return;
2343 }
2344 } else {
2345 err.accumulated_errors += "military_reform effect supplied with invalid issue option name " + std::string(value) + " (" +
2346 err.file_name + ", line " + std::to_string(line) + ")\n";
2347 return;
2348 }
2349 }
2350 void economic_reform(association_type t, std::string_view value, error_handler& err, int32_t line,
2351 effect_building_context& context) {
2352 if(auto it = context.outer_context.map_of_roptions.find(std::string(value));
2353 it != context.outer_context.map_of_roptions.end()) {
2355 context.compiled_effect.push_back(uint16_t(effect::economic_reform));
2356 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2357 } else {
2358 err.accumulated_errors +=
2359 "economic_reform effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2360 return;
2361 }
2362 } else {
2363 err.accumulated_errors += "economic_reform effect supplied with invalid issue option name " + std::string(value) + " (" +
2364 err.file_name + ", line " + std::to_string(line) + ")\n";
2365 return;
2366 }
2367 }
2368 void remove_random_military_reforms(association_type t, int32_t value, error_handler& err, int32_t line,
2369 effect_building_context& context) {
2371 context.compiled_effect.push_back(uint16_t(effect::remove_random_military_reforms));
2372 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
2373 } else {
2374 err.accumulated_errors += "remove_random_military_reforms effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
2375 ", line " + std::to_string(line) + ")\n";
2376 return;
2377 }
2378 }
2379 void remove_random_economic_reforms(association_type t, int32_t value, error_handler& err, int32_t line,
2380 effect_building_context& context) {
2382 context.compiled_effect.push_back(uint16_t(effect::remove_random_economic_reforms));
2383 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
2384 } else {
2385 err.accumulated_errors += "remove_random_economic_reforms effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
2386 ", line " + std::to_string(line) + ")\n";
2387 return;
2388 }
2389 }
2390 void add_crime(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
2391 if(auto it = context.outer_context.map_of_crimes.find(std::string(value)); it != context.outer_context.map_of_crimes.end()) {
2393 context.compiled_effect.push_back(uint16_t(effect::add_crime));
2394 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2395 } else {
2396 err.accumulated_errors +=
2397 "add_crime effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2398 return;
2399 }
2400 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "none")) {
2401 context.compiled_effect.push_back(uint16_t(effect::add_crime_none) | effect::no_payload);
2402 } else {
2403 err.accumulated_errors += "add_crime effect supplied with invalid modifier name " + std::string(value) + " (" +
2404 err.file_name + ", line " + std::to_string(line) + ")\n";
2405 return;
2406 }
2407 }
2408 void nationalize(association_type t, std::string_view value, error_handler& err, int32_t line,
2409 effect_building_context& context) {
2411 context.compiled_effect.push_back(uint16_t(effect::nationalize | effect::no_payload));
2412 } else {
2413 err.accumulated_errors +=
2414 "nationalize effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2415 return;
2416 }
2417 }
2418 void build_factory_in_capital_state(association_type t, std::string_view value, error_handler& err, int32_t line,
2419 effect_building_context& context) {
2420 if(auto it = context.outer_context.map_of_factory_names.find(std::string(value));
2421 it != context.outer_context.map_of_factory_names.end()) {
2423 context.compiled_effect.push_back(uint16_t(effect::build_factory_in_capital_state));
2424 context.compiled_effect.push_back(trigger::payload(it->second).value);
2425 } else {
2426 err.accumulated_errors += "build_factory_in_capital_state effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
2427 ", line " + std::to_string(line) + ")\n";
2428 return;
2429 }
2430 } else {
2431 err.accumulated_errors += "build_factory_in_capital_state effect supplied with invalid factory name " + std::string(value) +
2432 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2433 return;
2434 }
2435 }
2436 void activate_technology(association_type t, std::string_view value, error_handler& err, int32_t line,
2437 effect_building_context& context) {
2438 if(auto it = context.outer_context.map_of_technologies.find(std::string(value));
2439 it != context.outer_context.map_of_technologies.end()) {
2441 context.compiled_effect.push_back(uint16_t(effect::activate_technology));
2442 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
2443 } else {
2444 err.accumulated_errors += "activate_technology effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2445 std::to_string(line) + ")\n";
2446 return;
2447 }
2448 } else if(auto itb = context.outer_context.map_of_inventions.find(std::string(value));
2449 itb != context.outer_context.map_of_inventions.end()) {
2451 context.compiled_effect.push_back(uint16_t(effect::activate_invention));
2452 context.compiled_effect.push_back(trigger::payload(itb->second.id).value);
2453 } else {
2454 err.accumulated_errors += "activate_technology effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2455 std::to_string(line) + ")\n";
2456 return;
2457 }
2458 } else {
2459 err.accumulated_errors += "activate_technology effect supplied with invalid technology/invention name " +
2460 std::string(value) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2461 return;
2462 }
2463 }
2464 void great_wars_enabled(association_type t, bool value, error_handler& err, int32_t line, effect_building_context& context) {
2465 if(value)
2466 context.compiled_effect.push_back(uint16_t(effect::great_wars_enabled_yes | effect::no_payload));
2467 else
2468 context.compiled_effect.push_back(uint16_t(effect::great_wars_enabled_no | effect::no_payload));
2469 }
2470 void world_wars_enabled(association_type t, bool value, error_handler& err, int32_t line, effect_building_context& context) {
2471 if(value)
2472 context.compiled_effect.push_back(uint16_t(effect::world_wars_enabled_yes | effect::no_payload));
2473 else
2474 context.compiled_effect.push_back(uint16_t(effect::world_wars_enabled_no | effect::no_payload));
2475 }
2476 void assimilate(association_type t, std::string_view value, error_handler& err, int32_t line,
2477 effect_building_context& context) {
2479 context.compiled_effect.push_back(uint16_t(effect::assimilate_province | effect::no_payload));
2480 } else if(context.main_slot == trigger::slot_contents::pop) {
2481 context.compiled_effect.push_back(uint16_t(effect::assimilate_pop | effect::no_payload));
2482 } else if(context.main_slot == trigger::slot_contents::state) {
2483 context.compiled_effect.push_back(uint16_t(effect::assimilate_state | effect::no_payload));
2484 } else {
2485 err.accumulated_errors +=
2486 "assimilate effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2487 return;
2488 }
2489 }
2490 void literacy(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2491 if(context.main_slot == trigger::slot_contents::pop) {
2492 context.compiled_effect.push_back(uint16_t(effect::literacy));
2493 context.add_float_to_payload(value);
2494 } else {
2495 err.accumulated_errors +=
2496 "literacy effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2497 return;
2498 }
2499 }
2500 void add_crisis_interest(association_type t, std::string_view value, error_handler& err, int32_t line,
2501 effect_building_context& context) {
2503 context.compiled_effect.push_back(uint16_t(effect::add_crisis_interest | effect::no_payload));
2504 } else {
2505 err.accumulated_errors += "add_crisis_interest effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2506 std::to_string(line) + ")\n";
2507 return;
2508 }
2509 }
2510 void flashpoint_tension(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2512 context.compiled_effect.push_back(uint16_t(effect::flashpoint_tension));
2513 context.add_float_to_payload(value);
2514 } else if(context.main_slot == trigger::slot_contents::province) {
2515 context.compiled_effect.push_back(uint16_t(effect::flashpoint_tension_province));
2516 context.add_float_to_payload(value);
2517 } else {
2518 err.accumulated_errors += "flashpoint_tension effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2519 std::to_string(line) + ")\n";
2520 return;
2521 }
2522 }
2523 void add_crisis_temperature(association_type t, float value, error_handler& err, int32_t line,
2524 effect_building_context& context) {
2525 context.compiled_effect.push_back(uint16_t(effect::add_crisis_temperature));
2526 context.add_float_to_payload(value);
2527 }
2528 void consciousness(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2529 if(context.main_slot == trigger::slot_contents::pop) {
2530 context.compiled_effect.push_back(uint16_t(effect::consciousness));
2531 context.add_float_to_payload(value);
2532 } else if(context.main_slot == trigger::slot_contents::province) {
2533 context.compiled_effect.push_back(uint16_t(effect::consciousness_province));
2534 context.add_float_to_payload(value);
2535 } else if(context.main_slot == trigger::slot_contents::state) {
2536 context.compiled_effect.push_back(uint16_t(effect::consciousness_state));
2537 context.add_float_to_payload(value);
2538 } else if(context.main_slot == trigger::slot_contents::nation) {
2539 context.compiled_effect.push_back(uint16_t(effect::consciousness_nation));
2540 context.add_float_to_payload(value);
2541 } else {
2542 err.accumulated_errors +=
2543 "consciousness effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2544 return;
2545 }
2546 }
2547 void militancy(association_type t, float value, error_handler& err, int32_t line, effect_building_context& context) {
2548 if(context.main_slot == trigger::slot_contents::pop) {
2549 context.compiled_effect.push_back(uint16_t(effect::militancy));
2550 context.add_float_to_payload(value);
2551 } else if(context.main_slot == trigger::slot_contents::province) {
2552 context.compiled_effect.push_back(uint16_t(effect::militancy_province));
2553 context.add_float_to_payload(value);
2554 } else if(context.main_slot == trigger::slot_contents::state) {
2555 context.compiled_effect.push_back(uint16_t(effect::militancy_state));
2556 context.add_float_to_payload(value);
2557 } else if(context.main_slot == trigger::slot_contents::nation) {
2558 context.compiled_effect.push_back(uint16_t(effect::militancy_nation));
2559 context.add_float_to_payload(value);
2560 } else {
2561 err.accumulated_errors +=
2562 "militancy effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2563 return;
2564 }
2565 }
2566 void rgo_size(association_type t, int32_t value, error_handler& err, int32_t line, effect_building_context& context) {
2568 context.compiled_effect.push_back(uint16_t(effect::rgo_size));
2569 context.compiled_effect.push_back(trigger::payload(int16_t(value)).value);
2570 } else {
2571 err.accumulated_errors +=
2572 "rgo_size effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2573 return;
2574 }
2575 }
2576 void add_province_modifier(association_type t, std::string_view value, error_handler& err, int32_t line,
2577 effect_building_context& context) {
2579 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
2580 it != context.outer_context.map_of_modifiers.end()) {
2581 context.compiled_effect.push_back(uint16_t(effect::add_province_modifier_no_duration));
2582 context.compiled_effect.push_back(trigger::payload(it->second).value);
2583 } else {
2584 err.accumulated_errors += "add_province_modifier effect supplied with invalid modifier name " + std::string(value) +
2585 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2586 return;
2587 }
2588 } else if(context.main_slot == trigger::slot_contents::state) {
2589 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
2590 it != context.outer_context.map_of_modifiers.end()) {
2591 context.compiled_effect.push_back(uint16_t(effect::add_province_modifier_state_no_duration));
2592 context.compiled_effect.push_back(trigger::payload(it->second).value);
2593 } else {
2594 err.accumulated_errors += "add_province_modifier effect supplied with invalid modifier name " + std::string(value) +
2595 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2596 return;
2597 }
2598 } else {
2599 err.accumulated_errors += "add_province_modifier effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2600 std::to_string(line) + ")\n";
2601 return;
2602 }
2603 }
2604 void add_country_modifier(association_type t, std::string_view value, error_handler& err, int32_t line,
2605 effect_building_context& context) {
2607 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
2608 it != context.outer_context.map_of_modifiers.end()) {
2609 context.compiled_effect.push_back(uint16_t(effect::add_country_modifier_no_duration));
2610 context.compiled_effect.push_back(trigger::payload(it->second).value);
2611 } else {
2612 err.accumulated_errors += "add_country_modifier effect supplied with invalid modifier name " + std::string(value) + " (" +
2613 err.file_name + ", line " + std::to_string(line) + ")\n";
2614 return;
2615 }
2616 } else {
2617 err.accumulated_errors += "add_country_modifier effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2618 std::to_string(line) + ")\n";
2619 return;
2620 }
2621 }
2622 void trigger_revolt(ef_trigger_revolt const& value, error_handler& err, int32_t line, effect_building_context& context) {
2623 if(!value.type_) {
2624 err.accumulated_errors +=
2625 "trigger_revolt must have a valid rebel type (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2626 return;
2627 }
2629 context.compiled_effect.push_back(effect::trigger_revolt_nation);
2630 else if(context.main_slot == trigger::slot_contents::state)
2631 context.compiled_effect.push_back(effect::trigger_revolt_state);
2633 context.compiled_effect.push_back(effect::trigger_revolt_province);
2634 else {
2635 err.accumulated_errors +=
2636 "trigger_revolt effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2637 return;
2638 }
2639 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2640 context.compiled_effect.push_back(trigger::payload(value.culture_).value);
2641 context.compiled_effect.push_back(trigger::payload(value.religion_).value);
2642 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
2643 }
2644 void diplomatic_influence(ef_diplomatic_influence const& value, error_handler& err, int32_t line,
2645 effect_building_context& context) {
2647 err.accumulated_errors += "diplomatic_influence effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2648 std::to_string(line) + ")\n";
2649 return;
2650 }
2651 if(is_from(value.who)) {
2655 context.compiled_effect.push_back(uint16_t(2 + 2));
2656 auto payload_size_offset = context.compiled_effect.size() - 1;
2657 context.compiled_effect.push_back(trigger::payload(dcon::trigger_key()).value);
2658 }
2659 context.compiled_effect.push_back(effect::diplomatic_influence_from_nation);
2660 } else if(context.from_slot == trigger::slot_contents::province) {
2663 context.compiled_effect.push_back(uint16_t(2 + 2));
2664 auto payload_size_offset = context.compiled_effect.size() - 1;
2665 context.compiled_effect.push_back(trigger::payload(dcon::trigger_key()).value);
2666 }
2667 context.compiled_effect.push_back(effect::diplomatic_influence_from_province);
2668 } else {
2669 err.accumulated_errors += "diplomatic_influence = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
2670 ", line " + std::to_string(line) + ")\n";
2671 return;
2672 }
2673 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2674 } else if(is_this(value.who)) {
2678 context.compiled_effect.push_back(uint16_t(2 + 2));
2679 auto payload_size_offset = context.compiled_effect.size() - 1;
2680 context.compiled_effect.push_back(trigger::payload(dcon::trigger_key()).value);
2681 }
2682 context.compiled_effect.push_back(effect::diplomatic_influence_this_nation);
2683 } else if(context.this_slot == trigger::slot_contents::province) {
2686 context.compiled_effect.push_back(uint16_t(2 + 2));
2687 auto payload_size_offset = context.compiled_effect.size() - 1;
2688 context.compiled_effect.push_back(trigger::payload(dcon::trigger_key()).value);
2689 }
2690 context.compiled_effect.push_back(effect::diplomatic_influence_this_province);
2691 } else {
2692 err.accumulated_errors += "diplomatic_influence = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
2693 ", line " + std::to_string(line) + ")\n";
2694 return;
2695 }
2696 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2697 } else if(value.who.length() == 3) {
2698
2699 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
2700 it != context.outer_context.map_of_ident_names.end()) {
2701
2704 context.compiled_effect.push_back(uint16_t(2 + 3));
2705 auto payload_size_offset = context.compiled_effect.size() - 1;
2706 context.compiled_effect.push_back(trigger::payload(dcon::trigger_key()).value);
2707 }
2708
2709 context.compiled_effect.push_back(uint16_t(effect::diplomatic_influence));
2710 context.compiled_effect.push_back(trigger::payload(it->second).value);
2711 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2712 } else {
2713 err.accumulated_errors +=
2714 "diplomatic_influence effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2715 return;
2716 }
2717 } else {
2718 err.accumulated_errors +=
2719 "diplomatic_influence effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2720 return;
2721 }
2722 }
2723 void relation(ef_relation const& value, error_handler& err, int32_t line, effect_building_context& context) {
2725 if(is_from(value.who)) {
2727 context.compiled_effect.push_back(effect::relation_from_nation);
2729 context.compiled_effect.push_back(effect::relation_from_province);
2730 else {
2731 err.accumulated_errors += "relation = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2732 std::to_string(line) + ")\n";
2733 return;
2734 }
2735 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2736 } else if(is_this(value.who)) {
2738 context.compiled_effect.push_back(effect::relation_this_nation);
2740 context.compiled_effect.push_back(effect::relation_this_province);
2741 else {
2742 err.accumulated_errors += "relation = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2743 std::to_string(line) + ")\n";
2744 return;
2745 }
2746 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2747 } else if(is_reb(value.who)) {
2749 context.compiled_effect.push_back(effect::relation_reb);
2750 else {
2751 err.accumulated_errors += "relation = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2752 std::to_string(line) + ")\n";
2753 return;
2754 }
2755 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2756 } else if(value.who.length() == 3) {
2757 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
2758 it != context.outer_context.map_of_ident_names.end()) {
2759 context.compiled_effect.push_back(uint16_t(effect::relation));
2760 context.compiled_effect.push_back(trigger::payload(it->second).value);
2761 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2762 } else {
2763 err.accumulated_errors +=
2764 "relation effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2765 return;
2766 }
2767 } else {
2768 err.accumulated_errors +=
2769 "relation effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2770 return;
2771 }
2772 } else if(context.main_slot == trigger::slot_contents::province) {
2773 if(is_from(value.who)) {
2775 context.compiled_effect.push_back(effect::relation_province_from_nation);
2777 context.compiled_effect.push_back(effect::relation_province_from_province);
2778 else {
2779 err.accumulated_errors += "relation = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2780 std::to_string(line) + ")\n";
2781 return;
2782 }
2783 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2784 } else if(is_this(value.who)) {
2786 context.compiled_effect.push_back(effect::relation_province_this_nation);
2788 context.compiled_effect.push_back(effect::relation_province_this_province);
2789 else {
2790 err.accumulated_errors += "relation = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2791 std::to_string(line) + ")\n";
2792 return;
2793 }
2794 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2795 } else if(is_reb(value.who)) {
2797 context.compiled_effect.push_back(effect::relation_province_reb);
2798 else {
2799 err.accumulated_errors += "relation = reb effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2800 std::to_string(line) + ")\n";
2801 return;
2802 }
2803 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2804 } else if(value.who.length() == 3) {
2805 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
2806 it != context.outer_context.map_of_ident_names.end()) {
2807 context.compiled_effect.push_back(uint16_t(effect::relation_province));
2808 context.compiled_effect.push_back(trigger::payload(it->second).value);
2809 context.compiled_effect.push_back(trigger::payload(int16_t(value.value)).value);
2810 } else {
2811 err.accumulated_errors +=
2812 "relation effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2813 return;
2814 }
2815 } else {
2816 err.accumulated_errors +=
2817 "relation effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2818 return;
2819 }
2820 } else {
2821 err.accumulated_errors +=
2822 "relation effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2823 return;
2824 }
2825 }
2826 void add_province_modifier(ef_add_province_modifier const& value, error_handler& err, int32_t line,
2827 effect_building_context& context) {
2829 if(value.duration <= 0) {
2830 context.compiled_effect.push_back(effect::add_province_modifier_no_duration);
2831 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2832 } else {
2833 context.compiled_effect.push_back(effect::add_province_modifier);
2834 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2835 context.compiled_effect.push_back(trigger::payload(int16_t(value.duration)).value);
2836 }
2837 } else if(context.main_slot == trigger::slot_contents::state) {
2838 if(value.duration <= 0) {
2839 context.compiled_effect.push_back(effect::add_province_modifier_state_no_duration);
2840 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2841 } else {
2842 context.compiled_effect.push_back(effect::add_province_modifier_state);
2843 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2844 context.compiled_effect.push_back(trigger::payload(int16_t(value.duration)).value);
2845 }
2846 } else {
2847 err.accumulated_errors += "add_province_modifier effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2848 return;
2849 }
2850 }
2851 void add_country_modifier(ef_add_country_modifier const& value, error_handler& err, int32_t line,
2852 effect_building_context& context) {
2854 if(value.duration <= 0) {
2855 context.compiled_effect.push_back(effect::add_country_modifier_province_no_duration);
2856 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2857 } else {
2858 context.compiled_effect.push_back(effect::add_country_modifier_province);
2859 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2860 context.compiled_effect.push_back(trigger::payload(int16_t(value.duration)).value);
2861 }
2862 } else if(context.main_slot == trigger::slot_contents::nation) {
2863 if(value.duration <= 0) {
2864 context.compiled_effect.push_back(effect::add_country_modifier_no_duration);
2865 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2866 } else {
2867 context.compiled_effect.push_back(effect::add_country_modifier);
2868 context.compiled_effect.push_back(trigger::payload(value.name_).value);
2869 context.compiled_effect.push_back(trigger::payload(int16_t(value.duration)).value);
2870 }
2871 } else {
2872 err.accumulated_errors += "add_country_modifier effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2873 std::to_string(line) + ")\n";
2874 return;
2875 }
2876 }
2877 void casus_belli(ef_casus_belli const& value, error_handler& err, int32_t line, effect_building_context& context) {
2879 err.accumulated_errors +=
2880 "casus_belli effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2881 return;
2882 }
2883 if(is_from(value.target)) {
2885 context.compiled_effect.push_back(effect::casus_belli_from_nation);
2887 context.compiled_effect.push_back(effect::casus_belli_from_province);
2888 else {
2889 err.accumulated_errors += "casus_belli = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2890 std::to_string(line) + ")\n";
2891 return;
2892 }
2893 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2894 context.compiled_effect.push_back(uint16_t(value.months));
2895 } else if(is_this(value.target)) {
2897 context.compiled_effect.push_back(effect::casus_belli_this_nation);
2899 context.compiled_effect.push_back(effect::casus_belli_this_province);
2900 else if(context.this_slot == trigger::slot_contents::state)
2901 context.compiled_effect.push_back(effect::casus_belli_this_state);
2902 else if(context.this_slot == trigger::slot_contents::pop)
2903 context.compiled_effect.push_back(effect::casus_belli_this_pop);
2904 else {
2905 err.accumulated_errors += "casus_belli = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2906 std::to_string(line) + ")\n";
2907 return;
2908 }
2909 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2910 context.compiled_effect.push_back(uint16_t(value.months));
2911 } else if(is_integer(value.target.data(), value.target.data() + value.target.length())) {
2912 auto ivalue = parse_int(value.target, line, err);
2913 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
2914 context.compiled_effect.push_back(effect::casus_belli_int);
2915 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2916 context.compiled_effect.push_back(uint16_t(value.months));
2918 } else {
2919 err.accumulated_errors +=
2920 "casus_belli effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2921 return;
2922 }
2923 } else if(value.target.length() == 3) {
2924 if(auto it = context.outer_context.map_of_ident_names.find(
2925 nations::tag_to_int(value.target[0], value.target[1], value.target[2]));
2926 it != context.outer_context.map_of_ident_names.end()) {
2927 context.compiled_effect.push_back(uint16_t(effect::casus_belli_tag));
2928 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2929 context.compiled_effect.push_back(uint16_t(value.months));
2930 context.compiled_effect.push_back(trigger::payload(it->second).value);
2931 } else {
2932 err.accumulated_errors +=
2933 "casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2934 return;
2935 }
2936 } else {
2937 err.accumulated_errors +=
2938 "casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2939 return;
2940 }
2941 }
2942 void add_casus_belli(ef_add_casus_belli const& value, error_handler& err, int32_t line, effect_building_context& context) {
2944 err.accumulated_errors +=
2945 "add_casus_belli effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2946 return;
2947 }
2948 if(is_from(value.target)) {
2950 context.compiled_effect.push_back(effect::add_casus_belli_from_nation);
2952 context.compiled_effect.push_back(effect::add_casus_belli_from_province);
2953 else {
2954 err.accumulated_errors += "add_casus_belli = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2955 std::to_string(line) + ")\n";
2956 return;
2957 }
2958 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2959 context.compiled_effect.push_back(uint16_t(value.months));
2960 } else if(is_this(value.target)) {
2962 context.compiled_effect.push_back(effect::add_casus_belli_this_nation);
2964 context.compiled_effect.push_back(effect::add_casus_belli_this_province);
2965 else if(context.this_slot == trigger::slot_contents::state)
2966 context.compiled_effect.push_back(effect::add_casus_belli_this_state);
2967 else if(context.this_slot == trigger::slot_contents::pop)
2968 context.compiled_effect.push_back(effect::add_casus_belli_this_pop);
2969 else {
2970 err.accumulated_errors += "add_casus_belli = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2971 std::to_string(line) + ")\n";
2972 return;
2973 }
2974 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2975 context.compiled_effect.push_back(uint16_t(value.months));
2976 } else if(is_integer(value.target.data(), value.target.data() + value.target.length())) {
2977 auto ivalue = parse_int(value.target, line, err);
2978 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
2979 context.compiled_effect.push_back(effect::add_casus_belli_int);
2980 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2981 context.compiled_effect.push_back(uint16_t(value.months));
2983 } else {
2984 err.accumulated_errors +=
2985 "add_casus_belli effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2986 return;
2987 }
2988 } else if(value.target.length() == 3) {
2989 if(auto it = context.outer_context.map_of_ident_names.find(
2990 nations::tag_to_int(value.target[0], value.target[1], value.target[2]));
2991 it != context.outer_context.map_of_ident_names.end()) {
2992 context.compiled_effect.push_back(uint16_t(effect::add_casus_belli_tag));
2993 context.compiled_effect.push_back(trigger::payload(value.type_).value);
2994 context.compiled_effect.push_back(uint16_t(value.months));
2995 context.compiled_effect.push_back(trigger::payload(it->second).value);
2996 } else {
2997 err.accumulated_errors +=
2998 "add_casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2999 return;
3000 }
3001 } else {
3002 err.accumulated_errors +=
3003 "add_casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3004 return;
3005 }
3006 }
3007 void remove_casus_belli(ef_remove_casus_belli const& value, error_handler& err, int32_t line,
3008 effect_building_context& context) {
3010 err.accumulated_errors += "remove_casus_belli effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3011 std::to_string(line) + ")\n";
3012 return;
3013 }
3014 if(is_from(value.target)) {
3016 context.compiled_effect.push_back(effect::remove_casus_belli_from_nation);
3018 context.compiled_effect.push_back(effect::remove_casus_belli_from_province);
3019 else {
3020 err.accumulated_errors += "remove_casus_belli = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
3021 ", line " + std::to_string(line) + ")\n";
3022 return;
3023 }
3024 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3025 } else if(is_this(value.target)) {
3027 context.compiled_effect.push_back(effect::remove_casus_belli_this_nation);
3029 context.compiled_effect.push_back(effect::remove_casus_belli_this_province);
3030 else if(context.this_slot == trigger::slot_contents::state)
3031 context.compiled_effect.push_back(effect::remove_casus_belli_this_state);
3032 else if(context.this_slot == trigger::slot_contents::pop)
3033 context.compiled_effect.push_back(effect::remove_casus_belli_this_pop);
3034 else {
3035 err.accumulated_errors += "remove_casus_belli = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
3036 ", line " + std::to_string(line) + ")\n";
3037 return;
3038 }
3039 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3040 } else if(is_integer(value.target.data(), value.target.data() + value.target.length())) {
3041 auto ivalue = parse_int(value.target, line, err);
3042 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
3043 context.compiled_effect.push_back(effect::remove_casus_belli_int);
3044 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3046 } else {
3047 err.accumulated_errors +=
3048 "remove_casus_belli effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3049 return;
3050 }
3051 } else if(value.target.length() == 3) {
3052 if(auto it = context.outer_context.map_of_ident_names.find(
3053 nations::tag_to_int(value.target[0], value.target[1], value.target[2]));
3054 it != context.outer_context.map_of_ident_names.end()) {
3055 context.compiled_effect.push_back(uint16_t(effect::remove_casus_belli_tag));
3056 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3057 context.compiled_effect.push_back(trigger::payload(it->second).value);
3058 } else {
3059 err.accumulated_errors +=
3060 "remove_casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3061 return;
3062 }
3063 } else {
3064 err.accumulated_errors +=
3065 "remove_casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3066 return;
3067 }
3068 }
3070 effect_building_context& context) {
3072 err.accumulated_errors += "remove_casus_belli effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3073 std::to_string(line) + ")\n";
3074 return;
3075 }
3076 if(is_from(value.target)) {
3078 context.compiled_effect.push_back(effect::this_remove_casus_belli_from_nation);
3080 context.compiled_effect.push_back(effect::this_remove_casus_belli_from_province);
3081 else {
3082 err.accumulated_errors += "this_remove_casus_belli = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
3083 ", line " + std::to_string(line) + ")\n";
3084 return;
3085 }
3086 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3087 } else if(is_this(value.target)) {
3089 context.compiled_effect.push_back(effect::this_remove_casus_belli_this_nation);
3091 context.compiled_effect.push_back(effect::this_remove_casus_belli_this_province);
3092 else if(context.this_slot == trigger::slot_contents::state)
3093 context.compiled_effect.push_back(effect::this_remove_casus_belli_this_state);
3094 else if(context.this_slot == trigger::slot_contents::pop)
3095 context.compiled_effect.push_back(effect::this_remove_casus_belli_this_pop);
3096 else {
3097 err.accumulated_errors += "this_remove_casus_belli = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name +
3098 ", line " + std::to_string(line) + ")\n";
3099 return;
3100 }
3101 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3102 } else if(is_integer(value.target.data(), value.target.data() + value.target.length())) {
3103 auto ivalue = parse_int(value.target, line, err);
3104 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
3105 context.compiled_effect.push_back(effect::this_remove_casus_belli_int);
3106 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3108 } else {
3109 err.accumulated_errors += "this_remove_casus_belli effect given an invalid province id (" + err.file_name + ", line " +
3110 std::to_string(line) + ")\n";
3111 return;
3112 }
3113 } else if(value.target.length() == 3) {
3114 if(auto it = context.outer_context.map_of_ident_names.find(
3115 nations::tag_to_int(value.target[0], value.target[1], value.target[2]));
3116 it != context.outer_context.map_of_ident_names.end()) {
3117 context.compiled_effect.push_back(uint16_t(effect::this_remove_casus_belli_tag));
3118 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3119 context.compiled_effect.push_back(trigger::payload(it->second).value);
3120 } else {
3121 err.accumulated_errors +=
3122 "this_remove_casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3123 return;
3124 }
3125 } else {
3126 err.accumulated_errors +=
3127 "this_remove_casus_belli effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3128 return;
3129 }
3130 }
3131 void war(ef_war const& value, error_handler& err, int32_t line, effect_building_context& context) {
3133 err.accumulated_errors +=
3134 "war effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3135 return;
3136 }
3137 if(value.attacker_goal.special_end_wargoal) {
3138 if(is_from(value.target)) {
3140 context.compiled_effect.push_back(effect::add_truce_from_nation);
3142 context.compiled_effect.push_back(effect::add_truce_from_province);
3143 else {
3144 err.accumulated_errors +=
3145 "war = from effect (used to create a truce) used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3146 return;
3147 }
3148 } else if(is_this(value.target)) {
3150 context.compiled_effect.push_back(effect::add_truce_this_nation);
3152 context.compiled_effect.push_back(effect::add_truce_this_province);
3153 else if(context.this_slot == trigger::slot_contents::state)
3154 context.compiled_effect.push_back(effect::add_truce_this_state);
3156 context.compiled_effect.push_back(effect::add_truce_this_province);
3157 else {
3158 err.accumulated_errors +=
3159 "war = this (used to create a truce) used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3160 return;
3161 }
3162 } else if(value.target.length() == 3) {
3163 if(auto it = context.outer_context.map_of_ident_names.find(
3164 nations::tag_to_int(value.target[0], value.target[1], value.target[2]));
3165 it != context.outer_context.map_of_ident_names.end()) {
3166 context.compiled_effect.push_back(effect::add_truce_tag);
3167 context.compiled_effect.push_back(trigger::payload(it->second).value);
3168 } else {
3169 err.accumulated_errors +=
3170 "war = effect (used to create a truce) given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3171 return;
3172 }
3173 } else {
3174 err.accumulated_errors +=
3175 "war = effect (used to create a truce) given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3176 return;
3177 }
3178 context.compiled_effect.push_back(uint16_t(12)); // months
3179 return;
3180 } else if(value.attacker_goal.special_call_ally_wargoal) {
3181 context.compiled_effect.push_back(effect::call_allies);
3182 return;
3183 }
3184 if(is_from(value.target)) {
3186 context.compiled_effect.push_back(value.call_ally ? effect::war_from_nation : effect::war_no_ally_from_nation);
3188 context.compiled_effect.push_back(value.call_ally ? effect::war_from_province : effect::war_no_ally_from_province);
3189 else {
3190 err.accumulated_errors +=
3191 "war = from effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3192 return;
3193 }
3194 } else if(is_this(value.target)) {
3196 context.compiled_effect.push_back(value.call_ally ? effect::war_this_nation : effect::war_no_ally_this_nation);
3198 context.compiled_effect.push_back(value.call_ally ? effect::war_this_province : effect::war_no_ally_this_province);
3199 else if(context.this_slot == trigger::slot_contents::state)
3200 context.compiled_effect.push_back(value.call_ally ? effect::war_this_state : effect::war_no_ally_this_state);
3201 else if(context.this_slot == trigger::slot_contents::pop)
3202 context.compiled_effect.push_back(value.call_ally ? effect::war_this_pop : effect::war_no_ally_this_pop);
3203 else {
3204 err.accumulated_errors +=
3205 "war = this effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3206 return;
3207 }
3208 } else if(value.target.length() == 3) {
3209 if(auto it = context.outer_context.map_of_ident_names.find(
3210 nations::tag_to_int(value.target[0], value.target[1], value.target[2]));
3211 it != context.outer_context.map_of_ident_names.end()) {
3212 context.compiled_effect.push_back(uint16_t(value.call_ally ? effect::war_tag : effect::war_no_ally_tag));
3213 context.compiled_effect.push_back(trigger::payload(it->second).value);
3214 } else {
3215 err.accumulated_errors +=
3216 "war = effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3217 return;
3218 }
3219 } else if(value.target.length() == 0) { // some mods use this as a call allies effect. So far, we just discard it
3220 return;
3221 } else {
3222 err.accumulated_errors +=
3223 "war = effect given an invalid tag (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3224 return;
3225 }
3226 context.compiled_effect.push_back(trigger::payload(value.defender_goal.casus_belli_).value);
3227 context.compiled_effect.push_back(trigger::payload(value.defender_goal.state_province_id_).value);
3228 context.compiled_effect.push_back(trigger::payload(value.defender_goal.country_).value);
3229 context.compiled_effect.push_back(trigger::payload(value.attacker_goal.casus_belli_).value);
3230 context.compiled_effect.push_back(trigger::payload(value.attacker_goal.state_province_id_).value);
3231 context.compiled_effect.push_back(trigger::payload(value.attacker_goal.country_).value);
3232 }
3233 void country_event(ef_country_event const& value, error_handler& err, int32_t line, effect_building_context& context) {
3235 if(value.days <= 0) {
3237 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_nation));
3239 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_province));
3240 else if(context.this_slot == trigger::slot_contents::state)
3241 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_state));
3242 else if(context.this_slot == trigger::slot_contents::pop)
3243 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_pop));
3244 else {
3245 err.accumulated_errors +=
3246 "country_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3247 return;
3248 }
3249 context.compiled_effect.push_back(trigger::payload(value.id_).value);
3250 } else {
3252 context.compiled_effect.push_back(uint16_t(effect::country_event_this_nation));
3254 context.compiled_effect.push_back(uint16_t(effect::country_event_this_province));
3255 else if(context.this_slot == trigger::slot_contents::state)
3256 context.compiled_effect.push_back(uint16_t(effect::country_event_this_state));
3257 else if(context.this_slot == trigger::slot_contents::pop)
3258 context.compiled_effect.push_back(uint16_t(effect::country_event_this_pop));
3259 else {
3260 err.accumulated_errors +=
3261 "country_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3262 return;
3263 }
3264 context.compiled_effect.push_back(trigger::payload(value.id_).value);
3265 context.compiled_effect.push_back(uint16_t(value.days));
3266 }
3267 } else if(context.main_slot == trigger::slot_contents::province) {
3268 if(value.days <= 0) {
3270 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_nation));
3272 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_province));
3273 else if(context.this_slot == trigger::slot_contents::state)
3274 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_state));
3275 else if(context.this_slot == trigger::slot_contents::pop)
3276 context.compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_pop));
3277 else {
3278 err.accumulated_errors +=
3279 "country_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3280 return;
3281 }
3282 context.compiled_effect.push_back(trigger::payload(value.id_).value);
3283 } else {
3285 context.compiled_effect.push_back(uint16_t(effect::country_event_province_this_nation));
3287 context.compiled_effect.push_back(uint16_t(effect::country_event_province_this_province));
3288 else if(context.this_slot == trigger::slot_contents::state)
3289 context.compiled_effect.push_back(uint16_t(effect::country_event_province_this_state));
3290 else if(context.this_slot == trigger::slot_contents::pop)
3291 context.compiled_effect.push_back(uint16_t(effect::country_event_province_this_pop));
3292 else {
3293 err.accumulated_errors +=
3294 "country_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3295 return;
3296 }
3297 context.compiled_effect.push_back(trigger::payload(value.id_).value);
3298 context.compiled_effect.push_back(uint16_t(value.days));
3299 }
3300 } else {
3301 err.accumulated_errors +=
3302 "country_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3303 return;
3304 }
3305 }
3306 void province_event(ef_province_event const& value, error_handler& err, int32_t line, effect_building_context& context) {
3308 if(value.days <= 0) {
3310 context.compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_nation));
3312 context.compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_province));
3313 else if(context.this_slot == trigger::slot_contents::state)
3314 context.compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_state));
3315 else if(context.this_slot == trigger::slot_contents::pop)
3316 context.compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_pop));
3317 else {
3318 err.accumulated_errors += "province_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3319 std::to_string(line) + ")\n";
3320 return;
3321 }
3322 context.compiled_effect.push_back(trigger::payload(value.id_).value);
3323 } else {
3325 context.compiled_effect.push_back(uint16_t(effect::province_event_this_nation));
3327 context.compiled_effect.push_back(uint16_t(effect::province_event_this_province));
3328 else if(context.this_slot == trigger::slot_contents::state)
3329 context.compiled_effect.push_back(uint16_t(effect::province_event_this_state));
3330 else if(context.this_slot == trigger::slot_contents::pop)
3331 context.compiled_effect.push_back(uint16_t(effect::province_event_this_pop));
3332 else {
3333 err.accumulated_errors += "province_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3334 std::to_string(line) + ")\n";
3335 return;
3336 }
3337 context.compiled_effect.push_back(trigger::payload(value.id_).value);
3338 context.compiled_effect.push_back(uint16_t(value.days));
3339 }
3340 } else {
3341 err.accumulated_errors +=
3342 "province_event effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3343 return;
3344 }
3345 }
3346
3347 void sub_unit(ef_sub_unit const& value, error_handler& err, int32_t line, effect_building_context& context) {
3348 if(is_this(value.value)) {
3350 err.accumulated_errors +=
3351 "sub_unit effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3352 return;
3353 }
3354 context.compiled_effect.push_back(effect::sub_unit_this);
3355 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3356 } else if(is_from(value.value)) {
3358 err.accumulated_errors +=
3359 "sub_unit effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3360 return;
3361 }
3362 context.compiled_effect.push_back(effect::sub_unit_from);
3363 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3364 } else if(is_fixed_token_ci(value.value.data(), value.value.data() + value.value.length(), "current")) {
3366 err.accumulated_errors +=
3367 "sub_unit effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3368 return;
3369 }
3370 context.compiled_effect.push_back(effect::sub_unit_current);
3371 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3372 } else {
3373 auto ivalue = parse_int(value.value, line, err);
3374 if(0 <= ivalue && size_t(ivalue) < context.outer_context.original_id_to_prov_id_map.size()) {
3375 auto prov_id = context.outer_context.original_id_to_prov_id_map[ivalue];
3376 context.compiled_effect.push_back(effect::sub_unit_int);
3377 context.compiled_effect.push_back(trigger::payload(value.type_).value);
3378 context.compiled_effect.push_back(trigger::payload(prov_id).value);
3379 } else {
3380 err.accumulated_errors +=
3381 "sub_unit effect given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3382 return;
3383 }
3384 }
3385 }
3386 void set_variable(ef_set_variable const& value, error_handler& err, int32_t line, effect_building_context& context) {
3388 err.accumulated_errors +=
3389 "set_variable effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3390 return;
3391 }
3392 context.compiled_effect.push_back(effect::set_variable);
3393 context.compiled_effect.push_back(trigger::payload(value.which_).value);
3394 context.add_float_to_payload(value.value);
3395 }
3396 void change_variable(ef_change_variable const& value, error_handler& err, int32_t line, effect_building_context& context) {
3398 err.accumulated_errors +=
3399 "change_variable effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3400 return;
3401 }
3402 context.compiled_effect.push_back(effect::change_variable);
3403 context.compiled_effect.push_back(trigger::payload(value.which_).value);
3404 context.add_float_to_payload(value.value);
3405 }
3406 void increment_variable(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
3408 err.accumulated_errors +=
3409 "change_variable effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3410 return;
3411 }
3412 auto which_ = context.outer_context.get_national_variable(std::string(value));
3413 context.compiled_effect.push_back(effect::change_variable);
3414 context.compiled_effect.push_back(trigger::payload(which_).value);
3415 context.add_float_to_payload(1.f);
3416 }
3417 void decrement_variable(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
3419 err.accumulated_errors +=
3420 "change_variable effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3421 return;
3422 }
3423 auto which_ = context.outer_context.get_national_variable(std::string(value));
3424 context.compiled_effect.push_back(effect::change_variable);
3425 context.compiled_effect.push_back(trigger::payload(which_).value);
3426 context.add_float_to_payload(-1.f);
3427 }
3428 void set_variable_to_zero(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
3430 err.accumulated_errors +=
3431 "set_variable effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3432 return;
3433 }
3434 auto which_ = context.outer_context.get_national_variable(std::string(value));
3435 context.compiled_effect.push_back(effect::set_variable);
3436 context.compiled_effect.push_back(trigger::payload(which_).value);
3437 context.add_float_to_payload(0.f);
3438 }
3439 void change_terrain(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
3440 if(auto it = context.outer_context.map_of_terrain_types.find(std::string(value));
3441 it != context.outer_context.map_of_terrain_types.end()) {
3442 if(context.main_slot == trigger::slot_contents::pop) {
3443 context.compiled_effect.push_back(uint16_t(effect::change_terrain_pop));
3444 } else if(context.main_slot == trigger::slot_contents::province) {
3445 context.compiled_effect.push_back(uint16_t(effect::change_terrain_province));
3446 } else {
3447 err.accumulated_errors += "chenge_terrain effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3448 return;
3449 }
3450 context.compiled_effect.push_back(trigger::payload(it->second.id).value);
3451 } else {
3452 err.accumulated_errors += "chenge_terrain effect supplied with an invalid terrain \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3453 }
3454 }
3455 void masquerade_as_nation(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
3457 if(is_this(value)) {
3458 context.compiled_effect.push_back(uint16_t(effect::masquerade_as_nation_this));
3459 } else if(is_from(value)) {
3460 context.compiled_effect.push_back(uint16_t(effect::masquerade_as_nation_from));
3461 } else {
3462 err.accumulated_errors += "masquerade_as_nation effect given an invalid parameter " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3463 return;
3464 }
3465 } else {
3466 err.accumulated_errors += "masquerade_as_nation effect not used in a nation scope (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3467 }
3468 }
3469 void ideology(ef_ideology const& value, error_handler& err, int32_t line, effect_building_context& context) {
3470 if(context.main_slot != trigger::slot_contents::pop) {
3471 err.accumulated_errors +=
3472 "ideology effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3473 return;
3474 }
3475 context.compiled_effect.push_back(effect::ideology);
3476 context.compiled_effect.push_back(trigger::payload(value.value_).value);
3477 context.add_float_to_payload(value.factor);
3478 }
3479 void dominant_issue(ef_dominant_issue const& value, error_handler& err, int32_t line, effect_building_context& context) {
3480 if(context.main_slot == trigger::slot_contents::pop) {
3481 context.compiled_effect.push_back(effect::dominant_issue);
3482 context.compiled_effect.push_back(trigger::payload(value.value_).value);
3483 context.add_float_to_payload(value.factor);
3484 } else if(context.main_slot == trigger::slot_contents::nation) {
3485 context.compiled_effect.push_back(effect::dominant_issue_nation);
3486 context.compiled_effect.push_back(trigger::payload(value.value_).value);
3487 context.add_float_to_payload(value.factor);
3488 } else {
3489 err.accumulated_errors +=
3490 "dominant_issue effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3491 return;
3492 }
3493 }
3494 void upper_house(ef_upper_house const& value, error_handler& err, int32_t line, effect_building_context& context) {
3496 err.accumulated_errors +=
3497 "upper_house effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3498 return;
3499 }
3500 context.compiled_effect.push_back(effect::upper_house);
3501 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3502 context.add_float_to_payload(value.value);
3503 }
3504 void scaled_militancy(ef_scaled_militancy const& value, error_handler& err, int32_t line, effect_building_context& context) {
3505 if(context.main_slot == trigger::slot_contents::pop) {
3506 if(bool(value.ideology_)) {
3507 context.compiled_effect.push_back(effect::scaled_militancy_ideology);
3508 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3509 context.add_float_to_payload(value.factor);
3510 } else if(bool(value.issue_)) {
3511 context.compiled_effect.push_back(effect::scaled_militancy_issue);
3512 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3513 context.add_float_to_payload(value.factor);
3514 } else {
3515 context.compiled_effect.push_back(effect::scaled_militancy_unemployment);
3516 context.add_float_to_payload(value.factor * value.unemployment);
3517 }
3518 } else if(context.main_slot == trigger::slot_contents::nation) {
3519 if(bool(value.ideology_)) {
3520 context.compiled_effect.push_back(effect::scaled_militancy_nation_ideology);
3521 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3522 context.add_float_to_payload(value.factor);
3523 } else if(bool(value.issue_)) {
3524 context.compiled_effect.push_back(effect::scaled_militancy_nation_issue);
3525 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3526 context.add_float_to_payload(value.factor);
3527 } else {
3528 context.compiled_effect.push_back(effect::scaled_militancy_nation_unemployment);
3529 context.add_float_to_payload(value.factor * value.unemployment);
3530 }
3531 } else if(context.main_slot == trigger::slot_contents::state) {
3532 if(bool(value.ideology_)) {
3533 context.compiled_effect.push_back(effect::scaled_militancy_state_ideology);
3534 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3535 context.add_float_to_payload(value.factor);
3536 } else if(bool(value.issue_)) {
3537 context.compiled_effect.push_back(effect::scaled_militancy_state_issue);
3538 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3539 context.add_float_to_payload(value.factor);
3540 } else {
3541 context.compiled_effect.push_back(effect::scaled_militancy_state_unemployment);
3542 context.add_float_to_payload(value.factor * value.unemployment);
3543 }
3544 } else if(context.main_slot == trigger::slot_contents::province) {
3545 if(bool(value.ideology_)) {
3546 context.compiled_effect.push_back(effect::scaled_militancy_province_ideology);
3547 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3548 context.add_float_to_payload(value.factor);
3549 } else if(bool(value.issue_)) {
3550 context.compiled_effect.push_back(effect::scaled_militancy_province_issue);
3551 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3552 context.add_float_to_payload(value.factor);
3553 } else {
3554 context.compiled_effect.push_back(effect::scaled_militancy_province_unemployment);
3555 context.add_float_to_payload(value.factor * value.unemployment);
3556 }
3557 } else {
3558 err.accumulated_errors +=
3559 "scaled_militancy effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3560 return;
3561 }
3562 }
3564 if(context.main_slot == trigger::slot_contents::pop) {
3565 if(bool(value.ideology_)) {
3566 context.compiled_effect.push_back(effect::scaled_consciousness_ideology);
3567 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3568 context.add_float_to_payload(value.factor);
3569 } else if(bool(value.issue_)) {
3570 context.compiled_effect.push_back(effect::scaled_consciousness_issue);
3571 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3572 context.add_float_to_payload(value.factor);
3573 } else {
3574 context.compiled_effect.push_back(effect::scaled_consciousness_unemployment);
3575 context.add_float_to_payload(value.factor * value.unemployment);
3576 }
3577 } else if(context.main_slot == trigger::slot_contents::nation) {
3578 if(bool(value.ideology_)) {
3579 context.compiled_effect.push_back(effect::scaled_consciousness_nation_ideology);
3580 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3581 context.add_float_to_payload(value.factor);
3582 } else if(bool(value.issue_)) {
3583 context.compiled_effect.push_back(effect::scaled_consciousness_nation_issue);
3584 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3585 context.add_float_to_payload(value.factor);
3586 } else {
3587 context.compiled_effect.push_back(effect::scaled_consciousness_nation_unemployment);
3588 context.add_float_to_payload(value.factor * value.unemployment);
3589 }
3590 } else if(context.main_slot == trigger::slot_contents::state) {
3591 if(bool(value.ideology_)) {
3592 context.compiled_effect.push_back(effect::scaled_consciousness_state_ideology);
3593 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3594 context.add_float_to_payload(value.factor);
3595 } else if(bool(value.issue_)) {
3596 context.compiled_effect.push_back(effect::scaled_consciousness_state_issue);
3597 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3598 context.add_float_to_payload(value.factor);
3599 } else {
3600 context.compiled_effect.push_back(effect::scaled_consciousness_state_unemployment);
3601 context.add_float_to_payload(value.factor * value.unemployment);
3602 }
3603 } else if(context.main_slot == trigger::slot_contents::province) {
3604 if(bool(value.ideology_)) {
3605 context.compiled_effect.push_back(effect::scaled_consciousness_province_ideology);
3606 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3607 context.add_float_to_payload(value.factor);
3608 } else if(bool(value.issue_)) {
3609 context.compiled_effect.push_back(effect::scaled_consciousness_province_issue);
3610 context.compiled_effect.push_back(trigger::payload(value.issue_).value);
3611 context.add_float_to_payload(value.factor);
3612 } else {
3613 context.compiled_effect.push_back(effect::scaled_consciousness_province_unemployment);
3614 context.add_float_to_payload(value.factor * value.unemployment);
3615 }
3616 } else {
3617 err.accumulated_errors += "scaled_consciousness effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3618 std::to_string(line) + ")\n";
3619 return;
3620 }
3621 }
3622 void define_general(ef_define_general const& value, error_handler& err, int32_t line, effect_building_context& context);
3623 void define_admiral(ef_define_admiral const& value, error_handler& err, int32_t line, effect_building_context& context);
3624 void kill_leader(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context);
3625 void add_war_goal(ef_add_war_goal const& value, error_handler& err, int32_t line, effect_building_context& context) {
3627 err.accumulated_errors +=
3628 "add_war_goal effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3629 return;
3630 }
3631 context.compiled_effect.push_back(effect::add_war_goal);
3632 context.compiled_effect.push_back(trigger::payload(value.casus_belli_).value);
3633 }
3634 void move_issue_percentage(ef_move_issue_percentage const& value, error_handler& err, int32_t line,
3635 effect_building_context& context) {
3637 context.compiled_effect.push_back(effect::move_issue_percentage_nation);
3638 else if(context.main_slot == trigger::slot_contents::state)
3639 context.compiled_effect.push_back(effect::move_issue_percentage_state);
3641 context.compiled_effect.push_back(effect::move_issue_percentage_province);
3642 else if(context.main_slot == trigger::slot_contents::pop)
3643 context.compiled_effect.push_back(effect::move_issue_percentage_pop);
3644 else {
3645 err.accumulated_errors += "move_issue_percentage effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3646 std::to_string(line) + ")\n";
3647 return;
3648 }
3649 context.compiled_effect.push_back(trigger::payload(value.from_).value);
3650 context.compiled_effect.push_back(trigger::payload(value.to_).value);
3651 context.add_float_to_payload(value.value);
3652 }
3653 void party_loyalty(ef_party_loyalty const& value, error_handler& err, int32_t line, effect_building_context& context) {
3654 if(bool(value.province_id_)) {
3655 context.compiled_effect.push_back(effect::party_loyalty);
3656 context.compiled_effect.push_back(trigger::payload(value.province_id_).value);
3657 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3658 context.compiled_effect.push_back(trigger::payload(int16_t(value.loyalty_value)).value);
3659 } else if(context.main_slot == trigger::slot_contents::province) {
3660 context.compiled_effect.push_back(effect::party_loyalty_province);
3661 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3662 context.compiled_effect.push_back(trigger::payload(int16_t(value.loyalty_value)).value);
3663 } else {
3664 err.accumulated_errors +=
3665 "party_loyalty effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3666 return;
3667 }
3668 }
3669 void change_party_name(ef_change_party_name const& value, error_handler& err, int32_t line, effect_building_context& context) {
3671 err.accumulated_errors += "change_party_name effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3672 std::to_string(line) + ")\n";
3673 return;
3674 }
3675 context.compiled_effect.push_back(effect::change_party_name);
3676 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3677 context.add_int32_t_to_payload(value.name_.index());
3678 }
3681 err.accumulated_errors += "change_party_position effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3682 std::to_string(line) + ")\n";
3683 return;
3684 } else if(!value.opt_) {
3685 err.accumulated_errors += "change_party_position effect used without a valid position " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3686 std::to_string(line) + ")\n";
3687 return;
3688 }
3689 context.compiled_effect.push_back(effect::change_party_position);
3690 context.compiled_effect.push_back(trigger::payload(value.ideology_).value);
3691 context.compiled_effect.push_back(trigger::payload(value.opt_).value);
3692 }
3695 err.accumulated_errors += "build_railway_in_capital effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3696 std::to_string(line) + ")\n";
3697 return;
3698 }
3699 if(value.in_whole_capital_state && value.limit_to_world_greatest_level)
3700 context.compiled_effect.push_back( uint16_t(effect::build_railway_in_capital_yes_whole_state_yes_limit | effect::no_payload));
3701 else if(value.in_whole_capital_state && !value.limit_to_world_greatest_level)
3702 context.compiled_effect.push_back(uint16_t(effect::build_railway_in_capital_yes_whole_state_no_limit | effect::no_payload));
3703 else if(!value.in_whole_capital_state && value.limit_to_world_greatest_level)
3704 context.compiled_effect.push_back(uint16_t(effect::build_railway_in_capital_no_whole_state_yes_limit | effect::no_payload));
3705 else
3706 context.compiled_effect.push_back(uint16_t(effect::build_railway_in_capital_no_whole_state_no_limit | effect::no_payload));
3707 }
3708 void build_bank_in_capital(ef_build_bank_in_capital const& value, error_handler& err, int32_t line,
3709 effect_building_context& context) {
3711 err.accumulated_errors += "build_bank_in_capital effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3712 std::to_string(line) + ")\n";
3713 return;
3714 }
3715 if(value.in_whole_capital_state && value.limit_to_world_greatest_level)
3716 context.compiled_effect.push_back(
3717 uint16_t(effect::build_bank_in_capital_yes_whole_state_yes_limit | effect::no_payload));
3718 else if(value.in_whole_capital_state && !value.limit_to_world_greatest_level)
3719 context.compiled_effect.push_back(uint16_t(effect::build_bank_in_capital_yes_whole_state_no_limit | effect::no_payload));
3720 else if(!value.in_whole_capital_state && value.limit_to_world_greatest_level)
3721 context.compiled_effect.push_back(uint16_t(effect::build_bank_in_capital_no_whole_state_yes_limit | effect::no_payload));
3722 else
3723 context.compiled_effect.push_back(uint16_t(effect::build_bank_in_capital_no_whole_state_no_limit | effect::no_payload));
3724 }
3726 effect_building_context& context) {
3728 err.accumulated_errors += "build_university_in_capital effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3729 std::to_string(line) + ")\n";
3730 return;
3731 }
3732 if(value.in_whole_capital_state && value.limit_to_world_greatest_level)
3733 context.compiled_effect.push_back(
3734 uint16_t(effect::build_university_in_capital_yes_whole_state_yes_limit | effect::no_payload));
3735 else if(value.in_whole_capital_state && !value.limit_to_world_greatest_level)
3736 context.compiled_effect.push_back(uint16_t(effect::build_university_in_capital_yes_whole_state_no_limit | effect::no_payload));
3737 else if(!value.in_whole_capital_state && value.limit_to_world_greatest_level)
3738 context.compiled_effect.push_back(uint16_t(effect::build_university_in_capital_no_whole_state_yes_limit | effect::no_payload));
3739 else
3740 context.compiled_effect.push_back(uint16_t(effect::build_university_in_capital_no_whole_state_no_limit | effect::no_payload));
3741 }
3742 void build_fort_in_capital(ef_build_fort_in_capital const& value, error_handler& err, int32_t line,
3743 effect_building_context& context) {
3745 err.accumulated_errors += "build_fort_in_capital effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3746 std::to_string(line) + ")\n";
3747 return;
3748 }
3749 if(value.in_whole_capital_state && value.limit_to_world_greatest_level)
3750 context.compiled_effect.push_back(uint16_t(effect::build_fort_in_capital_yes_whole_state_yes_limit | effect::no_payload));
3751 else if(value.in_whole_capital_state && !value.limit_to_world_greatest_level)
3752 context.compiled_effect.push_back(uint16_t(effect::build_fort_in_capital_yes_whole_state_no_limit | effect::no_payload));
3753 else if(!value.in_whole_capital_state && value.limit_to_world_greatest_level)
3754 context.compiled_effect.push_back(uint16_t(effect::build_fort_in_capital_no_whole_state_yes_limit | effect::no_payload));
3755 else
3756 context.compiled_effect.push_back(uint16_t(effect::build_fort_in_capital_no_whole_state_no_limit | effect::no_payload));
3757 }
3758 void any_value(std::string_view label, association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context);
3759 void limit(dcon::trigger_key lim, error_handler& err, int32_t line, effect_building_context& context) {
3760 context.compiled_effect[context.limit_position] = trigger::payload(lim).value;
3761 }
3762};
3763
3765 dcon::value_modifier_key chance_modifier;
3767};
3768void ef_random_by_modifier(token_generator& gen, error_handler& err, effect_building_context& context);
3769
3770struct event_option : public effect_body {
3771 dcon::value_modifier_key ai_chance;
3772 dcon::text_key name_;
3773
3774 void name(association_type t, std::string_view value, error_handler& err, int32_t line, effect_building_context& context) {
3775 name_ = text::find_or_add_key(context.outer_context.state, value, false);
3776 }
3777};
3778
3779dcon::value_modifier_key make_option_ai_chance(token_generator& gen, error_handler& err, effect_building_context& context);
3780
3781dcon::trigger_key ef_limit(token_generator& gen, error_handler& err, effect_building_context& context);
3782
3783void ef_scope_if(token_generator& gen, error_handler& err, effect_building_context& context);
3784void ef_scope_else_if(token_generator& gen, error_handler& err, effect_building_context& context);
3824void ef_scope_variable(std::string_view label, token_generator& gen, error_handler& err, effect_building_context& context);
3826dcon::value_modifier_key read_chance_modifier(token_generator& gen, error_handler& err, effect_building_context& context);
3827int32_t add_to_random_list(std::string_view label, token_generator& gen, error_handler& err, effect_building_context& context);
3828
3829dcon::effect_key make_effect(token_generator& gen, error_handler& err, effect_building_context& context);
3830int32_t simplify_effect(uint16_t* source);
3831
3832} // namespace parsers
std::string accumulated_errors
Definition: parsers.hpp:62
std::string accumulated_warnings
Definition: parsers.hpp:63
std::string file_name
Definition: parsers.hpp:61
dcon::modifier_id get_province_immigrator_modifier(sys::state &state)
Definition: economy.cpp:5383
dcon::modifier_id get_province_selector_modifier(sys::state &state)
Definition: economy.cpp:5379
constexpr uint16_t owner_scope_province
constexpr uint16_t no_payload
constexpr uint16_t scope_has_limit
uint32_t tag_to_int(char first, char second, char third)
Definition: nations.hpp:7
void ef_scope_random_owned(token_generator &gen, error_handler &err, effect_building_context &context)
bool is_integer(char const *start, char const *end)
Definition: parsers.cpp:46
void ef_scope_any_defined_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_location(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_all_core(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_hidden_tooltip(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_sphere_owner(token_generator &gen, error_handler &err, effect_building_context &context)
bool is_this(std::string_view value)
bool is_reb(std::string_view value)
void ef_scope_random_state(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_owner(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_cultural_union(token_generator &gen, error_handler &err, effect_building_context &context)
association_type
Definition: parsers.hpp:28
void ef_scope_any_greater_power(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_list(token_generator &gen, error_handler &err, effect_building_context &context)
int32_t simplify_effect(uint16_t *source)
void ef_scope_else_if(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_middle_strata(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_state(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_empty_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
bool is_from(std::string_view value)
void ef_crisis_state_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_controller(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_else(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_overlord(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_capital_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_state_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_rich_strata(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_owned(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_substate(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_random_by_modifier(token_generator &gen, error_handler &err, effect_building_context &context)
bool is_fixed_token_ci(char const *start, char const *end, char const (&t)[N])
Definition: parsers.hpp:275
void ef_scope_any_existing_country_except_scoped(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_independence(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_from(token_generator &gen, error_handler &err, effect_building_context &context)
int32_t parse_int(std::string_view content, int32_t line, error_handler &err)
Definition: parsers.cpp:226
dcon::trigger_key ef_limit(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::effect_key make_effect(token_generator &gen, error_handler &err, effect_building_context &context)
int32_t add_to_random_list(std::string_view label, token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_poor_strata(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::value_modifier_key read_chance_modifier(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_flashpoint_tag_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_variable(std::string_view label, token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::value_modifier_key make_option_ai_chance(token_generator &gen, error_handler &err, effect_building_context &context)
std::string slot_contents_to_string(trigger::slot_contents v)
void ef_scope_random_neighbor_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_sea_zone(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_neighbor_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_if(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_pop(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_this(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_pop(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
Definition: text.cpp:695
void finish(effect_building_context &)
void type(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void finish(effect_building_context &)
void name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void casus_belli(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
dcon::cb_type_id casus_belli_
void finish(effect_building_context &)
void finish(effect_building_context &)
void finish(effect_building_context &)
void finish(effect_building_context &)
void type(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void name(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void position(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void which(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::national_variable_id which_
dcon::national_event_id id_
void id(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
dcon::leader_trait_id personality_
void personality(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::leader_trait_id background_
void finish(effect_building_context &)
void background(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::leader_trait_id personality_
void personality(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void background(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::leader_trait_id background_
void finish(effect_building_context &)
void finish(effect_building_context &)
void finish(effect_building_context &)
void value(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::issue_option_id value_
void value(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
dcon::ideology_id value_
void finish(effect_building_context &)
void to(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void from(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::ideology_id ideology_
void finish(effect_building_context &)
void province_id(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
dcon::province_id province_id_
void id(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
dcon::provincial_event_id id_
void finish(effect_building_context &)
void finish(effect_building_context &)
void any_group(std::string_view label, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
std::string_view who
void finish(effect_building_context &)
void finish(effect_building_context &)
void type(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void issue(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void issue(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::issue_option_id issue_
dcon::value_modifier_key chance_modifier
void finish(effect_building_context &)
void finish(effect_building_context &)
dcon::national_variable_id which_
void which(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
std::string_view value
dcon::unit_type_id type_
void finish(effect_building_context &)
void type(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void type(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void type(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void ideology(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
dcon::rebel_type_id type_
dcon::religion_id religion_
dcon::ideology_id ideology_
void culture(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void religion(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
dcon::ideology_id ideology_
ef_wargoal attacker_goal
ef_wargoal defender_goal
std::string_view target
void finish(effect_building_context &)
dcon::national_identity_id country_
void finish(effect_building_context &)
void state_province_id(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
dcon::cb_type_id casus_belli_
void country(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
dcon::province_id state_province_id_
void casus_belli(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void scaled_consciousness(ef_scaled_consciousness const &value, error_handler &err, int32_t line, effect_building_context &context)
void remove_random_military_reforms(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void province_immigrator(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void activate_technology(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void remove_accepted_culture(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void military_access(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void change_party_name(ef_change_party_name const &value, error_handler &err, int32_t line, effect_building_context &context)
void change_party_position(ef_change_party_position const &value, error_handler &err, int32_t line, effect_building_context &context)
void define_general(ef_define_general const &value, error_handler &err, int32_t line, effect_building_context &context)
void add_country_modifier(ef_add_country_modifier const &value, error_handler &err, int32_t line, effect_building_context &context)
void build_university_in_capital(ef_build_university_in_capital const &value, error_handler &err, int32_t line, effect_building_context &context)
void government(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void annex_to(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void naval_base(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void limit(dcon::trigger_key lim, error_handler &err, int32_t line, effect_building_context &context)
void set_culture(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void pop_type(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void decrement_variable(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void capital(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void clr_global_flag(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void military_reform(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void set_variable(ef_set_variable const &value, error_handler &err, int32_t line, effect_building_context &context)
void build_factory_in_capital_state(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void release_vassal(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void finish(effect_building_context &)
void add_country_modifier(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void end_war(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void party_loyalty(ef_party_loyalty const &value, error_handler &err, int32_t line, effect_building_context &context)
void set_global_flag(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void primary_culture(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void remove_province_modifier(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void create_vassal(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void leave_alliance(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void world_wars_enabled(association_type t, bool value, error_handler &err, int32_t line, effect_building_context &context)
void enable_ideology(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void nationalvalue(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void create_alliance(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void clr_country_flag(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void trigger_revolt(ef_trigger_revolt const &value, error_handler &err, int32_t line, effect_building_context &context)
void nationalize(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void economic_reform(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void relation(ef_relation const &value, error_handler &err, int32_t line, effect_building_context &context)
void consciousness(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void add_casus_belli(ef_add_casus_belli const &value, error_handler &err, int32_t line, effect_building_context &context)
void change_controller(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void set_variable_to_zero(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void add_accepted_culture(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void literacy(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void add_tax_relative_income(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void any_value(std::string_view label, association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void neutrality(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void prestige(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void flashpoint_tension(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void university(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void ruling_party_ideology(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void leadership(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void election(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void province_selector(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void sub_unit(ef_sub_unit const &value, error_handler &err, int32_t line, effect_building_context &context)
void remove_random_economic_reforms(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void religion(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void badboy(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void change_tag(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void war_exhaustion(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void add_crime(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void change_tag_no_core_switch(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void add_crisis_temperature(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void ideology(ef_ideology const &value, error_handler &err, int32_t line, effect_building_context &context)
void province_event(ef_province_event const &value, error_handler &err, int32_t line, effect_building_context &context)
void masquerade_as_nation(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void political_reform(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void dominant_issue(ef_dominant_issue const &value, error_handler &err, int32_t line, effect_building_context &context)
void remove_casus_belli(ef_remove_casus_belli const &value, error_handler &err, int32_t line, effect_building_context &context)
void upper_house(ef_upper_house const &value, error_handler &err, int32_t line, effect_building_context &context)
void remove_core(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void bank(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void move_issue_percentage(ef_move_issue_percentage const &value, error_handler &err, int32_t line, effect_building_context &context)
void prestige_factor(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void change_province_name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void money(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void country_event(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void plurality(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void trade_goods(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void social_reform(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void assimilate(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void infrastructure(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void casus_belli(ef_casus_belli const &value, error_handler &err, int32_t line, effect_building_context &context)
void add_war_goal(ef_add_war_goal const &value, error_handler &err, int32_t line, effect_building_context &context)
void change_variable(ef_change_variable const &value, error_handler &err, int32_t line, effect_building_context &context)
void release(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void reduce_pop(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void define_admiral(ef_define_admiral const &value, error_handler &err, int32_t line, effect_building_context &context)
void end_military_access(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void add_province_modifier(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void rgo_size(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void years_of_research(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void remove_country_modifier(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void set_country_flag(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void enable_canal(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void war(ef_war const &value, error_handler &err, int32_t line, effect_building_context &context)
void research_points(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void add_province_modifier(ef_add_province_modifier const &value, error_handler &err, int32_t line, effect_building_context &context)
void inherit(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void reduce_pop_abs(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void fort(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void province_event(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void kill_leader(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void country_event(ef_country_event const &value, error_handler &err, int32_t line, effect_building_context &context)
void great_wars_enabled(association_type t, bool value, error_handler &err, int32_t line, effect_building_context &context)
void scaled_militancy(ef_scaled_militancy const &value, error_handler &err, int32_t line, effect_building_context &context)
void move_pop(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void tech_school(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void diplomatic_influence(ef_diplomatic_influence const &value, error_handler &err, int32_t line, effect_building_context &context)
void life_rating(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void treasury(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
void secede_province(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void civilized(association_type t, bool value, error_handler &err, int32_t line, effect_building_context &context)
void increment_variable(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void build_railway_in_capital(ef_build_railway_in_capital const &value, error_handler &err, int32_t line, effect_building_context &context)
void change_region_name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void this_remove_casus_belli(ef_this_remove_casus_belli const &value, error_handler &err, int32_t line, effect_building_context &context)
void add_crisis_interest(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void build_fort_in_capital(ef_build_fort_in_capital const &value, error_handler &err, int32_t line, effect_building_context &context)
void change_terrain(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void build_bank_in_capital(ef_build_bank_in_capital const &value, error_handler &err, int32_t line, effect_building_context &context)
void add_core(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void is_slave(association_type t, bool value, error_handler &err, int32_t line, effect_building_context &context)
void militancy(association_type t, float value, error_handler &err, int32_t line, effect_building_context &context)
trigger::slot_contents this_slot
scenario_building_context & outer_context
std::vector< uint16_t > compiled_effect
trigger::slot_contents from_slot
effect_building_context(scenario_building_context &outer_context, trigger::slot_contents main_slot, trigger::slot_contents this_slot, trigger::slot_contents from_slot)
trigger::slot_contents main_slot
dcon::value_modifier_key ai_chance
void name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
ankerl::unordered_dense::map< std::string, dcon::unit_type_id > map_of_unit_types
ankerl::unordered_dense::map< std::string, dcon::modifier_id > map_of_modifiers
ankerl::unordered_dense::map< std::string, dcon::religion_id > map_of_religion_names
ankerl::unordered_dense::map< std::string, pending_invention_content > map_of_inventions
ankerl::unordered_dense::map< std::string, pending_roption_content > map_of_roptions
ankerl::unordered_dense::map< std::string, pending_tech_content > map_of_technologies
ankerl::unordered_dense::map< std::string, dcon::pop_type_id > map_of_poptypes
ankerl::unordered_dense::map< std::string, pending_ideology_content > map_of_ideologies
std::vector< dcon::province_id > original_id_to_prov_id_map
ankerl::unordered_dense::map< std::string, pending_crime_content > map_of_crimes
ankerl::unordered_dense::map< std::string, dcon::leader_trait_id > map_of_leader_traits
dcon::global_flag_id get_global_flag(std::string const &name)
ankerl::unordered_dense::map< std::string, pending_option_content > map_of_ioptions
ankerl::unordered_dense::map< std::string, pending_cb_content > map_of_cb_types
ankerl::unordered_dense::map< std::string, terrain_type > map_of_terrain_types
dcon::national_flag_id get_national_flag(std::string const &name)
ankerl::unordered_dense::map< std::string, pending_rebel_type_content > map_of_rebeltypes
ankerl::unordered_dense::map< uint32_t, dcon::national_identity_id > map_of_ident_names
ankerl::unordered_dense::map< std::string, dcon::culture_id > map_of_culture_names
ankerl::unordered_dense::map< std::string, dcon::commodity_id > map_of_commodity_names
ankerl::unordered_dense::map< std::string, dcon::government_type_id > map_of_governments
dcon::national_variable_id get_national_variable(std::string const &name)
ankerl::unordered_dense::map< std::string, dcon::factory_type_id > map_of_factory_names