56 if (!universals_n_is_valid(source.kind)) {
57 source.value.advance =
nullptr;
73 switch (source->
kind) {
84 if (tech_flag_id_is_valid(tech_flag_id(source->
value.
techflag))) {
106 case VUT_IMPROVEMENT:
139 if (terrain_flag_id_is_valid(
150 case VUT_NATIONGROUP:
156 case VUT_NATIONALITY:
176 if (unit_type_flag_id_is_valid(
190 if (unit_class_flag_id_is_valid(
267 case VUT_MINFOREIGNPCT:
279 case VUT_MAXTILEUNITS:
285 case VUT_TERRAINCLASS:
293 if (base_flag_id_is_valid(base_flag_id(source->
value.
baseflag))) {
299 if (road_flag_id_is_valid(road_flag_id(source->
value.
roadflag))) {
305 if (extra_flag_id_is_valid(extra_flag_id(source->
value.
extraflag))) {
326 case VUT_SERVERSETTING:
332 case VUT_TERRAINALTER:
335 if (terrain_alteration_is_valid(
352 case VUT_VISIONLAYER:
361 if (national_intelligence_is_valid(source->
value.
nintel)) {
369 source->
kind = universals_n_invalid();
384 switch (source.kind) {
387 source.value.advance =
nullptr;
392 if (source.value.advance !=
nullptr) {
397 source.value.techflag =
value;
401 if (source.value.govern !=
nullptr) {
405 case VUT_ACHIEVEMENT:
407 if (source.value.achievement !=
nullptr) {
413 if (source.value.style !=
nullptr) {
417 case VUT_IMPROVEMENT:
419 if (source.value.building !=
nullptr) {
424 source.value.impr_genus = impr_genus_id(
value);
425 if (impr_genus_id_is_valid(source.value.impr_genus)) {
431 if (source.value.extra !=
nullptr) {
437 if (source.value.good !=
nullptr) {
443 if (source.value.terrain !=
nullptr) {
448 source.value.terrainflag =
value;
449 if (terrain_flag_id_is_valid(
450 terrain_flag_id(source.value.terrainflag))) {
456 if (source.value.nation !=
nullptr) {
460 case VUT_NATIONGROUP:
462 if (source.value.nationgroup !=
nullptr) {
467 source.value.diplrel =
value;
468 if (source.value.diplrel != diplrel_other_invalid()) {
472 case VUT_NATIONALITY:
474 if (source.value.nationality !=
nullptr) {
480 if (source.value.utype !=
nullptr) {
485 source.value.unitflag =
value;
489 if (source.value.uclass !=
nullptr) {
494 source.value.unitclassflag =
value;
495 if (source.value.unitclassflag) {
501 if (source.value.minveteran > 0) {
507 if (ustate_prop_is_valid(source.value.unit_state)) {
512 source.value.activity = unit_activity(
value);
513 if (unit_activity_is_valid(source.value.activity)) {
518 source.value.minmoves =
value;
519 if (source.value.minmoves > 0) {
525 if (source.value.min_hit_points > 0) {
531 if (source.value.age > 0) {
537 if (source.value.min_techs > 0) {
543 if (source.value.action !=
nullptr) {
549 if (source.value.outputtype !=
O_LAST) {
555 if (source.value.specialist) {
560 source.value.minsize =
value;
561 if (source.value.minsize > 0) {
567 if (source.value.minculture > 0) {
571 case VUT_MINFOREIGNPCT:
573 if (source.value.minforeignpct > 0) {
579 if (ai_level_is_valid(source.value.ai_level)) {
583 case VUT_MAXTILEUNITS:
584 source.value.max_tile_units =
value;
585 if (0 <= source.value.max_tile_units) {
589 case VUT_TERRAINCLASS:
591 if (terrain_class_is_valid(terrain_class(source.value.terrainclass))) {
597 if (base_flag_id_is_valid(base_flag_id(source.value.baseflag))) {
603 if (road_flag_id_is_valid(road_flag_id(source.value.roadflag))) {
609 if (extra_flag_id_is_valid(extra_flag_id(source.value.extraflag))) {
618 if (source.value.mincalfrag >= 0) {
624 if (topo_flag_is_valid(source.value.topo_property)) {
628 case VUT_SERVERSETTING:
629 source.value.ssetval =
value;
634 case VUT_TERRAINALTER:
636 if (terrain_alteration_is_valid(
637 static_cast<terrain_alteration
>(source.value.terrainalter))) {
643 if (citytile_type_is_valid(source.value.citytile)) {
648 source.value.citystatus = citystatus_type(
value);
649 if (citystatus_type_is_valid(source.value.citystatus)) {
653 case VUT_VISIONLAYER:
654 source.value.vlayer = vision_layer(
value);
655 if (vision_layer_is_valid(source.value.vlayer)) {
660 source.value.nintel =
static_cast<national_intelligence
>(
value);
661 if (national_intelligence_is_valid(source.value.nintel)) {
670 source.kind = universals_n_invalid();
672 source.value.advance =
nullptr;
693 switch (source->
kind) {
702 case VUT_ACHIEVEMENT:
706 case VUT_IMPROVEMENT:
720 case VUT_NATIONGROUP:
722 case VUT_NATIONALITY:
758 case VUT_MINFOREIGNPCT:
762 case VUT_MAXTILEUNITS:
764 case VUT_TERRAINCLASS:
778 case VUT_SERVERSETTING:
780 case VUT_TERRAINALTER:
786 case VUT_VISIONLAYER:
795 fc_assert_msg(
false,
"universal_number(): invalid source kind %d.",
806 QString printable_req =
807 QStringLiteral(
"%1%2 %3 %4%5")
808 .arg(req->
survives ?
"surviving " :
"", req_range_name(req->
range),
812 return printable_req;
828 const char *error =
nullptr;
832 invalid = !universals_n_is_valid(req.source.kind);
834 error =
"bad type or name";
839 if (!req_range_is_valid(req.range)) {
840 switch (req.source.kind) {
844 case VUT_IMPROVEMENT:
863 case VUT_TERRAINCLASS:
867 case VUT_TERRAINALTER:
869 case VUT_MAXTILEUNITS:
870 case VUT_VISIONLAYER:
871 req.range = REQ_RANGE_LOCAL;
875 case VUT_MINFOREIGNPCT:
876 case VUT_NATIONALITY:
878 req.range = REQ_RANGE_CITY;
881 case VUT_ACHIEVEMENT:
886 case VUT_NATIONGROUP:
890 req.range = REQ_RANGE_PLAYER;
896 case VUT_SERVERSETTING:
897 req.range = REQ_RANGE_WORLD;
910 switch (req.source.kind) {
913 case VUT_TERRAINCLASS:
919 (req.range != REQ_RANGE_LOCAL && req.range != REQ_RANGE_CADJACENT
920 && req.range != REQ_RANGE_ADJACENT && req.range != REQ_RANGE_CITY
921 && req.range != REQ_RANGE_TRADEROUTE);
925 case VUT_ACHIEVEMENT:
927 invalid = (req.range < REQ_RANGE_PLAYER);
933 invalid = (req.range != REQ_RANGE_PLAYER);
936 case VUT_MINFOREIGNPCT:
937 case VUT_NATIONALITY:
941 (req.range != REQ_RANGE_CITY && req.range != REQ_RANGE_TRADEROUTE);
945 (req.range != REQ_RANGE_CITY && req.range != REQ_RANGE_TRADEROUTE
946 && req.range != REQ_RANGE_PLAYER && req.range != REQ_RANGE_TEAM
947 && req.range != REQ_RANGE_ALLIANCE
948 && req.range != REQ_RANGE_WORLD);
952 (req.range != REQ_RANGE_LOCAL && req.range != REQ_RANGE_PLAYER
953 && req.range != REQ_RANGE_TEAM && req.range != REQ_RANGE_ALLIANCE
954 && req.range != REQ_RANGE_WORLD)
956 || (req.source.value.diplrel == DRO_FOREIGN
957 && req.range != REQ_RANGE_LOCAL);
960 case VUT_NATIONGROUP:
961 invalid = (req.range != REQ_RANGE_PLAYER && req.range != REQ_RANGE_TEAM
962 && req.range != REQ_RANGE_ALLIANCE
963 && req.range != REQ_RANGE_WORLD);
977 case VUT_TERRAINALTER:
978 case VUT_VISIONLAYER:
979 invalid = (req.range != REQ_RANGE_LOCAL);
982 case VUT_MAXTILEUNITS:
984 (req.range != REQ_RANGE_LOCAL && req.range != REQ_RANGE_CADJACENT
985 && req.range != REQ_RANGE_ADJACENT);
990 case VUT_SERVERSETTING:
991 invalid = (req.range != REQ_RANGE_WORLD);
995 invalid = (req.range != REQ_RANGE_LOCAL && req.range != REQ_RANGE_CITY
996 && req.range != REQ_RANGE_PLAYER);
1000 invalid = req.range != REQ_RANGE_LOCAL;
1002 case VUT_IMPROVEMENT:
1014 error =
"bad range";
1020 switch (req.source.kind) {
1021 case VUT_IMPROVEMENT:
1023 invalid =
survives && req.range <= REQ_RANGE_CONTINENT;
1027 invalid =
survives && req.range != REQ_RANGE_WORLD;
1029 case VUT_IMPR_GENUS:
1030 case VUT_GOVERNMENT:
1036 case VUT_MINVETERAN:
1044 case VUT_SPECIALIST:
1046 case VUT_MINCULTURE:
1047 case VUT_MINFOREIGNPCT:
1049 case VUT_TERRAINCLASS:
1051 case VUT_MINCALFRAG:
1053 case VUT_SERVERSETTING:
1054 case VUT_TERRAINALTER:
1056 case VUT_CITYSTATUS:
1058 case VUT_NATIONALITY:
1065 case VUT_ACHIEVEMENT:
1066 case VUT_NATIONGROUP:
1069 case VUT_MAXTILEUNITS:
1071 case VUT_VISIONLAYER:
1081 error =
"bad 'survives'";
1086 qCritical(
"Invalid requirement %s | %s | %s | %s | %s: %s", type,
range,
1089 req.source.kind = universals_n_invalid();
1105 req.range = req_range(
range);
1161 if (impr_req->
range == REQ_RANGE_LOCAL
1162 && genus_req->
range == REQ_RANGE_LOCAL) {
1193 if (nation_req->
range == REQ_RANGE_PLAYER
1194 && group_req->
range == REQ_RANGE_PLAYER) {
1224 case VUT_IMPROVEMENT:
1232 case VUT_IMPR_GENUS:
1249 bv_diplrel_all_reqs req1_contra;
1256 return BV_ISSET(req1_contra, req2_pos);
1287 case VUT_NATIONGROUP:
1308 const struct requirement_vector *vec)
1329 const struct player *pplayer2,
1330 enum req_range
range)
1333 case REQ_RANGE_WORLD:
1335 case REQ_RANGE_ALLIANCE:
1337 case REQ_RANGE_TEAM:
1339 case REQ_RANGE_PLAYER:
1340 return pplayer1 == pplayer2;
1341 case REQ_RANGE_CONTINENT:
1342 case REQ_RANGE_TRADEROUTE:
1343 case REQ_RANGE_CITY:
1344 case REQ_RANGE_ADJACENT:
1345 case REQ_RANGE_CADJACENT:
1346 case REQ_RANGE_LOCAL:
1347 case REQ_RANGE_COUNT:
1367 qCritical(
"World-ranged requirements are only supported for wonders.");
1380 qCritical(
"World-ranged requirements are only supported for wonders.");
1403 qCritical(
"Player-ranged requirements are only supported for wonders.");
1417 qCritical(
"Player-ranged requirements are only supported for wonders.");
1430 const struct city *pcity;
1437 qCritical(
"Island-ranged requirements are only supported for wonders.");
1467 const struct player *target_player,
const struct city *target_city,
1469 bool survives,
const struct impr_type *source)
1480 case REQ_RANGE_WORLD:
1482 case REQ_RANGE_ALLIANCE:
1483 case REQ_RANGE_TEAM:
1484 if (target_player ==
nullptr) {
1496 case REQ_RANGE_PLAYER:
1497 if (target_player ==
nullptr) {
1501 case REQ_RANGE_CONTINENT:
1502 case REQ_RANGE_TRADEROUTE:
1503 case REQ_RANGE_CITY:
1504 case REQ_RANGE_LOCAL:
1505 case REQ_RANGE_CADJACENT:
1506 case REQ_RANGE_ADJACENT:
1508 qCritical(
"Surviving requirements are only supported at "
1509 "World/Alliance/Team/Player ranges.");
1511 case REQ_RANGE_COUNT:
1518 case REQ_RANGE_WORLD:
1520 case REQ_RANGE_ALLIANCE:
1521 case REQ_RANGE_TEAM:
1522 if (target_player ==
nullptr) {
1534 case REQ_RANGE_PLAYER:
1535 if (target_player ==
nullptr) {
1540 case REQ_RANGE_CONTINENT:
1543 if (target_player && target_city) {
1550 case REQ_RANGE_TRADEROUTE:
1567 case REQ_RANGE_CITY:
1573 case REQ_RANGE_LOCAL:
1574 if (target_building) {
1575 if (target_building == source) {
1584 case REQ_RANGE_CADJACENT:
1585 case REQ_RANGE_ADJACENT:
1587 case REQ_RANGE_COUNT:
1600 enum req_range
range,
bool survives,
1610 case REQ_RANGE_PLAYER:
1611 if (
nullptr != target_player) {
1618 case REQ_RANGE_TEAM:
1619 case REQ_RANGE_ALLIANCE:
1620 case REQ_RANGE_WORLD:
1621 if (
nullptr == target_player) {
1636 case REQ_RANGE_LOCAL:
1637 case REQ_RANGE_CADJACENT:
1638 case REQ_RANGE_ADJACENT:
1639 case REQ_RANGE_CITY:
1640 case REQ_RANGE_TRADEROUTE:
1641 case REQ_RANGE_CONTINENT:
1642 case REQ_RANGE_COUNT:
1656 enum req_range
range,
enum tech_flag_id techflag)
1659 case REQ_RANGE_PLAYER:
1660 if (
nullptr != target_player) {
1667 case REQ_RANGE_TEAM:
1668 case REQ_RANGE_ALLIANCE:
1669 if (
nullptr == target_player) {
1681 case REQ_RANGE_WORLD:
1691 case REQ_RANGE_LOCAL:
1692 case REQ_RANGE_CADJACENT:
1693 case REQ_RANGE_ADJACENT:
1694 case REQ_RANGE_CITY:
1695 case REQ_RANGE_TRADEROUTE:
1696 case REQ_RANGE_CONTINENT:
1697 case REQ_RANGE_COUNT:
1711 const struct player *target_player,
1712 enum req_range
range,
int minculture)
1715 case REQ_RANGE_CITY:
1720 case REQ_RANGE_TRADEROUTE:
1736 case REQ_RANGE_PLAYER:
1737 case REQ_RANGE_TEAM:
1738 case REQ_RANGE_ALLIANCE:
1739 case REQ_RANGE_WORLD:
1740 if (
nullptr == target_player) {
1753 case REQ_RANGE_LOCAL:
1754 case REQ_RANGE_CADJACENT:
1755 case REQ_RANGE_ADJACENT:
1756 case REQ_RANGE_CONTINENT:
1757 case REQ_RANGE_COUNT:
1771 enum req_range
range,
int min_foreign_pct)
1778 case REQ_RANGE_CITY:
1782 case REQ_RANGE_TRADEROUTE:
1785 if (foreign_pct >= min_foreign_pct) {
1793 if (foreign_pct >= min_foreign_pct) {
1800 case REQ_RANGE_PLAYER:
1801 case REQ_RANGE_TEAM:
1802 case REQ_RANGE_ALLIANCE:
1803 case REQ_RANGE_WORLD:
1804 case REQ_RANGE_LOCAL:
1805 case REQ_RANGE_CADJACENT:
1806 case REQ_RANGE_ADJACENT:
1807 case REQ_RANGE_CONTINENT:
1808 case REQ_RANGE_COUNT:
1826 case REQ_RANGE_LOCAL:
1831 case REQ_RANGE_CADJACENT:
1835 if (unit_list_size(target_tile->
units) <= max_units) {
1840 if (unit_list_size(adjc_tile->units) <= max_units) {
1846 case REQ_RANGE_ADJACENT:
1850 if (unit_list_size(target_tile->
units) <= max_units) {
1855 if (unit_list_size(adjc_tile->units) <= max_units) {
1861 case REQ_RANGE_CITY:
1862 case REQ_RANGE_TRADEROUTE:
1863 case REQ_RANGE_CONTINENT:
1864 case REQ_RANGE_PLAYER:
1865 case REQ_RANGE_TEAM:
1866 case REQ_RANGE_ALLIANCE:
1867 case REQ_RANGE_WORLD:
1868 case REQ_RANGE_COUNT:
1882 const struct city *target_city,
enum req_range
range,
1887 case REQ_RANGE_LOCAL:
1893 case REQ_RANGE_CADJACENT:
1899 case REQ_RANGE_ADJACENT:
1905 case REQ_RANGE_CITY:
1920 case REQ_RANGE_TRADEROUTE:
1947 case REQ_RANGE_CONTINENT:
1948 case REQ_RANGE_PLAYER:
1949 case REQ_RANGE_TEAM:
1950 case REQ_RANGE_ALLIANCE:
1951 case REQ_RANGE_WORLD:
1952 case REQ_RANGE_COUNT:
1966 const struct city *target_city,
enum req_range
range,
1969 Q_UNUSED(target_tile)
1972 case REQ_RANGE_LOCAL:
1973 case REQ_RANGE_CITY:
1979 case REQ_RANGE_CADJACENT:
1980 case REQ_RANGE_ADJACENT:
1981 case REQ_RANGE_TRADEROUTE:
1982 case REQ_RANGE_CONTINENT:
1983 case REQ_RANGE_PLAYER:
1984 case REQ_RANGE_TEAM:
1985 case REQ_RANGE_ALLIANCE:
1986 case REQ_RANGE_WORLD:
1987 case REQ_RANGE_COUNT:
2000 const struct city *target_city,
2001 enum req_range
range,
2003 const struct terrain *pterrain)
2007 case REQ_RANGE_LOCAL:
2014 case REQ_RANGE_CADJACENT:
2020 case REQ_RANGE_ADJACENT:
2026 case REQ_RANGE_CITY:
2030 if (pterrain !=
nullptr) {
2041 case REQ_RANGE_TRADEROUTE:
2045 if (pterrain !=
nullptr) {
2068 case REQ_RANGE_CONTINENT:
2069 case REQ_RANGE_PLAYER:
2070 case REQ_RANGE_TEAM:
2071 case REQ_RANGE_ALLIANCE:
2072 case REQ_RANGE_WORLD:
2073 case REQ_RANGE_COUNT:
2086 const struct tile *target_tile,
const struct city *target_city,
2087 enum req_range
range,
bool survives,
enum terrain_class pclass)
2091 case REQ_RANGE_LOCAL:
2099 case REQ_RANGE_CADJACENT:
2106 case REQ_RANGE_ADJACENT:
2113 case REQ_RANGE_CITY:
2129 case REQ_RANGE_TRADEROUTE:
2160 case REQ_RANGE_CONTINENT:
2161 case REQ_RANGE_PLAYER:
2162 case REQ_RANGE_TEAM:
2163 case REQ_RANGE_ALLIANCE:
2164 case REQ_RANGE_WORLD:
2165 case REQ_RANGE_COUNT:
2179 const struct city *target_city,
enum req_range
range,
2180 bool survives,
enum terrain_flag_id terrflag)
2184 case REQ_RANGE_LOCAL:
2192 case REQ_RANGE_CADJACENT:
2199 case REQ_RANGE_ADJACENT:
2206 case REQ_RANGE_CITY:
2221 case REQ_RANGE_TRADEROUTE:
2250 case REQ_RANGE_CONTINENT:
2251 case REQ_RANGE_PLAYER:
2252 case REQ_RANGE_TEAM:
2253 case REQ_RANGE_ALLIANCE:
2254 case REQ_RANGE_WORLD:
2255 case REQ_RANGE_COUNT:
2268 const struct city *target_city,
2269 enum req_range
range,
2271 enum base_flag_id baseflag)
2275 case REQ_RANGE_LOCAL:
2281 case REQ_RANGE_CADJACENT:
2288 case REQ_RANGE_ADJACENT:
2295 case REQ_RANGE_CITY:
2309 case REQ_RANGE_TRADEROUTE:
2336 case REQ_RANGE_CONTINENT:
2337 case REQ_RANGE_PLAYER:
2338 case REQ_RANGE_TEAM:
2339 case REQ_RANGE_ALLIANCE:
2340 case REQ_RANGE_WORLD:
2341 case REQ_RANGE_COUNT:
2354 const struct city *target_city,
2355 enum req_range
range,
2357 enum road_flag_id roadflag)
2361 case REQ_RANGE_LOCAL:
2367 case REQ_RANGE_CADJACENT:
2374 case REQ_RANGE_ADJACENT:
2381 case REQ_RANGE_CITY:
2395 case REQ_RANGE_TRADEROUTE:
2422 case REQ_RANGE_CONTINENT:
2423 case REQ_RANGE_PLAYER:
2424 case REQ_RANGE_TEAM:
2425 case REQ_RANGE_ALLIANCE:
2426 case REQ_RANGE_WORLD:
2427 case REQ_RANGE_COUNT:
2440 const struct city *target_city,
2441 enum req_range
range,
2443 enum extra_flag_id extraflag)
2447 case REQ_RANGE_LOCAL:
2454 case REQ_RANGE_CADJACENT:
2461 case REQ_RANGE_ADJACENT:
2468 case REQ_RANGE_CITY:
2482 case REQ_RANGE_TRADEROUTE:
2509 case REQ_RANGE_CONTINENT:
2510 case REQ_RANGE_PLAYER:
2511 case REQ_RANGE_TEAM:
2512 case REQ_RANGE_ALLIANCE:
2513 case REQ_RANGE_WORLD:
2514 case REQ_RANGE_COUNT:
2529 enum req_range
range,
bool survives,
2530 enum terrain_alteration alteration)
2538 case REQ_RANGE_LOCAL:
2541 case REQ_RANGE_CADJACENT:
2542 case REQ_RANGE_ADJACENT:
2543 case REQ_RANGE_CITY:
2544 case REQ_RANGE_TRADEROUTE:
2545 case REQ_RANGE_CONTINENT:
2546 case REQ_RANGE_PLAYER:
2547 case REQ_RANGE_TEAM:
2548 case REQ_RANGE_ALLIANCE:
2549 case REQ_RANGE_WORLD:
2550 case REQ_RANGE_COUNT:
2567 case REQ_RANGE_PLAYER:
2568 if (target_player ==
nullptr) {
2572 case REQ_RANGE_TEAM:
2573 case REQ_RANGE_ALLIANCE:
2574 if (target_player ==
nullptr) {
2587 case REQ_RANGE_WORLD:
2594 case REQ_RANGE_LOCAL:
2595 case REQ_RANGE_CADJACENT:
2596 case REQ_RANGE_ADJACENT:
2597 case REQ_RANGE_CITY:
2598 case REQ_RANGE_TRADEROUTE:
2599 case REQ_RANGE_CONTINENT:
2600 case REQ_RANGE_COUNT:
2614 enum req_range
range,
bool survives,
2619 case REQ_RANGE_PLAYER:
2620 if (target_player ==
nullptr) {
2625 case REQ_RANGE_TEAM:
2626 case REQ_RANGE_ALLIANCE:
2627 case REQ_RANGE_WORLD:
2628 if (target_player ==
nullptr) {
2641 case REQ_RANGE_LOCAL:
2642 case REQ_RANGE_CADJACENT:
2643 case REQ_RANGE_ADJACENT:
2644 case REQ_RANGE_CITY:
2645 case REQ_RANGE_TRADEROUTE:
2646 case REQ_RANGE_CONTINENT:
2647 case REQ_RANGE_COUNT:
2664 case REQ_RANGE_CITY:
2665 if (target_city ==
nullptr) {
2677 case REQ_RANGE_TRADEROUTE:
2678 if (target_city ==
nullptr) {
2702 case REQ_RANGE_PLAYER:
2703 case REQ_RANGE_TEAM:
2704 case REQ_RANGE_ALLIANCE:
2705 case REQ_RANGE_WORLD:
2706 case REQ_RANGE_LOCAL:
2707 case REQ_RANGE_CADJACENT:
2708 case REQ_RANGE_ADJACENT:
2709 case REQ_RANGE_CONTINENT:
2710 case REQ_RANGE_COUNT:
2724 const struct player *other_player,
enum req_range
range,
2728 case REQ_RANGE_PLAYER:
2729 if (target_player ==
nullptr) {
2733 case REQ_RANGE_TEAM:
2734 case REQ_RANGE_ALLIANCE:
2735 case REQ_RANGE_WORLD:
2736 if (target_player ==
nullptr) {
2749 case REQ_RANGE_LOCAL:
2750 if (target_player ==
nullptr || other_player ==
nullptr) {
2755 case REQ_RANGE_CADJACENT:
2756 case REQ_RANGE_ADJACENT:
2757 case REQ_RANGE_CITY:
2758 case REQ_RANGE_TRADEROUTE:
2759 case REQ_RANGE_CONTINENT:
2760 case REQ_RANGE_COUNT:
2774 enum req_range
range,
bool survives,
2782 range == REQ_RANGE_LOCAL
2783 && (!target_unittype || target_unittype == punittype));
2791 enum req_range
range,
bool survives,
2792 enum unit_type_flag_id unitflag)
2798 if (
range != REQ_RANGE_LOCAL) {
2801 if (!target_unittype) {
2813 enum req_range
range,
bool survives,
2821 range == REQ_RANGE_LOCAL
2822 && (!target_unittype ||
utype_class(target_unittype) == pclass));
2830 enum req_range
range,
bool survives,
2831 enum unit_class_flag_id ucflag)
2838 range == REQ_RANGE_LOCAL
2839 && (!target_unittype
2847 enum req_range
range,
bool survives,
2848 enum ustate_prop uprop)
2852 "Unsupported range \"%s\"", req_range_name(
range));
2856 if (target_unit ==
nullptr) {
2861 case USP_TRANSPORTED:
2863 case USP_LIVABLE_TILE:
2867 case USP_DOMESTIC_TILE:
2871 case USP_TRANSPORTING:
2873 case USP_HAS_HOME_CITY:
2875 case USP_NATIVE_TILE:
2879 case USP_NATIVE_EXTRA:
2883 case USP_MOVED_THIS_TURN:
2886 fc_assert_msg(uprop != USP_COUNT,
"Invalid unit state property.");
2892 fc_assert_msg(
false,
"Unsupported unit property %d", uprop);
2900 const struct city *pcity)
2902 if (pcity ==
nullptr) {
2913 const struct city *target_city,
2914 enum req_range
range,
2915 enum citytile_type citytile)
2918 if (citytile == CITYT_CENTER) {
2920 case REQ_RANGE_LOCAL:
2922 case REQ_RANGE_CADJACENT:
2935 case REQ_RANGE_ADJACENT:
2948 case REQ_RANGE_CITY:
2949 case REQ_RANGE_TRADEROUTE:
2950 case REQ_RANGE_CONTINENT:
2951 case REQ_RANGE_PLAYER:
2952 case REQ_RANGE_TEAM:
2953 case REQ_RANGE_ALLIANCE:
2954 case REQ_RANGE_WORLD:
2955 case REQ_RANGE_COUNT:
2962 }
else if (citytile == CITYT_CLAIMED) {
2964 case REQ_RANGE_LOCAL:
2966 case REQ_RANGE_CADJACENT:
2967 if (target_tile->
owner !=
nullptr) {
2972 if (adjc_tile->owner !=
nullptr) {
2979 case REQ_RANGE_ADJACENT:
2980 if (target_tile->
owner !=
nullptr) {
2985 if (adjc_tile->owner !=
nullptr) {
2992 case REQ_RANGE_CITY:
2993 case REQ_RANGE_TRADEROUTE:
2994 case REQ_RANGE_CONTINENT:
2995 case REQ_RANGE_PLAYER:
2996 case REQ_RANGE_TEAM:
2997 case REQ_RANGE_ALLIANCE:
2998 case REQ_RANGE_WORLD:
2999 case REQ_RANGE_COUNT:
3008 qCritical(
"is_req_active(): citytile %d not supported.", citytile);
3022 enum citystatus_type citystatus)
3024 if (citystatus == CITYS_OWNED_BY_ORIGINAL) {
3026 case REQ_RANGE_CITY:
3029 case REQ_RANGE_TRADEROUTE: {
3034 if (
city_owner(trade_partner) == trade_partner->original) {
3043 case REQ_RANGE_LOCAL:
3044 case REQ_RANGE_CADJACENT:
3045 case REQ_RANGE_ADJACENT:
3046 case REQ_RANGE_CONTINENT:
3047 case REQ_RANGE_PLAYER:
3048 case REQ_RANGE_TEAM:
3049 case REQ_RANGE_ALLIANCE:
3050 case REQ_RANGE_WORLD:
3051 case REQ_RANGE_COUNT:
3060 qCritical(
"is_req_active(): citystatus %d not supported.", citystatus);
3070 enum req_range
range,
3073 if (
range == REQ_RANGE_WORLD) {
3075 }
else if (target_player ==
nullptr) {
3077 }
else if (
range == REQ_RANGE_ALLIANCE ||
range == REQ_RANGE_TEAM) {
3087 }
else if (
range == REQ_RANGE_PLAYER) {
3094 fc_assert_msg(
false,
"Illegal range %d for achievement requirement.",
3112 const struct player *target_player,
const struct player *other_player,
3113 const struct city *target_city,
const struct impr_type *target_building,
3114 const struct tile *target_tile,
const struct unit *target_unit,
3115 const struct unit_type *target_unittype,
3120 const enum vision_layer vision_layer,
3121 const enum national_intelligence nintel)
3126 if (target_unittype ==
nullptr && target_unit !=
nullptr) {
3147 case VUT_GOVERNMENT:
3149 if (target_player ==
nullptr) {
3156 case VUT_ACHIEVEMENT:
3161 if (target_player ==
nullptr) {
3168 case VUT_IMPROVEMENT:
3173 case VUT_IMPR_GENUS:
3199 case VUT_NATIONGROUP:
3203 case VUT_NATIONALITY:
3212 if (target_unittype ==
nullptr) {
3225 if (target_unittype ==
nullptr) {
3233 if (target_unittype ==
nullptr) {
3241 case VUT_MINVETERAN:
3242 if (target_unit ==
nullptr) {
3250 if (target_unit ==
nullptr) {
3258 if (target_unit ==
nullptr) {
3266 if (target_unit ==
nullptr) {
3274 if (target_unit ==
nullptr) {
3278 <= target_unit->
hp);
3282 switch (req->
range) {
3283 case REQ_RANGE_LOCAL:
3284 if (target_unit ==
nullptr || !
is_server()) {
3289 - target_unit->
server.birth_turn);
3292 case REQ_RANGE_CITY:
3293 if (target_city ==
nullptr) {
3301 case REQ_RANGE_PLAYER:
3302 if (target_player ==
nullptr) {
3315 switch (req->
range) {
3316 case REQ_RANGE_WORLD:
3321 case REQ_RANGE_PLAYER:
3322 if (target_player ==
nullptr) {
3343 && target_output->
index
3346 case VUT_SPECIALIST:
3348 && target_specialist
3352 if (target_city ==
nullptr) {
3355 if (req->
range == REQ_RANGE_TRADEROUTE) {
3377 case VUT_MINCULTURE:
3381 case VUT_MINFOREIGNPCT:
3386 if (target_player ==
nullptr) {
3394 case VUT_MAXTILEUNITS:
3398 case VUT_TERRAINCLASS:
3421 case VUT_MINCALFRAG:
3429 case VUT_SERVERSETTING:
3433 case VUT_TERRAINALTER:
3434 if (target_tile ==
nullptr) {
3443 if (target_tile ==
nullptr) {
3450 case VUT_CITYSTATUS:
3451 if (target_city ==
nullptr) {
3458 case VUT_VISIONLAYER:
3459 if (!vision_layer_is_valid(vision_layer)) {
3466 if (!national_intelligence_is_valid(nintel)) {
3473 qCritical(
"is_req_active(): invalid source kind %d.", req->
source.
kind);
3501 const struct player *other_player,
3502 const struct city *target_city,
3503 const struct impr_type *target_building,
3504 const struct tile *target_tile,
3505 const struct unit *target_unit,
3506 const struct unit_type *target_unittype,
3509 const struct action *target_action,
3510 const struct requirement_vector *
reqs,
3512 const enum vision_layer vision_layer,
3513 const enum national_intelligence nintel)
3517 if (!
is_req_active(target_player, other_player, target_city,
3518 target_building, target_tile, target_unit,
3519 target_unittype, target_output, target_specialist,
3520 target_action, preq, prob_type, vision_layer,
3545 case VUT_SPECIALIST:
3548 case VUT_CITYSTATUS:
3551 case VUT_SERVERSETTING:
3552 case VUT_VISIONLAYER:
3556 case VUT_NATIONGROUP:
3557 return (req->
range != REQ_RANGE_ALLIANCE);
3560 case VUT_GOVERNMENT:
3561 case VUT_ACHIEVEMENT:
3562 case VUT_IMPROVEMENT:
3563 case VUT_IMPR_GENUS:
3565 case VUT_MINCULTURE:
3566 case VUT_MINFOREIGNPCT:
3568 case VUT_NATIONALITY:
3570 case VUT_MAXTILEUNITS:
3575 case VUT_MINVETERAN:
3583 case VUT_MINCALFRAG:
3588 case VUT_TERRAINCLASS:
3590 case VUT_TERRAINALTER:
3612 const struct requirement_vector *vec)
3632 enum universals_n kind)
3636 if (preq->present && preq->source.kind == kind) {
3653 const struct requirement_vector *vec)
3655 Q_UNUSED(parent_item)
3676 const char *req_vec_description;
3686 if (namer ==
nullptr) {
3689 req_vec_description =
_(
"the requirement vector");
3704 _(
"%s %s from %s"), req_vec_change_operation_name(change->
operation),
3716 _(
"%s %s to %s"), req_vec_change_operation_name(change->
operation),
3724 _(
"Do nothing to %s"), req_vec_description);
3743 const void *parent_item)
3745 struct requirement_vector *target =
3751 requirement_vector_append(target, modification->
req);
3757 requirement_vector_remove(target, i);
3780 const char *descr, ...)
3787 va_start(ap, descr);
3788 fc_vsnprintf(out->description,
sizeof(out->description), descr, ap);
3790 va_start(ap, descr);
3792 sizeof(out->description_translated), descr, ap);
3796 out->suggested_solutions =
3798 for (i = 0; i < out->num_suggested_solutions; i++) {
3800 out->suggested_solutions[i].
operation = RVCO_NOOP;
3801 out->suggested_solutions[i].vector_number = -1;
3802 out->suggested_solutions[i].req.source.kind = VUT_NONE;
3835 const void *parent_item)
3840 if (vec ==
nullptr || requirement_vector_size(vec) == 0) {
3845 if (get_num ==
nullptr || parent_item ==
nullptr) {
3848 vec_num = get_num(parent_item, vec);
3852 for (i = 0; i < requirement_vector_size(vec); i++) {
3853 struct requirement *preq = requirement_vector_get(vec, i);
3854 for (j = 0; j < requirement_vector_size(vec); j++) {
3855 struct requirement *nreq = requirement_vector_get(vec, j);
3861 2,
N_(
"Requirements {%s} and {%s} contradict each other."),
3890 if (psource1->
kind != psource2->
kind) {
3893 switch (psource1->
kind) {
3900 case VUT_GOVERNMENT:
3902 case VUT_ACHIEVEMENT:
3906 case VUT_IMPROVEMENT:
3908 case VUT_IMPR_GENUS:
3920 case VUT_NATIONGROUP:
3922 case VUT_NATIONALITY:
3934 case VUT_MINVETERAN:
3953 case VUT_SPECIALIST:
3957 case VUT_MINCULTURE:
3959 case VUT_MINFOREIGNPCT:
3963 case VUT_MAXTILEUNITS:
3965 case VUT_TERRAINCLASS:
3975 case VUT_MINCALFRAG:
3979 case VUT_SERVERSETTING:
3981 case VUT_TERRAINALTER:
3985 case VUT_CITYSTATUS:
3987 case VUT_VISIONLAYER:
4005 static char buffer[10];
4007 switch (psource->
kind) {
4012 case VUT_CITYSTATUS:
4018 case VUT_MINCALFRAG:
4025 case VUT_SERVERSETTING:
4030 return tech_flag_id_name(tech_flag_id(psource->
value.
techflag));
4031 case VUT_GOVERNMENT:
4033 case VUT_ACHIEVEMENT:
4037 case VUT_IMPROVEMENT:
4039 case VUT_IMPR_GENUS:
4051 case VUT_NATIONGROUP:
4055 case VUT_NATIONALITY:
4060 return unit_type_flag_id_name(
4065 return unit_class_flag_id_name(
4067 case VUT_MINVETERAN:
4095 case VUT_SPECIALIST:
4101 case VUT_MINCULTURE:
4105 case VUT_MINFOREIGNPCT:
4111 case VUT_MAXTILEUNITS:
4114 case VUT_TERRAINCLASS:
4117 return base_flag_id_name(base_flag_id(psource->
value.
baseflag));
4119 return road_flag_id_name(road_flag_id(psource->
value.
roadflag));
4121 return extra_flag_id_name(extra_flag_id(psource->
value.
extraflag));
4122 case VUT_TERRAINALTER:
4123 return terrain_alteration_name(
4125 case VUT_VISIONLAYER:
4128 return national_intelligence_name(psource->
value.
nintel);
4146 char *buf,
size_t bufsz)
4149 switch (psource->
kind) {
4159 buf, bufsz,
_(
"\"%s\" tech"),
4160 tech_flag_id_translated_name(tech_flag_id(psource->
value.
techflag)));
4162 case VUT_GOVERNMENT:
4166 case VUT_ACHIEVEMENT:
4173 case VUT_IMPROVEMENT:
4177 case VUT_IMPR_GENUS:
4194 case VUT_NATIONGROUP:
4199 case VUT_NATIONALITY:
4212 Q_(
"?utflag:\"%s\" units"),
4213 unit_type_flag_id_translated_name(
4225 Q_(
"?ucflag:\"%s\" units"),
4226 unit_class_flag_id_translated_name(
4229 case VUT_MINVETERAN:
4236 case USP_TRANSPORTED:
4241 case USP_LIVABLE_TILE:
4245 _(
"On livable tile"));
4247 case USP_DOMESTIC_TILE:
4251 _(
"On domestic tile"));
4253 case USP_TRANSPORTING:
4258 case USP_HAS_HOME_CITY:
4263 case USP_NATIVE_TILE:
4267 _(
"On native tile"));
4269 case USP_NATIVE_EXTRA:
4273 _(
"In native extra"));
4275 case USP_MOVED_THIS_TURN:
4282 "Invalid unit state property.");
4315 case VUT_SPECIALIST:
4322 case VUT_MINCULTURE:
4325 case VUT_MINFOREIGNPCT:
4334 case VUT_MAXTILEUNITS:
4341 case VUT_TERRAINCLASS:
4350 Q_(
"?terrflag:\"%s\" terrain"),
4351 terrain_flag_id_translated_name(
4358 Q_(
"?baseflag:\"%s\" base"),
4359 base_flag_id_translated_name(base_flag_id(psource->
value.
baseflag)));
4365 Q_(
"?roadflag:\"%s\" road"),
4366 road_flag_id_translated_name(road_flag_id(psource->
value.
roadflag)));
4371 Q_(
"?extraflag:\"%s\" extra"),
4372 extra_flag_id_translated_name(
4379 case VUT_MINCALFRAG:
4390 case VUT_SERVERSETTING:
4396 case VUT_TERRAINALTER:
4399 Q_(terrain_alteration_name(
4416 case VUT_CITYSTATUS:
4418 case CITYS_OWNED_BY_ORIGINAL:
4427 case VUT_VISIONLAYER:
4433 national_intelligence_translated_name(psource->
value.
nintel),
4449 return universals_n_name(psource->
kind);
4458 switch (target->
kind) {
4459 case VUT_IMPROVEMENT:
4478 bool changed =
false;
4483 preq->source = *replacement;
4497 const struct requirement_vector *
reqs,
const struct universal *psource)
4535 const struct requirement_vector *
reqs,
4538 bool necessary =
false;
4565 return (!check_necessary || necessary);
4573 bool check_necessary,
const struct requirement_vector *
reqs,
4594 qCritical(
"Unhandled item_found value");
4610 case VUT_NATIONGROUP:
4652 case VUT_IMPROVEMENT:
4657 case VUT_IMPR_GENUS:
4758 case VUT_TERRAINCLASS:
4812 case VUT_BASEFLAG: {
4818 case VUT_ROADFLAG: {
4874 && preq->
range == REQ_RANGE_LOCAL) {
4933 const bool present,
const int max_value)
4937 const int pres_start = (present ? 0 : max_value);
4941 const int range_start = ((max_value - 1) * 2) *
range;
4943 return range_start + pres_start + value;
bool achievement_player_has(const struct achievement *pach, const struct player *pplayer)
Has the given player got the achievement?
int achievement_number(const struct achievement *pach)
Return the achievement id.
const char * achievement_rule_name(struct achievement *pach)
Return untranslated name of this achievement type.
struct achievement * achievement_by_number(int id)
Return achievements of given id.
struct achievement * achievement_by_rule_name(const char *name)
Returns achievement matching rule name or nullptr if there is no achievement with such name.
bool achievement_claimed(const struct achievement *pach)
Has anybody got the achievement?
const char * achievement_name_translation(struct achievement *pach)
Return translated name of this achievement type.
const char * action_rule_name(const struct action *action)
Get the rule name of the action.
int action_number(const struct action *action)
Get the universal number of the action.
struct action * action_by_rule_name(const char *name)
Return the action with the given name.
const QString action_name_translation(const struct action *action)
Get the action name used when displaying the action in the UI.
struct action * action_by_number(action_id act_id)
Return the action with the given id.
bool base_has_flag(const struct base_type *pbase, enum base_flag_id flag)
Check if base provides effect.
bool is_base_flag_card_near(const struct tile *ptile, enum base_flag_id flag)
Returns TRUE iff any cardinally adjacent tile contains a base with the given flag (does not check pti...
bool is_base_flag_near_tile(const struct tile *ptile, enum base_flag_id flag)
Returns TRUE iff any adjacent tile contains a base with the given flag (does not check ptile itself)
bool BV_ISSET(const BV &bv, int bit)
const char * textcalfrag(int frag)
Produce a statically allocated textual representation of the given calendar fragment.
const char * textyear(int year)
Produce a statically allocated textual representation of the given year.
citizens citizens_nation_foreign(const struct city *pcity)
Get the number of foreign citizens.
#define citizens_iterate_end
#define citizens_iterate(_pcity, _pslot, _nationality)
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
Output_type_id output_type_by_identifier(const char *id)
Find the output type for this output identifier.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
const char * get_output_identifier(Output_type_id output)
Return an id string for the output type.
bool is_city_center(const struct city *pcity, const struct tile *ptile)
Return TRUE if the city is centered at the given tile.
const char * get_output_name(Output_type_id output)
Return a translated name for the output type.
citizens city_size_get(const struct city *pcity)
Get the city size.
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define city_tile_iterate_end
int city_culture(const struct city *pcity)
Return current culture score of the city.
int player_culture(const struct player *plr)
Return current culture score of the player.
#define PL_(String1, String2, n)
bool is_server()
Is program type server?
struct government * government_of_player(const struct player *pplayer)
Return the government of a player.
struct government * government_by_number(const Government_type_id gov)
Return the government with the given index.
const char * government_rule_name(const struct government *pgovern)
Return the (untranslated) rule name of the government.
struct government * government_by_rule_name(const char *name)
Returns the government that has the given (untranslated) rule name.
Government_type_id government_number(const struct government *pgovern)
Return the government index.
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
bool great_wonder_is_built(const struct impr_type *pimprove)
Returns whether this wonder is currently built.
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
struct impr_type * improvement_by_rule_name(const char *name)
Does a linear search of improvement_types[].name.vernacular Returns nullptr when none match.
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
Returns whether this wonder has been destroyed.
bool wonder_is_lost(const struct player *pplayer, const struct impr_type *pimprove)
Returns whether the player has lost this wonder after having owned it (small or great).
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
bool wonder_is_built(const struct player *pplayer, const struct impr_type *pimprove)
Returns whether the player is currently in possession of this wonder (small or great) and it hasn't b...
Impr_type_id improvement_number(const struct impr_type *pimprove)
Return the improvement index.
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Returns the number of shields it takes to build this improvement.
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
Returns TRUE if the improvement or wonder is obsolete.
struct city * city_from_wonder(const struct player *pplayer, const struct impr_type *pimprove)
Get the world city with this wonder (small or great).
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define fc_assert_msg(condition, message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_ret_val_msg(condition, val, message,...)
#define current_topo_has_flag(flag)
#define cardinal_adjc_iterate_end
#define adjc_iterate(nmap, center_tile, itr_tile)
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
This tile is native to unit.
const char * move_points_text(int mp, bool reduce)
Simple version of move_points_text_full() – render positive movement points as text without any prefi...
struct nation_type * nation_by_number(const Nation_type_id nation)
Return the nation with the given index.
const char * nation_group_name_translation(const struct nation_group *pgroup)
Return the translated name of a nation group.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
const char * nation_adjective_translation(const struct nation_type *pnation)
Return the (translated) adjective for the given nation.
struct nation_group * nation_group_by_rule_name(const char *name)
Return the nation group that has the given (untranslated) rule name.
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Check if the given nation is in a given group.
struct nation_group * nation_group_by_number(int id)
Return the nation group with the given index.
struct nation_type * nation_by_rule_name(const char *name)
Returns the nation that has the given (untranslated) rule name (adjective).
Nation_type_id nation_index(const struct nation_type *pnation)
Return the nation index.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
const char * nation_group_rule_name(const struct nation_group *pgroup)
Return the (untranslated) rule name of a nation group.
int nation_group_number(const struct nation_group *pgroup)
Return the nation group index.
#define NO_NATION_SELECTED
bool player_knows_techs_with_flag(const struct player *pplayer, enum tech_flag_id flag)
Returns TRUE iff the player knows at least one tech which has the given flag.
bv_diplrel_all_reqs diplrel_req_contradicts(const struct requirement *req)
Get the DiplRel requirements that are known to contradict the specified DiplRel requirement.
int diplrel_by_rule_name(const char *value)
Return the diplomatic relation that has the given (untranslated) rule name.
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
const char * diplrel_name_translation(int value)
Return the translated name of the given diplomatic relation.
bool is_diplrel_to_other(const struct player *pplayer, int diplrel)
Return TRUE iff pplayer has the diplomatic relation to any living player.
bool is_diplrel_between(const struct player *player1, const struct player *player2, int diplrel)
Return TRUE iff player1 has the diplomatic relation to player2.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
int player_age(const struct player *pplayer)
"Age" of the player: number of turns spent alive since created.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
const char * diplrel_rule_name(int value)
Return the (untranslated) rule name of the given diplomatic relation.
#define players_iterate_end
#define players_iterate(_pplayer)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
static enum req_item_found terrain_type_found(const struct requirement *preq, const struct universal *source)
Find if a terrain type fulfills a requirement.
static enum fc_tristate is_terrainflag_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum terrain_flag_id terrflag)
Is there a terrain with the given flag within range of the target?
bool universal_is_relevant_to_requirement(const struct requirement *req, const struct universal *source)
Returns TRUE iff the specified universal is relevant to fulfilling the specified requirement.
bool is_req_in_vec(const struct requirement *req, const struct requirement_vector *vec)
Returns TRUE iff the requirement vector vec contains the requirement req.
static int num_city_buildings(const struct city *pcity, const struct impr_type *building)
Returns the number of buildings of a certain type in a city.
int universal_build_shield_cost(const struct city *pcity, const struct universal *target)
Return the number of shields it takes to build this universal.
static enum req_item_found city_tile_found(const struct requirement *preq, const struct universal *source)
Find if a tile state fulfills a requirement.
static enum fc_tristate is_citystatus_in_range(const struct city *target_city, enum req_range range, enum citystatus_type citystatus)
Is city with specific status in range.
static universal_found universal_found_function[VUT_COUNT]
static enum req_item_found unit_type_found(const struct requirement *preq, const struct universal *source)
Find if a unit type fulfills a requirement.
void universal_extraction(const struct universal *source, int *kind, int *value)
Extract universal structure into its components for serialization; the opposite of universal_by_numbe...
static int num_player_buildings(const struct player *pplayer, const struct impr_type *building)
Returns the number of buildings of a certain type owned by plr.
static enum fc_tristate is_baseflag_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum base_flag_id baseflag)
Is there a base with the given flag within range of the target?
static enum fc_tristate is_achievement_in_range(const struct player *target_player, enum req_range range, const struct achievement *achievement)
Has achievement been claimed by someone in range.
static enum fc_tristate is_minforeignpct_in_range(const struct city *target_city, enum req_range range, int min_foreign_pct)
Is city with at least min_foreign_pct foreigners in range?
static int num_continent_buildings(const struct player *pplayer, int continent, const struct impr_type *building)
Returns the number of buildings of a certain type on a continent.
req_vec_num_in_item req_vec_vector_number(const void *parent_item, const struct requirement_vector *vec)
Returns the requirement vector number of the specified requirement vector in the specified requiremen...
static enum fc_tristate is_extra_type_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, struct extra_type *pextra)
Is there a source extra type within range of the target?
bool universal_fulfills_requirements(bool check_necessary, const struct requirement_vector *reqs, const struct universal *source)
Will the universal 'source' fulfill the requirements in the list? If 'check_necessary' is FALSE: are ...
bool sv_universal_fulfills_requirements(bool check_necessary, const struct requirement_vector *reqs, const struct universal source)
Version of universal_fulfills_requirements that takes the universal by value.
static enum fc_tristate is_building_in_range(const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, enum req_range range, bool survives, const struct impr_type *source)
Are there any source buildings within range of the target that are not obsolete?
bool req_vec_change_apply(const struct req_vec_change *modification, requirement_vector_by_number getter, const void *parent_item)
Returns TRUE iff the specified requirement vector modification was successfully applied to the specif...
bool are_requirements_equal(const struct requirement *req1, const struct requirement *req2)
Returns TRUE if req1 and req2 are equal.
static enum fc_tristate is_nation_group_in_range(const struct player *target_player, enum req_range range, bool survives, const struct nation_group *ngroup)
Is there a nation group within range of the target?
struct req_vec_problem * req_vec_problem_new(int num_suggested_solutions, const char *descr,...)
Returns a new requirement vector problem with the specified number of suggested solutions and the spe...
static enum req_item_found extra_type_found(const struct requirement *preq, const struct universal *source)
Find if an extra type fulfills a requirement.
bool is_req_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement to see if it is active on the given target.
bool is_req_unchanging(const struct requirement *req)
Return TRUE if this is an "unchanging" requirement.
struct req_vec_problem * req_vec_get_first_contradiction(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
Returns the first self contradiction found in the specified requirement vector with suggested solutio...
struct requirement req_from_str(const char *type, const char *range, bool survives, bool present, bool quiet, const char *value)
Parse a requirement type and value string into a requirement structure.
void universal_value_from_str(struct universal *source, const char *value)
Parse requirement value strings into a universal structure.
void req_get_values(const struct requirement *req, int *type, int *range, bool *survives, bool *present, bool *quiet, int *value)
Return the value of a req as a serializable integer.
struct requirement req_from_values(int type, int range, bool survives, bool present, bool quiet, int value)
Set the values of a req from serializable integers.
const char * universal_type_rule_name(const struct universal *psource)
Return untranslated name of the universal source name.
bool are_reqs_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement(s) to see if they are active on the given target.
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Make user-friendly text for the source.
static enum fc_tristate is_goods_type_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, struct goods_type *pgood)
Is there a source goods type within range of the target?
bool universal_replace_in_req_vec(struct requirement_vector *reqs, const struct universal *to_replace, const struct universal *replacement)
Replaces all instances of the universal to_replace with replacement in the requirement vector reqs an...
static enum req_item_found action_found(const struct requirement *preq, const struct universal *source)
Find if an action fulfills a requirement.
QString req_to_fstring(const struct requirement *req)
Returns the given requirement as a formatted string ready for printing.
static enum fc_tristate is_roadflag_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum road_flag_id roadflag)
Is there a road with the given flag within range of the target?
bool are_requirements_contradictions(const struct requirement *req1, const struct requirement *req2)
Returns TRUE if req1 and req2 contradicts each other.
static enum fc_tristate is_diplrel_in_range(const struct player *target_player, const struct player *other_player, enum req_range range, int diplrel)
Is the diplomatic state within range of the target?
void universal_found_functions_init()
Initialise universal_found_function array.
static enum fc_tristate is_unitclassflag_in_range(const struct unit_type *target_unittype, enum req_range range, bool survives, enum unit_class_flag_id ucflag)
Is there a unit with the given flag within range of the target?
int requirement_kind_ereq(const int value, const enum req_range range, const bool present, const int max_value)
Returns (the position of) the given requirement's enumerator in the enumeration of all possible requi...
void req_vec_problem_free(struct req_vec_problem *issue)
De-allocates resources associated with the given requirement vector problem.
static enum req_item_found improvement_found(const struct requirement *preq, const struct universal *source)
Find if an improvement fulfills a requirement.
static enum fc_tristate is_tech_in_range(const struct player *target_player, enum req_range range, bool survives, Tech_type_id tech)
Is there a source tech within range of the target?
static bool players_in_same_range(const struct player *pplayer1, const struct player *pplayer2, enum req_range range)
Returns TRUE if players are in the same requirements range.
enum req_item_found(* universal_found)(const struct requirement *, const struct universal *)
Container for req_item_found functions.
struct universal universal_by_number(const enum universals_n kind, const int value)
Combine values into a universal structure.
enum req_item_found universal_fulfills_requirement(const struct requirement *preq, const struct universal *source)
Will the universal 'source' fulfill this requirement?
static enum fc_tristate is_unitclass_in_range(const struct unit_type *target_unittype, enum req_range range, bool survives, struct unit_class *pclass)
Is there a unit with the given flag within range of the target?
bool req_vec_wants_type(const struct requirement_vector *reqs, enum universals_n kind)
Returns TRUE iff the specified requirement vector has a positive requirement of the specified require...
static int num_world_buildings_total(const struct impr_type *building)
Returns the number of total world buildings (this includes buildings that have been destroyed).
static enum fc_tristate is_techflag_in_range(const struct player *target_player, enum req_range range, enum tech_flag_id techflag)
Is there a tech with the given flag within range of the target?
static enum fc_tristate is_terrain_class_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum terrain_class pclass)
Is there a source terrain class within range of the target?
static enum req_item_found output_type_found(const struct requirement *preq, const struct universal *source)
Find if an output type fulfills a requirement.
static enum fc_tristate is_nation_in_range(const struct player *target_player, enum req_range range, bool survives, const struct nation_type *nation)
Is there a nation within range of the target?
static bool is_city_in_tile(const struct tile *ptile, const struct city *pcity)
Is center of given city in tile.
bool does_req_contradicts_reqs(const struct requirement *req, const struct requirement_vector *vec)
Returns TRUE if the given requirement contradicts the given requirement vector.
static enum req_item_found government_found(const struct requirement *preq, const struct universal *source)
Find if a government fulfills a requirement.
static enum fc_tristate is_unitflag_in_range(const struct unit_type *target_unittype, enum req_range range, bool survives, enum unit_type_flag_id unitflag)
Is there a unit with the given flag within range of the target?
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Return TRUE iff the two sources are equivalent.
static enum req_item_found unit_activity_found(const struct requirement *preq, const struct universal *source)
Find if a unit activity fulfills a requirement.
static enum fc_tristate is_citytile_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, enum citytile_type citytile)
Is center of given city in range.
static enum fc_tristate is_unittype_in_range(const struct unit_type *target_unittype, enum req_range range, bool survives, const struct unit_type *punittype)
Is there a unit of the given type within range of the target?
static enum req_item_found nation_found(const struct requirement *preq, const struct universal *source)
Find if a nation fulfills a requirement.
const char * universal_rule_name(const struct universal *psource)
Return the (untranslated) rule name of the universal.
static enum fc_tristate is_unit_state(const struct unit *target_unit, enum req_range range, bool survives, enum ustate_prop uprop)
Is the given property of the unit state true?
static enum fc_tristate is_minculture_in_range(const struct city *target_city, const struct player *target_player, enum req_range range, int minculture)
Is city or player with at least minculture culture in range?
static enum req_item_found unit_class_found(const struct requirement *preq, const struct universal *source)
Find if a unit class fulfills a requirement.
int universal_number(const struct universal *source)
Return the universal number of the constituent.
static enum fc_tristate is_tile_units_in_range(const struct tile *target_tile, enum req_range range, int max_units)
Is there a tile with max X units within range of the target?
bool universal_is_mentioned_by_requirements(const struct requirement_vector *reqs, const struct universal *psource)
Returns TRUE iff the universal 'psource' is directly mentioned by any of the requirements in 'reqs'.
static enum req_item_found diplrel_found(const struct requirement *preq, const struct universal *source)
Find if a diplrel fulfills a requirement.
static bool player_has_ever_built(const struct player *pplayer, const struct impr_type *building)
Returns whether a building of a certain type has ever been built by pplayer, even if it has subsequen...
static bool nation_contra_group(const struct requirement *nation_req, const struct requirement *group_req)
Returns TRUE if the specified nation requirement contradicts the specified nation group requirement.
static enum fc_tristate is_terrain_alter_possible_in_range(const struct tile *target_tile, enum req_range range, bool survives, enum terrain_alteration alteration)
Is there a terrain which can support the specified infrastructure within range of the target?
static bool are_requirements_opposites(const struct requirement *req1, const struct requirement *req2)
Returns TRUE if req1 and req2 directly negate each other.
static int num_world_buildings(const struct impr_type *building)
Returns the number of buildings of a certain type in the world.
static enum fc_tristate is_extraflag_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum extra_flag_id extraflag)
Is there an extra with the given flag within range of the target?
struct universal universal_by_rule_name(const char *kind, const char *value)
Parse requirement type (kind) and value strings into a universal structure.
static enum fc_tristate is_terrain_in_range(const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, const struct terrain *pterrain)
Is there a source tile within range of the target?
const char * req_vec_change_translation(const struct req_vec_change *change, const requirement_vector_namer namer)
Returns the specified requirement vector change as a translated string ready for use in the user inte...
static bool impr_contra_genus(const struct requirement *impr_req, const struct requirement *genus_req)
Returns TRUE if the specified building requirement contradicts the specified building genus requireme...
static enum fc_tristate is_nationality_in_range(const struct city *target_city, enum req_range range, const struct nation_type *nationality)
Is there a nationality within range of the target?
#define requirement_diplrel_ereq(_id_, _range_, _present_)
signed char req_vec_num_in_item
req_vec_num_in_item a requirement vectors number in an item.
req_vec_num_in_item(* requirement_vector_number)(const void *parent_item, const struct requirement_vector *vec)
Returns the requirement vector number of the specified requirement vector in the specified parent ite...
#define universal_is_mentioned_by_requirement(preq, psource)
#define requirement_vector_iterate_end
struct requirement_vector *(* requirement_vector_by_number)(const void *parent_item, req_vec_num_in_item number)
Returns a writable pointer to the specified requirement vector in the specified parent item or nullpt...
#define requirement_vector_iterate(req_vec, preq)
const char *(* requirement_vector_namer)(req_vec_num_in_item number)
Returns the name of the specified requirement vector number in the parent item or nullptr if parent i...
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Check if road provides effect.
bool is_road_flag_card_near(const struct tile *ptile, enum road_flag_id flag)
Returns TRUE iff any cardinally adjacent tile contains a road with the given flag (does not check pti...
bool is_road_flag_near_tile(const struct tile *ptile, enum road_flag_id flag)
Returns TRUE iff any adjacent tile contains a road with the given flag (does not check ptile itself).
QString ssetv_human_readable(ssetv val, bool present)
Returns the server setting - value pair formated in a user readable way.
const char * ssetv_rule_name(ssetv val)
Returns the server setting - value pair encoded as a string.
bool ssetv_setting_has_value(ssetv val)
Returns if the server setting currently has the value in the pair.
ssetv ssetv_by_rule_name(const char *name)
Returns the server setting - value pair encoded in the string.
#define BOOL_TO_TRISTATE(tri)
struct specialist * specialist_by_rule_name(const char *name)
Return the specialist type with the given (untranslated!) rule name.
const char * specialist_rule_name(const struct specialist *sp)
Return the (untranslated) rule name of the specialist type.
Specialist_type_id specialist_number(const struct specialist *sp)
Return the specialist item_number.
struct specialist * specialist_by_number(const Specialist_type_id id)
Return the specialist pointer for the given number.
const char * specialist_plural_translation(const struct specialist *sp)
Return the (translated, plural) name of the specialist type.
struct packet_game_info info
enum ai_level skill_level
struct player_ai ai_common
struct nation_style * style
req_vec_num_in_item vector_number
enum req_vec_change_operation operation
int num_suggested_solutions
struct req_vec_change * suggested_solutions
enum unit_activity activity
struct unit::@76::@79 server
struct unit * transporter
struct nation_style * style_by_rule_name(const char *name)
Returns style matching rule name or nullptr if there is no style with such name.
const char * style_rule_name(const struct nation_style *pstyle)
Return the (untranslated) rule name of the style.
struct nation_style * style_by_number(int id)
Return style of given id.
int style_number(const struct nation_style *pstyle)
Return the style id.
const char * style_name_translation(const struct nation_style *pstyle)
Return the (translated) name of the style.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
size_t fc_strlcat(char *dest, const char *src, size_t n)
fc_strlcat() provides utf-8 version of (non-standard) function strlcat() It is intended as more user-...
int cat_snprintf(char *str, size_t n, const char *format,...)
cat_snprintf is like a combination of fc_snprintf and fc_strlcat; it does snprintf to the end of an e...
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
struct advance * advance_by_rule_name(const char *name)
Does a linear search of advances[].name.vernacular Returns nullptr when none match.
const char * advance_rule_name(const struct advance *padvance)
Return the (untranslated) rule name of the advance/technology.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
bool is_terrain_class_card_near(const struct tile *ptile, enum terrain_class tclass)
Is there terrain of the given class cardinally near tile? (Does not check ptile itself....
bool is_terrain_flag_near_tile(const struct tile *ptile, enum terrain_flag_id flag)
Returns TRUE iff any adjacent tile contains terrain with the given flag (does not check ptile itself)...
bool is_terrain_flag_card_near(const struct tile *ptile, enum terrain_flag_id flag)
Returns TRUE iff any cardinally adjacent tile contains terrain with the given flag (does not check pt...
struct terrain * terrain_by_number(const Terrain_type_id type)
Return the terrain for the given terrain index.
const char * terrain_rule_name(const struct terrain *pterrain)
Return the (untranslated) rule name of the terrain.
struct terrain * terrain_by_rule_name(const char *name)
Return the terrain type matching the name, or T_UNKNOWN if none matches.
const char * terrain_class_name_translation(enum terrain_class tclass)
Return the (translated) name of the given terrain class.
bool is_terrain_near_tile(const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Returns TRUE iff any adjacent tile contains the given terrain.
bool terrain_can_support_alteration(const struct terrain *pterrain, enum terrain_alteration alter)
Can terrain support given infrastructure?
bool is_terrain_card_near(const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Returns TRUE iff any cardinally adjacent tile contains the given terrain.
bool is_terrain_class_near_tile(const struct tile *ptile, enum terrain_class tclass)
Is there terrain of the given class near tile? (Does not check ptile itself.)
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
What terrain class terrain type belongs to.
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
Terrain_type_id terrain_number(const struct terrain *pterrain)
Return the terrain index.
#define terrain_has_flag(terr, flag)
bool tile_has_extra_flag(const struct tile *ptile, enum extra_flag_id flag)
Check if tile contains extra providing effect.
bool tile_has_base_flag(const struct tile *ptile, enum base_flag_id flag)
Check if tile contains base providing effect.
bool tile_has_native_base(const struct tile *ptile, const struct unit_type *punittype)
Check if tile contains base native for unit.
bool tile_has_road_flag(const struct tile *ptile, enum road_flag_id flag)
Check if tile contains road providing effect.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
struct goods_type * goods_by_number(Goods_type_id id)
Return goods type of given id.
const char * goods_rule_name(struct goods_type *pgood)
Return untranslated name of this goods type.
struct goods_type * goods_by_rule_name(const char *name)
Returns goods type matching rule name or nullptr if there is no goods type with such name.
Goods_type_id goods_number(const struct goods_type *pgood)
Return the goods id.
const char * goods_name_translation(struct goods_type *pgood)
Return translated name of this goods type.
bool city_receives_goods(const struct city *pcity, const struct goods_type *pgood)
Does city receive goods.
#define trade_partners_iterate_end
#define trade_partners_iterate(c, p)
const struct unit_type * utype
struct nation_style * style
struct specialist * specialist
enum impr_genus_id impr_genus
enum citytile_type citytile
struct nation_group * nationgroup
struct extra_type * extra
struct nation_type * nation
struct government * govern
enum citystatus_type citystatus
const struct impr_type * building
struct achievement * achievement
enum unit_activity activity
enum national_intelligence nintel
enum ustate_prop unit_state
Output_type_id outputtype
enum topo_flag topo_property
struct unit_class * uclass
struct nation_type * nationality
int get_transporter_occupancy(const struct unit *ptrans)
Return how many units are in the transport.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
const char * uclass_name_translation(const struct unit_class *pclass)
Return the (translated) name of the unit class.
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
int utype_build_shield_cost(const struct city *pcity, const struct unit_type *punittype)
Returns the number of shields it takes to build this unit type.
struct unit_class * unit_class_by_rule_name(const char *s)
Returns the unit class that has the given (untranslated) rule name.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
struct unit_class * uclass_by_number(const Unit_Class_id id)
Returns unit class pointer for an ID value.
struct unit_type * unit_type_by_rule_name(const char *name)
Returns the unit type that has the given (untranslated) rule name.
Unit_type_id utype_number(const struct unit_type *punittype)
Return the unit type index.
const char * uclass_rule_name(const struct unit_class *pclass)
Return the (untranslated) rule name of the unit class.
Unit_Class_id uclass_number(const struct unit_class *pclass)
Return the unit_class index.
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
static bool utype_has_flag(const struct unit_type *punittype, int flag)