43 if(!state.current_scene.game_in_progress)
45 state.network_state.is_new_game =
false;
49 switch(state.network_mode) {
52 bool b = state.incoming_commands.try_push(p);
60 state.network_state.outgoing_commands.push(p);
80 if(state.world.province_get_nation_from_province_ownership(location) != source)
83 if(state.world.province_get_is_coast(location))
84 state.world.province_set_naval_rally_point(location, enable);
86 state.world.province_set_land_rally_point(location, enable);
108 dcon::national_focus_id focus) {
110 memset(&p, 0,
sizeof(
payload));
119 dcon::national_focus_id focus) {
125 auto state_owner = state.world.state_instance_get_nation_from_state_ownership(target_state);
127 if(state_owner == source) {
128 if(focus == state.national_definitions.flashpoint_focus)
130 if(
auto ideo = state.world.national_focus_get_ideology(focus); ideo) {
131 if(state.world.ideology_get_enabled(ideo) ==
false ||
132 (state.world.ideology_get_is_civilized_only(ideo) && !state.world.nation_get_is_civilized(source))) {
136 auto prov = state.world.state_instance_get_capital(target_state);
137 auto k = state.world.national_focus_get_limit(focus);
140 return num_focuses_set < num_focuses_total || bool(state.world.state_instance_get_owner_focus(target_state));
142 auto pc = state.world.nation_get_primary_culture(source);
146 auto ident = state.world.nation_get_identity_from_identity_holder(source);
147 if(state.world.national_identity_get_is_not_releasable(
ident))
150 bool state_contains_core =
false;
152 state_contains_core = state_contains_core || bool(state.world.get_core_by_prov_tag_key(p,
ident));
154 bool rank_high = state.world.nation_get_rank(source) > uint16_t(state.defines.colonial_rank);
155 bool is_tension_focus = focus == state.national_definitions.flashpoint_focus;
156 return state_contains_core && rank_high && is_tension_focus &&
157 (num_focuses_set < num_focuses_total || bool(state.world.nation_get_state_from_flashpoint_focus(source))) &&
158 bool(state.world.state_instance_get_nation_from_flashpoint_focus(target_state)) ==
false;
164 if(state.world.state_instance_get_nation_from_state_ownership(target_state) == source) {
165 state.world.state_instance_set_owner_focus(target_state, focus);
168 state.world.nation_set_state_from_flashpoint_focus(source, target_state);
170 state.world.nation_set_state_from_flashpoint_focus(source, dcon::state_instance_id{});
176 memset(&p, 0,
sizeof(
payload));
189 if(state.world.nation_get_active_technologies(source, tech))
193 if(!state.world.nation_get_is_civilized(source))
195 if(state.current_date.to_ymd(state.start_date).year >= state.world.technology_get_year(tech)) {
197 dcon::technology_id prev_tech = dcon::technology_id(dcon::technology_id::value_base_t(tech.index() - 1));
199 if(tech.index() != 0 && state.world.technology_get_folder_index(prev_tech) == state.world.technology_get_folder_index(tech)) {
201 return state.world.nation_get_active_technologies(source, prev_tech);
209 if(state.world.nation_get_current_research(source))
210 state.world.nation_set_research_points(source, 0.0f);
211 state.world.nation_set_current_research(source, tech);
216 memset(&p, 0,
sizeof(
payload));
223 return state.world.nation_get_leadership_points(source) >= state.defines.leader_recruit_cost;
232 memset(&p, 0,
sizeof(
payload));
245 if(!state.world.nation_get_is_at_war(target))
247 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, source);
248 if(rel && state.world.unilateral_relationship_get_war_subsidies(rel))
251 if(state.world.nation_get_is_player_controlled(source))
252 return state.world.nation_get_diplomatic_points(source) >= state.defines.warsubsidy_diplomatic_cost;
257 state.world.nation_get_diplomatic_points(source) -= state.defines.warsubsidy_diplomatic_cost;
258 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, source);
260 rel = state.world.force_create_unilateral_relationship(target, source);
262 state.world.unilateral_relationship_set_war_subsidies(rel,
true);
268 "msg_wsub_start_title",
269 source, target, dcon::nation_id{},
277 memset(&p, 0,
sizeof(
payload));
290 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, source);
291 if(rel && !state.world.unilateral_relationship_get_war_subsidies(rel))
293 if(state.world.nation_get_is_player_controlled(source))
294 return state.world.nation_get_diplomatic_points(source) >= state.defines.cancelwarsubsidy_diplomatic_cost;
299 state.world.nation_get_diplomatic_points(source) -= state.defines.cancelwarsubsidy_diplomatic_cost;
300 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, source);
302 state.world.unilateral_relationship_set_war_subsidies(rel,
false);
304 if(source != state.local_player_nation) {
309 "msg_wsub_end_title",
310 source, target, dcon::nation_id{},
319 memset(&p, 0,
sizeof(
payload));
335 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(source, target);
336 if(state.world.diplomatic_relation_get_value(rel) >= 200.f)
339 if(state.world.nation_get_is_player_controlled(source))
340 return state.world.nation_get_diplomatic_points(source) >= state.defines.increaserelation_diplomatic_cost;
345 state.world.nation_get_diplomatic_points(source) -= state.defines.increaserelation_diplomatic_cost;
352 source, target, dcon::nation_id{},
359 memset(&p, 0,
sizeof(
payload));
372 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(source, target);
373 if(rel && state.world.diplomatic_relation_get_value(rel) <= -200.f)
375 if(state.world.nation_get_is_player_controlled(source))
376 return state.world.nation_get_diplomatic_points(source) >= state.defines.decreaserelation_diplomatic_cost;
381 state.world.nation_get_diplomatic_points(source) -= state.defines.decreaserelation_diplomatic_cost;
388 source, target, dcon::nation_id{},
395 memset(&p, 0,
sizeof(
payload));
420 auto si = state.world.province_get_state_membership(p);
422 si.set_naval_base_is_taken(
true);
427 auto& base_cost = state.economy_definitions.building_definitions[int32_t(type)].cost;
429 if(base_cost.commodity_type[j]) {
430 amount += base_cost.commodity_amounts[j] * state.world.commodity_get_cost(base_cost.commodity_type[j]);
438 auto new_rr = fatten(state.world, state.world.force_create_province_building_construction(p, source));
439 new_rr.set_is_pop_project(
false);
440 new_rr.set_type(
uint8_t(type));
446 memset(&p, 0,
sizeof(
payload));
454 auto owner = state.world.state_instance_get_nation_from_state_ownership(location);
455 for(
auto c : state.world.state_instance_get_state_building_construction(location)) {
456 if(c.get_type() == type) {
457 if(c.get_is_pop_project())
459 if(c.get_nation() != source)
467 auto owner = state.world.state_instance_get_nation_from_state_ownership(location);
468 for(
auto c : state.world.state_instance_get_state_building_construction(location)) {
469 if(c.get_type() == type) {
470 if(c.get_is_pop_project())
472 if(c.get_nation() != source)
475 state.world.delete_state_building_construction(c);
482 memset(&p, 0,
sizeof(
payload));
493 auto owner = state.world.state_instance_get_nation_from_state_ownership(location);
500 if(state.world.nation_get_active_building(source, type) ==
false && !state.world.factory_type_get_is_available_from_start(type))
502 if(state.world.province_get_is_colonial(state.world.state_instance_get_capital(location)))
508 bool has_dup =
false;
514 auto d = state.world.state_instance_get_definition(location);
515 for(
auto p : state.world.state_definition_get_abstract_state_membership(d))
516 if(p.get_province().get_nation_from_province_ownership() == owner)
517 for(
auto f : p.get_province().get_factory_location())
518 if(f.get_factory().get_building_type() == type)
522 if(state.world.nation_get_is_civilized(source) ==
false)
525 if(owner != source) {
531 if(state.world.nation_get_is_great_power(source) ==
false || state.world.nation_get_is_great_power(owner) ==
true)
533 if(state.world.nation_get_is_civilized(owner) ==
false)
536 auto rules = state.world.nation_get_combined_issue_rules(owner);
547 auto rules = state.world.nation_get_combined_issue_rules(owner);
559 for(
auto p : state.world.state_instance_get_state_building_construction(location)) {
560 if(p.get_type() == type)
566 auto d = state.world.state_instance_get_definition(location);
567 for(
auto p : state.world.state_definition_get_abstract_state_membership(d)) {
568 if(p.get_province().get_nation_from_province_ownership() == owner) {
569 for(
auto f : p.get_province().get_factory_location()) {
570 if(f.get_factory().get_building_type() == type && f.get_factory().get_level() <
uint8_t(255)) {
579 if(state.world.factory_type_get_is_coastal(type)) {
585 return num_factories < int32_t(state.defines.factories_per_state);
590 auto new_up = fatten(state.world, state.world.force_create_state_building_construction(location, source));
591 new_up.set_is_pop_project(
false);
592 new_up.set_is_upgrade(is_upgrade);
593 new_up.set_type(type);
595 if(source != state.world.state_instance_get_nation_from_state_ownership(location)) {
597 auto& base_cost = state.world.factory_type_get_construction_costs(type);
599 if(base_cost.commodity_type[j]) {
600 amount += base_cost.commodity_amounts[j] * state.world.commodity_get_cost(base_cost.commodity_type[j]);
611 memset(&p, 0,
sizeof(
payload));
626 if(state.world.province_get_nation_from_province_ownership(location) != source)
628 if(state.world.province_get_nation_from_province_control(location) != source)
630 if(state.world.nation_get_active_unit(source, type) ==
false &&
631 state.military_definitions.unit_base_definitions[type].active ==
false)
633 auto disarm = state.world.nation_get_disarmed_until(source);
634 if(disarm && state.current_date < disarm)
637 if(state.military_definitions.unit_base_definitions[type].is_land) {
646 if(!state.world.province_get_is_coast(location))
649 auto overseas_allowed = state.military_definitions.unit_base_definitions[type].can_build_overseas;
650 auto level_req = state.military_definitions.unit_base_definitions[type].min_port_level;
663 auto c = fatten(state.world, state.world.try_create_province_naval_construction(location, source));
665 c.set_template_province(template_province);
668void start_land_unit_construction(
sys::state& state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province) {
670 memset(&p, 0,
sizeof(
payload));
685 if(state.world.province_get_nation_from_province_ownership(location) != source)
687 if(state.world.province_get_nation_from_province_control(location) != source)
689 if(state.world.nation_get_active_unit(source, type) ==
false &&
690 state.military_definitions.unit_base_definitions[type].active ==
false)
692 if(state.military_definitions.unit_base_definitions[type].primary_culture && soldier_culture != state.world.nation_get_primary_culture(source) && state.world.nation_get_accepted_cultures(source, soldier_culture) ==
false) {
695 auto disarm = state.world.nation_get_disarmed_until(source);
696 if(disarm && state.current_date < disarm)
699 if(state.military_definitions.unit_base_definitions[type].is_land) {
705 return bool(soldier);
713 auto c = fatten(state.world, state.world.try_create_province_land_construction(soldier, source));
715 c.set_template_province(template_province);
720 memset(&p, 0,
sizeof(
payload));
729 return state.world.province_get_nation_from_province_ownership(location) == source;
733 dcon::province_naval_construction_id c;
734 for(
auto lc : state.world.province_get_province_naval_construction(location)) {
735 if(lc.get_type() == type) {
739 state.world.delete_province_naval_construction(c);
744 memset(&p, 0,
sizeof(
payload));
753 return state.world.province_get_nation_from_province_ownership(location) == source;
756 dcon::province_land_construction_id c;
757 for(
auto pop : state.world.province_get_pop_location(location)) {
758 for(
auto lc : pop.get_pop().get_province_land_construction()) {
759 if(lc.get_type() == type) {
764 state.world.delete_province_land_construction(c);
769 memset(&p, 0,
sizeof(
payload));
777 auto loc = state.world.factory_get_province_from_factory_location(f);
778 if(state.world.province_get_nation_from_province_ownership(loc) != source)
780 auto rules = state.world.nation_get_combined_issue_rules(source);
786 if(state.world.province_get_nation_from_province_ownership(location) != source)
789 auto rules = state.world.nation_get_combined_issue_rules(source);
793 for(
auto sc : state.world.state_instance_get_state_building_construction(state.world.province_get_state_membership(location))) {
794 if(sc.get_type() == type) {
795 state.world.delete_state_building_construction(sc);
800 for(
auto f : state.world.province_get_factory_location(location)) {
801 if(f.get_factory().get_building_type() == type) {
802 state.world.delete_factory(f.get_factory());
810 memset(&p, 0,
sizeof(
payload));
820 auto loc = state.world.factory_get_province_from_factory_location(f);
821 if(state.world.province_get_nation_from_province_ownership(loc) != source)
824 auto rules = state.world.nation_get_combined_issue_rules(source);
830 if(current_priority != priority) {
843 if(state.world.province_get_nation_from_province_ownership(location) != source)
846 auto rules = state.world.nation_get_combined_issue_rules(source);
852 for(
auto f : state.world.province_get_factory_location(location)) {
853 if(f.get_factory().get_building_type() == type) {
855 if(current_priority != priority) {
860 if(subsidized && !f.get_factory().get_subsidized()) {
861 auto& scale = f.get_factory().get_production_scale();
862 scale = std::max(scale, 0.5f);
864 f.get_factory().set_subsidized(subsidized);
872 memset(&p, 0,
sizeof(
payload));
883 auto holder = state.world.national_identity_get_nation_from_identity_holder(t);
884 state.world.force_create_overlord(holder, source);
885 if(state.world.nation_get_is_great_power(source)) {
886 auto sr = state.world.force_create_gp_relationship(holder, source);
887 auto& flags = state.world.gp_relationship_get_status(sr);
889 state.world.nation_set_in_sphere_of(holder, source);
892 auto& inf = state.world.nation_get_infamy(source);
893 inf = std::max(0.0f, inf + state.defines.release_nation_infamy);
899 memset(&p, 0,
sizeof(
payload));
910 auto holder = state.world.national_identity_get_nation_from_identity_holder(t);
913 if(state.world.nation_get_is_player_controlled(source)) {
915 }
else if(state.world.nation_get_is_player_controlled(holder)) {
919 auto old_controller = state.world.nation_get_is_player_controlled(holder);
920 state.world.nation_set_is_player_controlled(holder, state.world.nation_get_is_player_controlled(source));
921 state.world.nation_set_is_player_controlled(source, old_controller);
923 if(state.world.nation_get_is_player_controlled(holder))
925 if(state.world.nation_get_is_player_controlled(source))
928 if(state.local_player_nation == source) {
929 state.local_player_nation = holder;
930 }
else if(state.local_player_nation == holder) {
931 state.local_player_nation = source;
935 for(
auto p : state.world.nation_get_province_ownership(holder)) {
936 auto pid = p.get_province();
937 state.world.province_set_is_colonial(pid,
false);
947 memset(&p, 0,
sizeof(
payload));
955 state.world.nation_set_administrative_spending(source, std::clamp(values.
administrative_spending, int8_t(0), int8_t(100)));
958 state.world.nation_set_construction_spending(source, std::clamp(values.
construction_spending, int8_t(0), int8_t(100)));
961 state.world.nation_set_education_spending(source, std::clamp(values.
education_spending, int8_t(0), int8_t(100)));
964 state.world.nation_set_land_spending(source, std::clamp(values.
land_spending, int8_t(0), int8_t(100)));
967 state.world.nation_set_middle_tax(source, std::clamp(values.
middle_tax, int8_t(0), int8_t(100)));
969 if(values.
poor_tax != int8_t(-127)) {
970 state.world.nation_set_poor_tax(source, std::clamp(values.
poor_tax, int8_t(0), int8_t(100)));
972 if(values.
rich_tax != int8_t(-127)) {
973 state.world.nation_set_rich_tax(source, std::clamp(values.
rich_tax, int8_t(0), int8_t(100)));
976 state.world.nation_set_military_spending(source, std::clamp(values.
military_spending, int8_t(0), int8_t(100)));
979 state.world.nation_set_naval_spending(source, std::clamp(values.
naval_spending, int8_t(0), int8_t(100)));
982 state.world.nation_set_social_spending(source, std::clamp(values.
social_spending, int8_t(0), int8_t(100)));
984 if(values.
tariffs != int8_t(-127)) {
985 state.world.nation_set_tariffs(source, std::clamp(values.
tariffs, int8_t(-100), int8_t(100)));
988 state.world.nation_set_domestic_investment_spending(source, std::clamp(values.
domestic_investment, int8_t(0), int8_t(100)));
990 if(values.
overseas != int8_t(-127)) {
991 state.world.nation_set_overseas_spending(source, std::clamp(values.
overseas, int8_t(0), int8_t(100)));
998 memset(&p, 0,
sizeof(
payload));
1004 auto type = state.world.nation_get_government_type(source);
1013 memset(&p, 0,
sizeof(
payload));
1022 return state.world.nation_get_is_great_power(source) && !state.world.nation_get_is_great_power(influence_target);
1025 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1027 rel = state.world.force_create_gp_relationship(influence_target, source);
1029 auto& flags = state.world.gp_relationship_get_status(rel);
1050 memset(&p, 0,
sizeof(
payload));
1065 if(!state.world.nation_get_is_great_power(source) || !state.world.nation_get_is_great_power(affected_gp) ||
1066 state.world.nation_get_is_great_power(influence_target))
1069 if(source == affected_gp)
1072 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1076 if(state.world.gp_relationship_get_influence(rel) < state.defines.discredit_influence_cost)
1089 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, affected_gp);
1102 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1103 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, affected_gp);
1105 orel = state.world.force_create_gp_relationship(influence_target, affected_gp);
1107 state.world.gp_relationship_get_influence(rel) -= state.defines.discredit_influence_cost;
1110 state.world.gp_relationship_set_penalty_expires_date(orel, state.current_date + int32_t(state.defines.discredit_days));
1113 [source, influence_target, affected_gp, enddate = state.current_date + int32_t(state.defines.discredit_days)](
sys::state& state,
text::layout_base& contents) {
1117 "msg_discredit_title",
1118 source, affected_gp, influence_target,
1125 memset(&p, 0,
sizeof(
payload));
1139 if(!state.world.nation_get_is_great_power(source) || !state.world.nation_get_is_great_power(affected_gp) ||
1140 state.world.nation_get_is_great_power(influence_target))
1143 if(source == affected_gp)
1146 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1150 if(state.world.gp_relationship_get_influence(rel) < state.defines.expeladvisors_influence_cost)
1172 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1173 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, affected_gp);
1175 state.world.gp_relationship_get_influence(rel) -= state.defines.expeladvisors_influence_cost;
1179 state.world.gp_relationship_set_influence(orel, 0.0f);
1180 state.world.gp_relationship_get_status(orel) &=
~nations::influence::is_discredited;
1188 source, affected_gp, influence_target,
1193void ban_embassy(
sys::state& state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp) {
1195 memset(&p, 0,
sizeof(
payload));
1210 if(!state.world.nation_get_is_great_power(source) || !state.world.nation_get_is_great_power(affected_gp) ||
1211 state.world.nation_get_is_great_power(influence_target))
1214 if(source == affected_gp)
1217 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1221 if(state.world.gp_relationship_get_influence(rel) < state.defines.banembassy_influence_cost)
1243 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1244 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, affected_gp);
1246 orel = state.world.force_create_gp_relationship(influence_target, affected_gp);
1248 state.world.gp_relationship_get_influence(rel) -= state.defines.banembassy_influence_cost;
1251 state.world.gp_relationship_set_influence(orel, 0.0f);
1252 state.world.gp_relationship_set_penalty_expires_date(orel, state.current_date + int32_t(state.defines.banembassy_days));
1255 [source, influence_target, affected_gp, enddate = state.current_date + int32_t(state.defines.banembassy_days)](
sys::state& state,
text::layout_base& contents) {
1260 source, affected_gp, influence_target,
1267 memset(&p, 0,
sizeof(
payload));
1279 if(!state.world.nation_get_is_great_power(source) || state.world.nation_get_is_great_power(influence_target))
1282 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1286 if(state.world.gp_relationship_get_influence(rel) < state.defines.increaseopinion_influence_cost)
1306 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1308 state.world.gp_relationship_get_influence(rel) -= state.defines.increaseopinion_influence_cost;
1309 auto& l = state.world.gp_relationship_get_status(rel);
1317 source, influence_target, dcon::nation_id{},
1324 memset(&p, 0,
sizeof(
payload));
1340 if(!state.world.nation_get_is_great_power(source) || !state.world.nation_get_is_great_power(affected_gp) ||
1341 state.world.nation_get_is_great_power(influence_target))
1344 if(source == affected_gp)
1347 if(state.world.nation_get_in_sphere_of(influence_target) == affected_gp)
1350 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1354 if(state.world.gp_relationship_get_influence(rel) < state.defines.decreaseopinion_influence_cost)
1368 state.world.gp_relationship_get_status(state.world.get_gp_relationship_by_gp_influence_pair(influence_target,
1381 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1382 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, affected_gp);
1384 orel = state.world.force_create_gp_relationship(influence_target, affected_gp);
1386 state.world.gp_relationship_get_influence(rel) -= state.defines.decreaseopinion_influence_cost;
1389 auto& l = state.world.gp_relationship_get_status(orel);
1397 source, affected_gp, influence_target,
1404 memset(&p, 0,
sizeof(
payload));
1417 if(!state.world.nation_get_is_great_power(source) || state.world.nation_get_is_great_power(influence_target))
1420 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1424 if(state.world.gp_relationship_get_influence(rel) < state.defines.addtosphere_influence_cost)
1437 if(state.world.nation_get_in_sphere_of(influence_target))
1443 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1445 state.world.gp_relationship_get_influence(rel) -= state.defines.addtosphere_influence_cost;
1446 auto& l = state.world.gp_relationship_get_status(rel);
1449 state.world.nation_set_in_sphere_of(influence_target, source);
1455 "msg_add_sphere_title",
1456 source, influence_target, dcon::nation_id{},
1463 memset(&p, 0,
sizeof(
payload));
1477 if(!state.world.nation_get_is_great_power(source) || !state.world.nation_get_is_great_power(affected_gp) ||
1478 state.world.nation_get_is_great_power(influence_target))
1481 if(state.world.nation_get_in_sphere_of(influence_target) != affected_gp)
1484 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1488 if(source != affected_gp && state.world.gp_relationship_get_influence(rel) < state.defines.removefromsphere_influence_cost)
1510 auto rel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, source);
1512 state.world.nation_set_in_sphere_of(influence_target, dcon::nation_id{});
1514 auto orel = state.world.get_gp_relationship_by_gp_influence_pair(influence_target, affected_gp);
1515 auto& l = state.world.gp_relationship_get_status(orel);
1518 if(source != affected_gp) {
1519 state.world.gp_relationship_get_influence(rel) -= state.defines.removefromsphere_influence_cost;
1522 state.world.nation_get_infamy(source) += state.defines.removefromsphere_infamy_cost;
1528 if(source == affected_gp)
1533 "msg_rem_sphere_title",
1534 source, affected_gp, influence_target,
1541 memset(&p, 0,
sizeof(
payload));
1556 memset(&p, 0,
sizeof(
payload));
1563 auto state_def = state.world.province_get_state_from_abstract_state_membership(p);
1570 auto state_def = state.world.province_get_state_from_abstract_state_membership(pr);
1574 bool adjacent = [&]() {
1575 for(
auto p : state.world.state_definition_get_abstract_state_membership(state_def)) {
1576 if(!p.get_province().get_nation_from_province_ownership()) {
1577 for(
auto adj : p.get_province().get_province_adjacency()) {
1578 auto indx = adj.get_connected_provinces(0) != p.get_province() ? 0 : 1;
1579 auto o = adj.get_connected_provinces(indx).get_nation_from_province_ownership();
1582 if(o.get_overlord_as_subject().get_ruler() == source)
1590 auto new_rel = fatten(state.world, state.world.force_create_colonization(state_def, source));
1591 new_rel.set_level(
uint8_t(1));
1592 new_rel.set_last_investment(state.current_date);
1593 new_rel.set_points_invested(uint16_t(state.defines.colonization_interest_cost_initial + (adjacent ? state.defines.colonization_interest_cost_neighbor_modifier : 0.0f)));
1595 state.world.state_definition_set_colonization_stage(state_def,
uint8_t(1));
1601 memset(&p, 0,
sizeof(
payload));
1609 auto state_def = state.world.province_get_state_from_abstract_state_membership(pr);
1614 auto state_def = state.world.province_get_state_from_abstract_state_membership(p);
1616 for(
auto rel : state.world.state_definition_get_colonization(state_def)) {
1617 if(rel.get_colonizer() == source) {
1618 state.world.delete_colonization(rel);
1625 memset(&p, 0,
sizeof(
payload));
1632 auto state_def = state.world.province_get_state_from_abstract_state_membership(p);
1633 if(state.world.state_definition_get_colonization_stage(state_def) != 3)
1635 auto rng = state.world.state_definition_get_colonization(state_def);
1636 if(
rng.begin() ==
rng.end())
1638 return (*
rng.begin()).get_colonizer() == source;
1641 auto state_def = state.world.province_get_state_from_abstract_state_membership(p);
1643 for(
auto pr : state.world.state_definition_get_abstract_state_membership(state_def)) {
1644 if(!pr.get_province().get_nation_from_province_ownership()) {
1649 state.world.state_definition_set_colonization_temperature(state_def, 0.0f);
1650 state.world.state_definition_set_colonization_stage(state_def,
uint8_t(0));
1652 auto rng = state.world.state_definition_get_colonization(state_def);
1654 while(
rng.begin() !=
rng.end()) {
1655 state.world.delete_colonization(*
rng.begin());
1661 memset(&p, 0,
sizeof(
payload));
1677 if(state.current_date < state.world.war_get_start_date(w) + int32_t(30.0f * state.defines.min_months_to_intervene))
1687 if(state.world.war_get_is_crisis_war(w) && !state.world.war_get_is_great(w))
1694 if(!state.world.war_get_is_great(w)) {
1706 auto defender = state.world.war_get_primary_defender(w);
1707 auto rel_w_defender = state.world.get_gp_relationship_by_gp_influence_pair(defender, source);
1723 if(state.world.nation_get_war_exhaustion(source) >= state.defines.gw_intervene_max_exhaustion)
1726 auto primary_on_side = for_attacker ? state.world.war_get_primary_attacker(w) : state.world.war_get_primary_defender(w);
1727 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(primary_on_side, source);
1728 if(state.world.diplomatic_relation_get_value(rel) < state.defines.gw_intervene_min_relations)
1731 for(
auto p : state.world.war_get_war_participant(w)) {
1732 if(p.get_is_attacker() != for_attacker) {
1733 if(p.get_nation().get_in_sphere_of() == source)
1736 auto irel = state.world.get_diplomatic_relation_by_diplomatic_pair(p.get_nation(), source);
1737 if(state.world.diplomatic_relation_get_are_allied(irel))
1740 for(
auto prov : p.get_nation().get_province_ownership()) {
1741 for(
auto arm : prov.get_province().get_army_location()) {
1742 if(arm.get_army().get_controller_from_army_control() == source)
1752 if(!state.world.war_get_is_great(w)) {
1753 bool status_quo_added =
false;
1754 for(
auto wg : state.world.war_get_wargoals_attached(w)) {
1757 status_quo_added =
true;
1761 if(!status_quo_added) {
1762 military::add_wargoal(state, w, source, state.world.war_get_primary_attacker(w), state.military_definitions.standard_status_quo, dcon::state_definition_id{},
1763 dcon::national_identity_id{}, dcon::nation_id{});
1772 memset(&p, 0,
sizeof(
payload));
1775 p.
data.
movement.
iopt = state.world.movement_get_associated_issue_option(m);
1776 p.
data.
movement.
tag = state.world.movement_get_associated_independence(m);
1780 if(state.world.movement_get_nation_from_movement_within(m) != source)
1782 if(state.world.movement_get_pop_movement_membership(m).begin() == state.world.movement_get_pop_movement_membership(m).end())
1787 dcon::national_identity_id tag) {
1788 dcon::movement_id m;
1802 memset(&p, 0,
sizeof(
payload));
1808 return state.world.nation_get_modifier_values(source, sys::national_mod_offsets::civilization_progress_modifier) >= 1.0f && !state.world.nation_get_is_civilized(source);
1816 memset(&p, 0,
sizeof(
payload));
1828 if(state.world.nation_get_ruling_party(source) == p)
1835 auto last_change = state.world.nation_get_ruling_party_last_appointed(source);
1836 if(last_change && state.current_date < last_change + 365)
1842 auto gov = state.world.nation_get_government_type(source);
1843 auto new_ideology = state.world.political_party_get_ideology(p);
1844 if((state.world.government_type_get_ideologies_allowed(gov) &
::culture::to_bits(new_ideology)) == 0) {
1856 memset(&p, 0,
sizeof(
payload));
1863 if(source == state.local_player_nation && state.cheat_data.always_allow_reforms)
1866 bool is_military = state.world.reform_get_reform_type(state.world.reform_option_get_parent_reform(r)) ==
1880 memset(&p, 0,
sizeof(
payload));
1887 if(source == state.local_player_nation && state.cheat_data.always_allow_reforms)
1890 auto type = state.world.issue_get_issue_type(state.world.issue_option_get_parent_issue(i));
1905 memset(&p, 0,
sizeof(
payload));
1917 if(state.world.nation_get_is_at_war(source))
1920 if(state.world.nation_get_disarmed_until(source) && state.current_date < state.world.nation_get_disarmed_until(source))
1926 for(
auto& i : state.crisis_participants) {
1936 for(
auto& i : state.crisis_participants) {
1939 i.merely_interested =
true;
1947 memset(&p, 0,
sizeof(
payload));
1962 for(
auto& i : state.crisis_participants) {
1964 return i.merely_interested ==
true;
1971 for(
auto& i : state.crisis_participants) {
1972 if(i.id == source) {
1973 i.merely_interested =
false;
1974 i.supports_attacker = join_attacker;
1980 "msg_crisis_vol_join_title",
1981 source, dcon::nation_id{}, dcon::nation_id{},
1993 bool draw_on_stockpiles) {
1998 bool draw_on_stockpiles) {
2000 memset(&p, 0,
sizeof(
payload));
2010 bool draw_on_stockpiles) {
2011 state.world.nation_set_stockpile_targets(source, c, target_amount);
2012 state.world.nation_set_drawing_on_stockpiles(source, c, draw_on_stockpiles);
2017 memset(&p, 0,
sizeof(
payload));
2024 if(!(state.world.nation_get_is_player_controlled(source) && state.cheat_data.always_potential_decisions)) {
2025 auto condition = state.world.decision_get_potential(d);
2029 if(!(state.world.nation_get_is_player_controlled(source) && state.cheat_data.always_allow_decisions)) {
2030 auto condition = state.world.decision_get_allow(d);
2037 if(
auto e = state.world.decision_get_effect(d); e) {
2039 uint32_t(source.index() << 4 ^ d.index()));
2046 if(
auto e = state.world.decision_get_effect(d); e) {
2049 uint32_t(source.index() << 4 ^ d.index()));
2052 "msg_decision_title",
2053 source, dcon::nation_id{}, dcon::nation_id{},
2060 memset(&p, 0,
sizeof(
payload));
2076 memset(&p, 0,
sizeof(
payload));
2088 memset(&p, 0,
sizeof(
payload));
2090 p.
source = state.world.province_get_nation_from_province_ownership(e.
p);
2103 memset(&p, 0,
sizeof(
payload));
2105 p.
source = state.world.province_get_nation_from_province_ownership(e.
p);
2124 if(source != state.world.province_get_nation_from_province_ownership(e.
p))
2131 if(source != state.world.province_get_nation_from_province_ownership(e.
p))
2140 memset(&p, 0,
sizeof(
payload));
2148 if(source == target)
2151 if(state.world.nation_get_constructing_cb_type(source))
2160 auto ol = state.world.nation_get_overlord_as_subject(source);
2161 if(state.defines.alice_allow_subjects_declare_wars < 1 && state.world.overlord_get_ruler(ol) && state.world.overlord_get_ruler(ol) != target)
2164 if(state.world.nation_get_in_sphere_of(target) == source)
2167 if(state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < state.defines.make_cb_diplomatic_cost)
2180 auto bits = state.world.cb_type_get_type_bits(type);
2191 state.world.nation_set_constructing_cb_target(source, target);
2192 state.world.nation_set_constructing_cb_type(source, type);
2193 state.world.nation_get_diplomatic_points(source) -= state.defines.make_cb_diplomatic_cost;
2202 memset(&p, 0,
sizeof(
payload));
2208 state.world.nation_set_constructing_cb_target(source, dcon::nation_id{});
2209 state.world.nation_set_constructing_cb_is_discovered(source,
false);
2210 state.world.nation_set_constructing_cb_progress(source, 0.0f);
2211 state.world.nation_set_constructing_cb_type(source, dcon::cb_type_id{});
2216 memset(&p, 0,
sizeof(
payload));
2230 if(!ignore_cost && state.world.nation_get_is_player_controlled(asker) && state.world.nation_get_diplomatic_points(asker) < state.defines.askmilaccess_diplomatic_cost)
2233 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, asker);
2234 if(state.world.unilateral_relationship_get_military_access(rel))
2243 state.world.nation_get_diplomatic_points(asker) -= state.defines.askmilaccess_diplomatic_cost;
2256 memset(&p, 0,
sizeof(
payload));
2266 if(!ignore_cost && state.world.nation_get_is_player_controlled(asker) && state.world.nation_get_diplomatic_points(asker) < state.defines.givemilaccess_diplomatic_cost)
2269 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(asker, target);
2270 if(state.world.unilateral_relationship_get_military_access(rel))
2279 state.world.nation_get_diplomatic_points(asker) -= state.defines.givemilaccess_diplomatic_cost;
2281 auto urel = state.world.get_unilateral_relationship_by_unilateral_pair(asker, target);
2283 urel = state.world.force_create_unilateral_relationship(asker, target);
2285 state.world.unilateral_relationship_set_military_access(urel,
true);
2291 memset(&p, 0,
sizeof(
payload));
2306 if(!ignore_cost && state.world.nation_get_is_player_controlled(asker) && state.world.nation_get_diplomatic_points(asker) < state.defines.alliance_diplomatic_cost)
2309 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(target, asker);
2310 if(state.world.diplomatic_relation_get_are_allied(rel))
2313 if(state.world.nation_get_is_great_power(asker) && state.world.nation_get_is_great_power(target) &&
2318 auto ol = state.world.nation_get_overlord_as_subject(asker);
2319 if(state.world.overlord_get_ruler(ol))
2321 auto ol2 = state.world.nation_get_overlord_as_subject(target);
2322 if(state.world.overlord_get_ruler(ol2))
2333 state.world.nation_get_diplomatic_points(asker) -= state.defines.alliance_diplomatic_cost;
2346 memset(&p, 0,
sizeof(
payload));
2360 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, asker);
2362 rel = state.world.force_create_unilateral_relationship(target, asker);
2363 state.world.unilateral_relationship_set_interested_in_alliance(rel, !state.world.unilateral_relationship_get_interested_in_alliance(rel));
2368 memset(&p, 0,
sizeof(
payload));
2380 if(!state.world.nation_get_is_player_controlled(asker) || !state.world.nation_get_is_player_controlled(target))
2384 auto ol = state.world.nation_get_overlord_as_subject(asker);
2385 if(state.world.overlord_get_ruler(ol))
2387 auto ol2 = state.world.nation_get_overlord_as_subject(target);
2388 if(state.world.overlord_get_ruler(ol2))
2390 if(state.world.nation_get_is_at_war(asker) || state.world.nation_get_is_at_war(target))
2396 for(
const auto ab : state.world.state_definition_get_abstract_state_membership(sid)) {
2397 if(ab.get_province().get_province_ownership().get_nation() == asker) {
2400 if(ab.get_province().get_province_control().get_nation() != asker)
2404 if(state.world.nation_get_owned_state_count(asker) == 1)
2423 memset(&p, 0,
sizeof(
payload));
2434 if(!ignore_cost && state.world.nation_get_is_player_controlled(asker) && state.world.nation_get_diplomatic_points(asker) < state.defines.callally_diplomatic_cost)
2437 if(!
nations::are_allied(state, asker, target) && !(state.world.war_get_primary_defender(w) == asker && state.world.nation_get_in_sphere_of(asker) == target))
2446 if(state.world.war_get_is_crisis_war(w) && !state.military_definitions.great_wars_enabled)
2452 state.world.nation_get_diplomatic_points(asker) -= state.defines.callally_diplomatic_cost;
2467 memset(&p, 0,
sizeof(
payload));
2477 for(
auto& m : state.pending_messages) {
2478 if(m.type == type && m.from == from && m.to == source) {
2494 memset(&p, 0,
sizeof(
payload));
2501 if(source == target)
2504 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, source);
2505 if(!ignore_cost && state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < state.defines.cancelaskmilaccess_diplomatic_cost)
2508 if(state.world.unilateral_relationship_get_military_access(rel))
2514 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(target, source);
2516 state.world.unilateral_relationship_set_military_access(rel,
false);
2518 state.world.nation_get_diplomatic_points(source) -= state.defines.cancelaskmilaccess_diplomatic_cost;
2525 "msg_access_canceled_a_title",
2526 source, target, dcon::nation_id{},
2533 memset(&p, 0,
sizeof(
payload));
2540 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(source, target);
2542 if(!ignore_cost && state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < state.defines.cancelgivemilaccess_diplomatic_cost)
2545 if(state.world.unilateral_relationship_get_military_access(rel))
2551 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(source, target);
2553 state.world.unilateral_relationship_set_military_access(rel,
false);
2555 state.world.nation_get_diplomatic_points(source) -= state.defines.cancelgivemilaccess_diplomatic_cost;
2558 if(source != state.local_player_nation) {
2563 "msg_access_canceled_b_title",
2564 source, target, dcon::nation_id{},
2572 memset(&p, 0,
sizeof(
payload));
2579 if(source == target)
2582 if(!ignore_cost && state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < state.defines.cancelalliance_diplomatic_cost)
2585 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(target, source);
2586 if(!state.world.diplomatic_relation_get_are_allied(rel))
2592 auto ol = state.world.nation_get_overlord_as_subject(source);
2593 if(state.world.overlord_get_ruler(ol) == target)
2599 state.world.nation_get_diplomatic_points(source) -= state.defines.cancelalliance_diplomatic_cost;
2606 dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation,
bool call_attacker_allies) {
2609 memset(&p, 0,
sizeof(
payload));
2622 dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation) {
2623 dcon::nation_id real_target = target;
2625 auto target_ol_rel = state.world.nation_get_overlord_as_subject(target);
2626 if(state.world.overlord_get_ruler(target_ol_rel))
2627 real_target = state.world.overlord_get_ruler(target_ol_rel);
2629 if(source == target || source == real_target)
2632 if(state.world.nation_get_owned_province_count(target) == 0 || state.world.nation_get_owned_province_count(real_target) == 0)
2641 auto source_ol_rel = state.world.nation_get_overlord_as_subject(source);
2642 if(state.world.overlord_get_ruler(source_ol_rel) && state.world.overlord_get_ruler(source_ol_rel) != real_target)
2645 if(state.world.nation_get_in_sphere_of(real_target) == source)
2648 if(state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < state.defines.declarewar_diplomatic_cost)
2659 dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation,
bool call_attacker_allies) {
2660 state.world.nation_get_diplomatic_points(source) -= state.defines.declarewar_diplomatic_cost;
2663 dcon::nation_id real_target = target;
2665 auto target_ol_rel = state.world.nation_get_overlord_as_subject(target);
2666 if(state.world.overlord_get_ruler(target_ol_rel))
2667 real_target = state.world.overlord_get_ruler(target_ol_rel);
2674 state.world.nation_get_infamy(source) += cb_infamy;
2677 for(
auto prov : state.world.nation_get_province_ownership(source)) {
2678 for(
auto pop : prov.get_province().get_pop_location()) {
2686 auto current_cbs = state.world.nation_get_available_cbs(source);
2687 for(
uint32_t i = current_cbs.size(); i-- > 0;) {
2688 if(current_cbs[i].cb_type == primary_cb && current_cbs[i].target == target) {
2689 current_cbs.remove_at(i);
2694 auto war =
military::create_war(state, source, target, primary_cb, cb_state, cb_tag, cb_secondary_nation);
2696 if(call_attacker_allies) {
2701void add_war_goal(
sys::state& state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type,
2702 dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation) {
2704 memset(&p, 0,
sizeof(
payload));
2716 dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation) {
2723 if(source == target)
2726 if(state.world.nation_get_is_player_controlled(source) && state.cheat_data.always_allow_wargoals)
2729 if(state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < state.defines.addwargoal_diplomatic_cost)
2733 bool target_in_war =
false;
2735 for(
auto par : state.world.war_get_war_participant(w)) {
2736 if(par.get_nation() == target) {
2737 if(par.get_is_attacker() == is_attacker)
2739 target_in_war =
true;
2755 bool cb_fabbed =
false;
2756 for(
auto& fab_cb : state.world.nation_get_available_cbs(source)) {
2757 if(fab_cb.cb_type == cb_type && fab_cb.target == target) {
2767 auto jingoism_perc = totalpop > 0 ? state.world.nation_get_demographics(source,
demographics::to_key(state, state.culture_definitions.jingoism)) / totalpop : 0.0f;
2769 if(state.world.war_get_is_great(w)) {
2770 if(jingoism_perc < state.defines.wargoal_jingoism_requirement * state.defines.gw_wargoal_jingoism_requirement_mod)
2773 if(jingoism_perc < state.defines.wargoal_jingoism_requirement)
2784 dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag,
2785 dcon::nation_id cb_secondary_nation) {
2787 if(!
can_add_war_goal(state, source, w, target, cb_type, cb_state, cb_tag, cb_secondary_nation))
2790 state.world.nation_get_diplomatic_points(source) -= state.defines.addwargoal_diplomatic_cost;
2794 state.world.nation_get_infamy(source) += infamy;
2801 memset(&p, 0,
sizeof(
payload));
2813 auto ol = state.world.nation_get_overlord_as_subject(source);
2814 if(state.world.overlord_get_ruler(ol) && !(state.world.war_get_primary_attacker(war) == source || state.world.war_get_primary_defender(war) == source))
2818 auto ol = state.world.nation_get_overlord_as_subject(target);
2819 if(state.world.overlord_get_ruler(ol) && !(state.world.war_get_primary_attacker(war) == target || state.world.war_get_primary_defender(war) == target))
2823 if(state.world.war_get_primary_attacker(war) == source) {
2826 }
else if(state.world.war_get_primary_defender(war) == source) {
2829 }
else if(state.world.war_get_primary_attacker(war) == target) {
2832 }
else if(state.world.war_get_primary_defender(war) == target) {
2839 if(state.world.war_get_is_crisis_war(war)) {
2840 if((state.world.war_get_primary_attacker(war) != source || state.world.war_get_primary_defender(war) != target) &&
2841 (state.world.war_get_primary_attacker(war) != target || state.world.war_get_primary_defender(war) != source)) {
2847 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
2851 auto offer = fatten(state.world, state.world.create_peace_offer());
2852 offer.set_target(target);
2853 offer.set_war_from_war_settlement(war);
2854 offer.set_is_concession(is_concession);
2855 offer.set_nation_from_pending_peace_offer(source);
2860 memset(&p, 0,
sizeof(
payload));
2867 if(source != state.primary_crisis_attacker && source != state.primary_crisis_defender)
2872 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
2876 auto offer = fatten(state.world, state.world.create_peace_offer());
2877 offer.set_is_concession(is_concession);
2878 offer.set_nation_from_pending_peace_offer(source);
2879 offer.set_is_crisis_offer(
true);
2882 if((source == state.primary_crisis_attacker && !is_concession) ||
2883 (source != state.primary_crisis_attacker && is_concession)) {
2884 auto new_wg = fatten(state.world, state.world.create_wargoal());
2885 new_wg.set_added_by(state.primary_crisis_attacker);
2886 new_wg.set_associated_state(state.world.state_instance_get_definition(state.crisis_state));
2887 new_wg.set_associated_tag(state.crisis_liberation_tag);
2888 new_wg.set_peace_offer_from_peace_offer_item(offer);
2889 new_wg.set_target_nation(state.world.state_instance_get_nation_from_state_ownership(state.crisis_state));
2890 new_wg.set_type(state.military_definitions.crisis_liberate);
2893 auto colonizers = state.world.state_definition_get_colonization(state.crisis_colony);
2895 if((colonizers.end() - colonizers.begin()) >= 2) {
2896 auto attacking_colonizer = (*colonizers.begin()).get_colonizer();
2897 auto defending_colonizer = (*(colonizers.begin() + 1)).get_colonizer();
2899 if((source == state.primary_crisis_attacker && !is_concession) ||
2900 (source != state.primary_crisis_attacker && is_concession)) {
2901 auto new_wg = fatten(state.world, state.world.create_wargoal());
2902 new_wg.set_added_by(attacking_colonizer);
2903 new_wg.set_associated_state(state.crisis_colony);
2904 new_wg.set_peace_offer_from_peace_offer_item(offer);
2905 new_wg.set_target_nation(defending_colonizer);
2906 new_wg.set_type(state.military_definitions.crisis_colony);
2908 auto new_wg = fatten(state.world, state.world.create_wargoal());
2909 new_wg.set_added_by(defending_colonizer);
2910 new_wg.set_associated_state(state.crisis_colony);
2911 new_wg.set_peace_offer_from_peace_offer_item(offer);
2912 new_wg.set_target_nation(attacking_colonizer);
2913 new_wg.set_type(state.military_definitions.crisis_colony);
2921 memset(&p, 0,
sizeof(
payload));
2928 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
2932 auto war = state.world.peace_offer_get_war_from_war_settlement(pending);
2933 auto wg = fatten(state.world, goal);
2934 auto target = state.world.peace_offer_get_target(pending);
2939 if(wg.get_war_from_wargoals_attached() != war)
2948 if(state.world.war_get_primary_attacker(war) == source && state.world.war_get_primary_defender(war) == target) {
2951 if(state.world.war_get_primary_attacker(war) == target && state.world.war_get_primary_defender(war) == source) {
2955 if(state.world.peace_offer_get_is_concession(pending)) {
2956 if(state.world.war_get_primary_attacker(war) == source || state.world.war_get_primary_defender(war) == source) {
2957 if(wg.get_added_by() == target)
2959 if(wg.get_added_by().get_overlord_as_subject().get_ruler() == target)
2963 if(wg.get_target_nation() == source)
2965 if(wg.get_target_nation().get_overlord_as_subject().get_ruler() == source)
2970 if(state.world.war_get_primary_attacker(war) == source || state.world.war_get_primary_defender(war) == source) {
2971 if(wg.get_target_nation() == target)
2973 if(wg.get_target_nation().get_overlord_as_subject().get_ruler() == target)
2977 if(wg.get_added_by() == target)
2979 if(wg.get_added_by().get_overlord_as_subject().get_ruler() == target)
2986 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
2987 state.world.force_create_peace_offer_item(pending, goal);
2991 dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag,
2992 dcon::nation_id cb_secondary_nation) {
2994 memset(&p, 0,
sizeof(
payload));
3006 dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag,
3007 dcon::nation_id cb_secondary_nation) {
3009 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
3013 auto war = state.world.peace_offer_get_war_from_war_settlement(pending);
3017 bool found = [&]() {
3018 for(
auto& par : state.crisis_participants) {
3022 if(par.id == wargoal_from) {
3023 if(cb_state == par.joined_with_offer.wargoal_state && cb_tag == par.joined_with_offer.wargoal_tag &&
3024 cb_secondary_nation == par.joined_with_offer.wargoal_secondary_nation && target == par.joined_with_offer.target &&
3025 primary_cb == par.joined_with_offer.wargoal_type)
3038 for(
auto wg : state.world.peace_offer_get_peace_offer_item(pending)) {
3039 if(wg.get_wargoal().get_added_by() == wargoal_from)
3046 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
3048 auto wg = fatten(state.world, state.world.create_wargoal());
3049 wg.set_peace_offer_from_peace_offer_item(pending);
3050 wg.set_added_by(data.
invited);
3051 wg.set_associated_state(data.
cb_state);
3052 wg.set_associated_tag(data.
cb_tag);
3054 wg.set_target_nation(data.
target);
3060 memset(&p, 0,
sizeof(
payload));
3066 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
3067 if(!pending || !state.world.peace_offer_get_war_from_war_settlement(pending))
3072 auto pending_offer = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
3073 auto in_war = state.world.peace_offer_get_war_from_war_settlement(pending_offer);
3079 auto target = state.world.peace_offer_get_target(pending_offer);
3090 m.data.peace = pending_offer;
3099 memset(&p, 0,
sizeof(
payload));
3105 auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
3106 if(!pending || state.world.peace_offer_get_war_from_war_settlement(pending))
3108 if(source != state.primary_crisis_attacker && source != state.primary_crisis_defender)
3116 auto pending_offer = state.world.nation_get_peace_offer_from_pending_peace_offer(source);
3120 if(!state.world.peace_offer_get_war_from_war_settlement(pending_offer))
3123 state.world.delete_peace_offer(pending_offer);
3128 auto target = state.primary_crisis_attacker == source ? state.primary_crisis_defender : state.primary_crisis_attacker;
3134 m.data.peace = pending_offer;
3140void move_army(
sys::state& state, dcon::nation_id source, dcon::army_id a, dcon::province_id dest,
bool reset) {
3142 memset(&p, 0,
sizeof(
payload));
3167 if(source != state.world.army_get_controller_from_army_control(a))
3168 return std::vector<dcon::province_id>{};
3169 if(state.world.army_get_is_retreating(a))
3170 return std::vector<dcon::province_id>{};
3172 return std::vector<dcon::province_id>{};
3174 auto last_province = state.world.army_get_location_from_army_location(a);
3175 auto movement = state.world.army_get_path(a);
3176 if(movement.size() > 0) {
3177 last_province = movement.at(0);
3180 if(last_province == dest)
3181 return std::vector<dcon::province_id>{};
3184 return std::vector<dcon::province_id>{};
3186 if(dest.index() < state.province_definitions.first_sea_province.index()) {
3188 if(state.world.army_get_battle_from_army_battle_participation(a)) {
3203 if(
military::are_at_war(state, state.world.province_get_nation_from_province_control(dest), source)) {
3204 auto units = state.world.province_get_army_location_as_location(dest);
3206 for(
const auto unit : units) {
3207 if(unit.get_army().get_controller_from_army_control() == source)
3209 if(unit.get_army().get_controller_from_army_rebel_control()
3218 for(
const auto adj : state.world.province_get_province_adjacency(dest)) {
3219 auto other = adj.get_connected_provinces(adj.get_connected_provinces(0) == dest ? 1 : 0);
3220 if(other.id.index() < state.province_definitions.first_sea_province.index()) {
3221 auto units = state.world.province_get_army_location_as_location(dest);
3222 bool has_enemy_units =
false;
3223 for(
const auto unit : units) {
3224 if(unit.get_army().get_controller_from_army_rebel_control()
3226 has_enemy_units =
true;
3230 if(!has_enemy_units) {
3238 for(
const auto adj : state.world.province_get_province_adjacency(dest)) {
3239 auto other = adj.get_connected_provinces(adj.get_connected_provinces(0) == dest ? 1 : 0);
3240 if(last_province == other) {
3246 if(state.world.army_get_black_flag(a)) {
3253 return std::vector<dcon::province_id>{};
3256 if(state.world.army_get_black_flag(a)) {
3261 return std::vector<dcon::province_id>{};
3265 if(state.world.army_get_black_flag(a)) {
3270 return std::vector<dcon::province_id>{};
3275 return std::vector<dcon::province_id>{};
3277 if(state.world.army_get_black_flag(a)) {
3286 if(source != state.world.army_get_controller_from_army_control(a))
3288 if(state.world.army_get_is_retreating(a))
3291 auto battle = state.world.army_get_battle_from_army_battle_participation(a);
3292 if(dest.index() < state.province_definitions.first_sea_province.index()) {
3304 auto existing_path = state.world.army_get_path(a);
3307 existing_path.clear();
3308 state.world.army_set_arrival_time(a,
sys::date{});
3312 auto old_first_prov = existing_path.size() > 0 ? existing_path.at(existing_path.size() - 1) : dcon::province_id{};
3314 existing_path.clear();
3319 if(path.size() > 0) {
3320 auto append_size =
uint32_t(path.size());
3321 auto old_size = existing_path.size();
3322 auto new_size = old_size + append_size;
3323 existing_path.resize(new_size);
3325 for(
uint32_t i = old_size; i-- > 0; ) {
3326 existing_path.at(append_size + i) = existing_path.at(i);
3328 for(
uint32_t i = 0; i < append_size; ++i) {
3329 existing_path.at(i) = path[i];
3332 if(existing_path.at(new_size - 1) != old_first_prov) {
3335 state.world.army_set_dig_in(a, 0);
3336 state.world.army_set_is_rebel_hunter(a,
false);
3338 state.world.army_set_arrival_time(a,
sys::date{});
3340 state.world.army_set_moving_to_merge(a,
false);
3343 state.world.army_set_is_retreating(a,
true);
3344 state.world.army_set_battle_from_army_battle_participation(a, dcon::land_battle_id{});
3345 for(
auto reg : state.world.army_get_army_membership(a)) {
3347 auto& line = state.world.land_battle_get_attacker_front_line(battle);
3348 for(
auto& lr : line) {
3349 if(lr == reg.get_regiment())
3350 lr = dcon::regiment_id{};
3354 auto& line = state.world.land_battle_get_attacker_back_line(battle);
3355 for(
auto& lr : line) {
3356 if(lr == reg.get_regiment())
3357 lr = dcon::regiment_id{};
3361 auto& line = state.world.land_battle_get_defender_front_line(battle);
3362 for(
auto& lr : line) {
3363 if(lr == reg.get_regiment())
3364 lr = dcon::regiment_id{};
3368 auto& line = state.world.land_battle_get_defender_back_line(battle);
3369 for(
auto& lr : line) {
3370 if(lr == reg.get_regiment())
3371 lr = dcon::regiment_id{};
3374 auto res = state.world.land_battle_get_reserves(battle);
3375 for(
uint32_t i = res.size(); i-- > 0;) {
3376 if(res[i].regiment == reg.get_regiment()) {
3377 res[i] = res[res.size() - 1];
3388void move_navy(
sys::state& state, dcon::nation_id source, dcon::navy_id n, dcon::province_id dest,
bool reset) {
3390 memset(&p, 0,
sizeof(
payload));
3399 if(source != state.world.navy_get_controller_from_navy_control(n))
3400 return std::vector<dcon::province_id>{};
3401 if(state.world.navy_get_is_retreating(n))
3402 return std::vector<dcon::province_id>{};
3404 return std::vector<dcon::province_id>{};
3406 auto last_province = state.world.navy_get_location_from_navy_location(n);
3407 auto movement = state.world.navy_get_path(n);
3408 if(movement.size() > 0) {
3409 last_province = movement.at(0);
3412 if(last_province == dest)
3413 return std::vector<dcon::province_id>{};
3416 return std::vector<dcon::province_id>{};
3418 if(dest.index() >= state.province_definitions.first_sea_province.index()) {
3421 if(!state.world.province_get_is_coast(dest))
3422 return std::vector<dcon::province_id>{};
3425 return std::vector<dcon::province_id>{};
3431 if(source != state.world.navy_get_controller_from_navy_control(n))
3433 if(state.world.navy_get_is_retreating(n))
3436 auto battle = state.world.navy_get_battle_from_navy_battle_participation(n);
3441 auto existing_path = state.world.navy_get_path(n);
3444 existing_path.clear();
3445 state.world.navy_set_arrival_time(n,
sys::date{});
3449 auto old_first_prov = existing_path.size() > 0 ? existing_path.at(existing_path.size() - 1) : dcon::province_id{};
3451 existing_path.clear();
3455 if(path.size() > 0) {
3456 auto append_size =
uint32_t(path.size());
3457 auto old_size = existing_path.size();
3458 auto new_size = old_size + append_size;
3459 existing_path.resize(new_size);
3461 for(
uint32_t i = old_size; i-- > 0; ) {
3462 existing_path.at(append_size + i) = existing_path.at(i);
3464 for(
uint32_t i = 0; i < append_size; ++i) {
3465 existing_path.at(i) = path[i];
3468 if(existing_path.at(new_size - 1) != old_first_prov) {
3472 state.world.navy_set_arrival_time(n,
sys::date{});
3474 state.world.navy_set_moving_to_merge(n,
false);
3477 state.world.navy_set_is_retreating(n,
true);
3478 state.world.navy_set_battle_from_navy_battle_participation(n, dcon::naval_battle_id{});
3479 for(
auto shp : state.world.navy_get_navy_membership(n)) {
3480 for(
auto& s : state.world.naval_battle_get_slots(battle)) {
3481 if(s.ship == shp.get_ship()) {
3482 s.ship = dcon::ship_id{};
3483 s.flags &= ~s.mode_mask;
3484 s.flags |= s.mode_retreated;
3495 memset(&p, 0,
sizeof(
payload));
3503 if(source != state.world.army_get_controller_from_army_control(a))
3505 if(state.world.army_get_is_retreating(a))
3508 auto location = state.world.army_get_location_from_army_location(a);
3509 if(location.index() >= state.province_definitions.first_sea_province.index())
3512 if(state.world.army_get_battle_from_army_battle_participation(a))
3515 if(state.world.army_get_navy_from_army_transport(a)) {
3523 if(source != state.world.army_get_controller_from_army_control(a))
3525 if(state.world.army_get_is_retreating(a))
3528 if(state.world.army_get_battle_from_army_battle_participation(a))
3531 auto location = state.world.army_get_location_from_army_location(a);
3532 if(location.index() >= state.province_definitions.first_sea_province.index())
3535 if(state.world.army_get_navy_from_army_transport(a)) {
3536 state.world.army_set_navy_from_army_transport(a, dcon::navy_id{});
3541 state.world.army_set_navy_from_army_transport(a, to_navy);
3542 state.world.army_set_black_flag(a,
false);
3545 state.world.army_set_is_rebel_hunter(a,
false);
3546 state.world.army_set_dig_in(a, 0);
3551 memset(&p, 0,
sizeof(
payload));
3559 if(state.world.army_get_controller_from_army_control(a) != source)
3561 if(state.world.army_get_controller_from_army_control(b) != source)
3563 if(state.world.army_get_is_retreating(a) || state.world.army_get_is_retreating(b))
3565 if(state.world.army_get_navy_from_army_transport(a))
3567 if(state.world.army_get_navy_from_army_transport(b))
3570 if(state.world.army_get_location_from_army_location(a) != state.world.army_get_location_from_army_location(b))
3573 if(state.world.army_get_battle_from_army_battle_participation(a) ||
3574 state.world.army_get_battle_from_army_battle_participation(b))
3582 auto a_leader = state.world.army_get_general_from_army_leadership(a);
3583 auto b_leader = state.world.army_get_general_from_army_leadership(b);
3584 if(!a_leader && b_leader) {
3585 state.world.army_set_general_from_army_leadership(a, b_leader);
3589 state.world.army_get_path(a).clear();
3590 state.world.army_set_arrival_time(a,
sys::date{});
3592 auto regs = state.world.army_get_army_membership(b);
3593 while(regs.begin() != regs.end()) {
3594 auto reg = (*regs.begin()).get_regiment();
3595 reg.set_army_from_army_membership(a);
3598 if(source == state.local_player_nation) {
3606 memset(&p, 0,
sizeof(
payload));
3614 if(state.world.navy_get_controller_from_navy_control(a) != source)
3616 if(state.world.navy_get_controller_from_navy_control(b) != source)
3618 if(state.world.navy_get_is_retreating(a) || state.world.navy_get_is_retreating(b))
3621 if(state.world.navy_get_location_from_navy_location(a) != state.world.navy_get_location_from_navy_location(b))
3624 if(state.world.navy_get_battle_from_navy_battle_participation(a) ||
3625 state.world.navy_get_battle_from_navy_battle_participation(b))
3632 auto a_leader = state.world.navy_get_admiral_from_navy_leadership(a);
3633 auto b_leader = state.world.navy_get_admiral_from_navy_leadership(b);
3634 if(!a_leader && b_leader) {
3635 state.world.navy_set_admiral_from_navy_leadership(a, b_leader);
3639 state.world.navy_get_path(a).clear();
3640 state.world.navy_set_arrival_time(a,
sys::date{});
3642 auto regs = state.world.navy_get_navy_membership(b);
3643 while(regs.begin() != regs.end()) {
3644 auto reg = (*regs.begin()).get_ship();
3645 reg.set_navy_from_navy_membership(a);
3648 auto transported = state.world.navy_get_army_transport(b);
3649 while(transported.begin() != transported.end()) {
3650 auto arm = (*transported.begin()).get_army();
3651 arm.set_navy_from_army_transport(a);
3654 if(source == state.local_player_nation) {
3662 memset(&p, 0,
sizeof(
payload));
3669 return state.world.army_get_controller_from_army_control(a) == source && !state.world.army_get_is_retreating(a) &&
3670 !bool(state.world.army_get_battle_from_army_battle_participation(a));
3673 std::vector<dcon::regiment_id> regs;
3674 for(
auto r : state.world.army_get_army_membership(a)) {
3675 auto pop = r.get_regiment().get_pop_from_regiment_source();
3676 if(!pop || pop.get_size() < state.defines.pop_min_size_for_regiment)
3677 regs.push_back(r.get_regiment());
3680 state.world.delete_regiment(r);
3685 memset(&p, 0,
sizeof(
payload));
3692 auto owner = state.world.army_get_controller_from_army_control(a);
3696 auto current_state = state.world.army_get_is_rebel_hunter(a);
3698 state.world.army_set_is_rebel_hunter(a,
false);
3700 auto path = state.world.army_get_path(a);
3701 if(path.size() > 0) {
3702 state.world.army_set_ai_province(a, path.at(0));
3704 state.world.army_set_ai_province(a, state.world.army_get_location_from_army_location(a));
3705 if(!state.world.army_get_battle_from_army_battle_participation(a)
3706 && !state.world.army_get_navy_from_army_transport(a)) {
3711 state.world.army_set_is_rebel_hunter(a,
true);
3717 memset(&p, 0,
sizeof(
payload));
3724 auto owner = state.world.army_get_controller_from_army_control(a);
3727 auto current_state = state.world.army_get_is_ai_controlled(a);
3729 state.world.army_set_ai_activity(a, 0);
3730 state.world.army_set_is_ai_controlled(a,
false);
3733 state.world.army_set_is_rebel_hunter(a,
false);
3734 auto path = state.world.army_get_path(a);
3735 if(path.size() > 0) {
3736 state.world.army_set_ai_province(a, path.at(0));
3738 state.world.army_set_ai_province(a, state.world.army_get_location_from_army_location(a));
3739 if(!state.world.army_get_battle_from_army_battle_participation(a)
3740 && !state.world.army_get_navy_from_army_transport(a)) {
3745 state.world.army_set_ai_activity(a, 0);
3746 state.world.army_set_is_ai_controlled(a,
true);
3752 memset(&p, 0,
sizeof(
payload));
3758 state.world.nation_set_mobilized_is_ai_controlled(source, !state.world.nation_get_mobilized_is_ai_controlled(source));
3763 memset(&p, 0,
sizeof(
payload));
3770 if(state.world.province_get_nation_from_province_control(prov) != source)
3772 if(state.world.province_get_nation_from_province_ownership(prov) != source)
3782 memset(&p, 0,
sizeof(
payload));
3789 if(state.world.province_get_nation_from_province_control(prov) != source)
3791 if(state.world.province_get_nation_from_province_ownership(prov) != source)
3801 memset(&p, 0,
sizeof(
payload));
3808 return state.world.overlord_get_ruler(state.world.nation_get_overlord_as_subject(target)) == source;
3818 memset(&p, 0,
sizeof(
payload));
3820 p.
source = state.local_player_nation;
3827 std::lock_guard lg{ state.lock_console_strings };
3828 command = state.console_command_pending;
3829 state.console_command_pending.clear();
3837 std::lock_guard lg{ state.lock_console_strings };
3838 state.console_command_result += state.console_command_error;
3839 state.console_command_error.clear();
3841 std::string temp_result;
3847 state.fif_environment->source_stack.push_back(
"drop");
3848 state.fif_environment->compiler_stack.emplace_back(std::make_unique<fif::outer_interpreter>(*state.fif_environment));
3854 m->interpreted_link = o;
3860 state.fif_environment->source_stack.pop_back();
3861 restore_compiler_stack_mode(*state.fif_environment);
3863 state.fif_environment->compiler_stack.pop_back();
3865 temp_result +=
"?Gok.?W\\n";
3867 std::lock_guard lg{ state.lock_console_strings };
3868 state.console_command_result += temp_result;
3877 memset(&p, 0,
sizeof(
payload));
3887 bool inf_split =
false;
3888 bool cav_split =
false;
3889 bool art_split =
false;
3891 static std::vector<dcon::regiment_id> to_transfer;
3892 to_transfer.clear();
3894 for(
auto t : state.world.army_get_army_membership(a)) {
3895 auto type = state.military_definitions.unit_base_definitions[t.get_regiment().get_type()].type;
3898 to_transfer.push_back(t.get_regiment());
3900 inf_split = !inf_split;
3903 to_transfer.push_back(t.get_regiment());
3905 cav_split = !cav_split;
3908 to_transfer.push_back(t.get_regiment());
3910 art_split = !art_split;
3914 if(to_transfer.size() > 0) {
3915 auto new_u = fatten(state.world, state.world.create_army());
3916 new_u.set_controller_from_army_control(source);
3917 new_u.set_location_from_army_location(state.world.army_get_location_from_army_location(a));
3918 new_u.set_black_flag(state.world.army_get_black_flag(a));
3920 for(
auto t : to_transfer) {
3921 state.world.regiment_set_army_from_army_membership(t, new_u);
3924 if(source == state.local_player_nation && state.is_selected(a)) {
3926 state.select(new_u);
3933 memset(&p, 0,
sizeof(
payload));
3943 static std::vector<dcon::ship_id> to_transfer;
3944 to_transfer.clear();
3946 bool big_split =
false;
3947 bool sm_split =
false;
3948 bool tra_split =
false;
3950 for(
auto t : state.world.navy_get_navy_membership(a)) {
3951 auto type = state.military_definitions.unit_base_definitions[t.get_ship().get_type()].type;
3954 to_transfer.push_back(t.get_ship());
3956 big_split = !big_split;
3959 to_transfer.push_back(t.get_ship());
3961 sm_split = !sm_split;
3964 to_transfer.push_back(t.get_ship());
3966 tra_split = !tra_split;
3970 if(to_transfer.size() > 0) {
3971 auto new_u = fatten(state.world, state.world.create_navy());
3972 new_u.set_controller_from_navy_control(source);
3973 new_u.set_location_from_navy_location(state.world.navy_get_location_from_navy_location(a));
3975 for(
auto t : to_transfer) {
3976 state.world.ship_set_navy_from_navy_membership(t, new_u);
3979 if(source == state.local_player_nation && state.is_selected(a)) {
3981 state.select(new_u);
3988 memset(&p, 0,
sizeof(
payload));
3995 return state.world.army_get_controller_from_army_control(a) == source && !state.world.army_get_is_retreating(a) && !state.world.army_get_navy_from_army_transport(a) &&
3996 !bool(state.world.army_get_battle_from_army_battle_participation(a));
3999 static std::vector<dcon::regiment_id> to_transfer;
4000 to_transfer.clear();
4002 for(
auto t : state.world.army_get_army_membership(a)) {
4003 if(t.get_regiment().get_pending_split()) {
4004 t.get_regiment().set_pending_split(
false);
4005 to_transfer.push_back(t.get_regiment().id);
4009 if(to_transfer.size() > 0) {
4010 auto new_u = fatten(state.world, state.world.create_army());
4011 new_u.set_controller_from_army_control(source);
4012 new_u.set_location_from_army_location(state.world.army_get_location_from_army_location(a));
4013 new_u.set_black_flag(state.world.army_get_black_flag(a));
4015 for(
auto t : to_transfer) {
4016 state.world.regiment_set_army_from_army_membership(t, new_u);
4019 if(source == state.local_player_nation && state.is_selected(a))
4020 state.select(new_u);
4022 auto old_regs = state.world.army_get_army_membership(a);
4023 if(old_regs.begin() == old_regs.end()) {
4024 state.world.leader_set_army_from_army_leadership(state.world.army_get_general_from_army_leadership(a), new_u);
4026 if(source == state.local_player_nation) {
4036 memset(&p, 0,
sizeof(
payload));
4043 auto embarked = state.world.navy_get_army_transport(a);
4044 return state.world.navy_get_controller_from_navy_control(a) == source && !state.world.navy_get_is_retreating(a) &&
4045 !bool(state.world.navy_get_battle_from_navy_battle_participation(a)) && embarked.begin() == embarked.end();
4048 static std::vector<dcon::ship_id> to_transfer;
4049 to_transfer.clear();
4051 for(
auto t : state.world.navy_get_navy_membership(a)) {
4052 if(t.get_ship().get_pending_split()) {
4053 t.get_ship().set_pending_split(
false);
4054 to_transfer.push_back(t.get_ship().id);
4058 if(to_transfer.size() > 0) {
4059 auto new_u = fatten(state.world, state.world.create_navy());
4060 new_u.set_controller_from_navy_control(source);
4061 new_u.set_location_from_navy_location(state.world.navy_get_location_from_navy_location(a));
4063 for(
auto t : to_transfer) {
4064 state.world.ship_set_navy_from_navy_membership(t, new_u);
4067 if(source == state.local_player_nation && state.is_selected(a))
4068 state.select(new_u);
4070 auto old_regs = state.world.navy_get_navy_membership(a);
4071 if(old_regs.begin() == old_regs.end()) {
4072 state.world.leader_set_navy_from_navy_leadership(state.world.navy_get_admiral_from_navy_leadership(a), new_u);
4073 if(source == state.local_player_nation) {
4083 memset(&p, 0,
sizeof(
payload));
4090 return state.world.army_get_controller_from_army_control(a) == source && !state.world.army_get_is_retreating(a) &&
4091 !bool(state.world.army_get_battle_from_army_battle_participation(a)) &&
4095 if(source == state.local_player_nation) {
4103 memset(&p, 0,
sizeof(
payload));
4111 auto embarked = state.world.navy_get_army_transport(a);
4112 return state.world.navy_get_controller_from_navy_control(a) == source && !state.world.navy_get_is_retreating(a) &&
4113 embarked.begin() == embarked.end() && !bool(state.world.navy_get_battle_from_navy_battle_participation(a)) &&
4117 if(source == state.local_player_nation) {
4125 memset(&p, 0,
sizeof(
payload));
4133 return state.world.army_get_controller_from_army_control(a) == source && !state.world.army_get_is_retreating(a) &&
4134 !bool(state.world.army_get_battle_from_army_battle_participation(a)) &&
4136 (!l || state.world.leader_get_nation_from_leader_loyalty(l) == source);
4139 state.world.army_set_general_from_army_leadership(a, l);
4144 memset(&p, 0,
sizeof(
payload));
4152 return state.world.navy_get_controller_from_navy_control(a) == source && !state.world.navy_get_is_retreating(a) &&
4153 !bool(state.world.navy_get_battle_from_navy_battle_participation(a)) &&
4155 (!l || state.world.leader_get_nation_from_leader_loyalty(l) == source);
4158 state.world.navy_set_admiral_from_navy_leadership(a, l);
4162 std::array<dcon::regiment_id, num_packed_units>
const& list) {
4165 memset(&p, 0,
sizeof(
payload));
4175 state.world.army_get_controller_from_army_control(state.world.regiment_get_army_from_army_membership(regs[i]))) {
4176 state.world.regiment_set_pending_split(regs[i], !state.world.regiment_get_pending_split(regs[i]));
4184 memset(&p, 0,
sizeof(
payload));
4194 if(source == state.world.navy_get_controller_from_navy_control(state.world.ship_get_navy_from_navy_membership(regs[i]))) {
4195 state.world.ship_set_pending_split(regs[i], !state.world.ship_get_pending_split(regs[i]));
4203 memset(&p, 0,
sizeof(
payload));
4230 memset(&p, 0,
sizeof(
payload));
4257 dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag,
4258 dcon::nation_id cb_secondary_nation) {
4260 memset(&p, 0,
sizeof(
payload));
4272 dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag,
4273 dcon::nation_id cb_secondary_nation) {
4275 if(state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < 1.0f)
4280 if(source != state.primary_crisis_attacker && source != state.primary_crisis_defender)
4283 if(invitation_to == target || source == target)
4287 for(
auto& par : state.crisis_participants) {
4291 if(par.id == invitation_to) {
4292 if(par.merely_interested ==
false)
4299 for(
auto& par : state.crisis_participants) {
4303 if(par.id == target) {
4304 if(par.merely_interested)
4306 if(par.supports_attacker && source == state.primary_crisis_attacker)
4308 if(!par.supports_attacker && source == state.primary_crisis_defender)
4315 auto cb_type = state.world.cb_type_get_type_bits(primary_cb);
4326 if(state.world.nation_get_is_player_controlled(source) && state.world.nation_get_diplomatic_points(source) < 1.0f)
4329 state.world.nation_get_diplomatic_points(source) -= 1.0f;
4335 m.data.crisis_offer.target = data.
target;
4337 m.data.crisis_offer.wargoal_state = data.
cb_state;
4338 m.data.crisis_offer.wargoal_tag = data.
cb_tag;
4339 m.data.crisis_offer.wargoal_type = data.
cb_type;
4348 memset(&p, 0,
sizeof(
payload));
4355 if(state.world.nation_get_is_mobilized(source)) {
4364 memset(&p, 0,
sizeof(
payload));
4372 state.world.nation_set_is_debt_spending(source, debt_is_enabled);
4377 memset(&p, 0,
sizeof(
payload));
4387 if(state.world.nation_get_is_at_war(source))
4389 if(state.world.nation_get_capital(source) == p)
4391 if(state.world.province_get_is_colonial(p))
4393 if(state.world.province_get_continent(state.world.nation_get_capital(source)) != state.world.province_get_continent(p))
4397 if(state.world.province_get_siege_progress(p) > 0.f)
4399 if(state.world.province_get_siege_progress(state.world.nation_get_capital(source)) > 0.f)
4401 if(state.world.province_get_nation_from_province_ownership(p) != source)
4403 if(state.world.province_get_nation_from_province_control(p) != source)
4405 if(state.world.province_get_is_owner_core(p) ==
false)
4411 state.world.nation_set_capital(source, p);
4416 memset(&p, 0,
sizeof(
payload));
4424 auto& def = state.ui_defs.gui[d];
4429 if(!def.data.button.scriptable_enable)
4434 auto & def = state.ui_defs.gui[d];
4435 if(def.data.button.scriptable_effect)
4441 memset(&p, 0,
sizeof(
payload));
4449 auto& def = state.ui_defs.gui[d];
4454 if(!def.data.button.scriptable_enable)
4459 auto& def = state.ui_defs.gui[d];
4460 if(def.data.button.scriptable_effect)
4466 bool can_see =
true;
4467 if(
bool(m.target)) {
4468 can_see = state.local_player_nation == m.source || state.local_player_nation == m.target;
4471 state.ui_state.chat_messages[
state.ui_state.chat_messages_index++] =
m;
4472 if(
state.ui_state.chat_messages_index >=
state.ui_state.chat_messages.size())
4473 state.ui_state.chat_messages_index = 0;
4479 "msg_chat_message_title",
4480 m.source, dcon::nation_id{}, dcon::nation_id{},
4488 memset(&p, 0,
sizeof(
payload));
4504 m.body = std::string(body);
4505 post_chat_message(state, m);
4510 memset(&p, 0,
sizeof(
payload));
4521 state.world.nation_set_is_player_controlled(source,
true);
4522 state.network_state.map_of_player_names.insert_or_assign(source.index(), name);
4529 post_chat_message(state, m);
4532 if(state.current_scene.game_in_progress)
4538 memset(&p, 0,
sizeof(
payload));
4545 return state.world.nation_get_is_player_controlled(source);
4549 state.world.nation_set_is_player_controlled(source,
false);
4557 post_chat_message(state, m);
4562 memset(&p, 0,
sizeof(
payload));
4569 if(source == target)
4575 for(
auto& client : state.network_state.clients) {
4576 if(client.is_active() && client.playing_as == target) {
4581 state.world.nation_set_is_player_controlled(target,
false);
4588 post_chat_message(state, m);
4593 memset(&p, 0,
sizeof(
payload));
4600 if(source == target)
4606 for(
auto& client : state.network_state.clients) {
4607 if(client.is_active() && client.playing_as == target) {
4612 state.world.nation_set_is_player_controlled(target,
false);
4619 post_chat_message(state, m);
4624 memset(&p, 0,
sizeof(
payload));
4631 if(source == target)
4633 if(!
bool(target) || target == state.world.national_identity_get_nation_from_identity_holder(state.national_definitions.rebel_id))
4636 return state.world.nation_get_is_player_controlled(target) ==
false;
4639 assert(source && source != state.world.national_identity_get_nation_from_identity_holder(state.national_definitions.rebel_id));
4641 state.world.nation_set_is_player_controlled(source,
false);
4642 state.world.nation_set_is_player_controlled(target,
true);
4644 if(state.local_player_nation == source) {
4645 state.local_player_nation = target;
4648 for(
auto& msg : state.ui_state.chat_messages)
4649 if(
bool(msg.source) && msg.source == source)
4650 msg.source = target;
4655 memset(&p, 0,
sizeof(
payload));
4661 state.actual_game_speed = 0;
4662 state.debug_save_oos_dump();
4669 post_chat_message(state, m);
4674 memset(&p, 0,
sizeof(
payload));
4685 if(!state.network_state.out_of_sync) {
4686 if(state.current_date.to_ymd(state.start_date).day == 1 || state.cheat_data.daily_oos_check) {
4688 if(!current.is_equal(k)) {
4689 state.network_state.out_of_sync =
true;
4690 state.debug_save_oos_dump();
4694 state.actual_game_speed = speed;
4696 state.single_game_tick();
4701 memset(&p, 0,
sizeof(
payload));
4708 state.session_host_checksum = k;
4712 state.network_state.is_new_game =
false;
4713 state.network_state.out_of_sync =
false;
4714 state.network_state.reported_oos =
false;
4719 memset(&p, 0,
sizeof(
payload));
4725 state.session_host_checksum = k;
4729 state.network_state.is_new_game =
false;
4730 state.network_state.out_of_sync =
false;
4731 state.network_state.reported_oos =
false;
4733 std::vector<dcon::nation_id> players;
4734 for(
const auto n : state.world.in_nation)
4735 if(state.world.nation_get_is_player_controlled(n))
4736 players.push_back(n);
4737 dcon::nation_id old_local_player_nation = state.local_player_nation;
4739 size_t length = sizeof_save_section(state);
4740 auto save_buffer = std::unique_ptr<uint8_t[]>(
new uint8_t[length]);
4745 state.local_player_nation = dcon::nation_id{ };
4746 for(
const auto n : players)
4747 state.world.nation_set_is_player_controlled(n,
true);
4748 state.local_player_nation = old_local_player_nation;
4749 assert(state.world.nation_get_is_player_controlled(state.local_player_nation));
4750 state.fill_unsaved_data();
4751 assert(state.session_host_checksum.is_equal(state.get_save_checksum()));
4755 assert(state.world.nation_get_is_player_controlled(state.local_player_nation));
4756 state.selected_armies.clear();
4757 state.selected_navies.clear();
4758 for(
auto& v : state.ctrl_armies) v.clear();
4759 for(
auto& v : state.ctrl_navies) v.clear();
4761 state.network_state.current_save_buffer.reset();
4762 state.network_state.current_save_length = 0;
4764 for(
const auto n : state.world.in_nation)
4765 if(state.world.nation_get_is_player_controlled(n))
4768 state.map_state.set_selected_province(dcon::province_id{});
4769 state.map_state.unhandled_province_selection =
true;
4774 memset(&p, 0,
sizeof(
payload));
4782 state.map_state.set_selected_province(dcon::province_id{});
4783 state.map_state.unhandled_province_selection =
true;
4788 memset(&p, 0,
sizeof(
payload));
4795 state.actual_game_speed = 0;
4800 memset(&p, 0,
sizeof(
payload));
5525 auto* c = state.incoming_commands.front();
5526 bool command_executed =
false;
5528 command_executed =
true;
5530 state.incoming_commands.pop();
5531 c = state.incoming_commands.front();
5534 if(command_executed) {
5538 state.game_state_updated.store(
true, std::memory_order::release);
virtual int64_t main_data(size_t index) const override
std::unique_ptr< state_stack > interpreter_state
int32_t main_type(size_t index) const
#define assert(condition)
void remove_ai_data(sys::state &state, dcon::nation_id n)
bool can_state_transfer(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::state_definition_id sid)
void execute_abandon_colony(sys::state &state, dcon::nation_id source, dcon::province_id p)
bool can_increase_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
void execute_send_peace_offer(sys::state &state, dcon::nation_id source)
void execute_delete_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_release_and_play_as(sys::state &state, dcon::nation_id source, dcon::national_identity_id t)
bool can_cancel_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
void mark_ships_to_split(sys::state &state, dcon::nation_id source, std::array< dcon::ship_id, num_packed_units > const &list)
constexpr size_t num_packed_units
void execute_notify_player_oos(sys::state &state, dcon::nation_id source)
void execute_retreat_from_naval_battle(sys::state &state, dcon::nation_id source, dcon::naval_battle_id b)
void execute_toggle_mobilization(sys::state &state, dcon::nation_id source)
bool can_start_research(sys::state &state, dcon::nation_id source, dcon::technology_id tech)
bool can_release_subject(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_send_crisis_peace_offer(sys::state &state, dcon::nation_id source)
void execute_notify_player_kick(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_expel_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
void execute_decrease_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void execute_use_nation_button(sys::state &state, dcon::nation_id source, dcon::gui_def_id d, dcon::nation_id n)
void execute_add_war_goal(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
void start_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province)
void execute_take_sides_in_crisis(sys::state &state, dcon::nation_id source, bool join_attacker)
void enact_issue(sys::state &state, dcon::nation_id source, dcon::issue_option_id i)
void execute_expel_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
bool can_add_to_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
bool can_invite_to_crisis(sys::state &state, dcon::nation_id source, dcon::nation_id invitation_to, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
bool can_give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_add_war_goal(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
bool can_change_admiral(sys::state &state, dcon::nation_id source, dcon::navy_id a, dcon::leader_id l)
void execute_cancel_factory_building_construction(sys::state &state, dcon::nation_id source, dcon::state_instance_id location, dcon::factory_type_id type)
bool is_console_command(command_type t)
void execute_toggle_unit_ai_control(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_start_crisis_peace_offer(sys::state &state, dcon::nation_id source, bool is_concession)
bool can_give_military_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
void execute_ask_for_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
void execute_make_leader(sys::state &state, dcon::nation_id source, bool general)
void execute_call_to_arms(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::war_id w)
void execute_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void toggle_rebel_hunting(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_state_transfer(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::state_definition_id sid)
void execute_change_general(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::leader_id l)
bool can_cancel_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void execute_toggle_interested_in_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
void execute_change_stockpile_settings(sys::state &state, dcon::nation_id source, dcon::commodity_id c, float target_amount, bool draw_on_stockpiles)
bool can_cancel_factory_building_construction(sys::state &state, dcon::nation_id source, dcon::state_instance_id location, dcon::factory_type_id type)
bool can_notify_player_joins(sys::state &state, dcon::nation_id source, sys::player_name &name)
bool can_change_general(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::leader_id l)
bool can_intervene_in_war(sys::state &state, dcon::nation_id source, dcon::war_id w, bool for_attacker)
bool can_release_and_play_as(sys::state &state, dcon::nation_id source, dcon::national_identity_id t)
void execute_enable_debt(sys::state &state, dcon::nation_id source, bool debt_is_enabled)
bool can_delete_factory(sys::state &state, dcon::nation_id source, dcon::factory_id f)
bool can_begin_factory_building_construction(sys::state &state, dcon::nation_id source, dcon::state_instance_id location, dcon::factory_type_id type, bool is_upgrade)
void execute_toggle_immigrator_province(sys::state &state, dcon::nation_id source, dcon::province_id prov)
void give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_call_to_arms(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::war_id w, bool ignore_cost)
bool can_appoint_ruling_party(sys::state &state, dcon::nation_id source, dcon::political_party_id p)
void execute_begin_province_building_construction(sys::state &state, dcon::nation_id source, dcon::province_id p, economy::province_building_type type)
bool can_begin_province_building_construction(sys::state &state, dcon::nation_id source, dcon::province_id p, economy::province_building_type type)
bool can_start_election(sys::state &state, dcon::nation_id source)
bool can_delete_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void change_budget_settings(sys::state &state, dcon::nation_id source, budget_settings_data const &values)
bool can_start_crisis_peace_offer(sys::state &state, dcon::nation_id source, bool is_concession)
void execute_start_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province)
bool can_notify_player_leaves(sys::state &state, dcon::nation_id source, bool make_ai)
void execute_chat_message(sys::state &state, dcon::nation_id source, std::string_view body, dcon::nation_id target)
bool can_add_to_peace_offer(sys::state &state, dcon::nation_id source, dcon::wargoal_id goal)
bool can_ask_for_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
void execute_advance_tick(sys::state &state, dcon::nation_id source, sys::checksum_key &k, int32_t speed)
void execute_cancel_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type)
void execute_appoint_ruling_party(sys::state &state, dcon::nation_id source, dcon::political_party_id p)
bool can_change_factory_settings(sys::state &state, dcon::nation_id source, dcon::factory_id f, uint8_t priority, bool subsidized)
void execute_make_vassal(sys::state &state, dcon::nation_id source, dcon::national_identity_id t)
void start_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type, dcon::province_id template_province)
void use_nation_button(sys::state &state, dcon::nation_id source, dcon::gui_def_id d, dcon::nation_id n)
void execute_mark_regiments_to_split(sys::state &state, dcon::nation_id source, dcon::regiment_id const *regs)
void execute_add_to_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
void execute_intervene_in_war(sys::state &state, dcon::nation_id source, dcon::war_id w, bool for_attacker)
bool can_increase_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_cancel_cb_fabrication(sys::state &state, dcon::nation_id source)
void retreat_from_land_battle(sys::state &state, dcon::nation_id source, dcon::land_battle_id b)
void mark_regiments_to_split(sys::state &state, dcon::nation_id source, std::array< dcon::regiment_id, num_packed_units > const &list)
bool can_upgrade_colony_to_state(sys::state &state, dcon::nation_id source, dcon::state_instance_id si)
bool can_civilize_nation(sys::state &state, dcon::nation_id source)
bool can_set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
void evenly_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_retreat_from_land_battle(sys::state &state, dcon::nation_id source, dcon::land_battle_id b)
void execute_notify_player_picks_nation(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_use_province_button(sys::state &state, dcon::nation_id source, dcon::gui_def_id d, dcon::province_id p)
void release_and_play_as(sys::state &state, dcon::nation_id source, dcon::national_identity_id t)
void execute_upgrade_colony_to_state(sys::state &state, dcon::nation_id source, dcon::state_instance_id si)
void execute_cancel_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_enact_reform(sys::state &state, dcon::nation_id source, dcon::reform_option_id r)
void execute_change_factory_settings(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::factory_type_id type, uint8_t priority, bool subsidized)
void execute_release_subject(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void execute_set_rally_point(sys::state &state, dcon::nation_id source, dcon::province_id location, bool naval, bool enable)
void execute_make_event_choice(sys::state &state, dcon::nation_id source, pending_human_n_event_data const &e)
void execute_notify_player_leaves(sys::state &state, dcon::nation_id source, bool make_ai)
void execute_notify_player_ban(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_evenly_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_civilize_nation(sys::state &state, dcon::nation_id source)
bool can_abandon_colony(sys::state &state, dcon::nation_id source, dcon::province_id pr)
bool can_ban_embassy(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
void execute_invite_to_crisis(sys::state &state, dcon::nation_id source, crisis_invitation_data const &data)
void execute_retreat_from_land_battle(sys::state &state, dcon::nation_id source, dcon::land_battle_id b)
void execute_start_peace_offer(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::war_id war, bool is_concession)
bool can_decrease_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_move_capital(sys::state &state, dcon::nation_id source, dcon::province_id p)
void set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
void execute_give_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_start_peace_offer(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::war_id war, bool is_concession)
void execute_notify_player_joins(sys::state &state, dcon::nation_id source, sys::player_name &name)
bool can_notify_player_kick(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void execute_begin_factory_building_construction(sys::state &state, dcon::nation_id source, dcon::state_instance_id location, dcon::factory_type_id type, bool is_upgrade)
bool can_toggle_select_province(sys::state &state, dcon::nation_id source, dcon::province_id prov)
bool can_start_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type, dcon::province_id template_province)
void execute_finish_colonization(sys::state &state, dcon::nation_id source, dcon::province_id p)
void execute_console_command(sys::state &state)
void execute_change_admiral(sys::state &state, dcon::nation_id source, dcon::navy_id a, dcon::leader_id l)
void execute_remove_from_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
bool can_evenly_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
void execute_evenly_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
void execute_fabricate_cb(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id type)
void execute_respond_to_diplomatic_message(sys::state &state, dcon::nation_id source, dcon::nation_id from, diplomatic_message::type type, bool accept)
void execute_take_decision(sys::state &state, dcon::nation_id source, dcon::decision_id d)
void execute_notify_stop_game(sys::state &state, dcon::nation_id source)
void execute_send_crisis_peace_offer(sys::state &state, dcon::nation_id source)
void add_to_crisis_peace_offer(sys::state &state, dcon::nation_id source, dcon::nation_id wargoal_from, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
void execute_start_research(sys::state &state, dcon::nation_id source, dcon::technology_id tech)
void execute_enact_reform(sys::state &state, dcon::nation_id source, dcon::reform_option_id r)
void retreat_from_naval_battle(sys::state &state, dcon::nation_id source, dcon::naval_battle_id b)
void execute_embark_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_give_military_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
void execute_increase_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target)
bool can_partial_retreat_from(sys::state &state, dcon::land_battle_id b)
bool can_disband_undermanned_regiments(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_set_national_focus(sys::state &state, dcon::nation_id source, dcon::state_instance_id target_state, dcon::national_focus_id focus)
void execute_move_army(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::province_id dest, bool reset)
bool can_take_sides_in_crisis(sys::state &state, dcon::nation_id source, bool join_attacker)
void execute_evenly_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_mark_ships_to_split(sys::state &state, dcon::nation_id source, dcon::ship_id const *regs)
bool can_change_stockpile_settings(sys::state &state, dcon::nation_id source, dcon::commodity_id c, float target_amount, bool draw_on_stockpiles)
void disband_undermanned_regiments(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_take_decision(sys::state &state, dcon::nation_id source, dcon::decision_id d)
void enact_reform(sys::state &state, dcon::nation_id source, dcon::reform_option_id r)
bool can_make_leader(sys::state &state, dcon::nation_id source, bool general)
void execute_change_budget_settings(sys::state &state, dcon::nation_id source, budget_settings_data const &values)
bool can_send_peace_offer(sys::state &state, dcon::nation_id source)
void execute_invest_in_colony(sys::state &state, dcon::nation_id source, dcon::province_id pr)
void execute_start_election(sys::state &state, dcon::nation_id source)
bool can_cancel_land_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::culture_id soldier_culture, dcon::unit_type_id type)
void execute_merge_navies(sys::state &state, dcon::nation_id source, dcon::navy_id a, dcon::navy_id b)
void execute_add_to_peace_offer(sys::state &state, dcon::nation_id source, dcon::wargoal_id goal)
bool can_make_vassal(sys::state &state, dcon::nation_id source, dcon::national_identity_id t)
bool can_merge_navies(sys::state &state, dcon::nation_id source, dcon::navy_id a, dcon::navy_id b)
void notify_console_command(sys::state &state)
void execute_ban_embassy(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
bool can_discredit_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
void execute_notify_start_game(sys::state &state, dcon::nation_id source)
void execute_change_influence_priority(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, uint8_t priority)
bool can_add_to_crisis_peace_offer(sys::state &state, dcon::nation_id source, dcon::nation_id wargoal_from, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
bool can_cancel_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type)
void add_to_command_queue(sys::state &state, payload &p)
void execute_merge_armies(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::army_id b)
void execute_increase_relations(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void execute_enact_issue(sys::state &state, dcon::nation_id source, dcon::issue_option_id i)
bool can_remove_from_sphere(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
void execute_notify_reload(sys::state &state, dcon::nation_id source, sys::checksum_key &k)
void execute_cancel_alliance(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void execute_notify_pause_game(sys::state &state, dcon::nation_id source)
bool can_retreat_from_naval_battle(sys::state &state, dcon::nation_id source, dcon::naval_battle_id b)
bool can_change_budget_settings(sys::state &state, dcon::nation_id source, budget_settings_data const &values)
void execute_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
void execute_toggle_mobilized_is_ai_controlled(sys::state &state, dcon::nation_id source)
void execute_save_game(sys::state &state, dcon::nation_id source, bool and_quit)
void execute_become_interested_in_crisis(sys::state &state, dcon::nation_id source)
void execute_cancel_cb_fabrication(sys::state &state, dcon::nation_id source)
bool can_become_interested_in_crisis(sys::state &state, dcon::nation_id source)
bool can_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
void execute_discredit_advisors(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
bool can_decrease_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
@ ask_for_military_access
@ change_factory_settings
@ cancel_land_unit_construction
@ respond_to_diplomatic_message
@ cancel_given_military_access
@ add_wargoal_to_crisis_offer
@ toggle_immigrator_province
@ change_influence_priority
@ notify_player_picks_nation
@ designate_split_regiments
@ begin_naval_unit_construction
@ send_crisis_peace_offer
@ upgrade_colony_to_state
@ begin_province_building_construction
@ change_stockpile_settings
@ toggle_interested_in_alliance
@ toggle_mobilized_is_ai_controlled
@ cancel_naval_unit_construction
@ start_crisis_peace_offer
@ cancel_factory_building_construction
@ release_and_play_nation
@ become_interested_in_crisis
@ begin_land_unit_construction
@ begin_factory_building_construction
bool can_suppress_movement(sys::state &state, dcon::nation_id source, dcon::movement_id m)
void execute_use_province_button(sys::state &state, dcon::nation_id source, dcon::gui_def_id d, dcon::province_id p)
bool can_fabricate_cb(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id type)
bool can_delete_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
void use_province_button(sys::state &state, dcon::nation_id source, dcon::gui_def_id d, dcon::province_id i)
bool can_split_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_invest_in_colony(sys::state &state, dcon::nation_id source, dcon::province_id p)
bool can_chat_message(sys::state &state, dcon::nation_id source, std::string_view body, dcon::nation_id target)
void execute_move_navy(sys::state &state, dcon::nation_id source, dcon::navy_id n, dcon::province_id dest, bool reset)
void execute_cancel_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type)
bool can_cancel_alliance(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
bool can_notify_player_ban(sys::state &state, dcon::nation_id source, dcon::nation_id target)
void evenly_split_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
bool can_declare_war(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
void execute_add_to_crisis_peace_offer(sys::state &state, dcon::nation_id source, crisis_invitation_data const &data)
void execute_notify_save_loaded(sys::state &state, dcon::nation_id source, sys::checksum_key &k)
bool can_embark_army(sys::state &state, dcon::nation_id source, dcon::army_id a)
bool can_toggle_interested_in_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
void execute_move_capital(sys::state &state, dcon::nation_id source, dcon::province_id p)
void execute_toggle_select_province(sys::state &state, dcon::nation_id source, dcon::province_id prov)
void add_to_peace_offer(sys::state &state, dcon::nation_id source, dcon::wargoal_id goal)
bool can_use_nation_button(sys::state &state, dcon::nation_id source, dcon::gui_def_id d, dcon::nation_id n)
void execute_cancel_war_subsidies(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_merge_armies(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::army_id b)
void execute_suppress_movement(sys::state &state, dcon::nation_id source, dcon::issue_option_id iopt, dcon::national_identity_id tag)
void execute_delete_factory(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::factory_type_id type)
void execute_cancel_given_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_finish_colonization(sys::state &state, dcon::nation_id source, dcon::province_id p)
void execute_declare_war(sys::state &state, dcon::nation_id source, dcon::nation_id target, dcon::cb_type_id primary_cb, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation, bool call_attacker_allies)
std::vector< dcon::province_id > can_move_navy(sys::state &state, dcon::nation_id source, dcon::navy_id n, dcon::province_id dest)
void make_event_choice(sys::state &state, event::pending_human_n_event const &e, uint8_t option_id)
bool can_notify_player_picks_nation(sys::state &state, dcon::nation_id source, dcon::nation_id target)
bool can_perform_command(sys::state &state, payload &c)
bool can_enact_issue(sys::state &state, dcon::nation_id source, dcon::issue_option_id i)
bool can_change_influence_priority(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, uint8_t priority)
bool can_cancel_given_military_access(sys::state &state, dcon::nation_id source, dcon::nation_id target, bool ignore_cost)
bool can_toggle_immigrator_province(sys::state &state, dcon::nation_id source, dcon::province_id prov)
void execute_disband_undermanned_regiments(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_pending_commands(sys::state &state)
void execute_decrease_opinion(sys::state &state, dcon::nation_id source, dcon::nation_id influence_target, dcon::nation_id affected_gp)
void execute_start_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type, dcon::province_id template_province)
bool can_ask_for_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
void execute_command(sys::state &state, payload &c)
void execute_delete_navy(sys::state &state, dcon::nation_id source, dcon::navy_id a)
bool can_start_naval_unit_construction(sys::state &state, dcon::nation_id source, dcon::province_id location, dcon::unit_type_id type, dcon::province_id template_province)
void execute_toggle_rebel_hunting(sys::state &state, dcon::nation_id source, dcon::army_id a)
void execute_ask_for_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target)
std::vector< dcon::province_id > can_move_army(sys::state &state, dcon::nation_id source, dcon::army_id a, dcon::province_id dest)
constexpr uint64_t to_bits(dcon::ideology_id id)
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
void decline(sys::state &state, message const &m)
void accept(sys::state &state, message const &m)
void post(sys::state &state, message const &m)
void for_each_new_factory(sys::state &state, dcon::state_instance_id s, F &&func)
int32_t state_factory_count(sys::state &state, dcon::state_instance_id sid, dcon::nation_id n)
int32_t factory_priority(sys::state const &state, dcon::factory_id f)
void bound_budget_settings(sys::state &state, dcon::nation_id n)
void set_factory_priority(sys::state &state, dcon::factory_id f, int32_t priority)
void execute(sys::state &state, dcon::effect_key key, int32_t primary, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
void take_option(sys::state &state, pending_human_n_event const &e, uint8_t opt)
void update_future_events(sys::state &state)
void execute_fif_word(interpreted_word_instance &wi, state_stack &ss, environment &env)
void run_fif_interpreter(environment &env, std::string_view on_text)
void switch_scene(sys::state &state, scene_id ui_scene)
constexpr uint32_t build_factory
constexpr uint32_t can_subsidise
constexpr uint32_t destroy_factory
constexpr uint32_t allow_foreign_investment
constexpr uint32_t factory_priority
constexpr uint32_t expand_factory
constexpr uint32_t po_status_quo
constexpr uint32_t is_not_constructing_cb
constexpr uint32_t always
bool are_allied_in_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
float truce_break_cb_prestige_cost(sys::state &state, dcon::cb_type_id t)
bool cb_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb)
float primary_warscore(sys::state &state, dcon::war_id w)
float truce_break_cb_infamy(sys::state &state, dcon::cb_type_id t)
void send_rebel_hunter_to_next_province(sys::state &state, dcon::army_id ar, dcon::province_id prov)
void army_arrives_in_province(sys::state &state, dcon::army_id a, dcon::province_id p, crossing_type crossing, dcon::land_battle_id from)
void add_to_war(sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_attacker, bool on_war_creation)
float directed_warscore(sys::state &state, dcon::war_id w, dcon::nation_id primary, dcon::nation_id secondary)
void end_battle(sys::state &state, dcon::land_battle_id b, battle_result result)
dcon::pop_id find_available_soldier(sys::state &state, dcon::province_id p, dcon::culture_id pop_culture)
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
bool standard_war_joining_is_possible(sys::state &state, dcon::war_id wfor, dcon::nation_id n, bool as_attacker)
dcon::nation_id get_naval_battle_lead_defender(sys::state &state, dcon::naval_battle_id b)
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
bool can_retreat_from_battle(sys::state &state, dcon::naval_battle_id battle)
void update_battle_leaders(sys::state &state, dcon::land_battle_id b)
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
void cleanup_navy(sys::state &state, dcon::navy_id n)
bool joining_as_attacker_would_break_truce(sys::state &state, dcon::nation_id a, dcon::war_id w)
bool is_defender_wargoal(sys::state const &state, dcon::war_id w, dcon::wargoal_id wg)
dcon::nation_id get_land_battle_lead_attacker(sys::state &state, dcon::land_battle_id b)
void add_wargoal(sys::state &state, dcon::war_id wfor, dcon::nation_id added_by, dcon::nation_id target, dcon::cb_type_id type, dcon::state_definition_id sd, dcon::national_identity_id tag, dcon::nation_id secondary_nation)
bool can_embark_onto_sea_tile(sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
sys::date arrival_time_to(sys::state &state, dcon::army_id a, dcon::province_id p)
dcon::war_id create_war(sys::state &state, dcon::nation_id primary_attacker, dcon::nation_id primary_defender, dcon::cb_type_id primary_wargoal, dcon::state_definition_id primary_wargoal_state, dcon::national_identity_id primary_wargoal_tag, dcon::nation_id primary_wargoal_secondary)
dcon::nation_id get_naval_battle_lead_attacker(sys::state &state, dcon::naval_battle_id b)
bool cb_instance_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::state_definition_id st, dcon::national_identity_id tag, dcon::nation_id secondary)
float truce_break_cb_militancy(sys::state &state, dcon::cb_type_id t)
void start_mobilization(sys::state &state, dcon::nation_id n)
void call_attacker_allies(sys::state &state, dcon::war_id wfor)
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
bool defenders_have_non_status_quo_wargoal(sys::state const &state, dcon::war_id w)
void end_mobilization(sys::state &state, dcon::nation_id n)
dcon::leader_id make_new_leader(sys::state &state, dcon::nation_id n, bool is_general)
void cleanup_army(sys::state &state, dcon::army_id n)
bool joining_war_does_not_violate_constraints(sys::state const &state, dcon::nation_id a, dcon::war_id w, bool as_attacker)
void implement_peace_offer(sys::state &state, dcon::peace_offer_id offer)
void call_defender_allies(sys::state &state, dcon::war_id wfor)
bool is_civil_war(sys::state const &state, dcon::war_id w)
dcon::nation_id get_land_battle_lead_defender(sys::state &state, dcon::land_battle_id b)
bool defenders_have_status_quo_wargoal(sys::state const &state, dcon::war_id w)
bool war_goal_would_be_duplicate(sys::state &state, dcon::nation_id source, dcon::war_id w, dcon::nation_id target, dcon::cb_type_id cb_type, dcon::state_definition_id cb_state, dcon::national_identity_id cb_tag, dcon::nation_id cb_secondary_nation)
int32_t cost_of_peace_offer(sys::state &state, dcon::peace_offer_id offer)
float cb_addition_infamy_cost(sys::state &state, dcon::war_id war, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
dcon::navy_id find_embark_target(sys::state &state, dcon::nation_id from, dcon::province_id p, dcon::army_id a)
constexpr uint8_t is_banned
constexpr uint8_t level_friendly
uint8_t decrease_level(uint8_t v)
constexpr uint8_t is_discredited
constexpr uint8_t priority_zero
constexpr uint8_t level_opposed
constexpr uint8_t level_hostile
constexpr uint8_t priority_three
uint8_t increase_level(uint8_t v)
constexpr uint8_t priority_one
constexpr uint8_t level_in_sphere
constexpr uint8_t level_mask
int32_t get_level(sys::state &state, dcon::nation_id gp, dcon::nation_id target)
constexpr uint8_t priority_two
bool is_influence_level_greater_or_equal(int32_t l, int32_t r)
void remove_cores_from_owned(sys::state &state, dcon::nation_id n, dcon::national_identity_id tag)
void cleanup_crisis_peace_offer(sys::state &state, dcon::peace_offer_id peace)
bool is_great_power(sys::state const &state, dcon::nation_id id)
void enact_reform(sys::state &state, dcon::nation_id source, dcon::reform_option_id r)
void break_alliance(sys::state &state, dcon::diplomatic_relation_id rel)
bool can_release_as_vassal(sys::state const &state, dcon::nation_id n, dcon::national_identity_id releasable)
void adjust_prestige(sys::state &state, dcon::nation_id n, float delta)
bool is_involved_in_crisis(sys::state const &state, dcon::nation_id n)
void release_vassal(sys::state &state, dcon::overlord_id rel)
bool are_allied(sys::state &state, dcon::nation_id a, dcon::nation_id b)
void adjust_foreign_investment(sys::state &state, dcon::nation_id great_power, dcon::nation_id target, float delta)
void liberate_nation_from(sys::state &state, dcon::national_identity_id liberated, dcon::nation_id from)
void enact_issue(sys::state &state, dcon::nation_id source, dcon::issue_option_id i)
void update_cached_values(sys::state &state)
void make_civilized(sys::state &state, dcon::nation_id n)
void adjust_relationship(sys::state &state, dcon::nation_id a, dcon::nation_id b, float delta)
int32_t national_focuses_in_use(sys::state &state, dcon::nation_id n)
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
int32_t max_national_focuses(sys::state &state, dcon::nation_id n)
auto nation_accepts_culture(sys::state const &state, T ids, U cul_ids)
void kick_player(sys::state &state, client_data &client)
void switch_player(sys::state &state, dcon::nation_id new_n, dcon::nation_id old_n)
void ban_player(sys::state &state, client_data &client)
void post(sys::state &state, message &&m)
bool can_enact_social_reform(sys::state &state, dcon::nation_id n, dcon::issue_option_id o)
bool can_enact_political_reform(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
bool can_appoint_ruling_party(sys::state &state, dcon::nation_id nation)
bool political_party_is_active(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
bool can_enact_military_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
void appoint_ruling_party(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
void start_election(sys::state &state, dcon::nation_id n)
bool is_election_ongoing(sys::state &state, dcon::nation_id nation)
bool can_enact_economic_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
void set_militancy(sys::state &state, dcon::pop_id p, float v)
float get_militancy(sys::state const &state, dcon::pop_id p)
std::vector< dcon::province_id > make_land_path(sys::state &state, dcon::province_id start, dcon::province_id end, dcon::nation_id nation_as, dcon::army_id a)
void upgrade_colonial_state(sys::state &state, dcon::nation_id source, dcon::state_instance_id si)
bool can_build_railroads(sys::state &state, dcon::province_id id, dcon::nation_id n)
void update_connected_regions(sys::state &state)
bool has_access_to_province(sys::state &state, dcon::nation_id nation_as, dcon::province_id prov)
bool is_overseas(sys::state const &state, dcon::province_id ids)
bool is_colonizing(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
bool can_build_province_building(sys::state &state, dcon::province_id id, dcon::nation_id n, economy::province_building_type t)
bool can_integrate_colony(sys::state &state, dcon::state_instance_id id)
bool state_is_coastal(sys::state &state, dcon::state_instance_id s)
bool can_build_fort(sys::state &state, dcon::province_id id, dcon::nation_id n)
bool can_start_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
void update_cached_values(sys::state &state)
std::vector< dcon::province_id > make_naval_path(sys::state &state, dcon::province_id start, dcon::province_id end)
std::vector< dcon::province_id > make_unowned_land_path(sys::state &state, dcon::province_id start, dcon::province_id end)
bool can_invest_in_colony(sys::state &state, dcon::nation_id n, dcon::state_definition_id d)
bool has_naval_access_to_province(sys::state &state, dcon::nation_id nation_as, dcon::province_id prov)
bool can_build_naval_base(sys::state &state, dcon::province_id id, dcon::nation_id n)
void change_province_owner(sys::state &state, dcon::province_id id, dcon::nation_id new_owner)
void increase_colonial_investment(sys::state &state, dcon::nation_id source, dcon::state_definition_id state_def)
void suppress_movement(sys::state &state, dcon::nation_id n, dcon::movement_id m)
dcon::movement_id get_movement_by_independence(sys::state &state, dcon::nation_id n, dcon::national_identity_id i)
float get_suppression_point_cost(sys::state &state, dcon::movement_id m)
dcon::movement_id get_movement_by_position(sys::state &state, dcon::nation_id n, dcon::issue_option_id o)
void toggle_modifier_from_province(sys::state &state, dcon::province_id target_prov, dcon::modifier_id mod_id, sys::date expiration)
uint8_t * write_save_section(uint8_t *ptr_in, sys::state &state)
uint8_t const * read_save_section(uint8_t const *ptr_in, uint8_t const *section_end, sys::state &state)
void write_save_file(sys::state &state, save_type type, std::string const &name)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
int32_t to_generic(dcon::province_id v)
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
std::string format_fif_value(sys::state &state, int64_t data, int32_t type)
void effect_description(sys::state &state, text::layout_base &layout, dcon::effect_key k, int32_t primary_slot, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
constexpr uint32_t max_chat_message_len
void initialize_console_fif_environment(sys::state &state)
void close_window(sys::state &game_state)
sys::checksum_key checksum
int8_t domestic_investment
int8_t administrative_spending
int8_t construction_spending
int8_t education_spending
char body[ui::max_chat_message_len]
dcon::national_identity_id cb_tag
dcon::state_definition_id cb_state
dcon::nation_id cb_secondary_nation
dcon::state_instance_id location
dcon::factory_type_id type
dcon::province_id location
dcon::factory_type_id type
dcon::nation_id influence_target
dcon::nation_id gp_target
dcon::nation_id influence_target
dcon::culture_id pop_culture
dcon::province_id template_province
dcon::province_id location
diplomatic_message::type type
dcon::national_identity_id tag
dcon::issue_option_id iopt
dcon::national_focus_id focus
dcon::state_instance_id target_state
dcon::province_id template_province
dcon::province_id location
dcon::cb_type_id primary_cb
dcon::state_definition_id cb_state
dcon::national_identity_id cb_tag
bool call_attacker_allies
dcon::nation_id cb_secondary_nation
dcon::state_definition_id cb_state
dcon::nation_id cb_secondary_nation
dcon::national_identity_id cb_tag
sys::checksum_key checksum
sys::checksum_key checksum
union command::payload::dtype data
dcon::free_national_event_id e
dcon::free_provincial_event_id e
dcon::national_event_id e
dcon::provincial_event_id e
dcon::political_party_id p
dcon::province_id location
economy::province_building_type type
dcon::province_id location
dcon::regiment_id regs[num_packed_units]
dcon::ship_id ships[num_packed_units]
dcon::state_definition_id state
dcon::national_identity_id ident
static constexpr uint32_t set_size
dcon::free_national_event_id e
dcon::free_provincial_event_id e
dcon::national_event_id e
dcon::provincial_event_id e
war_target_data war_target
influence_priority_data influence_priority
rally_point_data rally_point
new_general_data new_general
pending_human_p_event_data pending_human_p_event
call_to_arms_data call_to_arms
naval_battle_data naval_battle
pending_human_f_p_event_data pending_human_f_p_event
army_movement_data army_movement
generic_location_data generic_location
budget_settings_data budget_data
split_regiments_data split_regiments
new_admiral_data new_admiral
split_ships_data split_ships
land_battle_data land_battle
nation_pick_data nation_pick
state_transfer_data state_transfer
national_focus_data nat_focus
influence_action_data influence_action
crisis_invitation_data crisis_invitation
pending_human_f_n_event_data pending_human_f_n_event
naval_unit_construction_data naval_unit_construction
new_war_goal_data new_war_goal
province_building_data start_province_building
crisis_join_data crisis_join
chat_message_data chat_message
political_party_data political_party
pending_human_n_event_data pending_human_n_event
diplo_action_data diplo_action
stockpile_settings_data stockpile_settings
notify_reload_data notify_reload
advance_tick_data advance_tick
navy_movement_data navy_movement
factory_building_data start_factory_building
land_unit_construction_data land_unit_construction
make_leader_data make_leader
notify_save_loaded_data notify_save_loaded
offer_wargoal_data offer_wargoal
tag_target_data tag_target
start_research_data start_research
cb_fabrication_data cb_fabrication
notify_leaves_data notify_leave
merge_navy_data merge_navy
reform_selection_data reform_selection
sys::player_name player_name
merge_army_data merge_army
issue_selection_data issue_selection