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 diplo_points(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
2660 context.compiled_trigger.push_back(uint16_t(trigger::diplo_points | association_to_trigger_code(a)));
2661 } else {
2662 err.accumulated_errors += "diplo_points trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2663 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2664 return;
2665 }
2666 context.add_float_to_payload(value);
2667 }
2668 void owns(association_type a, std::string_view v, error_handler& err, int32_t line, trigger_building_context& context) {
2669 if(is_integer(v.data(), v.data() + v.length())) {
2670 auto value = parse_int(v, line, err);
2672 context.compiled_trigger.push_back(uint16_t(trigger::owns | association_to_bool_code(a)));
2673 } else if(context.main_slot == trigger::slot_contents::province) {
2674 context.compiled_trigger.push_back(uint16_t(trigger::owns_province | association_to_bool_code(a)));
2675 } else {
2676 err.accumulated_errors += "owns trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2677 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2678 return;
2679 }
2680 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
2682 } else {
2683 err.accumulated_errors +=
2684 "owns trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2685 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2686 }
2687 } else if(auto it = context.outer_context.map_of_state_names.find(std::string(v)); it != context.outer_context.map_of_state_names.end()) {
2689 context.compiled_trigger.push_back(uint16_t(trigger::owns_region | association_to_bool_code(a)));
2690 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2691 } else {
2692 err.accumulated_errors += "owns trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2693 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2694 return;
2695 }
2696 } else if(auto it = context.outer_context.map_of_region_names.find(std::string(v)); it != context.outer_context.map_of_region_names.end()) {
2698 context.compiled_trigger.push_back(uint16_t(trigger::owns_region_proper | association_to_bool_code(a)));
2699 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2700 } else {
2701 err.accumulated_errors += "owns trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2702 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2703 return;
2704 }
2705 } else {
2706 err.accumulated_errors +=
2707 "owns trigger given an invalid value (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2708 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2709 }
2710 }
2711 void controls(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2713 context.compiled_trigger.push_back(uint16_t(trigger::controls | association_to_bool_code(a)));
2714 } else {
2715 err.accumulated_errors += "controls trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
2716 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
2717 return;
2718 }
2719 if(0 <= value && size_t(value) < context.outer_context.original_id_to_prov_id_map.size()) {
2721 } else {
2722 err.accumulated_errors +=
2723 "controls trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2724 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2725 }
2726 }
2727
2728 void is_core(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2729 if(is_this(value) && context.main_slot == trigger::slot_contents::province) {
2731 context.compiled_trigger.push_back(
2732 uint16_t(trigger::is_core_this_nation | trigger::no_payload | association_to_bool_code(a)));
2733 } else if(context.this_slot == trigger::slot_contents::state) {
2734 context.compiled_trigger.push_back(
2735 uint16_t(trigger::is_core_this_state | trigger::no_payload | association_to_bool_code(a)));
2736 } else if(context.this_slot == trigger::slot_contents::province) {
2737 context.compiled_trigger.push_back(
2738 uint16_t(trigger::is_core_this_province | trigger::no_payload | association_to_bool_code(a)));
2739 } else if(context.this_slot == trigger::slot_contents::pop) {
2740 context.compiled_trigger.push_back(
2741 uint16_t(trigger::is_core_this_pop | trigger::no_payload | association_to_bool_code(a)));
2742 } else {
2743 err.accumulated_errors += "is_core = this 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_from(value) && context.main_slot == trigger::slot_contents::province) {
2750 context.compiled_trigger.push_back(
2751 uint16_t(trigger::is_core_from_nation | trigger::no_payload | association_to_bool_code(a)));
2752 } else {
2753 err.accumulated_errors += "is_core = from trigger used in an incorrect scope type " +
2754 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2755 std::to_string(line) + ")\n";
2756 return;
2757 }
2758 } else if(is_this(value) && context.main_slot == trigger::slot_contents::state) {
2760 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
2761 } else if(context.this_slot == trigger::slot_contents::province) {
2762 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_this_province | trigger::no_payload | association_to_bool_code(a)));
2763 } else if(context.this_slot == trigger::slot_contents::pop) {
2764 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
2765 } else {
2766 err.accumulated_errors += "is_core = this trigger used in an incorrect scope type " +
2767 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2768 std::to_string(line) + ")\n";
2769 return;
2770 }
2771 } else if(is_from(value) && context.main_slot == trigger::slot_contents::state) {
2773 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_from_nation | trigger::no_payload | association_to_bool_code(a)));
2774 } else {
2775 err.accumulated_errors += "is_core = from trigger used in an incorrect scope type " +
2776 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2777 std::to_string(line) + ")\n";
2778 return;
2779 }
2780 } else if(is_reb(value) && context.main_slot == trigger::slot_contents::province) {
2782 context.compiled_trigger.push_back(uint16_t(trigger::is_core_reb | trigger::no_payload | association_to_bool_code(a)));
2783 } else {
2784 err.accumulated_errors += "is_core = reb trigger used in an incorrect scope type " +
2785 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2786 std::to_string(line) + ")\n";
2787 return;
2788 }
2789 } else if(is_integer(value.data(), value.data() + value.length())) {
2791 auto int_value = parse_int(value, line, err);
2792 if(0 <= int_value && size_t(int_value) < context.outer_context.original_id_to_prov_id_map.size()) {
2793 context.compiled_trigger.push_back(uint16_t(trigger::is_core_integer | association_to_bool_code(a)));
2795 } else {
2796 err.accumulated_errors +=
2797 "owns trigger given an invalid province id (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2798 context.compiled_trigger.push_back(trigger::payload(dcon::province_id()).value);
2799 }
2800 } else {
2801 err.accumulated_errors += "is_core trigger used in an incorrect scope type " +
2802 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2803 std::to_string(line) + ")\n";
2804 return;
2805 }
2806 } 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"))) {
2807 context.compiled_trigger.push_back(uint16_t(trigger::is_core_boolean | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
2808 } else if(value.length() == 3 && context.main_slot == trigger::slot_contents::province) {
2809 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()) {
2810 context.compiled_trigger.push_back(uint16_t(trigger::is_core_tag | association_to_bool_code(a)));
2811 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2812 } else {
2813 err.accumulated_errors +=
2814 "is_core trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2815 }
2816 } else if(value.length() == 3 && context.main_slot == trigger::slot_contents::state) {
2817 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()) {
2818 context.compiled_trigger.push_back(uint16_t(trigger::is_core_state_tag | association_to_bool_code(a)));
2819 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2820 } else {
2821 err.accumulated_errors +=
2822 "is_core trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2823 }
2824 } else if(value.length() == 3 && context.main_slot == trigger::slot_contents::pop) {
2825 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()) {
2826 context.compiled_trigger.push_back(uint16_t(trigger::is_core_pop_tag | association_to_bool_code(a)));
2827 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2828 } else {
2829 err.accumulated_errors +=
2830 "is_core trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2831 }
2832 } else {
2833 err.accumulated_errors +=
2834 "is_core trigger supplied with an invalid argument \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2835 }
2836 }
2837 void num_of_revolts(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2839 context.compiled_trigger.push_back(uint16_t(trigger::num_of_revolts | association_to_trigger_code(a)));
2840 } else {
2841 err.accumulated_errors += "num_of_revolts trigger used in an incorrect scope type " +
2842 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2843 std::to_string(line) + ")\n";
2844 return;
2845 }
2846 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2847 }
2848 void revolt_percentage(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
2850 context.compiled_trigger.push_back(uint16_t(trigger::revolt_percentage | association_to_trigger_code(a)));
2851 } else {
2852 err.accumulated_errors += "revolt_percentage trigger used in an incorrect scope type " +
2853 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2854 std::to_string(line) + ")\n";
2855 return;
2856 }
2857 context.add_float_to_payload(value);
2858 }
2859 void num_of_cities(association_type a, std::string_view value, error_handler& err, int32_t line,
2860 trigger_building_context& context) {
2861 if(is_this(value) && context.main_slot == trigger::slot_contents::nation) {
2863 context.compiled_trigger.push_back(
2864 uint16_t(trigger::num_of_cities_this_nation | trigger::no_payload | association_to_trigger_code(a)));
2865 } else if(context.this_slot == trigger::slot_contents::state) {
2866 context.compiled_trigger.push_back(
2867 uint16_t(trigger::num_of_cities_this_province | trigger::no_payload | association_to_trigger_code(a)));
2868 } else if(context.this_slot == trigger::slot_contents::province) {
2869 context.compiled_trigger.push_back(
2870 uint16_t(trigger::num_of_cities_this_state | trigger::no_payload | association_to_trigger_code(a)));
2871 } else if(context.this_slot == trigger::slot_contents::pop) {
2872 context.compiled_trigger.push_back(
2873 uint16_t(trigger::num_of_cities_this_pop | trigger::no_payload | association_to_trigger_code(a)));
2874 } else {
2875 err.accumulated_errors += "num_of_cities = this 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(is_from(value) && context.main_slot == trigger::slot_contents::nation) {
2882 context.compiled_trigger.push_back(
2883 uint16_t(trigger::num_of_cities_from_nation | trigger::no_payload | association_to_trigger_code(a)));
2884 } else {
2885 err.accumulated_errors += "num_of_cities = from trigger used in an incorrect scope type " +
2886 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2887 std::to_string(line) + ")\n";
2888 return;
2889 }
2890 } else if(context.main_slot == trigger::slot_contents::nation) {
2891 context.compiled_trigger.push_back(uint16_t(trigger::num_of_cities_int | association_to_trigger_code(a)));
2892 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
2893 } else {
2894 err.accumulated_errors += "num_of_cities 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 }
2900 void num_of_ports(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2902 context.compiled_trigger.push_back(uint16_t(trigger::num_of_ports | association_to_trigger_code(a)));
2903 } else {
2904 err.accumulated_errors += "num_of_ports trigger used in an incorrect scope type " +
2905 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2906 std::to_string(line) + ")\n";
2907 return;
2908 }
2909 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2910 }
2911 void num_of_allies(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2913 context.compiled_trigger.push_back(uint16_t(trigger::num_of_allies | association_to_trigger_code(a)));
2914 } else {
2915 err.accumulated_errors += "num_of_allies trigger used in an incorrect scope type " +
2916 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2917 std::to_string(line) + ")\n";
2918 return;
2919 }
2920 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2921 }
2922 void num_of_vassals(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
2924 context.compiled_trigger.push_back(uint16_t(trigger::num_of_vassals | association_to_trigger_code(a)));
2925 } else {
2926 err.accumulated_errors += "num_of_vassals trigger used in an incorrect scope type " +
2927 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2928 std::to_string(line) + ")\n";
2929 return;
2930 }
2931 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
2932 }
2933 void owned_by(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
2935 if(is_this(value)) {
2937 context.compiled_trigger.push_back(
2938 uint16_t(trigger::owned_by_this_pop | trigger::no_payload | association_to_bool_code(a)));
2939 else if(context.this_slot == trigger::slot_contents::state)
2940 context.compiled_trigger.push_back(
2941 uint16_t(trigger::owned_by_this_state | trigger::no_payload | association_to_bool_code(a)));
2943 context.compiled_trigger.push_back(
2944 uint16_t(trigger::owned_by_this_province | trigger::no_payload | association_to_bool_code(a)));
2945 else if(context.this_slot == trigger::slot_contents::nation)
2946 context.compiled_trigger.push_back(
2947 uint16_t(trigger::owned_by_this_nation | trigger::no_payload | association_to_bool_code(a)));
2948 else {
2949 err.accumulated_errors += "owned_by = this 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(is_from(value)) {
2956 context.compiled_trigger.push_back(
2957 uint16_t(trigger::owned_by_from_nation | trigger::no_payload | association_to_bool_code(a)));
2958 else {
2959 err.accumulated_errors += "owned_by = from trigger used in an incorrect scope type " +
2960 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
2961 std::to_string(line) + ")\n";
2962 return;
2963 }
2964 } else if(value.length() == 3) {
2965 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
2966 it != context.outer_context.map_of_ident_names.end()) {
2967 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_tag | association_to_bool_code(a)));
2968 context.compiled_trigger.push_back(trigger::payload(it->second).value);
2969 } else {
2970 err.accumulated_errors +=
2971 "owned_by trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2972 }
2973 } else {
2974 err.accumulated_errors +=
2975 "owned_by trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
2976 return;
2977 }
2978 } else if(context.main_slot == trigger::slot_contents::state) {
2979 if(is_this(value)) {
2981 context.compiled_trigger.push_back(
2982 uint16_t(trigger::owned_by_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
2983 else if(context.this_slot == trigger::slot_contents::state)
2984 context.compiled_trigger.push_back(
2985 uint16_t(trigger::owned_by_state_this_state | trigger::no_payload | association_to_bool_code(a)));
2987 context.compiled_trigger.push_back(
2988 uint16_t(trigger::owned_by_state_this_province | trigger::no_payload | association_to_bool_code(a)));
2989 else if(context.this_slot == trigger::slot_contents::nation)
2990 context.compiled_trigger.push_back(
2991 uint16_t(trigger::owned_by_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
2992 else {
2993 err.accumulated_errors += "owned_by = this 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(is_from(value)) {
3000 context.compiled_trigger.push_back(
3001 uint16_t(trigger::owned_by_state_from_nation | trigger::no_payload | association_to_bool_code(a)));
3002 else {
3003 err.accumulated_errors += "owned_by = from trigger used in an incorrect scope type " +
3004 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3005 std::to_string(line) + ")\n";
3006 return;
3007 }
3008 } else if(value.length() == 3) {
3009 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3010 it != context.outer_context.map_of_ident_names.end()) {
3011 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_tag | association_to_bool_code(a)));
3012 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3013 } else {
3014 err.accumulated_errors +=
3015 "owned_by trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3016 }
3017 } else {
3018 err.accumulated_errors +=
3019 "owned_by trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3020 return;
3021 }
3022 } else {
3023 err.accumulated_errors += "owned_by trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3024 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3025 return;
3026 }
3027 }
3028
3029 void exists(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3030 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "yes") ||
3031 is_fixed_token_ci(value.data(), value.data() + value.length(), "no")) {
3033 context.compiled_trigger.push_back(
3034 uint16_t(trigger::exists_bool | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
3035 else {
3036 err.accumulated_errors += "exists = bool trigger used in an incorrect scope type " +
3037 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3038 std::to_string(line) + ")\n";
3039 return;
3040 }
3041 } else if(value.length() == 3) {
3042 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3043 it != context.outer_context.map_of_ident_names.end()) {
3044 context.compiled_trigger.push_back(uint16_t(trigger::exists_tag | association_to_bool_code(a)));
3045 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3046 } else {
3047 err.accumulated_errors +=
3048 "exists trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3049 }
3050
3051 } else {
3052 err.accumulated_errors +=
3053 "exists trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3054 return;
3055 }
3056 }
3057 void has_country_flag(association_type a, std::string_view value, error_handler& err, int32_t line,
3058 trigger_building_context& context) {
3060 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag | association_to_bool_code(a)));
3061 } else if(context.main_slot == trigger::slot_contents::pop) {
3062 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag_pop | association_to_bool_code(a)));
3063 } else if(context.main_slot == trigger::slot_contents::province) {
3064 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag_province | association_to_bool_code(a)));
3065 } else if(context.main_slot == trigger::slot_contents::state) {
3066 context.compiled_trigger.push_back(uint16_t(trigger::has_country_flag_state | association_to_bool_code(a)));
3067 } else {
3068 err.accumulated_errors += "has_country_flag trigger used in an incorrect scope type " +
3069 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3070 std::to_string(line) + ")\n";
3071 return;
3072 }
3073 context.compiled_trigger.push_back(trigger::payload(context.outer_context.get_national_flag(std::string(value))).value);
3074 }
3075 void has_global_flag(association_type a, std::string_view value, error_handler& err, int32_t line,
3076 trigger_building_context& context) {
3077 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "project_alice")) {
3078 context.compiled_trigger.push_back(uint16_t(trigger::always | trigger::no_payload | association_to_bool_code(a, true)));
3079 } else {
3080 context.compiled_trigger.push_back(uint16_t(trigger::has_global_flag | association_to_bool_code(a)));
3081 context.compiled_trigger.push_back(trigger::payload(context.outer_context.get_global_flag(std::string(value))).value);
3082 }
3083 }
3084
3085 void continent(association_type a, std::string_view value, error_handler& err, int32_t line,
3086 trigger_building_context& context) {
3088 if(is_this(value)) {
3090 context.compiled_trigger.push_back(
3091 uint16_t(trigger::continent_nation_this | trigger::no_payload | association_to_bool_code(a)));
3092 } else {
3093 err.accumulated_errors += "continent = this 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(is_from(value)) {
3100 context.compiled_trigger.push_back(
3101 uint16_t(trigger::continent_nation_from | trigger::no_payload | association_to_bool_code(a)));
3102 } else {
3103 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3104 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3105 std::to_string(line) + ")\n";
3106 return;
3107 }
3108 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3109 it != context.outer_context.map_of_modifiers.end()) {
3110 context.compiled_trigger.push_back(uint16_t(trigger::continent_nation | association_to_bool_code(a)));
3111 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3112 } else {
3113 err.accumulated_errors +=
3114 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3115 return;
3116 }
3117 } else if(context.main_slot == trigger::slot_contents::state) {
3118 if(is_this(value)) {
3120 context.compiled_trigger.push_back(
3121 uint16_t(trigger::continent_state_this | trigger::no_payload | association_to_bool_code(a)));
3122 } else {
3123 err.accumulated_errors += "continent = this 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(is_from(value)) {
3130 context.compiled_trigger.push_back(
3131 uint16_t(trigger::continent_state_from | trigger::no_payload | association_to_bool_code(a)));
3132 } else {
3133 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3134 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3135 std::to_string(line) + ")\n";
3136 return;
3137 }
3138 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3139 it != context.outer_context.map_of_modifiers.end()) {
3140 context.compiled_trigger.push_back(uint16_t(trigger::continent_state | association_to_bool_code(a)));
3141 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3142 } else {
3143 err.accumulated_errors +=
3144 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3145 return;
3146 }
3147 } else if(context.main_slot == trigger::slot_contents::province) {
3148 if(is_this(value)) {
3150 context.compiled_trigger.push_back(
3151 uint16_t(trigger::continent_province_this | trigger::no_payload | association_to_bool_code(a)));
3152 } else {
3153 err.accumulated_errors += "continent = this 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(is_from(value)) {
3160 context.compiled_trigger.push_back(
3161 uint16_t(trigger::continent_province_from | trigger::no_payload | association_to_bool_code(a)));
3162 } else {
3163 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3164 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3165 std::to_string(line) + ")\n";
3166 return;
3167 }
3168 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3169 it != context.outer_context.map_of_modifiers.end()) {
3170 context.compiled_trigger.push_back(uint16_t(trigger::continent_province | association_to_bool_code(a)));
3171 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3172 } else {
3173 err.accumulated_errors +=
3174 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3175 return;
3176 }
3177 } else if(context.main_slot == trigger::slot_contents::pop) {
3178 if(is_this(value)) {
3180 context.compiled_trigger.push_back(
3181 uint16_t(trigger::continent_pop_this | trigger::no_payload | association_to_bool_code(a)));
3182 } else {
3183 err.accumulated_errors += "continent = this 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(is_from(value)) {
3190 context.compiled_trigger.push_back(
3191 uint16_t(trigger::continent_pop_from | trigger::no_payload | association_to_bool_code(a)));
3192 } else {
3193 err.accumulated_errors += "continent = from trigger used in an incorrect scope type " +
3194 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3195 std::to_string(line) + ")\n";
3196 return;
3197 }
3198 } else if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3199 it != context.outer_context.map_of_modifiers.end()) {
3200 context.compiled_trigger.push_back(uint16_t(trigger::continent_pop | association_to_bool_code(a)));
3201 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3202 } else {
3203 err.accumulated_errors +=
3204 "continent trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3205 return;
3206 }
3207 } else {
3208 err.accumulated_errors += "continent trigger used in an incorrect scope type " +
3209 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3210 std::to_string(line) + ")\n";
3211 return;
3212 }
3213 }
3214 void casus_belli(association_type a, std::string_view value, error_handler& err, int32_t line,
3215 trigger_building_context& context) {
3217 if(is_this(value)) {
3219 context.compiled_trigger.push_back(
3220 uint16_t(trigger::casus_belli_this_pop | trigger::no_payload | association_to_bool_code(a)));
3221 else if(context.this_slot == trigger::slot_contents::state)
3222 context.compiled_trigger.push_back(
3223 uint16_t(trigger::casus_belli_this_state | trigger::no_payload | association_to_bool_code(a)));
3225 context.compiled_trigger.push_back(
3226 uint16_t(trigger::casus_belli_this_province | trigger::no_payload | association_to_bool_code(a)));
3227 else if(context.this_slot == trigger::slot_contents::nation)
3228 context.compiled_trigger.push_back(
3229 uint16_t(trigger::casus_belli_this_nation | trigger::no_payload | association_to_bool_code(a)));
3230 else {
3231 err.accumulated_errors += "casus_belli = this 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(is_from(value)) {
3238 context.compiled_trigger.push_back(
3239 uint16_t(trigger::casus_belli_from | trigger::no_payload | association_to_bool_code(a)));
3240 else {
3241 err.accumulated_errors += "casus_belli = from trigger used in an incorrect scope type " +
3242 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3243 std::to_string(line) + ")\n";
3244 return;
3245 }
3246 } else if(value.length() == 3) {
3247 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3248 it != context.outer_context.map_of_ident_names.end()) {
3249 context.compiled_trigger.push_back(uint16_t(trigger::casus_belli_tag | association_to_bool_code(a)));
3250 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3251 } else {
3252 err.accumulated_errors +=
3253 "casus_belli trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3254 }
3255 } else {
3256 err.accumulated_errors +=
3257 "casus_belli trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3258 return;
3259 }
3260 } else {
3261 err.accumulated_errors += "casus_belli trigger used in an incorrect scope type " +
3262 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3263 std::to_string(line) + ")\n";
3264 return;
3265 }
3266 }
3267
3268 void military_access(association_type a, std::string_view value, error_handler& err, int32_t line,
3269 trigger_building_context& context) {
3271 if(is_this(value)) {
3273 context.compiled_trigger.push_back(
3274 uint16_t(trigger::military_access_this_pop | trigger::no_payload | association_to_bool_code(a)));
3275 else if(context.this_slot == trigger::slot_contents::state)
3276 context.compiled_trigger.push_back(
3277 uint16_t(trigger::military_access_this_state | trigger::no_payload | association_to_bool_code(a)));
3279 context.compiled_trigger.push_back(
3280 uint16_t(trigger::military_access_this_province | trigger::no_payload | association_to_bool_code(a)));
3281 else if(context.this_slot == trigger::slot_contents::nation)
3282 context.compiled_trigger.push_back(
3283 uint16_t(trigger::military_access_this_nation | trigger::no_payload | association_to_bool_code(a)));
3284 else {
3285 err.accumulated_errors += "military_access = this 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(is_from(value)) {
3292 context.compiled_trigger.push_back(
3293 uint16_t(trigger::military_access_from | trigger::no_payload | association_to_bool_code(a)));
3294 else {
3295 err.accumulated_errors += "military_access = from trigger used in an incorrect scope type " +
3296 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3297 std::to_string(line) + ")\n";
3298 return;
3299 }
3300 } else if(value.length() == 3) {
3301 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3302 it != context.outer_context.map_of_ident_names.end()) {
3303 context.compiled_trigger.push_back(uint16_t(trigger::military_access_tag | association_to_bool_code(a)));
3304 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3305 } else {
3306 err.accumulated_errors +=
3307 "military_access trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3308 }
3309 } else {
3310 err.accumulated_errors +=
3311 "military_access trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3312 return;
3313 }
3314 } else {
3315 err.accumulated_errors += "military_access trigger used in an incorrect scope type " +
3316 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3317 std::to_string(line) + ")\n";
3318 return;
3319 }
3320 }
3321
3322 void prestige(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3324 if(is_this(value)) {
3326 context.compiled_trigger.push_back(
3327 uint16_t(trigger::prestige_this_pop | trigger::no_payload | association_to_trigger_code(a)));
3328 else if(context.this_slot == trigger::slot_contents::state)
3329 context.compiled_trigger.push_back(
3330 uint16_t(trigger::prestige_this_state | trigger::no_payload | association_to_trigger_code(a)));
3332 context.compiled_trigger.push_back(
3333 uint16_t(trigger::prestige_this_province | trigger::no_payload | association_to_trigger_code(a)));
3334 else if(context.this_slot == trigger::slot_contents::nation)
3335 context.compiled_trigger.push_back(
3336 uint16_t(trigger::prestige_this_nation | trigger::no_payload | association_to_trigger_code(a)));
3337 else {
3338 err.accumulated_errors += "prestige = this 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 if(is_from(value)) {
3345 context.compiled_trigger.push_back(
3346 uint16_t(trigger::prestige_from | trigger::no_payload | association_to_trigger_code(a)));
3347 else {
3348 err.accumulated_errors += "prestige = from trigger used in an incorrect scope type " +
3349 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3350 std::to_string(line) + ")\n";
3351 return;
3352 }
3353 } else {
3354 float fvalue = parse_float(value, line, err);
3355 context.compiled_trigger.push_back(uint16_t(trigger::prestige_value | association_to_trigger_code(a)));
3356 context.add_float_to_payload(fvalue);
3357 }
3358 } else {
3359 err.accumulated_errors += "prestige trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3360 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3361 return;
3362 }
3363 }
3364 void badboy(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context);
3365 void has_building(association_type a, std::string_view value, error_handler& err, int32_t line,
3366 trigger_building_context& context) {
3368 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "factory")) {
3369 context.compiled_trigger.push_back(
3370 uint16_t(trigger::has_building_factory | trigger::no_payload | association_to_bool_code(a)));
3371 } else if(auto it = context.outer_context.map_of_factory_names.find(std::string(value));
3372 it != context.outer_context.map_of_factory_names.end()) {
3373 context.compiled_trigger.push_back(uint16_t(trigger::has_building_state | association_to_bool_code(a)));
3374 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3375 } else {
3376 err.accumulated_errors +=
3377 "has_building trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3378 return;
3379 }
3380 } else if(context.main_slot == trigger::slot_contents::province) {
3381 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "fort")) {
3382 context.compiled_trigger.push_back(
3383 uint16_t(trigger::has_building_fort | trigger::no_payload | association_to_bool_code(a)));
3384 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "railroad")) {
3385 context.compiled_trigger.push_back(
3386 uint16_t(trigger::has_building_railroad | trigger::no_payload | association_to_bool_code(a)));
3387 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "naval_base")) {
3388 context.compiled_trigger.push_back(
3389 uint16_t(trigger::has_building_naval_base | trigger::no_payload | association_to_bool_code(a)));
3390 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "bank")) {
3391 context.compiled_trigger.push_back(
3392 uint16_t(trigger::has_building_bank | trigger::no_payload | association_to_bool_code(a)));
3393 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "university")) {
3394 context.compiled_trigger.push_back(
3395 uint16_t(trigger::has_building_university | trigger::no_payload | association_to_bool_code(a)));
3396 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "factory")) {
3397 context.compiled_trigger.push_back(
3398 uint16_t(trigger::has_building_factory_from_province | trigger::no_payload | association_to_bool_code(a)));
3399 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "province_selector")) {
3400 context.compiled_trigger.push_back(uint16_t(trigger::has_province_modifier | association_to_bool_code(a)));
3402 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "immigrator")
3403 || is_fixed_token_ci(value.data(), value.data() + value.length(), "immigrator_selector")
3404 || is_fixed_token_ci(value.data(), value.data() + value.length(), "province_immigrator")) {
3405 context.compiled_trigger.push_back(uint16_t(trigger::has_province_modifier | association_to_bool_code(a)));
3407 } else if(auto it = context.outer_context.map_of_factory_names.find(std::string(value));
3408 it != context.outer_context.map_of_factory_names.end()) {
3409 context.compiled_trigger.push_back(uint16_t(trigger::has_building_state_from_province | association_to_bool_code(a)));
3410 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3411 } else {
3412 err.accumulated_errors +=
3413 "has_building trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3414 return;
3415 }
3416 } else {
3417 err.accumulated_errors += "has_building trigger used in an incorrect scope type " +
3418 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3419 std::to_string(line) + ")\n";
3420 return;
3421 }
3422 }
3423 void empty(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3425 context.compiled_trigger.push_back(uint16_t(trigger::empty | trigger::no_payload | association_to_bool_code(a, value)));
3426 } else if(context.main_slot == trigger::slot_contents::state) {
3427 context.compiled_trigger.push_back(uint16_t(trigger::empty_state | trigger::no_payload | association_to_bool_code(a, value)));
3428 } else {
3429 err.accumulated_errors += "empty trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3430 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3431 return;
3432 }
3433 }
3434 void is_blockaded(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3436 context.compiled_trigger.push_back(
3437 uint16_t(trigger::is_blockaded | trigger::no_payload | association_to_bool_code(a, value)));
3438 } else {
3439 err.accumulated_errors += "is_blockaded trigger used in an incorrect scope type " +
3440 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3441 std::to_string(line) + ")\n";
3442 return;
3443 }
3444 }
3445
3446 void has_country_modifier(association_type a, std::string_view value, error_handler& err, int32_t line,
3447 trigger_building_context& context) {
3448 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3449 it != context.outer_context.map_of_modifiers.end()) {
3451 context.compiled_trigger.push_back(uint16_t(trigger::has_country_modifier | association_to_bool_code(a)));
3452 } else if(context.main_slot == trigger::slot_contents::province) {
3453 context.compiled_trigger.push_back(uint16_t(trigger::has_country_modifier_province | association_to_bool_code(a)));
3454 } else {
3455 err.accumulated_errors += "has_country_modifier trigger used in an incorrect scope type " +
3456 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3457 std::to_string(line) + ")\n";
3458 return;
3459 }
3460 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3461 } else {
3462 err.accumulated_errors += "has_country_modifier trigger supplied with an invalid modifier \"" + std::string(value) + "\" (" + err.file_name + ", line " +
3463 std::to_string(line) + ")\n";
3464 }
3465 }
3466 void has_province_modifier(association_type a, std::string_view value, error_handler& err, int32_t line,
3467 trigger_building_context& context) {
3468 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3469 it != context.outer_context.map_of_modifiers.end()) {
3471 context.compiled_trigger.push_back(uint16_t(trigger::has_province_modifier | association_to_bool_code(a)));
3472 } else {
3473 err.accumulated_errors += "has_province_modifier trigger used in an incorrect scope type " +
3474 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3475 std::to_string(line) + ")\n";
3476 return;
3477 }
3478 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3479 } else {
3480 err.accumulated_errors += "has_province_modifier trigger supplied with an invalid modifier \"" + std::string(value) + "\" (" + err.file_name + ", line " +
3481 std::to_string(line) + ")\n";
3482 }
3483 }
3484 void nationalvalue(association_type a, std::string_view value, error_handler& err, int32_t line,
3485 trigger_building_context& context) {
3486 if(auto it = context.outer_context.map_of_modifiers.find(std::string(value));
3487 it != context.outer_context.map_of_modifiers.end()) {
3489 context.compiled_trigger.push_back(uint16_t(trigger::nationalvalue_nation | association_to_bool_code(a)));
3490 } else if(context.main_slot == trigger::slot_contents::province) {
3491 context.compiled_trigger.push_back(uint16_t(trigger::nationalvalue_province | association_to_bool_code(a)));
3492 } else if(context.main_slot == trigger::slot_contents::pop) {
3493 context.compiled_trigger.push_back(uint16_t(trigger::nationalvalue_pop | association_to_bool_code(a)));
3494 } else {
3495 err.accumulated_errors += "nationalvalue trigger used in an incorrect scope type " +
3496 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3497 std::to_string(line) + ")\n";
3498 return;
3499 }
3500 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3501 } else {
3502 err.accumulated_errors +=
3503 "nationalvalue trigger supplied with an invalid modifier \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3504 }
3505 }
3506 void region(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3507 if(auto it = context.outer_context.map_of_state_names.find(std::string(value)); it != context.outer_context.map_of_state_names.end()) {
3509 context.compiled_trigger.push_back(uint16_t(trigger::region | association_to_bool_code(a)));
3510 } else if(context.main_slot == trigger::slot_contents::state) {
3511 context.compiled_trigger.push_back(uint16_t(trigger::region_state | association_to_bool_code(a)));
3512 } else if(context.main_slot == trigger::slot_contents::pop) {
3513 context.compiled_trigger.push_back(uint16_t(trigger::region_pop | association_to_bool_code(a)));
3514 } else {
3515 err.accumulated_errors += "region trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3516 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3517 return;
3518 }
3519 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3520 } else if(auto it = context.outer_context.map_of_region_names.find(std::string(value)); it != context.outer_context.map_of_region_names.end()) {
3522 context.compiled_trigger.push_back(uint16_t(trigger::region_proper | association_to_bool_code(a)));
3523 } else if(context.main_slot == trigger::slot_contents::state) {
3524 context.compiled_trigger.push_back(uint16_t(trigger::region_proper_state | association_to_bool_code(a)));
3525 } else if(context.main_slot == trigger::slot_contents::pop) {
3526 context.compiled_trigger.push_back(uint16_t(trigger::region_proper_pop | association_to_bool_code(a)));
3527 } else {
3528 err.accumulated_errors += "region trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3529 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3530 return;
3531 }
3532 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3533 } else {
3534 err.accumulated_errors +=
3535 "region trigger not supplied with a state name (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3536 }
3537 }
3538
3539 void tag(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3541 if(is_this(value)) {
3543 context.compiled_trigger.push_back(
3544 uint16_t(trigger::tag_this_province | trigger::no_payload | association_to_bool_code(a)));
3545 else if(context.this_slot == trigger::slot_contents::nation)
3546 context.compiled_trigger.push_back(
3547 uint16_t(trigger::tag_this_nation | trigger::no_payload | association_to_bool_code(a)));
3548 else {
3549 err.accumulated_errors += "tag = this trigger used in an incorrect scope type " +
3550 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3551 std::to_string(line) + ")\n";
3552 return;
3553 }
3554 } else if(is_from(value)) {
3556 context.compiled_trigger.push_back(
3557 uint16_t(trigger::tag_from_nation | trigger::no_payload | association_to_bool_code(a)));
3559 context.compiled_trigger.push_back(
3560 uint16_t(trigger::tag_from_province | trigger::no_payload | association_to_bool_code(a)));
3561 else {
3562 err.accumulated_errors += "tag = from trigger used in an incorrect scope type " +
3563 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3564 std::to_string(line) + ")\n";
3565 return;
3566 }
3567 } else if(value.length() == 3) {
3568 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3569 it != context.outer_context.map_of_ident_names.end()) {
3570 context.compiled_trigger.push_back(uint16_t(trigger::tag_tag | association_to_bool_code(a)));
3571 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3572 } else {
3573 err.accumulated_errors +=
3574 "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3575 }
3576 } else {
3577 err.accumulated_errors +=
3578 "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3579 return;
3580 }
3581 } else if(context.main_slot == trigger::slot_contents::province) {
3582 if(is_this(value)) {
3584 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_pop | trigger::no_payload | association_to_bool_code(a)));
3585 else if(context.this_slot == trigger::slot_contents::state)
3586 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_state | trigger::no_payload | association_to_bool_code(a)));
3588 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_province | trigger::no_payload | association_to_bool_code(a)));
3589 else if(context.this_slot == trigger::slot_contents::nation)
3590 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_this_nation | trigger::no_payload | association_to_bool_code(a)));
3591 else {
3592 err.accumulated_errors += "tag = this trigger used in an incorrect scope type " +
3593 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3594 std::to_string(line) + ")\n";
3595 return;
3596 }
3597 } else if(is_from(value)) {
3599 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_from_nation | trigger::no_payload | association_to_bool_code(a)));
3600 else {
3601 err.accumulated_errors += "tag = from trigger used in an incorrect scope type " +
3602 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3603 std::to_string(line) + ")\n";
3604 return;
3605 }
3606 } else if(value.length() == 3) {
3607 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3608 it != context.outer_context.map_of_ident_names.end()) {
3609 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_tag | association_to_bool_code(a)));
3610 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3611 } else {
3612 err.accumulated_errors += "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3613 }
3614 } else {
3615 err.accumulated_errors += "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3616 return;
3617 }
3618 } else if(context.main_slot == trigger::slot_contents::state) {
3619 if(is_this(value)) {
3621 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
3622 else if(context.this_slot == trigger::slot_contents::state)
3623 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_state | trigger::no_payload | association_to_bool_code(a)));
3625 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_province | trigger::no_payload | association_to_bool_code(a)));
3626 else if(context.this_slot == trigger::slot_contents::nation)
3627 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
3628 else {
3629 err.accumulated_errors += "tag = this trigger used in an incorrect scope type " +
3630 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3631 std::to_string(line) + ")\n";
3632 return;
3633 }
3634 } else if(is_from(value)) {
3636 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_from_nation | trigger::no_payload | association_to_bool_code(a)));
3637 else {
3638 err.accumulated_errors += "tag = from trigger used in an incorrect scope type " +
3639 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3640 std::to_string(line) + ")\n";
3641 return;
3642 }
3643 } else if(value.length() == 3) {
3644 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3645 it != context.outer_context.map_of_ident_names.end()) {
3646 context.compiled_trigger.push_back(uint16_t(trigger::owned_by_state_tag | association_to_bool_code(a)));
3647 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3648 } else {
3649 err.accumulated_errors += "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3650 }
3651 } else {
3652 err.accumulated_errors += "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3653 return;
3654 }
3655 } else if(context.main_slot == trigger::slot_contents::pop) {
3656 if(value.length() == 3) {
3657 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3658 it != context.outer_context.map_of_ident_names.end()) {
3659 context.compiled_trigger.push_back(uint16_t(trigger::tag_pop | association_to_bool_code(a)));
3660 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3661 } else {
3662 err.accumulated_errors += "tag trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3663 }
3664 } else {
3665 err.accumulated_errors += "tag trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3666 return;
3667 }
3668 } else {
3669 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";
3670 return;
3671 }
3672 }
3673 void stronger_army_than(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3675 if(is_this(value)) {
3677 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_province | trigger::no_payload | association_to_bool_code(a)));
3678 else if(context.this_slot == trigger::slot_contents::nation)
3679 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_nation | trigger::no_payload | association_to_bool_code(a)));
3680 else if(context.this_slot == trigger::slot_contents::state)
3681 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_state | trigger::no_payload | association_to_bool_code(a)));
3682 else if(context.this_slot == trigger::slot_contents::pop)
3683 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_this_pop | trigger::no_payload | association_to_bool_code(a)));
3684 else {
3685 err.accumulated_errors += "stronger_army_than = this trigger used in an incorrect scope type " +
3686 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3687 std::to_string(line) + ")\n";
3688 return;
3689 }
3690 } else if(is_from(value)) {
3692 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_from_nation | trigger::no_payload | association_to_bool_code(a)));
3694 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_from_province | trigger::no_payload | association_to_bool_code(a)));
3695 else {
3696 err.accumulated_errors += "stronger_army_than = from trigger used in an incorrect scope type " +
3697 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3698 std::to_string(line) + ")\n";
3699 return;
3700 }
3701 } else if(value.length() == 3) {
3702 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3703 it != context.outer_context.map_of_ident_names.end()) {
3704 context.compiled_trigger.push_back(uint16_t(trigger::stronger_army_than_tag | association_to_bool_code(a)));
3705 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3706 } else {
3707 err.accumulated_errors +=
3708 "stronger_army_than trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3709 }
3710 } else {
3711 err.accumulated_errors +=
3712 "stronger_army_than trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3713 return;
3714 }
3715 } else {
3716 err.accumulated_errors += "stronger_army_than trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3717 " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3718 return;
3719 }
3720 }
3721 void neighbour(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3723 if(is_this(value)) {
3725 context.compiled_trigger.push_back(
3726 uint16_t(trigger::neighbour_this | trigger::no_payload | association_to_bool_code(a)));
3728 context.compiled_trigger.push_back(
3729 uint16_t(trigger::neighbour_this_province | trigger::no_payload | association_to_bool_code(a)));
3730 else {
3731 err.accumulated_errors += "neighbour = this trigger used in an incorrect scope type " +
3732 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3733 std::to_string(line) + ")\n";
3734 return;
3735 }
3736 } else if(is_from(value)) {
3738 context.compiled_trigger.push_back(
3739 uint16_t(trigger::neighbour_from | trigger::no_payload | association_to_bool_code(a)));
3741 context.compiled_trigger.push_back(
3742 uint16_t(trigger::neighbour_from_province | trigger::no_payload | association_to_bool_code(a)));
3743 else {
3744 err.accumulated_errors += "neighbour = from trigger used in an incorrect scope type " +
3745 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3746 std::to_string(line) + ")\n";
3747 return;
3748 }
3749 } else if(value.length() == 3) {
3750 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3751 it != context.outer_context.map_of_ident_names.end()) {
3752 context.compiled_trigger.push_back(uint16_t(trigger::neighbour_tag | association_to_bool_code(a)));
3753 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3754 } else {
3755 err.accumulated_errors +=
3756 "neighbour trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3757 }
3758 } else {
3759 err.accumulated_errors +=
3760 "neighbour trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3761 return;
3762 }
3763 } else {
3764 err.accumulated_errors += "neighbour trigger used in an incorrect scope type " +
3765 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3766 std::to_string(line) + ")\n";
3767 return;
3768 }
3769 }
3770 void country_units_in_state(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3772 if(is_this(value)) {
3774 context.compiled_trigger.push_back(
3775 uint16_t(trigger::country_units_in_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
3776 else if(context.this_slot == trigger::slot_contents::state)
3777 context.compiled_trigger.push_back(
3778 uint16_t(trigger::country_units_in_state_this_state | trigger::no_payload | association_to_bool_code(a)));
3780 context.compiled_trigger.push_back(
3781 uint16_t(trigger::country_units_in_state_this_province | trigger::no_payload | association_to_bool_code(a)));
3782 else if(context.this_slot == trigger::slot_contents::pop)
3783 context.compiled_trigger.push_back(
3784 uint16_t(trigger::country_units_in_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
3785 else {
3786 err.accumulated_errors += "country_units_in_state = this 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(is_from(value)) {
3793 context.compiled_trigger.push_back(
3794 uint16_t(trigger::country_units_in_state_from | trigger::no_payload | association_to_bool_code(a)));
3795 else {
3796 err.accumulated_errors += "country_units_in_state = from trigger used in an incorrect scope type " +
3797 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3798 std::to_string(line) + ")\n";
3799 return;
3800 }
3801 } else if(value.length() == 3) {
3802 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3803 it != context.outer_context.map_of_ident_names.end()) {
3804 context.compiled_trigger.push_back(uint16_t(trigger::country_units_in_state_tag | association_to_bool_code(a)));
3805 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3806 } else {
3807 err.accumulated_errors +=
3808 "country_units_in_state trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3809 }
3810 } else {
3811 err.accumulated_errors +=
3812 "country_units_in_state trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3813 }
3814 } else {
3815 err.accumulated_errors += "country_units_in_state trigger used in an incorrect scope type " +
3816 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3817 std::to_string(line) + ")\n";
3818 return;
3819 }
3820 }
3821 void units_in_province(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3823 if(is_this(value)) {
3825 context.compiled_trigger.push_back(
3826 uint16_t(trigger::units_in_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
3827 else if(context.this_slot == trigger::slot_contents::state)
3828 context.compiled_trigger.push_back(
3829 uint16_t(trigger::units_in_province_this_state | trigger::no_payload | association_to_bool_code(a)));
3831 context.compiled_trigger.push_back(
3832 uint16_t(trigger::units_in_province_this_province | trigger::no_payload | association_to_bool_code(a)));
3833 else if(context.this_slot == trigger::slot_contents::pop)
3834 context.compiled_trigger.push_back(
3835 uint16_t(trigger::units_in_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
3836 else {
3837 err.accumulated_errors += "units_in_province = this 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_from(value)) {
3844 context.compiled_trigger.push_back(
3845 uint16_t(trigger::units_in_province_from | trigger::no_payload | association_to_bool_code(a)));
3846 else {
3847 err.accumulated_errors += "units_in_province = from trigger used in an incorrect scope type " +
3848 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3849 std::to_string(line) + ")\n";
3850 return;
3851 }
3852 } else if(is_integer(value.data(), value.data() + value.length())) {
3853 context.compiled_trigger.push_back(uint16_t(trigger::units_in_province_value | association_to_trigger_code(a)));
3854 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
3855 } else if(value.length() == 3) {
3856 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3857 it != context.outer_context.map_of_ident_names.end()) {
3858 context.compiled_trigger.push_back(uint16_t(trigger::units_in_province_tag | association_to_bool_code(a)));
3859 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3860 } else {
3861 err.accumulated_errors +=
3862 "units_in_province trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3863 }
3864 } else {
3865 err.accumulated_errors +=
3866 "units_in_province trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3867 }
3868 } else {
3869 err.accumulated_errors += "units_in_province trigger used in an incorrect scope type " +
3870 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3871 std::to_string(line) + ")\n";
3872 return;
3873 }
3874 }
3875 void war_with(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3877 if(is_this(value)) {
3879 context.compiled_trigger.push_back(
3880 uint16_t(trigger::war_with_this_nation | trigger::no_payload | association_to_bool_code(a)));
3881 else if(context.this_slot == trigger::slot_contents::state)
3882 context.compiled_trigger.push_back(
3883 uint16_t(trigger::war_with_this_state | trigger::no_payload | association_to_bool_code(a)));
3885 context.compiled_trigger.push_back(
3886 uint16_t(trigger::war_with_this_province | trigger::no_payload | association_to_bool_code(a)));
3887 else if(context.this_slot == trigger::slot_contents::pop)
3888 context.compiled_trigger.push_back(
3889 uint16_t(trigger::war_with_this_pop | trigger::no_payload | association_to_bool_code(a)));
3890 else {
3891 err.accumulated_errors += "war_with = this 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(is_from(value)) {
3898 context.compiled_trigger.push_back(
3899 uint16_t(trigger::war_with_from | trigger::no_payload | association_to_bool_code(a)));
3900 else {
3901 err.accumulated_errors += "war_with = from trigger used in an incorrect scope type " +
3902 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3903 std::to_string(line) + ")\n";
3904 return;
3905 }
3906 } else if(value.length() == 3) {
3907 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
3908 it != context.outer_context.map_of_ident_names.end()) {
3909 context.compiled_trigger.push_back(uint16_t(trigger::war_with_tag | association_to_bool_code(a)));
3910 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3911 } else {
3912 err.accumulated_errors +=
3913 "war_with trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3914 }
3915 } else {
3916 err.accumulated_errors +=
3917 "war_with trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3918 return;
3919 }
3920 } else {
3921 err.accumulated_errors += "war_with trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3922 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3923 return;
3924 }
3925 }
3926 void unit_in_battle(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3928 context.compiled_trigger.push_back(
3929 uint16_t(trigger::unit_in_battle | trigger::no_payload | association_to_bool_code(a, value)));
3930 } else {
3931 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";
3932 return;
3933 }
3934 }
3935 void unit_has_leader(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3937 context.compiled_trigger.push_back(uint16_t(trigger::unit_has_leader | trigger::no_payload | association_to_bool_code(a, value)));
3938 } else {
3939 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";
3940 return;
3941 }
3942 }
3943 void has_national_focus(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
3944 if(auto it = context.outer_context.map_of_national_focuses.find(std::string(value));
3945 it != context.outer_context.map_of_national_focuses.end()) {
3947 context.compiled_trigger.push_back(uint16_t(trigger::has_national_focus_state | trigger::no_payload | association_to_trigger_code(a)));
3948 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3949 } else if(context.main_slot == trigger::slot_contents::province) {
3950 context.compiled_trigger.push_back(uint16_t(trigger::has_national_focus_province | trigger::no_payload | association_to_trigger_code(a)));
3951 context.compiled_trigger.push_back(trigger::payload(it->second).value);
3952 } else {
3953 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";
3954 return;
3955 }
3956 } else {
3957 err.accumulated_errors += "has_national_focus given an invalid focus '" + std::string(value) + "' (" + err.file_name + ", line " + std::to_string(line) + ")\n";
3958 return;
3959 }
3960 }
3961 void total_amount_of_divisions(association_type a, int32_t value, error_handler& err, int32_t line,
3962 trigger_building_context& context) {
3964 context.compiled_trigger.push_back(uint16_t(trigger::total_amount_of_divisions | association_to_trigger_code(a)));
3965 } else {
3966 err.accumulated_errors += "total_amount_of_divisions trigger used in an incorrect scope type " +
3967 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3968 std::to_string(line) + ")\n";
3969 return;
3970 }
3971 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
3972 }
3973 void money(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
3975 context.compiled_trigger.push_back(uint16_t(trigger::money | association_to_trigger_code(a)));
3976 } else if(context.main_slot == trigger::slot_contents::province) {
3977 context.compiled_trigger.push_back(uint16_t(trigger::money_province | association_to_trigger_code(a)));
3978 } else {
3979 err.accumulated_errors += "money trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) +
3980 "(" + err.file_name + ", line " + std::to_string(line) + ")\n";
3981 return;
3982 }
3983 context.add_float_to_payload(value);
3984 }
3985 void lost_national(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
3987 context.compiled_trigger.push_back(uint16_t(trigger::lost_national | association_to_trigger_code(a)));
3988 } else {
3989 err.accumulated_errors += "lost_national trigger used in an incorrect scope type " +
3990 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
3991 std::to_string(line) + ")\n";
3992 return;
3993 }
3994 context.add_float_to_payload(value);
3995 }
3996 void is_vassal(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
3998 context.compiled_trigger.push_back(uint16_t(trigger::is_vassal | trigger::no_payload | association_to_bool_code(a, value)));
3999 } else {
4000 err.accumulated_errors += "is_vassal trigger used in an incorrect scope type " +
4001 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4002 std::to_string(line) + ")\n";
4003 return;
4004 }
4005 }
4006 void ruling_party_ideology(association_type a, std::string_view value, error_handler& err, int32_t line,
4007 trigger_building_context& context) {
4008 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
4009 it != context.outer_context.map_of_ideologies.end()) {
4011 context.compiled_trigger.push_back(uint16_t(trigger::ruling_party_ideology_nation | association_to_bool_code(a)));
4012 } else if(context.main_slot == trigger::slot_contents::pop) {
4013 context.compiled_trigger.push_back(uint16_t(trigger::ruling_party_ideology_pop | association_to_bool_code(a)));
4014 } else if(context.main_slot == trigger::slot_contents::province) {
4015 context.compiled_trigger.push_back(uint16_t(trigger::ruling_party_ideology_province | association_to_bool_code(a)));
4016 } else {
4017 err.accumulated_errors += "ruling_party_ideology trigger used in an incorrect scope type " +
4018 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4019 std::to_string(line) + ")\n";
4020 return;
4021 }
4022 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
4023 } else {
4024 err.accumulated_errors += "ruling_party_ideology trigger supplied with an invalid ideology \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4025 std::to_string(line) + ")\n";
4026 }
4027 }
4028 void ruling_party(association_type a, std::string_view value, error_handler& err, int32_t line,
4029 trigger_building_context& context);
4030 void has_leader(association_type a, std::string_view value, error_handler& err, int32_t line,
4031 trigger_building_context& context);
4032 void is_ideology_enabled(association_type a, std::string_view value, error_handler& err, int32_t line,
4033 trigger_building_context& context) {
4034 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value));
4035 it != context.outer_context.map_of_ideologies.end()) {
4036 context.compiled_trigger.push_back(uint16_t(trigger::is_ideology_enabled | association_to_bool_code(a)));
4037 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
4038 } else {
4039 err.accumulated_errors += "is_ideology_enabled trigger supplied with an invalid ideology \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4040 std::to_string(line) + ")\n";
4041 }
4042 }
4043 void political_reform_want(association_type a, float value, error_handler& err, int32_t line,
4044 trigger_building_context& context) {
4046 context.compiled_trigger.push_back(uint16_t(trigger::political_reform_want_nation | association_to_trigger_code(a)));
4047 } else if(context.main_slot == trigger::slot_contents::pop) {
4048 context.compiled_trigger.push_back(uint16_t(trigger::political_reform_want_pop | association_to_trigger_code(a)));
4049 } else {
4050 err.accumulated_errors += "political_reform_want trigger used in an incorrect scope type " +
4051 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4052 std::to_string(line) + ")\n";
4053 return;
4054 }
4055 context.add_float_to_payload(value);
4056 }
4057 void social_reform_want(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4059 context.compiled_trigger.push_back(uint16_t(trigger::social_reform_want_nation | association_to_trigger_code(a)));
4060 } else if(context.main_slot == trigger::slot_contents::pop) {
4061 context.compiled_trigger.push_back(uint16_t(trigger::social_reform_want_pop | association_to_trigger_code(a)));
4062 } else {
4063 err.accumulated_errors += "social_reform_want trigger used in an incorrect scope type " +
4064 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4065 std::to_string(line) + ")\n";
4066 return;
4067 }
4068 context.add_float_to_payload(value);
4069 }
4070 void total_amount_of_ships(association_type a, int32_t value, error_handler& err, int32_t line,
4071 trigger_building_context& context) {
4073 context.compiled_trigger.push_back(uint16_t(trigger::total_amount_of_ships | association_to_trigger_code(a)));
4074 } else {
4075 err.accumulated_errors += "total_amount_of_ships trigger used in an incorrect scope type " +
4076 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4077 std::to_string(line) + ")\n";
4078 return;
4079 }
4080 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
4081 }
4082 void plurality(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4084 context.compiled_trigger.push_back(uint16_t(trigger::plurality | association_to_trigger_code(a)));
4085 } else if(context.main_slot == trigger::slot_contents::pop) {
4086 context.compiled_trigger.push_back(uint16_t(trigger::plurality_pop | association_to_trigger_code(a)));
4087 } else {
4088 err.accumulated_errors += "plurality trigger used in an incorrect scope type " +
4089 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4090 std::to_string(line) + ")\n";
4091 return;
4092 }
4093 context.add_float_to_payload(value * 100.0f);
4094 }
4095 void corruption(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4097 context.compiled_trigger.push_back(uint16_t(trigger::corruption | association_to_trigger_code(a)));
4098 } else {
4099 err.accumulated_errors += "corruption trigger used in an incorrect scope type " +
4100 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4101 std::to_string(line) + ")\n";
4102 return;
4103 }
4104 context.add_float_to_payload(value);
4105 }
4106 void is_state_religion(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4108 context.compiled_trigger.push_back(
4109 uint16_t(trigger::is_state_religion_state | trigger::no_payload | association_to_bool_code(a, value)));
4110 } else if(context.main_slot == trigger::slot_contents::province) {
4111 context.compiled_trigger.push_back(
4112 uint16_t(trigger::is_state_religion_province | trigger::no_payload | association_to_bool_code(a, value)));
4113 } else if(context.main_slot == trigger::slot_contents::pop) {
4114 context.compiled_trigger.push_back(
4115 uint16_t(trigger::is_state_religion_pop | trigger::no_payload | association_to_bool_code(a, value)));
4116 } else {
4117 err.accumulated_errors += "is_state_religion trigger used in an incorrect scope type " +
4118 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4119 std::to_string(line) + ")\n";
4120 return;
4121 }
4122 }
4123 void is_primary_culture(association_type a, std::string_view value, error_handler& err, int32_t line,
4124 trigger_building_context& context) {
4125 if(is_this(value)) {
4128 context.compiled_trigger.push_back(
4129 uint16_t(trigger::is_primary_culture_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
4130 else if(context.this_slot == trigger::slot_contents::state)
4131 context.compiled_trigger.push_back(
4132 uint16_t(trigger::is_primary_culture_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
4134 context.compiled_trigger.push_back(
4135 uint16_t(trigger::is_primary_culture_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
4136 else if(context.this_slot == trigger::slot_contents::pop)
4137 context.compiled_trigger.push_back(
4138 uint16_t(trigger::is_primary_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
4139 else {
4140 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4141 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4142 std::to_string(line) + ")\n";
4143 return;
4144 }
4145 } else if(context.main_slot == trigger::slot_contents::state) {
4147 context.compiled_trigger.push_back(
4148 uint16_t(trigger::is_primary_culture_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
4149 else if(context.this_slot == trigger::slot_contents::state)
4150 context.compiled_trigger.push_back(
4151 uint16_t(trigger::is_primary_culture_state_this_state | trigger::no_payload | association_to_bool_code(a)));
4153 context.compiled_trigger.push_back(
4154 uint16_t(trigger::is_primary_culture_state_this_province | trigger::no_payload | association_to_bool_code(a)));
4155 else if(context.this_slot == trigger::slot_contents::pop)
4156 context.compiled_trigger.push_back(
4157 uint16_t(trigger::is_primary_culture_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
4158 else {
4159 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4160 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4161 std::to_string(line) + ")\n";
4162 return;
4163 }
4164 } else if(context.main_slot == trigger::slot_contents::province) {
4166 context.compiled_trigger.push_back(
4167 uint16_t(trigger::is_primary_culture_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
4168 else if(context.this_slot == trigger::slot_contents::state)
4169 context.compiled_trigger.push_back(
4170 uint16_t(trigger::is_primary_culture_province_this_state | trigger::no_payload | association_to_bool_code(a)));
4172 context.compiled_trigger.push_back(
4173 uint16_t(trigger::is_primary_culture_province_this_province | trigger::no_payload | association_to_bool_code(a)));
4174 else if(context.this_slot == trigger::slot_contents::pop)
4175 context.compiled_trigger.push_back(
4176 uint16_t(trigger::is_primary_culture_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
4177 else {
4178 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4179 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4180 std::to_string(line) + ")\n";
4181 return;
4182 }
4183 } else if(context.main_slot == trigger::slot_contents::pop) {
4185 context.compiled_trigger.push_back(
4186 uint16_t(trigger::is_primary_culture_pop_this_nation | trigger::no_payload | association_to_bool_code(a)));
4187 else if(context.this_slot == trigger::slot_contents::state)
4188 context.compiled_trigger.push_back(
4189 uint16_t(trigger::is_primary_culture_pop_this_state | trigger::no_payload | association_to_bool_code(a)));
4191 context.compiled_trigger.push_back(
4192 uint16_t(trigger::is_primary_culture_pop_this_province | trigger::no_payload | association_to_bool_code(a)));
4193 else if(context.this_slot == trigger::slot_contents::pop)
4194 context.compiled_trigger.push_back(
4195 uint16_t(trigger::is_primary_culture_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
4196 else {
4197 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4198 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4199 std::to_string(line) + ")\n";
4200 return;
4201 }
4202 } else {
4203 err.accumulated_errors += "is_primary_culture = this trigger used in an incorrect scope type " +
4204 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4205 std::to_string(line) + ")\n";
4206 return;
4207 }
4208 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value)); it != context.outer_context.map_of_culture_names.end()) {
4210 context.compiled_trigger.push_back(uint16_t(trigger::primary_culture | association_to_bool_code(a)));
4211 } else if(context.main_slot == trigger::slot_contents::pop) {
4212 context.compiled_trigger.push_back(uint16_t(trigger::culture_pop | association_to_bool_code(a)));
4213 } else {
4214 err.accumulated_errors += "is_primary_culture (treated as primary_culture or culture) trigger used in an incorrect scope type " +
4215 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4216 return;
4217 }
4218 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4219 } else {
4220 bool v = parse_bool(value, line, err);
4222 context.compiled_trigger.push_back(
4223 uint16_t(trigger::is_primary_culture_state | trigger::no_payload | association_to_bool_code(a, v)));
4225 context.compiled_trigger.push_back(
4226 uint16_t(trigger::is_primary_culture_province | trigger::no_payload | association_to_bool_code(a, v)));
4227 else if(context.main_slot == trigger::slot_contents::pop)
4228 context.compiled_trigger.push_back(
4229 uint16_t(trigger::is_primary_culture_pop | trigger::no_payload | association_to_bool_code(a, v)));
4230 else {
4231 err.accumulated_errors += "is_primary_culture trigger used in an incorrect scope type " +
4232 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4233 std::to_string(line) + ")\n";
4234 return;
4235 }
4236 }
4237 }
4238 void is_accepted_culture(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
4239 if(is_this(value)) {
4242 context.compiled_trigger.push_back(
4243 uint16_t(trigger::is_accepted_culture_nation_this_nation | trigger::no_payload | association_to_bool_code(a)));
4244 else if(context.this_slot == trigger::slot_contents::state)
4245 context.compiled_trigger.push_back(
4246 uint16_t(trigger::is_accepted_culture_nation_this_state | trigger::no_payload | association_to_bool_code(a)));
4248 context.compiled_trigger.push_back(
4249 uint16_t(trigger::is_accepted_culture_nation_this_province | trigger::no_payload | association_to_bool_code(a)));
4250 else if(context.this_slot == trigger::slot_contents::pop)
4251 context.compiled_trigger.push_back(
4252 uint16_t(trigger::is_accepted_culture_nation_this_pop | trigger::no_payload | association_to_bool_code(a)));
4253 else {
4254 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4255 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4256 std::to_string(line) + ")\n";
4257 return;
4258 }
4259 } else if(context.main_slot == trigger::slot_contents::state) {
4261 context.compiled_trigger.push_back(
4262 uint16_t(trigger::is_accepted_culture_state_this_nation | trigger::no_payload | association_to_bool_code(a)));
4263 else if(context.this_slot == trigger::slot_contents::state)
4264 context.compiled_trigger.push_back(
4265 uint16_t(trigger::is_accepted_culture_state_this_state | trigger::no_payload | association_to_bool_code(a)));
4267 context.compiled_trigger.push_back(
4268 uint16_t(trigger::is_accepted_culture_state_this_province | trigger::no_payload | association_to_bool_code(a)));
4269 else if(context.this_slot == trigger::slot_contents::pop)
4270 context.compiled_trigger.push_back(
4271 uint16_t(trigger::is_accepted_culture_state_this_pop | trigger::no_payload | association_to_bool_code(a)));
4272 else {
4273 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4274 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4275 std::to_string(line) + ")\n";
4276 return;
4277 }
4278 } else if(context.main_slot == trigger::slot_contents::province) {
4280 context.compiled_trigger.push_back(
4281 uint16_t(trigger::is_accepted_culture_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
4282 else if(context.this_slot == trigger::slot_contents::state)
4283 context.compiled_trigger.push_back(
4284 uint16_t(trigger::is_accepted_culture_province_this_state | trigger::no_payload | association_to_bool_code(a)));
4286 context.compiled_trigger.push_back(
4287 uint16_t(trigger::is_accepted_culture_province_this_province | trigger::no_payload | association_to_bool_code(a)));
4288 else if(context.this_slot == trigger::slot_contents::pop)
4289 context.compiled_trigger.push_back(
4290 uint16_t(trigger::is_accepted_culture_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
4291 else {
4292 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4293 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4294 std::to_string(line) + ")\n";
4295 return;
4296 }
4297 } else if(context.main_slot == trigger::slot_contents::pop) {
4299 context.compiled_trigger.push_back(
4300 uint16_t(trigger::is_accepted_culture_pop_this_nation | trigger::no_payload | association_to_bool_code(a)));
4301 else if(context.this_slot == trigger::slot_contents::state)
4302 context.compiled_trigger.push_back(
4303 uint16_t(trigger::is_accepted_culture_pop_this_state | trigger::no_payload | association_to_bool_code(a)));
4305 context.compiled_trigger.push_back(
4306 uint16_t(trigger::is_accepted_culture_pop_this_province | trigger::no_payload | association_to_bool_code(a)));
4307 else if(context.this_slot == trigger::slot_contents::pop)
4308 context.compiled_trigger.push_back(
4309 uint16_t(trigger::is_accepted_culture_pop_this_pop | trigger::no_payload | association_to_bool_code(a)));
4310 else {
4311 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4312 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4313 std::to_string(line) + ")\n";
4314 return;
4315 }
4316 } else {
4317 err.accumulated_errors += "is_accepted_culture = this trigger used in an incorrect scope type " +
4318 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4319 std::to_string(line) + ")\n";
4320 return;
4321 }
4322 } else if(auto it = context.outer_context.map_of_culture_names.find(std::string(value)); it != context.outer_context.map_of_culture_names.end()) {
4324 context.compiled_trigger.push_back(uint16_t(trigger::accepted_culture | association_to_bool_code(a)));
4325 } else {
4326 err.accumulated_errors += "is_accepted_culture (treated as accepted_culture) trigger used in an incorrect scope type " +
4327 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4328 return;
4329 }
4330 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4331 } else {
4332 bool v = parse_bool(value, line, err);
4334 context.compiled_trigger.push_back(
4335 uint16_t(trigger::is_accepted_culture_state | trigger::no_payload | association_to_bool_code(a, v)));
4336 } else if(context.main_slot == trigger::slot_contents::province) {
4337 context.compiled_trigger.push_back(
4338 uint16_t(trigger::is_accepted_culture_province | trigger::no_payload | association_to_bool_code(a, v)));
4339 } else if(context.main_slot == trigger::slot_contents::pop) {
4340 context.compiled_trigger.push_back(
4341 uint16_t(trigger::is_accepted_culture_pop | trigger::no_payload | association_to_bool_code(a, v)));
4342 } else {
4343 err.accumulated_errors += "is_accepted_culture trigger used in an incorrect scope type " +
4344 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4345 std::to_string(line) + ")\n";
4346 return;
4347 }
4348 }
4349 }
4350 void is_coastal(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4352 context.compiled_trigger.push_back(
4353 uint16_t(trigger::is_coastal_state | trigger::no_payload | association_to_bool_code(a, value)));
4354 } else if(context.main_slot == trigger::slot_contents::province) {
4355 context.compiled_trigger.push_back(
4356 uint16_t(trigger::is_coastal_province | trigger::no_payload | association_to_bool_code(a, value)));
4357 } else {
4358 err.accumulated_errors += "is_coastal trigger used in an incorrect scope type " +
4359 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4360 std::to_string(line) + ")\n";
4361 return;
4362 }
4363 }
4364 void in_sphere(association_type a, std::string_view value, error_handler& err, int32_t line,
4365 trigger_building_context& context) {
4367 if(is_this(value)) {
4369 context.compiled_trigger.push_back(
4370 uint16_t(trigger::in_sphere_this_nation | trigger::no_payload | association_to_bool_code(a)));
4371 else if(context.this_slot == trigger::slot_contents::state)
4372 context.compiled_trigger.push_back(
4373 uint16_t(trigger::in_sphere_this_state | trigger::no_payload | association_to_bool_code(a)));
4375 context.compiled_trigger.push_back(
4376 uint16_t(trigger::in_sphere_this_province | trigger::no_payload | association_to_bool_code(a)));
4377 else if(context.this_slot == trigger::slot_contents::pop)
4378 context.compiled_trigger.push_back(
4379 uint16_t(trigger::in_sphere_this_pop | trigger::no_payload | association_to_bool_code(a)));
4380 else {
4381 err.accumulated_errors += "in_sphere = this 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(is_from(value)) {
4388 context.compiled_trigger.push_back(
4389 uint16_t(trigger::in_sphere_from | trigger::no_payload | association_to_bool_code(a)));
4390 else {
4391 err.accumulated_errors += "in_sphere = from trigger used in an incorrect scope type " +
4392 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4393 std::to_string(line) + ")\n";
4394 return;
4395 }
4396 } else if(value.length() == 3) {
4397 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4398 it != context.outer_context.map_of_ident_names.end()) {
4399 context.compiled_trigger.push_back(uint16_t(trigger::in_sphere_tag | association_to_bool_code(a)));
4400 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4401 } else {
4402 err.accumulated_errors +=
4403 "in_sphere trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4404 }
4405 } else {
4406 err.accumulated_errors +=
4407 "in_sphere trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4408 return;
4409 }
4410 } else {
4411 err.accumulated_errors += "in_sphere trigger used in an incorrect scope type " +
4412 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4413 std::to_string(line) + ")\n";
4414 return;
4415 }
4416 }
4417 void produces(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
4418 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(value));
4419 it != context.outer_context.map_of_commodity_names.end()) {
4421 context.compiled_trigger.push_back(uint16_t(trigger::produces_nation | association_to_bool_code(a)));
4422 } else if(context.main_slot == trigger::slot_contents::state) {
4423 context.compiled_trigger.push_back(uint16_t(trigger::produces_state | association_to_bool_code(a)));
4424 } else if(context.main_slot == trigger::slot_contents::province) {
4425 context.compiled_trigger.push_back(uint16_t(trigger::produces_province | association_to_bool_code(a)));
4426 } else if(context.main_slot == trigger::slot_contents::pop) {
4427 context.compiled_trigger.push_back(uint16_t(trigger::produces_pop | association_to_bool_code(a)));
4428 } else {
4429 err.accumulated_errors += "produces trigger used in an incorrect scope type " +
4430 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4431 return;
4432 }
4433 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4434 } else {
4435 err.accumulated_errors += "produces trigger supplied with an invalid commodity \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4436 }
4437 }
4438 void has_pop_type(association_type a, std::string_view value, error_handler& err, int32_t line,
4439 trigger_building_context& context) {
4440 if(auto it = context.outer_context.map_of_poptypes.find(std::string(value));
4441 it != context.outer_context.map_of_poptypes.end()) {
4443 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_nation | association_to_bool_code(a)));
4444 } else if(context.main_slot == trigger::slot_contents::state) {
4445 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_state | association_to_bool_code(a)));
4446 } else if(context.main_slot == trigger::slot_contents::province) {
4447 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_province | association_to_bool_code(a)));
4448 } else if(context.main_slot == trigger::slot_contents::pop) {
4449 context.compiled_trigger.push_back(uint16_t(trigger::has_pop_type_pop | association_to_bool_code(a)));
4450 } else {
4451 err.accumulated_errors += "has_pop_type trigger used in an incorrect scope type " +
4452 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4453 return;
4454 }
4455 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4456 } else {
4457 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";
4458 }
4459 }
4460 void total_pops(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4462 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_nation | association_to_trigger_code(a)));
4463 } else if(context.main_slot == trigger::slot_contents::state) {
4464 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_state | association_to_trigger_code(a)));
4465 } else if(context.main_slot == trigger::slot_contents::province) {
4466 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_province | association_to_trigger_code(a)));
4467 } else if(context.main_slot == trigger::slot_contents::pop) {
4468 context.compiled_trigger.push_back(uint16_t(trigger::total_pops_pop | association_to_trigger_code(a)));
4469 } else {
4470 err.accumulated_errors += "total_pops trigger used in an incorrect scope type " +
4471 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4472 std::to_string(line) + ")\n";
4473 return;
4474 }
4475 context.add_float_to_payload(value);
4476 }
4477 void average_militancy(association_type a, float value, error_handler& err, int32_t line, trigger_building_context& context) {
4479 context.compiled_trigger.push_back(uint16_t(trigger::average_militancy_nation | association_to_trigger_code(a)));
4480 } else if(context.main_slot == trigger::slot_contents::state) {
4481 context.compiled_trigger.push_back(uint16_t(trigger::average_militancy_state | association_to_trigger_code(a)));
4482 } else if(context.main_slot == trigger::slot_contents::province) {
4483 context.compiled_trigger.push_back(uint16_t(trigger::average_militancy_province | association_to_trigger_code(a)));
4484 } else {
4485 err.accumulated_errors += "average_militancy trigger used in an incorrect scope type " +
4486 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4487 std::to_string(line) + ")\n";
4488 return;
4489 }
4490 context.add_float_to_payload(value);
4491 }
4492 void average_consciousness(association_type a, float value, error_handler& err, int32_t line,
4493 trigger_building_context& context) {
4495 context.compiled_trigger.push_back(uint16_t(trigger::average_consciousness_nation | association_to_trigger_code(a)));
4496 } else if(context.main_slot == trigger::slot_contents::state) {
4497 context.compiled_trigger.push_back(uint16_t(trigger::average_consciousness_state | association_to_trigger_code(a)));
4498 } else if(context.main_slot == trigger::slot_contents::province) {
4499 context.compiled_trigger.push_back(uint16_t(trigger::average_consciousness_province | association_to_trigger_code(a)));
4500 } else {
4501 err.accumulated_errors += "average_consciousness trigger used in an incorrect scope type " +
4502 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4503 std::to_string(line) + ")\n";
4504 return;
4505 }
4506 context.add_float_to_payload(value);
4507 }
4508 void is_next_reform(association_type a, std::string_view value, error_handler& err, int32_t line,
4509 trigger_building_context& context) {
4510 if(auto it = context.outer_context.map_of_ioptions.find(std::string(value));
4511 it != context.outer_context.map_of_ioptions.end()) {
4513 context.compiled_trigger.push_back(uint16_t(trigger::is_next_reform_nation | association_to_bool_code(a)));
4514 } else if(context.main_slot == trigger::slot_contents::pop) {
4515 context.compiled_trigger.push_back(uint16_t(trigger::is_next_reform_pop | association_to_bool_code(a)));
4516 } else {
4517 err.accumulated_errors += "is_next_reform trigger used in an incorrect scope type " +
4518 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4519 std::to_string(line) + ")\n";
4520 return;
4521 }
4522 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
4523 } else if(auto itb = context.outer_context.map_of_roptions.find(std::string(value));
4524 itb != context.outer_context.map_of_roptions.end()) {
4526 context.compiled_trigger.push_back(uint16_t(trigger::is_next_rreform_nation | association_to_bool_code(a)));
4527 } else if(context.main_slot == trigger::slot_contents::pop) {
4528 context.compiled_trigger.push_back(uint16_t(trigger::is_next_rreform_pop | association_to_bool_code(a)));
4529 } else {
4530 err.accumulated_errors += "is_next_reform trigger used in an incorrect scope type " +
4531 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4532 std::to_string(line) + ")\n";
4533 return;
4534 }
4535 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
4536 } else {
4537 err.accumulated_errors += "is_next_reform trigger supplied with an invalid issue/reform \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4538 std::to_string(line) + ")\n";
4539 }
4540 }
4541 void rebel_power_fraction(association_type a, float value, error_handler& err, int32_t line,
4542 trigger_building_context& context) {
4544 context.compiled_trigger.push_back(uint16_t(trigger::rebel_power_fraction | association_to_trigger_code(a)));
4545 } else {
4546 err.accumulated_errors += "rebel_power_fraction trigger used in an incorrect scope type " +
4547 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4548 std::to_string(line) + ")\n";
4549 return;
4550 }
4551 context.add_float_to_payload(value);
4552 }
4553 void recruited_percentage(association_type a, float value, error_handler& err, int32_t line,
4554 trigger_building_context& context) {
4556 context.compiled_trigger.push_back(uint16_t(trigger::recruited_percentage_nation | association_to_trigger_code(a)));
4557 } else if(context.main_slot == trigger::slot_contents::pop) {
4558 context.compiled_trigger.push_back(uint16_t(trigger::recruited_percentage_pop | association_to_trigger_code(a)));
4559 } else {
4560 err.accumulated_errors += "recruited_percentage trigger used in an incorrect scope type " +
4561 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4562 std::to_string(line) + ")\n";
4563 return;
4564 }
4565 context.add_float_to_payload(value);
4566 }
4567 void has_culture_core(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4568 if(context.main_slot == trigger::slot_contents::pop) {
4569 context.compiled_trigger.push_back(
4570 uint16_t(trigger::has_culture_core | trigger::no_payload | association_to_bool_code(a, value)));
4572 context.compiled_trigger.push_back(
4573 uint16_t(trigger::has_culture_core_province_this_pop | trigger::no_payload | association_to_bool_code(a, value)));
4574 } else {
4575 err.accumulated_errors += "has_culture_core 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 }
4581 void nationalism(association_type a, int32_t value, error_handler& err, int32_t line, trigger_building_context& context) {
4583 context.compiled_trigger.push_back(uint16_t(trigger::nationalism | association_to_trigger_code(a)));
4584 } else {
4585 err.accumulated_errors += "nationalism trigger used in an incorrect scope type " +
4586 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4587 std::to_string(line) + ")\n";
4588 return;
4589 }
4590 context.compiled_trigger.push_back(trigger::payload(uint16_t(value)).value);
4591 }
4592 void is_overseas(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4594 context.compiled_trigger.push_back(
4595 uint16_t(trigger::is_overseas | trigger::no_payload | association_to_bool_code(a, value)));
4596 } else if(context.main_slot == trigger::slot_contents::pop) {
4597 context.compiled_trigger.push_back(
4598 uint16_t(trigger::is_overseas_pop | trigger::no_payload | association_to_bool_code(a, value)));
4599 } else if(context.main_slot == trigger::slot_contents::state) {
4600 context.compiled_trigger.push_back(
4601 uint16_t(trigger::is_overseas_state | trigger::no_payload | association_to_bool_code(a, value)));
4602 } else {
4603 err.accumulated_errors += "is_overseas trigger used in an incorrect scope type " +
4604 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4605 std::to_string(line) + ")\n";
4606 return;
4607 }
4608 }
4609 void controlled_by_rebels(association_type a, bool value, error_handler& err, int32_t line, trigger_building_context& context) {
4611 context.compiled_trigger.push_back(
4612 uint16_t(trigger::controlled_by_rebels | trigger::no_payload | association_to_bool_code(a, value)));
4613 } else {
4614 err.accumulated_errors += "controlled_by_rebels trigger used in an incorrect scope type " +
4615 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4616 std::to_string(line) + ")\n";
4617 return;
4618 }
4619 }
4620 void controlled_by(association_type a, std::string_view value, error_handler& err, int32_t line,
4621 trigger_building_context& context) {
4623 if(is_this(value)) {
4625 context.compiled_trigger.push_back(
4626 uint16_t(trigger::controlled_by_this_nation | trigger::no_payload | association_to_bool_code(a)));
4627 else if(context.this_slot == trigger::slot_contents::state)
4628 context.compiled_trigger.push_back(
4629 uint16_t(trigger::controlled_by_this_state | trigger::no_payload | association_to_bool_code(a)));
4631 context.compiled_trigger.push_back(
4632 uint16_t(trigger::controlled_by_this_province | trigger::no_payload | association_to_bool_code(a)));
4633 else if(context.this_slot == trigger::slot_contents::pop)
4634 context.compiled_trigger.push_back(
4635 uint16_t(trigger::controlled_by_this_pop | trigger::no_payload | association_to_bool_code(a)));
4636 else {
4637 err.accumulated_errors += "controlled_by = this 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_from(value)) {
4644 context.compiled_trigger.push_back(
4645 uint16_t(trigger::controlled_by_from | trigger::no_payload | association_to_bool_code(a)));
4646 else {
4647 err.accumulated_errors += "controlled_by = from trigger used in an incorrect scope type " +
4648 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4649 std::to_string(line) + ")\n";
4650 return;
4651 }
4652 } else if(is_reb(value)) {
4654 context.compiled_trigger.push_back(
4655 uint16_t(trigger::controlled_by_reb | trigger::no_payload | association_to_bool_code(a)));
4656 else {
4657 context.compiled_trigger.push_back(
4658 uint16_t(trigger::controlled_by_rebels | trigger::no_payload | association_to_bool_code(a)));
4659 }
4660 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "owner")) {
4661 context.compiled_trigger.push_back(
4662 uint16_t(trigger::controlled_by_owner | trigger::no_payload | association_to_bool_code(a)));
4663 } else if(value.length() == 3) {
4664 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4665 it != context.outer_context.map_of_ident_names.end()) {
4666 context.compiled_trigger.push_back(uint16_t(trigger::controlled_by_tag | association_to_bool_code(a)));
4667 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4668 } else {
4669 err.accumulated_errors +=
4670 "controlled_by trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4671 }
4672 } else {
4673 err.accumulated_errors +=
4674 "controlled_by trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4675 return;
4676 }
4677 } else {
4678 err.accumulated_errors += "controlled_by trigger used in an incorrect scope type " +
4679 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4680 std::to_string(line) + ")\n";
4681 return;
4682 }
4683 }
4684 void truce_with(association_type a, std::string_view value, error_handler& err, int32_t line,
4685 trigger_building_context& context) {
4687 if(is_this(value)) {
4689 context.compiled_trigger.push_back(
4690 uint16_t(trigger::truce_with_this_nation | trigger::no_payload | association_to_bool_code(a)));
4691 else if(context.this_slot == trigger::slot_contents::state)
4692 context.compiled_trigger.push_back(
4693 uint16_t(trigger::truce_with_this_state | trigger::no_payload | association_to_bool_code(a)));
4695 context.compiled_trigger.push_back(
4696 uint16_t(trigger::truce_with_this_province | trigger::no_payload | association_to_bool_code(a)));
4697 else if(context.this_slot == trigger::slot_contents::pop)
4698 context.compiled_trigger.push_back(
4699 uint16_t(trigger::truce_with_this_pop | trigger::no_payload | association_to_bool_code(a)));
4700 else {
4701 err.accumulated_errors += "truce_with = this 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(is_from(value)) {
4708 context.compiled_trigger.push_back(
4709 uint16_t(trigger::truce_with_from | trigger::no_payload | association_to_bool_code(a)));
4710 else {
4711 err.accumulated_errors += "truce_with = from trigger used in an incorrect scope type " +
4712 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4713 std::to_string(line) + ")\n";
4714 return;
4715 }
4716 } else if(value.length() == 3) {
4717 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4718 it != context.outer_context.map_of_ident_names.end()) {
4719 context.compiled_trigger.push_back(uint16_t(trigger::truce_with_tag | association_to_bool_code(a)));
4720 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4721 } else {
4722 err.accumulated_errors +=
4723 "truce_with trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4724 }
4725 } else {
4726 err.accumulated_errors +=
4727 "truce_with trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4728 return;
4729 }
4730 } else {
4731 err.accumulated_errors += "truce_with trigger used in an incorrect scope type " +
4732 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4733 std::to_string(line) + ")\n";
4734 return;
4735 }
4736 }
4737 void is_sphere_leader_of(association_type a, std::string_view value, error_handler& err, int32_t line,
4738 trigger_building_context& context) {
4740 if(is_this(value)) {
4742 context.compiled_trigger.push_back(
4743 uint16_t(trigger::is_sphere_leader_of_this_nation | trigger::no_payload | association_to_bool_code(a)));
4744 else if(context.this_slot == trigger::slot_contents::state)
4745 context.compiled_trigger.push_back(
4746 uint16_t(trigger::is_sphere_leader_of_this_state | trigger::no_payload | association_to_bool_code(a)));
4748 context.compiled_trigger.push_back(
4749 uint16_t(trigger::is_sphere_leader_of_this_province | trigger::no_payload | association_to_bool_code(a)));
4750 else if(context.this_slot == trigger::slot_contents::pop)
4751 context.compiled_trigger.push_back(
4752 uint16_t(trigger::is_sphere_leader_of_this_pop | trigger::no_payload | association_to_bool_code(a)));
4753 else {
4754 err.accumulated_errors += "is_sphere_leader_of = this 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(is_from(value)) {
4761 context.compiled_trigger.push_back(
4762 uint16_t(trigger::is_sphere_leader_of_from | trigger::no_payload | association_to_bool_code(a)));
4763 else {
4764 err.accumulated_errors += "is_sphere_leader_of = from trigger used in an incorrect scope type " +
4765 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4766 std::to_string(line) + ")\n";
4767 return;
4768 }
4769 } else if(value.length() == 3) {
4770 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4771 it != context.outer_context.map_of_ident_names.end()) {
4772 context.compiled_trigger.push_back(uint16_t(trigger::is_sphere_leader_of_tag | association_to_bool_code(a)));
4773 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4774 } else {
4775 err.accumulated_errors += "is_sphere_leader_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4776 std::to_string(line) + ")\n";
4777 }
4778 } else {
4779 err.accumulated_errors += "is_sphere_leader_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " +
4780 std::to_string(line) + ")\n";
4781 return;
4782 }
4783 } else {
4784 err.accumulated_errors += "is_sphere_leader_of trigger used in an incorrect scope type " +
4785 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4786 std::to_string(line) + ")\n";
4787 return;
4788 }
4789 }
4790 void constructing_cb(association_type a, std::string_view value, error_handler& err, int32_t line,
4791 trigger_building_context& context) {
4793 if(is_this(value)) {
4795 context.compiled_trigger.push_back(
4796 uint16_t(trigger::constructing_cb_this_nation | trigger::no_payload | association_to_bool_code(a)));
4797 else if(context.this_slot == trigger::slot_contents::state)
4798 context.compiled_trigger.push_back(
4799 uint16_t(trigger::constructing_cb_this_state | trigger::no_payload | association_to_bool_code(a)));
4801 context.compiled_trigger.push_back(
4802 uint16_t(trigger::constructing_cb_this_province | trigger::no_payload | association_to_bool_code(a)));
4803 else if(context.this_slot == trigger::slot_contents::pop)
4804 context.compiled_trigger.push_back(
4805 uint16_t(trigger::constructing_cb_this_pop | trigger::no_payload | association_to_bool_code(a)));
4806 else {
4807 err.accumulated_errors += "constructing_cb = this 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(is_from(value)) {
4814 context.compiled_trigger.push_back(
4815 uint16_t(trigger::constructing_cb_from | trigger::no_payload | association_to_bool_code(a)));
4816 else {
4817 err.accumulated_errors += "constructing_cb = from trigger used in an incorrect scope type " +
4818 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4819 std::to_string(line) + ")\n";
4820 return;
4821 }
4822 } else if(value.length() == 3) {
4823 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4824 it != context.outer_context.map_of_ident_names.end()) {
4825 context.compiled_trigger.push_back(uint16_t(trigger::constructing_cb_tag | association_to_bool_code(a)));
4826 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4827 } else {
4828 err.accumulated_errors +=
4829 "constructing_cb trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4830 }
4831 } else {
4832 err.accumulated_errors +=
4833 "constructing_cb trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4834 return;
4835 }
4836 } else {
4837 err.accumulated_errors += "constructing_cb trigger used in an incorrect scope type " +
4838 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4839 std::to_string(line) + ")\n";
4840 return;
4841 }
4842 }
4843 void vassal_of(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
4845 if(is_this(value)) {
4847 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_nation | trigger::no_payload | association_to_bool_code(a)));
4848 else if(context.this_slot == trigger::slot_contents::state)
4849 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_state | trigger::no_payload | association_to_bool_code(a)));
4851 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_province | trigger::no_payload | association_to_bool_code(a)));
4852 else if(context.this_slot == trigger::slot_contents::pop)
4853 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_this_pop | trigger::no_payload | association_to_bool_code(a)));
4854 else {
4855 err.accumulated_errors += "vassal_of = this trigger used in an incorrect scope type " +
4856 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4857 return;
4858 }
4859 } else if(is_from(value)) {
4861 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_from | trigger::no_payload | association_to_bool_code(a)));
4862 else {
4863 err.accumulated_errors += "vassal_of = from trigger used in an incorrect scope type " +
4864 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4865 return;
4866 }
4867 } else if(value.length() == 3) {
4868 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4869 it != context.outer_context.map_of_ident_names.end()) {
4870 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_tag | association_to_bool_code(a)));
4871 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4872 } else {
4873 err.accumulated_errors += "vassal_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4874 }
4875 } else {
4876 err.accumulated_errors += "vassal_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4877 return;
4878 }
4879 } else if(context.main_slot == trigger::slot_contents::province) {
4880 if(is_this(value)) {
4882 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
4883 else if(context.this_slot == trigger::slot_contents::state)
4884 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_state | trigger::no_payload | association_to_bool_code(a)));
4886 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_province | trigger::no_payload | association_to_bool_code(a)));
4887 else if(context.this_slot == trigger::slot_contents::pop)
4888 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
4889 else {
4890 err.accumulated_errors += "vassal_of = this trigger used in an incorrect scope type " +
4891 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4892 return;
4893 }
4894 } else if(is_from(value)) {
4896 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_from | trigger::no_payload | association_to_bool_code(a)));
4897 else {
4898 err.accumulated_errors += "vassal_of = from trigger used in an incorrect scope type " +
4899 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4900 return;
4901 }
4902 } else if(value.length() == 3) {
4903 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4904 it != context.outer_context.map_of_ident_names.end()) {
4905 context.compiled_trigger.push_back(uint16_t(trigger::vassal_of_province_tag | association_to_bool_code(a)));
4906 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4907 } else {
4908 err.accumulated_errors += "vassal_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4909 }
4910 } else {
4911 err.accumulated_errors += "vassal_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4912 return;
4913 }
4914 } else {
4915 err.accumulated_errors += "vassal_of trigger used in an incorrect scope type " +
4916 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4917 return;
4918 }
4919 }
4920 void substate_of(association_type a, std::string_view value, error_handler& err, int32_t line,
4921 trigger_building_context& context) {
4923 if(is_this(value)) {
4925 context.compiled_trigger.push_back(
4926 uint16_t(trigger::substate_of_this_nation | trigger::no_payload | association_to_bool_code(a)));
4927 else if(context.this_slot == trigger::slot_contents::state)
4928 context.compiled_trigger.push_back(
4929 uint16_t(trigger::substate_of_this_state | trigger::no_payload | association_to_bool_code(a)));
4931 context.compiled_trigger.push_back(
4932 uint16_t(trigger::substate_of_this_province | trigger::no_payload | association_to_bool_code(a)));
4933 else if(context.this_slot == trigger::slot_contents::pop)
4934 context.compiled_trigger.push_back(
4935 uint16_t(trigger::substate_of_this_pop | trigger::no_payload | association_to_bool_code(a)));
4936 else {
4937 err.accumulated_errors += "substate_of = this 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(is_from(value)) {
4944 context.compiled_trigger.push_back(
4945 uint16_t(trigger::substate_of_from | trigger::no_payload | association_to_bool_code(a)));
4946 else {
4947 err.accumulated_errors += "substate_of = from trigger used in an incorrect scope type " +
4948 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4949 std::to_string(line) + ")\n";
4950 return;
4951 }
4952 } else if(value.length() == 3) {
4953 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
4954 it != context.outer_context.map_of_ident_names.end()) {
4955 context.compiled_trigger.push_back(uint16_t(trigger::substate_of_tag | association_to_bool_code(a)));
4956 context.compiled_trigger.push_back(trigger::payload(it->second).value);
4957 } else {
4958 err.accumulated_errors +=
4959 "substate_of trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4960 }
4961 } else {
4962 err.accumulated_errors +=
4963 "substate_of trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
4964 return;
4965 }
4966 } else {
4967 err.accumulated_errors += "substate_of trigger used in an incorrect scope type " +
4968 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
4969 std::to_string(line) + ")\n";
4970 return;
4971 }
4972 }
4973 void is_our_vassal(association_type a, std::string_view value, error_handler& err, int32_t line,
4974 trigger_building_context& context) {
4976 if(is_this(value)) {
4978 context.compiled_trigger.push_back(
4979 uint16_t(trigger::is_our_vassal_this_nation | trigger::no_payload | association_to_bool_code(a)));
4980 else if(context.this_slot == trigger::slot_contents::state)
4981 context.compiled_trigger.push_back(
4982 uint16_t(trigger::is_our_vassal_this_state | trigger::no_payload | association_to_bool_code(a)));
4984 context.compiled_trigger.push_back(
4985 uint16_t(trigger::is_our_vassal_this_province | trigger::no_payload | association_to_bool_code(a)));
4986 else if(context.this_slot == trigger::slot_contents::pop)
4987 context.compiled_trigger.push_back(
4988 uint16_t(trigger::is_our_vassal_this_pop | trigger::no_payload | association_to_bool_code(a)));
4989 else {
4990 err.accumulated_errors += "is_our_vassal = this 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(is_from(value)) {
4997 context.compiled_trigger.push_back(
4998 uint16_t(trigger::is_our_vassal_from | trigger::no_payload | association_to_bool_code(a)));
4999 else {
5000 err.accumulated_errors += "is_our_vassal = from trigger used in an incorrect scope type " +
5001 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5002 std::to_string(line) + ")\n";
5003 return;
5004 }
5005 } else if(value.length() == 3) {
5006 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5007 it != context.outer_context.map_of_ident_names.end()) {
5008 context.compiled_trigger.push_back(uint16_t(trigger::is_our_vassal_tag | association_to_bool_code(a)));
5009 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5010 } else {
5011 err.accumulated_errors +=
5012 "is_our_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5013 }
5014 } else {
5015 err.accumulated_errors +=
5016 "is_our_vassal trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5017 return;
5018 }
5019 } else if(context.main_slot == trigger::slot_contents::province) {
5020 if(is_this(value)) {
5022 context.compiled_trigger.push_back(
5023 uint16_t(trigger::is_our_vassal_province_this_nation | trigger::no_payload | association_to_bool_code(a)));
5024 else if(context.this_slot == trigger::slot_contents::state)
5025 context.compiled_trigger.push_back(
5026 uint16_t(trigger::is_our_vassal_province_this_state | trigger::no_payload | association_to_bool_code(a)));
5028 context.compiled_trigger.push_back(
5029 uint16_t(trigger::is_our_vassal_province_this_province | trigger::no_payload | association_to_bool_code(a)));
5030 else if(context.this_slot == trigger::slot_contents::pop)
5031 context.compiled_trigger.push_back(
5032 uint16_t(trigger::is_our_vassal_province_this_pop | trigger::no_payload | association_to_bool_code(a)));
5033 else {
5034 err.accumulated_errors += "is_our_vassal = this 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(is_from(value)) {
5041 context.compiled_trigger.push_back(
5042 uint16_t(trigger::is_our_vassal_province_from | trigger::no_payload | association_to_bool_code(a)));
5043 else {
5044 err.accumulated_errors += "is_our_vassal = from trigger used in an incorrect scope type " +
5045 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5046 std::to_string(line) + ")\n";
5047 return;
5048 }
5049 } else if(value.length() == 3) {
5050 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5051 it != context.outer_context.map_of_ident_names.end()) {
5052 context.compiled_trigger.push_back(uint16_t(trigger::is_our_vassal_province_tag | association_to_bool_code(a)));
5053 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5054 } else {
5055 err.accumulated_errors +=
5056 "is_our_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5057 }
5058 } else {
5059 err.accumulated_errors +=
5060 "is_our_vassal trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5061 return;
5062 }
5063 } else {
5064 err.accumulated_errors += "is_our_vassal trigger used in an incorrect scope type " +
5065 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5066 std::to_string(line) + ")\n";
5067 return;
5068 }
5069 }
5070 void this_culture_union(association_type a, std::string_view value, error_handler& err, int32_t line,
5071 trigger_building_context& context) {
5073 if(is_this(value)) {
5075 context.compiled_trigger.push_back(
5076 uint16_t(trigger::this_culture_union_this_nation | trigger::no_payload | association_to_bool_code(a)));
5077 else if(context.this_slot == trigger::slot_contents::state)
5078 context.compiled_trigger.push_back(
5079 uint16_t(trigger::this_culture_union_this_state | trigger::no_payload | association_to_bool_code(a)));
5081 context.compiled_trigger.push_back(
5082 uint16_t(trigger::this_culture_union_this_province | trigger::no_payload | association_to_bool_code(a)));
5083 else if(context.this_slot == trigger::slot_contents::pop)
5084 context.compiled_trigger.push_back(
5085 uint16_t(trigger::this_culture_union_this_pop | trigger::no_payload | association_to_bool_code(a)));
5086 else {
5087 err.accumulated_errors += "this_culture_union = this trigger used in an incorrect scope type " +
5088 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5089 std::to_string(line) + ")\n";
5090 return;
5091 }
5092 } else if(is_fixed_token_ci(value.data(), value.data() + value.length(), "this_union")) {
5094 context.compiled_trigger.push_back(
5095 uint16_t(trigger::this_culture_union_this_union_nation | trigger::no_payload | association_to_bool_code(a)));
5096 else if(context.this_slot == trigger::slot_contents::state)
5097 context.compiled_trigger.push_back(
5098 uint16_t(trigger::this_culture_union_this_union_state | trigger::no_payload | association_to_bool_code(a)));
5100 context.compiled_trigger.push_back(
5101 uint16_t(trigger::this_culture_union_this_union_province | trigger::no_payload | association_to_bool_code(a)));
5102 else if(context.this_slot == trigger::slot_contents::pop)
5103 context.compiled_trigger.push_back(
5104 uint16_t(trigger::this_culture_union_this_union_pop | trigger::no_payload | association_to_bool_code(a)));
5105 else {
5106 err.accumulated_errors += "this_culture_union = this_union 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(is_from(value)) {
5113 context.compiled_trigger.push_back(
5114 uint16_t(trigger::this_culture_union_from | trigger::no_payload | association_to_bool_code(a)));
5115 else {
5116 err.accumulated_errors += "this_culture_union = from trigger used in an incorrect scope type " +
5117 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5118 std::to_string(line) + ")\n";
5119 return;
5120 }
5121 } else if(value.length() == 3) {
5122 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5123 it != context.outer_context.map_of_ident_names.end()) {
5124 context.compiled_trigger.push_back(uint16_t(trigger::this_culture_union_tag | association_to_bool_code(a)));
5125 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5126 } else {
5127 err.accumulated_errors += "this_culture_union trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " +
5128 std::to_string(line) + ")\n";
5129 }
5130 } else {
5131 err.accumulated_errors += "this_culture_union trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " +
5132 std::to_string(line) + ")\n";
5133 return;
5134 }
5135 } else {
5136 err.accumulated_errors += "this_culture_union trigger used in an incorrect scope type " +
5137 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5138 std::to_string(line) + ")\n";
5139 return;
5140 }
5141 }
5142 void alliance_with(association_type a, std::string_view value, error_handler& err, int32_t line,
5143 trigger_building_context& context) {
5145 if(is_this(value)) {
5147 context.compiled_trigger.push_back(
5148 uint16_t(trigger::alliance_with_this_nation | trigger::no_payload | association_to_bool_code(a)));
5149 else if(context.this_slot == trigger::slot_contents::state)
5150 context.compiled_trigger.push_back(
5151 uint16_t(trigger::alliance_with_this_state | trigger::no_payload | association_to_bool_code(a)));
5153 context.compiled_trigger.push_back(
5154 uint16_t(trigger::alliance_with_this_province | trigger::no_payload | association_to_bool_code(a)));
5155 else if(context.this_slot == trigger::slot_contents::pop)
5156 context.compiled_trigger.push_back(
5157 uint16_t(trigger::alliance_with_this_pop | trigger::no_payload | association_to_bool_code(a)));
5158 else {
5159 err.accumulated_errors += "alliance_with = this 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(is_from(value)) {
5166 context.compiled_trigger.push_back(
5167 uint16_t(trigger::alliance_with_from | trigger::no_payload | association_to_bool_code(a)));
5168 else {
5169 err.accumulated_errors += "alliance_with = from trigger used in an incorrect scope type " +
5170 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5171 std::to_string(line) + ")\n";
5172 return;
5173 }
5174 } else if(value.length() == 3) {
5175 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5176 it != context.outer_context.map_of_ident_names.end()) {
5177 context.compiled_trigger.push_back(uint16_t(trigger::alliance_with_tag | association_to_bool_code(a)));
5178 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5179 } else {
5180 err.accumulated_errors +=
5181 "alliance_with trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5182 }
5183 } else {
5184 err.accumulated_errors +=
5185 "alliance_with trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5186 return;
5187 }
5188 } else {
5189 err.accumulated_errors += "alliance_with trigger used in an incorrect scope type " +
5190 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5191 std::to_string(line) + ")\n";
5192 return;
5193 }
5194 }
5195 void in_default(association_type a, std::string_view value, error_handler& err, int32_t line,
5196 trigger_building_context& context) {
5198 if(is_fixed_token_ci(value.data(), value.data() + value.length(), "yes") ||
5199 is_fixed_token_ci(value.data(), value.data() + value.length(), "no")) {
5200
5201 context.compiled_trigger.push_back(uint16_t(trigger::in_default_bool | trigger::no_payload | association_to_bool_code(a, parse_bool(value, line, err))));
5202
5203 } else if(is_this(value)) {
5205 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_nation | trigger::no_payload | association_to_bool_code(a)));
5206 else if(context.this_slot == trigger::slot_contents::state)
5207 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_state | trigger::no_payload | association_to_bool_code(a)));
5209 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_province | trigger::no_payload | association_to_bool_code(a)));
5210 else if(context.this_slot == trigger::slot_contents::pop)
5211 context.compiled_trigger.push_back(uint16_t(trigger::in_default_this_pop | trigger::no_payload | association_to_bool_code(a)));
5212 else {
5213 err.accumulated_errors += "in_default = this trigger used in an incorrect scope type " +
5214 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5215 std::to_string(line) + ")\n";
5216 return;
5217 }
5218 } else if(is_from(value)) {
5220 context.compiled_trigger.push_back(uint16_t(trigger::in_default_from | trigger::no_payload | association_to_bool_code(a)));
5221 else {
5222 err.accumulated_errors += "in_default = from trigger used in an incorrect scope type " +
5223 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5224 std::to_string(line) + ")\n";
5225 return;
5226 }
5227 } else if(value.length() == 3) {
5228 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5229 it != context.outer_context.map_of_ident_names.end()) {
5230 context.compiled_trigger.push_back(uint16_t(trigger::in_default_tag | association_to_bool_code(a)));
5231 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5232 } else {
5233 err.accumulated_errors += "in_default trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5234 }
5235 } else {
5236 err.accumulated_errors += "in_default trigger supplied with an invalid value \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5237 return;
5238 }
5239 } else {
5240 err.accumulated_errors += "in_default trigger used in an incorrect scope type " +
5241 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5242 return;
5243 }
5244 }
5245 void industrial_score(association_type a, std::string_view value, error_handler& err, int32_t line,
5246 trigger_building_context& context) {
5248 if(is_this(value)) {
5250 context.compiled_trigger.push_back(
5251 uint16_t(trigger::industrial_score_this_nation | trigger::no_payload | association_to_trigger_code(a)));
5252 else if(context.this_slot == trigger::slot_contents::state)
5253 context.compiled_trigger.push_back(
5254 uint16_t(trigger::industrial_score_this_state | trigger::no_payload | association_to_trigger_code(a)));
5256 context.compiled_trigger.push_back(
5257 uint16_t(trigger::industrial_score_this_province | trigger::no_payload | association_to_trigger_code(a)));
5258 else if(context.this_slot == trigger::slot_contents::pop)
5259 context.compiled_trigger.push_back(
5260 uint16_t(trigger::industrial_score_this_pop | trigger::no_payload | association_to_trigger_code(a)));
5261 else {
5262 err.accumulated_errors += "industrial_score = this 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(is_from(value)) {
5269 context.compiled_trigger.push_back(
5270 uint16_t(trigger::industrial_score_from_nation | trigger::no_payload | association_to_trigger_code(a)));
5271 else {
5272 err.accumulated_errors += "industrial_score = from trigger used in an incorrect scope type " +
5273 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5274 std::to_string(line) + ")\n";
5275 return;
5276 }
5277 } else if(!parsers::is_integer(value.data(), value.data() + value.length()) && value.length() == 3) {
5278 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5279 it != context.outer_context.map_of_ident_names.end()) {
5280 context.compiled_trigger.push_back(uint16_t(trigger::industrial_score_tag | association_to_bool_code(a)));
5281 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5282 } else {
5283 err.accumulated_errors += "industrial_score trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5284 }
5285 } else {
5286 context.compiled_trigger.push_back(uint16_t(trigger::industrial_score_value | association_to_trigger_code(a)));
5287 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
5288 }
5289 } else {
5290 err.accumulated_errors += "industrial_score trigger used in an incorrect scope type " +
5291 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5292 std::to_string(line) + ")\n";
5293 return;
5294 }
5295 }
5296 void military_score(association_type a, std::string_view value, error_handler& err, int32_t line,
5297 trigger_building_context& context) {
5299 if(is_this(value)) {
5301 context.compiled_trigger.push_back(
5302 uint16_t(trigger::military_score_this_nation | trigger::no_payload | association_to_trigger_code(a)));
5303 else if(context.this_slot == trigger::slot_contents::state)
5304 context.compiled_trigger.push_back(
5305 uint16_t(trigger::military_score_this_state | trigger::no_payload | association_to_trigger_code(a)));
5307 context.compiled_trigger.push_back(
5308 uint16_t(trigger::military_score_this_province | trigger::no_payload | association_to_trigger_code(a)));
5309 else if(context.this_slot == trigger::slot_contents::pop)
5310 context.compiled_trigger.push_back(
5311 uint16_t(trigger::military_score_this_pop | trigger::no_payload | association_to_trigger_code(a)));
5312 else {
5313 err.accumulated_errors += "military_score = this 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(is_from(value)) {
5320 context.compiled_trigger.push_back(
5321 uint16_t(trigger::military_score_from_nation | trigger::no_payload | association_to_trigger_code(a)));
5322 else {
5323 err.accumulated_errors += "military_score = from trigger used in an incorrect scope type " +
5324 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5325 std::to_string(line) + ")\n";
5326 return;
5327 }
5328 } else if(!parsers::is_integer(value.data(), value.data() + value.length()) && value.length() == 3) {
5329 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5330 it != context.outer_context.map_of_ident_names.end()) {
5331 context.compiled_trigger.push_back(uint16_t(trigger::military_score_tag | association_to_bool_code(a)));
5332 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5333 } else {
5334 err.accumulated_errors += "military_score trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5335 }
5336 } else {
5337 context.compiled_trigger.push_back(uint16_t(trigger::military_score_value | association_to_trigger_code(a)));
5338 context.compiled_trigger.push_back(trigger::payload(uint16_t(parse_uint(value, line, err))).value);
5339 }
5340 } else {
5341 err.accumulated_errors += "military_score trigger used in an incorrect scope type " +
5342 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5343 std::to_string(line) + ")\n";
5344 return;
5345 }
5346 }
5347 void test(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
5348 if(auto it = context.outer_context.map_of_stored_triggers.find(std::string(value)); it != context.outer_context.map_of_stored_triggers.end()) {
5349 dcon::stored_trigger_id st;
5350 for(auto r : it->second) {
5351 if((r.main_slot == context.main_slot || r.main_slot == trigger::slot_contents::empty)
5352 && (r.from_slot == context.from_slot || r.from_slot == trigger::slot_contents::empty)
5353 && (r.this_slot == context.this_slot || r.this_slot == trigger::slot_contents::empty)) {
5354
5355 if(!st) {
5356 st = r.id;
5357 } else {
5358 err.accumulated_errors += "test trigger found multiple matching possibilities for the name " +
5359 std::string(value) + " (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5360 return;
5361 }
5362 }
5363 }
5364 if(st) {
5365 context.compiled_trigger.push_back(uint16_t(trigger::test | association_to_bool_code(a)));
5366 context.compiled_trigger.push_back(trigger::payload(st).value);
5367 } else {
5368 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";
5369 }
5370 } else {
5371 err.accumulated_errors += "test trigger used with an unknown scripted trigger " + std::string(value) + " (" + err.file_name + ", line " +
5372 std::to_string(line) + ")\n";
5373 }
5374 }
5375 void is_possible_vassal(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
5376 if(value.length() == 3) {
5377 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value[0], value[1], value[2]));
5378 it != context.outer_context.map_of_ident_names.end()) {
5380 context.compiled_trigger.push_back(uint16_t(trigger::is_possible_vassal | association_to_bool_code(a)));
5381 } else {
5382 err.accumulated_errors += "is_possible_vassal trigger used in an incorrect scope type " +
5383 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5384 std::to_string(line) + ")\n";
5385 return;
5386 }
5387 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5388 } else {
5389 err.accumulated_errors += "is_possible_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " +
5390 std::to_string(line) + ")\n";
5391 }
5392 } else {
5393 err.accumulated_errors +=
5394 "is_possible_vassal trigger supplied with an invalid tag \"" + std::string(value) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5395 }
5396 }
5397
5398 void diplomatic_influence(tr_diplomatic_influence const& value, error_handler& err, int32_t line,
5399 trigger_building_context& context) {
5401 err.accumulated_errors += "diplomatic_influence trigger used in an incorrect scope type " +
5402 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5403 std::to_string(line) + ")\n";
5404 return;
5405 } else if(is_from(value.who)) {
5407 context.compiled_trigger.push_back(
5408 uint16_t(trigger::diplomatic_influence_from_nation | association_to_trigger_code(value.a)));
5410 context.compiled_trigger.push_back(
5411 uint16_t(trigger::diplomatic_influence_from_province | association_to_trigger_code(value.a)));
5412 else {
5413 err.accumulated_errors += "diplomatic_influence trigger used in an incorrect scope type " +
5414 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5415 std::to_string(line) + ")\n";
5416 return;
5417 }
5418 context.compiled_trigger.push_back(trigger::payload(uint16_t(value.value_)).value);
5419 } else if(is_this(value.who)) {
5421 context.compiled_trigger.push_back(
5422 uint16_t(trigger::diplomatic_influence_this_nation | association_to_trigger_code(value.a)));
5424 context.compiled_trigger.push_back(
5425 uint16_t(trigger::diplomatic_influence_this_province | association_to_trigger_code(value.a)));
5426 else {
5427 err.accumulated_errors += "diplomatic_influence trigger used in an incorrect scope type " +
5428 slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5429 std::to_string(line) + ")\n";
5430 return;
5431 }
5432 context.compiled_trigger.push_back(trigger::payload(uint16_t(value.value_)).value);
5433 } else if(value.who.length() == 3) {
5434 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
5435 it != context.outer_context.map_of_ident_names.end()) {
5436 context.compiled_trigger.push_back(uint16_t(trigger::diplomatic_influence_tag | association_to_trigger_code(value.a)));
5437 context.compiled_trigger.push_back(trigger::payload(uint16_t(value.value_)).value);
5438 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5439 } else {
5440 err.accumulated_errors += "diplomatic_influence trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " +
5441 std::to_string(line) + ")\n";
5442 }
5443 } else {
5444 err.accumulated_errors += "diplomatic_influence trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " +
5445 std::to_string(line) + ")\n";
5446 return;
5447 }
5448 }
5449 void pop_unemployment(tr_pop_unemployment const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5450 if(is_this(value.type)) {
5451 if(context.this_slot != trigger::slot_contents::pop) {
5452 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5453 std::to_string(line) + ")\n";
5454 return;
5455 } else if(context.main_slot == trigger::slot_contents::nation)
5456 context.compiled_trigger.push_back(
5457 uint16_t(trigger::pop_unemployment_nation_this_pop | association_to_trigger_code(value.a)));
5458 else if(context.main_slot == trigger::slot_contents::state)
5459 context.compiled_trigger.push_back(
5460 uint16_t(trigger::pop_unemployment_state_this_pop | association_to_trigger_code(value.a)));
5462 context.compiled_trigger.push_back(
5463 uint16_t(trigger::pop_unemployment_province_this_pop | association_to_trigger_code(value.a)));
5464 else {
5465 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5466 std::to_string(line) + ")\n";
5467 return;
5468 }
5469 context.add_float_to_payload(value.value_);
5470 } else if(is_from(value.type)) {
5471 if(context.this_slot != trigger::slot_contents::pop) {
5472 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5473 std::to_string(line) + ")\n";
5474 return;
5475 } else if(context.main_slot == trigger::slot_contents::nation)
5476 context.compiled_trigger.push_back(
5477 uint16_t(trigger::pop_unemployment_nation_this_pop | association_to_trigger_code(value.a)));
5478 else if(context.main_slot == trigger::slot_contents::state)
5479 context.compiled_trigger.push_back(
5480 uint16_t(trigger::pop_unemployment_state_this_pop | association_to_trigger_code(value.a)));
5482 context.compiled_trigger.push_back(
5483 uint16_t(trigger::pop_unemployment_province_this_pop | association_to_trigger_code(value.a)));
5484 else {
5485 err.accumulated_errors += "pop_unemployment = this trigger used in an invalid context (" + err.file_name + ", line " +
5486 std::to_string(line) + ")\n";
5487 return;
5488 }
5489 context.add_float_to_payload(value.value_);
5490 } else if(auto it = context.outer_context.map_of_poptypes.find(std::string(value.type));
5491 it != context.outer_context.map_of_poptypes.end()) {
5493 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_nation | association_to_trigger_code(value.a)));
5494 else if(context.main_slot == trigger::slot_contents::state)
5495 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_state | association_to_trigger_code(value.a)));
5497 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_province | association_to_trigger_code(value.a)));
5498 else if(context.main_slot == trigger::slot_contents::pop)
5499 context.compiled_trigger.push_back(uint16_t(trigger::pop_unemployment_pop | association_to_trigger_code(value.a)));
5500 else {
5501 err.accumulated_errors +=
5502 "pop_unemployment trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5503 return;
5504 }
5505
5506 context.add_float_to_payload(value.value_);
5507 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5508 } else {
5509 err.accumulated_errors += "pop_unemployment trigger supplied with an invalid pop type (" + err.file_name + ", line " +
5510 std::to_string(line) + ")\n";
5511 return;
5512 }
5513 }
5514 void relation(tr_relation const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5516 err.accumulated_errors +=
5517 "relation trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5518 return;
5519 } else if(is_from(value.who)) {
5521 context.compiled_trigger.push_back(uint16_t(trigger::relation_from_nation | association_to_trigger_code(value.a)));
5523 context.compiled_trigger.push_back(uint16_t(trigger::relation_from_province | association_to_trigger_code(value.a)));
5524 else {
5525 err.accumulated_errors +=
5526 "relation = from trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5527 return;
5528 }
5529 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5530 } else if(is_this(value.who)) {
5532 context.compiled_trigger.push_back(uint16_t(trigger::relation_this_nation | association_to_trigger_code(value.a)));
5534 context.compiled_trigger.push_back(uint16_t(trigger::relation_this_province | association_to_trigger_code(value.a)));
5535 else if(context.this_slot == trigger::slot_contents::pop)
5536 context.compiled_trigger.push_back(uint16_t(trigger::relation_this_pop | association_to_trigger_code(value.a)));
5537 else {
5538 err.accumulated_errors +=
5539 "relation = this trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5540 return;
5541 }
5542 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5543 } else if(value.who.length() == 3) {
5544 if(auto it = context.outer_context.map_of_ident_names.find(nations::tag_to_int(value.who[0], value.who[1], value.who[2]));
5545 it != context.outer_context.map_of_ident_names.end()) {
5546 context.compiled_trigger.push_back(uint16_t(trigger::relation_tag | association_to_trigger_code(value.a)));
5547 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5548 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5549 } else {
5550 err.accumulated_errors +=
5551 "relation trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5552 }
5553 } else {
5554 err.accumulated_errors +=
5555 "relation trigger supplied with an invalid tag \"" + std::string(value.who) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5556 return;
5557 }
5558 }
5559 void check_variable(tr_check_variable const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5560 context.compiled_trigger.push_back(uint16_t(trigger::check_variable | association_to_trigger_code(value.a)));
5561 context.add_float_to_payload(value.value_);
5562 context.compiled_trigger.push_back(
5563 trigger::payload(context.outer_context.get_national_variable(std::string(value.which))).value);
5564 }
5565 void upper_house(tr_upper_house const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5566 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value.ideology));
5567 it != context.outer_context.map_of_ideologies.end()) {
5569 err.accumulated_errors +=
5570 "upper_house trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5571 return;
5572 }
5573 context.compiled_trigger.push_back(uint16_t(trigger::upper_house | association_to_trigger_code(value.a)));
5574 context.add_float_to_payload(value.value_);
5575 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5576 } else {
5577 err.accumulated_errors +=
5578 "upper_house trigger supplied with an invalid ideology \"" + std::string(value.ideology) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5579 return;
5580 }
5581 }
5582 void unemployment_by_type(tr_unemployment_by_type const& value, error_handler& err, int32_t line,
5583 trigger_building_context& context) {
5584 if(auto it = context.outer_context.map_of_poptypes.find(std::string(value.type));
5585 it != context.outer_context.map_of_poptypes.end()) {
5587 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_by_type_nation | association_to_trigger_code(value.a)));
5588 else if(context.main_slot == trigger::slot_contents::state)
5589 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_by_type_state | association_to_trigger_code(value.a)));
5591 context.compiled_trigger.push_back(
5592 uint16_t(trigger::unemployment_by_type_province | association_to_trigger_code(value.a)));
5593 else if(context.main_slot == trigger::slot_contents::pop)
5594 context.compiled_trigger.push_back(uint16_t(trigger::unemployment_by_type_pop | association_to_trigger_code(value.a)));
5595 else {
5596 err.accumulated_errors += "unemployment_by_type trigger used in an invalid context (" + err.file_name + ", line " +
5597 std::to_string(line) + ")\n";
5598 return;
5599 }
5600 context.add_float_to_payload(value.value_);
5601 context.compiled_trigger.push_back(trigger::payload(it->second).value);
5602 } else {
5603 err.accumulated_errors += "unemployment_by_type trigger supplied with an invalid pop type \"" + std::string(value.type) + "\" (" + err.file_name + ", line " +
5604 std::to_string(line) + ")\n";
5605 return;
5606 }
5607 }
5608
5609 void party_loyalty(tr_party_loyalty const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5610 if(auto it = context.outer_context.map_of_ideologies.find(std::string(value.ideology));
5611 it != context.outer_context.map_of_ideologies.end()) {
5612 if(value.province_id != 0) {
5613 if(0 <= value.province_id && size_t(value.province_id) < context.outer_context.original_id_to_prov_id_map.size()) {
5615 context.compiled_trigger.push_back(
5616 uint16_t(trigger::party_loyalty_nation_province_id | association_to_trigger_code(value.a)));
5617 else if(context.from_slot == trigger::slot_contents::nation)
5618 context.compiled_trigger.push_back(
5619 uint16_t(trigger::party_loyalty_from_nation_province_id | association_to_trigger_code(value.a)));
5621 context.compiled_trigger.push_back(
5622 uint16_t(trigger::party_loyalty_province_province_id | association_to_trigger_code(value.a)));
5624 context.compiled_trigger.push_back(
5625 uint16_t(trigger::party_loyalty_from_province_province_id | association_to_trigger_code(value.a)));
5626 else {
5627 err.accumulated_errors +=
5628 "party_loyalty trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5629 return;
5630 }
5631 context.compiled_trigger.push_back(
5633 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5634 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5635 } else {
5636 err.accumulated_errors += "party_loyalty trigger supplied with an invalid province id " + std::to_string(value.province_id) + " (" + err.file_name + ", line " +
5637 std::to_string(line) + ")\n";
5638 return;
5639 }
5640 } else {
5643 context.compiled_trigger.push_back(
5644 uint16_t(trigger::party_loyalty_from_nation_scope_province | association_to_trigger_code(value.a)));
5646 context.compiled_trigger.push_back(
5647 uint16_t(trigger::party_loyalty_from_province_scope_province | association_to_trigger_code(value.a)));
5648 else
5649 context.compiled_trigger.push_back(uint16_t(trigger::party_loyalty_generic | association_to_trigger_code(value.a)));
5650 } else {
5651 err.accumulated_errors +=
5652 "party_loyalty trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5653 return;
5654 }
5655 context.compiled_trigger.push_back(trigger::payload(int16_t(value.value_)).value);
5656 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5657 }
5658 } else {
5659 err.accumulated_errors +=
5660 "party_loyalty trigger supplied with an invalid ideology \"" + std::string(value.ideology) + "\" (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5661 return;
5662 }
5663 }
5664
5665 void can_build_in_province(tr_can_build_in_province const& value, error_handler& err, int32_t line,
5666 trigger_building_context& context) {
5668 err.accumulated_errors +=
5669 "can_build_in_province trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5670 return;
5671 } else if(value.limit_to_world_greatest_level) {
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_this_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_this_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_this_nation | trigger::association_eq | trigger::no_payload));
5682 } else if(context.from_slot == trigger::slot_contents::nation) {
5683 if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "railroad"))
5684 context.compiled_trigger.push_back(uint16_t(
5685 trigger::can_build_in_province_railroad_yes_limit_from_nation | trigger::association_eq | trigger::no_payload));
5686 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "naval_base"))
5687 context.compiled_trigger.push_back(uint16_t(
5688 trigger::can_build_in_province_naval_base_yes_limit_from_nation | trigger::association_eq | trigger::no_payload));
5689 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "fort"))
5690 context.compiled_trigger.push_back(uint16_t(
5691 trigger::can_build_in_province_fort_yes_limit_from_nation | trigger::association_eq | trigger::no_payload));
5692 } else {
5693 err.accumulated_errors += "can_build_in_province trigger used in an invalid context (" + err.file_name + ", line " +
5694 std::to_string(line) + ")\n";
5695 return;
5696 }
5697 } else {
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_this_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_this_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_this_nation | trigger::association_eq | trigger::no_payload));
5708 } else if(context.from_slot == trigger::slot_contents::nation) {
5709 if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "railroad"))
5710 context.compiled_trigger.push_back(uint16_t(
5711 trigger::can_build_in_province_railroad_no_limit_from_nation | trigger::association_eq | trigger::no_payload));
5712 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "naval_base"))
5713 context.compiled_trigger.push_back(uint16_t(
5714 trigger::can_build_in_province_naval_base_no_limit_from_nation | trigger::association_eq | trigger::no_payload));
5715 else if(is_fixed_token_ci(value.building.data(), value.building.data() + value.building.length(), "fort"))
5716 context.compiled_trigger.push_back(
5717 uint16_t(trigger::can_build_in_province_fort_no_limit_from_nation | trigger::association_eq | trigger::no_payload));
5718 } else {
5719 err.accumulated_errors += "can_build_in_province trigger used in an invalid context (" + err.file_name + ", line " +
5720 std::to_string(line) + ")\n";
5721 return;
5722 }
5723 }
5724 }
5726 trigger_building_context& context) {
5728 err.accumulated_errors += "can_build_railway_in_capital trigger used in an invalid context (" + err.file_name + ", line " +
5729 std::to_string(line) + ")\n";
5730 return;
5731 } else if(value.in_whole_capital_state) {
5732 if(value.limit_to_world_greatest_level)
5733 context.compiled_trigger.push_back(uint16_t(
5734 trigger::can_build_railway_in_capital_yes_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5735 else
5736 context.compiled_trigger.push_back(uint16_t(
5737 trigger::can_build_railway_in_capital_yes_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5738 } else {
5739 if(value.limit_to_world_greatest_level)
5740 context.compiled_trigger.push_back(uint16_t(
5741 trigger::can_build_railway_in_capital_no_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5742 else
5743 context.compiled_trigger.push_back(uint16_t(
5744 trigger::can_build_railway_in_capital_no_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5745 }
5746 }
5748 trigger_building_context& context) {
5750 err.accumulated_errors += "can_build_fort_in_capital trigger used in an invalid context (" + err.file_name + ", line " +
5751 std::to_string(line) + ")\n";
5752 return;
5753 } else if(value.in_whole_capital_state) {
5754 if(value.limit_to_world_greatest_level)
5755 context.compiled_trigger.push_back(uint16_t(
5756 trigger::can_build_fort_in_capital_yes_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5757 else
5758 context.compiled_trigger.push_back(uint16_t(
5759 trigger::can_build_fort_in_capital_yes_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5760 } else {
5761 if(value.limit_to_world_greatest_level)
5762 context.compiled_trigger.push_back(uint16_t(
5763 trigger::can_build_fort_in_capital_no_whole_state_yes_limit | trigger::association_eq | trigger::no_payload));
5764 else
5765 context.compiled_trigger.push_back(
5766 uint16_t(trigger::can_build_fort_in_capital_no_whole_state_no_limit | trigger::association_eq | trigger::no_payload));
5767 }
5768 }
5769
5770 void work_available(tr_work_available const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5771 if(value.pop_type_list.size() > 1 || value.pop_type_list.size() == 0) {
5772 err.accumulated_errors += "work_available trigger used with an unsupported number of worker types (" + err.file_name +
5773 ", line " + std::to_string(line) + ")\n";
5774 return;
5775 }
5776
5778 context.compiled_trigger.push_back(uint16_t(trigger::work_available_nation | trigger::association_eq));
5779 else if(context.main_slot == trigger::slot_contents::state)
5780 context.compiled_trigger.push_back(uint16_t(trigger::work_available_state | trigger::association_eq));
5782 context.compiled_trigger.push_back(uint16_t(trigger::work_available_province | trigger::association_eq));
5783 else {
5784 err.accumulated_errors +=
5785 "work_available trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5786 return;
5787 }
5788 context.compiled_trigger.push_back(trigger::payload(value.pop_type_list[0]).value);
5789 }
5790 void party_name(tr_party_name const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5792 err.accumulated_errors += "party_name effect 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 }
5796 context.compiled_trigger.push_back(trigger::party_name);
5797 context.compiled_trigger.push_back(trigger::payload(value.ideology_).value);
5798 context.add_int32_t_to_payload(value.name_.index());
5799 }
5800 void party_position(tr_party_position const& value, error_handler& err, int32_t line, trigger_building_context& context) {
5802 err.accumulated_errors += "party_position trigger used in an incorrect scope type " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5803 std::to_string(line) + ")\n";
5804 return;
5805 } else if(!value.opt_) {
5806 err.accumulated_errors += "party_position trigger used without a valid position " + slot_contents_to_string(context.main_slot) + " (" + err.file_name + ", line " +
5807 std::to_string(line) + ")\n";
5808 return;
5809 }
5810 context.compiled_trigger.push_back(trigger::party_position);
5811 context.compiled_trigger.push_back(trigger::payload(value.ideology_).value);
5812 context.compiled_trigger.push_back(trigger::payload(value.opt_).value);
5813 }
5814 void any_value(std::string_view label, association_type a, std::string_view value, error_handler& err, int32_t line,
5815 trigger_building_context& context) {
5816 std::string str_label{label};
5817 if(auto it = context.outer_context.map_of_technologies.find(str_label);
5818 it != context.outer_context.map_of_technologies.end()) {
5820 bool bvalue = parse_bool(value, line, err);
5821 context.compiled_trigger.push_back(uint16_t(trigger::technology | association_to_bool_code(a, bvalue)));
5822 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5823 } else if(context.main_slot == trigger::slot_contents::province) {
5824 bool bvalue = parse_bool(value, line, err);
5825 context.compiled_trigger.push_back(uint16_t(trigger::technology_province | association_to_bool_code(a, bvalue)));
5826 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5827 } else if(context.main_slot == trigger::slot_contents::pop) {
5828 bool bvalue = parse_bool(value, line, err);
5829 context.compiled_trigger.push_back(uint16_t(trigger::technology_pop | association_to_bool_code(a, bvalue)));
5830 context.compiled_trigger.push_back(trigger::payload(it->second.id).value);
5831 } else {
5832 err.accumulated_errors += "named technology trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5833 return;
5834 }
5835 } else if(auto itb = context.outer_context.map_of_inventions.find(str_label);
5836 itb != context.outer_context.map_of_inventions.end()) {
5838 bool bvalue = parse_bool(value, line, err);
5839 context.compiled_trigger.push_back(uint16_t(trigger::invention | association_to_bool_code(a, bvalue)));
5840 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
5841 } else if(context.main_slot == trigger::slot_contents::province) {
5842 bool bvalue = parse_bool(value, line, err);
5843 context.compiled_trigger.push_back(uint16_t(trigger::invention_province | association_to_bool_code(a, bvalue)));
5844 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
5845 } else if(context.main_slot == trigger::slot_contents::pop) {
5846 bool bvalue = parse_bool(value, line, err);
5847 context.compiled_trigger.push_back(uint16_t(trigger::invention_pop | association_to_bool_code(a, bvalue)));
5848 context.compiled_trigger.push_back(trigger::payload(itb->second.id).value);
5849 } else {
5850 err.accumulated_errors += "named invention trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5851 return;
5852 }
5853 } else if(auto itc = context.outer_context.map_of_ideologies.find(str_label);
5854 itc != context.outer_context.map_of_ideologies.end()) {
5856 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_nation | association_to_trigger_code(a)));
5857 else if(context.main_slot == trigger::slot_contents::pop)
5858 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_pop | association_to_trigger_code(a)));
5860 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_province | association_to_trigger_code(a)));
5861 else if(context.main_slot == trigger::slot_contents::state)
5862 context.compiled_trigger.push_back(uint16_t(trigger::variable_ideology_name_state | association_to_trigger_code(a)));
5863 else {
5864 err.accumulated_errors +=
5865 "named ideology trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5866 return;
5867 }
5868 context.compiled_trigger.push_back(trigger::payload(itc->second.id).value);
5869 context.add_float_to_payload(parse_float(value, line, err));
5870 } else if(auto itd = context.outer_context.map_of_poptypes.find(str_label);
5871 itd != context.outer_context.map_of_poptypes.end()) {
5873 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_nation | association_to_trigger_code(a)));
5874 else if(context.main_slot == trigger::slot_contents::pop)
5875 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_pop | association_to_trigger_code(a)));
5877 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_province | association_to_trigger_code(a)));
5878 else if(context.main_slot == trigger::slot_contents::state)
5879 context.compiled_trigger.push_back(uint16_t(trigger::variable_pop_type_name_state | association_to_trigger_code(a)));
5880 else {
5881 err.accumulated_errors +=
5882 "named pop type trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5883 return;
5884 }
5885 context.compiled_trigger.push_back(trigger::payload(itd->second).value);
5886 context.add_float_to_payload(parse_float(value, line, err));
5887 } else if(auto ite = context.outer_context.map_of_commodity_names.find(str_label);
5888 ite != context.outer_context.map_of_commodity_names.end()) {
5890 context.compiled_trigger.push_back(uint16_t(trigger::variable_good_name | association_to_trigger_code(a)));
5891 else {
5892 err.accumulated_errors +=
5893 "named commodity trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5894 return;
5895 }
5896 context.compiled_trigger.push_back(trigger::payload(ite->second).value);
5897 context.add_float_to_payload(parse_float(value, line, err));
5898 } else if(auto itg = context.outer_context.map_of_ioptions.find(str_label); itg != context.outer_context.map_of_ioptions.end()) {
5900 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_nation | association_to_trigger_code(a)));
5901 else if(context.main_slot == trigger::slot_contents::pop)
5902 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_pop | association_to_trigger_code(a)));
5904 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_province | association_to_trigger_code(a)));
5905 else if(context.main_slot == trigger::slot_contents::state)
5906 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_name_state | association_to_trigger_code(a)));
5907 else {
5908 err.accumulated_errors +=
5909 "named issue option trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5910 return;
5911 }
5912 context.compiled_trigger.push_back(trigger::payload(itg->second.id).value);
5913 context.add_float_to_payload(parse_float(value, line, err) / 100.0f);
5914 } else if(auto itf = context.outer_context.map_of_iissues.find(str_label); itf != context.outer_context.map_of_iissues.end()) {
5915 if(auto itopt = context.outer_context.map_of_ioptions.find(std::string(value));
5916 itopt != context.outer_context.map_of_ioptions.end()) {
5918 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_nation | association_to_bool_code(a)));
5919 else if(context.main_slot == trigger::slot_contents::pop)
5920 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_pop | association_to_bool_code(a)));
5922 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_province | association_to_bool_code(a)));
5923 else if(context.main_slot == trigger::slot_contents::state)
5924 context.compiled_trigger.push_back(uint16_t(trigger::variable_issue_group_name_state | association_to_bool_code(a)));
5925 else {
5926 err.accumulated_errors +=
5927 "named issue trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5928 return;
5929 }
5930 context.compiled_trigger.push_back(trigger::payload(itf->second).value);
5931 context.compiled_trigger.push_back(trigger::payload(itopt->second.id).value);
5932 } else {
5933 err.accumulated_errors +=
5934 "named issue trigger used with an invalid option name (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5935 return;
5936 }
5937 } else if(auto ith = context.outer_context.map_of_reforms.find(str_label); ith != context.outer_context.map_of_reforms.end()) {
5938 if(auto itopt = context.outer_context.map_of_roptions.find(std::string(value));
5939 itopt != context.outer_context.map_of_roptions.end()) {
5941 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_nation | association_to_bool_code(a)));
5942 else if(context.main_slot == trigger::slot_contents::pop)
5943 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_pop | association_to_bool_code(a)));
5945 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_province | association_to_bool_code(a)));
5946 else if(context.main_slot == trigger::slot_contents::state)
5947 context.compiled_trigger.push_back(uint16_t(trigger::variable_reform_group_name_state | association_to_bool_code(a)));
5948 else {
5949 err.accumulated_errors +=
5950 "named reform trigger used in an invalid context (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5951 return;
5952 }
5953 context.compiled_trigger.push_back(trigger::payload(ith->second).value);
5954 context.compiled_trigger.push_back(trigger::payload(itopt->second.id).value);
5955 } else {
5956 err.accumulated_errors +=
5957 "named reform trigger used with an invalid option name (" + err.file_name + ", line " + std::to_string(line) + ")\n";
5958 return;
5959 }
5960 } else {
5961 err.accumulated_errors +=
5962 "unknown key: " + str_label + " found in trigger(" + err.file_name + ", line " + std::to_string(line) + ")\n";
5963 return;
5964 }
5965 }
5966};
5967
5968void tr_scope_and(token_generator& gen, error_handler& err, trigger_building_context& context);
5969void tr_scope_or(token_generator& gen, error_handler& err, trigger_building_context& context);
5970void tr_scope_not(token_generator& gen, error_handler& err, trigger_building_context& context);
5971void tr_scope_any_neighbor_province(token_generator& gen, error_handler& err, trigger_building_context& context);
5972void tr_scope_any_neighbor_country(token_generator& gen, error_handler& err, trigger_building_context& context);
5973void tr_scope_war_countries(token_generator& gen, error_handler& err, trigger_building_context& context);
5974void tr_scope_all_war_countries(token_generator& gen, error_handler& err, trigger_building_context& context);
5975void tr_scope_any_greater_power(token_generator& gen, error_handler& err, trigger_building_context& context);
5976void tr_scope_any_owned_province(token_generator& gen, error_handler& err, trigger_building_context& context);
5977void tr_scope_any_core(token_generator& gen, error_handler& err, trigger_building_context& context);
5978void tr_scope_all_core(token_generator& gen, error_handler& err, trigger_building_context& context);
5979void tr_scope_any_state(token_generator& gen, error_handler& err, trigger_building_context& context);
5980void tr_scope_any_substate(token_generator& gen, error_handler& err, trigger_building_context& context);
5981void tr_scope_any_sphere_member(token_generator& gen, error_handler& err, trigger_building_context& context);
5982void tr_scope_any_pop(token_generator& gen, error_handler& err, trigger_building_context& context);
5983void tr_scope_owner(token_generator& gen, error_handler& err, trigger_building_context& context);
5984void tr_scope_controller(token_generator& gen, error_handler& err, trigger_building_context& context);
5985void tr_scope_location(token_generator& gen, error_handler& err, trigger_building_context& context);
5986void tr_scope_country(token_generator& gen, error_handler& err, trigger_building_context& context);
5987void tr_capital_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5988void tr_scope_this(token_generator& gen, error_handler& err, trigger_building_context& context);
5989void tr_scope_from(token_generator& gen, error_handler& err, trigger_building_context& context);
5990void tr_scope_sea_zone(token_generator& gen, error_handler& err, trigger_building_context& context);
5991void tr_scope_cultural_union(token_generator& gen, error_handler& err, trigger_building_context& context);
5992void tr_scope_overlord(token_generator& gen, error_handler& err, trigger_building_context& context);
5993void tr_scope_sphere_owner(token_generator& gen, error_handler& err, trigger_building_context& context);
5994void tr_scope_independence(token_generator& gen, error_handler& err, trigger_building_context& context);
5995void tr_flashpoint_tag_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5996void tr_crisis_state_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5997void tr_state_scope(token_generator& gen, error_handler& err, trigger_building_context& context);
5998void tr_scope_variable(std::string_view name, token_generator& gen, error_handler& err, trigger_building_context& context);
5999//extensions
6000void tr_scope_any_country(token_generator& gen, error_handler& err, trigger_building_context& context);
6001void tr_scope_all_state(token_generator& gen, error_handler& err, trigger_building_context& context);
6002void tr_scope_all_substate(token_generator& gen, error_handler& err, trigger_building_context& context);
6003void tr_scope_all_sphere_member(token_generator& gen, error_handler& err, trigger_building_context& context);
6004void tr_scope_all_pop(token_generator& gen, error_handler& err, trigger_building_context& context);
6005void tr_scope_all_greater_power(token_generator& gen, error_handler& err, trigger_building_context& context);
6006void tr_scope_every_country(token_generator& gen, error_handler& err, trigger_building_context& context);
6007
6008void invert_trigger(uint16_t* source);
6009bool scope_is_empty(uint16_t const* source);
6010bool scope_has_single_member(uint16_t const* source);
6011int32_t simplify_trigger(uint16_t* source);
6012dcon::trigger_key make_trigger(token_generator& gen, error_handler& err, trigger_building_context& context);
6013
6015 std::optional<float> factor;
6016 float base = 0.0f;
6017 void months(association_type, float value, error_handler& err, int32_t line, trigger_building_context& context) {
6018 factor = value * 30.0f;
6019 }
6020 void years(association_type, float value, error_handler& err, int32_t line, trigger_building_context& context) {
6021 factor = value * 365.0f;
6022 }
6023 void group(value_modifier_definition const& value, error_handler& err, int32_t line, trigger_building_context& context) { }
6025};
6026
6027void make_value_modifier_segment(token_generator& gen, error_handler& err, trigger_building_context& context);
6028dcon::value_modifier_key make_value_modifier(token_generator& gen, error_handler& err, trigger_building_context& context);
6029
6032};
6033
6035 void main_parameter(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
6036 if(context.compiled_trigger.size() <= 2) {
6037 if(is_fixed_token_ci(value.data(), value.data() + value.size(), "nation") || is_fixed_token_ci(value.data(), value.data() + value.size(), "country")) {
6039 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "state")) {
6041 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "province")) {
6043 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "pop")) {
6045 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "rebel")) {
6047 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "none")) {
6049 } else {
6050 err.accumulated_errors +=
6051 "unknown parameter type " + std::string(value) + " defined for a scripted trigger (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6052 }
6053 } else {
6054 err.accumulated_errors +=
6055 "parameters for a scripted trigger must be given first (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6056 }
6057 }
6058 void this_parameter(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
6059 if(context.compiled_trigger.size() <= 2) {
6060 if(is_fixed_token_ci(value.data(), value.data() + value.size(), "nation") || is_fixed_token_ci(value.data(), value.data() + value.size(), "country")) {
6062 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "state")) {
6064 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "province")) {
6066 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "pop")) {
6068 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "rebel")) {
6070 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "none")) {
6072 } else {
6073 err.accumulated_errors +=
6074 "unknown parameter type " + std::string(value) + " defined for a scripted trigger (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6075 }
6076 } else {
6077 err.accumulated_errors +=
6078 "parameters for a scripted trigger must be given first (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6079 }
6080 }
6081 void from_parameter(association_type a, std::string_view value, error_handler& err, int32_t line, trigger_building_context& context) {
6082 if(context.compiled_trigger.size() <= 2) {
6083 if(is_fixed_token_ci(value.data(), value.data() + value.size(), "nation") || is_fixed_token_ci(value.data(), value.data() + value.size(), "country")) {
6085 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "state")) {
6087 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "province")) {
6089 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "pop")) {
6091 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "rebel")) {
6093 } else if(is_fixed_token_ci(value.data(), value.data() + value.size(), "none")) {
6095 } else {
6096 err.accumulated_errors +=
6097 "unknown parameter type " + std::string(value) + " defined for a scripted trigger (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6098 }
6099 } else {
6100 err.accumulated_errors +=
6101 "parameters for a scripted trigger must be given first (" + err.file_name + ", line " + std::to_string(line) + ")\n";
6102 }
6103 }
6104};
6105
6106void make_stored_trigger(std::string_view tag, token_generator& gen, error_handler& err, scenario_building_context& context);
6107
6108} // 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:8919
dcon::modifier_id get_province_selector_modifier(sys::state &state)
Definition: economy.cpp:8915
uint32_t tag_to_int(char first, char second, char third)
Definition: nations.hpp:11
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 diplo_points(association_type a, float 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 &)
Holds important data about the game world, state, and other data regarding windowing,...