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