Project Alice
Loading...
Searching...
No Matches
trigger_parsing.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <optional>
5#include <string_view>
6#include <string>
7
8#include "constants.hpp"
9#include "parsers.hpp"
10#include "script_constants.hpp"
11#include "nations.hpp"
12#include "container_types.hpp"
13#include "text.hpp"
14
15namespace economy {
16dcon::modifier_id get_province_selector_modifier(sys::state& state);
17dcon::modifier_id get_province_immigrator_modifier(sys::state& state);
18}
19
20namespace parsers {
21
24 std::vector<uint16_t> compiled_trigger;
25
26 float factor = 0.0f;
27
31
35
36 void add_float_to_payload(float f) {
37 union {
38 struct {
39 uint16_t low;
40 uint16_t high;
41 } v;
42 float f;
43 } pack_float;
44 pack_float.f = f;
45
46 compiled_trigger.push_back(pack_float.v.low);
47 compiled_trigger.push_back(pack_float.v.high);
48 }
49
50 void add_int32_t_to_payload(int32_t i) {
51 union {
52 struct {
53 uint16_t low;
54 uint16_t high;
55 } v;
56 int32_t i;
57 } pack_int;
58 pack_int.i = i;
59
60 compiled_trigger.push_back(pack_int.v.low);
61 compiled_trigger.push_back(pack_int.v.high);
62 }
63};
64
66 switch(v) {
68 return "empty";
70 return "province";
72 return "state";
74 return "pop";
76 return "nation";
78 return "rebel";
79 }
80 return "unknown";
81}
82
84 switch(a) {
103 default:
105 }
106}
107
109 switch(a) {
128 default:
130 }
131}
132
134 switch(a) {
153 default:
155 }
156}
157
158inline uint16_t invert_association(uint16_t a) {
159 return static_cast<uint16_t>(0x7000) - a;
160}
161
162inline uint16_t association_to_bool_code(association_type a, bool v) {
163 if(v) {
166 else
168 } else {
171 else
173 }
174}
175
176constexpr bool scope_has_any_all(uint16_t code) {
178}
179
181 std::string_view who;
182 int32_t value_ = 0;
184 void value(association_type t, int32_t v, error_handler& err, int32_t line, trigger_building_context& context) {
185 a = t;
186 value_ = v;
187 }
189};
190
192 std::string_view ideology;
193 float value_ = 0.0f;
195 int32_t province_id = 0;
196 void value(association_type t, float v, error_handler& err, int32_t line, trigger_building_context& context) {
197 a = t;
198 value_ = v;
199 }
201};
202
204 std::string_view type;
205 float value_ = 0.0f;
207 void value(association_type t, float v, error_handler& err, int32_t line, trigger_building_context& context) {
208 a = t;
209 value_ = v;
210 }
212};
213
215 std::string_view ideology;
216 float value_ = 0.0f;
218 void value(association_type t, float v, error_handler& err, int32_t line, trigger_building_context& context) {
219 a = t;
220 value_ = v;
221 }
223};
224
226 std::string_view which;
227 float value_ = 0.0f;
229 void value(association_type t, float v, error_handler& err, int32_t line, trigger_building_context& context) {
230 a = t;
231 value_ = v;
232 }
234};
235
237 std::string_view who;
238 int32_t value_ = 0;
240 void value(association_type t, int32_t v, error_handler& err, int32_t line, trigger_building_context& context) {
241 a = t;
242 value_ = v;
243 }
245};
246
248 std::string_view type;
249 float value_ = 0.0f;
251 void value(association_type t, float v, error_handler& err, int32_t line, trigger_building_context& context) {
252 a = t;
253 value_ = v;
254 }
256};
257
259 std::string_view building;
262};
263
268};
269
274};
275
277 std::vector<dcon::pop_type_id> pop_type_list;
278 void worker(association_type, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
279 if(auto it = context.outer_context.map_of_poptypes.find(std::string(value));
280 it != context.outer_context.map_of_poptypes.end()) {
281 pop_type_list.push_back(it->second);
282 } else {
283 err.accumulated_errors +=
284 std::string(value) + " is not a valid pop type name (" + err.file_name + " line " + std::to_string(line) + ")\n";
285 }
286 }
288};
289
291 dcon::ideology_id ideology_;
292 dcon::text_key name_;
293 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, trigger_building_context& context) {
294 if(is_fixed_token_ci(v.data(), v.data() + v.length(), "ruling_party")) {
295 // leave invalid
296 } else if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
297 ideology_ = it->second.id;
298 } else {
299 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
300 }
301 }
302 void name(association_type t, std::string_view v, error_handler& err, int32_t line, trigger_building_context& context) {
303 name_ = text::find_or_add_key(context.outer_context.state, v, false);
304 }
306};
308 dcon::ideology_id ideology_;
309 dcon::issue_option_id opt_;
310 void ideology(association_type t, std::string_view v, error_handler& err, int32_t line, trigger_building_context& context) {
311 if(is_fixed_token_ci(v.data(), v.data() + v.length(), "ruling_party")) {
312 // leave invalid
313 } else if(auto it = context.outer_context.map_of_ideologies.find(std::string(v)); it != context.outer_context.map_of_ideologies.end()) {
314 ideology_ = it->second.id;
315 } else {
316 err.accumulated_errors += "Invalid ideology " + std::string(v) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
317 }
318 }
319 void position(association_type t, std::string_view v, error_handler& err, int32_t line, trigger_building_context& context);
321};
322
323inline bool is_from(std::string_view value) {
324 return is_fixed_token_ci(value.data(), value.data() + value.length(), "from");
325}
326inline bool is_this(std::string_view value) {
327 return is_fixed_token_ci(value.data(), value.data() + value.length(), "this");
328}
329inline bool is_reb(std::string_view value) {
330 return is_fixed_token_ci(value.data(), value.data() + value.length(), "reb");
331}
332
335
336 void factor(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
337 context.factor = value;
338 }
339
340 void ai(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
342 context.compiled_trigger.push_back(uint16_t(trigger::ai | trigger::no_payload | association_to_bool_code(a, value)));
343 } else {
344 err.accumulated_errors += "ai trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" +
345 err.file_name + ", line " + std::to_string(line) + ")\n";
346 return;
347 }
348 }
349
350 void year(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
351 context.compiled_trigger.push_back(uint16_t(trigger::year | association_to_trigger_code(a)));
352 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
353 }
354 void is_canal_enabled(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context);
355 void month(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
356 context.compiled_trigger.push_back(uint16_t(trigger::month | association_to_trigger_code(a)));
357 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
358 }
359 void great_wars_enabled(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
360 context.compiled_trigger.push_back(
361 uint16_t(trigger::great_wars_enabled | trigger::no_payload | association_to_bool_code(a, value)));
362 }
363 void world_wars_enabled(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
364 context.compiled_trigger.push_back(
365 uint16_t(trigger::world_wars_enabled | trigger::no_payload | association_to_bool_code(a, value)));
366 }
367 void crisis_exist(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
368 context.compiled_trigger.push_back(
369 uint16_t(trigger::crisis_exist | trigger::no_payload | association_to_bool_code(a, value)));
370 }
371 void is_liberation_crisis(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
372 context.compiled_trigger.push_back(
373 uint16_t(trigger::is_liberation_crisis | trigger::no_payload | association_to_bool_code(a, value)));
374 }
375 void is_claim_crisis(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
376 context.compiled_trigger.push_back(
377 uint16_t(trigger::is_claim_crisis | trigger::no_payload | association_to_bool_code(a, value)));
378 }
379
380 void port(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
382 context.compiled_trigger.push_back(uint16_t(trigger::port | trigger::no_payload | association_to_bool_code(a, value)));
383 } else {
384 err.accumulated_errors += "port trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
385 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
386 return;
387 }
388 }
389
390 void involved_in_crisis(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
392 context.compiled_trigger.push_back(
393 uint16_t(trigger::involved_in_crisis_pop | trigger::no_payload | association_to_bool_code(a, value)));
394 } else if(context.main_slot == trigger::slot_contents::nation) {
395 context.compiled_trigger.push_back(
396 uint16_t(trigger::involved_in_crisis_nation | trigger::no_payload | association_to_bool_code(a, value)));
397 } else {
398 err.accumulated_errors += "involved_in_crisis trigger used in an incorrect scope type " +
399 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
400 std::to_string(line) + ")\n";
401 return;
402 }
403 }
404 void has_cultural_sphere(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
406 context.compiled_trigger.push_back(
407 uint16_t(trigger::has_cultural_sphere | trigger::no_payload | association_to_bool_code(a, value)));
408 } else {
409 err.accumulated_errors += "has_cultural_sphere trigger used in an incorrect scope type " +
410 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
411 std::to_string(line) + ")\n";
412 return;
413 }
414 }
415
416 void social_movement(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
418 context.compiled_trigger.push_back(
419 uint16_t(trigger::social_movement | trigger::no_payload | association_to_bool_code(a, value)));
420 } else if(context.from_slot == trigger::slot_contents::rebel) {
421 context.compiled_trigger.push_back(
422 uint16_t(trigger::social_movement_from_reb | trigger::no_payload | association_to_bool_code(a, value)));
423 } else {
424 err.accumulated_errors += "social_movement trigger used in an incorrect scope type " +
425 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
426 std::to_string(line) + ")\n";
427 return;
428 }
429 }
430 void political_movement(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
432 context.compiled_trigger.push_back(
433 uint16_t(trigger::political_movement | trigger::no_payload | association_to_bool_code(a, value)));
434 } else if(context.from_slot == trigger::slot_contents::rebel) {
435 context.compiled_trigger.push_back(
436 uint16_t(trigger::political_movement_from_reb | trigger::no_payload | association_to_bool_code(a, value)));
437 } else {
438 err.accumulated_errors += "political_movement trigger used in an incorrect scope type " +
439 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
440 std::to_string(line) + ")\n";
441 return;
442 }
443 }
444 void rich_tax_above_poor(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
446 context.compiled_trigger.push_back(
447 uint16_t(trigger::rich_tax_above_poor | trigger::no_payload | association_to_bool_code(a, value)));
448 } else {
449 err.accumulated_errors += "rich_tax_above_poor trigger used in an incorrect scope type " +
450 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
451 std::to_string(line) + ")\n";
452 return;
453 }
454 }
455
456 void is_substate(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
458 context.compiled_trigger.push_back(
459 uint16_t(trigger::is_substate | trigger::no_payload | association_to_bool_code(a, value)));
460 } else {
461 err.accumulated_errors += "is_substate trigger used in an incorrect scope type " +
462 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
463 std::to_string(line) + ")\n";
464 return;
465 }
466 }
467 void has_flashpoint(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
469 context.compiled_trigger.push_back(
470 uint16_t(trigger::has_flashpoint | trigger::no_payload | association_to_bool_code(a, value)));
471 } else {
472 err.accumulated_errors += "has_flashpoint trigger used in an incorrect scope type " +
473 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
474 std::to_string(line) + ")\n";
475 return;
476 }
477 }
478 void is_disarmed(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
480 context.compiled_trigger.push_back(
481 uint16_t(trigger::is_disarmed | trigger::no_payload | association_to_bool_code(a, value)));
482 } else if(context.main_slot == trigger::slot_contents::pop) {
483 context.compiled_trigger.push_back(
484 uint16_t(trigger::is_disarmed_pop | trigger::no_payload | association_to_bool_code(a, value)));
485 } else {
486 err.accumulated_errors += "is_disarmed trigger used in an incorrect scope type " +
487 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
488 std::to_string(line) + ")\n";
489 return;
490 }
491 }
492 void can_nationalize(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
494 context.compiled_trigger.push_back(
495 uint16_t(trigger::can_nationalize | trigger::no_payload | association_to_bool_code(a, value)));
496 } else {
497 err.accumulated_errors += "can_nationalize trigger used in an incorrect scope type " +
498 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
499 std::to_string(line) + ")\n";
500 return;
501 }
502 }
503 void part_of_sphere(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
505 context.compiled_trigger.push_back(
506 uint16_t(trigger::part_of_sphere | trigger::no_payload | association_to_bool_code(a, value)));
507 } else {
508 err.accumulated_errors += "part_of_sphere trigger used in an incorrect scope type " +
509 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
510 std::to_string(line) + ")\n";
511 return;
512 }
513 }
514 void constructing_cb_discovered(association_type a, bool value, error_handler& err, int32_t line,
515 trigger_building_context& context) {
517 context.compiled_trigger.push_back(
518 uint16_t(trigger::constructing_cb_discovered | trigger::no_payload | association_to_bool_code(a, value)));
519 } else {
520 err.accumulated_errors += "constructing_cb_discovered trigger used in an incorrect scope type " +
521 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
522 std::to_string(line) + ")\n";
523 return;
524 }
525 }
526 void colonial_nation(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
528 context.compiled_trigger.push_back(
529 uint16_t(trigger::colonial_nation | trigger::no_payload | association_to_bool_code(a, value)));
530 } else {
531 err.accumulated_errors += "colonial_nation trigger used in an incorrect scope type " +
532 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
533 std::to_string(line) + ")\n";
534 return;
535 }
536 }
537 void is_capital(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
539 context.compiled_trigger.push_back(
540 uint16_t(trigger::is_capital | trigger::no_payload | association_to_bool_code(a, value)));
541 } else {
542 err.accumulated_errors += "is_capital trigger used in an incorrect scope type " +
543 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
544 std::to_string(line) + ")\n";
545 return;
546 }
547 }
548 void election(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
550 context.compiled_trigger.push_back(uint16_t(trigger::election | trigger::no_payload | association_to_bool_code(a, value)));
551 } else {
552 err.accumulated_errors += "election trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
553 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
554 return;
555 }
556 }
557 void always(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
558 context.compiled_trigger.push_back(uint16_t(trigger::always | trigger::no_payload | association_to_bool_code(a, value)));
559 }
560 void is_releasable_vassal(association_type a, std::string_view value, error_handler& err, int32_t line,
561 trigger_building_context& context) {
562 if(is_from(value)) {
564 context.compiled_trigger.push_back(
565 uint16_t(trigger::is_releasable_vassal_from | trigger::no_payload | association_to_bool_code(a)));
566 else {
567 err.accumulated_errors += "is_releasable_vassal trigger used in an incorrect scope type " +
568 slot_contents_to_string(context.from_slot) + " (" + err.file_name + ", line " +
569 std::to_string(line) + ")\n";
570 return;
571 }
572 } else {
574 context.compiled_trigger.push_back(uint16_t(trigger::is_releasable_vassal_other | trigger::no_payload |
575 association_to_bool_code(a, parse_bool(value, line, err))));
576 else {
577 err.accumulated_errors += "is_releasable_vassal trigger used in an incorrect scope type " +
578 slot_contents_to_string(context.from_slot) + " (" + err.file_name + ", line " +
579 std::to_string(line) + ")\n";
580 return;
581 }
582 }
583 }
584
585 void someone_can_form_union_tag(association_type a, std::string_view value, error_handler& err, int32_t line,
586 trigger_building_context& context) {
587 if(is_from(value)) {
589 context.compiled_trigger.push_back(
590 uint16_t(trigger::someone_can_form_union_tag_from | trigger::no_payload | association_to_bool_code(a)));
591 else {
592 err.accumulated_errors += "someone_can_form_union_tag trigger used in an incorrect scope type " +
593 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
594 std::to_string(line) + ")\n";
595 return;
596 }
597 } else {
599 context.compiled_trigger.push_back(uint16_t(trigger::someone_can_form_union_tag_other | trigger::no_payload |
600 association_to_bool_code(a, parse_bool(value, line, err))));
601 else {
602 err.accumulated_errors += "someone_can_form_union_tag trigger used in an incorrect scope type " +
603 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
604 std::to_string(line) + ")\n";
605 return;
606 }
607 }
608 }
609 void is_state_capital(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
611 context.compiled_trigger.push_back(uint16_t(trigger::is_state_capital | trigger::no_payload | association_to_bool_code(a, value)));
612 } else if(context.main_slot == trigger::slot_contents::pop) {
613 context.compiled_trigger.push_back(uint16_t(trigger::is_state_capital_pop | trigger::no_payload | association_to_bool_code(a, value)));
614 } else {
615 err.accumulated_errors += "is_state_capital trigger used in an incorrect scope type " +
616 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
617 std::to_string(line) + ")\n";
618 return;
619 }
620 }
621
622 void has_factories(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
624 context.compiled_trigger.push_back(
625 uint16_t(trigger::has_factories_nation | trigger::no_payload | association_to_bool_code(a, value)));
626 } else if(context.main_slot == trigger::slot_contents::state) {
627 context.compiled_trigger.push_back(
628 uint16_t(trigger::has_factories_state | trigger::no_payload | association_to_bool_code(a, value)));
629 } else {
630 err.accumulated_errors += "has_factories trigger used in an incorrect scope type " +
631 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
632 std::to_string(line) + ")\n";
633 return;
634 }
635 }
636 void has_empty_adjacent_province(association_type a, bool value, error_handler& err, int32_t line,
637 trigger_building_context& context) {
639 context.compiled_trigger.push_back(
640 uint16_t(trigger::has_empty_adjacent_province | trigger::no_payload | association_to_bool_code(a, value)));
641 } else {
642 err.accumulated_errors += "has_empty_adjacent_province trigger used in an incorrect scope type " +
643 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
644 std::to_string(line) + ")\n";
645 return;
646 }
647 }
648 void minorities(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
650 context.compiled_trigger.push_back(
651 uint16_t(trigger::minorities_nation | trigger::no_payload | association_to_bool_code(a, value)));
652 } else if(context.main_slot == trigger::slot_contents::state) {
653 context.compiled_trigger.push_back(
654 uint16_t(trigger::minorities_state | trigger::no_payload | association_to_bool_code(a, value)));
655 } else if(context.main_slot == trigger::slot_contents::province) {
656 context.compiled_trigger.push_back(
657 uint16_t(trigger::minorities_province | trigger::no_payload | association_to_bool_code(a, value)));
658 } else {
659 err.accumulated_errors += "minorities trigger used in an incorrect scope type " +
660 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
661 std::to_string(line) + ")\n";
662 return;
663 }
664 }
665 void culture_has_union_tag(association_type a, bool value, error_handler& err, int32_t line,
666 trigger_building_context& context) {
668 context.compiled_trigger.push_back(
669 uint16_t(trigger::culture_has_union_tag_nation | trigger::no_payload | association_to_bool_code(a, value)));
670 } else if(context.main_slot == trigger::slot_contents::pop) {
671 context.compiled_trigger.push_back(
672 uint16_t(trigger::culture_has_union_tag_pop | trigger::no_payload | association_to_bool_code(a, value)));
673 } else {
674 err.accumulated_errors += "culture_has_union_tag trigger used in an incorrect scope type " +
675 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
676 std::to_string(line) + ")\n";
677 return;
678 }
679 }
680 void is_colonial(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
682 context.compiled_trigger.push_back(uint16_t(trigger::is_colonial_province | trigger::no_payload | association_to_bool_code(a, value)));
683 } else if(context.main_slot == trigger::slot_contents::state) {
684 context.compiled_trigger.push_back(uint16_t(trigger::is_colonial_state | trigger::no_payload | association_to_bool_code(a, value)));
685 } else if(context.main_slot == trigger::slot_contents::pop) {
686 context.compiled_trigger.push_back(uint16_t(trigger::is_colonial_pop | trigger::no_payload | association_to_bool_code(a, value)));
687 } else if(context.main_slot == trigger::slot_contents::nation) {
688 context.compiled_trigger.push_back(uint16_t(trigger::colonial_nation | trigger::no_payload | association_to_bool_code(a, value)));
689 } else {
690 err.accumulated_errors += "is_colonial trigger used in an incorrect scope type " +
691 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
692 std::to_string(line) + ")\n";
693 return;
694 }
695 }
696 void is_greater_power(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
698 context.compiled_trigger.push_back(
699 uint16_t(trigger::is_greater_power_pop | trigger::no_payload | association_to_bool_code(a, value)));
700 } else if(context.main_slot == trigger::slot_contents::nation) {
701 context.compiled_trigger.push_back(
702 uint16_t(trigger::is_greater_power_nation | trigger::no_payload | association_to_bool_code(a, value)));
703 } else if(context.main_slot == trigger::slot_contents::province) {
704 context.compiled_trigger.push_back(
705 uint16_t(trigger::is_greater_power_province | trigger::no_payload | association_to_bool_code(a, value)));
706 } else {
707 err.accumulated_errors += "is_greater_power trigger used in an incorrect scope type " +
708 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
709 std::to_string(line) + ")\n";
710 return;
711 }
712 }
713 void can_create_vassals(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
715 context.compiled_trigger.push_back(
716 uint16_t(trigger::can_create_vassals | trigger::no_payload | association_to_bool_code(a, value)));
717 } else {
718 err.accumulated_errors += "can_create_vassals trigger used in an incorrect scope type " +
719 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
720 std::to_string(line) + ")\n";
721 return;
722 }
723 }
724 void has_recently_lost_war(association_type a, bool value, error_handler& err, int32_t line,
725 trigger_building_context& context) {
727 context.compiled_trigger.push_back(uint16_t(trigger::has_recently_lost_war | trigger::no_payload | association_to_bool_code(a, value)));
728 } else if(context.main_slot == trigger::slot_contents::pop) {
729 context.compiled_trigger.push_back(uint16_t(trigger::has_recently_lost_war_pop | trigger::no_payload | association_to_bool_code(a, value)));
730 } else {
731 err.accumulated_errors += "has_recently_lost_war trigger used in an incorrect scope type " +
732 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
733 return;
734 }
735 }
736 void is_mobilised(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
738 context.compiled_trigger.push_back(
739 uint16_t(trigger::is_mobilised | trigger::no_payload | association_to_bool_code(a, value)));
740 } else {
741 err.accumulated_errors += "is_mobilised trigger used in an incorrect scope type " +
742 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
743 std::to_string(line) + ")\n";
744 return;
745 }
746 }
747 void crime_higher_than_education(association_type a, bool value, error_handler& err, int32_t line,
748 trigger_building_context& context) {
750 context.compiled_trigger.push_back(
751 uint16_t(trigger::crime_higher_than_education_nation | trigger::no_payload | association_to_bool_code(a, value)));
752 } else if(context.main_slot == trigger::slot_contents::state) {
753 context.compiled_trigger.push_back(
754 uint16_t(trigger::crime_higher_than_education_state | trigger::no_payload | association_to_bool_code(a, value)));
755 } else if(context.main_slot == trigger::slot_contents::province) {
756 context.compiled_trigger.push_back(
757 uint16_t(trigger::crime_higher_than_education_province | trigger::no_payload | association_to_bool_code(a, value)));
758 } else if(context.main_slot == trigger::slot_contents::pop) {
759 context.compiled_trigger.push_back(
760 uint16_t(trigger::crime_higher_than_education_pop | trigger::no_payload | association_to_bool_code(a, value)));
761 } else {
762 err.accumulated_errors += "crime_higher_than_education trigger used in an incorrect scope type " +
763 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
764 std::to_string(line) + ")\n";
765 return;
766 }
767 }
768
769 void civilized(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
771 context.compiled_trigger.push_back(
772 uint16_t(trigger::civilized_nation | trigger::no_payload | association_to_bool_code(a, value)));
773 } else if(context.main_slot == trigger::slot_contents::province) {
774 context.compiled_trigger.push_back(
775 uint16_t(trigger::civilized_province | trigger::no_payload | association_to_bool_code(a, value)));
776 } else if(context.main_slot == trigger::slot_contents::pop) {
777 context.compiled_trigger.push_back(
778 uint16_t(trigger::civilized_pop | trigger::no_payload | association_to_bool_code(a, value)));
779 } else {
780 err.accumulated_errors += "civilized trigger used in an incorrect scope type " +
781 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
782 std::to_string(line) + ")\n";
783 return;
784 }
785 }
786
787 void rank(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
789 context.compiled_trigger.push_back(uint16_t(trigger::rank | association_to_trigger_code(a)));
790 } else {
791 err.accumulated_errors += "rank trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
792 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
793 return;
794 }
795 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
796 }
797
798 void crisis_temperature(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
799 context.compiled_trigger.push_back(uint16_t(trigger::crisis_temperature | association_to_trigger_code(a)));
800 context.add_float_to_payload(value);
801 }
802
803 void has_recent_imigration(association_type a, int32_t value, error_handler& err, int32_t line,
804 trigger_building_context& context) {
806 context.compiled_trigger.push_back(uint16_t(trigger::has_recent_imigration | association_to_le_trigger_code(a)));
807 } else {
808 err.accumulated_errors += "has_recent_imigration trigger used in an incorrect scope type " +
809 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
810 std::to_string(line) + ")\n";
811 return;
812 }
813 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
814 }
815
816 void province_control_days(association_type a, int32_t value, error_handler& err, int32_t line,
817 trigger_building_context& context) {
819 context.compiled_trigger.push_back(uint16_t(trigger::province_control_days | association_to_trigger_code(a)));
820 } else {
821 err.accumulated_errors += "province_control_days trigger used in an incorrect scope type " +
822 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
823 std::to_string(line) + ")\n";
824 return;
825 }
826 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
827 }
828 void num_of_substates(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
830 context.compiled_trigger.push_back(uint16_t(trigger::num_of_substates | association_to_trigger_code(a)));
831 } else {
832 err.accumulated_errors += "num_of_substates trigger used in an incorrect scope type " +
833 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
834 std::to_string(line) + ")\n";
835 return;
836 }
837 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
838 }
839 void num_of_vassals_no_substates(association_type a, int32_t value, error_handler& err, int32_t line,
840 trigger_building_context& context) {
842 context.compiled_trigger.push_back(uint16_t(trigger::num_of_vassals_no_substates | association_to_trigger_code(a)));
843 } else {
844 err.accumulated_errors += "num_of_vassals_no_substates trigger used in an incorrect scope type " +
845 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
846 std::to_string(line) + ")\n";
847 return;
848 }
849 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
850 }
851 void number_of_states(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
853 context.compiled_trigger.push_back(uint16_t(trigger::number_of_states | association_to_trigger_code(a)));
854 } else {
855 err.accumulated_errors += "number_of_states trigger used in an incorrect scope type " +
856 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
857 std::to_string(line) + ")\n";
858 return;
859 }
860 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
861 }
862
863 void war_score(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
865 context.compiled_trigger.push_back(uint16_t(trigger::war_score | association_to_trigger_code(a)));
866 } else {
867 err.accumulated_errors += "war_score trigger used in an incorrect scope type " +
868 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
869 std::to_string(line) + ")\n";
870 return;
871 }
872 context.add_float_to_payload(value);
873 }
874
875 void flashpoint_tension(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
877 context.compiled_trigger.push_back(uint16_t(trigger::flashpoint_tension | association_to_trigger_code(a)));
878 } else if(context.main_slot == trigger::slot_contents::province) {
879 context.compiled_trigger.push_back(uint16_t(trigger::flashpoint_tension_province | association_to_trigger_code(a)));
880 } else {
881 err.accumulated_errors += "flashpoint_tension trigger used in an incorrect scope type " +
882 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
883 std::to_string(line) + ")\n";
884 return;
885 }
886 context.add_float_to_payload(value);
887 }
888
889 void life_needs(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
891 context.compiled_trigger.push_back(uint16_t(trigger::life_needs | association_to_trigger_code(a)));
892 } else {
893 err.accumulated_errors += "life_needs trigger used in an incorrect scope type " +
894 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
895 std::to_string(line) + ")\n";
896 return;
897 }
898 context.add_float_to_payload(value);
899 }
900
901 void everyday_needs(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
903 context.compiled_trigger.push_back(uint16_t(trigger::everyday_needs | association_to_trigger_code(a)));
904 } else {
905 err.accumulated_errors += "everyday_needs trigger used in an incorrect scope type " +
906 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
907 std::to_string(line) + ")\n";
908 return;
909 }
910 context.add_float_to_payload(value);
911 }
912
913 void luxury_needs(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
915 context.compiled_trigger.push_back(uint16_t(trigger::luxury_needs | association_to_trigger_code(a)));
916 } else {
917 err.accumulated_errors += "luxury_needs trigger used in an incorrect scope type " +
918 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
919 std::to_string(line) + ")\n";
920 return;
921 }
922 context.add_float_to_payload(value);
923 }
924 void social_movement_strength(association_type a, float value, error_handler& err, int32_t line,
925 trigger_building_context& context) {
927 context.compiled_trigger.push_back(uint16_t(trigger::social_movement_strength | association_to_trigger_code(a)));
928 } else {
929 err.accumulated_errors += "social_movement_strength trigger used in an incorrect scope type " +
930 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
931 std::to_string(line) + ")\n";
932 return;
933 }
934 context.add_float_to_payload(value);
935 }
936 void political_movement_strength(association_type a, float value, error_handler& err, int32_t line,
937 trigger_building_context& context) {
939 context.compiled_trigger.push_back(uint16_t(trigger::political_movement_strength | association_to_trigger_code(a)));
940 } else {
941 err.accumulated_errors += "political_movement_strength trigger used in an incorrect scope type " +
942 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
943 std::to_string(line) + ")\n";
944 return;
945 }
946 context.add_float_to_payload(value);
947 }
948
949 void total_num_of_ports(association_type a, int32_t value, error_handler& err, int32_t line,
950 trigger_building_context& context) {
952 context.compiled_trigger.push_back(uint16_t(trigger::total_num_of_ports | association_to_trigger_code(a)));
953 } else {
954 err.accumulated_errors += "total_num_of_ports trigger used in an incorrect scope type " +
955 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
956 std::to_string(line) + ")\n";
957 return;
958 }
959 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
960 }
961 void agree_with_ruling_party(association_type a, float value, error_handler& err, int32_t line,
962 trigger_building_context& context) {
964 context.compiled_trigger.push_back(uint16_t(trigger::agree_with_ruling_party | association_to_trigger_code(a)));
965 } else {
966 err.accumulated_errors += "agree_with_ruling_party trigger used in an incorrect scope type " +
967 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
968 std::to_string(line) + ")\n";
969 return;
970 }
971 context.add_float_to_payload(value);
972 }
973 void constructing_cb_progress(association_type a, float value, error_handler& err, int32_t line,
974 trigger_building_context& context) {
976 context.compiled_trigger.push_back(uint16_t(trigger::constructing_cb_progress | association_to_trigger_code(a)));
977 } else {
978 err.accumulated_errors += "constructing_cb_progress trigger used in an incorrect scope type " +
979 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
980 std::to_string(line) + ")\n";
981 return;
982 }
983 context.add_float_to_payload(value);
984 }
985 void civilization_progress(association_type a, float value, error_handler& err, int32_t line,
986 trigger_building_context& context) {
988 context.compiled_trigger.push_back(uint16_t(trigger::civilization_progress | association_to_trigger_code(a)));
989 } else {
990 err.accumulated_errors += "civilization_progress trigger used in an incorrect scope type " +
991 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
992 std::to_string(line) + ")\n";
993 return;
994 }
995 context.add_float_to_payload(value);
996 }
997
998 void rich_strata_life_needs(association_type a, float value, error_handler& err, int32_t line,
999 trigger_building_context& context) {
1001 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_life_needs_nation | association_to_trigger_code(a)));
1002 } else if(context.main_slot == trigger::slot_contents::state) {
1003 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_life_needs_state | association_to_trigger_code(a)));
1004 } else if(context.main_slot == trigger::slot_contents::province) {
1005 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_life_needs_province | association_to_trigger_code(a)));
1006 } else if(context.main_slot == trigger::slot_contents::pop) {
1007 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_life_needs_pop | association_to_trigger_code(a)));
1008 } else {
1009 err.accumulated_errors += "rich_strata_life_needs trigger used in an incorrect scope type " +
1010 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1011 std::to_string(line) + ")\n";
1012 return;
1013 }
1014 context.add_float_to_payload(value);
1015 }
1016 void rich_strata_everyday_needs(association_type a, float value, error_handler& err, int32_t line,
1017 trigger_building_context& context) {
1019 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_everyday_needs_nation | association_to_trigger_code(a)));
1020 } else if(context.main_slot == trigger::slot_contents::state) {
1021 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_everyday_needs_state | association_to_trigger_code(a)));
1022 } else if(context.main_slot == trigger::slot_contents::province) {
1023 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_everyday_needs_province | association_to_trigger_code(a)));
1024 } else if(context.main_slot == trigger::slot_contents::pop) {
1025 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_everyday_needs_pop | association_to_trigger_code(a)));
1026 } else {
1027 err.accumulated_errors += "rich_strata_everyday_needs trigger used in an incorrect scope type " +
1028 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1029 std::to_string(line) + ")\n";
1030 return;
1031 }
1032 context.add_float_to_payload(value);
1033 }
1034 void rich_strata_luxury_needs(association_type a, float value, error_handler& err, int32_t line,
1035 trigger_building_context& context) {
1037 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_luxury_needs_nation | association_to_trigger_code(a)));
1038 } else if(context.main_slot == trigger::slot_contents::state) {
1039 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_luxury_needs_state | association_to_trigger_code(a)));
1040 } else if(context.main_slot == trigger::slot_contents::province) {
1041 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_luxury_needs_province | association_to_trigger_code(a)));
1042 } else if(context.main_slot == trigger::slot_contents::pop) {
1043 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_luxury_needs_pop | association_to_trigger_code(a)));
1044 } else {
1045 err.accumulated_errors += "rich_strata_luxury_needs trigger used in an incorrect scope type " +
1046 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1047 std::to_string(line) + ")\n";
1048 return;
1049 }
1050 context.add_float_to_payload(value);
1051 }
1052
1053 void middle_strata_life_needs(association_type a, float value, error_handler& err, int32_t line,
1054 trigger_building_context& context) {
1056 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_life_needs_nation | association_to_trigger_code(a)));
1057 } else if(context.main_slot == trigger::slot_contents::state) {
1058 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_life_needs_state | association_to_trigger_code(a)));
1059 } else if(context.main_slot == trigger::slot_contents::province) {
1060 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_life_needs_province | association_to_trigger_code(a)));
1061 } else if(context.main_slot == trigger::slot_contents::pop) {
1062 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_life_needs_pop | association_to_trigger_code(a)));
1063 } else {
1064 err.accumulated_errors += "middle_strata_life_needs trigger used in an incorrect scope type " +
1065 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1066 std::to_string(line) + ")\n";
1067 return;
1068 }
1069 context.add_float_to_payload(value);
1070 }
1071 void middle_strata_everyday_needs(association_type a, float value, error_handler& err, int32_t line,
1072 trigger_building_context& context) {
1074 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_everyday_needs_nation | association_to_trigger_code(a)));
1075 } else if(context.main_slot == trigger::slot_contents::state) {
1076 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_everyday_needs_state | association_to_trigger_code(a)));
1077 } else if(context.main_slot == trigger::slot_contents::province) {
1078 context.compiled_trigger.push_back(
1079 uint16_t(trigger::middle_strata_everyday_needs_province | association_to_trigger_code(a)));
1080 } else if(context.main_slot == trigger::slot_contents::pop) {
1081 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_everyday_needs_pop | association_to_trigger_code(a)));
1082 } else {
1083 err.accumulated_errors += "middle_strata_everyday_needs trigger used in an incorrect scope type " +
1084 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1085 std::to_string(line) + ")\n";
1086 return;
1087 }
1088 context.add_float_to_payload(value);
1089 }
1090 void middle_strata_luxury_needs(association_type a, float value, error_handler& err, int32_t line,
1091 trigger_building_context& context) {
1093 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_luxury_needs_nation | association_to_trigger_code(a)));
1094 } else if(context.main_slot == trigger::slot_contents::state) {
1095 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_luxury_needs_state | association_to_trigger_code(a)));
1096 } else if(context.main_slot == trigger::slot_contents::province) {
1097 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_luxury_needs_province | association_to_trigger_code(a)));
1098 } else if(context.main_slot == trigger::slot_contents::pop) {
1099 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_luxury_needs_pop | association_to_trigger_code(a)));
1100 } else {
1101 err.accumulated_errors += "middle_strata_luxury_needs trigger used in an incorrect scope type " +
1102 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1103 std::to_string(line) + ")\n";
1104 return;
1105 }
1106 context.add_float_to_payload(value);
1107 }
1108
1109 void poor_strata_life_needs(association_type a, float value, error_handler& err, int32_t line,
1110 trigger_building_context& context) {
1112 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_life_needs_nation | association_to_trigger_code(a)));
1113 } else if(context.main_slot == trigger::slot_contents::state) {
1114 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_life_needs_state | association_to_trigger_code(a)));
1115 } else if(context.main_slot == trigger::slot_contents::province) {
1116 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_life_needs_province | association_to_trigger_code(a)));
1117 } else if(context.main_slot == trigger::slot_contents::pop) {
1118 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_life_needs_pop | association_to_trigger_code(a)));
1119 } else {
1120 err.accumulated_errors += "poor_strata_life_needs trigger used in an incorrect scope type " +
1121 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1122 std::to_string(line) + ")\n";
1123 return;
1124 }
1125 context.add_float_to_payload(value);
1126 }
1127 void poor_strata_everyday_needs(association_type a, float value, error_handler& err, int32_t line,
1128 trigger_building_context& context) {
1130 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_everyday_needs_nation | association_to_trigger_code(a)));
1131 } else if(context.main_slot == trigger::slot_contents::state) {
1132 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_everyday_needs_state | association_to_trigger_code(a)));
1133 } else if(context.main_slot == trigger::slot_contents::province) {
1134 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_everyday_needs_province | association_to_trigger_code(a)));
1135 } else if(context.main_slot == trigger::slot_contents::pop) {
1136 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_everyday_needs_pop | association_to_trigger_code(a)));
1137 } else {
1138 err.accumulated_errors += "poor_strata_everyday_needs trigger used in an incorrect scope type " +
1139 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1140 std::to_string(line) + ")\n";
1141 return;
1142 }
1143 context.add_float_to_payload(value);
1144 }
1145 void poor_strata_luxury_needs(association_type a, float value, error_handler& err, int32_t line,
1146 trigger_building_context& context) {
1148 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_luxury_needs_nation | association_to_trigger_code(a)));
1149 } else if(context.main_slot == trigger::slot_contents::state) {
1150 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_luxury_needs_state | association_to_trigger_code(a)));
1151 } else if(context.main_slot == trigger::slot_contents::province) {
1152 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_luxury_needs_province | association_to_trigger_code(a)));
1153 } else if(context.main_slot == trigger::slot_contents::pop) {
1154 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_luxury_needs_pop | association_to_trigger_code(a)));
1155 } else {
1156 err.accumulated_errors += "poor_strata_luxury_needs trigger used in an incorrect scope type " +
1157 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1158 std::to_string(line) + ")\n";
1159 return;
1160 }
1161 context.add_float_to_payload(value);
1162 }
1163
1164 void revanchism(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1166 context.compiled_trigger.push_back(uint16_t(trigger::revanchism_nation | association_to_trigger_code(a)));
1167 } else if(context.main_slot == trigger::slot_contents::pop) {
1168 context.compiled_trigger.push_back(uint16_t(trigger::revanchism_pop | association_to_trigger_code(a)));
1169 } else {
1170 err.accumulated_errors += "revanchism trigger used in an incorrect scope type " +
1171 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1172 std::to_string(line) + ")\n";
1173 return;
1174 }
1175 context.add_float_to_payload(value);
1176 }
1177
1178 void poor_strata_militancy(association_type a, float value, error_handler& err, int32_t line,
1179 trigger_building_context& context) {
1181 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_militancy_nation | association_to_trigger_code(a)));
1182 } else if(context.main_slot == trigger::slot_contents::state) {
1183 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_militancy_state | association_to_trigger_code(a)));
1184 } else if(context.main_slot == trigger::slot_contents::province) {
1185 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_militancy_province | association_to_trigger_code(a)));
1186 } else if(context.main_slot == trigger::slot_contents::pop) {
1187 context.compiled_trigger.push_back(uint16_t(trigger::poor_strata_militancy_pop | association_to_trigger_code(a)));
1188 } else {
1189 err.accumulated_errors += "poor_strata_militancy trigger used in an incorrect scope type " +
1190 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1191 std::to_string(line) + ")\n";
1192 return;
1193 }
1194 context.add_float_to_payload(value);
1195 }
1196 void middle_strata_militancy(association_type a, float value, error_handler& err, int32_t line,
1197 trigger_building_context& context) {
1199 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_militancy_nation | association_to_trigger_code(a)));
1200 } else if(context.main_slot == trigger::slot_contents::state) {
1201 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_militancy_state | association_to_trigger_code(a)));
1202 } else if(context.main_slot == trigger::slot_contents::province) {
1203 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_militancy_province | association_to_trigger_code(a)));
1204 } else if(context.main_slot == trigger::slot_contents::pop) {
1205 context.compiled_trigger.push_back(uint16_t(trigger::middle_strata_militancy_pop | association_to_trigger_code(a)));
1206 } else {
1207 err.accumulated_errors += "middle_strata_militancy trigger used in an incorrect scope type " +
1208 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1209 std::to_string(line) + ")\n";
1210 return;
1211 }
1212 context.add_float_to_payload(value);
1213 }
1214 void rich_strata_militancy(association_type a, float value, error_handler& err, int32_t line,
1215 trigger_building_context& context) {
1217 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_militancy_nation | association_to_trigger_code(a)));
1218 } else if(context.main_slot == trigger::slot_contents::state) {
1219 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_militancy_state | association_to_trigger_code(a)));
1220 } else if(context.main_slot == trigger::slot_contents::province) {
1221 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_militancy_province | association_to_trigger_code(a)));
1222 } else if(context.main_slot == trigger::slot_contents::pop) {
1223 context.compiled_trigger.push_back(uint16_t(trigger::rich_strata_militancy_pop | association_to_trigger_code(a)));
1224 } else {
1225 err.accumulated_errors += "rich_strata_militancy trigger used in an incorrect scope type " +
1226 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1227 std::to_string(line) + ")\n";
1228 return;
1229 }
1230 context.add_float_to_payload(value);
1231 }
1232 void consciousness(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1234 context.compiled_trigger.push_back(uint16_t(trigger::consciousness_nation | association_to_trigger_code(a)));
1235 } else if(context.main_slot == trigger::slot_contents::state) {
1236 context.compiled_trigger.push_back(uint16_t(trigger::consciousness_state | association_to_trigger_code(a)));
1237 } else if(context.main_slot == trigger::slot_contents::province) {
1238 context.compiled_trigger.push_back(uint16_t(trigger::consciousness_province | association_to_trigger_code(a)));
1239 } else if(context.main_slot == trigger::slot_contents::pop) {
1240 context.compiled_trigger.push_back(uint16_t(trigger::consciousness_pop | association_to_trigger_code(a)));
1241 } else {
1242 err.accumulated_errors += "consciousness trigger used in an incorrect scope type " +
1243 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1244 std::to_string(line) + ")\n";
1245 return;
1246 }
1247 context.add_float_to_payload(value);
1248 }
1249 void literacy(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1251 context.compiled_trigger.push_back(uint16_t(trigger::literacy_nation | association_to_trigger_code(a)));
1252 } else if(context.main_slot == trigger::slot_contents::state) {
1253 context.compiled_trigger.push_back(uint16_t(trigger::literacy_state | association_to_trigger_code(a)));
1254 } else if(context.main_slot == trigger::slot_contents::province) {
1255 context.compiled_trigger.push_back(uint16_t(trigger::literacy_province | association_to_trigger_code(a)));
1256 } else if(context.main_slot == trigger::slot_contents::pop) {
1257 context.compiled_trigger.push_back(uint16_t(trigger::literacy_pop | association_to_trigger_code(a)));
1258 } else {
1259 err.accumulated_errors += "literacy trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1260 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1261 return;
1262 }
1263 context.add_float_to_payload(value);
1264 }
1265 void militancy(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1267 context.compiled_trigger.push_back(uint16_t(trigger::militancy_nation | association_to_trigger_code(a)));
1268 } else if(context.main_slot == trigger::slot_contents::state) {
1269 context.compiled_trigger.push_back(uint16_t(trigger::militancy_state | association_to_trigger_code(a)));
1270 } else if(context.main_slot == trigger::slot_contents::province) {
1271 context.compiled_trigger.push_back(uint16_t(trigger::militancy_province | association_to_trigger_code(a)));
1272 } else if(context.main_slot == trigger::slot_contents::pop) {
1273 context.compiled_trigger.push_back(uint16_t(trigger::militancy_pop | association_to_trigger_code(a)));
1274 } else {
1275 err.accumulated_errors += "militancy trigger used in an incorrect scope type " +
1276 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1277 std::to_string(line) + ")\n";
1278 return;
1279 }
1280 context.add_float_to_payload(value);
1281 }
1282 void military_spending(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1284 context.compiled_trigger.push_back(uint16_t(trigger::military_spending_nation | association_to_trigger_code(a)));
1285 } else if(context.main_slot == trigger::slot_contents::state) {
1286 context.compiled_trigger.push_back(uint16_t(trigger::military_spending_state | association_to_trigger_code(a)));
1287 } else if(context.main_slot == trigger::slot_contents::province) {
1288 context.compiled_trigger.push_back(uint16_t(trigger::military_spending_province | association_to_trigger_code(a)));
1289 } else if(context.main_slot == trigger::slot_contents::pop) {
1290 context.compiled_trigger.push_back(uint16_t(trigger::military_spending_pop | association_to_trigger_code(a)));
1291 } else {
1292 err.accumulated_errors += "military_spending trigger used in an incorrect scope type " +
1293 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1294 std::to_string(line) + ")\n";
1295 return;
1296 }
1297 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1298 }
1299 void administration_spending(association_type a, float value, error_handler& err, int32_t line,
1300 trigger_building_context& context) {
1302 context.compiled_trigger.push_back(uint16_t(trigger::administration_spending_nation | association_to_trigger_code(a)));
1303 } else if(context.main_slot == trigger::slot_contents::state) {
1304 context.compiled_trigger.push_back(uint16_t(trigger::administration_spending_state | association_to_trigger_code(a)));
1305 } else if(context.main_slot == trigger::slot_contents::province) {
1306 context.compiled_trigger.push_back(uint16_t(trigger::administration_spending_province | association_to_trigger_code(a)));
1307 } else if(context.main_slot == trigger::slot_contents::pop) {
1308 context.compiled_trigger.push_back(uint16_t(trigger::administration_spending_pop | association_to_trigger_code(a)));
1309 } else {
1310 err.accumulated_errors += "administration_spending trigger used in an incorrect scope type " +
1311 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1312 std::to_string(line) + ")\n";
1313 return;
1314 }
1315 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1316 }
1317 void education_spending(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1319 context.compiled_trigger.push_back(uint16_t(trigger::education_spending_nation | association_to_trigger_code(a)));
1320 } else if(context.main_slot == trigger::slot_contents::state) {
1321 context.compiled_trigger.push_back(uint16_t(trigger::education_spending_state | association_to_trigger_code(a)));
1322 } else if(context.main_slot == trigger::slot_contents::province) {
1323 context.compiled_trigger.push_back(uint16_t(trigger::education_spending_province | association_to_trigger_code(a)));
1324 } else if(context.main_slot == trigger::slot_contents::pop) {
1325 context.compiled_trigger.push_back(uint16_t(trigger::education_spending_pop | association_to_trigger_code(a)));
1326 } else {
1327 err.accumulated_errors += "education_spending trigger used in an incorrect scope type " +
1328 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1329 std::to_string(line) + ")\n";
1330 return;
1331 }
1332 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1333 }
1334 void national_provinces_occupied(association_type a, float value, error_handler& err, int32_t line,
1335 trigger_building_context& context) {
1337 context.compiled_trigger.push_back(uint16_t(trigger::national_provinces_occupied | association_to_trigger_code(a)));
1338 } else {
1339 err.accumulated_errors += "national_provinces_occupied trigger used in an incorrect scope type " +
1340 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1341 std::to_string(line) + ")\n";
1342 return;
1343 }
1344 context.add_float_to_payload(value);
1345 }
1346 void social_spending(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1348 context.compiled_trigger.push_back(uint16_t(trigger::social_spending_nation | association_to_trigger_code(a)));
1349 } else if(context.main_slot == trigger::slot_contents::province) {
1350 context.compiled_trigger.push_back(uint16_t(trigger::social_spending_province | association_to_trigger_code(a)));
1351 } else if(context.main_slot == trigger::slot_contents::pop) {
1352 context.compiled_trigger.push_back(uint16_t(trigger::social_spending_pop | association_to_trigger_code(a)));
1353 } else {
1354 err.accumulated_errors += "social_spending trigger used in an incorrect scope type " +
1355 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1356 std::to_string(line) + ")\n";
1357 return;
1358 }
1359 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1360 }
1361 void brigades_compare(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1364 context.compiled_trigger.push_back(uint16_t(trigger::brigades_compare_this | association_to_trigger_code(a)));
1365 } else if(context.from_slot == trigger::slot_contents::nation) {
1366 context.compiled_trigger.push_back(uint16_t(trigger::brigades_compare_from | association_to_trigger_code(a)));
1367 } else {
1368 err.accumulated_errors += "brigades_compare trigger used in an incorrect scope type " +
1369 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1370 std::to_string(line) + ")\n";
1371 return;
1372 }
1373 } else if(context.main_slot == trigger::slot_contents::province) {
1375 context.compiled_trigger.push_back(uint16_t(trigger::brigades_compare_province_this | association_to_trigger_code(a)));
1376 } else if(context.from_slot == trigger::slot_contents::nation) {
1377 context.compiled_trigger.push_back(uint16_t(trigger::brigades_compare_province_from | association_to_trigger_code(a)));
1378 } else {
1379 err.accumulated_errors += "brigades_compare trigger used in an incorrect scope type " +
1380 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1381 std::to_string(line) + ")\n";
1382 return;
1383 }
1384 } else {
1385 err.accumulated_errors += "brigades_compare trigger used in an incorrect scope type " +
1386 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1387 std::to_string(line) + ")\n";
1388 return;
1389 }
1390 context.add_float_to_payload(value);
1391 }
1392 void rich_tax(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1394 context.compiled_trigger.push_back(uint16_t(trigger::rich_tax | association_to_trigger_code(a)));
1395 } else if(context.main_slot == trigger::slot_contents::pop) {
1396 context.compiled_trigger.push_back(uint16_t(trigger::rich_tax_pop | association_to_trigger_code(a)));
1397 } else {
1398 err.accumulated_errors += "rich_tax trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1399 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1400 return;
1401 }
1402 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1403 }
1404 void middle_tax(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1406 context.compiled_trigger.push_back(uint16_t(trigger::middle_tax | association_to_trigger_code(a)));
1407 } else if(context.main_slot == trigger::slot_contents::pop) {
1408 context.compiled_trigger.push_back(uint16_t(trigger::middle_tax_pop | association_to_trigger_code(a)));
1409 } else {
1410 err.accumulated_errors += "middle_tax trigger used in an incorrect scope type " +
1411 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1412 std::to_string(line) + ")\n";
1413 return;
1414 }
1415 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1416 }
1417 void poor_tax(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1419 context.compiled_trigger.push_back(uint16_t(trigger::poor_tax | association_to_trigger_code(a)));
1420 } else if(context.main_slot == trigger::slot_contents::pop) {
1421 context.compiled_trigger.push_back(uint16_t(trigger::poor_tax_pop | association_to_trigger_code(a)));
1422 } else {
1423 err.accumulated_errors += "poor_tax trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1424 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1425 return;
1426 }
1427 context.compiled_trigger.push_back(uint16_t(value * 100.0f));
1428 }
1429 void mobilisation_size(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1431 context.compiled_trigger.push_back(uint16_t(trigger::mobilisation_size | association_to_trigger_code(a)));
1432 } else {
1433 err.accumulated_errors += "mobilisation_size trigger used in an incorrect scope type " +
1434 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1435 std::to_string(line) + ")\n";
1436 return;
1437 }
1438 context.add_float_to_payload(value);
1439 }
1440 void province_id(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
1442 context.compiled_trigger.push_back(uint16_t(trigger::province_id | association_to_bool_code(a)));
1443 } else {
1444 err.accumulated_errors += "province_id trigger used in an incorrect scope type " +
1445 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1446 std::to_string(line) + ")\n";
1447 return;
1448 }
1449 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
1451 } else {
1452 err.accumulated_errors +=
1453 "province_id trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1454 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
1455 }
1456 }
1457 void invention(association_type a, std::string_view value, error_handler& err, int32_t line,
1458 trigger_building_context& context) {
1459
1460 if(auto it = context.outer_context.map_of_technologies.find(std::string(value));
1461 it != context.outer_context.map_of_technologies.end()) {
1463 context.compiled_trigger.push_back(uint16_t(trigger::technology | association_to_bool_code(a)));
1464 } else if(context.main_slot == trigger::slot_contents::province) {
1465 context.compiled_trigger.push_back(uint16_t(trigger::technology_province | association_to_bool_code(a)));
1466 } else if(context.main_slot == trigger::slot_contents::pop) {
1467 context.compiled_trigger.push_back(uint16_t(trigger::technology_pop | association_to_bool_code(a)));
1468 } else {
1469 err.accumulated_errors += "invention trigger used in an incorrect scope type " +
1470 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1471 std::to_string(line) + ")\n";
1472 return;
1473 }
1474
1475 context.compiled_trigger.push_back(uint16_t(1 + 1)); // data size; if no payload add code | trigger_codes::no_payload
1476 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
1477 } else if(auto itb = context.outer_context.map_of_inventions.find(std::string(value));
1478 itb != context.outer_context.map_of_inventions.end()) {
1480 context.compiled_trigger.push_back(uint16_t(trigger::invention | association_to_bool_code(a)));
1481 } else if(context.main_slot == trigger::slot_contents::province) {
1482 context.compiled_trigger.push_back(uint16_t(trigger::invention_province | association_to_bool_code(a)));
1483 } else if(context.main_slot == trigger::slot_contents::pop) {
1484 context.compiled_trigger.push_back(uint16_t(trigger::invention_pop | association_to_bool_code(a)));
1485 } else {
1486 err.accumulated_errors += "invention trigger used in an incorrect scope type " +
1487 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1488 std::to_string(line) + ")\n";
1489 return;
1490 }
1491
1492 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
1493 } else {
1494 err.accumulated_errors += "invention trigger supplied with neither a valid technology nor a valid invention "
1495 + std::string(value) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1496 }
1497 }
1498 void big_producer(association_type a, std::string_view value, error_handler& err, int32_t line,
1499 trigger_building_context& context) {
1500 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(value));
1501 it != context.outer_context.map_of_commodity_names.end()) {
1503 context.compiled_trigger.push_back(uint16_t(trigger::big_producer | association_to_bool_code(a)));
1504 } else {
1505 err.accumulated_errors += "big_producer trigger used in an incorrect scope type " +
1506 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1507 std::to_string(line) + ")\n";
1508 return;
1509 }
1510
1511 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1512 } else {
1513 err.accumulated_errors +=
1514 "big_producer trigger supplied with an invalid commodity \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1515 }
1516 }
1517 void strata(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1518 if(context.main_slot == trigger::slot_contents::pop) {
1519 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "poor"))
1520 context.compiled_trigger.push_back(uint16_t(trigger::strata_poor | trigger::no_payload | association_to_bool_code(a)));
1521 else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "rich"))
1522 context.compiled_trigger.push_back(uint16_t(trigger::strata_rich | trigger::no_payload | association_to_bool_code(a)));
1523 else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "middle"))
1524 context.compiled_trigger.push_back(uint16_t(trigger::strata_middle | trigger::no_payload | association_to_bool_code(a)));
1525 else {
1526 err.accumulated_errors +=
1527 "strata trigger given unknown strata (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1528 return;
1529 }
1530 } else {
1531 err.accumulated_errors += "strata trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1532 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1533 return;
1534 }
1535 }
1536
1537 void life_rating(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
1539 context.compiled_trigger.push_back(uint16_t(trigger::life_rating_province | association_to_trigger_code(a)));
1540 } else if(context.main_slot == trigger::slot_contents::state) {
1541 context.compiled_trigger.push_back(uint16_t(trigger::life_rating_state | association_to_trigger_code(a)));
1542 } else {
1543 err.accumulated_errors += "life_rating trigger used in an incorrect scope type " +
1544 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1545 std::to_string(line) + ")\n";
1546 return;
1547 }
1548 context.compiled_trigger.push_back(trigger::payload(int16_t(value)).value);
1549 }
1550
1551 void has_empty_adjacent_state(association_type a, bool value, error_handler& err, int32_t line,
1552 trigger_building_context& context) {
1554 context.compiled_trigger.push_back(
1555 uint16_t(trigger::has_empty_adjacent_state_province | trigger::no_payload | association_to_bool_code(a, value)));
1556 } else if(context.main_slot == trigger::slot_contents::state) {
1557 context.compiled_trigger.push_back(
1558 uint16_t(trigger::has_empty_adjacent_state_state | trigger::no_payload | association_to_bool_code(a, value)));
1559 } else {
1560 err.accumulated_errors += "has_empty_adjacent_state trigger used in an incorrect scope type " +
1561 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1562 std::to_string(line) + ")\n";
1563 return;
1564 }
1565 }
1566
1567 void state_id(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
1569 context.compiled_trigger.push_back(uint16_t(trigger::state_id_province | association_to_bool_code(a)));
1570 } else if(context.main_slot == trigger::slot_contents::state) {
1571 context.compiled_trigger.push_back(uint16_t(trigger::state_id_state | association_to_bool_code(a)));
1572 } else {
1573 err.accumulated_errors += "state_id trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1574 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1575 return;
1576 }
1577 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
1579 } else {
1580 err.accumulated_errors +=
1581 "state_id trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1582 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
1583 }
1584 }
1585 void cash_reserves(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1586 if(context.main_slot == trigger::slot_contents::pop) {
1587 context.compiled_trigger.push_back(uint16_t(trigger::cash_reserves | association_to_trigger_code(a)));
1588 } else {
1589 err.accumulated_errors += "cash_reserves trigger used in an incorrect scope type " +
1590 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1591 std::to_string(line) + ")\n";
1592 return;
1593 }
1594 context.add_float_to_payload(value);
1595 }
1596 void unemployment(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
1598 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_nation | association_to_trigger_code(a)));
1599 } else if(context.main_slot == trigger::slot_contents::state) {
1600 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_state | association_to_trigger_code(a)));
1601 } else if(context.main_slot == trigger::slot_contents::province) {
1602 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_province | association_to_trigger_code(a)));
1603 } else if(context.main_slot == trigger::slot_contents::pop) {
1604 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_pop | association_to_trigger_code(a)));
1605 } else {
1606 err.accumulated_errors += "unemployment trigger used in an incorrect scope type " +
1607 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1608 std::to_string(line) + ")\n";
1609 return;
1610 }
1611 context.add_float_to_payload(value);
1612 }
1613
1614 void is_slave(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
1616 context.compiled_trigger.push_back(
1617 uint16_t(trigger::is_slave_nation | trigger::no_payload | association_to_bool_code(a, value)));
1618 } else if(context.main_slot == trigger::slot_contents::state) {
1619 context.compiled_trigger.push_back(
1620 uint16_t(trigger::is_slave_state | trigger::no_payload | association_to_bool_code(a, value)));
1621 } else if(context.main_slot == trigger::slot_contents::province) {
1622 context.compiled_trigger.push_back(
1623 uint16_t(trigger::is_slave_province | trigger::no_payload | association_to_bool_code(a, value)));
1624 } else if(context.main_slot == trigger::slot_contents::pop) {
1625 context.compiled_trigger.push_back(
1626 uint16_t(trigger::is_slave_pop | trigger::no_payload | association_to_bool_code(a, value)));
1627 } else {
1628 err.accumulated_errors += "is_slave trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1629 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1630 return;
1631 }
1632 }
1633
1634 void is_independant(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
1636 context.compiled_trigger.push_back(
1637 uint16_t(trigger::is_independant | trigger::no_payload | association_to_bool_code(a, value)));
1638 } else {
1639 err.accumulated_errors += "is_independant trigger used in an incorrect scope type " +
1640 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1641 std::to_string(line) + ")\n";
1642 return;
1643 }
1644 }
1645
1646 void has_national_minority(association_type a, bool value, error_handler& err, int32_t line,
1647 trigger_building_context& context) {
1649 context.compiled_trigger.push_back(
1650 uint16_t(trigger::has_national_minority_nation | trigger::no_payload | association_to_bool_code(a, value)));
1651 } else if(context.main_slot == trigger::slot_contents::state) {
1652 context.compiled_trigger.push_back(
1653 uint16_t(trigger::has_national_minority_state | trigger::no_payload | association_to_bool_code(a, value)));
1654 } else if(context.main_slot == trigger::slot_contents::province) {
1655 context.compiled_trigger.push_back(
1656 uint16_t(trigger::has_national_minority_province | trigger::no_payload | association_to_bool_code(a, value)));
1657 } else {
1658 err.accumulated_errors += "has_national_minority trigger used in an incorrect scope type " +
1659 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1660 std::to_string(line) + ")\n";
1661 return;
1662 }
1663 }
1664
1665 void government(association_type a, std::string_view value, error_handler& err, int32_t line,
1666 trigger_building_context& context) {
1667 if(auto it = context.outer_context.map_of_governments.find(std::string(value));
1668 it != context.outer_context.map_of_governments.end()) {
1670 context.compiled_trigger.push_back(uint16_t(trigger::government_nation | association_to_bool_code(a)));
1671 } else if(context.main_slot == trigger::slot_contents::pop) {
1672 context.compiled_trigger.push_back(uint16_t(trigger::government_pop | association_to_bool_code(a)));
1673 } else {
1674 err.accumulated_errors += "government trigger used in an incorrect scope type " +
1675 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1676 std::to_string(line) + ")\n";
1677 return;
1678 }
1679
1680 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1681 } else {
1682 err.accumulated_errors += "government trigger supplied with an invalid government type \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1683 std::to_string(line) + ")\n";
1684 }
1685 }
1686
1687 void constructing_cb_type(association_type a, std::string_view value, error_handler& err, int32_t line,
1688 trigger_building_context& context) {
1689 if(auto it = context.outer_context.map_of_cb_types.find(std::string(value));
1690 it != context.outer_context.map_of_cb_types.end()) {
1692 context.compiled_trigger.push_back(uint16_t(trigger::constructing_cb_type | association_to_bool_code(a)));
1693 } else {
1694 err.accumulated_errors += "constructing_cb_type trigger used in an incorrect scope type " +
1695 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1696 std::to_string(line) + ")\n";
1697 return;
1698 }
1699
1700 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
1701 } else {
1702 err.accumulated_errors += "constructing_cb_type trigger supplied with an invalid cb type \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1703 std::to_string(line) + ")\n";
1704 }
1705 }
1706
1707 void can_build_factory_in_capital_state(association_type a, std::string_view value, error_handler& err, int32_t line,
1708 trigger_building_context& context) {
1709 if(auto it = context.outer_context.map_of_factory_names.find(std::string(value));
1710 it != context.outer_context.map_of_factory_names.end()) {
1712 context.compiled_trigger.push_back(uint16_t(trigger::can_build_factory_in_capital_state | association_to_bool_code(a)));
1713 } else {
1714 err.accumulated_errors += "can_build_factory_in_capital_state trigger used in an incorrect scope type " +
1715 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1716 std::to_string(line) + ")\n";
1717 return;
1718 }
1719
1720 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1721 } else {
1722 err.accumulated_errors += "can_build_factory_in_capital_state trigger supplied with an government type (" + err.file_name +
1723 ", line " + std::to_string(line) + ")\n";
1724 }
1725 }
1726 void capital(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
1728 context.compiled_trigger.push_back(uint16_t(trigger::capital | association_to_bool_code(a)));
1729 } else {
1730 err.accumulated_errors += "capital trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
1731 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1732 return;
1733 }
1734 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
1736 } else {
1737 err.accumulated_errors +=
1738 "capital trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1739 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
1740 }
1741 }
1742 void tech_school(association_type a, std::string_view value, error_handler& err, int32_t line,
1743 trigger_building_context& context) {
1744 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
1745 it != context.outer_context.map_of_modifiers.end()) {
1747 context.compiled_trigger.push_back(uint16_t(trigger::tech_school | association_to_bool_code(a)));
1748 } else {
1749 err.accumulated_errors += "tech_school trigger used in an incorrect scope type " +
1750 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1751 std::to_string(line) + ")\n";
1752 return;
1753 }
1754
1755 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1756 } else {
1757 err.accumulated_errors +=
1758 "tech_school trigger supplied with an invalid school \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1759 }
1760 }
1761 void primary_culture(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1762 if(is_this(value)) {
1765 context.compiled_trigger.push_back(
1766 uint16_t(trigger::is_primary_culture_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
1767 } else if(context.this_slot == trigger::slot_contents::state) {
1768 context.compiled_trigger.push_back(
1769 uint16_t(trigger::is_primary_culture_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
1770 } else if(context.this_slot == trigger::slot_contents::province) {
1771 context.compiled_trigger.push_back(
1772 uint16_t(trigger::is_primary_culture_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
1773 } else if(context.this_slot == trigger::slot_contents::pop) {
1774 context.compiled_trigger.push_back(
1775 uint16_t(trigger::is_primary_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
1776 } else {
1777 err.accumulated_errors += "primary_culture trigger used in an incorrect scope type " +
1778 slot_contents_to_string(context.this_slot) + "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
1779 return;
1780 }
1781 } else {
1782 err.accumulated_errors += "primary_culture = this trigger used in an incorrect scope type " +
1783 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1784 return;
1785 }
1786 } else if(is_from(value)) {
1788 context.compiled_trigger.push_back(
1789 uint16_t(trigger::primary_culture_from_nation | trigger::no_payload | association_to_bool_code(a)));
1791 context.compiled_trigger.push_back(
1792 uint16_t(trigger::primary_culture_from_province | trigger::no_payload | association_to_bool_code(a)));
1793 else {
1794 err.accumulated_errors += "primary_culture = from trigger used in an incorrect scope type " +
1795 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1796 std::to_string(line) + ")\n";
1797 return;
1798 }
1799 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value)); it != context.outer_context.map_of_culture_names.end()) {
1801 context.compiled_trigger.push_back(uint16_t(trigger::primary_culture | association_to_bool_code(a)));
1802 } else if(context.main_slot == trigger::slot_contents::pop) {
1803 context.compiled_trigger.push_back(uint16_t(trigger::primary_culture_pop | association_to_bool_code(a)));
1804 } else {
1805 err.accumulated_errors += "primary_culture trigger used in an incorrect scope type " +
1806 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1807 return;
1808 }
1809
1810 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1811 } else {
1812 err.accumulated_errors +=
1813 "primary_culture trigger supplied with an invalid culture \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1814 }
1815 }
1816 void total_sunk_by_us(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
1817 // this is a trigger we don't support currently, not even in trigger codes
1818 context.compiled_trigger.push_back(uint16_t(trigger::always | trigger::no_payload | association_to_trigger_code(a)));
1819 }
1820 void has_crime(association_type a, std::string_view value, error_handler& err, int32_t line,
1821 trigger_building_context& context) {
1822 if(auto it = context.outer_context.map_of_crimes.find(std::string(value)); it != context.outer_context.map_of_crimes.end()) {
1824 context.compiled_trigger.push_back(uint16_t(trigger::has_crime | association_to_bool_code(a)));
1825 } else {
1826 err.accumulated_errors += "has_crime trigger used in an incorrect scope type " +
1827 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1828 std::to_string(line) + ")\n";
1829 return;
1830 }
1831
1832 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
1833 } else {
1834 err.accumulated_errors +=
1835 "has_crime trigger supplied with an invalid crime \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1836 }
1837 }
1838 void accepted_culture(association_type a, std::string_view value, error_handler& err, int32_t line,
1839 trigger_building_context& context) {
1840 if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
1841 it != context.outer_context.map_of_culture_names.end()) {
1843 context.compiled_trigger.push_back(uint16_t(trigger::accepted_culture | association_to_bool_code(a)));
1844 } else {
1845 err.accumulated_errors += "accepted_culture trigger used in an incorrect scope type " +
1846 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1847 std::to_string(line) + ")\n";
1848 return;
1849 }
1850
1851 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1852 } else {
1853 err.accumulated_errors += "accepted_culture trigger supplied with an invalid culture \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1854 std::to_string(line) + ")\n";
1855 }
1856 }
1857 void pop_majority_religion(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1858 if(is_this(value)) {
1860 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_religion_nation_this_nation | association_to_bool_code(a)));
1861 } else {
1862 err.accumulated_errors += "pop_majority_religion = THIS trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1863 return;
1864 }
1865 } else if(auto it = context.outer_context.map_of_religion_names.find(std::string(value)); it != context.outer_context.map_of_religion_names.end()) {
1867 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_religion_nation | association_to_bool_code(a)));
1868 } else if(context.main_slot == trigger::slot_contents::state) {
1869 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_religion_state | association_to_bool_code(a)));
1870 } else if(context.main_slot == trigger::slot_contents::province) {
1871 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_religion_province | association_to_bool_code(a)));
1872 } else {
1873 err.accumulated_errors += "pop_majority_religion trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
1874 return;
1875 }
1876 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1877 } else {
1878 err.accumulated_errors += "pop_majority_religion trigger supplied with an invalid religion \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1879 std::to_string(line) + ")\n";
1880 }
1881 }
1882 void pop_majority_culture(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1883 if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
1884 it != context.outer_context.map_of_culture_names.end()) {
1886 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_culture_nation | association_to_bool_code(a)));
1887 } else if(context.main_slot == trigger::slot_contents::state) {
1888 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_culture_state | association_to_bool_code(a)));
1889 } else if(context.main_slot == trigger::slot_contents::province) {
1890 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_culture_province | association_to_bool_code(a)));
1891 } else {
1892 err.accumulated_errors += "pop_majority_culture trigger used in an incorrect scope type " +
1893 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1894 std::to_string(line) + ")\n";
1895 return;
1896 }
1897 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1898 } else {
1899 err.accumulated_errors += "pop_majority_culture trigger supplied with an invalid culture \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1900 std::to_string(line) + ")\n";
1901 }
1902 }
1903 void pop_majority_issue(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1904 if(auto it = context.outer_context.map_of_ioptions.find(std::string(value));
1905 it != context.outer_context.map_of_ioptions.end()) {
1907 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_issue_nation | association_to_bool_code(a)));
1908 } else if(context.main_slot == trigger::slot_contents::state) {
1909 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_issue_state | association_to_bool_code(a)));
1910 } else if(context.main_slot == trigger::slot_contents::province) {
1911 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_issue_province | association_to_bool_code(a)));
1912 } else if(context.main_slot == trigger::slot_contents::pop) {
1913 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_issue_pop | association_to_bool_code(a)));
1914 } else {
1915 err.accumulated_errors += "pop_majority_issue trigger used in an incorrect scope type " +
1916 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1917 std::to_string(line) + ")\n";
1918 return;
1919 }
1920 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
1921 } else {
1922 err.accumulated_errors += "pop_majority_issue trigger supplied with an invalid option name \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1923 std::to_string(line) + ")\n";
1924 }
1925 }
1926 void pop_majority_ideology(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1927 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
1928 it != context.outer_context.map_of_ideologies.end()) {
1930 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_ideology_nation | association_to_bool_code(a)));
1931 } else if(context.main_slot == trigger::slot_contents::state) {
1932 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_ideology_state | association_to_bool_code(a)));
1933 } else if(context.main_slot == trigger::slot_contents::province) {
1934 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_ideology_province | association_to_bool_code(a)));
1935 } else if(context.main_slot == trigger::slot_contents::pop) {
1936 context.compiled_trigger.push_back(uint16_t(trigger::pop_majority_ideology_pop | association_to_bool_code(a)));
1937 } else {
1938 err.accumulated_errors += "pop_majority_ideology trigger used in an incorrect scope type " +
1939 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1940 std::to_string(line) + ")\n";
1941 return;
1942 }
1943 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
1944 } else {
1945 err.accumulated_errors += "pop_majority_ideology trigger supplied with an invalid ideology \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1946 std::to_string(line) + ")\n";
1947 }
1948 }
1949 void trade_goods_in_state(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1950 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(value));
1951 it != context.outer_context.map_of_commodity_names.end()) {
1953 context.compiled_trigger.push_back(uint16_t(trigger::trade_goods_in_state_state | association_to_bool_code(a)));
1954 } else if(context.main_slot == trigger::slot_contents::province) {
1955 context.compiled_trigger.push_back(uint16_t(trigger::trade_goods_in_state_province | association_to_bool_code(a)));
1956 } else {
1957 err.accumulated_errors += "trade_goods_in_state trigger used in an incorrect scope type " +
1958 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
1959 std::to_string(line) + ")\n";
1960 return;
1961 }
1962 context.compiled_trigger.push_back(trigger::payload(it->second).value);
1963 } else {
1964 err.accumulated_errors += "trade_goods_in_state trigger supplied with an invalid commodity \"" + std::string(value) + "\" (" + err.file_name + ", line " +
1965 std::to_string(line) + ")\n";
1966 }
1967 }
1968
1969 void culture(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
1970 if(is_this(value)) {
1971 if(context.main_slot == trigger::slot_contents::pop) {
1973 context.compiled_trigger.push_back((trigger::culture_this_nation | trigger::no_payload | association_to_bool_code(a)));
1974 } else if(context.this_slot == trigger::slot_contents::state) {
1975 context.compiled_trigger.push_back(uint16_t(trigger::culture_this_state | trigger::no_payload | association_to_bool_code(a)));
1976 } else if(context.this_slot == trigger::slot_contents::province) {
1977 context.compiled_trigger.push_back(uint16_t(trigger::culture_this_province | trigger::no_payload | association_to_bool_code(a)));
1978 } else if(context.this_slot == trigger::slot_contents::pop) {
1979 context.compiled_trigger.push_back(uint16_t(trigger::culture_this_pop | trigger::no_payload | association_to_bool_code(a)));
1980 } else {
1981 err.accumulated_errors += "culture trigger used in an incorrect scope type " +
1982 slot_contents_to_string(context.this_slot) + "(" + err.file_name + ", line " +
1983 std::to_string(line) + ")\n";
1984 return;
1985 }
1986 } else if(context.main_slot == trigger::slot_contents::province) {
1988 context.compiled_trigger.push_back((trigger::is_primary_culture_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
1989 } else if(context.this_slot == trigger::slot_contents::state) {
1990 context.compiled_trigger.push_back(uint16_t(trigger::is_primary_culture_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
1991 } else if(context.this_slot == trigger::slot_contents::province) {
1992 context.compiled_trigger.push_back(uint16_t(trigger::is_primary_culture_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
1993 } else if(context.this_slot == trigger::slot_contents::pop) {
1994 context.compiled_trigger.push_back(uint16_t(trigger::is_primary_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
1995 } else {
1996 err.accumulated_errors += "culture trigger used in an incorrect scope type " +
1997 slot_contents_to_string(context.this_slot) + "(" + err.file_name + ", line " +
1998 std::to_string(line) + ")\n";
1999 return;
2000 }
2001 } else {
2002 err.accumulated_errors += "culture = this trigger used in an incorrect scope type " +
2003 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2004 std::to_string(line) + ")\n";
2005 return;
2006 }
2007 } else if(is_from(value)) {
2009 context.compiled_trigger.push_back(
2010 uint16_t(trigger::culture_from_nation | trigger::no_payload | association_to_bool_code(a)));
2011 else {
2012 err.accumulated_errors += "culture = from trigger used in an incorrect scope type " +
2013 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2014 std::to_string(line) + ")\n";
2015 return;
2016 }
2017 } else if(is_reb(value)) {
2019 err.accumulated_errors += "culture = reb trigger used in an incorrect scope type " +
2020 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2021 std::to_string(line) + ")\n";
2022 return;
2023 } else if(context.main_slot == trigger::slot_contents::pop)
2024 context.compiled_trigger.push_back(
2025 uint16_t(trigger::culture_pop_reb | trigger::no_payload | association_to_bool_code(a)));
2026 else if(context.main_slot == trigger::slot_contents::state)
2027 context.compiled_trigger.push_back(
2028 uint16_t(trigger::culture_state_reb | trigger::no_payload | association_to_bool_code(a)));
2030 context.compiled_trigger.push_back(
2031 uint16_t(trigger::culture_province_reb | trigger::no_payload | association_to_bool_code(a)));
2032 else if(context.main_slot == trigger::slot_contents::nation)
2033 context.compiled_trigger.push_back(
2034 uint16_t(trigger::culture_nation_reb | trigger::no_payload | association_to_bool_code(a)));
2035 else {
2036 err.accumulated_errors += "culture = reb trigger used in an incorrect scope type " +
2037 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2038 std::to_string(line) + ")\n";
2039 return;
2040 }
2041 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value)); it != context.outer_context.map_of_culture_names.end()) {
2043 context.compiled_trigger.push_back(uint16_t(trigger::culture_nation | association_to_bool_code(a)));
2044 } else if(context.main_slot == trigger::slot_contents::state) {
2045 context.compiled_trigger.push_back(uint16_t(trigger::culture_state | association_to_bool_code(a)));
2046 } else if(context.main_slot == trigger::slot_contents::province) {
2047 context.compiled_trigger.push_back(uint16_t(trigger::culture_province | association_to_bool_code(a)));
2048 } else if(context.main_slot == trigger::slot_contents::pop) {
2049 context.compiled_trigger.push_back(uint16_t(trigger::culture_pop | association_to_bool_code(a)));
2050 } else {
2051 err.accumulated_errors += "culture trigger used in an incorrect scope type " +
2052 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2053 std::to_string(line) + ")\n";
2054 return;
2055 }
2056 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2057 } else {
2058 err.accumulated_errors +=
2059 "culture trigger supplied with an invalid culture \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2060 }
2061 }
2062 void has_pop_culture(association_type a, std::string_view value, error_handler& err, int32_t line,
2063 trigger_building_context& context) {
2064 if(is_this(value)) {
2065 if(context.this_slot == trigger::slot_contents::pop) {
2067 context.compiled_trigger.push_back(
2068 uint16_t(trigger::has_pop_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
2069 else if(context.main_slot == trigger::slot_contents::pop)
2070 context.compiled_trigger.push_back(
2071 uint16_t(trigger::has_pop_culture_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
2072 else if(context.main_slot == trigger::slot_contents::state)
2073 context.compiled_trigger.push_back(
2074 uint16_t(trigger::has_pop_culture_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
2076 context.compiled_trigger.push_back(
2077 uint16_t(trigger::has_pop_culture_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
2078 else {
2079 err.accumulated_errors += "has_pop_culture = this trigger used in an incorrect scope type " +
2080 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2081 std::to_string(line) + ")\n";
2082 return;
2083 }
2084 } else {
2085 err.accumulated_errors += "has_pop_culture = this trigger used in an incorrect scope type " +
2086 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2087 std::to_string(line) + ")\n";
2088 return;
2089 }
2090 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value));
2091 it != context.outer_context.map_of_culture_names.end()) {
2093 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_culture_nation | association_to_bool_code(a)));
2094 } else if(context.main_slot == trigger::slot_contents::state) {
2095 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_culture_state | association_to_bool_code(a)));
2096 } else if(context.main_slot == trigger::slot_contents::province) {
2097 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_culture_province | association_to_bool_code(a)));
2098 } else if(context.main_slot == trigger::slot_contents::pop) {
2099 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_culture_pop | association_to_bool_code(a)));
2100 } else {
2101 err.accumulated_errors += "has_pop_culture trigger used in an incorrect scope type " +
2102 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2103 std::to_string(line) + ")\n";
2104 return;
2105 }
2106 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2107 } else {
2108 err.accumulated_errors +=
2109 "has_pop_culture trigger supplied with an invalid culture \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2110 }
2111 }
2112 void has_pop_religion(association_type a, std::string_view value, error_handler& err, int32_t line,
2113 trigger_building_context& context) {
2114 if(is_this(value)) {
2115 if(context.this_slot == trigger::slot_contents::pop) {
2117 context.compiled_trigger.push_back(
2118 uint16_t(trigger::has_pop_religion_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
2119 else if(context.main_slot == trigger::slot_contents::pop)
2120 context.compiled_trigger.push_back(
2121 uint16_t(trigger::has_pop_religion_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
2122 else if(context.main_slot == trigger::slot_contents::state)
2123 context.compiled_trigger.push_back(
2124 uint16_t(trigger::has_pop_religion_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
2126 context.compiled_trigger.push_back(
2127 uint16_t(trigger::has_pop_religion_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
2128 else {
2129 err.accumulated_errors += "has_pop_religion = this trigger used in an incorrect scope type " +
2130 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2131 std::to_string(line) + ")\n";
2132 return;
2133 }
2134 } else {
2135 err.accumulated_errors += "has_pop_religion = this trigger used in an incorrect scope type " +
2136 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2137 std::to_string(line) + ")\n";
2138 return;
2139 }
2140 } else if(auto it = context.outer_context.map_of_religion_names.find(std::string(value));
2141 it != context.outer_context.map_of_religion_names.end()) {
2143 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_religion_nation | association_to_bool_code(a)));
2144 } else if(context.main_slot == trigger::slot_contents::state) {
2145 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_religion_state | association_to_bool_code(a)));
2146 } else if(context.main_slot == trigger::slot_contents::province) {
2147 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_religion_province | association_to_bool_code(a)));
2148 } else if(context.main_slot == trigger::slot_contents::pop) {
2149 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_religion_pop | association_to_bool_code(a)));
2150 } else {
2151 err.accumulated_errors += "has_pop_religion trigger used in an incorrect scope type " +
2152 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2153 std::to_string(line) + ")\n";
2154 return;
2155 }
2156 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2157 } else {
2158 err.accumulated_errors += "has_pop_religion trigger supplied with an invalid religion \"" + std::string(value) + "\" (" + err.file_name + ", line " +
2159 std::to_string(line) + ")\n";
2160 }
2161 }
2162
2163 void culture_group(association_type a, std::string_view value, error_handler& err, int32_t line,
2164 trigger_building_context& context) {
2165 if(is_this(value)) {
2168 context.compiled_trigger.push_back(
2169 uint16_t(trigger::culture_group_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
2170 else if(context.main_slot == trigger::slot_contents::pop)
2171 context.compiled_trigger.push_back(
2172 uint16_t(trigger::culture_group_pop_this_nation | trigger::no_payload | association_to_bool_code(a)));
2173 else {
2174 err.accumulated_errors += "culture_group = this trigger used in an incorrect scope type " +
2175 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2176 std::to_string(line) + ")\n";
2177 return;
2178 }
2179 } else if(context.this_slot == trigger::slot_contents::state) {
2181 context.compiled_trigger.push_back(
2182 uint16_t(trigger::culture_group_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
2183 else if(context.main_slot == trigger::slot_contents::pop)
2184 context.compiled_trigger.push_back(
2185 uint16_t(trigger::culture_group_pop_this_state | trigger::no_payload | association_to_bool_code(a)));
2186 else {
2187 err.accumulated_errors += "culture_group = this trigger used in an incorrect scope type " +
2188 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2189 std::to_string(line) + ")\n";
2190 return;
2191 }
2192 } else if(context.this_slot == trigger::slot_contents::province) {
2194 context.compiled_trigger.push_back(
2195 uint16_t(trigger::culture_group_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
2196 else if(context.main_slot == trigger::slot_contents::pop)
2197 context.compiled_trigger.push_back(
2198 uint16_t(trigger::culture_group_pop_this_province | trigger::no_payload | association_to_bool_code(a)));
2199 else {
2200 err.accumulated_errors += "culture_group = this trigger used in an incorrect scope type " +
2201 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2202 std::to_string(line) + ")\n";
2203 return;
2204 }
2205 } else if(context.this_slot == trigger::slot_contents::pop) {
2207 context.compiled_trigger.push_back(
2208 uint16_t(trigger::culture_group_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
2209 else if(context.main_slot == trigger::slot_contents::pop)
2210 context.compiled_trigger.push_back(
2211 uint16_t(trigger::culture_group_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
2212 else {
2213 err.accumulated_errors += "culture_group = this trigger used in an incorrect scope type " +
2214 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2215 std::to_string(line) + ")\n";
2216 return;
2217 }
2218 } else {
2219 err.accumulated_errors += "culture_group = this trigger used in an incorrect scope type " +
2220 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2221 std::to_string(line) + ")\n";
2222 return;
2223 }
2224 } else if(is_from(value)) {
2227 context.compiled_trigger.push_back(
2228 uint16_t(trigger::culture_group_nation_from_nation | trigger::no_payload | association_to_bool_code(a)));
2229 else if(context.main_slot == trigger::slot_contents::pop)
2230 context.compiled_trigger.push_back(
2231 uint16_t(trigger::culture_group_pop_from_nation | trigger::no_payload | association_to_bool_code(a)));
2232 else {
2233 err.accumulated_errors += "culture_group = from trigger used in an incorrect scope type " +
2234 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2235 std::to_string(line) + ")\n";
2236 return;
2237 }
2238 } else {
2239 err.accumulated_errors += "culture_group = from trigger used in an incorrect scope type " +
2240 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2241 std::to_string(line) + ")\n";
2242 return;
2243 }
2244 } else if(is_reb(value)) {
2247 context.compiled_trigger.push_back(
2248 uint16_t(trigger::culture_group_reb_nation | trigger::no_payload | association_to_bool_code(a)));
2249 else if(context.main_slot == trigger::slot_contents::pop)
2250 context.compiled_trigger.push_back(
2251 uint16_t(trigger::culture_group_reb_pop | trigger::no_payload | association_to_bool_code(a)));
2252 else {
2253 err.accumulated_errors += "culture_group = reb trigger used in an incorrect scope type " +
2254 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2255 std::to_string(line) + ")\n";
2256 return;
2257 }
2258 } else {
2259 err.accumulated_errors += "culture_group = reb trigger used in an incorrect scope type " +
2260 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2261 std::to_string(line) + ")\n";
2262 return;
2263 }
2264 } else if(auto it = context.outer_context.map_of_culture_group_names.find(std::string(value));
2265 it != context.outer_context.map_of_culture_group_names.end()) {
2267 context.compiled_trigger.push_back(uint16_t(trigger::culture_group_nation | association_to_bool_code(a)));
2268 } else if(context.main_slot == trigger::slot_contents::pop) {
2269 context.compiled_trigger.push_back(uint16_t(trigger::culture_group_pop | association_to_bool_code(a)));
2270 } else if(context.main_slot == trigger::slot_contents::province) {
2271 context.compiled_trigger.push_back(uint16_t(trigger::culture_group_province | association_to_bool_code(a)));
2272 } else if(context.main_slot == trigger::slot_contents::state) {
2273 context.compiled_trigger.push_back(uint16_t(trigger::culture_group_state | association_to_bool_code(a)));
2274 } else {
2275 err.accumulated_errors += "culture_group trigger used in an incorrect scope type " +
2276 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2277 std::to_string(line) + ")\n";
2278 return;
2279 }
2280 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2281 } else {
2282 err.accumulated_errors += "culture_group trigger supplied with an invalid culture group \"" + std::string(value) + "\" (" + err.file_name + ", line " +
2283 std::to_string(line) + ")\n";
2284 }
2285 }
2286
2287 void religion(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2288 if(is_this(value)) {
2291 context.compiled_trigger.push_back(
2292 uint16_t(trigger::religion_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
2293 else if(context.main_slot == trigger::slot_contents::pop)
2294 context.compiled_trigger.push_back(
2295 uint16_t(trigger::religion_this_nation | trigger::no_payload | association_to_bool_code(a)));
2296 else {
2297 err.accumulated_errors += "religion = this trigger used in an incorrect scope type " +
2298 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2299 std::to_string(line) + ")\n";
2300 return;
2301 }
2302 } else if(context.this_slot == trigger::slot_contents::state) {
2304 context.compiled_trigger.push_back(
2305 uint16_t(trigger::religion_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
2306 else if(context.main_slot == trigger::slot_contents::pop)
2307 context.compiled_trigger.push_back(
2308 uint16_t(trigger::religion_this_state | trigger::no_payload | association_to_bool_code(a)));
2309 else {
2310 err.accumulated_errors += "religion = this trigger used in an incorrect scope type " +
2311 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2312 std::to_string(line) + ")\n";
2313 return;
2314 }
2315 } else if(context.this_slot == trigger::slot_contents::province) {
2317 context.compiled_trigger.push_back(
2318 uint16_t(trigger::religion_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
2319 else if(context.main_slot == trigger::slot_contents::pop)
2320 context.compiled_trigger.push_back(
2321 uint16_t(trigger::religion_this_province | trigger::no_payload | association_to_bool_code(a)));
2322 else {
2323 err.accumulated_errors += "religion = this trigger used in an incorrect scope type " +
2324 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2325 std::to_string(line) + ")\n";
2326 return;
2327 }
2328 } else if(context.this_slot == trigger::slot_contents::pop) {
2330 context.compiled_trigger.push_back(
2331 uint16_t(trigger::religion_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
2332 else if(context.main_slot == trigger::slot_contents::pop)
2333 context.compiled_trigger.push_back(
2334 uint16_t(trigger::religion_this_pop | trigger::no_payload | association_to_bool_code(a)));
2335 else {
2336 err.accumulated_errors += "religion = this trigger used in an incorrect scope type " +
2337 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2338 std::to_string(line) + ")\n";
2339 return;
2340 }
2341 } else {
2342 err.accumulated_errors += "religion = this trigger used in an incorrect scope type " +
2343 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2344 std::to_string(line) + ")\n";
2345 return;
2346 }
2347 } else if(is_from(value)) {
2350 context.compiled_trigger.push_back(
2351 uint16_t(trigger::religion_nation_from_nation | trigger::no_payload | association_to_bool_code(a)));
2352 else if(context.main_slot == trigger::slot_contents::pop)
2353 context.compiled_trigger.push_back(
2354 uint16_t(trigger::religion_from_nation | trigger::no_payload | association_to_bool_code(a)));
2355 else {
2356 err.accumulated_errors += "religion = from trigger used in an incorrect scope type " +
2357 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2358 std::to_string(line) + ")\n";
2359 return;
2360 }
2361 } else {
2362 err.accumulated_errors += "religion = from trigger used in an incorrect scope type " +
2363 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2364 std::to_string(line) + ")\n";
2365 return;
2366 }
2367 } else if(is_reb(value)) {
2370 context.compiled_trigger.push_back(
2371 uint16_t(trigger::religion_nation_reb | trigger::no_payload | association_to_bool_code(a)));
2372 else if(context.main_slot == trigger::slot_contents::pop)
2373 context.compiled_trigger.push_back(uint16_t(trigger::religion_reb | trigger::no_payload | association_to_bool_code(a)));
2374 else {
2375 err.accumulated_errors += "religion = reb trigger used in an incorrect scope type " +
2376 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2377 std::to_string(line) + ")\n";
2378 return;
2379 }
2380 } else {
2381 err.accumulated_errors += "religion = reb trigger used in an incorrect scope type " +
2382 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2383 std::to_string(line) + ")\n";
2384 return;
2385 }
2386 } else if(auto it = context.outer_context.map_of_religion_names.find(std::string(value));
2387 it != context.outer_context.map_of_religion_names.end()) {
2389 context.compiled_trigger.push_back(uint16_t(trigger::religion_nation | association_to_bool_code(a)));
2390 } else if(context.main_slot == trigger::slot_contents::pop) {
2391 context.compiled_trigger.push_back(uint16_t(trigger::religion | association_to_bool_code(a)));
2392 } else {
2393 err.accumulated_errors += "religion trigger used in an incorrect scope type " +
2394 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2395 std::to_string(line) + ")\n";
2396 return;
2397 }
2398 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2399 } else {
2400 err.accumulated_errors +=
2401 "religion trigger supplied with an invalid religion \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2402 }
2403 }
2404 void terrain(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2405 if(auto it = context.outer_context.map_of_terrain_types.find(std::string(value));
2406 it != context.outer_context.map_of_terrain_types.end()) {
2407 if(context.main_slot == trigger::slot_contents::pop) {
2408 context.compiled_trigger.push_back(uint16_t(trigger::terrain_pop | association_to_bool_code(a)));
2409 } else if(context.main_slot == trigger::slot_contents::province) {
2410 context.compiled_trigger.push_back(uint16_t(trigger::terrain_province | association_to_bool_code(a)));
2411 } else {
2412 err.accumulated_errors += "terrain trigger used in an incorrect scope type " +
2413 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2414 std::to_string(line) + ")\n";
2415 return;
2416 }
2417 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
2418 } else {
2419 err.accumulated_errors +=
2420 "terrain trigger supplied with an invalid terrain \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2421 }
2422 }
2423 void trade_goods(association_type a, std::string_view value, error_handler& err, int32_t line,
2424 trigger_building_context& context) {
2425 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(value));
2426 it != context.outer_context.map_of_commodity_names.end()) {
2428 context.compiled_trigger.push_back(uint16_t(trigger::trade_goods | association_to_bool_code(a)));
2429 } else {
2430 err.accumulated_errors += "trade_goods trigger used in an incorrect scope type " +
2431 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2432 std::to_string(line) + ")\n";
2433 return;
2434 }
2435 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2436 } else {
2437 err.accumulated_errors +=
2438 "trade_goods trigger supplied with an invalid commodity \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2439 }
2440 }
2441 void is_secondary_power(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
2443 context.compiled_trigger.push_back(
2444 uint16_t(trigger::is_secondary_power_nation | trigger::no_payload | association_to_bool_code(a, value)));
2445 } else if(context.main_slot == trigger::slot_contents::pop) {
2446 context.compiled_trigger.push_back(
2447 uint16_t(trigger::is_secondary_power_pop | trigger::no_payload | association_to_bool_code(a, value)));
2448 } else {
2449 err.accumulated_errors += "is_secondary_power trigger used in an incorrect scope type " +
2450 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2451 std::to_string(line) + ")\n";
2452 return;
2453 }
2454 }
2455 void has_faction(association_type a, std::string_view value, error_handler& err, int32_t line,
2456 trigger_building_context& context) {
2457 if(auto it = context.outer_context.map_of_rebeltypes.find(std::string(value));
2458 it != context.outer_context.map_of_rebeltypes.end()) {
2460 context.compiled_trigger.push_back(uint16_t(trigger::has_faction_nation | association_to_bool_code(a)));
2461 } else if(context.main_slot == trigger::slot_contents::pop) {
2462 context.compiled_trigger.push_back(uint16_t(trigger::has_faction_pop | association_to_bool_code(a)));
2463 } else {
2464 err.accumulated_errors += "has_faction trigger used in an incorrect scope type " +
2465 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2466 std::to_string(line) + ")\n";
2467 return;
2468 }
2469 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
2470 } else {
2471 err.accumulated_errors +=
2472 "has_faction trigger supplied with an invalid rebel type \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2473 }
2474 }
2475 void has_unclaimed_cores(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
2477 context.compiled_trigger.push_back(
2478 uint16_t(trigger::has_unclaimed_cores | trigger::no_payload | association_to_bool_code(a, value)));
2479 } else {
2480 err.accumulated_errors += "has_unclaimed_cores trigger used in an incorrect scope type " +
2481 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2482 std::to_string(line) + ")\n";
2483 return;
2484 }
2485 }
2486 void have_core_in(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2487 if(is_this(value)) {
2489 context.compiled_trigger.push_back(uint16_t(trigger::have_core_in_nation_this | association_to_bool_code(a)));
2490 } else {
2491 err.accumulated_errors += "have_core_in = this trigger used in an incorrect scope type " +
2492 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2493 std::to_string(line) + ")\n";
2494 return;
2495 }
2496 } else if(is_from(value)) {
2498 context.compiled_trigger.push_back(uint16_t(trigger::have_core_in_nation_from | association_to_bool_code(a)));
2499 } else {
2500 err.accumulated_errors += "have_core_in = from trigger used in an incorrect scope type " +
2501 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2502 std::to_string(line) + ")\n";
2503 return;
2504 }
2505 } else if(value.length() == 3) {
2506 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2507 it != context.outer_context.map_of_ident_names.end()) {
2508
2510 context.compiled_trigger.push_back(uint16_t(trigger::have_core_in_nation_tag | association_to_bool_code(a)));
2511 else {
2512 err.accumulated_errors += "have_core_in = tag trigger used in an incorrect scope type " +
2513 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2514 std::to_string(line) + ")\n";
2515 return;
2516 }
2517 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2518 } else {
2519 err.accumulated_errors +=
2520 "have_core_in trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2521 }
2522 } else {
2523 err.accumulated_errors +=
2524 "have_core_in trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2525 }
2526 }
2527 void is_cultural_union(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2528 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "yes") || is_fixed_token_ci(value.data(), value.data() + value.length(), "no")) {
2530 context.compiled_trigger.push_back(uint16_t(
2531 trigger::is_cultural_union_bool | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
2532 else {
2533 err.accumulated_errors += "is_cultural_union = bool trigger used in an incorrect scope type " +
2534 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2535 std::to_string(line) + ")\n";
2536 return;
2537 }
2538 } else if(is_this(value)) {
2540 context.compiled_trigger.push_back(
2541 uint16_t(trigger::is_cultural_union_this_self_pop | trigger::no_payload | association_to_bool_code(a)));
2543 context.compiled_trigger.push_back(
2544 uint16_t(trigger::is_cultural_union_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
2545 else if(context.main_slot == trigger::slot_contents::nation) {
2547 context.compiled_trigger.push_back(
2548 uint16_t(trigger::is_cultural_union_this_pop | trigger::no_payload | association_to_bool_code(a)));
2549 else if(context.this_slot == trigger::slot_contents::state)
2550 context.compiled_trigger.push_back(
2551 uint16_t(trigger::is_cultural_union_this_state | trigger::no_payload | association_to_bool_code(a)));
2553 context.compiled_trigger.push_back(
2554 uint16_t(trigger::is_cultural_union_this_province | trigger::no_payload | association_to_bool_code(a)));
2555 else if(context.this_slot == trigger::slot_contents::nation)
2556 context.compiled_trigger.push_back(
2557 uint16_t(trigger::is_cultural_union_this_nation | trigger::no_payload | association_to_bool_code(a)));
2558 else if(context.from_slot == trigger::slot_contents::rebel)
2559 context.compiled_trigger.push_back(
2560 uint16_t(trigger::is_cultural_union_this_rebel | trigger::no_payload | association_to_bool_code(a)));
2561 else {
2562 err.accumulated_errors += "is_cultural_union = this trigger used in an incorrect scope type " +
2563 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2564 std::to_string(line) + ")\n";
2565 return;
2566 }
2567 } else {
2568 err.accumulated_errors += "is_cultural_union = this trigger used in an incorrect scope type " +
2569 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2570 std::to_string(line) + ")\n";
2571 return;
2572 }
2573 } else if(value.length() == 3) {
2574 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2575 it != context.outer_context.map_of_ident_names.end()) {
2576
2578 context.compiled_trigger.push_back(uint16_t(trigger::is_cultural_union_tag_nation | association_to_bool_code(a)));
2579 else if(context.this_slot == trigger::slot_contents::pop)
2580 context.compiled_trigger.push_back(uint16_t(trigger::is_cultural_union_tag_this_pop | association_to_bool_code(a)));
2581 else if(context.this_slot == trigger::slot_contents::state)
2582 context.compiled_trigger.push_back(uint16_t(trigger::is_cultural_union_tag_this_state | association_to_bool_code(a)));
2584 context.compiled_trigger.push_back(
2585 uint16_t(trigger::is_cultural_union_tag_this_province | association_to_bool_code(a)));
2586 else if(context.this_slot == trigger::slot_contents::nation)
2587 context.compiled_trigger.push_back(uint16_t(trigger::is_cultural_union_tag_this_nation | association_to_bool_code(a)));
2588 else {
2589 err.accumulated_errors += "is_cultural_union = tag trigger used in an incorrect scope type " +
2590 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2591 std::to_string(line) + ")\n";
2592 return;
2593 }
2594 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2595 } else {
2596 err.accumulated_errors +=
2597 "is_cultural_union trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2598 }
2599 } else {
2600 err.accumulated_errors +=
2601 "is_cultural_union trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2602 }
2603 }
2604 void can_build_factory(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
2606 context.compiled_trigger.push_back(
2607 uint16_t(trigger::can_build_factory_nation | trigger::no_payload | association_to_bool_code(a, value)));
2608 } else if(context.main_slot == trigger::slot_contents::province) {
2609 context.compiled_trigger.push_back(
2610 uint16_t(trigger::can_build_factory_province | trigger::no_payload | association_to_bool_code(a, value)));
2611 } else if(context.main_slot == trigger::slot_contents::pop) {
2612 context.compiled_trigger.push_back(
2613 uint16_t(trigger::can_build_factory_pop | trigger::no_payload | association_to_bool_code(a, value)));
2614 } else {
2615 err.accumulated_errors += "can_build_factory trigger used in an incorrect scope type " +
2616 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2617 std::to_string(line) + ")\n";
2618 return;
2619 }
2620 }
2621 void war(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
2623 context.compiled_trigger.push_back(
2624 uint16_t(trigger::war_nation | trigger::no_payload | association_to_bool_code(a, value)));
2625 } else if(context.main_slot == trigger::slot_contents::pop) {
2626 context.compiled_trigger.push_back(uint16_t(trigger::war_pop | trigger::no_payload | association_to_bool_code(a, value)));
2627 } else {
2628 err.accumulated_errors += "war trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2629 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2630 return;
2631 }
2632 }
2633 void war_exhaustion(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
2635 context.compiled_trigger.push_back(uint16_t(trigger::war_exhaustion_nation | association_to_trigger_code(a)));
2636 } else if(context.main_slot == trigger::slot_contents::province) {
2637 context.compiled_trigger.push_back(uint16_t(trigger::war_exhaustion_province | association_to_trigger_code(a)));
2638 } else if(context.main_slot == trigger::slot_contents::pop) {
2639 context.compiled_trigger.push_back(uint16_t(trigger::war_exhaustion_pop | association_to_trigger_code(a)));
2640 } else {
2641 err.accumulated_errors += "war_exhaustion trigger used in an incorrect scope type " +
2642 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2643 std::to_string(line) + ")\n";
2644 return;
2645 }
2646 context.add_float_to_payload(value / 100.0f);
2647 }
2648 void blockade(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
2650 context.compiled_trigger.push_back(uint16_t(trigger::blockade | association_to_trigger_code(a)));
2651 } else {
2652 err.accumulated_errors += "blockade trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2653 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2654 return;
2655 }
2656 context.add_float_to_payload(value);
2657 }
2658 void owns(association_type a, std::string_view v, error_handler& err, int32_t line, trigger_building_context& context) {
2659 if(is_integer(v.data(), v.data() + v.length())) {
2660 auto value = parse_int(v, line, err);
2662 context.compiled_trigger.push_back(uint16_t(trigger::owns | association_to_bool_code(a)));
2663 } else if(context.main_slot == trigger::slot_contents::province) {
2664 context.compiled_trigger.push_back(uint16_t(trigger::owns_province | association_to_bool_code(a)));
2665 } else {
2666 err.accumulated_errors += "owns trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2667 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2668 return;
2669 }
2670 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
2672 } else {
2673 err.accumulated_errors +=
2674 "owns trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2675 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2676 }
2677 } else if(auto it = context.outer_context.map_of_state_names.find(std::string(v)); it != context.outer_context.map_of_state_names.end()) {
2679 context.compiled_trigger.push_back(uint16_t(trigger::owns_region | association_to_bool_code(a)));
2680 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2681 } else {
2682 err.accumulated_errors += "owns trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2683 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2684 return;
2685 }
2686 } else if(auto it = context.outer_context.map_of_region_names.find(std::string(v)); it != context.outer_context.map_of_region_names.end()) {
2688 context.compiled_trigger.push_back(uint16_t(trigger::owns_region_proper | association_to_bool_code(a)));
2689 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2690 } else {
2691 err.accumulated_errors += "owns trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2692 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2693 return;
2694 }
2695 } else {
2696 err.accumulated_errors +=
2697 "owns trigger given an invalid value (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2698 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2699 }
2700 }
2701 void controls(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2703 context.compiled_trigger.push_back(uint16_t(trigger::controls | association_to_bool_code(a)));
2704 } else {
2705 err.accumulated_errors += "controls trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2706 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2707 return;
2708 }
2709 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
2711 } else {
2712 err.accumulated_errors +=
2713 "controls trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2714 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2715 }
2716 }
2717
2718 void is_core(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2719 if(is_this(value) && context.main_slot == trigger::slot_contents::province) {
2721 context.compiled_trigger.push_back(
2722 uint16_t(trigger::is_core_this_nation | trigger::no_payload | association_to_bool_code(a)));
2723 } else if(context.this_slot == trigger::slot_contents::state) {
2724 context.compiled_trigger.push_back(
2725 uint16_t(trigger::is_core_this_state | trigger::no_payload | association_to_bool_code(a)));
2726 } else if(context.this_slot == trigger::slot_contents::province) {
2727 context.compiled_trigger.push_back(
2728 uint16_t(trigger::is_core_this_province | trigger::no_payload | association_to_bool_code(a)));
2729 } else if(context.this_slot == trigger::slot_contents::pop) {
2730 context.compiled_trigger.push_back(
2731 uint16_t(trigger::is_core_this_pop | trigger::no_payload | association_to_bool_code(a)));
2732 } else {
2733 err.accumulated_errors += "is_core = this trigger used in an incorrect scope type " +
2734 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2735 std::to_string(line) + ")\n";
2736 return;
2737 }
2738 } else if(is_from(value) && context.main_slot == trigger::slot_contents::province) {
2740 context.compiled_trigger.push_back(
2741 uint16_t(trigger::is_core_from_nation | trigger::no_payload | association_to_bool_code(a)));
2742 } else {
2743 err.accumulated_errors += "is_core = from trigger used in an incorrect scope type " +
2744 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2745 std::to_string(line) + ")\n";
2746 return;
2747 }
2748 } else if(is_this(value) && context.main_slot == trigger::slot_contents::state) {
2750 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
2751 } else if(context.this_slot == trigger::slot_contents::province) {
2752 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_this_province | trigger::no_payload | association_to_bool_code(a)));
2753 } else if(context.this_slot == trigger::slot_contents::pop) {
2754 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
2755 } else {
2756 err.accumulated_errors += "is_core = this trigger used in an incorrect scope type " +
2757 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2758 std::to_string(line) + ")\n";
2759 return;
2760 }
2761 } else if(is_from(value) && context.main_slot == trigger::slot_contents::state) {
2763 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_from_nation | trigger::no_payload | association_to_bool_code(a)));
2764 } else {
2765 err.accumulated_errors += "is_core = from trigger used in an incorrect scope type " +
2766 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2767 std::to_string(line) + ")\n";
2768 return;
2769 }
2770 } else if(is_reb(value) && context.main_slot == trigger::slot_contents::province) {
2772 context.compiled_trigger.push_back(uint16_t(trigger::is_core_reb | trigger::no_payload | association_to_bool_code(a)));
2773 } else {
2774 err.accumulated_errors += "is_core = reb trigger used in an incorrect scope type " +
2775 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2776 std::to_string(line) + ")\n";
2777 return;
2778 }
2779 } else if(is_integer(value.data(), value.data() + value.length())) {
2781 auto int_value = parse_int(value, line, err);
2782 if(0 <= int_value && size_t(int_value) < context.outer_context.original_id_to_prov_id_map.size()) {
2783 context.compiled_trigger.push_back(uint16_t(trigger::is_core_integer | association_to_bool_code(a)));
2785 } else {
2786 err.accumulated_errors +=
2787 "owns trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2788 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2789 }
2790 } else {
2791 err.accumulated_errors += "is_core trigger used in an incorrect scope type " +
2792 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2793 std::to_string(line) + ")\n";
2794 return;
2795 }
2796 } else if(context.main_slot == trigger::slot_contents::province && (is_fixed_token_ci(value.data(), value.data() + value.length(), "yes") || is_fixed_token_ci(value.data(), value.data() + value.length(), "no"))) {
2797 context.compiled_trigger.push_back(uint16_t(trigger::is_core_boolean | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
2798 } else if(value.length() == 3 && context.main_slot == trigger::slot_contents::province) {
2799 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2])); it != context.outer_context.map_of_ident_names.end()) {
2800 context.compiled_trigger.push_back(uint16_t(trigger::is_core_tag | association_to_bool_code(a)));
2801 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2802 } else {
2803 err.accumulated_errors +=
2804 "is_core trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2805 }
2806 } else if(value.length() == 3 && context.main_slot == trigger::slot_contents::state) {
2807 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2])); it != context.outer_context.map_of_ident_names.end()) {
2808 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_tag | association_to_bool_code(a)));
2809 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2810 } else {
2811 err.accumulated_errors +=
2812 "is_core trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2813 }
2814 } else if(value.length() == 3 && context.main_slot == trigger::slot_contents::pop) {
2815 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2])); it != context.outer_context.map_of_ident_names.end()) {
2816 context.compiled_trigger.push_back(uint16_t(trigger::is_core_pop_tag | association_to_bool_code(a)));
2817 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2818 } else {
2819 err.accumulated_errors +=
2820 "is_core trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2821 }
2822 } else {
2823 err.accumulated_errors +=
2824 "is_core trigger supplied with an invalid argument \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2825 }
2826 }
2827 void num_of_revolts(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2829 context.compiled_trigger.push_back(uint16_t(trigger::num_of_revolts | association_to_trigger_code(a)));
2830 } else {
2831 err.accumulated_errors += "num_of_revolts trigger used in an incorrect scope type " +
2832 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2833 std::to_string(line) + ")\n";
2834 return;
2835 }
2836 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2837 }
2838 void revolt_percentage(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
2840 context.compiled_trigger.push_back(uint16_t(trigger::revolt_percentage | association_to_trigger_code(a)));
2841 } else {
2842 err.accumulated_errors += "revolt_percentage trigger used in an incorrect scope type " +
2843 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2844 std::to_string(line) + ")\n";
2845 return;
2846 }
2847 context.add_float_to_payload(value);
2848 }
2849 void num_of_cities(association_type a, std::string_view value, error_handler& err, int32_t line,
2850 trigger_building_context& context) {
2851 if(is_this(value) && context.main_slot == trigger::slot_contents::nation) {
2853 context.compiled_trigger.push_back(
2854 uint16_t(trigger::num_of_cities_this_nation | trigger::no_payload | association_to_trigger_code(a)));
2855 } else if(context.this_slot == trigger::slot_contents::state) {
2856 context.compiled_trigger.push_back(
2857 uint16_t(trigger::num_of_cities_this_province | trigger::no_payload | association_to_trigger_code(a)));
2858 } else if(context.this_slot == trigger::slot_contents::province) {
2859 context.compiled_trigger.push_back(
2860 uint16_t(trigger::num_of_cities_this_state | trigger::no_payload | association_to_trigger_code(a)));
2861 } else if(context.this_slot == trigger::slot_contents::pop) {
2862 context.compiled_trigger.push_back(
2863 uint16_t(trigger::num_of_cities_this_pop | trigger::no_payload | association_to_trigger_code(a)));
2864 } else {
2865 err.accumulated_errors += "num_of_cities = this trigger used in an incorrect scope type " +
2866 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2867 std::to_string(line) + ")\n";
2868 return;
2869 }
2870 } else if(is_from(value) && context.main_slot == trigger::slot_contents::nation) {
2872 context.compiled_trigger.push_back(
2873 uint16_t(trigger::num_of_cities_from_nation | trigger::no_payload | association_to_trigger_code(a)));
2874 } else {
2875 err.accumulated_errors += "num_of_cities = from trigger used in an incorrect scope type " +
2876 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2877 std::to_string(line) + ")\n";
2878 return;
2879 }
2880 } else if(context.main_slot == trigger::slot_contents::nation) {
2881 context.compiled_trigger.push_back(uint16_t(trigger::num_of_cities_int | association_to_trigger_code(a)));
2882 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
2883 } else {
2884 err.accumulated_errors += "num_of_cities trigger used in an incorrect scope type " +
2885 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2886 std::to_string(line) + ")\n";
2887 return;
2888 }
2889 }
2890 void num_of_ports(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2892 context.compiled_trigger.push_back(uint16_t(trigger::num_of_ports | association_to_trigger_code(a)));
2893 } else {
2894 err.accumulated_errors += "num_of_ports trigger used in an incorrect scope type " +
2895 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2896 std::to_string(line) + ")\n";
2897 return;
2898 }
2899 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2900 }
2901 void num_of_allies(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2903 context.compiled_trigger.push_back(uint16_t(trigger::num_of_allies | association_to_trigger_code(a)));
2904 } else {
2905 err.accumulated_errors += "num_of_allies trigger used in an incorrect scope type " +
2906 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2907 std::to_string(line) + ")\n";
2908 return;
2909 }
2910 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2911 }
2912 void num_of_vassals(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2914 context.compiled_trigger.push_back(uint16_t(trigger::num_of_vassals | association_to_trigger_code(a)));
2915 } else {
2916 err.accumulated_errors += "num_of_vassals trigger used in an incorrect scope type " +
2917 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2918 std::to_string(line) + ")\n";
2919 return;
2920 }
2921 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2922 }
2923 void owned_by(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2925 if(is_this(value)) {
2927 context.compiled_trigger.push_back(
2928 uint16_t(trigger::owned_by_this_pop | trigger::no_payload | association_to_bool_code(a)));
2929 else if(context.this_slot == trigger::slot_contents::state)
2930 context.compiled_trigger.push_back(
2931 uint16_t(trigger::owned_by_this_state | trigger::no_payload | association_to_bool_code(a)));
2933 context.compiled_trigger.push_back(
2934 uint16_t(trigger::owned_by_this_province | trigger::no_payload | association_to_bool_code(a)));
2935 else if(context.this_slot == trigger::slot_contents::nation)
2936 context.compiled_trigger.push_back(
2937 uint16_t(trigger::owned_by_this_nation | trigger::no_payload | association_to_bool_code(a)));
2938 else {
2939 err.accumulated_errors += "owned_by = this trigger used in an incorrect scope type " +
2940 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2941 std::to_string(line) + ")\n";
2942 return;
2943 }
2944 } else if(is_from(value)) {
2946 context.compiled_trigger.push_back(
2947 uint16_t(trigger::owned_by_from_nation | trigger::no_payload | association_to_bool_code(a)));
2948 else {
2949 err.accumulated_errors += "owned_by = from trigger used in an incorrect scope type " +
2950 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2951 std::to_string(line) + ")\n";
2952 return;
2953 }
2954 } else if(value.length() == 3) {
2955 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2956 it != context.outer_context.map_of_ident_names.end()) {
2957 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_tag | association_to_bool_code(a)));
2958 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2959 } else {
2960 err.accumulated_errors +=
2961 "owned_by trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2962 }
2963 } else {
2964 err.accumulated_errors +=
2965 "owned_by trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2966 return;
2967 }
2968 } else if(context.main_slot == trigger::slot_contents::state) {
2969 if(is_this(value)) {
2971 context.compiled_trigger.push_back(
2972 uint16_t(trigger::owned_by_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
2973 else if(context.this_slot == trigger::slot_contents::state)
2974 context.compiled_trigger.push_back(
2975 uint16_t(trigger::owned_by_state_this_state | trigger::no_payload | association_to_bool_code(a)));
2977 context.compiled_trigger.push_back(
2978 uint16_t(trigger::owned_by_state_this_province | trigger::no_payload | association_to_bool_code(a)));
2979 else if(context.this_slot == trigger::slot_contents::nation)
2980 context.compiled_trigger.push_back(
2981 uint16_t(trigger::owned_by_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
2982 else {
2983 err.accumulated_errors += "owned_by = this trigger used in an incorrect scope type " +
2984 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2985 std::to_string(line) + ")\n";
2986 return;
2987 }
2988 } else if(is_from(value)) {
2990 context.compiled_trigger.push_back(
2991 uint16_t(trigger::owned_by_state_from_nation | trigger::no_payload | association_to_bool_code(a)));
2992 else {
2993 err.accumulated_errors += "owned_by = from trigger used in an incorrect scope type " +
2994 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2995 std::to_string(line) + ")\n";
2996 return;
2997 }
2998 } else if(value.length() == 3) {
2999 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3000 it != context.outer_context.map_of_ident_names.end()) {
3001 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_tag | association_to_bool_code(a)));
3002 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3003 } else {
3004 err.accumulated_errors +=
3005 "owned_by trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3006 }
3007 } else {
3008 err.accumulated_errors +=
3009 "owned_by trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3010 return;
3011 }
3012 } else {
3013 err.accumulated_errors += "owned_by trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3014 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3015 return;
3016 }
3017 }
3018
3019 void exists(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3020 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "yes") ||
3021 is_fixed_token_ci(value.data(), value.data() + value.length(), "no")) {
3023 context.compiled_trigger.push_back(
3024 uint16_t(trigger::exists_bool | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
3025 else {
3026 err.accumulated_errors += "exists = bool trigger used in an incorrect scope type " +
3027 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3028 std::to_string(line) + ")\n";
3029 return;
3030 }
3031 } else if(value.length() == 3) {
3032 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3033 it != context.outer_context.map_of_ident_names.end()) {
3034 context.compiled_trigger.push_back(uint16_t(trigger::exists_tag | association_to_bool_code(a)));
3035 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3036 } else {
3037 err.accumulated_errors +=
3038 "exists trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3039 }
3040
3041 } else {
3042 err.accumulated_errors +=
3043 "exists trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3044 return;
3045 }
3046 }
3047 void has_country_flag(association_type a, std::string_view value, error_handler& err, int32_t line,
3048 trigger_building_context& context) {
3050 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag | association_to_bool_code(a)));
3051 } else if(context.main_slot == trigger::slot_contents::pop) {
3052 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag_pop | association_to_bool_code(a)));
3053 } else if(context.main_slot == trigger::slot_contents::province) {
3054 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag_province | association_to_bool_code(a)));
3055 } else if(context.main_slot == trigger::slot_contents::state) {
3056 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag_state | association_to_bool_code(a)));
3057 } else {
3058 err.accumulated_errors += "has_country_flag trigger used in an incorrect scope type " +
3059 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3060 std::to_string(line) + ")\n";
3061 return;
3062 }
3063 context.compiled_trigger.push_back(trigger::payload(context.outer_context.get_national_flag(std::string(value))).value);
3064 }
3065 void has_global_flag(association_type a, std::string_view value, error_handler& err, int32_t line,
3066 trigger_building_context& context) {
3067 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "project_alice")) {
3068 context.compiled_trigger.push_back(uint16_t(trigger::always | trigger::no_payload | association_to_bool_code(a, true)));
3069 } else {
3070 context.compiled_trigger.push_back(uint16_t(trigger::has_global_flag | association_to_bool_code(a)));
3071 context.compiled_trigger.push_back(trigger::payload(context.outer_context.get_global_flag(std::string(value))).value);
3072 }
3073 }
3074
3075 void continent(association_type a, std::string_view value, error_handler& err, int32_t line,
3076 trigger_building_context& context) {
3078 if(is_this(value)) {
3080 context.compiled_trigger.push_back(
3081 uint16_t(trigger::continent_nation_this | trigger::no_payload | association_to_bool_code(a)));
3082 } else {
3083 err.accumulated_errors += "continent = this trigger used in an incorrect scope type " +
3084 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3085 std::to_string(line) + ")\n";
3086 return;
3087 }
3088 } else if(is_from(value)) {
3090 context.compiled_trigger.push_back(
3091 uint16_t(trigger::continent_nation_from | trigger::no_payload | association_to_bool_code(a)));
3092 } else {
3093 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3094 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3095 std::to_string(line) + ")\n";
3096 return;
3097 }
3098 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3099 it != context.outer_context.map_of_modifiers.end()) {
3100 context.compiled_trigger.push_back(uint16_t(trigger::continent_nation | association_to_bool_code(a)));
3101 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3102 } else {
3103 err.accumulated_errors +=
3104 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3105 return;
3106 }
3107 } else if(context.main_slot == trigger::slot_contents::state) {
3108 if(is_this(value)) {
3110 context.compiled_trigger.push_back(
3111 uint16_t(trigger::continent_state_this | trigger::no_payload | association_to_bool_code(a)));
3112 } else {
3113 err.accumulated_errors += "continent = this trigger used in an incorrect scope type " +
3114 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3115 std::to_string(line) + ")\n";
3116 return;
3117 }
3118 } else if(is_from(value)) {
3120 context.compiled_trigger.push_back(
3121 uint16_t(trigger::continent_state_from | trigger::no_payload | association_to_bool_code(a)));
3122 } else {
3123 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3124 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3125 std::to_string(line) + ")\n";
3126 return;
3127 }
3128 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3129 it != context.outer_context.map_of_modifiers.end()) {
3130 context.compiled_trigger.push_back(uint16_t(trigger::continent_state | association_to_bool_code(a)));
3131 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3132 } else {
3133 err.accumulated_errors +=
3134 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3135 return;
3136 }
3137 } else if(context.main_slot == trigger::slot_contents::province) {
3138 if(is_this(value)) {
3140 context.compiled_trigger.push_back(
3141 uint16_t(trigger::continent_province_this | trigger::no_payload | association_to_bool_code(a)));
3142 } else {
3143 err.accumulated_errors += "continent = this trigger used in an incorrect scope type " +
3144 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3145 std::to_string(line) + ")\n";
3146 return;
3147 }
3148 } else if(is_from(value)) {
3150 context.compiled_trigger.push_back(
3151 uint16_t(trigger::continent_province_from | trigger::no_payload | association_to_bool_code(a)));
3152 } else {
3153 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3154 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3155 std::to_string(line) + ")\n";
3156 return;
3157 }
3158 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3159 it != context.outer_context.map_of_modifiers.end()) {
3160 context.compiled_trigger.push_back(uint16_t(trigger::continent_province | association_to_bool_code(a)));
3161 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3162 } else {
3163 err.accumulated_errors +=
3164 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3165 return;
3166 }
3167 } else if(context.main_slot == trigger::slot_contents::pop) {
3168 if(is_this(value)) {
3170 context.compiled_trigger.push_back(
3171 uint16_t(trigger::continent_pop_this | trigger::no_payload | association_to_bool_code(a)));
3172 } else {
3173 err.accumulated_errors += "continent = this trigger used in an incorrect scope type " +
3174 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3175 std::to_string(line) + ")\n";
3176 return;
3177 }
3178 } else if(is_from(value)) {
3180 context.compiled_trigger.push_back(
3181 uint16_t(trigger::continent_pop_from | trigger::no_payload | association_to_bool_code(a)));
3182 } else {
3183 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3184 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3185 std::to_string(line) + ")\n";
3186 return;
3187 }
3188 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3189 it != context.outer_context.map_of_modifiers.end()) {
3190 context.compiled_trigger.push_back(uint16_t(trigger::continent_pop | association_to_bool_code(a)));
3191 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3192 } else {
3193 err.accumulated_errors +=
3194 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3195 return;
3196 }
3197 } else {
3198 err.accumulated_errors += "continent trigger used in an incorrect scope type " +
3199 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3200 std::to_string(line) + ")\n";
3201 return;
3202 }
3203 }
3204 void casus_belli(association_type a, std::string_view value, error_handler& err, int32_t line,
3205 trigger_building_context& context) {
3207 if(is_this(value)) {
3209 context.compiled_trigger.push_back(
3210 uint16_t(trigger::casus_belli_this_pop | trigger::no_payload | association_to_bool_code(a)));
3211 else if(context.this_slot == trigger::slot_contents::state)
3212 context.compiled_trigger.push_back(
3213 uint16_t(trigger::casus_belli_this_state | trigger::no_payload | association_to_bool_code(a)));
3215 context.compiled_trigger.push_back(
3216 uint16_t(trigger::casus_belli_this_province | trigger::no_payload | association_to_bool_code(a)));
3217 else if(context.this_slot == trigger::slot_contents::nation)
3218 context.compiled_trigger.push_back(
3219 uint16_t(trigger::casus_belli_this_nation | trigger::no_payload | association_to_bool_code(a)));
3220 else {
3221 err.accumulated_errors += "casus_belli = this trigger used in an incorrect scope type " +
3222 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3223 std::to_string(line) + ")\n";
3224 return;
3225 }
3226 } else if(is_from(value)) {
3228 context.compiled_trigger.push_back(
3229 uint16_t(trigger::casus_belli_from | trigger::no_payload | association_to_bool_code(a)));
3230 else {
3231 err.accumulated_errors += "casus_belli = from trigger used in an incorrect scope type " +
3232 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3233 std::to_string(line) + ")\n";
3234 return;
3235 }
3236 } else if(value.length() == 3) {
3237 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3238 it != context.outer_context.map_of_ident_names.end()) {
3239 context.compiled_trigger.push_back(uint16_t(trigger::casus_belli_tag | association_to_bool_code(a)));
3240 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3241 } else {
3242 err.accumulated_errors +=
3243 "casus_belli trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3244 }
3245 } else {
3246 err.accumulated_errors +=
3247 "casus_belli trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3248 return;
3249 }
3250 } else {
3251 err.accumulated_errors += "casus_belli trigger used in an incorrect scope type " +
3252 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3253 std::to_string(line) + ")\n";
3254 return;
3255 }
3256 }
3257
3258 void military_access(association_type a, std::string_view value, error_handler& err, int32_t line,
3259 trigger_building_context& context) {
3261 if(is_this(value)) {
3263 context.compiled_trigger.push_back(
3264 uint16_t(trigger::military_access_this_pop | trigger::no_payload | association_to_bool_code(a)));
3265 else if(context.this_slot == trigger::slot_contents::state)
3266 context.compiled_trigger.push_back(
3267 uint16_t(trigger::military_access_this_state | trigger::no_payload | association_to_bool_code(a)));
3269 context.compiled_trigger.push_back(
3270 uint16_t(trigger::military_access_this_province | trigger::no_payload | association_to_bool_code(a)));
3271 else if(context.this_slot == trigger::slot_contents::nation)
3272 context.compiled_trigger.push_back(
3273 uint16_t(trigger::military_access_this_nation | trigger::no_payload | association_to_bool_code(a)));
3274 else {
3275 err.accumulated_errors += "military_access = this trigger used in an incorrect scope type " +
3276 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3277 std::to_string(line) + ")\n";
3278 return;
3279 }
3280 } else if(is_from(value)) {
3282 context.compiled_trigger.push_back(
3283 uint16_t(trigger::military_access_from | trigger::no_payload | association_to_bool_code(a)));
3284 else {
3285 err.accumulated_errors += "military_access = from trigger used in an incorrect scope type " +
3286 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3287 std::to_string(line) + ")\n";
3288 return;
3289 }
3290 } else if(value.length() == 3) {
3291 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3292 it != context.outer_context.map_of_ident_names.end()) {
3293 context.compiled_trigger.push_back(uint16_t(trigger::military_access_tag | association_to_bool_code(a)));
3294 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3295 } else {
3296 err.accumulated_errors +=
3297 "military_access trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3298 }
3299 } else {
3300 err.accumulated_errors +=
3301 "military_access trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3302 return;
3303 }
3304 } else {
3305 err.accumulated_errors += "military_access trigger used in an incorrect scope type " +
3306 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3307 std::to_string(line) + ")\n";
3308 return;
3309 }
3310 }
3311
3312 void prestige(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3314 if(is_this(value)) {
3316 context.compiled_trigger.push_back(
3317 uint16_t(trigger::prestige_this_pop | trigger::no_payload | association_to_trigger_code(a)));
3318 else if(context.this_slot == trigger::slot_contents::state)
3319 context.compiled_trigger.push_back(
3320 uint16_t(trigger::prestige_this_state | trigger::no_payload | association_to_trigger_code(a)));
3322 context.compiled_trigger.push_back(
3323 uint16_t(trigger::prestige_this_province | trigger::no_payload | association_to_trigger_code(a)));
3324 else if(context.this_slot == trigger::slot_contents::nation)
3325 context.compiled_trigger.push_back(
3326 uint16_t(trigger::prestige_this_nation | trigger::no_payload | association_to_trigger_code(a)));
3327 else {
3328 err.accumulated_errors += "prestige = this trigger used in an incorrect scope type " +
3329 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3330 std::to_string(line) + ")\n";
3331 return;
3332 }
3333 } else if(is_from(value)) {
3335 context.compiled_trigger.push_back(
3336 uint16_t(trigger::prestige_from | trigger::no_payload | association_to_trigger_code(a)));
3337 else {
3338 err.accumulated_errors += "prestige = from trigger used in an incorrect scope type " +
3339 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3340 std::to_string(line) + ")\n";
3341 return;
3342 }
3343 } else {
3344 float fvalue = parse_float(value, line, err);
3345 context.compiled_trigger.push_back(uint16_t(trigger::prestige_value | association_to_trigger_code(a)));
3346 context.add_float_to_payload(fvalue);
3347 }
3348 } else {
3349 err.accumulated_errors += "prestige trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3350 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3351 return;
3352 }
3353 }
3354 void badboy(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context);
3355 void has_building(association_type a, std::string_view value, error_handler& err, int32_t line,
3356 trigger_building_context& context) {
3358 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "factory")) {
3359 context.compiled_trigger.push_back(
3360 uint16_t(trigger::has_building_factory | trigger::no_payload | association_to_bool_code(a)));
3361 } else if(auto it = context.outer_context.map_of_factory_names.find(std::string(value));
3362 it != context.outer_context.map_of_factory_names.end()) {
3363 context.compiled_trigger.push_back(uint16_t(trigger::has_building_state | association_to_bool_code(a)));
3364 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3365 } else {
3366 err.accumulated_errors +=
3367 "has_building trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3368 return;
3369 }
3370 } else if(context.main_slot == trigger::slot_contents::province) {
3371 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "fort")) {
3372 context.compiled_trigger.push_back(
3373 uint16_t(trigger::has_building_fort | trigger::no_payload | association_to_bool_code(a)));
3374 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "railroad")) {
3375 context.compiled_trigger.push_back(
3376 uint16_t(trigger::has_building_railroad | trigger::no_payload | association_to_bool_code(a)));
3377 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "naval_base")) {
3378 context.compiled_trigger.push_back(
3379 uint16_t(trigger::has_building_naval_base | trigger::no_payload | association_to_bool_code(a)));
3380 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "bank")) {
3381 context.compiled_trigger.push_back(
3382 uint16_t(trigger::has_building_bank | trigger::no_payload | association_to_bool_code(a)));
3383 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "university")) {
3384 context.compiled_trigger.push_back(
3385 uint16_t(trigger::has_building_university | trigger::no_payload | association_to_bool_code(a)));
3386 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "factory")) {
3387 context.compiled_trigger.push_back(
3388 uint16_t(trigger::has_building_factory_from_province | trigger::no_payload | association_to_bool_code(a)));
3389 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "province_selector")) {
3390 context.compiled_trigger.push_back(uint16_t(trigger::has_province_modifier | association_to_bool_code(a)));
3392 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "immigrator")
3393 || is_fixed_token_ci(value.data(), value.data() + value.length(), "immigrator_selector")
3394 || is_fixed_token_ci(value.data(), value.data() + value.length(), "province_immigrator")) {
3395 context.compiled_trigger.push_back(uint16_t(trigger::has_province_modifier | association_to_bool_code(a)));
3397 } else if(auto it = context.outer_context.map_of_factory_names.find(std::string(value));
3398 it != context.outer_context.map_of_factory_names.end()) {
3399 context.compiled_trigger.push_back(uint16_t(trigger::has_building_state_from_province | association_to_bool_code(a)));
3400 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3401 } else {
3402 err.accumulated_errors +=
3403 "has_building trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3404 return;
3405 }
3406 } else {
3407 err.accumulated_errors += "has_building trigger used in an incorrect scope type " +
3408 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3409 std::to_string(line) + ")\n";
3410 return;
3411 }
3412 }
3413 void empty(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3415 context.compiled_trigger.push_back(uint16_t(trigger::empty | trigger::no_payload | association_to_bool_code(a, value)));
3416 } else if(context.main_slot == trigger::slot_contents::state) {
3417 context.compiled_trigger.push_back(uint16_t(trigger::empty_state | trigger::no_payload | association_to_bool_code(a, value)));
3418 } else {
3419 err.accumulated_errors += "empty trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3420 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3421 return;
3422 }
3423 }
3424 void is_blockaded(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3426 context.compiled_trigger.push_back(
3427 uint16_t(trigger::is_blockaded | trigger::no_payload | association_to_bool_code(a, value)));
3428 } else {
3429 err.accumulated_errors += "is_blockaded trigger used in an incorrect scope type " +
3430 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3431 std::to_string(line) + ")\n";
3432 return;
3433 }
3434 }
3435
3436 void has_country_modifier(association_type a, std::string_view value, error_handler& err, int32_t line,
3437 trigger_building_context& context) {
3438 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3439 it != context.outer_context.map_of_modifiers.end()) {
3441 context.compiled_trigger.push_back(uint16_t(trigger::has_country_modifier | association_to_bool_code(a)));
3442 } else if(context.main_slot == trigger::slot_contents::province) {
3443 context.compiled_trigger.push_back(uint16_t(trigger::has_country_modifier_province | association_to_bool_code(a)));
3444 } else {
3445 err.accumulated_errors += "has_country_modifier trigger used in an incorrect scope type " +
3446 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3447 std::to_string(line) + ")\n";
3448 return;
3449 }
3450 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3451 } else {
3452 err.accumulated_errors += "has_country_modifier trigger supplied with an invalid modifier \"" + std::string(value) + "\" (" + err.file_name + ", line " +
3453 std::to_string(line) + ")\n";
3454 }
3455 }
3456 void has_province_modifier(association_type a, std::string_view value, error_handler& err, int32_t line,
3457 trigger_building_context& context) {
3458 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3459 it != context.outer_context.map_of_modifiers.end()) {
3461 context.compiled_trigger.push_back(uint16_t(trigger::has_province_modifier | association_to_bool_code(a)));
3462 } else {
3463 err.accumulated_errors += "has_province_modifier trigger used in an incorrect scope type " +
3464 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3465 std::to_string(line) + ")\n";
3466 return;
3467 }
3468 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3469 } else {
3470 err.accumulated_errors += "has_province_modifier trigger supplied with an invalid modifier \"" + std::string(value) + "\" (" + err.file_name + ", line " +
3471 std::to_string(line) + ")\n";
3472 }
3473 }
3474 void nationalvalue(association_type a, std::string_view value, error_handler& err, int32_t line,
3475 trigger_building_context& context) {
3476 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3477 it != context.outer_context.map_of_modifiers.end()) {
3479 context.compiled_trigger.push_back(uint16_t(trigger::nationalvalue_nation | association_to_bool_code(a)));
3480 } else if(context.main_slot == trigger::slot_contents::province) {
3481 context.compiled_trigger.push_back(uint16_t(trigger::nationalvalue_province | association_to_bool_code(a)));
3482 } else if(context.main_slot == trigger::slot_contents::pop) {
3483 context.compiled_trigger.push_back(uint16_t(trigger::nationalvalue_pop | association_to_bool_code(a)));
3484 } else {
3485 err.accumulated_errors += "nationalvalue trigger used in an incorrect scope type " +
3486 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3487 std::to_string(line) + ")\n";
3488 return;
3489 }
3490 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3491 } else {
3492 err.accumulated_errors +=
3493 "nationalvalue trigger supplied with an invalid modifier \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3494 }
3495 }
3496 void region(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3497 if(auto it = context.outer_context.map_of_state_names.find(std::string(value)); it != context.outer_context.map_of_state_names.end()) {
3499 context.compiled_trigger.push_back(uint16_t(trigger::region | association_to_bool_code(a)));
3500 } else if(context.main_slot == trigger::slot_contents::state) {
3501 context.compiled_trigger.push_back(uint16_t(trigger::region_state | association_to_bool_code(a)));
3502 } else if(context.main_slot == trigger::slot_contents::pop) {
3503 context.compiled_trigger.push_back(uint16_t(trigger::region_pop | association_to_bool_code(a)));
3504 } else {
3505 err.accumulated_errors += "region trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3506 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3507 return;
3508 }
3509 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3510 } else if(auto it = context.outer_context.map_of_region_names.find(std::string(value)); it != context.outer_context.map_of_region_names.end()) {
3512 context.compiled_trigger.push_back(uint16_t(trigger::region_proper | association_to_bool_code(a)));
3513 } else if(context.main_slot == trigger::slot_contents::state) {
3514 context.compiled_trigger.push_back(uint16_t(trigger::region_proper_state | association_to_bool_code(a)));
3515 } else if(context.main_slot == trigger::slot_contents::pop) {
3516 context.compiled_trigger.push_back(uint16_t(trigger::region_proper_pop | association_to_bool_code(a)));
3517 } else {
3518 err.accumulated_errors += "region trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3519 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3520 return;
3521 }
3522 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3523 } else {
3524 err.accumulated_errors +=
3525 "region trigger not supplied with a state name (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3526 }
3527 }
3528
3529 void tag(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3531 if(is_this(value)) {
3533 context.compiled_trigger.push_back(
3534 uint16_t(trigger::tag_this_province | trigger::no_payload | association_to_bool_code(a)));
3535 else if(context.this_slot == trigger::slot_contents::nation)
3536 context.compiled_trigger.push_back(
3537 uint16_t(trigger::tag_this_nation | trigger::no_payload | association_to_bool_code(a)));
3538 else {
3539 err.accumulated_errors += "tag = this trigger used in an incorrect scope type " +
3540 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3541 std::to_string(line) + ")\n";
3542 return;
3543 }
3544 } else if(is_from(value)) {
3546 context.compiled_trigger.push_back(
3547 uint16_t(trigger::tag_from_nation | trigger::no_payload | association_to_bool_code(a)));
3549 context.compiled_trigger.push_back(
3550 uint16_t(trigger::tag_from_province | trigger::no_payload | association_to_bool_code(a)));
3551 else {
3552 err.accumulated_errors += "tag = from trigger used in an incorrect scope type " +
3553 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3554 std::to_string(line) + ")\n";
3555 return;
3556 }
3557 } else if(value.length() == 3) {
3558 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3559 it != context.outer_context.map_of_ident_names.end()) {
3560 context.compiled_trigger.push_back(uint16_t(trigger::tag_tag | association_to_bool_code(a)));
3561 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3562 } else {
3563 err.accumulated_errors +=
3564 "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3565 }
3566 } else {
3567 err.accumulated_errors +=
3568 "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3569 return;
3570 }
3571 } else if(context.main_slot == trigger::slot_contents::province) {
3572 if(is_this(value)) {
3574 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_pop | trigger::no_payload | association_to_bool_code(a)));
3575 else if(context.this_slot == trigger::slot_contents::state)
3576 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_state | trigger::no_payload | association_to_bool_code(a)));
3578 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_province | trigger::no_payload | association_to_bool_code(a)));
3579 else if(context.this_slot == trigger::slot_contents::nation)
3580 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_nation | trigger::no_payload | association_to_bool_code(a)));
3581 else {
3582 err.accumulated_errors += "tag = this trigger used in an incorrect scope type " +
3583 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3584 std::to_string(line) + ")\n";
3585 return;
3586 }
3587 } else if(is_from(value)) {
3589 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_from_nation | trigger::no_payload | association_to_bool_code(a)));
3590 else {
3591 err.accumulated_errors += "tag = from trigger used in an incorrect scope type " +
3592 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3593 std::to_string(line) + ")\n";
3594 return;
3595 }
3596 } else if(value.length() == 3) {
3597 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3598 it != context.outer_context.map_of_ident_names.end()) {
3599 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_tag | association_to_bool_code(a)));
3600 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3601 } else {
3602 err.accumulated_errors += "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3603 }
3604 } else {
3605 err.accumulated_errors += "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3606 return;
3607 }
3608 } else if(context.main_slot == trigger::slot_contents::state) {
3609 if(is_this(value)) {
3611 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
3612 else if(context.this_slot == trigger::slot_contents::state)
3613 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_state | trigger::no_payload | association_to_bool_code(a)));
3615 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_province | trigger::no_payload | association_to_bool_code(a)));
3616 else if(context.this_slot == trigger::slot_contents::nation)
3617 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
3618 else {
3619 err.accumulated_errors += "tag = this trigger used in an incorrect scope type " +
3620 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3621 std::to_string(line) + ")\n";
3622 return;
3623 }
3624 } else if(is_from(value)) {
3626 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_from_nation | trigger::no_payload | association_to_bool_code(a)));
3627 else {
3628 err.accumulated_errors += "tag = from trigger used in an incorrect scope type " +
3629 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3630 std::to_string(line) + ")\n";
3631 return;
3632 }
3633 } else if(value.length() == 3) {
3634 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3635 it != context.outer_context.map_of_ident_names.end()) {
3636 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_tag | association_to_bool_code(a)));
3637 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3638 } else {
3639 err.accumulated_errors += "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3640 }
3641 } else {
3642 err.accumulated_errors += "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3643 return;
3644 }
3645 } else if(context.main_slot == trigger::slot_contents::pop) {
3646 if(value.length() == 3) {
3647 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3648 it != context.outer_context.map_of_ident_names.end()) {
3649 context.compiled_trigger.push_back(uint16_t(trigger::tag_pop | association_to_bool_code(a)));
3650 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3651 } else {
3652 err.accumulated_errors += "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3653 }
3654 } else {
3655 err.accumulated_errors += "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3656 return;
3657 }
3658 } else {
3659 err.accumulated_errors += "tag trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3660 return;
3661 }
3662 }
3663 void stronger_army_than(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3665 if(is_this(value)) {
3667 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_province | trigger::no_payload | association_to_bool_code(a)));
3668 else if(context.this_slot == trigger::slot_contents::nation)
3669 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_nation | trigger::no_payload | association_to_bool_code(a)));
3670 else if(context.this_slot == trigger::slot_contents::state)
3671 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_state | trigger::no_payload | association_to_bool_code(a)));
3672 else if(context.this_slot == trigger::slot_contents::pop)
3673 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_pop | trigger::no_payload | association_to_bool_code(a)));
3674 else {
3675 err.accumulated_errors += "stronger_army_than = this trigger used in an incorrect scope type " +
3676 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3677 std::to_string(line) + ")\n";
3678 return;
3679 }
3680 } else if(is_from(value)) {
3682 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_from_nation | trigger::no_payload | association_to_bool_code(a)));
3684 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_from_province | trigger::no_payload | association_to_bool_code(a)));
3685 else {
3686 err.accumulated_errors += "stronger_army_than = from trigger used in an incorrect scope type " +
3687 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3688 std::to_string(line) + ")\n";
3689 return;
3690 }
3691 } else if(value.length() == 3) {
3692 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3693 it != context.outer_context.map_of_ident_names.end()) {
3694 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_tag | association_to_bool_code(a)));
3695 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3696 } else {
3697 err.accumulated_errors +=
3698 "stronger_army_than trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3699 }
3700 } else {
3701 err.accumulated_errors +=
3702 "stronger_army_than trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3703 return;
3704 }
3705 } else {
3706 err.accumulated_errors += "stronger_army_than trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3707 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3708 return;
3709 }
3710 }
3711 void neighbour(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3713 if(is_this(value)) {
3715 context.compiled_trigger.push_back(
3716 uint16_t(trigger::neighbour_this | trigger::no_payload | association_to_bool_code(a)));
3718 context.compiled_trigger.push_back(
3719 uint16_t(trigger::neighbour_this_province | trigger::no_payload | association_to_bool_code(a)));
3720 else {
3721 err.accumulated_errors += "neighbour = this trigger used in an incorrect scope type " +
3722 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3723 std::to_string(line) + ")\n";
3724 return;
3725 }
3726 } else if(is_from(value)) {
3728 context.compiled_trigger.push_back(
3729 uint16_t(trigger::neighbour_from | trigger::no_payload | association_to_bool_code(a)));
3731 context.compiled_trigger.push_back(
3732 uint16_t(trigger::neighbour_from_province | trigger::no_payload | association_to_bool_code(a)));
3733 else {
3734 err.accumulated_errors += "neighbour = from trigger used in an incorrect scope type " +
3735 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3736 std::to_string(line) + ")\n";
3737 return;
3738 }
3739 } else if(value.length() == 3) {
3740 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3741 it != context.outer_context.map_of_ident_names.end()) {
3742 context.compiled_trigger.push_back(uint16_t(trigger::neighbour_tag | association_to_bool_code(a)));
3743 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3744 } else {
3745 err.accumulated_errors +=
3746 "neighbour trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3747 }
3748 } else {
3749 err.accumulated_errors +=
3750 "neighbour trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3751 return;
3752 }
3753 } else {
3754 err.accumulated_errors += "neighbour trigger used in an incorrect scope type " +
3755 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3756 std::to_string(line) + ")\n";
3757 return;
3758 }
3759 }
3760 void country_units_in_state(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3762 if(is_this(value)) {
3764 context.compiled_trigger.push_back(
3765 uint16_t(trigger::country_units_in_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
3766 else if(context.this_slot == trigger::slot_contents::state)
3767 context.compiled_trigger.push_back(
3768 uint16_t(trigger::country_units_in_state_this_state | trigger::no_payload | association_to_bool_code(a)));
3770 context.compiled_trigger.push_back(
3771 uint16_t(trigger::country_units_in_state_this_province | trigger::no_payload | association_to_bool_code(a)));
3772 else if(context.this_slot == trigger::slot_contents::pop)
3773 context.compiled_trigger.push_back(
3774 uint16_t(trigger::country_units_in_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
3775 else {
3776 err.accumulated_errors += "country_units_in_state = this trigger used in an incorrect scope type " +
3777 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3778 std::to_string(line) + ")\n";
3779 return;
3780 }
3781 } else if(is_from(value)) {
3783 context.compiled_trigger.push_back(
3784 uint16_t(trigger::country_units_in_state_from | trigger::no_payload | association_to_bool_code(a)));
3785 else {
3786 err.accumulated_errors += "country_units_in_state = from trigger used in an incorrect scope type " +
3787 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3788 std::to_string(line) + ")\n";
3789 return;
3790 }
3791 } else if(value.length() == 3) {
3792 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3793 it != context.outer_context.map_of_ident_names.end()) {
3794 context.compiled_trigger.push_back(uint16_t(trigger::country_units_in_state_tag | association_to_bool_code(a)));
3795 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3796 } else {
3797 err.accumulated_errors +=
3798 "country_units_in_state trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3799 }
3800 } else {
3801 err.accumulated_errors +=
3802 "country_units_in_state trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3803 }
3804 } else {
3805 err.accumulated_errors += "country_units_in_state trigger used in an incorrect scope type " +
3806 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3807 std::to_string(line) + ")\n";
3808 return;
3809 }
3810 }
3811 void units_in_province(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3813 if(is_this(value)) {
3815 context.compiled_trigger.push_back(
3816 uint16_t(trigger::units_in_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
3817 else if(context.this_slot == trigger::slot_contents::state)
3818 context.compiled_trigger.push_back(
3819 uint16_t(trigger::units_in_province_this_state | trigger::no_payload | association_to_bool_code(a)));
3821 context.compiled_trigger.push_back(
3822 uint16_t(trigger::units_in_province_this_province | trigger::no_payload | association_to_bool_code(a)));
3823 else if(context.this_slot == trigger::slot_contents::pop)
3824 context.compiled_trigger.push_back(
3825 uint16_t(trigger::units_in_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
3826 else {
3827 err.accumulated_errors += "units_in_province = this trigger used in an incorrect scope type " +
3828 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3829 std::to_string(line) + ")\n";
3830 return;
3831 }
3832 } else if(is_from(value)) {
3834 context.compiled_trigger.push_back(
3835 uint16_t(trigger::units_in_province_from | trigger::no_payload | association_to_bool_code(a)));
3836 else {
3837 err.accumulated_errors += "units_in_province = from trigger used in an incorrect scope type " +
3838 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3839 std::to_string(line) + ")\n";
3840 return;
3841 }
3842 } else if(is_integer(value.data(), value.data() + value.length())) {
3843 context.compiled_trigger.push_back(uint16_t(trigger::units_in_province_value | association_to_trigger_code(a)));
3844 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
3845 } else if(value.length() == 3) {
3846 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3847 it != context.outer_context.map_of_ident_names.end()) {
3848 context.compiled_trigger.push_back(uint16_t(trigger::units_in_province_tag | association_to_bool_code(a)));
3849 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3850 } else {
3851 err.accumulated_errors +=
3852 "units_in_province trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3853 }
3854 } else {
3855 err.accumulated_errors +=
3856 "units_in_province trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3857 }
3858 } else {
3859 err.accumulated_errors += "units_in_province trigger used in an incorrect scope type " +
3860 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3861 std::to_string(line) + ")\n";
3862 return;
3863 }
3864 }
3865 void war_with(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3867 if(is_this(value)) {
3869 context.compiled_trigger.push_back(
3870 uint16_t(trigger::war_with_this_nation | trigger::no_payload | association_to_bool_code(a)));
3871 else if(context.this_slot == trigger::slot_contents::state)
3872 context.compiled_trigger.push_back(
3873 uint16_t(trigger::war_with_this_state | trigger::no_payload | association_to_bool_code(a)));
3875 context.compiled_trigger.push_back(
3876 uint16_t(trigger::war_with_this_province | trigger::no_payload | association_to_bool_code(a)));
3877 else if(context.this_slot == trigger::slot_contents::pop)
3878 context.compiled_trigger.push_back(
3879 uint16_t(trigger::war_with_this_pop | trigger::no_payload | association_to_bool_code(a)));
3880 else {
3881 err.accumulated_errors += "war_with = this trigger used in an incorrect scope type " +
3882 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3883 std::to_string(line) + ")\n";
3884 return;
3885 }
3886 } else if(is_from(value)) {
3888 context.compiled_trigger.push_back(
3889 uint16_t(trigger::war_with_from | trigger::no_payload | association_to_bool_code(a)));
3890 else {
3891 err.accumulated_errors += "war_with = from trigger used in an incorrect scope type " +
3892 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3893 std::to_string(line) + ")\n";
3894 return;
3895 }
3896 } else if(value.length() == 3) {
3897 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3898 it != context.outer_context.map_of_ident_names.end()) {
3899 context.compiled_trigger.push_back(uint16_t(trigger::war_with_tag | association_to_bool_code(a)));
3900 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3901 } else {
3902 err.accumulated_errors +=
3903 "war_with trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3904 }
3905 } else {
3906 err.accumulated_errors +=
3907 "war_with trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3908 return;
3909 }
3910 } else {
3911 err.accumulated_errors += "war_with trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3912 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3913 return;
3914 }
3915 }
3916 void unit_in_battle(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3918 context.compiled_trigger.push_back(
3919 uint16_t(trigger::unit_in_battle | trigger::no_payload | association_to_bool_code(a, value)));
3920 } else {
3921 err.accumulated_errors += "unit_in_battle trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3922 return;
3923 }
3924 }
3925 void unit_has_leader(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3927 context.compiled_trigger.push_back(uint16_t(trigger::unit_has_leader | trigger::no_payload | association_to_bool_code(a, value)));
3928 } else {
3929 err.accumulated_errors += "unit_has_leader trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3930 return;
3931 }
3932 }
3933 void has_national_focus(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3934 if(auto it = context.outer_context.map_of_national_focuses.find(std::string(value));
3935 it != context.outer_context.map_of_national_focuses.end()) {
3937 context.compiled_trigger.push_back(uint16_t(trigger::has_national_focus_state | trigger::no_payload | association_to_trigger_code(a)));
3938 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3939 } else if(context.main_slot == trigger::slot_contents::province) {
3940 context.compiled_trigger.push_back(uint16_t(trigger::has_national_focus_province | trigger::no_payload | association_to_trigger_code(a)));
3941 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3942 } else {
3943 err.accumulated_errors += "has_national_focus trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3944 return;
3945 }
3946 } else {
3947 err.accumulated_errors += "has_national_focus given an invalid focus '" + std::string(value) + "' (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3948 return;
3949 }
3950 }
3951 void total_amount_of_divisions(association_type a, int32_t value, error_handler& err, int32_t line,
3952 trigger_building_context& context) {
3954 context.compiled_trigger.push_back(uint16_t(trigger::total_amount_of_divisions | association_to_trigger_code(a)));
3955 } else {
3956 err.accumulated_errors += "total_amount_of_divisions trigger used in an incorrect scope type " +
3957 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3958 std::to_string(line) + ")\n";
3959 return;
3960 }
3961 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
3962 }
3963 void money(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
3965 context.compiled_trigger.push_back(uint16_t(trigger::money | association_to_trigger_code(a)));
3966 } else if(context.main_slot == trigger::slot_contents::province) {
3967 context.compiled_trigger.push_back(uint16_t(trigger::money_province | association_to_trigger_code(a)));
3968 } else {
3969 err.accumulated_errors += "money trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3970 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3971 return;
3972 }
3973 context.add_float_to_payload(value);
3974 }
3975 void lost_national(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
3977 context.compiled_trigger.push_back(uint16_t(trigger::lost_national | association_to_trigger_code(a)));
3978 } else {
3979 err.accumulated_errors += "lost_national trigger used in an incorrect scope type " +
3980 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3981 std::to_string(line) + ")\n";
3982 return;
3983 }
3984 context.add_float_to_payload(value);
3985 }
3986 void is_vassal(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3988 context.compiled_trigger.push_back(uint16_t(trigger::is_vassal | trigger::no_payload | association_to_bool_code(a, value)));
3989 } else {
3990 err.accumulated_errors += "is_vassal trigger used in an incorrect scope type " +
3991 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3992 std::to_string(line) + ")\n";
3993 return;
3994 }
3995 }
3996 void ruling_party_ideology(association_type a, std::string_view value, error_handler& err, int32_t line,
3997 trigger_building_context& context) {
3998 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
3999 it != context.outer_context.map_of_ideologies.end()) {
4001 context.compiled_trigger.push_back(uint16_t(trigger::ruling_party_ideology_nation | association_to_bool_code(a)));
4002 } else if(context.main_slot == trigger::slot_contents::pop) {
4003 context.compiled_trigger.push_back(uint16_t(trigger::ruling_party_ideology_pop | association_to_bool_code(a)));
4004 } else if(context.main_slot == trigger::slot_contents::province) {
4005 context.compiled_trigger.push_back(uint16_t(trigger::ruling_party_ideology_province | association_to_bool_code(a)));
4006 } else {
4007 err.accumulated_errors += "ruling_party_ideology trigger used in an incorrect scope type " +
4008 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4009 std::to_string(line) + ")\n";
4010 return;
4011 }
4012 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
4013 } else {
4014 err.accumulated_errors += "ruling_party_ideology trigger supplied with an invalid ideology \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4015 std::to_string(line) + ")\n";
4016 }
4017 }
4018 void ruling_party(association_type a, std::string_view value, error_handler& err, int32_t line,
4019 trigger_building_context& context);
4020 void has_leader(association_type a, std::string_view value, error_handler& err, int32_t line,
4021 trigger_building_context& context);
4022 void is_ideology_enabled(association_type a, std::string_view value, error_handler& err, int32_t line,
4023 trigger_building_context& context) {
4024 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
4025 it != context.outer_context.map_of_ideologies.end()) {
4026 context.compiled_trigger.push_back(uint16_t(trigger::is_ideology_enabled | association_to_bool_code(a)));
4027 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
4028 } else {
4029 err.accumulated_errors += "is_ideology_enabled trigger supplied with an invalid ideology \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4030 std::to_string(line) + ")\n";
4031 }
4032 }
4033 void political_reform_want(association_type a, float value, error_handler& err, int32_t line,
4034 trigger_building_context& context) {
4036 context.compiled_trigger.push_back(uint16_t(trigger::political_reform_want_nation | association_to_trigger_code(a)));
4037 } else if(context.main_slot == trigger::slot_contents::pop) {
4038 context.compiled_trigger.push_back(uint16_t(trigger::political_reform_want_pop | association_to_trigger_code(a)));
4039 } else {
4040 err.accumulated_errors += "political_reform_want trigger used in an incorrect scope type " +
4041 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4042 std::to_string(line) + ")\n";
4043 return;
4044 }
4045 context.add_float_to_payload(value);
4046 }
4047 void social_reform_want(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4049 context.compiled_trigger.push_back(uint16_t(trigger::social_reform_want_nation | association_to_trigger_code(a)));
4050 } else if(context.main_slot == trigger::slot_contents::pop) {
4051 context.compiled_trigger.push_back(uint16_t(trigger::social_reform_want_pop | association_to_trigger_code(a)));
4052 } else {
4053 err.accumulated_errors += "social_reform_want trigger used in an incorrect scope type " +
4054 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4055 std::to_string(line) + ")\n";
4056 return;
4057 }
4058 context.add_float_to_payload(value);
4059 }
4060 void total_amount_of_ships(association_type a, int32_t value, error_handler& err, int32_t line,
4061 trigger_building_context& context) {
4063 context.compiled_trigger.push_back(uint16_t(trigger::total_amount_of_ships | association_to_trigger_code(a)));
4064 } else {
4065 err.accumulated_errors += "total_amount_of_ships trigger used in an incorrect scope type " +
4066 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4067 std::to_string(line) + ")\n";
4068 return;
4069 }
4070 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
4071 }
4072 void plurality(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4074 context.compiled_trigger.push_back(uint16_t(trigger::plurality | association_to_trigger_code(a)));
4075 } else if(context.main_slot == trigger::slot_contents::pop) {
4076 context.compiled_trigger.push_back(uint16_t(trigger::plurality_pop | association_to_trigger_code(a)));
4077 } else {
4078 err.accumulated_errors += "plurality trigger used in an incorrect scope type " +
4079 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4080 std::to_string(line) + ")\n";
4081 return;
4082 }
4083 context.add_float_to_payload(value * 100.0f);
4084 }
4085 void corruption(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4087 context.compiled_trigger.push_back(uint16_t(trigger::corruption | association_to_trigger_code(a)));
4088 } else {
4089 err.accumulated_errors += "corruption trigger used in an incorrect scope type " +
4090 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4091 std::to_string(line) + ")\n";
4092 return;
4093 }
4094 context.add_float_to_payload(value);
4095 }
4096 void is_state_religion(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4098 context.compiled_trigger.push_back(
4099 uint16_t(trigger::is_state_religion_state | trigger::no_payload | association_to_bool_code(a, value)));
4100 } else if(context.main_slot == trigger::slot_contents::province) {
4101 context.compiled_trigger.push_back(
4102 uint16_t(trigger::is_state_religion_province | trigger::no_payload | association_to_bool_code(a, value)));
4103 } else if(context.main_slot == trigger::slot_contents::pop) {
4104 context.compiled_trigger.push_back(
4105 uint16_t(trigger::is_state_religion_pop | trigger::no_payload | association_to_bool_code(a, value)));
4106 } else {
4107 err.accumulated_errors += "is_state_religion trigger used in an incorrect scope type " +
4108 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4109 std::to_string(line) + ")\n";
4110 return;
4111 }
4112 }
4113 void is_primary_culture(association_type a, std::string_view value, error_handler& err, int32_t line,
4114 trigger_building_context& context) {
4115 if(is_this(value)) {
4118 context.compiled_trigger.push_back(
4119 uint16_t(trigger::is_primary_culture_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
4120 else if(context.this_slot == trigger::slot_contents::state)
4121 context.compiled_trigger.push_back(
4122 uint16_t(trigger::is_primary_culture_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
4124 context.compiled_trigger.push_back(
4125 uint16_t(trigger::is_primary_culture_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
4126 else if(context.this_slot == trigger::slot_contents::pop)
4127 context.compiled_trigger.push_back(
4128 uint16_t(trigger::is_primary_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
4129 else {
4130 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4131 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4132 std::to_string(line) + ")\n";
4133 return;
4134 }
4135 } else if(context.main_slot == trigger::slot_contents::state) {
4137 context.compiled_trigger.push_back(
4138 uint16_t(trigger::is_primary_culture_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
4139 else if(context.this_slot == trigger::slot_contents::state)
4140 context.compiled_trigger.push_back(
4141 uint16_t(trigger::is_primary_culture_state_this_state | trigger::no_payload | association_to_bool_code(a)));
4143 context.compiled_trigger.push_back(
4144 uint16_t(trigger::is_primary_culture_state_this_province | trigger::no_payload | association_to_bool_code(a)));
4145 else if(context.this_slot == trigger::slot_contents::pop)
4146 context.compiled_trigger.push_back(
4147 uint16_t(trigger::is_primary_culture_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
4148 else {
4149 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4150 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4151 std::to_string(line) + ")\n";
4152 return;
4153 }
4154 } else if(context.main_slot == trigger::slot_contents::province) {
4156 context.compiled_trigger.push_back(
4157 uint16_t(trigger::is_primary_culture_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
4158 else if(context.this_slot == trigger::slot_contents::state)
4159 context.compiled_trigger.push_back(
4160 uint16_t(trigger::is_primary_culture_province_this_state | trigger::no_payload | association_to_bool_code(a)));
4162 context.compiled_trigger.push_back(
4163 uint16_t(trigger::is_primary_culture_province_this_province | trigger::no_payload | association_to_bool_code(a)));
4164 else if(context.this_slot == trigger::slot_contents::pop)
4165 context.compiled_trigger.push_back(
4166 uint16_t(trigger::is_primary_culture_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
4167 else {
4168 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4169 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4170 std::to_string(line) + ")\n";
4171 return;
4172 }
4173 } else if(context.main_slot == trigger::slot_contents::pop) {
4175 context.compiled_trigger.push_back(
4176 uint16_t(trigger::is_primary_culture_pop_this_nation | trigger::no_payload | association_to_bool_code(a)));
4177 else if(context.this_slot == trigger::slot_contents::state)
4178 context.compiled_trigger.push_back(
4179 uint16_t(trigger::is_primary_culture_pop_this_state | trigger::no_payload | association_to_bool_code(a)));
4181 context.compiled_trigger.push_back(
4182 uint16_t(trigger::is_primary_culture_pop_this_province | trigger::no_payload | association_to_bool_code(a)));
4183 else if(context.this_slot == trigger::slot_contents::pop)
4184 context.compiled_trigger.push_back(
4185 uint16_t(trigger::is_primary_culture_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
4186 else {
4187 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4188 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4189 std::to_string(line) + ")\n";
4190 return;
4191 }
4192 } else {
4193 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4194 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4195 std::to_string(line) + ")\n";
4196 return;
4197 }
4198 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value)); it != context.outer_context.map_of_culture_names.end()) {
4200 context.compiled_trigger.push_back(uint16_t(trigger::primary_culture | association_to_bool_code(a)));
4201 } else if(context.main_slot == trigger::slot_contents::pop) {
4202 context.compiled_trigger.push_back(uint16_t(trigger::culture_pop | association_to_bool_code(a)));
4203 } else {
4204 err.accumulated_errors += "is_primary_culture (treated as primary_culture or culture) trigger used in an incorrect scope type " +
4205 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4206 return;
4207 }
4208 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4209 } else {
4210 bool v = parse_bool(value, line, err);
4212 context.compiled_trigger.push_back(
4213 uint16_t(trigger::is_primary_culture_state | trigger::no_payload | association_to_bool_code(a, v)));
4215 context.compiled_trigger.push_back(
4216 uint16_t(trigger::is_primary_culture_province | trigger::no_payload | association_to_bool_code(a, v)));
4217 else if(context.main_slot == trigger::slot_contents::pop)
4218 context.compiled_trigger.push_back(
4219 uint16_t(trigger::is_primary_culture_pop | trigger::no_payload | association_to_bool_code(a, v)));
4220 else {
4221 err.accumulated_errors += "is_primary_culture trigger used in an incorrect scope type " +
4222 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4223 std::to_string(line) + ")\n";
4224 return;
4225 }
4226 }
4227 }
4228 void is_accepted_culture(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
4229 if(is_this(value)) {
4232 context.compiled_trigger.push_back(
4233 uint16_t(trigger::is_accepted_culture_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
4234 else if(context.this_slot == trigger::slot_contents::state)
4235 context.compiled_trigger.push_back(
4236 uint16_t(trigger::is_accepted_culture_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
4238 context.compiled_trigger.push_back(
4239 uint16_t(trigger::is_accepted_culture_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
4240 else if(context.this_slot == trigger::slot_contents::pop)
4241 context.compiled_trigger.push_back(
4242 uint16_t(trigger::is_accepted_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
4243 else {
4244 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4245 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4246 std::to_string(line) + ")\n";
4247 return;
4248 }
4249 } else if(context.main_slot == trigger::slot_contents::state) {
4251 context.compiled_trigger.push_back(
4252 uint16_t(trigger::is_accepted_culture_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
4253 else if(context.this_slot == trigger::slot_contents::state)
4254 context.compiled_trigger.push_back(
4255 uint16_t(trigger::is_accepted_culture_state_this_state | trigger::no_payload | association_to_bool_code(a)));
4257 context.compiled_trigger.push_back(
4258 uint16_t(trigger::is_accepted_culture_state_this_province | trigger::no_payload | association_to_bool_code(a)));
4259 else if(context.this_slot == trigger::slot_contents::pop)
4260 context.compiled_trigger.push_back(
4261 uint16_t(trigger::is_accepted_culture_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
4262 else {
4263 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4264 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4265 std::to_string(line) + ")\n";
4266 return;
4267 }
4268 } else if(context.main_slot == trigger::slot_contents::province) {
4270 context.compiled_trigger.push_back(
4271 uint16_t(trigger::is_accepted_culture_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
4272 else if(context.this_slot == trigger::slot_contents::state)
4273 context.compiled_trigger.push_back(
4274 uint16_t(trigger::is_accepted_culture_province_this_state | trigger::no_payload | association_to_bool_code(a)));
4276 context.compiled_trigger.push_back(
4277 uint16_t(trigger::is_accepted_culture_province_this_province | trigger::no_payload | association_to_bool_code(a)));
4278 else if(context.this_slot == trigger::slot_contents::pop)
4279 context.compiled_trigger.push_back(
4280 uint16_t(trigger::is_accepted_culture_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
4281 else {
4282 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4283 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4284 std::to_string(line) + ")\n";
4285 return;
4286 }
4287 } else if(context.main_slot == trigger::slot_contents::pop) {
4289 context.compiled_trigger.push_back(
4290 uint16_t(trigger::is_accepted_culture_pop_this_nation | trigger::no_payload | association_to_bool_code(a)));
4291 else if(context.this_slot == trigger::slot_contents::state)
4292 context.compiled_trigger.push_back(
4293 uint16_t(trigger::is_accepted_culture_pop_this_state | trigger::no_payload | association_to_bool_code(a)));
4295 context.compiled_trigger.push_back(
4296 uint16_t(trigger::is_accepted_culture_pop_this_province | trigger::no_payload | association_to_bool_code(a)));
4297 else if(context.this_slot == trigger::slot_contents::pop)
4298 context.compiled_trigger.push_back(
4299 uint16_t(trigger::is_accepted_culture_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
4300 else {
4301 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4302 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4303 std::to_string(line) + ")\n";
4304 return;
4305 }
4306 } else {
4307 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4308 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4309 std::to_string(line) + ")\n";
4310 return;
4311 }
4312 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value)); it != context.outer_context.map_of_culture_names.end()) {
4314 context.compiled_trigger.push_back(uint16_t(trigger::accepted_culture | association_to_bool_code(a)));
4315 } else {
4316 err.accumulated_errors += "is_accepted_culture (treated as accepted_culture) trigger used in an incorrect scope type " +
4317 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4318 return;
4319 }
4320 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4321 } else {
4322 bool v = parse_bool(value, line, err);
4324 context.compiled_trigger.push_back(
4325 uint16_t(trigger::is_accepted_culture_state | trigger::no_payload | association_to_bool_code(a, v)));
4326 } else if(context.main_slot == trigger::slot_contents::province) {
4327 context.compiled_trigger.push_back(
4328 uint16_t(trigger::is_accepted_culture_province | trigger::no_payload | association_to_bool_code(a, v)));
4329 } else if(context.main_slot == trigger::slot_contents::pop) {
4330 context.compiled_trigger.push_back(
4331 uint16_t(trigger::is_accepted_culture_pop | trigger::no_payload | association_to_bool_code(a, v)));
4332 } else {
4333 err.accumulated_errors += "is_accepted_culture trigger used in an incorrect scope type " +
4334 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4335 std::to_string(line) + ")\n";
4336 return;
4337 }
4338 }
4339 }
4340 void is_coastal(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4342 context.compiled_trigger.push_back(
4343 uint16_t(trigger::is_coastal_state | trigger::no_payload | association_to_bool_code(a, value)));
4344 } else if(context.main_slot == trigger::slot_contents::province) {
4345 context.compiled_trigger.push_back(
4346 uint16_t(trigger::is_coastal_province | trigger::no_payload | association_to_bool_code(a, value)));
4347 } else {
4348 err.accumulated_errors += "is_coastal trigger used in an incorrect scope type " +
4349 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4350 std::to_string(line) + ")\n";
4351 return;
4352 }
4353 }
4354 void in_sphere(association_type a, std::string_view value, error_handler& err, int32_t line,
4355 trigger_building_context& context) {
4357 if(is_this(value)) {
4359 context.compiled_trigger.push_back(
4360 uint16_t(trigger::in_sphere_this_nation | trigger::no_payload | association_to_bool_code(a)));
4361 else if(context.this_slot == trigger::slot_contents::state)
4362 context.compiled_trigger.push_back(
4363 uint16_t(trigger::in_sphere_this_state | trigger::no_payload | association_to_bool_code(a)));
4365 context.compiled_trigger.push_back(
4366 uint16_t(trigger::in_sphere_this_province | trigger::no_payload | association_to_bool_code(a)));
4367 else if(context.this_slot == trigger::slot_contents::pop)
4368 context.compiled_trigger.push_back(
4369 uint16_t(trigger::in_sphere_this_pop | trigger::no_payload | association_to_bool_code(a)));
4370 else {
4371 err.accumulated_errors += "in_sphere = this trigger used in an incorrect scope type " +
4372 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4373 std::to_string(line) + ")\n";
4374 return;
4375 }
4376 } else if(is_from(value)) {
4378 context.compiled_trigger.push_back(
4379 uint16_t(trigger::in_sphere_from | trigger::no_payload | association_to_bool_code(a)));
4380 else {
4381 err.accumulated_errors += "in_sphere = from trigger used in an incorrect scope type " +
4382 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4383 std::to_string(line) + ")\n";
4384 return;
4385 }
4386 } else if(value.length() == 3) {
4387 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4388 it != context.outer_context.map_of_ident_names.end()) {
4389 context.compiled_trigger.push_back(uint16_t(trigger::in_sphere_tag | association_to_bool_code(a)));
4390 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4391 } else {
4392 err.accumulated_errors +=
4393 "in_sphere trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4394 }
4395 } else {
4396 err.accumulated_errors +=
4397 "in_sphere trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4398 return;
4399 }
4400 } else {
4401 err.accumulated_errors += "in_sphere trigger used in an incorrect scope type " +
4402 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4403 std::to_string(line) + ")\n";
4404 return;
4405 }
4406 }
4407 void produces(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
4408 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(value));
4409 it != context.outer_context.map_of_commodity_names.end()) {
4411 context.compiled_trigger.push_back(uint16_t(trigger::produces_nation | association_to_bool_code(a)));
4412 } else if(context.main_slot == trigger::slot_contents::state) {
4413 context.compiled_trigger.push_back(uint16_t(trigger::produces_state | association_to_bool_code(a)));
4414 } else if(context.main_slot == trigger::slot_contents::province) {
4415 context.compiled_trigger.push_back(uint16_t(trigger::produces_province | association_to_bool_code(a)));
4416 } else if(context.main_slot == trigger::slot_contents::pop) {
4417 context.compiled_trigger.push_back(uint16_t(trigger::produces_pop | association_to_bool_code(a)));
4418 } else {
4419 err.accumulated_errors += "produces trigger used in an incorrect scope type " +
4420 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4421 return;
4422 }
4423 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4424 } else {
4425 err.accumulated_errors += "produces trigger supplied with an invalid commodity \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4426 }
4427 }
4428 void has_pop_type(association_type a, std::string_view value, error_handler& err, int32_t line,
4429 trigger_building_context& context) {
4430 if(auto it = context.outer_context.map_of_poptypes.find(std::string(value));
4431 it != context.outer_context.map_of_poptypes.end()) {
4433 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_nation | association_to_bool_code(a)));
4434 } else if(context.main_slot == trigger::slot_contents::state) {
4435 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_state | association_to_bool_code(a)));
4436 } else if(context.main_slot == trigger::slot_contents::province) {
4437 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_province | association_to_bool_code(a)));
4438 } else if(context.main_slot == trigger::slot_contents::pop) {
4439 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_pop | association_to_bool_code(a)));
4440 } else {
4441 err.accumulated_errors += "has_pop_type trigger used in an incorrect scope type " +
4442 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4443 return;
4444 }
4445 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4446 } else {
4447 err.accumulated_errors += "has_pop_type trigger supplied with an invalid type name \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4448 }
4449 }
4450 void total_pops(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4452 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_nation | association_to_trigger_code(a)));
4453 } else if(context.main_slot == trigger::slot_contents::state) {
4454 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_state | association_to_trigger_code(a)));
4455 } else if(context.main_slot == trigger::slot_contents::province) {
4456 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_province | association_to_trigger_code(a)));
4457 } else if(context.main_slot == trigger::slot_contents::pop) {
4458 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_pop | association_to_trigger_code(a)));
4459 } else {
4460 err.accumulated_errors += "total_pops trigger used in an incorrect scope type " +
4461 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4462 std::to_string(line) + ")\n";
4463 return;
4464 }
4465 context.add_float_to_payload(value);
4466 }
4467 void average_militancy(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4469 context.compiled_trigger.push_back(uint16_t(trigger::average_militancy_nation | association_to_trigger_code(a)));
4470 } else if(context.main_slot == trigger::slot_contents::state) {
4471 context.compiled_trigger.push_back(uint16_t(trigger::average_militancy_state | association_to_trigger_code(a)));
4472 } else if(context.main_slot == trigger::slot_contents::province) {
4473 context.compiled_trigger.push_back(uint16_t(trigger::average_militancy_province | association_to_trigger_code(a)));
4474 } else {
4475 err.accumulated_errors += "average_militancy trigger used in an incorrect scope type " +
4476 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4477 std::to_string(line) + ")\n";
4478 return;
4479 }
4480 context.add_float_to_payload(value);
4481 }
4482 void average_consciousness(association_type a, float value, error_handler& err, int32_t line,
4483 trigger_building_context& context) {
4485 context.compiled_trigger.push_back(uint16_t(trigger::average_consciousness_nation | association_to_trigger_code(a)));
4486 } else if(context.main_slot == trigger::slot_contents::state) {
4487 context.compiled_trigger.push_back(uint16_t(trigger::average_consciousness_state | association_to_trigger_code(a)));
4488 } else if(context.main_slot == trigger::slot_contents::province) {
4489 context.compiled_trigger.push_back(uint16_t(trigger::average_consciousness_province | association_to_trigger_code(a)));
4490 } else {
4491 err.accumulated_errors += "average_consciousness trigger used in an incorrect scope type " +
4492 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4493 std::to_string(line) + ")\n";
4494 return;
4495 }
4496 context.add_float_to_payload(value);
4497 }
4498 void is_next_reform(association_type a, std::string_view value, error_handler& err, int32_t line,
4499 trigger_building_context& context) {
4500 if(auto it = context.outer_context.map_of_ioptions.find(std::string(value));
4501 it != context.outer_context.map_of_ioptions.end()) {
4503 context.compiled_trigger.push_back(uint16_t(trigger::is_next_reform_nation | association_to_bool_code(a)));
4504 } else if(context.main_slot == trigger::slot_contents::pop) {
4505 context.compiled_trigger.push_back(uint16_t(trigger::is_next_reform_pop | association_to_bool_code(a)));
4506 } else {
4507 err.accumulated_errors += "is_next_reform trigger used in an incorrect scope type " +
4508 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4509 std::to_string(line) + ")\n";
4510 return;
4511 }
4512 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
4513 } else if(auto itb = context.outer_context.map_of_roptions.find(std::string(value));
4514 itb != context.outer_context.map_of_roptions.end()) {
4516 context.compiled_trigger.push_back(uint16_t(trigger::is_next_rreform_nation | association_to_bool_code(a)));
4517 } else if(context.main_slot == trigger::slot_contents::pop) {
4518 context.compiled_trigger.push_back(uint16_t(trigger::is_next_rreform_pop | association_to_bool_code(a)));
4519 } else {
4520 err.accumulated_errors += "is_next_reform trigger used in an incorrect scope type " +
4521 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4522 std::to_string(line) + ")\n";
4523 return;
4524 }
4525 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
4526 } else {
4527 err.accumulated_errors += "is_next_reform trigger supplied with an invalid issue/reform \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4528 std::to_string(line) + ")\n";
4529 }
4530 }
4531 void rebel_power_fraction(association_type a, float value, error_handler& err, int32_t line,
4532 trigger_building_context& context) {
4534 context.compiled_trigger.push_back(uint16_t(trigger::rebel_power_fraction | association_to_trigger_code(a)));
4535 } else {
4536 err.accumulated_errors += "rebel_power_fraction trigger used in an incorrect scope type " +
4537 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4538 std::to_string(line) + ")\n";
4539 return;
4540 }
4541 context.add_float_to_payload(value);
4542 }
4543 void recruited_percentage(association_type a, float value, error_handler& err, int32_t line,
4544 trigger_building_context& context) {
4546 context.compiled_trigger.push_back(uint16_t(trigger::recruited_percentage_nation | association_to_trigger_code(a)));
4547 } else if(context.main_slot == trigger::slot_contents::pop) {
4548 context.compiled_trigger.push_back(uint16_t(trigger::recruited_percentage_pop | association_to_trigger_code(a)));
4549 } else {
4550 err.accumulated_errors += "recruited_percentage trigger used in an incorrect scope type " +
4551 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4552 std::to_string(line) + ")\n";
4553 return;
4554 }
4555 context.add_float_to_payload(value);
4556 }
4557 void has_culture_core(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4558 if(context.main_slot == trigger::slot_contents::pop) {
4559 context.compiled_trigger.push_back(
4560 uint16_t(trigger::has_culture_core | trigger::no_payload | association_to_bool_code(a, value)));
4562 context.compiled_trigger.push_back(
4563 uint16_t(trigger::has_culture_core_province_this_pop | trigger::no_payload | association_to_bool_code(a, value)));
4564 } else {
4565 err.accumulated_errors += "has_culture_core trigger used in an incorrect scope type " +
4566 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4567 std::to_string(line) + ")\n";
4568 return;
4569 }
4570 }
4571 void nationalism(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
4573 context.compiled_trigger.push_back(uint16_t(trigger::nationalism | association_to_trigger_code(a)));
4574 } else {
4575 err.accumulated_errors += "nationalism trigger used in an incorrect scope type " +
4576 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4577 std::to_string(line) + ")\n";
4578 return;
4579 }
4580 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
4581 }
4582 void is_overseas(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4584 context.compiled_trigger.push_back(
4585 uint16_t(trigger::is_overseas | trigger::no_payload | association_to_bool_code(a, value)));
4586 } else if(context.main_slot == trigger::slot_contents::pop) {
4587 context.compiled_trigger.push_back(
4588 uint16_t(trigger::is_overseas_pop | trigger::no_payload | association_to_bool_code(a, value)));
4589 } else if(context.main_slot == trigger::slot_contents::state) {
4590 context.compiled_trigger.push_back(
4591 uint16_t(trigger::is_overseas_state | trigger::no_payload | association_to_bool_code(a, value)));
4592 } else {
4593 err.accumulated_errors += "is_overseas trigger used in an incorrect scope type " +
4594 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4595 std::to_string(line) + ")\n";
4596 return;
4597 }
4598 }
4599 void controlled_by_rebels(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4601 context.compiled_trigger.push_back(
4602 uint16_t(trigger::controlled_by_rebels | trigger::no_payload | association_to_bool_code(a, value)));
4603 } else {
4604 err.accumulated_errors += "controlled_by_rebels trigger used in an incorrect scope type " +
4605 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4606 std::to_string(line) + ")\n";
4607 return;
4608 }
4609 }
4610 void controlled_by(association_type a, std::string_view value, error_handler& err, int32_t line,
4611 trigger_building_context& context) {
4613 if(is_this(value)) {
4615 context.compiled_trigger.push_back(
4616 uint16_t(trigger::controlled_by_this_nation | trigger::no_payload | association_to_bool_code(a)));
4617 else if(context.this_slot == trigger::slot_contents::state)
4618 context.compiled_trigger.push_back(
4619 uint16_t(trigger::controlled_by_this_state | trigger::no_payload | association_to_bool_code(a)));
4621 context.compiled_trigger.push_back(
4622 uint16_t(trigger::controlled_by_this_province | trigger::no_payload | association_to_bool_code(a)));
4623 else if(context.this_slot == trigger::slot_contents::pop)
4624 context.compiled_trigger.push_back(
4625 uint16_t(trigger::controlled_by_this_pop | trigger::no_payload | association_to_bool_code(a)));
4626 else {
4627 err.accumulated_errors += "controlled_by = this trigger used in an incorrect scope type " +
4628 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4629 std::to_string(line) + ")\n";
4630 return;
4631 }
4632 } else if(is_from(value)) {
4634 context.compiled_trigger.push_back(
4635 uint16_t(trigger::controlled_by_from | trigger::no_payload | association_to_bool_code(a)));
4636 else {
4637 err.accumulated_errors += "controlled_by = from trigger used in an incorrect scope type " +
4638 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4639 std::to_string(line) + ")\n";
4640 return;
4641 }
4642 } else if(is_reb(value)) {
4644 context.compiled_trigger.push_back(
4645 uint16_t(trigger::controlled_by_reb | trigger::no_payload | association_to_bool_code(a)));
4646 else {
4647 context.compiled_trigger.push_back(
4648 uint16_t(trigger::controlled_by_rebels | trigger::no_payload | association_to_bool_code(a)));
4649 }
4650 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "owner")) {
4651 context.compiled_trigger.push_back(
4652 uint16_t(trigger::controlled_by_owner | trigger::no_payload | association_to_bool_code(a)));
4653 } else if(value.length() == 3) {
4654 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4655 it != context.outer_context.map_of_ident_names.end()) {
4656 context.compiled_trigger.push_back(uint16_t(trigger::controlled_by_tag | association_to_bool_code(a)));
4657 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4658 } else {
4659 err.accumulated_errors +=
4660 "controlled_by trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4661 }
4662 } else {
4663 err.accumulated_errors +=
4664 "controlled_by trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4665 return;
4666 }
4667 } else {
4668 err.accumulated_errors += "controlled_by trigger used in an incorrect scope type " +
4669 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4670 std::to_string(line) + ")\n";
4671 return;
4672 }
4673 }
4674 void truce_with(association_type a, std::string_view value, error_handler& err, int32_t line,
4675 trigger_building_context& context) {
4677 if(is_this(value)) {
4679 context.compiled_trigger.push_back(
4680 uint16_t(trigger::truce_with_this_nation | trigger::no_payload | association_to_bool_code(a)));
4681 else if(context.this_slot == trigger::slot_contents::state)
4682 context.compiled_trigger.push_back(
4683 uint16_t(trigger::truce_with_this_state | trigger::no_payload | association_to_bool_code(a)));
4685 context.compiled_trigger.push_back(
4686 uint16_t(trigger::truce_with_this_province | trigger::no_payload | association_to_bool_code(a)));
4687 else if(context.this_slot == trigger::slot_contents::pop)
4688 context.compiled_trigger.push_back(
4689 uint16_t(trigger::truce_with_this_pop | trigger::no_payload | association_to_bool_code(a)));
4690 else {
4691 err.accumulated_errors += "truce_with = this trigger used in an incorrect scope type " +
4692 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4693 std::to_string(line) + ")\n";
4694 return;
4695 }
4696 } else if(is_from(value)) {
4698 context.compiled_trigger.push_back(
4699 uint16_t(trigger::truce_with_from | trigger::no_payload | association_to_bool_code(a)));
4700 else {
4701 err.accumulated_errors += "truce_with = from trigger used in an incorrect scope type " +
4702 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4703 std::to_string(line) + ")\n";
4704 return;
4705 }
4706 } else if(value.length() == 3) {
4707 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4708 it != context.outer_context.map_of_ident_names.end()) {
4709 context.compiled_trigger.push_back(uint16_t(trigger::truce_with_tag | association_to_bool_code(a)));
4710 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4711 } else {
4712 err.accumulated_errors +=
4713 "truce_with trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4714 }
4715 } else {
4716 err.accumulated_errors +=
4717 "truce_with trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4718 return;
4719 }
4720 } else {
4721 err.accumulated_errors += "truce_with trigger used in an incorrect scope type " +
4722 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4723 std::to_string(line) + ")\n";
4724 return;
4725 }
4726 }
4727 void is_sphere_leader_of(association_type a, std::string_view value, error_handler& err, int32_t line,
4728 trigger_building_context& context) {
4730 if(is_this(value)) {
4732 context.compiled_trigger.push_back(
4733 uint16_t(trigger::is_sphere_leader_of_this_nation | trigger::no_payload | association_to_bool_code(a)));
4734 else if(context.this_slot == trigger::slot_contents::state)
4735 context.compiled_trigger.push_back(
4736 uint16_t(trigger::is_sphere_leader_of_this_state | trigger::no_payload | association_to_bool_code(a)));
4738 context.compiled_trigger.push_back(
4739 uint16_t(trigger::is_sphere_leader_of_this_province | trigger::no_payload | association_to_bool_code(a)));
4740 else if(context.this_slot == trigger::slot_contents::pop)
4741 context.compiled_trigger.push_back(
4742 uint16_t(trigger::is_sphere_leader_of_this_pop | trigger::no_payload | association_to_bool_code(a)));
4743 else {
4744 err.accumulated_errors += "is_sphere_leader_of = this trigger used in an incorrect scope type " +
4745 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4746 std::to_string(line) + ")\n";
4747 return;
4748 }
4749 } else if(is_from(value)) {
4751 context.compiled_trigger.push_back(
4752 uint16_t(trigger::is_sphere_leader_of_from | trigger::no_payload | association_to_bool_code(a)));
4753 else {
4754 err.accumulated_errors += "is_sphere_leader_of = from trigger used in an incorrect scope type " +
4755 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4756 std::to_string(line) + ")\n";
4757 return;
4758 }
4759 } else if(value.length() == 3) {
4760 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4761 it != context.outer_context.map_of_ident_names.end()) {
4762 context.compiled_trigger.push_back(uint16_t(trigger::is_sphere_leader_of_tag | association_to_bool_code(a)));
4763 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4764 } else {
4765 err.accumulated_errors += "is_sphere_leader_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4766 std::to_string(line) + ")\n";
4767 }
4768 } else {
4769 err.accumulated_errors += "is_sphere_leader_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4770 std::to_string(line) + ")\n";
4771 return;
4772 }
4773 } else {
4774 err.accumulated_errors += "is_sphere_leader_of trigger used in an incorrect scope type " +
4775 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4776 std::to_string(line) + ")\n";
4777 return;
4778 }
4779 }
4780 void constructing_cb(association_type a, std::string_view value, error_handler& err, int32_t line,
4781 trigger_building_context& context) {
4783 if(is_this(value)) {
4785 context.compiled_trigger.push_back(
4786 uint16_t(trigger::constructing_cb_this_nation | trigger::no_payload | association_to_bool_code(a)));
4787 else if(context.this_slot == trigger::slot_contents::state)
4788 context.compiled_trigger.push_back(
4789 uint16_t(trigger::constructing_cb_this_state | trigger::no_payload | association_to_bool_code(a)));
4791 context.compiled_trigger.push_back(
4792 uint16_t(trigger::constructing_cb_this_province | trigger::no_payload | association_to_bool_code(a)));
4793 else if(context.this_slot == trigger::slot_contents::pop)
4794 context.compiled_trigger.push_back(
4795 uint16_t(trigger::constructing_cb_this_pop | trigger::no_payload | association_to_bool_code(a)));
4796 else {
4797 err.accumulated_errors += "constructing_cb = this trigger used in an incorrect scope type " +
4798 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4799 std::to_string(line) + ")\n";
4800 return;
4801 }
4802 } else if(is_from(value)) {
4804 context.compiled_trigger.push_back(
4805 uint16_t(trigger::constructing_cb_from | trigger::no_payload | association_to_bool_code(a)));
4806 else {
4807 err.accumulated_errors += "constructing_cb = from trigger used in an incorrect scope type " +
4808 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4809 std::to_string(line) + ")\n";
4810 return;
4811 }
4812 } else if(value.length() == 3) {
4813 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4814 it != context.outer_context.map_of_ident_names.end()) {
4815 context.compiled_trigger.push_back(uint16_t(trigger::constructing_cb_tag | association_to_bool_code(a)));
4816 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4817 } else {
4818 err.accumulated_errors +=
4819 "constructing_cb trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4820 }
4821 } else {
4822 err.accumulated_errors +=
4823 "constructing_cb trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4824 return;
4825 }
4826 } else {
4827 err.accumulated_errors += "constructing_cb trigger used in an incorrect scope type " +
4828 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4829 std::to_string(line) + ")\n";
4830 return;
4831 }
4832 }
4833 void vassal_of(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
4835 if(is_this(value)) {
4837 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_nation | trigger::no_payload | association_to_bool_code(a)));
4838 else if(context.this_slot == trigger::slot_contents::state)
4839 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_state | trigger::no_payload | association_to_bool_code(a)));
4841 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_province | trigger::no_payload | association_to_bool_code(a)));
4842 else if(context.this_slot == trigger::slot_contents::pop)
4843 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_pop | trigger::no_payload | association_to_bool_code(a)));
4844 else {
4845 err.accumulated_errors += "vassal_of = this trigger used in an incorrect scope type " +
4846 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4847 return;
4848 }
4849 } else if(is_from(value)) {
4851 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_from | trigger::no_payload | association_to_bool_code(a)));
4852 else {
4853 err.accumulated_errors += "vassal_of = from trigger used in an incorrect scope type " +
4854 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4855 return;
4856 }
4857 } else if(value.length() == 3) {
4858 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4859 it != context.outer_context.map_of_ident_names.end()) {
4860 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_tag | association_to_bool_code(a)));
4861 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4862 } else {
4863 err.accumulated_errors += "vassal_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4864 }
4865 } else {
4866 err.accumulated_errors += "vassal_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4867 return;
4868 }
4869 } else if(context.main_slot == trigger::slot_contents::province) {
4870 if(is_this(value)) {
4872 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
4873 else if(context.this_slot == trigger::slot_contents::state)
4874 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_state | trigger::no_payload | association_to_bool_code(a)));
4876 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_province | trigger::no_payload | association_to_bool_code(a)));
4877 else if(context.this_slot == trigger::slot_contents::pop)
4878 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
4879 else {
4880 err.accumulated_errors += "vassal_of = this trigger used in an incorrect scope type " +
4881 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4882 return;
4883 }
4884 } else if(is_from(value)) {
4886 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_from | trigger::no_payload | association_to_bool_code(a)));
4887 else {
4888 err.accumulated_errors += "vassal_of = from trigger used in an incorrect scope type " +
4889 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4890 return;
4891 }
4892 } else if(value.length() == 3) {
4893 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4894 it != context.outer_context.map_of_ident_names.end()) {
4895 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_tag | association_to_bool_code(a)));
4896 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4897 } else {
4898 err.accumulated_errors += "vassal_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4899 }
4900 } else {
4901 err.accumulated_errors += "vassal_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4902 return;
4903 }
4904 } else {
4905 err.accumulated_errors += "vassal_of trigger used in an incorrect scope type " +
4906 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4907 return;
4908 }
4909 }
4910 void substate_of(association_type a, std::string_view value, error_handler& err, int32_t line,
4911 trigger_building_context& context) {
4913 if(is_this(value)) {
4915 context.compiled_trigger.push_back(
4916 uint16_t(trigger::substate_of_this_nation | trigger::no_payload | association_to_bool_code(a)));
4917 else if(context.this_slot == trigger::slot_contents::state)
4918 context.compiled_trigger.push_back(
4919 uint16_t(trigger::substate_of_this_state | trigger::no_payload | association_to_bool_code(a)));
4921 context.compiled_trigger.push_back(
4922 uint16_t(trigger::substate_of_this_province | trigger::no_payload | association_to_bool_code(a)));
4923 else if(context.this_slot == trigger::slot_contents::pop)
4924 context.compiled_trigger.push_back(
4925 uint16_t(trigger::substate_of_this_pop | trigger::no_payload | association_to_bool_code(a)));
4926 else {
4927 err.accumulated_errors += "substate_of = this trigger used in an incorrect scope type " +
4928 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4929 std::to_string(line) + ")\n";
4930 return;
4931 }
4932 } else if(is_from(value)) {
4934 context.compiled_trigger.push_back(
4935 uint16_t(trigger::substate_of_from | trigger::no_payload | association_to_bool_code(a)));
4936 else {
4937 err.accumulated_errors += "substate_of = from trigger used in an incorrect scope type " +
4938 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4939 std::to_string(line) + ")\n";
4940 return;
4941 }
4942 } else if(value.length() == 3) {
4943 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4944 it != context.outer_context.map_of_ident_names.end()) {
4945 context.compiled_trigger.push_back(uint16_t(trigger::substate_of_tag | association_to_bool_code(a)));
4946 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4947 } else {
4948 err.accumulated_errors +=
4949 "substate_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4950 }
4951 } else {
4952 err.accumulated_errors +=
4953 "substate_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4954 return;
4955 }
4956 } else {
4957 err.accumulated_errors += "substate_of trigger used in an incorrect scope type " +
4958 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4959 std::to_string(line) + ")\n";
4960 return;
4961 }
4962 }
4963 void is_our_vassal(association_type a, std::string_view value, error_handler& err, int32_t line,
4964 trigger_building_context& context) {
4966 if(is_this(value)) {
4968 context.compiled_trigger.push_back(
4969 uint16_t(trigger::is_our_vassal_this_nation | trigger::no_payload | association_to_bool_code(a)));
4970 else if(context.this_slot == trigger::slot_contents::state)
4971 context.compiled_trigger.push_back(
4972 uint16_t(trigger::is_our_vassal_this_state | trigger::no_payload | association_to_bool_code(a)));
4974 context.compiled_trigger.push_back(
4975 uint16_t(trigger::is_our_vassal_this_province | trigger::no_payload | association_to_bool_code(a)));
4976 else if(context.this_slot == trigger::slot_contents::pop)
4977 context.compiled_trigger.push_back(
4978 uint16_t(trigger::is_our_vassal_this_pop | trigger::no_payload | association_to_bool_code(a)));
4979 else {
4980 err.accumulated_errors += "is_our_vassal = this trigger used in an incorrect scope type " +
4981 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4982 std::to_string(line) + ")\n";
4983 return;
4984 }
4985 } else if(is_from(value)) {
4987 context.compiled_trigger.push_back(
4988 uint16_t(trigger::is_our_vassal_from | trigger::no_payload | association_to_bool_code(a)));
4989 else {
4990 err.accumulated_errors += "is_our_vassal = from trigger used in an incorrect scope type " +
4991 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4992 std::to_string(line) + ")\n";
4993 return;
4994 }
4995 } else if(value.length() == 3) {
4996 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4997 it != context.outer_context.map_of_ident_names.end()) {
4998 context.compiled_trigger.push_back(uint16_t(trigger::is_our_vassal_tag | association_to_bool_code(a)));
4999 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5000 } else {
5001 err.accumulated_errors +=
5002 "is_our_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5003 }
5004 } else {
5005 err.accumulated_errors +=
5006 "is_our_vassal trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5007 return;
5008 }
5009 } else if(context.main_slot == trigger::slot_contents::province) {
5010 if(is_this(value)) {
5012 context.compiled_trigger.push_back(
5013 uint16_t(trigger::is_our_vassal_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
5014 else if(context.this_slot == trigger::slot_contents::state)
5015 context.compiled_trigger.push_back(
5016 uint16_t(trigger::is_our_vassal_province_this_state | trigger::no_payload | association_to_bool_code(a)));
5018 context.compiled_trigger.push_back(
5019 uint16_t(trigger::is_our_vassal_province_this_province | trigger::no_payload | association_to_bool_code(a)));
5020 else if(context.this_slot == trigger::slot_contents::pop)
5021 context.compiled_trigger.push_back(
5022 uint16_t(trigger::is_our_vassal_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
5023 else {
5024 err.accumulated_errors += "is_our_vassal = this trigger used in an incorrect scope type " +
5025 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5026 std::to_string(line) + ")\n";
5027 return;
5028 }
5029 } else if(is_from(value)) {
5031 context.compiled_trigger.push_back(
5032 uint16_t(trigger::is_our_vassal_province_from | trigger::no_payload | association_to_bool_code(a)));
5033 else {
5034 err.accumulated_errors += "is_our_vassal = from trigger used in an incorrect scope type " +
5035 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5036 std::to_string(line) + ")\n";
5037 return;
5038 }
5039 } else if(value.length() == 3) {
5040 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5041 it != context.outer_context.map_of_ident_names.end()) {
5042 context.compiled_trigger.push_back(uint16_t(trigger::is_our_vassal_province_tag | association_to_bool_code(a)));
5043 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5044 } else {
5045 err.accumulated_errors +=
5046 "is_our_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5047 }
5048 } else {
5049 err.accumulated_errors +=
5050 "is_our_vassal trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5051 return;
5052 }
5053 } else {
5054 err.accumulated_errors += "is_our_vassal trigger used in an incorrect scope type " +
5055 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5056 std::to_string(line) + ")\n";
5057 return;
5058 }
5059 }
5060 void this_culture_union(association_type a, std::string_view value, error_handler& err, int32_t line,
5061 trigger_building_context& context) {
5063 if(is_this(value)) {
5065 context.compiled_trigger.push_back(
5066 uint16_t(trigger::this_culture_union_this_nation | trigger::no_payload | association_to_bool_code(a)));
5067 else if(context.this_slot == trigger::slot_contents::state)
5068 context.compiled_trigger.push_back(
5069 uint16_t(trigger::this_culture_union_this_state | trigger::no_payload | association_to_bool_code(a)));
5071 context.compiled_trigger.push_back(
5072 uint16_t(trigger::this_culture_union_this_province | trigger::no_payload | association_to_bool_code(a)));
5073 else if(context.this_slot == trigger::slot_contents::pop)
5074 context.compiled_trigger.push_back(
5075 uint16_t(trigger::this_culture_union_this_pop | trigger::no_payload | association_to_bool_code(a)));
5076 else {
5077 err.accumulated_errors += "this_culture_union = this trigger used in an incorrect scope type " +
5078 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5079 std::to_string(line) + ")\n";
5080 return;
5081 }
5082 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "this_union")) {
5084 context.compiled_trigger.push_back(
5085 uint16_t(trigger::this_culture_union_this_union_nation | trigger::no_payload | association_to_bool_code(a)));
5086 else if(context.this_slot == trigger::slot_contents::state)
5087 context.compiled_trigger.push_back(
5088 uint16_t(trigger::this_culture_union_this_union_state | trigger::no_payload | association_to_bool_code(a)));
5090 context.compiled_trigger.push_back(
5091 uint16_t(trigger::this_culture_union_this_union_province | trigger::no_payload | association_to_bool_code(a)));
5092 else if(context.this_slot == trigger::slot_contents::pop)
5093 context.compiled_trigger.push_back(
5094 uint16_t(trigger::this_culture_union_this_union_pop | trigger::no_payload | association_to_bool_code(a)));
5095 else {
5096 err.accumulated_errors += "this_culture_union = this_union trigger used in an incorrect scope type " +
5097 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5098 std::to_string(line) + ")\n";
5099 return;
5100 }
5101 } else if(is_from(value)) {
5103 context.compiled_trigger.push_back(
5104 uint16_t(trigger::this_culture_union_from | trigger::no_payload | association_to_bool_code(a)));
5105 else {
5106 err.accumulated_errors += "this_culture_union = from trigger used in an incorrect scope type " +
5107 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5108 std::to_string(line) + ")\n";
5109 return;
5110 }
5111 } else if(value.length() == 3) {
5112 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5113 it != context.outer_context.map_of_ident_names.end()) {
5114 context.compiled_trigger.push_back(uint16_t(trigger::this_culture_union_tag | association_to_bool_code(a)));
5115 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5116 } else {
5117 err.accumulated_errors += "this_culture_union trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " +
5118 std::to_string(line) + ")\n";
5119 }
5120 } else {
5121 err.accumulated_errors += "this_culture_union trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " +
5122 std::to_string(line) + ")\n";
5123 return;
5124 }
5125 } else {
5126 err.accumulated_errors += "this_culture_union trigger used in an incorrect scope type " +
5127 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5128 std::to_string(line) + ")\n";
5129 return;
5130 }
5131 }
5132 void alliance_with(association_type a, std::string_view value, error_handler& err, int32_t line,
5133 trigger_building_context& context) {
5135 if(is_this(value)) {
5137 context.compiled_trigger.push_back(
5138 uint16_t(trigger::alliance_with_this_nation | trigger::no_payload | association_to_bool_code(a)));
5139 else if(context.this_slot == trigger::slot_contents::state)
5140 context.compiled_trigger.push_back(
5141 uint16_t(trigger::alliance_with_this_state | trigger::no_payload | association_to_bool_code(a)));
5143 context.compiled_trigger.push_back(
5144 uint16_t(trigger::alliance_with_this_province | trigger::no_payload | association_to_bool_code(a)));
5145 else if(context.this_slot == trigger::slot_contents::pop)
5146 context.compiled_trigger.push_back(
5147 uint16_t(trigger::alliance_with_this_pop | trigger::no_payload | association_to_bool_code(a)));
5148 else {
5149 err.accumulated_errors += "alliance_with = this trigger used in an incorrect scope type " +
5150 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5151 std::to_string(line) + ")\n";
5152 return;
5153 }
5154 } else if(is_from(value)) {
5156 context.compiled_trigger.push_back(
5157 uint16_t(trigger::alliance_with_from | trigger::no_payload | association_to_bool_code(a)));
5158 else {
5159 err.accumulated_errors += "alliance_with = from trigger used in an incorrect scope type " +
5160 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5161 std::to_string(line) + ")\n";
5162 return;
5163 }
5164 } else if(value.length() == 3) {
5165 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5166 it != context.outer_context.map_of_ident_names.end()) {
5167 context.compiled_trigger.push_back(uint16_t(trigger::alliance_with_tag | association_to_bool_code(a)));
5168 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5169 } else {
5170 err.accumulated_errors +=
5171 "alliance_with trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5172 }
5173 } else {
5174 err.accumulated_errors +=
5175 "alliance_with trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5176 return;
5177 }
5178 } else {
5179 err.accumulated_errors += "alliance_with trigger used in an incorrect scope type " +
5180 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5181 std::to_string(line) + ")\n";
5182 return;
5183 }
5184 }
5185 void in_default(association_type a, std::string_view value, error_handler& err, int32_t line,
5186 trigger_building_context& context) {
5188 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "yes") ||
5189 is_fixed_token_ci(value.data(), value.data() + value.length(), "no")) {
5190
5191 context.compiled_trigger.push_back(uint16_t(trigger::in_default_bool | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
5192
5193 } else if(is_this(value)) {
5195 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_nation | trigger::no_payload | association_to_bool_code(a)));
5196 else if(context.this_slot == trigger::slot_contents::state)
5197 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_state | trigger::no_payload | association_to_bool_code(a)));
5199 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_province | trigger::no_payload | association_to_bool_code(a)));
5200 else if(context.this_slot == trigger::slot_contents::pop)
5201 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_pop | trigger::no_payload | association_to_bool_code(a)));
5202 else {
5203 err.accumulated_errors += "in_default = this trigger used in an incorrect scope type " +
5204 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5205 std::to_string(line) + ")\n";
5206 return;
5207 }
5208 } else if(is_from(value)) {
5210 context.compiled_trigger.push_back(uint16_t(trigger::in_default_from | trigger::no_payload | association_to_bool_code(a)));
5211 else {
5212 err.accumulated_errors += "in_default = from trigger used in an incorrect scope type " +
5213 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5214 std::to_string(line) + ")\n";
5215 return;
5216 }
5217 } else if(value.length() == 3) {
5218 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5219 it != context.outer_context.map_of_ident_names.end()) {
5220 context.compiled_trigger.push_back(uint16_t(trigger::in_default_tag | association_to_bool_code(a)));
5221 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5222 } else {
5223 err.accumulated_errors += "in_default trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5224 }
5225 } else {
5226 err.accumulated_errors += "in_default trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5227 return;
5228 }
5229 } else {
5230 err.accumulated_errors += "in_default trigger used in an incorrect scope type " +
5231 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5232 return;
5233 }
5234 }
5235 void industrial_score(association_type a, std::string_view value, error_handler& err, int32_t line,
5236 trigger_building_context& context) {
5238 if(is_this(value)) {
5240 context.compiled_trigger.push_back(
5241 uint16_t(trigger::industrial_score_this_nation | trigger::no_payload | association_to_trigger_code(a)));
5242 else if(context.this_slot == trigger::slot_contents::state)
5243 context.compiled_trigger.push_back(
5244 uint16_t(trigger::industrial_score_this_state | trigger::no_payload | association_to_trigger_code(a)));
5246 context.compiled_trigger.push_back(
5247 uint16_t(trigger::industrial_score_this_province | trigger::no_payload | association_to_trigger_code(a)));
5248 else if(context.this_slot == trigger::slot_contents::pop)
5249 context.compiled_trigger.push_back(
5250 uint16_t(trigger::industrial_score_this_pop | trigger::no_payload | association_to_trigger_code(a)));
5251 else {
5252 err.accumulated_errors += "industrial_score = this trigger used in an incorrect scope type " +
5253 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5254 std::to_string(line) + ")\n";
5255 return;
5256 }
5257 } else if(is_from(value)) {
5259 context.compiled_trigger.push_back(
5260 uint16_t(trigger::industrial_score_from_nation | trigger::no_payload | association_to_trigger_code(a)));
5261 else {
5262 err.accumulated_errors += "industrial_score = from trigger used in an incorrect scope type " +
5263 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5264 std::to_string(line) + ")\n";
5265 return;
5266 }
5267 } else if(!parsers::is_integer(value.data(), value.data() + value.length()) && value.length() == 3) {
5268 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5269 it != context.outer_context.map_of_ident_names.end()) {
5270 context.compiled_trigger.push_back(uint16_t(trigger::industrial_score_tag | association_to_bool_code(a)));
5271 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5272 } else {
5273 err.accumulated_errors += "industrial_score trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5274 }
5275 } else {
5276 context.compiled_trigger.push_back(uint16_t(trigger::industrial_score_value | association_to_trigger_code(a)));
5277 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
5278 }
5279 } else {
5280 err.accumulated_errors += "industrial_score trigger used in an incorrect scope type " +
5281 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5282 std::to_string(line) + ")\n";
5283 return;
5284 }
5285 }
5286 void military_score(association_type a, std::string_view value, error_handler& err, int32_t line,
5287 trigger_building_context& context) {
5289 if(is_this(value)) {
5291 context.compiled_trigger.push_back(
5292 uint16_t(trigger::military_score_this_nation | trigger::no_payload | association_to_trigger_code(a)));
5293 else if(context.this_slot == trigger::slot_contents::state)
5294 context.compiled_trigger.push_back(
5295 uint16_t(trigger::military_score_this_state | trigger::no_payload | association_to_trigger_code(a)));
5297 context.compiled_trigger.push_back(
5298 uint16_t(trigger::military_score_this_province | trigger::no_payload | association_to_trigger_code(a)));
5299 else if(context.this_slot == trigger::slot_contents::pop)
5300 context.compiled_trigger.push_back(
5301 uint16_t(trigger::military_score_this_pop | trigger::no_payload | association_to_trigger_code(a)));
5302 else {
5303 err.accumulated_errors += "military_score = this trigger used in an incorrect scope type " +
5304 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5305 std::to_string(line) + ")\n";
5306 return;
5307 }
5308 } else if(is_from(value)) {
5310 context.compiled_trigger.push_back(
5311 uint16_t(trigger::military_score_from_nation | trigger::no_payload | association_to_trigger_code(a)));
5312 else {
5313 err.accumulated_errors += "military_score = from trigger used in an incorrect scope type " +
5314 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5315 std::to_string(line) + ")\n";
5316 return;
5317 }
5318 } else if(!parsers::is_integer(value.data(), value.data() + value.length()) && value.length() == 3) {
5319 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5320 it != context.outer_context.map_of_ident_names.end()) {
5321 context.compiled_trigger.push_back(uint16_t(trigger::military_score_tag | association_to_bool_code(a)));
5322 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5323 } else {
5324 err.accumulated_errors += "military_score trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5325 }
5326 } else {
5327 context.compiled_trigger.push_back(uint16_t(trigger::military_score_value | association_to_trigger_code(a)));
5328 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
5329 }
5330 } else {
5331 err.accumulated_errors += "military_score trigger used in an incorrect scope type " +
5332 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5333 std::to_string(line) + ")\n";
5334 return;
5335 }
5336 }
5337 void test(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
5338 if(auto it = context.outer_context.map_of_stored_triggers.find(std::string(value)); it != context.outer_context.map_of_stored_triggers.end()) {
5339 dcon::stored_trigger_id st;
5340 for(auto r : it->second) {
5341 if((r.main_slot == context.main_slot || r.main_slot == trigger::slot_contents::empty)
5342 && (r.from_slot == context.from_slot || r.from_slot == trigger::slot_contents::empty)
5343 && (r.this_slot == context.this_slot || r.this_slot == trigger::slot_contents::empty)) {
5344
5345 if(!st) {
5346 st = r.id;
5347 } else {
5348 err.accumulated_errors += "test trigger found multiple matching possibilities for the name " +
5349 std::string(value) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5350 return;
5351 }
5352 }
5353 }
5354 if(st) {
5355 context.compiled_trigger.push_back(uint16_t(trigger::test | association_to_bool_code(a)));
5356 context.compiled_trigger.push_back(trigger::payload(st).value);
5357 } else {
5358 err.accumulated_errors += "test trigger was unable to find a version of " + std::string(value) + " that matched the local parameters (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5359 }
5360 } else {
5361 err.accumulated_errors += "test trigger used with an unknown scripted trigger " + std::string(value) + " (" + err.file_name + ", line " +
5362 std::to_string(line) + ")\n";
5363 }
5364 }
5365 void is_possible_vassal(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
5366 if(value.length() == 3) {
5367 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5368 it != context.outer_context.map_of_ident_names.end()) {
5370 context.compiled_trigger.push_back(uint16_t(trigger::is_possible_vassal | association_to_bool_code(a)));
5371 } else {
5372 err.accumulated_errors += "is_possible_vassal trigger used in an incorrect scope type " +
5373 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5374 std::to_string(line) + ")\n";
5375 return;
5376 }
5377 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5378 } else {
5379 err.accumulated_errors += "is_possible_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " +
5380 std::to_string(line) + ")\n";
5381 }
5382 } else {
5383 err.accumulated_errors +=
5384 "is_possible_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5385 }
5386 }
5387
5388 void diplomatic_influence(tr_diplomatic_influence const& value, error_handler& err, int32_t line,
5389 trigger_building_context& context) {
5391 err.accumulated_errors += "diplomatic_influence trigger used in an incorrect scope type " +
5392 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5393 std::to_string(line) + ")\n";
5394 return;
5395 } else if(is_from(value.who)) {
5397 context.compiled_trigger.push_back(
5398 uint16_t(trigger::diplomatic_influence_from_nation | association_to_trigger_code(value.a)));
5400 context.compiled_trigger.push_back(
5401 uint16_t(trigger::diplomatic_influence_from_province | association_to_trigger_code(value.a)));
5402 else {
5403 err.accumulated_errors += "diplomatic_influence trigger used in an incorrect scope type " +
5404 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5405 std::to_string(line) + ")\n";
5406 return;
5407 }
5408 context.compiled_trigger.push_back(trigger::payload(uint16_t(value.value_)).value);
5409 } else if(is_this(value.who)) {
5411 context.compiled_trigger.push_back(
5412 uint16_t(trigger::diplomatic_influence_this_nation | association_to_trigger_code(value.a)));
5414 context.compiled_trigger.push_back(
5415 uint16_t(trigger::diplomatic_influence_this_province | association_to_trigger_code(value.a)));
5416 else {
5417 err.accumulated_errors += "diplomatic_influence trigger used in an incorrect scope type " +
5418 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5419 std::to_string(line) + ")\n";
5420 return;
5421 }
5422 context.compiled_trigger.push_back(trigger::payload(uint16_t(value.value_)).value);
5423 } else if(value.who.length() == 3) {
5424 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
5425 it != context.outer_context.map_of_ident_names.end()) {
5426 context.compiled_trigger.push_back(uint16_t(trigger::diplomatic_influence_tag | association_to_trigger_code(value.a)));
5427 context.compiled_trigger.push_back(trigger::payload(uint16_t(value.value_)).value);
5428 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5429 } else {
5430 err.accumulated_errors += "diplomatic_influence trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " +
5431 std::to_string(line) + ")\n";
5432 }
5433 } else {
5434 err.accumulated_errors += "diplomatic_influence trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " +
5435 std::to_string(line) + ")\n";
5436 return;
5437 }
5438 }
5439 void pop_unemployment(tr_pop_unemployment const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5440 if(is_this(value.type)) {
5441 if(context.this_slot != trigger::slot_contents::pop) {
5442 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5443 std::to_string(line) + ")\n";
5444 return;
5445 } else if(context.main_slot == trigger::slot_contents::nation)
5446 context.compiled_trigger.push_back(
5447 uint16_t(trigger::pop_unemployment_nation_this_pop | association_to_trigger_code(value.a)));
5448 else if(context.main_slot == trigger::slot_contents::state)
5449 context.compiled_trigger.push_back(
5450 uint16_t(trigger::pop_unemployment_state_this_pop | association_to_trigger_code(value.a)));
5452 context.compiled_trigger.push_back(
5453 uint16_t(trigger::pop_unemployment_province_this_pop | association_to_trigger_code(value.a)));
5454 else {
5455 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5456 std::to_string(line) + ")\n";
5457 return;
5458 }
5459 context.add_float_to_payload(value.value_);
5460 } else if(is_from(value.type)) {
5461 if(context.this_slot != trigger::slot_contents::pop) {
5462 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5463 std::to_string(line) + ")\n";
5464 return;
5465 } else if(context.main_slot == trigger::slot_contents::nation)
5466 context.compiled_trigger.push_back(
5467 uint16_t(trigger::pop_unemployment_nation_this_pop | association_to_trigger_code(value.a)));
5468 else if(context.main_slot == trigger::slot_contents::state)
5469 context.compiled_trigger.push_back(
5470 uint16_t(trigger::pop_unemployment_state_this_pop | association_to_trigger_code(value.a)));
5472 context.compiled_trigger.push_back(
5473 uint16_t(trigger::pop_unemployment_province_this_pop | association_to_trigger_code(value.a)));
5474 else {
5475 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5476 std::to_string(line) + ")\n";
5477 return;
5478 }
5479 context.add_float_to_payload(value.value_);
5480 } else if(auto it = context.outer_context.map_of_poptypes.find(std::string(value.type));
5481 it != context.outer_context.map_of_poptypes.end()) {
5483 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_nation | association_to_trigger_code(value.a)));
5484 else if(context.main_slot == trigger::slot_contents::state)
5485 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_state | association_to_trigger_code(value.a)));
5487 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_province | association_to_trigger_code(value.a)));
5488 else if(context.main_slot == trigger::slot_contents::pop)
5489 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_pop | association_to_trigger_code(value.a)));
5490 else {
5491 err.accumulated_errors +=
5492 "pop_unemployment trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5493 return;
5494 }
5495
5496 context.add_float_to_payload(value.value_);
5497 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5498 } else {
5499 err.accumulated_errors += "pop_unemployment trigger supplied with an invalid pop type (" + err.file_name + ", line " +
5500 std::to_string(line) + ")\n";
5501 return;
5502 }
5503 }
5504 void relation(tr_relation const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5506 err.accumulated_errors +=
5507 "relation trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5508 return;
5509 } else if(is_from(value.who)) {
5511 context.compiled_trigger.push_back(uint16_t(trigger::relation_from_nation | association_to_trigger_code(value.a)));
5513 context.compiled_trigger.push_back(uint16_t(trigger::relation_from_province | association_to_trigger_code(value.a)));
5514 else {
5515 err.accumulated_errors +=
5516 "relation = from trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5517 return;
5518 }
5519 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5520 } else if(is_this(value.who)) {
5522 context.compiled_trigger.push_back(uint16_t(trigger::relation_this_nation | association_to_trigger_code(value.a)));
5524 context.compiled_trigger.push_back(uint16_t(trigger::relation_this_province | association_to_trigger_code(value.a)));
5525 else if(context.this_slot == trigger::slot_contents::pop)
5526 context.compiled_trigger.push_back(uint16_t(trigger::relation_this_pop | association_to_trigger_code(value.a)));
5527 else {
5528 err.accumulated_errors +=
5529 "relation = this trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5530 return;
5531 }
5532 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5533 } else if(value.who.length() == 3) {
5534 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
5535 it != context.outer_context.map_of_ident_names.end()) {
5536 context.compiled_trigger.push_back(uint16_t(trigger::relation_tag | association_to_trigger_code(value.a)));
5537 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5538 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5539 } else {
5540 err.accumulated_errors +=
5541 "relation trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5542 }
5543 } else {
5544 err.accumulated_errors +=
5545 "relation trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5546 return;
5547 }
5548 }
5549 void check_variable(tr_check_variable const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5550 context.compiled_trigger.push_back(uint16_t(trigger::check_variable | association_to_trigger_code(value.a)));
5551 context.add_float_to_payload(value.value_);
5552 context.compiled_trigger.push_back(
5553 trigger::payload(context.outer_context.get_national_variable(std::string(value.which))).value);
5554 }
5555 void upper_house(tr_upper_house const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5556 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value.ideology));
5557 it != context.outer_context.map_of_ideologies.end()) {
5559 err.accumulated_errors +=
5560 "upper_house trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5561 return;
5562 }
5563 context.compiled_trigger.push_back(uint16_t(trigger::upper_house | association_to_trigger_code(value.a)));
5564 context.add_float_to_payload(value.value_);
5565 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5566 } else {
5567 err.accumulated_errors +=
5568 "upper_house trigger supplied with an invalid ideology \"" + std::string(value.ideology) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5569 return;
5570 }
5571 }
5572 void unemployment_by_type(tr_unemployment_by_type const& value, error_handler& err, int32_t line,
5573 trigger_building_context& context) {
5574 if(auto it = context.outer_context.map_of_poptypes.find(std::string(value.type));
5575 it != context.outer_context.map_of_poptypes.end()) {
5577 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_by_type_nation | association_to_trigger_code(value.a)));
5578 else if(context.main_slot == trigger::slot_contents::state)
5579 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_by_type_state | association_to_trigger_code(value.a)));
5581 context.compiled_trigger.push_back(
5582 uint16_t(trigger::unemployment_by_type_province | association_to_trigger_code(value.a)));
5583 else if(context.main_slot == trigger::slot_contents::pop)
5584 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_by_type_pop | association_to_trigger_code(value.a)));
5585 else {
5586 err.accumulated_errors += "unemployment_by_type trigger used in an invalid context (" + err.file_name + ", line " +
5587 std::to_string(line) + ")\n";
5588 return;
5589 }
5590 context.add_float_to_payload(value.value_);
5591 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5592 } else {
5593 err.accumulated_errors += "unemployment_by_type trigger supplied with an invalid pop type \"" + std::string(value.type) + "\" (" + err.file_name + ", line " +
5594 std::to_string(line) + ")\n";
5595 return;
5596 }
5597 }
5598
5599 void party_loyalty(tr_party_loyalty const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5600 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value.ideology));
5601 it != context.outer_context.map_of_ideologies.end()) {
5602 if(value.province_id != 0) {
5603 if(0 <= value.province_id && size_t(value.province_id) < context.outer_context.original_id_to_prov_id_map.size()) {
5605 context.compiled_trigger.push_back(
5606 uint16_t(trigger::party_loyalty_nation_province_id | association_to_trigger_code(value.a)));
5607 else if(context.from_slot == trigger::slot_contents::nation)
5608 context.compiled_trigger.push_back(
5609 uint16_t(trigger::party_loyalty_from_nation_province_id | association_to_trigger_code(value.a)));
5611 context.compiled_trigger.push_back(
5612 uint16_t(trigger::party_loyalty_province_province_id | association_to_trigger_code(value.a)));
5614 context.compiled_trigger.push_back(
5615 uint16_t(trigger::party_loyalty_from_province_province_id | association_to_trigger_code(value.a)));
5616 else {
5617 err.accumulated_errors +=
5618 "party_loyalty trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5619 return;
5620 }
5621 context.compiled_trigger.push_back(
5623 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5624 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5625 } else {
5626 err.accumulated_errors += "party_loyalty trigger supplied with an invalid province id " + std::to_string(value.province_id) + " (" + err.file_name + ", line " +
5627 std::to_string(line) + ")\n";
5628 return;
5629 }
5630 } else {
5633 context.compiled_trigger.push_back(
5634 uint16_t(trigger::party_loyalty_from_nation_scope_province | association_to_trigger_code(value.a)));
5636 context.compiled_trigger.push_back(
5637 uint16_t(trigger::party_loyalty_from_province_scope_province | association_to_trigger_code(value.a)));
5638 else
5639 context.compiled_trigger.push_back(uint16_t(trigger::party_loyalty_generic | association_to_trigger_code(value.a)));
5640 } else {
5641 err.accumulated_errors +=
5642 "party_loyalty trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5643 return;
5644 }
5645 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5646 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5647 }
5648 } else {
5649 err.accumulated_errors +=
5650 "party_loyalty trigger supplied with an invalid ideology \"" + std::string(value.ideology) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5651 return;
5652 }
5653 }
5654
5655 void can_build_in_province(tr_can_build_in_province const& value, error_handler& err, int32_t line,
5656 trigger_building_context& context) {
5658 err.accumulated_errors +=
5659 "can_build_in_province trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5660 return;
5661 } else if(value.limit_to_world_greatest_level) {
5663 if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "railroad"))
5664 context.compiled_trigger.push_back(uint16_t(
5665 trigger::can_build_in_province_railroad_yes_limit_this_nation | trigger::association_eq | trigger::no_payload));
5666 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "naval_base"))
5667 context.compiled_trigger.push_back(uint16_t(
5668 trigger::can_build_in_province_naval_base_yes_limit_this_nation | trigger::association_eq | trigger::no_payload));
5669 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "fort"))
5670 context.compiled_trigger.push_back(uint16_t(
5671 trigger::can_build_in_province_fort_yes_limit_this_nation | trigger::association_eq | trigger::no_payload));
5672 } else if(context.from_slot == trigger::slot_contents::nation) {
5673 if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "railroad"))
5674 context.compiled_trigger.push_back(uint16_t(
5675 trigger::can_build_in_province_railroad_yes_limit_from_nation | trigger::association_eq | trigger::no_payload));
5676 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "naval_base"))
5677 context.compiled_trigger.push_back(uint16_t(
5678 trigger::can_build_in_province_naval_base_yes_limit_from_nation | trigger::association_eq | trigger::no_payload));
5679 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "fort"))
5680 context.compiled_trigger.push_back(uint16_t(
5681 trigger::can_build_in_province_fort_yes_limit_from_nation | trigger::association_eq | trigger::no_payload));
5682 } else {
5683 err.accumulated_errors += "can_build_in_province trigger used in an invalid context (" + err.file_name + ", line " +
5684 std::to_string(line) + ")\n";
5685 return;
5686 }
5687 } else {
5689 if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "railroad"))
5690 context.compiled_trigger.push_back(uint16_t(
5691 trigger::can_build_in_province_railroad_no_limit_this_nation | trigger::association_eq | trigger::no_payload));
5692 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "naval_base"))
5693 context.compiled_trigger.push_back(uint16_t(
5694 trigger::can_build_in_province_naval_base_no_limit_this_nation | trigger::association_eq | trigger::no_payload));
5695 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "fort"))
5696 context.compiled_trigger.push_back(
5697 uint16_t(trigger::can_build_in_province_fort_no_limit_this_nation | trigger::association_eq | trigger::no_payload));
5698 } else if(context.from_slot == trigger::slot_contents::nation) {
5699 if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "railroad"))
5700 context.compiled_trigger.push_back(uint16_t(
5701 trigger::can_build_in_province_railroad_no_limit_from_nation | trigger::association_eq | trigger::no_payload));
5702 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "naval_base"))
5703 context.compiled_trigger.push_back(uint16_t(
5704 trigger::can_build_in_province_naval_base_no_limit_from_nation | trigger::association_eq | trigger::no_payload));
5705 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "fort"))
5706 context.compiled_trigger.push_back(
5707 uint16_t(trigger::can_build_in_province_fort_no_limit_from_nation | trigger::association_eq | trigger::no_payload));
5708 } else {
5709 err.accumulated_errors += "can_build_in_province trigger used in an invalid context (" + err.file_name + ", line " +
5710 std::to_string(line) + ")\n";
5711 return;
5712 }
5713 }
5714 }
5716 trigger_building_context& context) {
5718 err.accumulated_errors += "can_build_railway_in_capital trigger used in an invalid context (" + err.file_name + ", line " +
5719 std::to_string(line) + ")\n";
5720 return;
5721 } else if(value.in_whole_capital_state) {
5722 if(value.limit_to_world_greatest_level)
5723 context.compiled_trigger.push_back(uint16_t(
5724 trigger::can_build_railway_in_capital_yes_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5725 else
5726 context.compiled_trigger.push_back(uint16_t(
5727 trigger::can_build_railway_in_capital_yes_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5728 } else {
5729 if(value.limit_to_world_greatest_level)
5730 context.compiled_trigger.push_back(uint16_t(
5731 trigger::can_build_railway_in_capital_no_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5732 else
5733 context.compiled_trigger.push_back(uint16_t(
5734 trigger::can_build_railway_in_capital_no_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5735 }
5736 }
5738 trigger_building_context& context) {
5740 err.accumulated_errors += "can_build_fort_in_capital trigger used in an invalid context (" + err.file_name + ", line " +
5741 std::to_string(line) + ")\n";
5742 return;
5743 } else if(value.in_whole_capital_state) {
5744 if(value.limit_to_world_greatest_level)
5745 context.compiled_trigger.push_back(uint16_t(
5746 trigger::can_build_fort_in_capital_yes_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5747 else
5748 context.compiled_trigger.push_back(uint16_t(
5749 trigger::can_build_fort_in_capital_yes_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5750 } else {
5751 if(value.limit_to_world_greatest_level)
5752 context.compiled_trigger.push_back(uint16_t(
5753 trigger::can_build_fort_in_capital_no_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5754 else
5755 context.compiled_trigger.push_back(
5756 uint16_t(trigger::can_build_fort_in_capital_no_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5757 }
5758 }
5759
5760 void work_available(tr_work_available const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5761 if(value.pop_type_list.size() > 1 || value.pop_type_list.size() == 0) {
5762 err.accumulated_errors += "work_available trigger used with an unsupported number of worker types (" + err.file_name +
5763 ", line " + std::to_string(line) + ")\n";
5764 return;
5765 }
5766
5768 context.compiled_trigger.push_back(uint16_t(trigger::work_available_nation | trigger::association_eq));
5769 else if(context.main_slot == trigger::slot_contents::state)
5770 context.compiled_trigger.push_back(uint16_t(trigger::work_available_state | trigger::association_eq));
5772 context.compiled_trigger.push_back(uint16_t(trigger::work_available_province | trigger::association_eq));
5773 else {
5774 err.accumulated_errors +=
5775 "work_available trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5776 return;
5777 }
5778 context.compiled_trigger.push_back(trigger::payload(value.pop_type_list[0]).value);
5779 }
5780 void party_name(tr_party_name const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5782 err.accumulated_errors += "party_name effect used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5783 std::to_string(line) + ")\n";
5784 return;
5785 }
5786 context.compiled_trigger.push_back(trigger::party_name);
5787 context.compiled_trigger.push_back(trigger::payload(value.ideology_).value);
5788 context.add_int32_t_to_payload(value.name_.index());
5789 }
5790 void party_position(tr_party_position const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5792 err.accumulated_errors += "party_position trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5793 std::to_string(line) + ")\n";
5794 return;
5795 } else if(!value.opt_) {
5796 err.accumulated_errors += "party_position trigger used without a valid position " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5797 std::to_string(line) + ")\n";
5798 return;
5799 }
5800 context.compiled_trigger.push_back(trigger::party_position);
5801 context.compiled_trigger.push_back(trigger::payload(value.ideology_).value);
5802 context.compiled_trigger.push_back(trigger::payload(value.opt_).value);
5803 }
5804 void any_value(std::string_view label, association_type a, std::string_view value, error_handler& err, int32_t line,
5805 trigger_building_context& context) {
5806 std::string str_label{label};
5807 if(auto it = context.outer_context.map_of_technologies.find(str_label);
5808 it != context.outer_context.map_of_technologies.end()) {
5810 bool bvalue = parse_bool(value, line, err);
5811 context.compiled_trigger.push_back(uint16_t(trigger::technology | association_to_bool_code(a, bvalue)));
5812 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5813 } else if(context.main_slot == trigger::slot_contents::province) {
5814 bool bvalue = parse_bool(value, line, err);
5815 context.compiled_trigger.push_back(uint16_t(trigger::technology_province | association_to_bool_code(a, bvalue)));
5816 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5817 } else if(context.main_slot == trigger::slot_contents::pop) {
5818 bool bvalue = parse_bool(value, line, err);
5819 context.compiled_trigger.push_back(uint16_t(trigger::technology_pop | association_to_bool_code(a, bvalue)));
5820 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5821 } else {
5822 err.accumulated_errors += "named technology trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5823 return;
5824 }
5825 } else if(auto itb = context.outer_context.map_of_inventions.find(str_label);
5826 itb != context.outer_context.map_of_inventions.end()) {
5828 bool bvalue = parse_bool(value, line, err);
5829 context.compiled_trigger.push_back(uint16_t(trigger::invention | association_to_bool_code(a, bvalue)));
5830 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
5831 } else if(context.main_slot == trigger::slot_contents::province) {
5832 bool bvalue = parse_bool(value, line, err);
5833 context.compiled_trigger.push_back(uint16_t(trigger::invention_province | association_to_bool_code(a, bvalue)));
5834 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
5835 } else if(context.main_slot == trigger::slot_contents::pop) {
5836 bool bvalue = parse_bool(value, line, err);
5837 context.compiled_trigger.push_back(uint16_t(trigger::invention_pop | association_to_bool_code(a, bvalue)));
5838 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
5839 } else {
5840 err.accumulated_errors += "named invention trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5841 return;
5842 }
5843 } else if(auto itc = context.outer_context.map_of_ideologies.find(str_label);
5844 itc != context.outer_context.map_of_ideologies.end()) {
5846 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_nation | association_to_trigger_code(a)));
5847 else if(context.main_slot == trigger::slot_contents::pop)
5848 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_pop | association_to_trigger_code(a)));
5850 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_province | association_to_trigger_code(a)));
5851 else if(context.main_slot == trigger::slot_contents::state)
5852 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_state | association_to_trigger_code(a)));
5853 else {
5854 err.accumulated_errors +=
5855 "named ideology trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5856 return;
5857 }
5858 context.compiled_trigger.push_back(trigger::payload(itc->second.id).value);
5859 context.add_float_to_payload(parse_float(value, line, err));
5860 } else if(auto itd = context.outer_context.map_of_poptypes.find(str_label);
5861 itd != context.outer_context.map_of_poptypes.end()) {
5863 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_nation | association_to_trigger_code(a)));
5864 else if(context.main_slot == trigger::slot_contents::pop)
5865 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_pop | association_to_trigger_code(a)));
5867 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_province | association_to_trigger_code(a)));
5868 else if(context.main_slot == trigger::slot_contents::state)
5869 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_state | association_to_trigger_code(a)));
5870 else {
5871 err.accumulated_errors +=
5872 "named pop type trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5873 return;
5874 }
5875 context.compiled_trigger.push_back(trigger::payload(itd->second).value);
5876 context.add_float_to_payload(parse_float(value, line, err));
5877 } else if(auto ite = context.outer_context.map_of_commodity_names.find(str_label);
5878 ite != context.outer_context.map_of_commodity_names.end()) {
5880 context.compiled_trigger.push_back(uint16_t(trigger::variable_good_name | association_to_trigger_code(a)));
5881 else {
5882 err.accumulated_errors +=
5883 "named commodity trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5884 return;
5885 }
5886 context.compiled_trigger.push_back(trigger::payload(ite->second).value);
5887 context.add_float_to_payload(parse_float(value, line, err));
5888 } else if(auto itg = context.outer_context.map_of_ioptions.find(str_label); itg != context.outer_context.map_of_ioptions.end()) {
5890 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_nation | association_to_trigger_code(a)));
5891 else if(context.main_slot == trigger::slot_contents::pop)
5892 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_pop | association_to_trigger_code(a)));
5894 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_province | association_to_trigger_code(a)));
5895 else if(context.main_slot == trigger::slot_contents::state)
5896 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_state | association_to_trigger_code(a)));
5897 else {
5898 err.accumulated_errors +=
5899 "named issue option trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5900 return;
5901 }
5902 context.compiled_trigger.push_back(trigger::payload(itg->second.id).value);
5903 context.add_float_to_payload(parse_float(value, line, err) / 100.0f);
5904 } else if(auto itf = context.outer_context.map_of_iissues.find(str_label); itf != context.outer_context.map_of_iissues.end()) {
5905 if(auto itopt = context.outer_context.map_of_ioptions.find(std::string(value));
5906 itopt != context.outer_context.map_of_ioptions.end()) {
5908 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_nation | association_to_bool_code(a)));
5909 else if(context.main_slot == trigger::slot_contents::pop)
5910 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_pop | association_to_bool_code(a)));
5912 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_province | association_to_bool_code(a)));
5913 else if(context.main_slot == trigger::slot_contents::state)
5914 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_state | association_to_bool_code(a)));
5915 else {
5916 err.accumulated_errors +=
5917 "named issue trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5918 return;
5919 }
5920 context.compiled_trigger.push_back(trigger::payload(itf->second).value);
5921 context.compiled_trigger.push_back(trigger::payload(itopt->second.id).value);
5922 } else {
5923 err.accumulated_errors +=
5924 "named issue trigger used with an invalid option name (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5925 return;
5926 }
5927 } else if(auto ith = context.outer_context.map_of_reforms.find(str_label); ith != context.outer_context.map_of_reforms.end()) {
5928 if(auto itopt = context.outer_context.map_of_roptions.find(std::string(value));
5929 itopt != context.outer_context.map_of_roptions.end()) {
5931 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_nation | association_to_bool_code(a)));
5932 else if(context.main_slot == trigger::slot_contents::pop)
5933 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_pop | association_to_bool_code(a)));
5935 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_province | association_to_bool_code(a)));
5936 else if(context.main_slot == trigger::slot_contents::state)
5937 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_state | association_to_bool_code(a)));
5938 else {
5939 err.accumulated_errors +=
5940 "named reform trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5941 return;
5942 }
5943 context.compiled_trigger.push_back(trigger::payload(ith->second).value);
5944 context.compiled_trigger.push_back(trigger::payload(itopt->second.id).value);
5945 } else {
5946 err.accumulated_errors +=
5947 "named reform trigger used with an invalid option name (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5948 return;
5949 }
5950 } else {
5951 err.accumulated_errors +=
5952 "unknown key: " + str_label + " found in trigger(" + err.file_name + ", line " + std::to_string(line) + ")\n";
5953 return;
5954 }
5955 }
5956};
5957
5958void tr_scope_and(token_generator& gen, error_handler& err, trigger_building_context& context);
5959void tr_scope_or(token_generator& gen, error_handler& err, trigger_building_context& context);
5960void tr_scope_not(token_generator& gen, error_handler& err, trigger_building_context& context);
5961void tr_scope_any_neighbor_province(token_generator& gen, error_handler& err, trigger_building_context& context);
5962void tr_scope_any_neighbor_country(token_generator& gen, error_handler& err, trigger_building_context& context);
5963void tr_scope_war_countries(token_generator& gen, error_handler& err, trigger_building_context& context);
5964void tr_scope_all_war_countries(token_generator& gen, error_handler& err, trigger_building_context& context);
5965void tr_scope_any_greater_power(token_generator& gen, error_handler& err, trigger_building_context& context);
5966void tr_scope_any_owned_province(token_generator& gen, error_handler& err, trigger_building_context& context);
5967void tr_scope_any_core(token_generator& gen, error_handler& err, trigger_building_context& context);
5968void tr_scope_all_core(token_generator& gen, error_handler& err, trigger_building_context& context);
5969void tr_scope_any_state(token_generator& gen, error_handler& err, trigger_building_context& context);
5970void tr_scope_any_substate(token_generator& gen, error_handler& err, trigger_building_context& context);
5971void tr_scope_any_sphere_member(token_generator& gen, error_handler& err, trigger_building_context& context);
5972void tr_scope_any_pop(token_generator& gen, error_handler& err, trigger_building_context& context);
5973void tr_scope_owner(token_generator& gen, error_handler& err, trigger_building_context& context);
5974void tr_scope_controller(token_generator& gen, error_handler& err, trigger_building_context& context);
5975void tr_scope_location(token_generator& gen, error_handler& err, trigger_building_context& context);
5976void tr_scope_country(token_generator& gen, error_handler& err, trigger_building_context& context);
5977void tr_capital_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5978void tr_scope_this(token_generator& gen, error_handler& err, trigger_building_context& context);
5979void tr_scope_from(token_generator& gen, error_handler& err, trigger_building_context& context);
5980void tr_scope_sea_zone(token_generator& gen, error_handler& err, trigger_building_context& context);
5981void tr_scope_cultural_union(token_generator& gen, error_handler& err, trigger_building_context& context);
5982void tr_scope_overlord(token_generator& gen, error_handler& err, trigger_building_context& context);
5983void tr_scope_sphere_owner(token_generator& gen, error_handler& err, trigger_building_context& context);
5984void tr_scope_independence(token_generator& gen, error_handler& err, trigger_building_context& context);
5985void tr_flashpoint_tag_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5986void tr_crisis_state_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5987void tr_state_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5988void tr_scope_variable(std::string_view name, token_generator& gen, error_handler& err, trigger_building_context& context);
5989//extensions
5990void tr_scope_any_country(token_generator& gen, error_handler& err, trigger_building_context& context);
5991void tr_scope_all_state(token_generator& gen, error_handler& err, trigger_building_context& context);
5992void tr_scope_all_substate(token_generator& gen, error_handler& err, trigger_building_context& context);
5993void tr_scope_all_sphere_member(token_generator& gen, error_handler& err, trigger_building_context& context);
5994void tr_scope_all_pop(token_generator& gen, error_handler& err, trigger_building_context& context);
5995void tr_scope_all_greater_power(token_generator& gen, error_handler& err, trigger_building_context& context);
5996void tr_scope_every_country(token_generator& gen, error_handler& err, trigger_building_context& context);
5997
5998void invert_trigger(uint16_t* source);
5999bool scope_is_empty(uint16_t const* source);
6000bool scope_has_single_member(uint16_t const* source);
6001int32_t simplify_trigger(uint16_t* source);
6002dcon::trigger_key make_trigger(token_generator& gen, error_handler& err, trigger_building_context& context);
6003
6005 std::optional<float> factor;
6006 float base = 0.0f;
6007 void months(association_type, float value, error_handler& err, int32_t line, trigger_building_context& context) {
6008 factor = value * 30.0f;
6009 }
6010 void years(association_type, float value, error_handler& err, int32_t line, trigger_building_context& context) {
6011 factor = value * 365.0f;
6012 }
6013 void group(value_modifier_definition const& value, error_handler& err, int32_t line, trigger_building_context& context) { }
6015};
6016
6017void make_value_modifier_segment(token_generator& gen, error_handler& err, trigger_building_context& context);
6018dcon::value_modifier_key make_value_modifier(token_generator& gen, error_handler& err, trigger_building_context& context);
6019
6022};
6023
6025 void main_parameter(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
6026 if(context.compiled_trigger.size() <= 2) {
6027 if(is_fixed_token_ci(value.data(), value.data() + value.size(), "nation") || is_fixed_token_ci(value.data(), value.data() + value.size(), "country")) {
6029 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "state")) {
6031 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "province")) {
6033 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "pop")) {
6035 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "rebel")) {
6037 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "none")) {
6039 } else {
6040 err.accumulated_errors +=
6041 "unknown parameter type " + std::string(value) + " defined for a scripted trigger (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6042 }
6043 } else {
6044 err.accumulated_errors +=
6045 "parameters for a scripted trigger must be given first (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6046 }
6047 }
6048 void this_parameter(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
6049 if(context.compiled_trigger.size() <= 2) {
6050 if(is_fixed_token_ci(value.data(), value.data() + value.size(), "nation") || is_fixed_token_ci(value.data(), value.data() + value.size(), "country")) {
6052 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "state")) {
6054 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "province")) {
6056 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "pop")) {
6058 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "rebel")) {
6060 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "none")) {
6062 } else {
6063 err.accumulated_errors +=
6064 "unknown parameter type " + std::string(value) + " defined for a scripted trigger (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6065 }
6066 } else {
6067 err.accumulated_errors +=
6068 "parameters for a scripted trigger must be given first (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6069 }
6070 }
6071 void from_parameter(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
6072 if(context.compiled_trigger.size() <= 2) {
6073 if(is_fixed_token_ci(value.data(), value.data() + value.size(), "nation") || is_fixed_token_ci(value.data(), value.data() + value.size(), "country")) {
6075 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "state")) {
6077 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "province")) {
6079 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "pop")) {
6081 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "rebel")) {
6083 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "none")) {
6085 } else {
6086 err.accumulated_errors +=
6087 "unknown parameter type " + std::string(value) + " defined for a scripted trigger (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6088 }
6089 } else {
6090 err.accumulated_errors +=
6091 "parameters for a scripted trigger must be given first (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6092 }
6093 }
6094};
6095
6096void make_stored_trigger(std::string_view tag, token_generator& gen, error_handler& err, scenario_building_context& context);
6097
6098} // namespace parsers
std::string accumulated_errors
Definition: parsers.hpp:62
std::string file_name
Definition: parsers.hpp:61
dcon::modifier_id get_province_immigrator_modifier(sys::state &state)
Definition: economy.cpp:5383
dcon::modifier_id get_province_selector_modifier(sys::state &state)
Definition: economy.cpp:5379
uint32_t tag_to_int(char first, char second, char third)
Definition: nations.hpp:7
uint16_t association_to_trigger_code(association_type a)
bool is_integer(char const *start, char const *end)
Definition: parsers.cpp:46
void tr_scope_all_core(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_substate(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_owned_province(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_crisis_state_scope(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_core(token_generator &gen, error_handler &err, trigger_building_context &context)
bool is_this(std::string_view value)
bool is_reb(std::string_view value)
dcon::trigger_key make_trigger(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_all_state(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_or(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_owner(token_generator &gen, error_handler &err, trigger_building_context &context)
association_type
Definition: parsers.hpp:28
void tr_scope_every_country(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_sphere_member(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_all_pop(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_all_substate(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_country(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_sea_zone(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_cultural_union(token_generator &gen, error_handler &err, trigger_building_context &context)
bool is_from(std::string_view value)
constexpr bool scope_has_any_all(uint16_t code)
void tr_state_scope(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_not(token_generator &gen, error_handler &err, trigger_building_context &context)
void make_stored_trigger(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
dcon::value_modifier_key make_value_modifier(token_generator &gen, error_handler &err, trigger_building_context &context)
int32_t simplify_trigger(uint16_t *source)
void tr_scope_variable(std::string_view name, token_generator &gen, error_handler &err, trigger_building_context &context)
bool scope_is_empty(uint16_t const *source)
void tr_scope_and(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_capital_scope(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_overlord(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_state(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_greater_power(token_generator &gen, error_handler &err, trigger_building_context &context)
bool is_fixed_token_ci(char const *start, char const *end, char const (&t)[N])
Definition: parsers.hpp:275
uint16_t association_to_bool_code(association_type a)
void tr_scope_this(token_generator &gen, error_handler &err, trigger_building_context &context)
int32_t parse_int(std::string_view content, int32_t line, error_handler &err)
Definition: parsers.cpp:226
void tr_scope_country(token_generator &gen, error_handler &err, trigger_building_context &context)
bool parse_bool(std::string_view content, int32_t, error_handler &)
Definition: parsers.cpp:201
uint16_t association_to_le_trigger_code(association_type a)
void tr_scope_controller(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_neighbor_province(token_generator &gen, error_handler &err, trigger_building_context &context)
uint16_t invert_association(uint16_t a)
void tr_scope_from(token_generator &gen, error_handler &err, trigger_building_context &context)
float parse_float(std::string_view content, int32_t line, error_handler &err)
Definition: parsers.cpp:208
void tr_scope_sphere_owner(token_generator &gen, error_handler &err, trigger_building_context &context)
bool scope_has_single_member(uint16_t const *source)
void tr_scope_war_countries(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_pop(token_generator &gen, error_handler &err, trigger_building_context &context)
uint32_t parse_uint(std::string_view content, int32_t line, error_handler &err)
Definition: parsers.cpp:235
std::string slot_contents_to_string(trigger::slot_contents v)
void tr_flashpoint_tag_scope(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_all_war_countries(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_any_neighbor_country(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_all_sphere_member(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_independence(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_location(token_generator &gen, error_handler &err, trigger_building_context &context)
void tr_scope_all_greater_power(token_generator &gen, error_handler &err, trigger_building_context &context)
void invert_trigger(uint16_t *source)
void make_value_modifier_segment(token_generator &gen, error_handler &err, trigger_building_context &context)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
Definition: text.cpp:695
constexpr uint16_t no_payload
constexpr uint16_t x_provinces_in_variable_region
constexpr uint16_t association_gt
constexpr uint16_t association_le
constexpr uint16_t association_ge
constexpr uint16_t association_lt
constexpr uint16_t x_neighbor_province_scope
constexpr uint16_t association_ne
constexpr uint16_t association_eq
ankerl::unordered_dense::map< std::string, dcon::state_definition_id > map_of_state_names
ankerl::unordered_dense::map< std::string, dcon::culture_group_id > map_of_culture_group_names
ankerl::unordered_dense::map< std::string, dcon::national_focus_id > map_of_national_focuses
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
ankerl::unordered_dense::map< std::string, dcon::reform_id > map_of_reforms
std::vector< dcon::province_id > original_id_to_prov_id_map
ankerl::unordered_dense::map< std::string, dcon::issue_id > map_of_iissues
ankerl::unordered_dense::map< std::string, pending_crime_content > map_of_crimes
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< std::string, dcon::region_id > map_of_region_names
ankerl::unordered_dense::map< std::string, std::vector< saved_stored_condition > > map_of_stored_triggers
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
void finish(scenario_building_context const &)
void main_parameter(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void this_parameter(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void from_parameter(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void finish(trigger_building_context &)
void finish(trigger_building_context &)
void value(association_type t, float v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void finish(trigger_building_context &)
void value(association_type t, int32_t v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void value(association_type t, float v, error_handler &err, int32_t line, trigger_building_context &context)
dcon::ideology_id ideology_
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, trigger_building_context &context)
void name(association_type t, std::string_view v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void finish(trigger_building_context &)
void position(association_type t, std::string_view v, error_handler &err, int32_t line, trigger_building_context &context)
dcon::issue_option_id opt_
void ideology(association_type t, std::string_view v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void value(association_type t, float v, error_handler &err, int32_t line, trigger_building_context &context)
void value(association_type t, int32_t v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
std::string_view who
void value(association_type t, float v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void finish(trigger_building_context &)
void value(association_type t, float v, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
std::vector< dcon::pop_type_id > pop_type_list
void worker(association_type, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void poor_tax(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_accepted_culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void any_value(std::string_view label, association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_allies(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void tech_school(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void empty(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void has_recently_lost_war(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void poor_strata_everyday_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void ruling_party_ideology(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void truce_with(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void political_movement(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void life_rating(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void has_country_modifier(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void substate_of(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_state_capital(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void plurality(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void strata(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void controlled_by(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void pop_unemployment(tr_pop_unemployment const &value, error_handler &err, int32_t line, trigger_building_context &context)
void can_build_factory_in_capital_state(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void average_militancy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void minorities(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void is_cultural_union(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void blockade(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void stronger_army_than(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_empty_adjacent_province(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void rich_strata_everyday_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void can_build_factory(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void trade_goods_in_state(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_ideology_enabled(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void nationalism(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void rebel_power_fraction(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void have_core_in(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void badboy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void part_of_sphere(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void total_amount_of_ships(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void cash_reserves(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_claim_crisis(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_revolts(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void has_pop_religion(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_vassals(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void poor_strata_militancy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_liberation_crisis(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void relation(tr_relation const &value, error_handler &err, int32_t line, trigger_building_context &context)
void world_wars_enabled(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)
void has_cultural_sphere(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void middle_tax(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void has_recent_imigration(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void test(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void militancy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_slave(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void poor_strata_life_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void brigades_compare(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_cities(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void great_wars_enabled(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void unemployment_by_type(tr_unemployment_by_type const &value, error_handler &err, int32_t line, trigger_building_context &context)
void can_build_in_province(tr_can_build_in_province const &value, error_handler &err, int32_t line, trigger_building_context &context)
void owns(association_type a, std::string_view v, error_handler &err, int32_t line, trigger_building_context &context)
void crisis_exist(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void check_variable(tr_check_variable const &value, error_handler &err, int32_t line, trigger_building_context &context)
void trade_goods(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void civilized(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void in_sphere(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void average_consciousness(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void industrial_score(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void this_culture_union(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void rich_strata_luxury_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void can_nationalize(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void party_position(tr_party_position const &value, error_handler &err, int32_t line, trigger_building_context &context)
void is_overseas(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void religion(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_vassal(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void pop_majority_religion(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void everyday_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void constructing_cb(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void party_name(tr_party_name const &value, error_handler &err, int32_t line, trigger_building_context &context)
void unit_has_leader(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void war_exhaustion(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void civilization_progress(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_primary_culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_capital(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void party_loyalty(tr_party_loyalty const &value, error_handler &err, int32_t line, trigger_building_context &context)
void military_access(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_colonial(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void has_country_flag(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void vassal_of(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void unit_in_battle(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void units_in_province(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void middle_strata_everyday_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_core(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void upper_house(tr_upper_house const &value, error_handler &err, int32_t line, trigger_building_context &context)
void revanchism(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void always(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void constructing_cb_discovered(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void is_independant(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void is_disarmed(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void culture_group(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void constructing_cb_progress(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void rich_strata_militancy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void money(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void crisis_temperature(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void neighbour(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_vassals_no_substates(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void can_build_railway_in_capital(tr_can_build_railway_in_capital const &value, error_handler &err, int32_t line, trigger_building_context &context)
void social_movement_strength(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void total_num_of_ports(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void number_of_states(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void total_pops(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void controls(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void is_sphere_leader_of(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_leader(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void political_movement_strength(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_possible_vassal(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void primary_culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void someone_can_form_union_tag(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void literacy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void alliance_with(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void big_producer(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void war_with(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void invention(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void year(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void month(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void exists(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_substate(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void ai(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void terrain(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_our_vassal(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void administration_spending(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void casus_belli(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void state_id(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void has_factories(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void accepted_culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void controlled_by_rebels(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void produces(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_national_focus(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_pop_type(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void election(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void social_movement(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void has_unclaimed_cores(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void has_empty_adjacent_state(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void colonial_nation(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void pop_majority_ideology(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void province_id(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_substates(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void luxury_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void in_default(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void work_available(tr_work_available const &value, error_handler &err, int32_t line, trigger_building_context &context)
void province_control_days(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void education_spending(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void has_crime(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void num_of_ports(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void military_score(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void total_sunk_by_us(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void agree_with_ruling_party(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void culture_has_union_tag(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void has_national_minority(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void war(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void rich_tax_above_poor(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void port(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void can_build_fort_in_capital(tr_can_build_fort_in_capital const &value, error_handler &err, int32_t line, trigger_building_context &context)
void factor(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void rich_tax(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_greater_power(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void pop_majority_culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void middle_strata_life_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void rich_strata_life_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_secondary_power(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void can_create_vassals(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void is_mobilised(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void crime_higher_than_education(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void is_coastal(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void owned_by(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void involved_in_crisis(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void country_units_in_state(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void ruling_party(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_next_reform(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_global_flag(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void consciousness(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void region(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void war_score(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void lost_national(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void national_provinces_occupied(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void constructing_cb_type(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void flashpoint_tension(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void has_building(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_pop_culture(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void unemployment(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void mobilisation_size(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void government(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_blockaded(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void middle_strata_luxury_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void total_amount_of_divisions(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void diplomatic_influence(tr_diplomatic_influence const &value, error_handler &err, int32_t line, trigger_building_context &context)
void continent(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void poor_strata_luxury_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void has_culture_core(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void has_province_modifier(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void is_state_religion(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void social_reform_want(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void tag(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void nationalvalue(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void has_flashpoint(association_type a, bool value, error_handler &err, int32_t line, trigger_building_context &context)
void pop_majority_issue(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void social_spending(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void recruited_percentage(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void military_spending(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_canal_enabled(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void middle_strata_militancy(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void is_releasable_vassal(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void corruption(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void life_needs(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void rank(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void capital(association_type a, int32_t value, error_handler &err, int32_t line, trigger_building_context &context)
void has_faction(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void prestige(association_type a, std::string_view value, error_handler &err, int32_t line, trigger_building_context &context)
void political_reform_want(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
void revolt_percentage(association_type a, float value, error_handler &err, int32_t line, trigger_building_context &context)
trigger::slot_contents this_slot
trigger::slot_contents from_slot
std::vector< uint16_t > compiled_trigger
trigger::slot_contents main_slot
scenario_building_context & outer_context
trigger_building_context(scenario_building_context &outer_context, trigger::slot_contents main_slot, trigger::slot_contents this_slot, trigger::slot_contents from_slot)
void years(association_type, float value, error_handler &err, int32_t line, trigger_building_context &context)
void months(association_type, float value, error_handler &err, int32_t line, trigger_building_context &context)
void group(value_modifier_definition const &value, error_handler &err, int32_t line, trigger_building_context &context)
void finish(trigger_building_context &)