20 parse_effect_body(gen, err, context);
35 parse_effect_body(gen, err, context);
50 parse_effect_body(gen, err, context);
66 parse_effect_body(gen, err, context);
83 parse_effect_body(gen, err, context);
106 parse_effect_body(gen, err, context);
126 parse_effect_body(gen, err, context);
169 parse_effect_body(gen, err, context);
186 parse_effect_body(gen, err, context);
202 parse_effect_body(gen, err, context);
225 parse_effect_body(gen, err, context);
247 parse_effect_body(gen, err, context);
287 parse_effect_body(gen, err, context);
304 parse_effect_body(gen, err, context);
321 parse_effect_body(gen, err, context);
344 parse_effect_body(gen, err, context);
361 parse_effect_body(gen, err, context);
384 parse_effect_body(gen, err, context);
401 parse_effect_body(gen, err, context);
426 parse_effect_body(gen, err, context);
445 parse_effect_body(gen, err, context);
475 parse_effect_body(gen, err, context);
505 parse_effect_body(gen, err, context);
535 parse_effect_body(gen, err, context);
565 parse_effect_body(gen, err, context);
587 parse_effect_body(gen, err, context);
608 parse_effect_body(gen, err, context);
633 parse_effect_body(gen, err, context);
651 parse_effect_body(gen, err, context);
680 parse_effect_body(gen, err, context);
705 parse_effect_body(gen, err, context);
729 parse_effect_body(gen, err, context);
754 parse_effect_body(gen, err, context);
784 parse_effect_body(gen, err, context);
805 parse_effect_body(gen, err, context);
823 parse_effect_body(gen, err, context);
848 parse_effect_body(gen, err, context);
873 parse_effect_body(gen, err, context);
900 parse_effect_body(gen, err, context);
927 parse_effect_body(gen, err, context);
958 parse_effect_body(gen, err, context);
990 parse_effect_body(gen, err, context);
1014 parse_effect_body(gen, err, context);
1037 parse_effect_body(gen, err, context);
1060 parse_effect_body(gen, err, context);
1083 parse_effect_body(gen, err, context);
1108 parse_effect_body(gen, err, context);
1133 parse_effect_body(gen, err, context);
1152 parse_effect_body(gen, err, context);
1169 parse_effect_body(gen, err, context);
1197 parse_effect_body(gen, err, context);
1216 auto read_body = parse_effect_body(gen, err, context);
1219 context.
compiled_effect[payload_size_offset + 2] = uint16_t(read_body.chance);
1235 auto read_body = parse_ef_scope_random_by_modifier(gen, err, context);
1238 context.
compiled_effect[payload_size_offset + 2] = uint16_t(read_body.chance_modifier.index());
1239 static_assert(
sizeof(dcon::value_modifier_key::value_base_t) ==
sizeof(uint16_t));
1259 parse_effect_body(gen, err, context);
1278 auto random_set = parse_ef_random_list(gen, err, context);
1281 context.
compiled_effect[payload_size_offset + 1] = uint16_t(std::max(random_set.chances_sum, 1));
1287 std::string str_label{label};
1303 parse_effect_body(gen, err, context);
1323 parse_effect_body(gen, err, context);
1355 parse_effect_body(gen, err, context);
1360 }
else if(
is_integer(label.data(), label.data() + label.length())) {
1377 parse_effect_body(gen, err, context);
1388 }
else if(label.length() == 3) {
1405 parse_effect_body(gen, err, context);
1431 auto sub_units_start = source + 4;
1432 while(sub_units_start < source + source_size) {
1436 if(new_size != old_size) {
1437 assert(new_size < old_size);
1438 std::copy(sub_units_start + old_size, source + source_size, sub_units_start + new_size);
1439 source_size -= (old_size - new_size);
1441 sub_units_start += new_size + 1;
1443 std::copy(sub_units_start + old_size, source + source_size, sub_units_start - 1);
1444 source_size -= (1 + old_size);
1449 while(sub_units_start < source + source_size) {
1459 while(sub_units_start + old_size < source + source_size
1465 static const uint16_t fop_table[] = {
1466 effect::clr_global_flag,
1467 effect::fop_clr_global_flag_2,
1468 effect::fop_clr_global_flag_3,
1469 effect::fop_clr_global_flag_4,
1470 effect::fop_clr_global_flag_5,
1471 effect::fop_clr_global_flag_6,
1472 effect::fop_clr_global_flag_7,
1473 effect::fop_clr_global_flag_8,
1474 effect::fop_clr_global_flag_9,
1475 effect::fop_clr_global_flag_10,
1476 effect::fop_clr_global_flag_11,
1477 effect::fop_clr_global_flag_12
1479 sub_units_start[0] = fop_table[repeats];
1481 for(
auto i = 1; i <= repeats + 1; i++) {
1487 if(new_size != old_size) {
1488 assert(new_size < old_size);
1489 std::copy(sub_units_start + old_size, source + source_size, sub_units_start + new_size);
1490 source_size -= (old_size - new_size);
1492 sub_units_start += new_size;
1496 source[1] = uint16_t(source_size - 1);
1499 std::copy(source + 3, source + source_size, source + 2);
1502 source[1] = uint16_t(source_size - 1);
1506 if(source_size == 2) {
1509 std::copy(source + 2, source + source_size, source);
1515 bool can_elim =
true;
1517 while(sub_units_start < source + source_size && can_elim) {
1519 case effect::clr_global_flag:
1520 case effect::set_global_flag:
1521 case effect::fop_clr_global_flag_2:
1522 case effect::fop_clr_global_flag_3:
1523 case effect::fop_clr_global_flag_4:
1524 case effect::fop_clr_global_flag_5:
1525 case effect::fop_clr_global_flag_6:
1526 case effect::fop_clr_global_flag_7:
1527 case effect::fop_clr_global_flag_8:
1528 case effect::fop_clr_global_flag_9:
1529 case effect::fop_clr_global_flag_10:
1530 case effect::fop_clr_global_flag_11:
1531 case effect::fop_clr_global_flag_12:
1532 case effect::fop_change_province_name:
1542 std::copy(source + 2, source + source_size, source);
1552 if(sub_units_start[0] == effect::change_province_name) {
1553 auto const prov = source[2];
1554 auto const name_1 = sub_units_start[1];
1555 auto const name_2 = sub_units_start[2];
1556 source[0] = effect::fop_change_province_name;
1561 assert(new_size < old_size);
1562 std::copy(source + old_size, source + source_size, source + new_size);
1563 source_size -= (old_size - new_size);
1580 auto sub_units_start = source + 4;
1581 while(sub_units_start < source + source_size) {
1589 while(sub_units_start < source + source_size) {
1600 if(context.
compiled_effect.size() >= std::numeric_limits<uint16_t>::max()) {
1602 " cells big, which exceeds 64 KB bytecode limit (" + err.
file_name +
")\n";
1603 return dcon::effect_key{0};
1617 id_ = it->second.id;
1620 it->second.id =
id_;
1623 it->second.from_slot = context.
this_slot;
1624 it->second.just_in_case_placeholder =
false;
1637 id_ = it->second.id;
1640 it->second.id =
id_;
1643 it->second.from_slot = context.
this_slot;
1644 it->second.just_in_case_placeholder =
false;
1657 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_nation));
1659 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_province));
1661 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_state));
1663 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_this_pop));
1666 "country_event effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1675 it->second.id = ev_id;
1678 it->second.from_slot = context.
this_slot;
1679 it->second.just_in_case_placeholder =
false;
1690 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_nation));
1692 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_province));
1694 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_state));
1696 context.
compiled_effect.push_back(uint16_t(effect::country_event_immediate_province_this_pop));
1699 "country_event effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1708 it->second.id = ev_id;
1711 it->second.from_slot = context.
this_slot;
1712 it->second.just_in_case_placeholder =
false;
1723 "country_event effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1732 context.
compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_nation));
1734 context.
compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_province));
1736 context.
compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_state));
1738 context.
compiled_effect.push_back(uint16_t(effect::province_event_immediate_this_pop));
1741 "province_event effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1750 it->second.id = ev_id;
1753 it->second.from_slot = context.
this_slot;
1754 it->second.just_in_case_placeholder =
false;
1765 "province_event effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1774 "define_general effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1787 err.
accumulated_errors +=
"kill_leader effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1795 "define_admiral effect used in an incorrect scope type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1806 context.
compiled_effect.push_back(uint16_t(effect::change_province_name));
1817 context.
compiled_effect.push_back(uint16_t(effect::change_region_name_state));
1819 context.
compiled_effect.push_back(uint16_t(effect::change_region_name_province));
1834 "canal index " + std::to_string(value) +
" out of range (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1838 std::string str_label{ label };
1846 context.
compiled_effect.push_back(effect::variable_good_name_province);
1851 std::to_string(line) +
")\n";
1864 ", line " + std::to_string(line) +
")\n";
1870 context.
compiled_effect.push_back(effect::variable_invention_name_yes);
1872 context.
compiled_effect.push_back(effect::variable_invention_name_no);
1877 std::to_string(line) +
")\n";
1885 context.
compiled_effect.push_back(uint16_t(effect::political_reform));
1891 err.
accumulated_errors +=
"named issue effect used with a party issue (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1895 err.
accumulated_errors +=
"named issue effect used in an invalid context (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1899 err.
accumulated_errors +=
"named issue effect used with an invalid option name (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1914 err.
accumulated_errors +=
"named reform effect used with an invalid issue type (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1918 err.
accumulated_errors +=
"named reform effect used in an invalid context (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1922 err.
accumulated_errors +=
"named reform effect used with an invalid option name (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1927 "unknown effect " + str_label +
" encountered (" + err.
file_name +
", line " + std::to_string(line) +
")\n";
1934 opt_ = it->second.id;
1936 err.
accumulated_errors +=
"Invalid issue position " + std::string(v) +
" (" + err.
file_name +
" line " + std::to_string(line) +
")\n";
std::string accumulated_errors
#define assert(condition)
constexpr uint16_t x_state_scope
constexpr uint16_t x_greater_power_scope
constexpr uint16_t rich_strata_scope_nation
constexpr uint16_t pop_type_scope_nation
constexpr uint16_t this_bounce_scope
bool effect_scope_has_single_member(uint16_t const *source)
constexpr uint16_t region_proper_scope
constexpr uint16_t crisis_state_scope
constexpr uint16_t x_neighbor_country_scope
constexpr uint16_t region_scope
constexpr uint16_t x_decision_country_scope_nation
int32_t get_effect_non_scope_payload_size(uint16_t const *data)
constexpr int8_t data_sizes[]
constexpr uint16_t x_pop_scope_province
constexpr uint16_t country_scope_pop
constexpr uint16_t this_scope_province
constexpr uint16_t owner_scope_province
constexpr uint16_t country_scope_state
constexpr uint16_t capital_scope_province
constexpr uint16_t is_random_scope
constexpr uint16_t this_scope_pop
constexpr uint16_t x_country_scope_nation
constexpr uint16_t if_scope
int32_t get_effect_scope_payload_size(uint16_t const *data)
constexpr uint16_t owner_scope_state
constexpr uint16_t state_scope_province
constexpr uint16_t poor_strata_scope_state
constexpr uint16_t state_scope_pop
constexpr uint16_t x_empty_neighbor_province_scope
int32_t effect_scope_data_payload(uint16_t code)
constexpr uint16_t from_scope_nation
constexpr uint16_t code_mask
constexpr uint16_t location_scope
constexpr uint16_t capital_scope
constexpr uint16_t generic_scope
constexpr uint16_t this_scope_nation
constexpr uint16_t tag_scope
EFFECT_BYTECODE_LIST constexpr uint16_t first_scope_code
constexpr uint16_t controller_scope
constexpr uint16_t cultural_union_scope
constexpr uint16_t sea_zone_scope
constexpr uint16_t random_scope
constexpr uint16_t independence_scope
constexpr uint16_t x_core_scope
constexpr uint16_t random_by_modifier_scope
constexpr uint16_t middle_strata_scope_state
constexpr uint16_t this_scope_state
constexpr uint16_t x_core_scope_province
constexpr uint16_t x_neighbor_province_scope
constexpr uint16_t from_scope_state
constexpr uint16_t else_if_scope
constexpr uint16_t x_event_country_scope
constexpr uint16_t rich_strata_scope_state
constexpr uint16_t x_country_scope
constexpr uint16_t from_scope_province
constexpr uint16_t poor_strata_scope_nation
int32_t get_generic_effect_payload_size(uint16_t const *data)
constexpr uint16_t x_substate_scope
constexpr uint16_t rich_strata_scope_province
constexpr uint16_t random_list_scope
constexpr uint16_t x_empty_neighbor_province_scope_nation
constexpr uint16_t pop_type_scope_province
constexpr uint16_t first_invalid_code
constexpr uint16_t poor_strata_scope_province
constexpr uint16_t scope_has_limit
constexpr uint16_t flashpoint_tag_scope
constexpr uint16_t x_owned_scope_nation
constexpr uint16_t x_decision_country_scope
constexpr uint16_t overlord_scope
constexpr uint16_t sphere_owner_scope
constexpr uint16_t x_owned_scope_state
constexpr uint16_t x_event_country_scope_nation
constexpr uint16_t integer_scope
constexpr uint16_t pop_type_scope_state
constexpr uint16_t middle_strata_scope_province
constexpr uint16_t x_pop_scope_state
constexpr uint16_t x_pop_scope_nation
constexpr uint16_t from_scope_pop
constexpr uint16_t from_bounce_scope
constexpr uint16_t middle_strata_scope_nation
constexpr uint16_t x_neighbor_province_scope_nation
uint32_t tag_to_int(char first, char second, char third)
void ef_scope_random_owned(token_generator &gen, error_handler &err, effect_building_context &context)
bool is_integer(char const *start, char const *end)
void ef_scope_any_defined_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_location(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_all_core(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_hidden_tooltip(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_sphere_owner(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::trigger_key make_trigger(token_generator &gen, error_handler &err, trigger_building_context &context)
void ef_scope_random_state(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_owner(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_cultural_union(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_greater_power(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_list(token_generator &gen, error_handler &err, effect_building_context &context)
int32_t simplify_effect(uint16_t *source)
void ef_scope_from_bounce(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_else_if(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_this_bounce(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_middle_strata(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_state(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_empty_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_crisis_state_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_controller(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_country(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::value_modifier_key make_value_modifier(token_generator &gen, error_handler &err, trigger_building_context &context)
void ef_scope_overlord(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_capital_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_state_scope(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_rich_strata(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_owned(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_empty_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_substate(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_random_by_modifier(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_existing_country_except_scoped(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_independence(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_from(token_generator &gen, error_handler &err, effect_building_context &context)
int32_t parse_int(std::string_view content, int32_t line, error_handler &err)
dcon::trigger_key ef_limit(token_generator &gen, error_handler &err, effect_building_context &context)
bool parse_bool(std::string_view content, int32_t, error_handler &)
dcon::effect_key make_effect(token_generator &gen, error_handler &err, effect_building_context &context)
int32_t add_to_random_list(std::string_view label, token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_neighbor_province(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_poor_strata(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::value_modifier_key read_chance_modifier(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_flashpoint_tag_scope(token_generator &gen, error_handler &err, effect_building_context &context)
float parse_float(std::string_view content, int32_t line, error_handler &err)
void ef_scope_variable(std::string_view label, token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random(token_generator &gen, error_handler &err, effect_building_context &context)
std::string slot_contents_to_string(trigger::slot_contents v)
void ef_scope_random_greater_power(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_neighbor_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_sea_zone(token_generator &gen, error_handler &err, effect_building_context &context)
void recurse_over_effects(uint16_t *source, T const &f)
void ef_scope_any_neighbor_country(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_if(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_random_pop(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_this(token_generator &gen, error_handler &err, effect_building_context &context)
void ef_scope_any_pop(token_generator &gen, error_handler &err, effect_building_context &context)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
dcon::issue_option_id opt_
void position(association_type t, std::string_view v, error_handler &err, int32_t line, effect_building_context &context)
dcon::national_event_id id_
void id(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void id(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
dcon::provincial_event_id id_
void define_general(ef_define_general const &value, error_handler &err, int32_t line, effect_building_context &context)
void any_value(std::string_view label, association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void change_province_name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void country_event(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void define_admiral(ef_define_admiral const &value, error_handler &err, int32_t line, effect_building_context &context)
void enable_canal(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void province_event(association_type t, int32_t value, error_handler &err, int32_t line, effect_building_context &context)
void kill_leader(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
void change_region_name(association_type t, std::string_view value, error_handler &err, int32_t line, effect_building_context &context)
trigger::slot_contents this_slot
scenario_building_context & outer_context
void add_int32_t_to_payload(int32_t i)
std::vector< uint16_t > compiled_effect
trigger::slot_contents from_slot
trigger::slot_contents main_slot
void add_float_to_payload(float f)
ankerl::unordered_dense::map< std::string, dcon::state_definition_id > map_of_state_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< int32_t, pending_nat_event > map_of_national_events
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_option_content > map_of_ioptions
ankerl::unordered_dense::map< int32_t, pending_prov_event > map_of_provincial_events
ankerl::unordered_dense::map< std::string, dcon::region_id > map_of_region_names
ankerl::unordered_dense::map< uint32_t, dcon::national_identity_id > map_of_ident_names
ankerl::unordered_dense::map< std::string, dcon::commodity_id > map_of_commodity_names
std::vector< dcon::province_adjacency_id > canals
dcon::data_container world
dcon::effect_key commit_effect_data(std::vector< uint16_t > data)
dcon::unit_name_id add_unit_name(std::string_view text)
province::global_provincial_state province_definitions