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