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