Project Alice
Loading...
Searching...
No Matches
fif_common.hpp
Go to the documentation of this file.
1#pragma once
2#include "fif.hpp"
3#include "politics.hpp"
4
5namespace fif {
6
7
8inline constexpr sys::year_month_day civil_from_days(int64_t z) noexcept {
9 z += 719468;
10 const int32_t era = int32_t((z >= 0 ? z : z - 146096) / 146097);
11 unsigned const doe = static_cast<unsigned>(z - era * 146097); // [0, 146096]
12 unsigned const yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; // [0, 399]
13 const int32_t y = static_cast<int32_t>(yoe) + era * 400;
14 unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100); // [0, 365]
15 unsigned const mp = (5 * doy + 2) / 153; // [0, 11]
16 unsigned const d = doy - (153 * mp + 2) / 5 + 1; // [1, 31]
17 unsigned const m = mp < 10 ? mp + 3 : mp - 9; // [1, 12]
18 return sys::year_month_day{ int32_t(y + (m <= 2)), uint16_t(m), uint16_t(d) };
19}
20
21inline int32_t f_date_to_year(int64_t v) {
22 return civil_from_days(v).year;
23}
24inline int32_t f_date_to_month(int64_t v) {
25 return int32_t(civil_from_days(v).month);
26}
27inline int32_t* f_date_to_year_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
30 return p + 2;
31 s.pop_main();
32 s.push_back_main(fif::fif_i32, 0, nullptr);
33 return p + 2;
34 }
35
36 auto r = f_date_to_year(s.main_data_back(0));
37 s.pop_main();
38 s.push_back_main(fif::fif_i32, r, nullptr);
39
40 return p + 2;
41}
42inline int32_t* f_date_to_month_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
45 return p + 2;
46 s.pop_main();
47 s.push_back_main(fif::fif_i32, 0, nullptr);
48 return p + 2;
49 }
50
51 auto r = f_date_to_month(s.main_data_back(0));
52 s.pop_main();
53 s.push_back_main(fif::fif_i32, r, nullptr);
54
55 return p + 2;
56}
57
58inline bool f_empty_adjacent_province(sys::state* state, int32_t p_index) {
59 dcon::province_id p{ dcon::province_id::value_base_t(p_index) };
60 for(auto a : state->world.province_get_province_adjacency(p)) {
61 auto other = a.get_connected_provinces(0) == p ? a.get_connected_provinces(1) : a.get_connected_provinces(0);
62 if(other.get_nation_from_province_ownership() == dcon::nation_id() && other.id.index() < state->province_definitions.first_sea_province.index())
63 return true;
64 }
65 return false;
66}
70 return p + 2;
71 s.pop_main();
72 s.pop_main();
73 s.push_back_main(fif::fif_bool, 0, nullptr);
74 return p + 2;
75 }
76
77 sys::state* state = (sys::state*)(s.main_data_back(0));
78 s.pop_main();
79 int32_t index = int32_t(s.main_data_back(0));
80 s.pop_main();
81
83
84 return p + 2;
85}
86inline bool f_empty_adjacent_state(sys::state* state, int32_t p_index) {
87 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(p_index) };
88 auto owner = state->world.state_instance_get_nation_from_state_ownership(s);
89 for(auto p : state->world.state_instance_get_definition(s).get_abstract_state_membership()) {
90 if(p.get_province().get_nation_from_province_ownership() == owner) {
91 for(auto a : p.get_province().get_province_adjacency()) {
92 auto other = a.get_connected_provinces(0) == p.get_province() ? a.get_connected_provinces(1) : a.get_connected_provinces(0);
93 if(other.get_nation_from_province_ownership() == dcon::nation_id() && other.id.index() < state->province_definitions.first_sea_province.index())
94 return true;
95 }
96 }
97 }
98 return false;
99}
100inline int32_t* f_empty_adjacent_state_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
103 return p + 2;
104 s.pop_main();
105 s.pop_main();
106 s.push_back_main(fif::fif_bool, 0, nullptr);
107 return p + 2;
108 }
109
110 sys::state* state = (sys::state*)(s.main_data_back(0));
111 s.pop_main();
112 int32_t index = int32_t(s.main_data_back(0));
113 s.pop_main();
114
115 s.push_back_main(fif::fif_bool, f_empty_adjacent_state(state, index), nullptr);
116
117 return p + 2;
118}
119
120
121template<typename F>
122class f_true_accumulator : public F {
123private:
124 ve::tagged_vector<int32_t> value;
125 uint32_t index = 0;
126 int32_t accumulated_mask = 0;
127
128public:
129 bool result = false;
130
131 f_true_accumulator(F&& f) : F(std::move(f)) { }
132
133 inline void add_value(int32_t v) {
134 if(!result) {
135 accumulated_mask |= (int32_t(v != -1) << index);
136 value.set(index++, v);
137
138 if(index == ve::vector_size) {
139 result = (ve::compress_mask(F::operator()(value)).v & accumulated_mask) != 0;
140 value = ve::tagged_vector<int32_t>();
141 index = 0;
142 accumulated_mask = 0;
143 }
144 }
145 }
146 inline void flush() {
147 if(index != 0 && !result) {
148 result = (ve::compress_mask(F::operator()(value)).v & accumulated_mask) != 0;
149 index = 0;
150 }
151 }
152};
153
154template<typename F>
156 return f_true_accumulator<F>(std::forward<F>(f));
157}
158
159
160inline bool f_unowned_core(sys::state* state, int32_t n_index) {
161 dcon::nation_id n{ dcon::nation_id::value_base_t(n_index) };
162 auto nation_tag = state->world.nation_get_identity_from_identity_holder(n);
163
164 auto acc = f_make_true_accumulator([state, n](ve::tagged_vector<int32_t> v) {
165 auto owners = state->world.province_get_nation_from_province_ownership(trigger::to_prov(v));
166 return owners != n;
167 });
168
169 for(auto p : state->world.national_identity_get_core(nation_tag)) {
170 acc.add_value(trigger::to_generic(p.get_province().id));
171 if(acc.result)
172 return true;
173 }
174
175 acc.flush();
176 return acc.result;
177}
178inline int32_t* f_unowned_core_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
181 return p + 2;
182 s.pop_main();
183 s.pop_main();
184 s.push_back_main(fif::fif_bool, 0, nullptr);
185 return p + 2;
186 }
187
188 sys::state* state = (sys::state*)(s.main_data_back(0));
189 s.pop_main();
190 int32_t index = int32_t(s.main_data_back(0));
191 s.pop_main();
192
193 s.push_back_main(fif::fif_bool, f_unowned_core(state, index), nullptr);
194
195 return p + 2;
196}
197inline bool f_core_in_nation(sys::state* state, int32_t n_index, int32_t t_index) {
198 dcon::nation_id n{ dcon::nation_id::value_base_t(n_index) };
199 dcon::national_identity_id t{ dcon::national_identity_id::value_base_t(t_index) };
200
201 for(auto p : state->world.nation_get_province_ownership(n)) {
202 if(state->world.get_core_by_prov_tag_key(p.get_province(), t))
203 return true;
204 }
205 return false;
206}
207inline int32_t* f_core_in_nation_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
210 return p + 2;
211 s.pop_main();
212 s.pop_main();
213 s.pop_main();
214 s.push_back_main(fif::fif_bool, 0, nullptr);
215 return p + 2;
216 }
217
218 sys::state* state = (sys::state*)(s.main_data_back(0));
219 s.pop_main();
220 int32_t nindex = int32_t(s.main_data_back(0));
221 s.pop_main();
222 int32_t tindex = int32_t(s.main_data_back(0));
223 s.pop_main();
224
225 s.push_back_main(fif::fif_bool, f_core_in_nation(state, nindex, tindex), nullptr);
226
227 return p + 2;
228}
229inline bool f_core_in_province(sys::state* state, int32_t p_index, int32_t t_index) {
230 dcon::province_id p{ dcon::province_id::value_base_t(p_index) };
231 dcon::national_identity_id t{ dcon::national_identity_id::value_base_t(t_index) };
232
233 auto core = state->world.get_core_by_prov_tag_key(p, t);
234 return bool(core);
235}
236inline int32_t* f_core_in_province_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
239 return p + 2;
240 s.pop_main();
241 s.pop_main();
242 s.pop_main();
243 s.push_back_main(fif::fif_bool, 0, nullptr);
244 return p + 2;
245 }
246
247 sys::state* state = (sys::state*)(s.main_data_back(0));
248 s.pop_main();
249 int32_t nindex = int32_t(s.main_data_back(0));
250 s.pop_main();
251 int32_t tindex = int32_t(s.main_data_back(0));
252 s.pop_main();
253
254 s.push_back_main(fif::fif_bool, f_core_in_province(state, nindex, tindex), nullptr);
255
256 return p + 2;
257}
258inline bool f_core_in_state(sys::state* state, int32_t s_index, int32_t t_index) {
259 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(s_index) };
260 dcon::national_identity_id t{ dcon::national_identity_id::value_base_t(t_index) };
261
262 auto ab = state->world.state_instance_get_definition(s);
263 for(auto p : state->world.state_definition_get_abstract_state_membership(ab)) {
264 if(state->world.get_core_by_prov_tag_key(p.get_province(), t))
265 return true;
266 }
267 return false;
268}
269inline int32_t* f_core_in_state_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
272 return p + 2;
273 s.pop_main();
274 s.pop_main();
275 s.pop_main();
276 s.push_back_main(fif::fif_bool, 0, nullptr);
277 return p + 2;
278 }
279
280 sys::state* state = (sys::state*)(s.main_data_back(0));
281 s.pop_main();
282 int32_t nindex = int32_t(s.main_data_back(0));
283 s.pop_main();
284 int32_t tindex = int32_t(s.main_data_back(0));
285 s.pop_main();
286
287 s.push_back_main(fif::fif_bool, f_core_in_state(state, nindex, tindex), nullptr);
288
289 return p + 2;
290}
291inline bool f_core_fully_state(sys::state* state, int32_t s_index, int32_t t_index) {
292 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(s_index) };
293 dcon::national_identity_id t{ dcon::national_identity_id::value_base_t(t_index) };
294
295 auto ab = state->world.state_instance_get_definition(s);
296 for(auto p : state->world.state_definition_get_abstract_state_membership(ab)) {
297 if(!bool(state->world.get_core_by_prov_tag_key(p.get_province(), t)))
298 return false;
299 }
300 return true;
301}
302inline int32_t* f_core_fully_state_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
305 return p + 2;
306 s.pop_main();
307 s.pop_main();
308 s.pop_main();
309 s.push_back_main(fif::fif_bool, 0, nullptr);
310 return p + 2;
311 }
312
313 sys::state* state = (sys::state*)(s.main_data_back(0));
314 s.pop_main();
315 int32_t nindex = int32_t(s.main_data_back(0));
316 s.pop_main();
317 int32_t tindex = int32_t(s.main_data_back(0));
318 s.pop_main();
319
320 s.push_back_main(fif::fif_bool, f_core_fully_state(state, nindex, tindex), nullptr);
321
322 return p + 2;
323}
324inline bool f_has_cb_against(sys::state* state, int32_t targ_index, int32_t source_index) {
325 dcon::nation_id s{ dcon::nation_id::value_base_t(source_index) };
326 dcon::nation_id t{ dcon::nation_id::value_base_t(targ_index) };
327 return military::can_use_cb_against(*state, s, t);
328}
329inline int32_t* f_has_cb_against_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
332 return p + 2;
333 s.pop_main();
334 s.pop_main();
335 s.pop_main();
336 s.push_back_main(fif::fif_bool, 0, nullptr);
337 return p + 2;
338 }
339
340 sys::state* state = (sys::state*)(s.main_data_back(0));
341 s.pop_main();
342 int32_t nindex = int32_t(s.main_data_back(0));
343 s.pop_main();
344 int32_t tindex = int32_t(s.main_data_back(0));
345 s.pop_main();
346
347 s.push_back_main(fif::fif_bool, f_has_cb_against(state, nindex, tindex), nullptr);
348
349 return p + 2;
350}
351inline bool f_has_access_with(sys::state* state, int32_t targ_index, int32_t source_index) {
352 dcon::nation_id s{ dcon::nation_id::value_base_t(source_index) };
353 dcon::nation_id t{ dcon::nation_id::value_base_t(targ_index) };
354 if(auto p = state->world.get_unilateral_relationship_by_unilateral_pair(t, s); p) {
355 return state->world.unilateral_relationship_get_military_access(p);
356 }
357 return false;
358}
359inline int32_t* f_has_access_with_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
362 return p + 2;
363 s.pop_main(); s.pop_main(); s.pop_main();
364 s.push_back_main(fif::fif_bool, 0, nullptr);
365 return p + 2;
366 }
367
368 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
369 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
370 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
371
372 s.push_back_main(fif::fif_bool, f_has_access_with(state, nindex, tindex), nullptr);
373
374 return p + 2;
375}
376inline bool f_has_any_factory(sys::state* state, int32_t s_index) {
377 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(s_index) };
378 return economy::has_factory(*state, s);
379}
380inline int32_t* f_has_any_factory_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
383 return p + 2;
384 s.pop_main(); s.pop_main();
385 s.push_back_main(fif::fif_bool, 0, nullptr);
386 return p + 2;
387 }
388
389 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
390 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
391
392 s.push_back_main(fif::fif_bool, f_has_any_factory(state, nindex), nullptr);
393
394 return p + 2;
395}
396inline bool f_has_factory(sys::state* state, int32_t findex, int32_t s_index) {
397 dcon::factory_type_id f{ dcon::factory_type_id::value_base_t(findex) };
398 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(s_index) };
399 return economy::has_building(*state, s, f);
400}
401inline int32_t* f_has_factory_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
404 return p + 2;
405 s.pop_main(); s.pop_main(); s.pop_main();
406 s.push_back_main(fif::fif_bool, 0, nullptr);
407 return p + 2;
408 }
409
410 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
411 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
412 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
413
414 s.push_back_main(fif::fif_bool, f_has_factory(state, nindex, tindex), nullptr);
415
416 return p + 2;
417}
418inline bool f_has_nmod(sys::state* state, int32_t m_index, int32_t n_index) {
419 dcon::modifier_id f{ dcon::modifier_id::value_base_t(m_index) };
420 dcon::nation_id s{ dcon::nation_id::value_base_t(n_index) };
421 for(auto m : state->world.nation_get_current_modifiers(s)) {
422 if(m.mod_id == f)
423 return true;
424 }
425 return false;
426}
427inline int32_t* f_has_nmod_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
430 return p + 2;
431 s.pop_main(); s.pop_main(); s.pop_main();
432 s.push_back_main(fif::fif_bool, 0, nullptr);
433 return p + 2;
434 }
435
436 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
437 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
438 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
439
440 s.push_back_main(fif::fif_bool, f_has_nmod(state, nindex, tindex), nullptr);
441
442 return p + 2;
443}
444inline bool f_has_pmod(sys::state* state, int32_t m_index, int32_t p_index) {
445 dcon::modifier_id f{ dcon::modifier_id::value_base_t(m_index) };
446 dcon::province_id s{ dcon::province_id::value_base_t(p_index) };
447 for(auto m : state->world.province_get_current_modifiers(s)) {
448 if(m.mod_id == f)
449 return true;
450 }
451 return false;
452}
453inline int32_t* f_has_pmod_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
456 return p + 2;
457 s.pop_main(); s.pop_main(); s.pop_main();
458 s.push_back_main(fif::fif_bool, 0, nullptr);
459 return p + 2;
460 }
461
462 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
463 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
464 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
465
466 s.push_back_main(fif::fif_bool, f_has_pmod(state, nindex, tindex), nullptr);
467
468 return p + 2;
469}
470inline bool f_in_region(sys::state* state, int32_t rindex, int32_t p_index) {
471 dcon::region_id f{ dcon::region_id::value_base_t(rindex) };
472 dcon::province_id s{ dcon::province_id::value_base_t(p_index) };
473 for(auto m : state->world.province_get_region_membership(s)) {
474 if(m.get_region() == f)
475 return true;
476 }
477 return false;
478}
479inline int32_t* f_in_region_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
482 return p + 2;
483 s.pop_main(); s.pop_main(); s.pop_main();
484 s.push_back_main(fif::fif_bool, 0, nullptr);
485 return p + 2;
486 }
487
488 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
489 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
490 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
491
492 s.push_back_main(fif::fif_bool, f_in_region(state, nindex, tindex), nullptr);
493
494 return p + 2;
495}
496inline bool f_owns_region(sys::state* state, int32_t rindex, int32_t n_index) {
497 dcon::region_id f{ dcon::region_id::value_base_t(rindex) };
498 dcon::nation_id s{ dcon::nation_id::value_base_t(n_index) };
499 for(auto m : state->world.region_get_region_membership(f)) {
500 if(m.get_province().get_nation_from_province_ownership() != s)
501 return false;
502 }
503 return true;
504}
505inline int32_t* f_owns_region_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
508 return p + 2;
509 s.pop_main(); s.pop_main(); s.pop_main();
510 s.push_back_main(fif::fif_bool, 0, nullptr);
511 return p + 2;
512 }
513
514 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
515 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
516 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
517
518 s.push_back_main(fif::fif_bool, f_owns_region(state, nindex, tindex), nullptr);
519
520 return p + 2;
521}
522inline bool f_owns_state(sys::state* state, int32_t rindex, int32_t n_index) {
523 dcon::state_definition_id f{ dcon::state_definition_id::value_base_t(rindex) };
524 dcon::nation_id s{ dcon::nation_id::value_base_t(n_index) };
525 for(auto m : state->world.state_definition_get_abstract_state_membership(f)) {
526 if(m.get_province().get_nation_from_province_ownership() != s)
527 return false;
528 }
529 return true;
530}
531inline int32_t* f_owns_state_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
534 return p + 2;
535 s.pop_main(); s.pop_main(); s.pop_main();
536 s.push_back_main(fif::fif_bool, 0, nullptr);
537 return p + 2;
538 }
539
540 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
541 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
542 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
543
544 s.push_back_main(fif::fif_bool, f_owns_state(state, nindex, tindex), nullptr);
545
546 return p + 2;
547}
548inline bool f_nation_a(sys::state* state, int32_t aindex, int32_t bindex) {
549 dcon::nation_id a{ dcon::nation_id::value_base_t(aindex) };
550 dcon::nation_id b{ dcon::nation_id::value_base_t(bindex) };
551 return bool(state->world.get_nation_adjacency_by_nation_adjacency_pair(a, b));
552}
553inline int32_t* f_nation_a_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
556 return p + 2;
557 s.pop_main(); s.pop_main(); s.pop_main();
558 s.push_back_main(fif::fif_bool, 0, nullptr);
559 return p + 2;
560 }
561
562 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
563 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
564 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
565
566 s.push_back_main(fif::fif_bool, f_nation_a(state, nindex, tindex), nullptr);
567
568 return p + 2;
569}
570inline bool f_units_in_state(sys::state* state, int32_t sindex, int32_t nindex) {
571 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(sindex) };
572 dcon::nation_id n{ dcon::nation_id::value_base_t(nindex) };
573
574 for(auto p : state->world.state_definition_get_abstract_state_membership(state->world.state_instance_get_definition(s))) {
575 if(p.get_province().get_state_membership() == s) {
576 for(auto a : state->world.province_get_army_location(p.get_province())) {
577 if(a.get_army().get_controller_from_army_control() == n)
578 return true;
579 }
580 }
581 }
582 return false;
583}
584inline int32_t* f_units_in_state_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
587 return p + 2;
588 s.pop_main(); s.pop_main(); s.pop_main();
589 s.push_back_main(fif::fif_bool, 0, nullptr);
590 return p + 2;
591 }
592
593 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
594 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
595 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
596
597 s.push_back_main(fif::fif_bool, f_units_in_state(state, nindex, tindex), nullptr);
598
599 return p + 2;
600}
601inline bool f_units_in_province(sys::state* state, int32_t sindex, int32_t nindex) {
602 dcon::province_id s{ dcon::province_id::value_base_t(sindex) };
603 dcon::nation_id n{ dcon::nation_id::value_base_t(nindex) };
604
605 for(auto a : state->world.province_get_army_location(s)) {
606 if(a.get_army().get_controller_from_army_control() == n)
607 return true;
608 }
609 return false;
610}
611inline int32_t* f_units_in_province_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
614 return p + 2;
615 s.pop_main(); s.pop_main(); s.pop_main();
616 s.push_back_main(fif::fif_bool, 0, nullptr);
617 return p + 2;
618 }
619
620 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
621 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
622 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
623
624 s.push_back_main(fif::fif_bool, f_units_in_province(state, nindex, tindex), nullptr);
625
626 return p + 2;
627}
628inline int32_t f_count_p_units(sys::state* state, int32_t sindex) {
629 dcon::province_id s{ dcon::province_id::value_base_t(sindex) };
630
631 int32_t total = 0;
632 for(auto a : state->world.province_get_army_location(s)) {
633 auto mrange = a.get_army().get_army_membership();
634 total += int32_t(mrange.end() - mrange.begin());
635 }
636 return total;
637}
638inline int32_t* f_count_p_units_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
641 return p + 2;
642 s.pop_main(); s.pop_main();
643 s.push_back_main(fif::fif_i32, 0, nullptr);
644 return p + 2;
645 }
646
647 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
648 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
649
650 s.push_back_main(fif::fif_i32, f_count_p_units(state, nindex), nullptr);
651
652 return p + 2;
653}
654inline bool f_are_at_war(sys::state* state, int32_t sindex, int32_t nindex) {
655 dcon::nation_id s{ dcon::nation_id::value_base_t(sindex) };
656 dcon::nation_id n{ dcon::nation_id::value_base_t(nindex) };
657 return military::are_at_war(*state, s, n);
658}
659inline int32_t* f_are_at_war_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
662 return p + 2;
663 s.pop_main(); s.pop_main(); s.pop_main();
664 s.push_back_main(fif::fif_bool, 0, nullptr);
665 return p + 2;
666 }
667
668 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
669 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
670 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
671
672 s.push_back_main(fif::fif_bool, f_units_in_province(state, nindex, tindex), nullptr);
673
674 return p + 2;
675}
676inline bool f_general_in_p(sys::state* state, int32_t sindex) {
677 dcon::province_id s{ dcon::province_id::value_base_t(sindex) };
678 for(const auto ar : state->world.province_get_army_location(s)) {
679 if(state->world.army_leadership_get_general(state->world.army_get_army_leadership(state->world.army_location_get_army(ar)))) {
680 return true;
681 }
682 }
683 return false;
684}
685inline int32_t* f_general_in_p_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
688 return p + 2;
689 s.pop_main(); s.pop_main();
690 s.push_back_main(fif::fif_bool, 0, nullptr);
691 return p + 2;
692 }
693
694 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
695 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
696
697 s.push_back_main(fif::fif_bool, f_general_in_p(state, nindex), nullptr);
698
699 return p + 2;
700}
701inline int32_t f_count_ships(sys::state* state, int32_t sindex) {
702 dcon::nation_id s{ dcon::nation_id::value_base_t(sindex) };
703
704 int32_t total = 0;
705 for(auto a : state->world.nation_get_navy_control(s)) {
706 auto mrange = a.get_navy().get_navy_membership();
707 total += int32_t(mrange.end() - mrange.begin());
708 }
709 return total;
710}
711inline int32_t* f_count_ships_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
714 return p + 2;
715 s.pop_main(); s.pop_main();
716 s.push_back_main(fif::fif_i32, 0, nullptr);
717 return p + 2;
718 }
719
720 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
721 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
722
723 s.push_back_main(fif::fif_i32, f_count_ships(state, nindex), nullptr);
724
725 return p + 2;
726}
727inline bool f_coastal_s(sys::state* state, int32_t sindex) {
728 dcon::state_instance_id s{ dcon::state_instance_id::value_base_t(sindex) };
729 return province::state_is_coastal(*state, s);
730}
731inline int32_t* f_coastal_s_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
734 return p + 2;
735 s.pop_main(); s.pop_main();
736 s.push_back_main(fif::fif_bool, 0, nullptr);
737 return p + 2;
738 }
739
740 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
741 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
742
743 s.push_back_main(fif::fif_bool, f_coastal_s(state, nindex), nullptr);
744
745 return p + 2;
746}
747inline bool f_state_produces(sys::state* state, int32_t cindex, int32_t sindex) {
748 dcon::commodity_id c{ dcon::commodity_id::value_base_t(cindex) };
749 dcon::state_instance_id si{ dcon::state_instance_id::value_base_t(sindex) };
750
751 auto o = state->world.state_instance_get_nation_from_state_ownership(si);
752 auto d = state->world.state_instance_get_definition(si);
753 for(auto p : state->world.state_definition_get_abstract_state_membership(d)) {
754 if(p.get_province().get_nation_from_province_ownership() == o) {
755 if(p.get_province().get_rgo() == c)
756 return true;
757 for(auto f : p.get_province().get_factory_location()) {
758 if(f.get_factory().get_building_type().get_output() == c)
759 return true;
760 }
761 }
762 }
763
764 return false;
765}
766inline int32_t* f_state_produces_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
769 return p + 2;
770 s.pop_main(); s.pop_main(); s.pop_main();
771 s.push_back_main(fif::fif_bool, 0, nullptr);
772 return p + 2;
773 }
774
775 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
776 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
777 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
778
779 s.push_back_main(fif::fif_bool, f_state_produces(state, nindex, tindex), nullptr);
780
781 return p + 2;
782}
783inline bool f_has_culture_core(sys::state* state, int32_t cindex, int32_t sindex) {
784 dcon::culture_id c{ dcon::culture_id::value_base_t(cindex) };
785 dcon::province_id p{ dcon::province_id::value_base_t(sindex) };
786
787 for(auto co : state->world.province_get_core(p)) {
788 if(co.get_identity().get_primary_culture() == c)
789 return true;
790 }
791 return false;
792}
793inline int32_t* f_has_culture_core_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
796 return p + 2;
797 s.pop_main(); s.pop_main(); s.pop_main();
798 s.push_back_main(fif::fif_bool, 0, nullptr);
799 return p + 2;
800 }
801
802 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
803 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
804 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
805
806 s.push_back_main(fif::fif_bool, f_has_culture_core(state, nindex, tindex), nullptr);
807
808 return p + 2;
809}
810inline bool f_canal_enabled(sys::state* state, int32_t sindex) {
811 return (state->world.province_adjacency_get_type(state->province_definitions.canals[sindex]) & province::border::impassible_bit) == 0;
812}
813inline int32_t* f_canal_enabled_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
816 return p + 2;
817 s.pop_main(); s.pop_main();
818 s.push_back_main(fif::fif_bool, 0, nullptr);
819 return p + 2;
820 }
821
822 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
823 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
824
825 s.push_back_main(fif::fif_bool, f_canal_enabled(state, nindex), nullptr);
826
827 return p + 2;
828}
829inline bool f_truce_with(sys::state* state, int32_t tindex, int32_t sindex) {
830 dcon::nation_id target{ dcon::nation_id::value_base_t(tindex) };
831 dcon::nation_id source{ dcon::nation_id::value_base_t(sindex) };
832
833 return military::has_truce_with(*state, source, target);
834}
835inline int32_t* f_truce_with_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
838 return p + 2;
839 s.pop_main(); s.pop_main(); s.pop_main();
840 s.push_back_main(fif::fif_bool, 0, nullptr);
841 return p + 2;
842 }
843
844 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
845 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
846 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
847
848 s.push_back_main(fif::fif_bool, f_truce_with(state, nindex, tindex), nullptr);
849
850 return p + 2;
851}
852inline bool f_has_named_leader(sys::state* state, int32_t name, int32_t nindex) {
853 dcon::nation_id n{ dcon::nation_id::value_base_t(nindex) };
854 dcon::unit_name_id t{ dcon::unit_name_id::value_base_t(name) };
855
856 for(auto l : state->world.nation_get_leader_loyalty(n)) {
857 auto lname = l.get_leader().get_name();
858 if(state->to_string_view(lname) == state->to_string_view(t))
859 return true;
860 }
861 return false;
862}
863inline int32_t* f_has_named_leader_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
866 return p + 2;
867 s.pop_main(); s.pop_main(); s.pop_main();
868 s.push_back_main(fif::fif_bool, 0, nullptr);
869 return p + 2;
870 }
871
872 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
873 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
874 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
875
876 s.push_back_main(fif::fif_bool, f_has_named_leader(state, nindex, tindex), nullptr);
877
878 return p + 2;
879}
880inline bool f_can_release(sys::state* state, int32_t tindex, int32_t nindex) {
881 dcon::nation_id n{ dcon::nation_id::value_base_t(nindex) };
882 dcon::national_identity_id t{ dcon::national_identity_id::value_base_t(tindex) };
883 return nations::can_release_as_vassal(*state, n, t);
884}
885inline int32_t* f_can_release_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
888 return p + 2;
889 s.pop_main(); s.pop_main(); s.pop_main();
890 s.push_back_main(fif::fif_bool, 0, nullptr);
891 return p + 2;
892 }
893
894 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
895 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
896 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
897
898 s.push_back_main(fif::fif_bool, f_can_release(state, nindex, tindex), nullptr);
899
900 return p + 2;
901}
902inline bool f_are_allied(sys::state* state, int32_t tindex, int32_t sindex) {
903 dcon::nation_id target{ dcon::nation_id::value_base_t(tindex) };
904 dcon::nation_id source{ dcon::nation_id::value_base_t(sindex) };
905
906 return nations::are_allied(*state, source, target);
907}
908inline int32_t* f_are_allied_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
911 return p + 2;
912 s.pop_main(); s.pop_main(); s.pop_main();
913 s.push_back_main(fif::fif_bool, 0, nullptr);
914 return p + 2;
915 }
916
917 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
918 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
919 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
920
921 s.push_back_main(fif::fif_bool, f_are_allied(state, nindex, tindex), nullptr);
922 return p + 2;
923}
924inline bool f_nation_has_any_factory(sys::state* state, int32_t s_index) {
925 dcon::nation_id s{ dcon::nation_id::value_base_t(s_index) };
926 for(auto p : state->world.nation_get_province_ownership(s)) {
927 auto rng = p.get_province().get_factory_location();
928 if(rng.begin() != rng.end())
929 return true;
930 }
931 return false;
932}
936 return p + 2;
937 s.pop_main(); s.pop_main();
938 s.push_back_main(fif::fif_bool, 0, nullptr);
939 return p + 2;
940 }
941
942 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
943 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
944
945 s.push_back_main(fif::fif_bool, f_nation_has_any_factory(state, nindex), nullptr);
946 return p + 2;
947}
948inline bool f_is_bankrupt_debtor_to(sys::state* state, int32_t tindex, int32_t sindex) {
949 dcon::nation_id target{ dcon::nation_id::value_base_t(tindex) };
950 dcon::nation_id source{ dcon::nation_id::value_base_t(sindex) };
951
952 return economy::is_bankrupt_debtor_to(*state, source, target);
953}
957 return p + 2;
958 s.pop_main(); s.pop_main(); s.pop_main();
959 s.push_back_main(fif::fif_bool, 0, nullptr);
960 return p + 2;
961 }
962
963 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
964 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
965 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
966
967 s.push_back_main(fif::fif_bool, f_is_bankrupt_debtor_to(state, nindex, tindex), nullptr);
968 return p + 2;
969}
970inline bool f_global_flag_set(sys::state* state, int32_t s_index) {
971 dcon::global_flag_id s{ dcon::global_flag_id::value_base_t(s_index) };
972 return state->national_definitions.is_global_flag_variable_set(s);
973}
974inline int32_t* f_global_flag_set_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
977 return p + 2;
978 s.pop_main(); s.pop_main();
979 s.push_back_main(fif::fif_bool, 0, nullptr);
980 return p + 2;
981 }
982
983 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
984 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
985
986 s.push_back_main(fif::fif_bool, f_global_flag_set(state, nindex), nullptr);
987 return p + 2;
988}
989inline bool f_can_nationalize(sys::state* state, int32_t s_index) {
990 dcon::nation_id s{ dcon::nation_id::value_base_t(s_index) };
991 for(auto c : state->world.nation_get_unilateral_relationship_as_target(s)) {
992 if(c.get_foreign_investment() > 0.0f)
993 return true;
994 }
995 return false;
996}
997inline int32_t* f_can_nationalize_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1000 return p + 2;
1001 s.pop_main(); s.pop_main();
1002 s.push_back_main(fif::fif_bool, 0, nullptr);
1003 return p + 2;
1004 }
1005
1006 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1007 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1008
1009 s.push_back_main(fif::fif_bool, f_can_nationalize(state, nindex), nullptr);
1010 return p + 2;
1011}
1012inline float f_movement_str(sys::state* state, bool is_social, int32_t s_index) {
1013 dcon::nation_id s{ dcon::nation_id::value_base_t(s_index) };
1015
1016 float max_str = 0.0f;
1017 for(auto m : state->world.nation_get_movement_within(s)) {
1018 auto issue = m.get_movement().get_associated_issue_option();
1019 if(issue) {
1020 if(culture::issue_type(issue.get_parent_issue().get_issue_type()) == itype && m.get_movement().get_pop_support() > max_str) {
1021 max_str = m.get_movement().get_pop_support();
1022 }
1023 }
1024 }
1025 auto ncpop = state->world.nation_get_non_colonial_population(s);
1026 return ncpop > 0.0f ? max_str * state->defines.movement_support_uh_factor / ncpop : 0.0f;
1027}
1028inline int32_t* f_movement_str_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1031 return p + 2;
1032 s.pop_main(); s.pop_main(); s.pop_main();
1033 s.push_back_main(fif::fif_f32, 0, nullptr);
1034 return p + 2;
1035 }
1036
1037 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1038 bool social = s.main_data_back(0) != 0; s.pop_main();
1039 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1040
1041 auto fres = f_movement_str(state, social, nindex);
1042 int64_t data = 0;
1043 memcpy(&data, &fres, 4);
1044 s.push_back_main(fif::fif_f32, data, nullptr);
1045 return p + 2;
1046}
1047inline float f_influence_on(sys::state* state, int32_t t_index, int32_t n_index) {
1048 dcon::nation_id gp{ dcon::nation_id::value_base_t(n_index) };
1049 dcon::nation_id t{ dcon::nation_id::value_base_t(t_index) };
1050
1051 auto gpr = state->world.get_gp_relationship_by_gp_influence_pair(t, gp);
1052 return state->world.gp_relationship_get_influence(gpr);
1053}
1054inline int32_t* f_influence_on_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1057 return p + 2;
1058 s.pop_main(); s.pop_main(); s.pop_main();
1059 s.push_back_main(fif::fif_f32, 0, nullptr);
1060 return p + 2;
1061 }
1062
1063 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1064 int32_t sindex = int32_t(s.main_data_back(0)); s.pop_main();
1065 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1066
1067 auto fres = f_influence_on(state, sindex, nindex);
1068 int64_t data = 0;
1069 memcpy(&data, &fres, 4);
1070 s.push_back_main(fif::fif_f32, data, nullptr);
1071 return p + 2;
1072}
1073inline float f_relations(sys::state* state, int32_t t_index, int32_t n_index) {
1074 dcon::nation_id n{ dcon::nation_id::value_base_t(n_index) };
1075 dcon::nation_id t{ dcon::nation_id::value_base_t(t_index) };
1076
1077 auto rel = state->world.get_diplomatic_relation_by_diplomatic_pair(t, n);
1078 return state->world.diplomatic_relation_get_value(rel);
1079}
1080inline int32_t* f_relations_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1083 return p + 2;
1084 s.pop_main(); s.pop_main(); s.pop_main();
1085 s.push_back_main(fif::fif_f32, 0, nullptr);
1086 return p + 2;
1087 }
1088
1089 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1090 int32_t sindex = int32_t(s.main_data_back(0)); s.pop_main();
1091 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1092
1093 auto fres = f_relations(state, sindex, nindex);
1094 int64_t data = 0;
1095 memcpy(&data, &fres, 4);
1096 s.push_back_main(fif::fif_f32, data, nullptr);
1097 return p + 2;
1098}
1099inline bool f_has_union_sphere(sys::state* state, int32_t s_index) {
1100 dcon::nation_id n{ dcon::nation_id::value_base_t(s_index) };
1101 auto prim_culture = state->world.nation_get_primary_culture(n);
1102 auto culture_group = state->world.culture_get_group_from_culture_group_membership(prim_culture);
1103
1104 for(auto s : state->world.nation_get_gp_relationship_as_great_power(n)) {
1106 s.get_influence_target().get_primary_culture().get_group_from_culture_group_membership() == culture_group) {
1107 return true;
1108 }
1109 }
1110 return false;
1111}
1112inline int32_t* f_has_union_sphere_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1115 return p + 2;
1116 s.pop_main(); s.pop_main();
1117 s.push_back_main(fif::fif_bool, 0, nullptr);
1118 return p + 2;
1119 }
1120
1121 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1122 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1123
1124 s.push_back_main(fif::fif_bool, f_has_union_sphere(state, nindex), nullptr);
1125 return p + 2;
1126}
1127inline bool f_state_rgo(sys::state* state, int32_t cindex, int32_t sindex) {
1128 dcon::commodity_id c{ dcon::commodity_id::value_base_t(cindex) };
1129 dcon::state_instance_id si{ dcon::state_instance_id::value_base_t(sindex) };
1130
1131 auto o = state->world.state_instance_get_nation_from_state_ownership(si);
1132 auto d = state->world.state_instance_get_definition(si);
1133 for(auto p : state->world.state_definition_get_abstract_state_membership(d)) {
1134 if(p.get_province().get_nation_from_province_ownership() == o) {
1135 if(p.get_province().get_rgo() == c)
1136 return true;
1137 }
1138 }
1139
1140 return false;
1141}
1142inline int32_t* f_state_rgo_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1145 return p + 2;
1146 s.pop_main(); s.pop_main(); s.pop_main();
1147 s.push_back_main(fif::fif_bool, 0, nullptr);
1148 return p + 2;
1149 }
1150
1151 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1152 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1153 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
1154
1155 s.push_back_main(fif::fif_bool, f_state_rgo(state, nindex, tindex), nullptr);
1156 return p + 2;
1157}
1158inline bool f_in_crisis(sys::state* state, int32_t nindex) {
1159 dcon::nation_id n{ dcon::nation_id::value_base_t(nindex) };
1160
1161 auto sz = state->crisis_participants.size();
1162 for(uint32_t i = 0; i < sz; ++i) {
1163 if(!state->crisis_participants[i].id)
1164 return false;
1165 if(state->crisis_participants[i].id == n)
1166 return true;
1167 }
1168 return false;
1169}
1170inline int32_t* f_in_crisis_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1173 return p + 2;
1174 s.pop_main(); s.pop_main();
1175 s.push_back_main(fif::fif_bool, 0, nullptr);
1176 return p + 2;
1177 }
1178
1179 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1180 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1181
1182 s.push_back_main(fif::fif_bool, f_in_crisis(state, nindex), nullptr);
1183 return p + 2;
1184}
1185inline bool f_can_build_naval_base(sys::state* state, int32_t cindex, int32_t sindex) {
1186 dcon::province_id p{ dcon::province_id::value_base_t(cindex) };
1187 dcon::nation_id n{ dcon::nation_id::value_base_t(sindex) };
1188
1189 return state->world.province_get_is_coast(p)
1190 && (state->world.province_get_building_level(p, uint8_t(economy::province_building_type::naval_base)) < state->world.nation_get_max_building_level(n, uint8_t(economy::province_building_type::naval_base)))
1191 && (state->world.province_get_building_level(p, uint8_t(economy::province_building_type::naval_base)) != 0 || !military::state_has_naval_base(*state, state->world.province_get_state_membership(p)));
1192}
1196 return p + 2;
1197 s.pop_main(); s.pop_main(); s.pop_main();
1198 s.push_back_main(fif::fif_bool, 0, nullptr);
1199 return p + 2;
1200 }
1201
1202 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1203 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1204 int32_t tindex = int32_t(s.main_data_back(0)); s.pop_main();
1205
1206 s.push_back_main(fif::fif_bool, f_can_build_naval_base(state, nindex, tindex), nullptr);
1207 return p + 2;
1208}
1209inline void* f_ranked_nations(sys::state* state) {
1210 return state->nations_by_rank.data();
1211}
1212inline int32_t* f_ranked_nations_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1215 return p + 2;
1216 s.pop_main();
1217 s.push_back_main(fif::fif_opaque_ptr, 0, nullptr);
1218 return p + 2;
1219 }
1220
1221 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1222 int64_t res = (int64_t)(f_ranked_nations(state));
1223
1224 s.push_back_main(fif::fif_opaque_ptr, res, nullptr);
1225 return p + 2;
1226}
1227
1228inline std::string state_to_owner() {
1229 return "state_ownership-state nation @ ";
1230}
1231inline std::string province_to_owner() {
1232 return "province_ownership-province nation @ ";
1233}
1234inline std::string province_to_controller() {
1235 return "province_control-province nation @ ";
1236}
1237inline std::string pop_to_location() {
1238 return "pop_location-pop province @ ";
1239}
1240inline std::string pop_to_owner() {
1242}
1243inline std::string nation_to_tag() {
1244 return "identity_holder-nation @ identity ";
1245}
1246inline std::string tag_to_nation() {
1247 return "identity_holder-identity nation @ ";
1248}
1249
1250inline bool f_party_name(sys::state* state, int32_t s_index, int32_t ideoindex, int32_t nameindex) {
1251 dcon::nation_id n{ dcon::nation_id::value_base_t(s_index) };
1252 dcon::ideology_id i{ dcon::ideology_id::value_base_t(ideoindex) };
1253 dcon::text_key m{ dcon::text_key::value_base_t(nameindex) };
1254
1255 auto holder = state->world.nation_get_identity_from_identity_holder(n);
1256
1257 auto start = state->world.national_identity_get_political_party_first(holder).id.index();
1258 auto end = start + state->world.national_identity_get_political_party_count(holder);
1259
1260 for(int32_t j = start; j < end; j++) {
1261 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(j));
1262 if(politics::political_party_is_active(*state, n, pid) && state->world.political_party_get_ideology(pid) == i) {
1263 return state->world.political_party_get_name(pid) == m;
1264 }
1265 }
1266
1267 return false;
1268}
1269inline int32_t* f_party_name_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1272 return p + 2;
1273 s.pop_main(); s.pop_main(); s.pop_main();
1274 s.push_back_main(fif::fif_bool, 0, nullptr);
1275 return p + 2;
1276 }
1277
1278 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1279 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1280 int32_t ideoindex = int32_t(s.main_data_back(0)); s.pop_main();
1281 int32_t nameindex = int32_t(s.main_data_back(0)); s.pop_main();
1282
1283 s.push_back_main(fif::fif_bool, f_party_name(state, nindex, ideoindex, nameindex), nullptr);
1284 return p + 2;
1285}
1286
1287inline bool f_party_pos(sys::state* state, int32_t s_index, int32_t ideoindex, int32_t optid) {
1288 dcon::nation_id n{ dcon::nation_id::value_base_t(s_index) };
1289 dcon::ideology_id i{ dcon::ideology_id::value_base_t(ideoindex) };
1290 dcon::issue_option_id m{ dcon::issue_option_id::value_base_t(optid) };
1291
1292 auto popt = state->world.issue_option_get_parent_issue(m);
1293 auto holder = state->world.nation_get_identity_from_identity_holder(n);
1294
1295 auto start = state->world.national_identity_get_political_party_first(holder).id.index();
1296 auto end = start + state->world.national_identity_get_political_party_count(holder);
1297
1298 for(int32_t j = start; j < end; j++) {
1299 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(j));
1300 if(politics::political_party_is_active(*state, n, pid) && state->world.political_party_get_ideology(pid) == i) {
1301 return state->world.political_party_get_party_issues(pid, popt) == m;
1302 }
1303 }
1304 return false;
1305}
1306inline int32_t* f_party_pos_b(fif::state_stack& s, int32_t* p, fif::environment* e) {
1309 return p + 2;
1310 s.pop_main(); s.pop_main(); s.pop_main();
1311 s.push_back_main(fif::fif_bool, 0, nullptr);
1312 return p + 2;
1313 }
1314
1315 sys::state* state = (sys::state*)(s.main_data_back(0)); s.pop_main();
1316 int32_t nindex = int32_t(s.main_data_back(0)); s.pop_main();
1317 int32_t ideoindex = int32_t(s.main_data_back(0)); s.pop_main();
1318 int32_t nameindex = int32_t(s.main_data_back(0)); s.pop_main();
1319
1320 s.push_back_main(fif::fif_bool, f_party_pos(state, nindex, ideoindex, nameindex), nullptr);
1321 return p + 2;
1322}
1323
1326
1327 fif::interpreter_stack values{ };
1328
1329 fif::run_fif_interpreter(env, fif::container_interface(), values);
1330
1331 values.push_back_main(fif::fif_opaque_ptr, (int64_t)(&(state.world)), nullptr);
1332 fif::run_fif_interpreter(env, "set-container ", values);
1333 values.push_back_main(fif::fif_opaque_ptr, (int64_t)(dcon::shared_backing_storage.allocation), nullptr);
1334 fif::run_fif_interpreter(env, "set-vector-storage ", values);
1335
1337 " ptr(nil) global state-ptr "
1338 " : set-state state-ptr ! ; "
1339 " :export set_state ptr(nil) set-state ; ",
1340 values);
1341
1342 values.push_back_main(fif::fif_opaque_ptr, (int64_t)(&state), nullptr);
1343 fif::run_fif_interpreter(env, "set-state", values);
1344
1345 //fif::run_fif_interpreter(env, "ptr(nil) global state-ptr state-ptr ! ", values);
1346
1347 auto nation_id_type = env.dict.types.find("nation_id")->second;
1348 auto prov_id_type = env.dict.types.find("province_id")->second;
1349
1350 fif::add_import("current-year", (void *) f_date_to_year, f_date_to_year_b, { fif::fif_i64 }, { fif::fif_i32 }, env);
1351 fif::add_import("current-month", (void *) f_date_to_month, f_date_to_month_b, { fif::fif_i64 }, { fif::fif_i32 }, env);
1373 fif::add_import("general-in-province?", (void *) f_general_in_p, f_general_in_p_b, { fif::fif_i32, fif::fif_opaque_ptr }, { fif::fif_bool }, env);
1389 fif::add_import("state-has-rgo?", (void *) f_state_rgo, f_state_rgo_b, { fif::fif_i32, fif::fif_opaque_ptr }, { fif::fif_bool }, env);
1394 fif::add_import("ranked-nation-array", (void *) f_ranked_nations, f_ranked_nations_b, { fif::fif_opaque_ptr }, { fif::fif_opaque_ptr }, env);
1397
1399 " : first-sea-province " + std::to_string(offsetof(sys::state, province_definitions) + offsetof(province::global_provincial_state, first_sea_province)) + " state-ptr @ buf-add ptr-cast ptr(province_id) ; "
1400 " : start-date " + std::to_string(offsetof(sys::state, start_date)) + " state-ptr @ buf-add ptr-cast ptr(i64) ; "
1401 " : current-date " + std::to_string(offsetof(sys::state, current_date)) + " state-ptr @ buf-add ptr-cast ptr(u16) ; "
1402 " : crisis-state " + std::to_string(offsetof(sys::state, crisis_state)) + " state-ptr @ buf-add ptr-cast ptr(state_instance_id) ; "
1403 " : sea-province? >index first-sea-province @ >index >= ; "
1404 " :s >owner pop_id s: " + pop_to_owner() + " ; "
1405 " :s >owner province_id s: " + province_to_owner() + " ; "
1406 " :s >owner state_instance_id s: " + state_to_owner() + " ; "
1407 " :s >location pop_id s: " + pop_to_location() + " ; "
1408
1409 ":struct gp-iterator ptr(nil) base i32 count i32 size i32 gp-count ; "
1410 ":s next gp-iterator s: let it it .count " + std::to_string(sizeof(dcon::nation_id)) + " * it .base buf-add ptr-cast ptr(nation_id) @ it .count@ 1 + swap .count! swap ; "
1411 ":s more? gp-iterator s: let it it .count it .size < it .gp-count " + std::to_string(state.defines.great_nations_count) + " < and it swap ; "
1412 ":s inc-gp gp-iterator s: .gp-count@ 1 + swap .gp-count! ; "
1413 ": make-gp-it make gp-iterator state-ptr @ ranked-nation-array swap .base! nation-size swap .size! ; "
1414
1415 ":struct state-prov-iterator vpool-abstract_state_membership-state base i32 count state_instance_id parent ; "
1416 ":s next state-prov-iterator s: let it it .base it .count index @ province it .count@ 1 - swap .count! swap dup state_membership @ it .parent = ; "
1417 ":s more? state-prov-iterator s: .count@ 0 >= ; "
1418 ": make-sp-it dup definition @ abstract_state_membership-state make state-prov-iterator .base! .parent! .base@ size 1 - swap .count! ; "
1419
1420 ":struct nation-prov-iterator vpool-province_ownership-nation base i32 count ; "
1421 ":s next nation-prov-iterator s: let it it .base it .count index @ province it .count@ 1 - swap .count! swap ; "
1422 ":s more? nation-prov-iterator s: .count@ 0 >= ; "
1423 ": make-n-it province_ownership-nation make nation-prov-iterator .base! .base@ size 1 - swap .count! ; "
1424
1425 ":struct pcore-iterator vpool-core-province base i32 count ; "
1426 ":s next pcore-iterator s: let it it .base it .count index @ identity @ " + tag_to_nation() + " it .count@ 1 - swap .count! swap ; "
1427 ":s more? pcore-iterator s: .count@ 0 >= ; "
1428 ": make-pc-it core-province make pcore-iterator .base! .base@ size 1 - swap .count! ; "
1429
1430 ":struct ncore-iterator vpool-core-identity base i32 count ; "
1431 ":s next ncore-iterator s: let it it .base it .count index @ province @ it .count@ 1 - swap .count! swap ; "
1432 ":s more? ncore-iterator s: .count@ 0 >= ; "
1433 ": make-nc-it core-identity make ncore-iterator .base! .base@ size 1 - swap .count! ; "
1434
1435 ":struct nation-state-iterator vpool-state_ownership-nation base i32 count ; "
1436 ":s next nation-state-iterator s: let it it .base it .count index @ state it .count@ 1 - swap .count! swap ; "
1437 ":s more? nation-state-iterator s: .count@ 0 >= ; "
1438 ": make-ns-it state_ownership-nation make nation-state-iterator .base! .base@ size 1 - swap .count! ; "
1439
1440 ":struct nation-vassal-iterator vpool-overlord-ruler base i32 count ; "
1441 ":s next nation-vassal-iterator s: let it it .base it .count index @ subject it .count@ 1 - swap .count! swap ; "
1442 ":s more? nation-vassal-iterator s: .count@ 0 >= ; "
1443 ": make-nv-it overlord-ruler make nation-vassal-iterator .base! .base@ size 1 - swap .count! ; "
1444
1445 ":struct nation-gp-iterator vpool-gp_relationship-great_power base i32 count ; "
1446 ":s next nation-gp-iterator s: let it it .base it .count index @ dup influence_target @ swap status @ >i32 " + std::to_string(nations::influence::level_mask) + " and " + std::to_string(nations::influence::level_in_sphere) + " = >r it .count@ 1 - swap .count! swap r> ; "
1447 ":s more? nation-gp-iterator s: .count@ 0 >= ; "
1448 ": make-ngp-it gp_relationship-great_power make nation-gp-iterator .base! .base@ size 1 - swap .count! ; "
1449
1450 ":struct prov-pop-iterator vpool-pop_location-province base i32 count ; "
1451 ":s next prov-pop-iterator s: let it it .base it .count index @ pop it .count@ 1 - swap .count! swap ; "
1452 ":s more? prov-pop-iterator s: .count@ 0 >= ; "
1453 ": make-pp-it pop_location-province make prov-pop-iterator .base! .base@ size 1 - swap .count! ; "
1454
1455 ":struct astate-prov-iterator vpool-abstract_state_membership-state base i32 count ; "
1456 ":s next astate-prov-iterator s: let it it .base it .count index @ province it .count@ 1 - swap .count! swap ; "
1457 ":s more? astate-prov-iterator s: .count@ 0 >= ; "
1458 ": make-asp-it abstract_state_membership-state make astate-prov-iterator .base! .base@ size 1 - swap .count! ; "
1459
1460 ":struct aregion-prov-iterator vpool-region_membership-region base i32 count ; "
1461 ":s next aregion-prov-iterator s: let it it .base it .count index @ province @ it .count@ 1 - swap .count! swap ; "
1462 ":s more? aregion-prov-iterator s: .count@ 0 >= ; "
1463 ": make-arp-it region_membership-region make aregion-prov-iterator .base! .base@ size 1 - swap .count! ; "
1464
1465 ":struct adj-prov-iterator vpool-province_adjacency-connected_provinces base i32 count province_id parent ; "
1466 ":s next adj-prov-iterator s: let it it .base it .count index @ dup >r "
1467 "connected_provinces .wrapped dup ptr-cast ptr(nil) " + std::to_string(sizeof(dcon::province_id)) + " swap buf-add ptr-cast ptr(province_id) @ swap @ dup it .parent = not select "
1468 "it .count@ 1 - swap .count! swap "
1469 "r> type @ " + std::to_string(int32_t(province::border::impassible_bit)) + " >i8 and 0 >i8 = ; "
1470 ":s more? adj-prov-iterator s: .count@ 0 >= ; "
1471 ": make-ap-it dup province_adjacency-connected_provinces make adj-prov-iterator .base! .parent! .base@ size 1 - swap .count! ; "
1472
1473 ":struct adj-nation-iterator vpool-nation_adjacency-connected_nations base i32 count nation_id parent ; "
1474 ":s next adj-nation-iterator s: let it it .base it .count index @ "
1475 "connected_nations .wrapped dup ptr-cast ptr(nil) " + std::to_string(sizeof(dcon::nation_id)) + " swap buf-add ptr-cast ptr(nation_id) @ swap @ dup it .parent = not select "
1476 "it .count@ 1 - swap .count! swap ; "
1477 ":s more? adj-nation-iterator s: .count@ 0 >= ; "
1478 ": make-an-it dup nation_adjacency-connected_nations make adj-nation-iterator .base! .parent! .base@ size 1 - swap .count! ; "
1479 ,
1480 values);
1481
1483}
1484
1485
1486}
1487
1488namespace fif_trigger {
1489std::string multiplicative_modifier(sys::state& state, dcon::value_modifier_key modifier);
1490std::string additive_modifier(sys::state& state, dcon::value_modifier_key modifier);
1491std::string evaluate(sys::state& state, dcon::trigger_key key);
1492}
1493
ankerl::unordered_dense::map< std::string, int32_t > types
Definition: fif.hpp:505
fif_mode mode
Definition: fif.hpp:767
dictionary dict
Definition: fif.hpp:762
void add_value(int32_t v)
Definition: fif_common.hpp:133
virtual int64_t main_data_back(size_t index) const =0
virtual void pop_main()=0
virtual void push_back_main(int32_t type, int64_t data, LLVMValueRef expr)=0
#define assert(condition)
Definition: debug.h:74
bool has_building(sys::state const &state, dcon::state_instance_id si, dcon::factory_type_id fac)
Definition: economy.cpp:384
bool is_bankrupt_debtor_to(sys::state &state, dcon::nation_id debt_holder, dcon::nation_id debtor)
Definition: economy.cpp:398
bool has_factory(sys::state const &state, dcon::state_instance_id si)
Definition: economy.cpp:128
std::string evaluate(sys::state &state, dcon::trigger_key key)
std::string multiplicative_modifier(sys::state &state, dcon::value_modifier_key modifier)
std::string additive_modifier(sys::state &state, dcon::value_modifier_key modifier)
Definition: fif.hpp:44
bool f_units_in_province(sys::state *state, int32_t sindex, int32_t nindex)
Definition: fif_common.hpp:601
bool f_core_in_province(sys::state *state, int32_t p_index, int32_t t_index)
Definition: fif_common.hpp:229
bool f_has_culture_core(sys::state *state, int32_t cindex, int32_t sindex)
Definition: fif_common.hpp:783
int32_t f_date_to_year(int64_t v)
Definition: fif_common.hpp:21
int32_t * f_has_nmod_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:427
std::string province_to_controller()
bool f_is_bankrupt_debtor_to(sys::state *state, int32_t tindex, int32_t sindex)
Definition: fif_common.hpp:948
int32_t * f_core_in_province_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:236
int32_t * f_unowned_core_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:178
bool f_unowned_core(sys::state *state, int32_t n_index)
Definition: fif_common.hpp:160
int32_t * f_core_fully_state_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:302
int32_t * f_has_any_factory_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:380
bool f_owns_region(sys::state *state, int32_t rindex, int32_t n_index)
Definition: fif_common.hpp:496
void run_fif_interpreter(environment &env, std::string_view on_text)
Definition: fif.hpp:5096
int32_t * f_has_culture_core_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:793
constexpr int32_t fif_i32
Definition: fif.hpp:483
int32_t * f_state_rgo_b(fif::state_stack &s, int32_t *p, fif::environment *e)
bool f_are_at_war(sys::state *state, int32_t sindex, int32_t nindex)
Definition: fif_common.hpp:654
int32_t * f_influence_on_b(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_has_access_with_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:359
std::string tag_to_nation()
bool f_has_factory(sys::state *state, int32_t findex, int32_t s_index)
Definition: fif_common.hpp:396
int32_t * f_coastal_s_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:731
bool f_core_in_state(sys::state *state, int32_t s_index, int32_t t_index)
Definition: fif_common.hpp:258
int32_t * f_truce_with_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:835
int32_t * f_units_in_province_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:611
bool f_has_pmod(sys::state *state, int32_t m_index, int32_t p_index)
Definition: fif_common.hpp:444
constexpr int32_t fif_bool
Definition: fif.hpp:485
bool f_empty_adjacent_state(sys::state *state, int32_t p_index)
Definition: fif_common.hpp:86
bool f_owns_state(sys::state *state, int32_t rindex, int32_t n_index)
Definition: fif_common.hpp:522
bool f_in_crisis(sys::state *state, int32_t nindex)
float f_influence_on(sys::state *state, int32_t t_index, int32_t n_index)
int32_t * f_can_build_naval_base_b(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_can_nationalize_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:997
int32_t * f_party_pos_b(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_are_at_war_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:659
int32_t * f_canal_enabled_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:813
std::string nation_to_tag()
bool f_state_produces(sys::state *state, int32_t cindex, int32_t sindex)
Definition: fif_common.hpp:747
int32_t * f_in_region_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:479
int32_t * f_global_flag_set_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:974
int32_t * f_general_in_p_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:685
int32_t * f_nation_has_any_factory_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:933
void common_fif_environment(sys::state &state, fif::environment &env)
bool typechecking_mode(fif_mode m)
Definition: fif.hpp:719
bool f_core_in_nation(sys::state *state, int32_t n_index, int32_t t_index)
Definition: fif_common.hpp:197
bool f_coastal_s(sys::state *state, int32_t sindex)
Definition: fif_common.hpp:727
bool f_nation_a(sys::state *state, int32_t aindex, int32_t bindex)
Definition: fif_common.hpp:548
int32_t * f_count_ships_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:711
bool f_has_cb_against(sys::state *state, int32_t targ_index, int32_t source_index)
Definition: fif_common.hpp:324
std::string province_to_owner()
int32_t * f_core_in_nation_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:207
void add_import(std::string_view name, void *ptr, fif_call interpreter_implementation, std::vector< int32_t > const &params, std::vector< int32_t > const &returns, environment &env)
Definition: fif.hpp:5154
bool f_truce_with(sys::state *state, int32_t tindex, int32_t sindex)
Definition: fif_common.hpp:829
bool f_units_in_state(sys::state *state, int32_t sindex, int32_t nindex)
Definition: fif_common.hpp:570
std::string pop_to_location()
int32_t * f_ranked_nations_b(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_movement_str_b(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_can_release_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:885
bool f_has_union_sphere(sys::state *state, int32_t s_index)
int32_t * f_has_named_leader_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:863
bool f_has_nmod(sys::state *state, int32_t m_index, int32_t n_index)
Definition: fif_common.hpp:418
std::string pop_to_owner()
int32_t f_count_p_units(sys::state *state, int32_t sindex)
Definition: fif_common.hpp:628
int32_t * f_has_union_sphere_b(fif::state_stack &s, int32_t *p, fif::environment *e)
bool f_core_fully_state(sys::state *state, int32_t s_index, int32_t t_index)
Definition: fif_common.hpp:291
int32_t * f_nation_a_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:553
int32_t * f_empty_adjacent_state_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:100
int32_t * f_relations_b(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_core_in_state_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:269
std::string state_to_owner()
bool f_has_any_factory(sys::state *state, int32_t s_index)
Definition: fif_common.hpp:376
bool f_party_name(sys::state *state, int32_t s_index, int32_t ideoindex, int32_t nameindex)
int32_t * f_owns_state_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:531
int32_t * f_date_to_year_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:27
int32_t * f_date_to_month_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:42
int32_t * f_has_cb_against_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:329
int32_t f_count_ships(sys::state *state, int32_t sindex)
Definition: fif_common.hpp:701
int32_t * f_has_factory_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:401
bool f_party_pos(sys::state *state, int32_t s_index, int32_t ideoindex, int32_t optid)
bool f_empty_adjacent_province(sys::state *state, int32_t p_index)
Definition: fif_common.hpp:58
int32_t * f_owns_region_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:505
bool f_can_release(sys::state *state, int32_t tindex, int32_t nindex)
Definition: fif_common.hpp:880
bool f_general_in_p(sys::state *state, int32_t sindex)
Definition: fif_common.hpp:676
bool typechecking_failed(fif_mode m)
Definition: fif.hpp:723
constexpr sys::year_month_day civil_from_days(int64_t z) noexcept
Definition: fif_common.hpp:8
constexpr int32_t fif_f32
Definition: fif.hpp:484
int32_t * f_are_allied_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:908
constexpr int32_t fif_opaque_ptr
Definition: fif.hpp:497
bool f_has_access_with(sys::state *state, int32_t targ_index, int32_t source_index)
Definition: fif_common.hpp:351
bool f_can_nationalize(sys::state *state, int32_t s_index)
Definition: fif_common.hpp:989
bool f_can_build_naval_base(sys::state *state, int32_t cindex, int32_t sindex)
void initialize_standard_vocab(environment &fif_env)
Definition: fif.hpp:9485
int32_t f_date_to_month(int64_t v)
Definition: fif_common.hpp:24
bool f_in_region(sys::state *state, int32_t rindex, int32_t p_index)
Definition: fif_common.hpp:470
auto f_make_true_accumulator(F &&f) -> f_true_accumulator< F >
Definition: fif_common.hpp:155
int32_t * f_empty_adjacent_province_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:67
bool f_are_allied(sys::state *state, int32_t tindex, int32_t sindex)
Definition: fif_common.hpp:902
float f_movement_str(sys::state *state, bool is_social, int32_t s_index)
int32_t * f_state_produces_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:766
bool f_nation_has_any_factory(sys::state *state, int32_t s_index)
Definition: fif_common.hpp:924
bool f_canal_enabled(sys::state *state, int32_t sindex)
Definition: fif_common.hpp:810
int32_t * f_has_pmod_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:453
constexpr int32_t fif_i64
Definition: fif.hpp:487
int32_t * f_in_crisis_b(fif::state_stack &s, int32_t *p, fif::environment *e)
float f_relations(sys::state *state, int32_t t_index, int32_t n_index)
int32_t * f_count_p_units_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:638
int32_t * f_party_name_b(fif::state_stack &s, int32_t *p, fif::environment *e)
void * f_ranked_nations(sys::state *state)
bool f_has_named_leader(sys::state *state, int32_t name, int32_t nindex)
Definition: fif_common.hpp:852
int32_t * f_is_bankrupt_debtor_to_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:954
bool f_global_flag_set(sys::state *state, int32_t s_index)
Definition: fif_common.hpp:970
int32_t * f_units_in_state_b(fif::state_stack &s, int32_t *p, fif::environment *e)
Definition: fif_common.hpp:584
bool f_state_rgo(sys::state *state, int32_t cindex, int32_t sindex)
bool can_use_cb_against(sys::state &state, dcon::nation_id from, dcon::nation_id target)
Definition: military.cpp:95
bool has_truce_with(sys::state &state, dcon::nation_id attacker, dcon::nation_id target)
Definition: military.cpp:2037
bool state_has_naval_base(sys::state const &state, dcon::state_instance_id si)
Definition: military.cpp:463
bool are_at_war(sys::state const &state, dcon::nation_id a, dcon::nation_id b)
Definition: military.cpp:475
constexpr uint8_t level_in_sphere
Definition: nations.hpp:169
constexpr uint8_t level_mask
Definition: nations.hpp:163
bool can_release_as_vassal(sys::state const &state, dcon::nation_id n, dcon::national_identity_id releasable)
Definition: nations.cpp:176
bool are_allied(sys::state &state, dcon::nation_id a, dcon::nation_id b)
Definition: nations.cpp:198
bool political_party_is_active(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
Definition: politics.cpp:323
constexpr uint8_t impassible_bit
Definition: constants.hpp:595
bool state_is_coastal(sys::state &state, dcon::state_instance_id s)
Definition: province.cpp:1476
Definition: prng.cpp:6
int32_t to_generic(dcon::province_id v)
Definition: triggers.hpp:12
dcon::province_id to_prov(int32_t v)
Definition: triggers.hpp:88
bool compress_mask(bool v)
uint uint32_t
uchar uint8_t