104 enum unit_activity new_activity);
106 enum unit_activity new_activity,
111 struct tile *target_tile,
const struct city *target_city,
112 const struct unit *target_unit,
bool disturb_player,
113 const enum action_requester requester);
115 struct city *pcity,
const struct action *paction);
117 struct tile *ptile,
const char *
name,
118 const struct action *paction);
121 struct city *pcity_dest,
122 const struct action *paction);
125 struct city *pcity_dest,
126 const struct action *paction);
128 const struct action *paction);
130 struct tile *def_tile,
const struct action *paction);
132 struct unit *act_unit,
133 struct city *tgt_city,
134 const struct action *paction);
136 const struct action *paction);
138 const struct action *paction);
140 struct unit *act_unit,
141 struct city *tgt_city,
142 const struct action *paction);
144 struct unit *act_unit,
145 struct city *tgt_city,
147 const struct action *paction);
149 struct unit *act_unit,
150 struct city *tgt_city,
153 const struct action *paction);
155 const struct action *paction,
165 int number_of_upgraded_units = 0;
168 if (
nullptr == from_unittype) {
170 qDebug(
"handle_unit_type_upgrade() invalid unit type %d", uti);
177 _(
"Illegal packet, can't upgrade %s (yet)."),
194 paction->
id, ACT_REQ_SS_AGENT)) {
195 number_of_upgraded_units++;
205 if (number_of_upgraded_units > 0) {
212 PL_(
"%d %s upgraded to %s for %d gold.",
213 "%d %s upgraded to %s for %d gold.",
214 cost * number_of_upgraded_units),
215 number_of_upgraded_units,
218 cost * number_of_upgraded_units);
222 _(
"No units could be upgraded."));
234 enum action_requester ordered_by,
235 const struct action *paction)
243 if (ordered_by == ACT_REQ_PLAYER) {
247 PL_(
"%s upgraded to %s for %d gold.",
248 "%s upgraded to %s for %d gold.", cost),
262 struct tile *pdesttile,
263 const struct action *paction)
268 bv_unit_types unique_on_tile;
279 bool unique_conflict =
false;
285 unique_conflict =
true;
296 unique_conflict =
true;
304 if (unique_conflict) {
305 log_debug(
"capture units: already got unique unit");
308 _(
"You can only have one %s."),
unit_link(to_capture));
322 const char *victim_link;
338 _(
"Your %s succeeded in capturing the %s %s."),
343 _(
"Your %s was captured by the %s."), victim_link,
348 pdesttile, victim_link);
350 if (
nullptr != pcity) {
381 ACTION_CONQUER_CITY, ACT_REQ_RULES))
384 "", ACTION_CONQUER_CITY2, ACT_REQ_RULES))
387 punit, def_tile,
nullptr)
390 ACTION_TRANSPORT_DISEMBARK1, ACT_REQ_RULES))
393 punit, def_tile,
nullptr)
396 ACTION_TRANSPORT_DISEMBARK2, ACT_REQ_RULES))
418 struct unit *target,
const struct action *paction)
422 struct tile *target_tile;
450 if (pcity ==
nullptr) {
460 _(
"The %s don't have a capital to expel their %s to."),
474 _(
"Your %s succeeded in expelling the %s %s."),
479 _(
"Your %s was expelled by the %s."), target_link,
484 qCritical(
"Bug in unit expulsion: unit can't teleport.");
504 struct unit *tgt_unit,
const struct action *paction)
508 struct player *tgt_player;
509 struct tile *tgt_tile;
512 const char *tgt_unit_owner;
535 healing_limit = tgt_hp_max / 4;
538 tgt_unit->
hp =
MIN(tgt_unit->
hp + healing_limit, tgt_hp_max);
549 if (act_player == tgt_player) {
552 tgt_unit_owner =
_(
"your");
560 _(
"Your %s heals %s %s."), act_unit_link, tgt_unit_owner,
563 if (act_player != tgt_player) {
566 _(
"%s %s heals your %s."),
568 act_unit_link, tgt_unit_link);
585 struct unit *tgt_unit,
586 const struct action *paction)
603 struct unit *tgt_unit,
604 const struct action *paction)
623 struct unit *tgt_unit,
624 const struct action *paction)
639 struct tile *tgt_tile,
const struct action *paction)
649 unit_move(act_unit, tgt_tile, move_cost,
nullptr,
true,
false);
663 struct unit *tgt_unit,
664 const struct action *paction)
666 struct tile *tgt_tile;
683 unit_move(act_unit, tgt_tile, move_cost, tgt_unit,
false,
false);
696 const struct player *oplayer)
698 enum diplstate_type ds;
708 && ds != DS_TEAM && pplayer != oplayer;
719 const struct tile *target_tile,
720 const struct city *target_city,
721 const struct unit *target_unit)
723 struct player *target_player =
nullptr;
741 switch (paction->
result) {
756 case ACTRES_PARADROP:
779 case ACTRES_ESTABLISH_EMBASSY:
780 case ACTRES_SPY_INVESTIGATE_CITY:
781 case ACTRES_SPY_POISON:
782 case ACTRES_SPY_SPREAD_PLAGUE:
783 case ACTRES_SPY_STEAL_GOLD:
784 case ACTRES_SPY_SABOTAGE_CITY:
785 case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
786 case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
787 case ACTRES_SPY_STEAL_TECH:
788 case ACTRES_SPY_TARGETED_STEAL_TECH:
789 case ACTRES_SPY_INCITE_CITY:
790 case ACTRES_TRADE_ROUTE:
791 case ACTRES_MARKETPLACE:
792 case ACTRES_HELP_WONDER:
793 case ACTRES_SPY_BRIBE_UNIT:
794 case ACTRES_SPY_SABOTAGE_UNIT:
795 case ACTRES_CAPTURE_UNITS:
796 case ACTRES_FOUND_CITY:
797 case ACTRES_JOIN_CITY:
798 case ACTRES_STEAL_MAPS:
799 case ACTRES_SPY_NUKE:
801 case ACTRES_NUKE_CITY:
802 case ACTRES_NUKE_UNITS:
803 case ACTRES_DESTROY_CITY:
804 case ACTRES_EXPEL_UNIT:
805 case ACTRES_RECYCLE_UNIT:
806 case ACTRES_DISBAND_UNIT:
807 case ACTRES_HOME_CITY:
808 case ACTRES_UPGRADE_UNIT:
810 case ACTRES_HEAL_UNIT:
811 case ACTRES_STRIKE_BUILDING:
812 case ACTRES_STRIKE_PRODUCTION:
813 case ACTRES_CONQUER_CITY:
814 case ACTRES_TRANSFORM_TERRAIN:
815 case ACTRES_CULTIVATE:
818 case ACTRES_CLEAN_POLLUTION:
819 case ACTRES_CLEAN_FALLOUT:
825 case ACTRES_IRRIGATE:
826 case ACTRES_TRANSPORT_ALIGHT:
827 case ACTRES_TRANSPORT_UNLOAD:
828 case ACTRES_TRANSPORT_DISEMBARK:
829 case ACTRES_TRANSPORT_BOARD:
830 case ACTRES_TRANSPORT_EMBARK:
831 case ACTRES_SPY_ATTACK:
840 if (target_city ==
nullptr) {
848 if (target_unit ==
nullptr) {
855 if (target_tile ==
nullptr) {
870 if (target_tile ==
nullptr) {
886 if (target_player ==
nullptr) {
913 return target_player;
923 const struct tile *target_tile,
924 const struct city *target_city,
925 const struct unit *target_unit)
931 struct player *war_player;
936 if (war_player !=
nullptr) {
958 struct unit *actor_unit,
985 (is_target ? &enabler->target_reqs : &enabler->actor_reqs))
987 &enabler->actor_reqs)) {
1003 struct unit *actor_unit,
1030 (is_target ? &enabler->target_reqs : &enabler->actor_reqs))
1032 &enabler->actor_reqs)) {
1048 const struct tile *target_tile,
1049 const struct city *target_city,
1050 const struct unit *target_unit)
1052 struct player *must_war_player;
1053 const struct action *paction;
1057 struct player *tgt_player =
nullptr;
1073 if (target_city ==
nullptr) {
1078 if (target_unit ==
nullptr) {
1084 if (target_tile ==
nullptr) {
1107 }
else if (target_unit) {
1110 }
else if (target_tile) {
1129 if (target_tile && unit_list_size(target_tile->
units) > 0) {
1146 switch (paction->
result) {
1147 case ACTRES_UPGRADE_UNIT:
1150 case ACTRES_AIRLIFT:
1153 case ACTRES_NUKE_UNITS:
1159 case ACTRES_CONQUER_CITY:
1163 city_tile(target_city),
false,
nullptr,
true);
1165 action_custom =
MR_OK;
1168 case ACTRES_TRANSPORT_EMBARK:
1172 unit_tile(target_unit),
false,
nullptr,
false);
1174 action_custom =
MR_OK;
1177 case ACTRES_TRANSPORT_DISEMBARK:
1181 target_tile,
false,
nullptr,
false);
1183 action_custom =
MR_OK;
1197 }
else if ((!can_exist
1199 USP_LIVABLE_TILE,
false))
1202 act_id, USP_LIVABLE_TILE,
1206 }
else if ((!on_native
1208 USP_NATIVE_TILE,
false))
1228 && (!
game.
info.paradrop_to_transport
1232 }
else if (target_tile
1240 USP_TRANSPORTED,
true)) {
1244 USP_TRANSPORTED,
false)) {
1248 USP_TRANSPORTING,
true)) {
1252 USP_TRANSPORTING,
false)) {
1256 USP_HAS_HOME_CITY,
true)) {
1260 USP_HAS_HOME_CITY,
false)) {
1266 }
else if (act_player && tgt_player
1272 act_id, DS_PEACE,
true)) {
1274 explnat->peace_with = tgt_player;
1275 }
else if ((must_war_player =
need_war_player(punit, act_id, target_tile,
1276 target_city, target_unit))) {
1278 explnat->no_war_with = must_war_player;
1281 }
else if (tgt_player &&
unit_owner(punit) != tgt_player
1285 }
else if (tgt_player &&
unit_owner(punit) == tgt_player
1293 explnat->no_act_nation =
unit_owner(punit)->nation;
1294 }
else if (tgt_player
1298 explnat->no_act_nation = tgt_player->
nation;
1299 }
else if ((target_tile &&
tile_city(target_tile))
1301 CITYT_CENTER,
true)) {
1303 }
else if ((target_tile && !
tile_city(target_tile))
1305 CITYT_CENTER,
false)) {
1307 }
else if ((target_tile &&
tile_owner(target_tile) !=
nullptr)
1309 CITYT_CLAIMED,
true)) {
1311 }
else if ((target_tile &&
tile_owner(target_tile) ==
nullptr)
1313 CITYT_CLAIMED,
false)) {
1315 }
else if (paction && punit
1337 }
else if (paction && punit
1351 }
else if (target_city
1360 }
else if (target_city
1370 && action_custom !=
ATT_OK) {
1371 switch (action_custom) {
1408 && action_custom !=
MR_OK) {
1409 switch (action_custom) {
1441 target_city, target_unit))) {
1443 explnat->blocker = blocker;
1455 const struct tile *target_tile,
1456 const struct city *target_city,
1457 const struct unit *target_unit)
1460 target_city, target_unit);
1473 const struct tile *target_tile,
1474 const struct city *target_city,
1475 const struct unit *target_unit)
1479 punit,
ACTION_ANY, target_tile, target_city, target_unit);
1481 switch (explnat->
kind) {
1486 "Asked to explain why a non actor can't act.");
1489 _(
"Unit cannot do anything."));
1493 _(
"Your %s found no suitable target."),
1503 _(
"Your %s found no suitable target."),
1511 USP_LIVABLE_TILE,
false)
1529 _(
"Your %s cannot act from %s. "
1530 "Only %s can act from a non livable tile."),
1537 _(
"Unit cannot act from %s."),
1544 _(
"Unit cannot act against %s."),
1549 _(
"This unit is being transported, and"
1550 " so cannot act."));
1554 _(
"This unit cannot act when it isn't being "
1559 _(
"This unit is transporting, and"
1560 " so cannot act."));
1564 _(
"This unit cannot act when it isn't transporting."));
1568 _(
"This unit has a home city, and so cannot act."));
1572 _(
"This unit cannot act unless it has a home city."));
1576 _(
"You must declare war on %s first. Try using "
1577 "the Nations report."),
1582 _(
"You must break peace with %s first. Try using"
1583 " the Nations report."),
1588 _(
"This unit cannot act against domestic targets."));
1592 _(
"This unit cannot act against foreign targets."));
1597 _(
"%s %s cannot act."),
1604 _(
"This unit cannot act against %s targets."),
1609 _(
"This unit has too few moves left to act."));
1613 _(
"This unit cannot act against city centers."));
1617 _(
"This unit cannot act against non city centers."));
1621 _(
"This unit cannot act against claimed tiles."));
1625 _(
"This unit cannot act against unclaimed tiles."));
1629 _(
"This unit is too near its target to act."));
1633 _(
"This unit is too far away from its target to act."));
1637 _(
"Can't perform any action this scenario permits."));
1641 _(
"Can't perform any action this close to a city."));
1646 _(
"%s can't do anything to %s. It is too big."),
1652 _(
"%s needs an improvement to grow, so "
1653 "%s cannot do anything to it."),
1659 _(
"%s don't have enough capacity, so "
1660 "%s cannot do anything."),
1667 _(
"%s can't do anything to an unknown target tile."),
1673 _(
"You can't afford having your %s do anything."
1674 " %d gold needed."),
1682 PL_(
"Treasury contains %d gold.",
1689 PL_(
"%s can't do anything. %d gold may help. %s",
1690 "%s can't do anything. %d gold may help. %s",
1698 _(
"%s cannot move that far from the coast line."),
1704 _(
"%s cannot disembark outside of a city or a native base "
1711 _(
"%s can't do anything since there is an unreachable "
1717 _(
"%s can't do anything since you already have a %s."),
1728 _(
"No action possible."));
1744 const int target_unit_id_client,
1745 const int target_tile_id,
1746 const int target_extra_id_client,
1747 const bool disturb_player)
1749 struct player *actor_player;
1750 struct unit *actor_unit;
1751 struct tile *target_tile;
1753 struct unit *target_unit;
1754 struct city *target_city;
1756 int actor_target_distance;
1758 int target_extra_id = target_extra_id_client;
1762 bool at_least_one_action =
false;
1777 if (!target_tile || !actor_unit || !actor_player
1778 || actor_unit->
owner != actor_player) {
1779 dsend_packet_unit_actions(
1781 target_tile_id, target_extra_id, disturb_player, probabilities);
1799 if (target_unit &&
unit_tile(target_unit) != target_tile) {
1802 dsend_packet_unit_actions(
1804 target_tile_id, target_extra_id, disturb_player, probabilities);
1822 actor_target_distance =
1837 if (plrtile && plrtile->
site) {
1841 probabilities[act] =
1846 actor_target_distance)) {
1866 probabilities[act] =
1876 probabilities[act] =
1886 probabilities[act] =
1894 if (actor_target_distance == 0) {
1918 at_least_one_action =
true;
1930 target_city_id = plrtile->
site->identity;
1936 target_unit_id = target_unit->
id;
1944 target_extra_id = target_extra->
id;
1957 "Invalid action target kind.");
1971 dsend_packet_unit_actions(pc, actor_unit_id, target_unit_id,
1972 target_city_id, target_tile_id, target_extra_id,
1973 disturb_player, probabilities);
1975 if (disturb_player && !at_least_one_action) {
2005 const struct tile *target_tile,
2006 const struct city *target_city,
2007 const struct unit *target_unit)
2013 target_city, target_unit);
2014 switch (explnat->
kind) {
2023 _(
"Only %s can do %s."), qUtf8Printable(roles),
2038 _(
"Your %s found no target suitable for %s."),
2047 _(
"Having your %s do %s to this target is redundant."),
2057 USP_LIVABLE_TILE,
false)
2062 USP_LIVABLE_TILE,
false)) {
2076 _(
"Your %s can't do %s from %s. "
2077 "Only %s can do %s from a non livable tile."),
2097 _(
"Your %s can't do %s to %s."),
2106 _(
"Your %s can't do %s while being transported."),
2108 qUtf8Printable(qUtf8Printable(
2116 _(
"Your %s can't do %s while not being transported."),
2125 _(
"Your %s can't do %s while transporting."),
2134 _(
"Your %s can't do %s while not transporting."),
2143 _(
"Your %s can't do %s because it has a home city."),
2152 _(
"Your %s can't do %s because it is homeless."),
2161 _(
"Your %s can't do %s while you"
2162 " aren't at war with %s."),
2173 _(
"Your %s can't do %s while you"
2174 " are at peace with %s. Try using"
2175 " the Nations report."),
2185 _(
"Your %s can't do %s to domestic %s."),
2188 action_target_kind_translated_name(
2196 _(
"Your %s can't do %s to foreign %s."),
2199 action_target_kind_translated_name(
2207 _(
"%s %s can't do %s."),
2216 _(
"Your %s can't do %s to %s %s."),
2220 action_target_kind_translated_name(
2228 _(
"Your %s has too few moves left to do %s."),
2237 _(
"Your %s can't do %s to city centers."),
2247 _(
"Your %s can only do %s to city centers."),
2256 _(
"Your %s can't do %s to claimed tiles."),
2266 _(
"Your %s can't do %s to unclaimed tiles."),
2276 PL_(
"Your %s must be at least %d tile away to do %s.",
2277 "Your %s must be at least %d tiles away to do %s.",
2288 PL_(
"Your %s can't be more than %d tile away to do %s.",
2289 "Your %s can't be more than %d tiles away to do %s.",
2298 _(
"Can't do %s in this scenario."),
2305 _(
"Can't do %s this close to a city."),
2311 _(
"%s can't do %s to %s. It is too big."),
2320 _(
"%s needs an improvement to grow, so "
2321 "%s cannot do %s."),
2328 _(
"%s has no capacity to %s %s."),
2337 _(
"%s can't do %s to an unknown tile."),
2347 PL_(
"Treasury contains %d gold.",
2354 PL_(
"%s can't do %s for %d gold. %s",
2355 "%s can't do %s for %d gold. %s",
2364 _(
"%s cannot move that far from the coast line."),
2372 _(
"%s cannot disembark outside of a city or a native base "
2381 _(
"Your %s can't do %s there since there's an "
2382 "unreachable unit."),
2389 _(
"You already have a %s."),
2396 _(
"Your %s can't do %s when %s is legal."),
2428 struct player *pplayer,
bool information_revealed,
struct unit *act_unit,
2429 struct action *stopped_action,
struct player *tgt_player,
2430 struct tile *tgt_tile,
const enum action_requester requester)
2439 (requester == ACT_REQ_PLAYER || requester == ACT_REQ_SS_AGENT),
false,
2440 "The player wasn't responsible for this.");
2442 if (!information_revealed) {
2452 nullptr,
unit_owner(act_unit), tgt_player,
nullptr,
nullptr,
nullptr,
2453 act_unit,
unit_type_get(act_unit),
nullptr,
nullptr, stopped_action,
2454 EFT_ILLEGAL_ACTION_HP_COST);
2457 punishment_hp =
MAX(0, punishment_hp);
2460 act_unit->
hp =
MAX(0, act_unit->
hp - punishment_hp);
2462 if (punishment_hp != 0) {
2472 if (act_unit->
hp > 0) {
2480 _(
"Your %s lost %d hit points while attempting to"
2493 _(
"Your %s was killed while attempting to do %s."),
2497 wipe_unit(act_unit, ULR_KILLED,
nullptr);
2506 nullptr,
unit_owner(act_unit), tgt_player,
nullptr,
nullptr,
nullptr,
2507 act_unit,
unit_type_get(act_unit),
nullptr,
nullptr, stopped_action,
2508 EFT_ILLEGAL_ACTION_MOVE_COST);
2511 punishment_mp =
MAX(0, punishment_mp);
2517 if (punishment_mp != 0) {
2524 _(
"Your %s lost %s MP for attempting an illegal action."),
2529 return punishment_mp != 0 || punishment_hp != 0;
2540 struct tile *target_tile,
const struct city *target_city,
2541 const struct unit *target_unit,
bool disturb_player,
2542 const enum action_requester requester)
2544 bool information_revealed;
2556 target_unit, target_tile,
nullptr));
2558 if (disturb_player) {
2562 (information_revealed ? E_UNIT_ILLEGAL_ACTION : E_BAD_COMMAND),
2563 actor, stopped_action_id, target_tile, target_city, target_unit);
2567 actor, stopped_action, tgt_player,
2568 target_tile, requester);
2570 if (!disturb_player && was_punished) {
2577 (information_revealed ? E_UNIT_ILLEGAL_ACTION : E_BAD_COMMAND),
2579 _(
"No explanation why you couldn't do %s. This is a bug."
2580 " Sorry about that. -- Sveinung"),
2589 const int target_id,
bool disturb_player)
2591 dsend_packet_unit_action_answer(pc, actor_id, target_id, 0,
ACTION_NONE,
2603 const int target_id,
2605 bool disturb_player)
2613 if (
nullptr == paction) {
2615 qCritical(
"handle_unit_action_query() the action %d doesn't exist.",
2622 if (
nullptr == pactor) {
2624 qDebug(
"handle_unit_action_query() invalid actor %d", actor_id);
2629 switch (paction->
result) {
2630 case ACTRES_SPY_BRIBE_UNIT:
2633 dsend_packet_unit_action_answer(pc, actor_id, target_id,
2635 action_type, disturb_player);
2638 punit ?
unit_owner(punit) :
nullptr,
nullptr,
nullptr,
2639 punit, disturb_player, ACT_REQ_PLAYER);
2644 case ACTRES_SPY_INCITE_CITY:
2647 dsend_packet_unit_action_answer(pc, actor_id, target_id,
2649 action_type, disturb_player);
2652 pcity ?
city_owner(pcity) :
nullptr,
nullptr, pcity,
2653 nullptr, disturb_player, ACT_REQ_PLAYER);
2658 case ACTRES_UPGRADE_UNIT:
2670 dsend_packet_unit_action_answer(pc, actor_id, target_id, upgr_cost,
2671 action_type, disturb_player);
2674 pcity ?
city_owner(pcity) :
nullptr,
nullptr, pcity,
2675 nullptr, disturb_player, ACT_REQ_PLAYER);
2680 case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
2681 case ACTRES_STRIKE_BUILDING:
2688 pcity ?
city_owner(pcity) :
nullptr,
nullptr, pcity,
2689 nullptr, disturb_player, ACT_REQ_PLAYER);
2706 const int target_id,
const int sub_tgt_id,
2710 action_type, ACT_REQ_PLAYER);
2719 const int target_id,
const int sub_tgt_id,
2724 name, action_type, ACT_REQ_PLAYER);
2738 const int target_id,
const int sub_tgt_id_incoming,
2740 const enum action_requester requester)
2752 qCritical(
"unit_perform_action() the action %d doesn't exist.",
2765 sub_tgt_id = sub_tgt_id_incoming;
2773 target_extra =
nullptr;
2778 && target_extra ==
nullptr) {
2780 qDebug(
"unit_perform_action() action %d requires action "
2781 "but extra id %d is invalid.",
2782 action_type, sub_tgt_id);
2786 if (
nullptr == actor_unit) {
2788 qDebug(
"handle_unit_do_action() invalid actor %d", actor_id);
2798 #define ACTION_STARTED_UNIT_CITY(action, actor, target, action_performer) \
2800 && is_action_enabled_unit_on_city(action_type, actor_unit, pcity)) { \
2802 script_server_signal_emit("action_started_unit_city", \
2803 action_by_number(action), actor, target); \
2804 if (!actor || !unit_is_alive(actor_id)) { \
2808 if (!target || !city_exist(target_id)) { \
2812 success = action_performer; \
2814 action_success_actor_price(paction, actor_id, actor); \
2818 illegal_action(pplayer, actor_unit, action_type, \
2819 pcity ? city_owner(pcity) : nullptr, nullptr, pcity, \
2820 nullptr, true, requester); \
2823 #define ACTION_STARTED_UNIT_SELF(action, actor, action_performer) \
2825 && is_action_enabled_unit_on_self(action_type, actor_unit)) { \
2827 script_server_signal_emit("action_started_unit_self", \
2828 action_by_number(action), actor); \
2829 if (!actor || !unit_is_alive(actor_id)) { \
2833 success = action_performer; \
2835 action_success_actor_price(paction, actor_id, actor); \
2839 illegal_action(pplayer, actor_unit, action_type, \
2840 unit_owner(actor_unit), nullptr, nullptr, actor_unit, \
2844 #define ACTION_STARTED_UNIT_UNIT(action, actor, target, action_performer) \
2846 && is_action_enabled_unit_on_unit(action_type, actor_unit, punit)) { \
2848 script_server_signal_emit("action_started_unit_unit", \
2849 action_by_number(action), actor, target); \
2850 if (!actor || !unit_is_alive(actor_id)) { \
2854 if (!target || !unit_is_alive(target_id)) { \
2858 success = action_performer; \
2860 action_success_actor_price(paction, actor_id, actor); \
2861 action_success_target_pay_mp(paction, target_id, punit); \
2865 illegal_action(pplayer, actor_unit, action_type, \
2866 punit ? unit_owner(punit) : nullptr, nullptr, nullptr, \
2867 punit, true, requester); \
2870 #define ACTION_STARTED_UNIT_UNITS(action, actor, target, action_performer) \
2872 && is_action_enabled_unit_on_units(action_type, actor_unit, \
2875 script_server_signal_emit("action_started_unit_units", \
2876 action_by_number(action), actor, target); \
2877 if (!actor || !unit_is_alive(actor_id)) { \
2881 success = action_performer; \
2883 action_success_actor_price(paction, actor_id, actor); \
2887 illegal_action(pplayer, actor_unit, action_type, nullptr, target_tile, \
2888 nullptr, nullptr, true, requester); \
2891 #define ACTION_STARTED_UNIT_TILE(action, actor, target, action_performer) \
2893 && is_action_enabled_unit_on_tile(action_type, actor_unit, \
2894 target_tile, target_extra)) { \
2896 script_server_signal_emit("action_started_unit_tile", \
2897 action_by_number(action), actor, target); \
2898 if (!actor || !unit_is_alive(actor_id)) { \
2902 success = action_performer; \
2904 action_success_actor_price(paction, actor_id, actor); \
2908 illegal_action(pplayer, actor_unit, action_type, \
2909 target_tile ? tile_owner(target_tile) : nullptr, \
2910 target_tile, nullptr, nullptr, true, requester); \
2913 switch (paction->
result) {
2914 case ACTRES_SPY_BRIBE_UNIT:
2916 action_type, actor_unit, punit,
2919 case ACTRES_SPY_SABOTAGE_UNIT:
2922 action_type, actor_unit, punit,
2925 case ACTRES_EXPEL_UNIT:
2927 action_type, actor_unit, punit,
2930 case ACTRES_HEAL_UNIT:
2932 action_type, actor_unit, punit,
2935 case ACTRES_TRANSPORT_ALIGHT:
2937 action_type, actor_unit, punit,
2940 case ACTRES_TRANSPORT_UNLOAD:
2942 action_type, actor_unit, punit,
2945 case ACTRES_TRANSPORT_BOARD:
2947 action_type, actor_unit, punit,
2950 case ACTRES_TRANSPORT_EMBARK:
2952 action_type, actor_unit, punit,
2955 case ACTRES_DISBAND_UNIT:
2959 case ACTRES_FORTIFY:
2963 case ACTRES_CONVERT:
2967 case ACTRES_SPY_SABOTAGE_CITY:
2970 action_type, actor_unit, pcity,
2973 case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
2976 action_type, actor_unit, pcity,
2979 case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
2982 action_type, actor_unit, pcity,
2985 case ACTRES_SPY_POISON:
2988 action_type, actor_unit, pcity,
2989 spy_poison(pplayer, actor_unit, pcity, paction));
2991 case ACTRES_SPY_SPREAD_PLAGUE:
2993 action_type, actor_unit, pcity,
2996 case ACTRES_SPY_INVESTIGATE_CITY:
2999 action_type, actor_unit, pcity,
3002 case ACTRES_ESTABLISH_EMBASSY:
3005 action_type, actor_unit, pcity,
3008 case ACTRES_SPY_INCITE_CITY:
3011 action_type, actor_unit, pcity,
3014 case ACTRES_SPY_STEAL_TECH:
3017 action_type, actor_unit, pcity,
3020 case ACTRES_SPY_TARGETED_STEAL_TECH:
3023 action_type, actor_unit, pcity,
3026 case ACTRES_SPY_STEAL_GOLD:
3029 action_type, actor_unit, pcity,
3032 case ACTRES_STEAL_MAPS:
3035 action_type, actor_unit, pcity,
3038 case ACTRES_TRADE_ROUTE:
3040 action_type, actor_unit, pcity,
3043 case ACTRES_MARKETPLACE:
3045 action_type, actor_unit, pcity,
3048 case ACTRES_HELP_WONDER:
3050 action_type, actor_unit, pcity,
3053 case ACTRES_SPY_NUKE:
3056 action_type, actor_unit, pcity,
3059 case ACTRES_JOIN_CITY:
3061 action_type, actor_unit, pcity,
3064 case ACTRES_DESTROY_CITY:
3066 action_type, actor_unit, pcity,
3069 case ACTRES_RECYCLE_UNIT:
3071 action_type, actor_unit, pcity,
3074 case ACTRES_HOME_CITY:
3076 action_type, actor_unit, pcity,
3079 case ACTRES_UPGRADE_UNIT:
3081 action_type, actor_unit, pcity,
3084 case ACTRES_CONQUER_CITY:
3087 action_type, actor_unit, pcity,
3090 case ACTRES_STRIKE_BUILDING:
3092 action_type, actor_unit, pcity,
3096 case ACTRES_STRIKE_PRODUCTION:
3098 action_type, actor_unit, pcity,
3101 case ACTRES_AIRLIFT:
3105 case ACTRES_NUKE_CITY:
3107 action_type, actor_unit, pcity,
3110 case ACTRES_CAPTURE_UNITS:
3112 action_type, actor_unit, target_tile,
3115 case ACTRES_BOMBARD:
3118 action_type, actor_unit, target_tile,
3124 do_attack(actor_unit, target_tile, paction));
3126 case ACTRES_NUKE_UNITS:
3128 action_type, actor_unit, target_tile,
3129 unit_nuke(pplayer, actor_unit, target_tile, paction));
3131 case ACTRES_SPY_ATTACK:
3133 action_type, actor_unit, target_tile,
3134 spy_attack(pplayer, actor_unit, target_tile, paction));
3136 case ACTRES_FOUND_CITY:
3138 action_type, actor_unit, target_tile,
3143 action_type, actor_unit, target_tile,
3144 unit_nuke(pplayer, actor_unit, target_tile, paction));
3146 case ACTRES_PARADROP:
3150 case ACTRES_TRANSPORT_DISEMBARK:
3153 action_type, actor_unit, target_tile,
3154 do_disembark(pplayer, actor_unit, target_tile, paction));
3156 case ACTRES_TRANSFORM_TERRAIN:
3160 case ACTRES_CULTIVATE:
3168 case ACTRES_PILLAGE:
3170 action_type, actor_unit, target_tile,
3173 case ACTRES_CLEAN_POLLUTION:
3175 action_type, actor_unit, target_tile,
3178 case ACTRES_CLEAN_FALLOUT:
3180 action_type, actor_unit, target_tile,
3185 action_type, actor_unit, target_tile,
3190 action_type, actor_unit, target_tile,
3195 action_type, actor_unit, target_tile,
3198 case ACTRES_IRRIGATE:
3200 action_type, actor_unit, target_tile,
3240 struct city *new_pcity,
bool rehome)
3255 if (old_owner != new_owner) {
3264 if (pcity !=
nullptr
3277 unit_list_remove(old_owner->
units, punit);
3278 unit_list_prepend(new_owner->
units, punit);
3279 punit->
owner = new_owner;
3339 const struct action *paction)
3341 const char *giver =
nullptr;
3355 _(
"%s transferred control over a %s to you in %s."), giver,
3371 struct city *pcity,
const struct action *paction)
3426 struct tile *ptile,
const char *
name,
3427 const struct action *paction)
3431 struct player *nationality;
3472 enum unit_activity activity,
3477 if (
nullptr == punit) {
3479 qDebug(
"handle_unit_change_activity() invalid unit %d", unit_id);
3507 if (
activity == ACTIVITY_EXPLORE) {
3520 enum unit_activity
activity,
int target_id)
3524 if (target_id < 0 || target_id >=
game.
control.num_extra_types) {
3525 activity_target =
nullptr;
3549 packet_unit_short_info short_packet;
3550 packet_unit_info full_packet;
3557 struct player *pplayer = pconn->playing;
3559 if (pplayer !=
nullptr) {
3566 send_packet_unit_info(pconn, &full_packet);
3568 send_packet_unit_short_info(pconn, &short_packet,
false);
3571 }
else if (pconn->observer) {
3573 send_packet_unit_info(pconn, &full_packet);
3584 struct packet_unit_bombard_info info;
3585 info.attacker_unit_id = pattacker->
id;
3586 info.target_tile = ptarget->
index;
3594 lsend_packet_unit_bombard_info(other_player->connections, &info);
3609 if (
nullptr == pconn->playing && pconn->observer) {
3610 send_packet_unit_bombard_info(pconn, &info);
3620 int att_veteran,
int def_veteran)
3622 struct packet_unit_combat_info combat;
3624 combat.attacker_unit_id = pattacker->
id;
3625 combat.defender_unit_id = pdefender->
id;
3626 combat.attacker_hp = pattacker->
hp;
3627 combat.defender_hp = pdefender->
hp;
3628 combat.make_att_veteran = att_veteran;
3629 combat.make_def_veteran = def_veteran;
3638 lsend_packet_unit_combat_info(other_player->connections, &combat);
3658 if (
nullptr == pconn->playing && pconn->observer) {
3659 send_packet_unit_combat_info(pconn, &combat);
3670 const struct action *paction,
3692 const struct action *paction)
3696 std::set<struct player *> players_to_notify;
3702 log_debug(
"Start bombard: %s %s to %d, %d.",
3712 "Trying to attack a unit with which you have "
3713 "peace or cease-fire at (%d, %d).",
3717 "Trying to attack a unit with which you have "
3718 "alliance at (%d, %d).",
3723 enum direction8 facing;
3727 pdefender->tile, &facing);
3738 players_to_notify.insert(
unit_owner(pdefender));
3741 pdefender->hp = def_hp;
3765 for (
auto player_to_notify : players_to_notify) {
3767 player_to_notify, ptile, E_UNIT_BOMB_DEF,
ftc_server,
3770 _(
"Your units at %s were bombarded by a %s %s %s [id:%d]."),
3779 _(
"Your %s %s [id:%d] bombarded the units at %s."),
3804 struct tile *def_tile,
const struct action *paction)
3812 log_debug(
"Start nuclear attack: %s %s against (%d, %d).",
3819 _(
"Your %s was shot down by "
3820 "SDI defenses, what a waste."),
3823 _(
"The nuclear attack on %s was avoided by"
3824 " your SDI defense."),
3844 wipe_unit(punit, ULR_DETONATED,
nullptr);
3868 struct unit *act_unit,
3869 struct city *tgt_city,
3870 const struct action *paction)
3873 struct player *tgt_player;
3875 bool try_civil_war =
false;
3890 tgt_city_id = tgt_city->
id;
3905 try_civil_war =
true;
3912 if (tgt_player != act_player) {
3915 _(
"%s has been destroyed by %s."),
3932 if (try_civil_war) {
3951 const struct action *paction)
3957 int moves_used, def_moves_used;
3958 int old_unit_vet, old_defender_vet;
3961 enum direction8 facing;
3962 int att_hp, def_hp, att_fp, def_fp;
3963 int att_hp_start, def_hp_start;
3964 int def_power, att_power;
3965 struct unit *pdefender;
3972 att_hp_start = punit->
hp;
3973 def_hp_start = pdefender->
hp;
3978 log_debug(
"Start attack: %s %s against %s %s.",
3987 "Trying to attack a unit with which you have peace "
3988 "or cease-fire at (%d, %d).",
3992 "Trying to attack a unit with which you have "
3993 "alliance at (%d, %d).",
4008 old_unit_vet = punit->
veteran;
4009 old_defender_vet = pdefender->
veteran;
4035 pdefender->
hp = def_hp;
4064 pdefender->
veteran - old_defender_vet);
4067 if (punit->
hp > 0 && pdefender->
hp > 0) {
4072 log_debug(
"Tied battle: %s %s against %s %s.",
4079 if (def_hp_start == pdefender->
hp) {
4086 _(
"Your %s %s [id:%d %sA:%.1f, lost %d HP, %d HP remaining]"
4087 " failed to hit the %s %s %s [id:%d %sD:%.1f HP:%d%s]!"),
4088 attacker_vet, attacker_link, punit->
id, attacker_fp,
4091 defender_vet, defender_link, pdefender->
id, defender_fp,
4093 (pdefender->
veteran != old_defender_vet)
4104 _(
"Your %s %s [id:%d %sD:%.1f HP:%d]"
4105 " brushed off a pathetic attack from the %s %s %s [id:%d "
4107 " HP, %d HP remaining%s]!"),
4108 defender_vet, defender_link, pdefender->
id, defender_fp,
4111 attacker_link, punit->
id, attacker_fp,
4123 _(
"Your %s %s [id:%d %sA:%.1f, lost %d HP, %d HP remaining]"
4124 " attacked the %s %s %s [id:%d %sD:%.1f, lost %d"
4125 " HP, %d HP remaining%s]!"),
4126 attacker_vet, attacker_link, punit->
id, attacker_fp,
4129 defender_vet, defender_link, pdefender->
id, defender_fp,
4132 (pdefender->
veteran != old_defender_vet)
4143 _(
"Your %s %s [id:%d %sD:%.1f, lost %d HP, %d HP remaining]"
4144 " fought back the attacking %s %s %s [id:%d %sA:%.1f, lost %d"
4145 " HP, %d HP remaining%s]!"),
4146 defender_vet, defender_link, pdefender->
id, defender_fp,
4149 attacker_vet, attacker_link, punit->
id, attacker_fp,
4157 if (punit->
veteran != old_unit_vet) {
4162 if (pdefender->
veteran != old_defender_vet) {
4169 if (punit->
hp > 0 && pdefender->
hp <= 0) {
4174 log_debug(
"Attacker won: %s %s against %s %s.",
4181 if (att_hp_start == punit->
hp) {
4188 _(
"Your %s %s [id:%d %s%sA:%.1f, HP:%d] eliminated the "
4189 "worthless %s %s %s [id:%d %sD:%.1f, lost %d HP]."),
4190 attacker_vet, attacker_link, punit->
id, attacker_fp,
4193 defender_link, pdefender->
id, defender_fp,
4203 _(
"Your %s %s [id:%d %sD:%.1f HP:%d] helplessly perished in an"
4204 " attack by the %s %s %s [id:%d %s%sA:%.1f HP:%d%s]."),
4205 defender_vet, defender_link, pdefender->
id, defender_fp,
4208 attacker_link, punit->
id, attacker_fp, attacker_tired,
4219 _(
"Your %s %s [id:%d %s%sA:%.1f, lost %d HP, "
4220 "has %d remaining] eliminated the %s %s %s "
4221 "[id:%d %sD:%.1f, lost %d HP]."),
4222 attacker_vet, attacker_link, punit->
id, attacker_fp,
4224 att_hp_start - punit->
hp, punit->
hp,
4226 defender_vet, defender_link, pdefender->
id, defender_fp,
4236 _(
"Your %s %s [id:%d %sD:%.1f HP:%d] perished in an attack by "
4237 "the %s %s %s [id:%d %s%sA:%.1f, lost %d HP, has %d HP "
4239 defender_vet, defender_link, pdefender->
id, defender_fp,
4242 attacker_link, punit->
id, attacker_fp, attacker_tired,
4249 if (punit->
veteran != old_unit_vet) {
4253 punit->
moved =
true;
4255 punit->
veteran == old_unit_vet
4261 if (
auto pcity =
tile_city(def_tile); pcity !=
nullptr) {
4283 if (punit->
hp <= 0 && pdefender->
hp > 0) {
4289 log_debug(
"Attacker lost: %s %s against %s %s.",
4296 if (def_hp_start == pdefender->
hp) {
4304 _(
"Your %s %s [id:%d %sA:%.1f, lost %d HP] failed terribly"
4305 " against the %s %s %s [id:%d %sD:%.1f HP:%d%s]!"),
4306 attacker_vet, attacker_link, punit->
id, attacker_fp,
4309 defender_link, pdefender->
id, defender_fp,
4311 (pdefender->
veteran != old_defender_vet)
4320 _(
"Your %s %s [id:%d %sD:%.1f HP:%d]"
4321 " stopped the pathetic %sattack from the %s %s %s "
4322 "[id:%d %sA:%.1f HP:%d]."),
4323 defender_vet, defender_link, pdefender->
id, defender_fp,
4326 attacker_link, punit->
id, attacker_fp,
4336 _(
"Your %s %s [id:%d %sA:%.1f, lost %d HP] perished while"
4337 " attacking the %s %s %s [id:%d %sD:%.1f, lost %d HP, %d HP "
4339 attacker_vet, attacker_link, punit->
id, attacker_fp,
4342 defender_link, pdefender->
id, defender_fp,
4345 (pdefender->
veteran != old_defender_vet)
4353 _(
"Your %s %s [id:%d %sD:%.1f lost %d HP, %d HP remaining]"
4354 " stopped the %sattack from the %s %s %s "
4355 "[id:%d %sA:%.1f HP:%d]."),
4356 defender_vet, defender_link, pdefender->
id, defender_fp,
4358 pdefender->
hp, attacker_tired,
4360 attacker_link, punit->
id, attacker_fp,
4364 if (pdefender->
veteran == old_defender_vet ? 0 : 1) {
4386 struct unit *act_unit,
4387 struct city *tgt_city,
4388 const struct action *paction)
4390 struct player *tgt_player;
4411 _(
"Your %s failed to do %s in %s."),
unit_link(act_unit),
4432 _(
"Your %s succeeded in destroying"
4433 " the production of %s in %s."),
4437 _(
"The production of %s was destroyed in %s,"
4438 " %s are suspected."),
4456 struct unit *act_unit,
4457 struct city *tgt_city,
4459 const struct action *paction)
4461 struct player *tgt_player;
4482 _(
"Your %s failed to do %s in %s."),
unit_link(act_unit),
4499 _(
"Your %s didn't find a %s to %s in %s."),
4523 _(
"The %s destroyed the %s in %s."),
4540 struct unit *act_unit,
4541 struct city *tgt_city,
4547 int tgt_city_id = tgt_city->
id;
4549 const char *victim_link =
city_link(tgt_city);
4554 unit_move(act_unit, tgt_tile, move_cost,
nullptr,
false,
true);
4572 struct tile *dest_tile,
4574 struct unit *embark_to,
4575 bool enter_enemy_city)
4580 dest_tile, igzoc, embark_to, enter_enemy_city);
4588 _(
"Cannot attack unless you declare war first."));
4593 _(
"%s can only move into your own zone of control."),
4599 _(
"%s cannot move that far from the coast line."),
4606 _(
"Cannot invade unless you break peace with "
4615 _(
"%s cannot disembark outside of a city or a native base "
4623 _(
"Terrain is unsuitable for %s units."),
4655 bool igzoc,
bool move_do_not_act)
4664 log_debug(
"tiles not adjacent in move request");
4670 _(
"This unit has no moves left."));
4710 if (!move_do_not_act) {
4711 const bool can_not_move =
4713 bool one_action_may_be_legal =
4722 if (one_action_may_be_legal || can_not_move) {
4759 _(
"A transported unit is not allied to all "
4760 "units or city on target tile."));
4798 struct city *pcity_dest,
4799 const struct action *paction)
4843 prod =
_(
"current production");
4850 work =
_(
"remaining");
4855 work =
_(
"surplus");
4862 _(
"Your %s does %s to help build the %s in %s (%d %s)."),
4877 _(
"Help building the %s in %s received from %s %s "
4901 struct city *pcity_dest,
4902 const struct action *paction)
4908 int home_overbooked = 0;
4909 int dest_overbooked = 0;
4912 struct city *pcity_homecity;
4913 struct trade_route_list *routes_out_of_dest;
4914 struct trade_route_list *routes_out_of_home;
4915 enum traderoute_bonus_type bonus_type;
4917 const char *goods_str;
4928 if (!pcity_homecity) {
4930 _(
"Sorry, your %s cannot establish"
4931 " a trade route because it has no home city."),
4936 if (
game.
info.goods_selection == GSM_ARRIVAL) {
4941 if (
goods ==
nullptr) {
4943 _(
"Sorry, your %s cannot establish"
4944 " a trade route because it's not carrying any goods."),
4954 _(
"Sorry, your %s cannot establish"
4955 " a trade route between %s and %s."),
4956 unit_link(punit), homecity_link, destcity_link);
4961 routes_out_of_home = trade_route_list_new();
4962 routes_out_of_dest = trade_route_list_new();
4971 if (can_establish) {
4978 if (can_establish && (home_overbooked >= 0 || dest_overbooked >= 0)) {
4982 if (home_overbooked >= 0) {
4988 _(
"Sorry, your %s cannot establish"
4989 " a trade route here!"),
4994 PL_(
" The city of %s already has %d "
4995 "better trade route!",
4996 " The city of %s already has %d "
4997 "better trade routes!",
4999 homecity_link, home_max);
5001 can_establish =
false;
5006 if (can_establish && dest_overbooked >= 0) {
5012 _(
"Sorry, your %s cannot establish"
5013 " a trade route here!"),
5018 PL_(
" The city of %s already has %d "
5019 "better trade route!",
5020 " The city of %s already has %d "
5021 "better trade routes!",
5023 destcity_link, dest_max);
5025 can_establish =
false;
5034 pcity_homecity, pcity_dest,
nullptr,
goods, can_establish);
5046 switch (bonus_type) {
5051 _(
"Your %s from %s has arrived in %s carrying %s."),
5052 punit_link, homecity_link, destcity_link, goods_str);
5058 PL_(
"Your %s from %s has arrived in %s carrying %s,"
5059 " and revenues amount to %d in gold.",
5060 "Your %s from %s has arrived in %s carrying %s,"
5061 " and revenues amount to %d in gold.",
5063 punit_link, homecity_link, destcity_link, goods_str, revenue);
5065 case TBONUS_SCIENCE:
5069 PL_(
"Your %s from %s has arrived in %s carrying %s,"
5070 " and revenues amount to %d in research.",
5071 "Your %s from %s has arrived in %s carrying %s,"
5072 " and revenues amount to %d in research.",
5074 punit_link, homecity_link, destcity_link, goods_str, revenue);
5080 PL_(
"Your %s from %s has arrived in %s carrying %s,"
5081 " and revenues amount to %d in gold and research.",
5082 "Your %s from %s has arrived in %s carrying %s,"
5083 " and revenues amount to %d in gold and research.",
5085 punit_link, homecity_link, destcity_link, goods_str, revenue);
5089 if (bonus_type == TBONUS_GOLD || bonus_type == TBONUS_BOTH) {
5095 if (bonus_type == TBONUS_SCIENCE || bonus_type == TBONUS_BOTH) {
5103 if (can_establish) {
5105 struct city_list *cities_out_of_home;
5106 struct city_list *cities_out_of_dest;
5107 struct player *partner_player;
5117 _(
"New trade route established from %s to %s."),
5118 homecity_link, destcity_link);
5119 if (pplayer != partner_player) {
5122 _(
"The %s established a trade route between their "
5128 cities_out_of_home = city_list_new();
5129 cities_out_of_dest = city_list_new();
5136 city_list_append(cities_out_of_home,
5150 city_list_append(cities_out_of_dest,
5165 proute_to->
partner = pcity_homecity->
id;
5169 proute_from->
dir = RDIR_BIDIRECTIONAL;
5170 proute_to->
dir = RDIR_BIDIRECTIONAL;
5172 proute_from->
dir = RDIR_FROM;
5173 proute_to->
dir = RDIR_TO;
5175 trade_route_list_append(pcity_homecity->
routes, proute_from);
5176 trade_route_list_append(pcity_dest->
routes, proute_to);
5202 if (pplayer != partner_player) {
5235 city_list_destroy(cities_out_of_home);
5236 city_list_destroy(cities_out_of_dest);
5246 trade_route_list_destroy(routes_out_of_home);
5247 trade_route_list_destroy(routes_out_of_dest);
5261 enum unit_ss_data_type type,
int value)
5265 if (
nullptr == punit) {
5268 if (type != USSDT_UNQUEUE) {
5270 qDebug(
"handle_unit_sscs_set() invalid unit %d", unit_id);
5285 qDebug(
"unit_sscs_set() invalid target tile %d for unit %d", value,
5311 case USSDT_BATTLE_GROUP:
5341 enum server_side_agent agent)
5345 if (
nullptr == punit) {
5347 qDebug(
"handle_unit_server_side_agent_set() invalid unit %d", unit_id);
5351 if (!server_side_agent_is_valid(agent)) {
5353 qDebug(
"handle_unit_server_side_agent_set() invalid agent %d", agent);
5365 if (agent == SSA_AUTOEXPLORE) {
5387 enum server_side_agent agent)
5391 case SSA_AUTOSETTLER:
5396 case SSA_AUTOEXPLORE:
5421 enum unit_activity old_activity,
5426 switch (old_activity) {
5427 case ACTIVITY_PILLAGE: {
5428 if (old_target !=
nullptr) {
5431 if (punit2->activity == ACTIVITY_PILLAGE) {
5434 if (pdep == old_target) {
5447 case ACTIVITY_EXPLORE:
5454 case ACTIVITY_EXPLORE:
5472 const struct action *paction)
5486 enum unit_activity new_activity)
5490 && new_activity != ACTIVITY_GEN_ROAD,
5493 if (new_activity == ACTIVITY_PILLAGE) {
5513 enum unit_activity new_activity)
5518 enum unit_activity old_activity = punit->
activity;
5536 const struct action *paction,
5552 enum unit_activity new_activity,
5573 enum unit_activity new_activity,
5579 enum unit_activity old_activity = punit->
activity;
5581 enum unit_activity stored_activity = new_activity;
5584 if (new_activity != stored_activity
5594 if (new_activity == ACTIVITY_PILLAGE) {
5613 const struct packet_unit_orders *packet)
5615 int length = packet->length;
5619 #ifdef FREECIV_DEBUG
5623 if (
nullptr == punit) {
5625 qDebug(
"handle_unit_orders() invalid unit %d", packet->unit_id);
5631 qCritical(
"handle_unit_orders() invalid %s (%d) "
5632 "packet length %d (max %d)",
5643 qDebug(
"handle_unit_orders() invalid %s (%d) tile (%d, %d) "
5650 if (ACTIVITY_IDLE != punit->
activity) {
5658 qCritical(
"received invalid orders from %s for %s (%d).",
5690 if (!packet->repeat) {
5697 #ifdef FREECIV_DEBUG
5698 log_debug(
"Orders for unit %d: length:%d", packet->unit_id, length);
5699 for (i = 0; i < length; i++) {
5700 log_debug(
" %d,%s,%s,%d,%d", packet->orders[i].order,
5705 ? unit_activity_name(packet->orders[i].activity)
5706 :
"no action/activity required",
5707 packet->orders[i].target, packet->orders[i].sub_target);
5722 const struct packet_worker_task *packet)
5728 if (pcity ==
nullptr || pcity->
owner != pplayer || ptile ==
nullptr) {
5734 if (
tile_index(ptask_old->ptile) == packet->tile_id) {
5740 if (ptask ==
nullptr) {
5741 if (packet->activity == ACTIVITY_LAST) {
5747 worker_task_list_append(pcity->
task_reqs, ptask);
5749 if (packet->activity == ACTIVITY_LAST) {
5750 worker_task_list_remove(pcity->
task_reqs, ptask);
5756 if (ptask !=
nullptr) {
5757 ptask->
ptile = ptile;
5758 ptask->
act = packet->activity;
5759 if (packet->tgt >= 0) {
5763 log_debug(
"Illegal worker task target %d", packet->tgt);
5764 ptask->
tgt =
nullptr;
5767 ptask->
tgt =
nullptr;
5769 ptask->
want = packet->want;
5772 lsend_packet_worker_task(pplayer->
connections, packet);
bool is_action_enabled_unit_on_unit(const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerne...
bool action_distance_inside_max(const struct action *action, const int distance)
Returns TRUE iff the specified distance between actor and target is sm,aller or equal to the max rang...
bool action_mp_full_makes_legal(const struct unit *actor, const action_id act_id)
Returns TRUE if the specified action can't be done now but would have been legal if the unit had full...
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Get the actor unit's probability of successfully performing the chosen action on itself.
bool action_prob_possible(const struct act_prob probability)
Returns TRUE iff the given action probability belongs to an action that may be possible.
struct extra_type * action_tgt_tile_extra(const struct unit *actor, const struct tile *target_tile, bool accept_all_actions)
Find an extra to target for an action at the specified tile.
struct unit * action_tgt_unit(struct unit *actor, struct tile *target_tile, bool accept_all_actions)
Find a unit to target for an action at the specified tile.
struct city * action_tgt_city(struct unit *actor, struct tile *target_tile, bool accept_all_actions)
Find a city to target for an action on the specified tile.
bool is_action_enabled_unit_on_city(const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerne...
struct act_prob action_prob_unit_vs_tgt(const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
Returns the actor unit's probability of successfully performing the specified action against the acti...
struct act_prob action_prob_vs_city(const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
Get the actor unit's probability of successfully performing the chosen action on the target city.
struct act_prob action_prob_vs_unit(const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
Get the actor unit's probability of successfully performing the chosen action on the target unit.
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Get the actor unit's probability of successfully performing the chosen action on the target tile.
struct tile * action_tgt_tile(struct unit *actor, struct tile *target, const struct extra_type *target_extra, bool accept_all_actions)
Returns the tile iff it, from the point of view of the owner of the actor unit, looks like a target t...
struct act_prob action_prob_vs_units(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Get the actor unit's probability of successfully performing the chosen action on all units at the tar...
const QString action_name_translation(const struct action *action)
Get the action name used when displaying the action in the UI.
bool action_maybe_possible_actor_unit(const action_id act_id, const struct unit *actor_unit)
Returns TRUE if the wanted action (as far as the player knows) can be performed right now by the spec...
struct action * action_is_blocked_by(const action_id act_id, const struct unit *actor_unit, const struct tile *target_tile_arg, const struct city *target_city_arg, const struct unit *target_unit)
Returns the action that blocks the specified action or nullptr if the specified action isn't blocked.
bool is_action_enabled_unit_on_tile(const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are conc...
const QString action_id_name_translation(action_id act_id)
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.
enum unit_activity action_get_activity(const struct action *paction)
Returns the unit activity this action may cause or ACTIVITY_LAST if the action doesn't result in a un...
bool action_actor_utype_hard_reqs_ok(enum action_result result, const struct unit_type *actor_unittype)
Returns TRUE if the specified unit type can perform an action with the wanted result given that an ac...
bool action_id_exists(const action_id act_id)
Returns TRUE iff the specified action ID refers to a valid action.
enum action_target_kind action_get_target_kind(const struct action *paction)
Get the target kind of an action.
bool action_has_result(const struct action *paction, enum action_result result)
Returns TRUE iff performing the specified action has the specified result.
const char * action_id_rule_name(action_id act_id)
Get the rule name of the action.
struct action_enabler_list * action_enablers_for_action(action_id action)
Get all enablers for an action in the current ruleset.
#define action_enabler_list_iterate_end
#define action_id_get_role(act_id)
#define action_iterate_end
#define action_id_get_actor_kind(act_id)
#define ACTPROB_NOT_KNOWN
#define action_has_result_safe(paction, result)
#define action_enabler_list_iterate(action_enabler_list, aenabler)
#define action_id_distance_accepted(act_id, distance)
#define ACTPROB_IMPOSSIBLE
#define action_iterate(_act_)
#define action_id_get_target_kind(act_id)
#define action_id_has_complex_target(act_id)
#define CALL_PLR_AI_FUNC(_func, _player,...)
QString strvec_to_and_list(const QVector< QString > &psv)
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
Change unit's advisor task.
bool BV_ISSET(const BV &bv, int bit)
void citizens_update(struct city *pcity, struct player *plr)
bool citymindist_prevents_city_on_tile(const struct tile *ptile)
Returns TRUE iff it is illegal to found a city on the specified tile because of citymindist.
bool city_production_gets_caravan_shields(const struct universal *tgt)
Returns TRUE iff the specified production should get shields from units that has done ACTION_HELP_WON...
struct city * is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non_allied city on this tile?
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.
bool is_capital(const struct city *pcity)
Return TRUE iff this city is its nation's capital.
struct city * is_non_attack_city_tile(const struct tile *ptile, const struct player *pplayer)
Is there an enemy city on this tile?
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
void city_size_add(struct city *pcity, int add)
Add a (positive or negative) value to the city size.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool city_can_grow_to(const struct city *pcity, int pop_size)
Return TRUE iff the city can grow to the given size.
bool city_exist(int id)
Check if city with given id still exist.
citizens city_size_get(const struct city *pcity)
Get the city size.
const char * city_production_name_translation(const struct city *pcity)
Return the extended name of the current production.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void nullify_prechange_production(struct city *pcity)
Initialize all variables containing information about production before it was changed.
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Change the city size.
int city_incite_cost(struct player *pplayer, struct city *pcity)
Returns the cost to incite a city.
bool city_reduce_size(struct city *pcity, citizens pop_loss, struct player *destroyer, const char *reason)
Reduce the city size.
bool city_refresh(struct city *pcity)
Updates unit upkeeps and city internal cached data.
struct unit * get_defender(const struct unit *attacker, const struct tile *ptile)
Finds the best defender on the tile, given an attacker.
bool is_unit_reachable_at(const struct unit *defender, const struct unit *attacker, const struct tile *location)
Can unit attack other at given location.
enum unit_attack_result unit_attack_units_at_tile_result(const struct unit *punit, const struct tile *ptile)
Check if unit can attack unit stack at tile.
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
return the modified defense power of a unit.
struct city * sdi_try_defend(const struct player *owner, const struct tile *ptile)
Try defending against nuclear attack; if successful, return a city which had enough luck and EFT_NUKE...
int get_total_attack_power(const struct unit *attacker, const struct unit *defender)
Return the modified attack power of a unit.
void get_modified_firepower(const struct unit *attacker, const struct unit *defender, int *att_fp, int *def_fp)
A unit's effective firepower depend on the situation.
void conn_list_do_unbuffer(struct conn_list *dest)
Convenience functions to unbuffer a list of connections.
void conn_list_do_buffer(struct conn_list *dest)
Convenience functions to buffer a list of connections.
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
bool spy_steal_some_maps(struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
Steal part of another player's map.
bool spy_sabotage_unit(struct player *pplayer, struct unit *pdiplomat, struct unit *pvictim, const struct action *paction)
Sabotage an enemy unit.
bool diplomat_embassy(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
Establish an embassy.
bool diplomat_get_tech(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, Tech_type_id technology, const struct action *paction)
Try to steal a technology from an enemy city.
bool diplomat_sabotage(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, Impr_type_id improvement, const struct action *paction)
Sabotage enemy city's improvement or production.
bool diplomat_incite(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
Incite a city to disaffect.
bool spy_steal_gold(struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
Steal gold from another player.
bool spy_spread_plague(struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
Spread a plague to the target city.
bool spy_nuke_city(struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
Hide a suitcase nuke in a city and detonate it.
bool diplomat_investigate(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
Investigate a city.
void spy_send_sabotage_list(struct connection *pc, struct unit *pdiplomat, struct city *pcity, const struct action *paction, bool disturb_player)
Get list of improvements from city (for purposes of sabotage).
bool diplomat_bribe(struct player *pplayer, struct unit *pdiplomat, struct unit *pvictim, const struct action *paction)
Bribe an enemy unit.
bool spy_attack(struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction)
Diplomatic battle.
bool spy_poison(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
Poison a city's water supply.
int get_target_bonus_effects(struct effect_list *plist, 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, enum effect_type effect_type, enum vision_layer vision_layer, enum national_intelligence nintel)
Returns the effect bonus of a given type for any target.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
@ ANEK_CITY_TOO_CLOSE_TGT
@ ANEK_IS_NOT_CITY_CENTER
@ ANEK_ACTOR_HAS_HOME_CITY
@ ANEK_ACT_NOT_ENOUGH_MONEY
@ ANEK_IS_NOT_TRANSPORTING
@ ANEK_ACTOR_HAS_NO_HOME_CITY
@ ANEK_IS_NOT_TRANSPORTED
@ ANEK_TGT_IS_UNIQUE_ACT_HAS
#define IDENTITY_NUMBER_ZERO
#define PL_(String1, String2, n)
const char * unit_firepower_if_not_one(int firepower)
Get string of unit's firepower text, i.e.
const char * city_tile_link(const struct city *pcity)
Get a text link to a city tile (make a clickable link to a tile with the city name as text).
const char * tile_link(const struct tile *ptile)
Get a text link to a tile.
const char * unit_tired_attack_string(const struct unit *punit)
Get string of unit's attack would be a tired attack or not.
const char * unit_tile_link(const struct unit *punit)
Get a text link to a unit tile (make a clickable link to a tile with the unit type name as text).
const char * unit_veteran_level_string(const struct unit *punit)
Get a text of a unit's vet level.
const struct ft_color ftc_server
const char * unit_achieved_rank_string(const struct unit *punit)
Get string of when unit gets upgraded to new veteran level.
const char * city_link(const struct city *pcity)
Get a text link to a city.
const char * unit_link(const struct unit *punit)
Get a text link to an unit.
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
bool is_player_phase(const struct player *pplayer, int phase)
Return TRUE if it is this player's phase.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
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_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define fc_assert_ret_val_msg(condition, val, message,...)
enum direction8 opposite_direction(enum direction8 dir)
Return direction that is opposite to given one.
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Are two tiles adjacent to each other.
const char * dir_get_name(enum direction8 dir)
Return the debugging name of the direction.
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
bool base_get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile, enum direction8 *dir)
Return TRUE and sets dir to the direction of the step if (end_x, end_y) can be reached from (start_x,...
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
void vision_clear_sight(struct vision *vision)
Clear all sight points from this vision source.
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Shows the area to the player.
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
Players' information of tiles is tracked so that fogged area can be kept consistent even when the cli...
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.
int unit_move_rate(const struct unit *punit)
This function calculates the move rate of the unit.
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Return whether we could find a suitable transporter for given unit at 'ptile'.
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool igzoc, bool enter_enemy_city)
Returns whether the unit can move from its current tile to the destination tile.
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...
enum unit_move_result unit_move_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool igzoc, struct unit *embark_to, bool enter_enemy_city)
Returns whether the unit can move from its current tile to the destination tile.
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.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Similar to notify_conn_packet (see also), but takes player as "destination".
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
If the specified player owns the unit with the specified id, return pointer to the unit struct.
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Checks if a unit can be seen by pplayer at its current location.
struct city * player_primary_capital(const struct player *pplayer)
Locate the player's primary capital city, (nullptr Otherwise)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players have peace, cease-fire, or armistice.
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see units in the city.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
#define players_iterate_end
#define players_iterate(_pplayer)
struct conn_list * player_reply_dest(struct player *pplayer)
Convenience function to return "reply" destination connection list for player: pplayer->current_conn ...
struct player * civil_war(struct player *pplayer)
Capturing a nation's primary capital is a devastating blow.
bool civil_war_triggered(struct player *pplayer)
civil_war_triggered: The capture of a primary capital is not a sure fire way to throw and empire into...
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
Check if we make contact with anyone.
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Check if civil war is possible for a player.
int normal_player_count()
Return the number of non-barbarian players.
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Make user-friendly text for the source.
#define requirement_fulfilled_by_unit_type(_ut_, _rqs_)
#define requirement_fulfilled_by_terrain(_ter_, _rqs_)
#define requirement_fulfilled_by_nation(_nat_, _rqs_)
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
#define sanity_check_city(x)
void script_server_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
#define CLIP(lower, current, upper)
void spaceship_lost(struct player *pplayer)
Handle spaceship loss.
#define DEFAULT_SPECIALIST
struct action::@10::@11 is_unit
bool actor_consuming_always
enum action_result result
enum act_tgt_compl target_complexity
struct player * no_war_with
const struct unit_type * no_tgt_utype
struct terrain * no_act_terrain
struct city * capacity_city
struct player * peace_with
struct nation_type * no_act_nation
struct worker_task_list * task_reqs
struct trade_route_list * routes
struct universal production
citizens specialists[SP_MAX]
struct unit_list * units_supported
struct civ_game::@28::@32 server
struct packet_ruleset_control control
struct conn_list * est_connections
struct packet_game_info info
struct packet_scenario_info scenario
enum spaceship_state state
std::unique_ptr< vision_site > site
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct nation_type * nation
enum traderoute_bonus_type bonus_type
struct goods_type * goods
enum action_decision action_decision_want
enum unit_activity activity
struct unit::@76::@79 server
struct extra_type * activity_target
struct goods_type * carrying
struct tile * action_decision_tile
const struct unit_type * utype
enum server_side_agent ssa_controller
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
#define sz_strlcpy(dest, src)
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
#define terrain_has_flag(terr, flag)
bool tile_is_seen(const struct tile *target_tile, const struct player *pow_player)
Returns TRUE iff the target_tile is seen by pow_player.
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_owner(_tile)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
Return TRUE iff the two cities are capable of trade; i.e., if a caravan from one city can enter the o...
enum trade_route_type cities_trade_route_type(const struct city *pcity1, const struct city *pcity2)
What is type of the traderoute between two cities.
int max_trade_routes(const struct city *pcity)
Return current maximum number of trade routes city can have.
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
Return the trade that exists between these cities, assuming they have a trade route.
int city_num_trade_routes(const struct city *pcity)
Return number of trade route city has.
const char * goods_name_translation(struct goods_type *pgood)
Return translated name of this goods type.
bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag)
Check if goods has given flag.
struct goods_type * goods_from_city_to_unit(struct city *src, struct unit *punit)
Return goods type for the new traderoute between given cities.
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Get trade route settings related to type.
int city_trade_removable(const struct city *pcity, struct trade_route_list *would_remove)
Return the minimum value of the sum of trade routes which could be replaced by a new one.
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const player *seen_as, struct goods_type *pgood, const bool establish_trade)
Returns the revenue trade bonus - you get this when establishing a trade route and also when you simp...
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
Check if cities have an established trade route.
#define trade_route_list_iterate(trade_route_list, proute)
#define trade_route_list_iterate_end
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
Returns how many shields the unit (type) is worth.
int get_transporter_occupancy(const struct unit *ptrans)
Return how many units are in the transport.
void free_unit_orders(struct unit *punit)
Free and reset the unit's goto route (punit->pgr).
enum unit_upgrade_result unit_upgrade_test(const struct unit *punit, bool is_free)
Tests if the unit could be updated.
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
Assign a new untargeted task to a unit.
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Returns whether 'pcargo' is transported by 'ptrans', either directly or indirectly.
bool can_unit_continue_current_activity(struct unit *punit)
Check if the unit's current activity is actually legal.
int unit_bribe_cost(struct unit *punit, struct player *briber)
Calculate how expensive it is to bribe the unit.
bool can_unit_do_autosettlers(const struct unit *punit)
Return whether the unit can be put in auto-settler mode.
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
assign a new targeted task to a unit.
bool can_unit_do_activity_targeted(const struct unit *punit, enum unit_activity activity, struct extra_type *target)
Return whether the unit can do the targeted activity at its current location.
int get_transporter_capacity(const struct unit *punit)
Return the number of units the transporter can hold (or 0).
bool can_unit_do_activity(const struct unit *punit, enum unit_activity activity)
Return TRUE iff the unit can do the given untargeted activity at its current location.
enum unit_airlift_result test_unit_can_airlift_to(const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now.
bool kills_citizen_after_attack(const struct unit *punit)
Return TRUE iff an attack from this unit would kill a citizen in a city (city walls protect against t...
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
bool unit_has_orders(const struct unit *punit)
Return TRUE iff the unit is following client-side orders.
struct player * unit_nationality(const struct unit *punit)
Return the nationality of the unit.
bool activity_requires_target(enum unit_activity activity)
Return TRUE if activity requires some sort of target to be specified.
#define MAX_NUM_BATTLEGROUPS
static bool do_unit_strike_city_production(const struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
Have the unit perform a surgical strike against the current production in the target city.
static struct player * need_war_player_hlp(const struct unit *actor, const action_id act, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Returns the first player that may enable the specified action if war is declared.
static bool rel_may_become_war(const struct player *pplayer, const struct player *oplayer)
Returns TRUE iff the player is able to change his diplomatic relationship to the other player to war.
bool unit_move_handling(struct unit *punit, struct tile *pdesttile, bool igzoc, bool move_do_not_act)
Will try to move to/attack the tile dest_x,dest_y.
static void send_combat(struct unit *pattacker, struct unit *pdefender, int att_veteran, int def_veteran)
Send combat info to players.
static bool do_unit_change_homecity(struct unit *punit, struct city *pcity, const struct action *paction)
Change a unit's home city.
static bool do_unit_upgrade(struct player *pplayer, struct unit *punit, struct city *pcity, enum action_requester ordered_by, const struct action *paction)
Upgrade the unit to a newer unit type.
void handle_unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
Handle a request to do an action.
static void see_combat_unit(struct unit *punit)
Make sure everyone who can see combat does.
void handle_unit_orders(struct player *pplayer, const struct packet_unit_orders *packet)
Receives route packages.
void illegal_action_msg(struct player *pplayer, const enum event_type event, struct unit *actor, const action_id stopped_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Try to explain to the player why an action is illegal.
static bool do_heal_unit(struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
Restore some of the target unit's hit points.
static bool do_unit_alight(struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
Unload actor unit from target unit.
static bool do_capture_units(struct player *pplayer, struct unit *punit, struct tile *pdesttile, const struct action *paction)
Capture all the units at pdesttile using punit.
static bool do_expel_unit(struct player *pplayer, struct unit *actor, struct unit *target, const struct action *paction)
Expel the target unit to his owner's capital.
static bool do_unit_conquer_city(struct player *act_player, struct unit *act_unit, struct city *tgt_city, struct action *paction)
Have the unit conquer a city.
static bool do_unit_strike_city_building(const struct player *act_player, struct unit *act_unit, struct city *tgt_city, Impr_type_id tgt_bld_id, const struct action *paction)
Have the unit perform a surgical strike against a building in the target city.
static bool does_nation_block_action(const action_id act_id, bool is_target, struct unit *actor_unit, struct nation_type *pnation)
Returns TRUE iff the specified nation blocks the specified action.
#define ACTION_STARTED_UNIT_UNIT(action, actor, target, action_performer)
void handle_unit_change_activity(struct player *pplayer, int unit_id, enum unit_activity activity, int target_id)
Handle change in unit activity.
void handle_worker_task(struct player *pplayer, const struct packet_worker_task *packet)
Handle worker task assigned to the city.
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
Handle request for changing activity.
#define ACTION_STARTED_UNIT_TILE(action, actor, target, action_performer)
static bool do_unit_embark(struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
Have the actor unit embark the target unit.
bool unit_perform_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id_incoming, const char *name, const action_id action_type, const enum action_requester requester)
Execute a request to perform an action and let the caller know if it was performed or not.
static bool illegal_action_pay_price(struct player *pplayer, bool information_revealed, struct unit *act_unit, struct action *stopped_action, struct player *tgt_player, struct tile *tgt_tile, const enum action_requester requester)
Punish a player for trying to perform an action that turned out to be illegal.
static void explain_why_no_action_enabled(struct unit *punit, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Explain why punit can't perform any action at all based on its current game state.
static void illegal_action(struct player *pplayer, struct unit *actor, action_id stopped_action, struct player *tgt_player, struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, bool disturb_player, const enum action_requester requester)
Tell the client that the action it requested is illegal.
static bool does_terrain_block_action(const action_id act_id, bool is_target, struct unit *actor_unit, struct terrain *pterrain)
Returns TRUE iff the specified terrain type blocks the specified action.
static void unit_activity_dependencies(struct unit *punit, enum unit_activity old_activity, struct extra_type *old_target)
Update everything that needs changing when unit activity changes from old activity to new one.
void handle_unit_action_query(struct connection *pc, const int actor_id, const int target_id, const action_id action_type, bool disturb_player)
Tell the client the cost of bribing a unit, inciting a revolt, or any other parameters needed for act...
static bool unit_bombard(struct unit *punit, struct tile *ptile, const struct action *paction)
This function assumes the bombard is legal.
static bool unit_do_destroy_city(struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
Destroy the target city.
static void handle_unit_change_activity_real(struct player *pplayer, int unit_id, enum unit_activity activity, struct extra_type *activity_target)
Handle change in unit activity.
void handle_unit_server_side_agent_set(struct player *pplayer, int unit_id, enum server_side_agent agent)
Handle request to change controlling server side agent.
void unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
Handle unit action.
static bool do_action_activity(struct unit *punit, const struct action *paction)
Perform an action that is an activity.
static struct ane_expl * expl_act_not_enabl(struct unit *punit, const action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Returns an explaination why punit can't perform the specified action based on the current game state.
#define ACTION_STARTED_UNIT_CITY(action, actor, target, action_performer)
void handle_unit_rename(player *pplayer, int unit_id, const char *name)
Handle request to rename a unit.
static bool do_unit_unload(struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
Unload target unit from actor unit.
void unit_change_homecity_handling(struct unit *punit, struct city *new_pcity, bool rehome)
Transfer a unit from one city (and possibly player) to another.
static bool unit_activity_targeted_internal(struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target)
Handle request for targeted activity.
static bool do_action_activity_targeted(struct unit *punit, const struct action *paction, struct extra_type **new_target)
Perform an action that is an activity.
static bool unit_do_help_build(struct player *pplayer, struct unit *punit, struct city *pcity_dest, const struct action *paction)
Help build the current production in a city.
void handle_unit_type_upgrade(struct player *pplayer, Unit_type_id uti)
Upgrade all units of a given type.
static bool city_add_unit(struct player *pplayer, struct unit *punit, struct city *pcity, const struct action *paction)
This function assumes that the target city is valid.
static bool unit_activity_internal(struct unit *punit, enum unit_activity new_activity)
Handle request for changing activity.
bool unit_activity_handling_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target)
Handle request for targeted activity.
static bool unit_nuke(struct player *pplayer, struct unit *punit, struct tile *def_tile, const struct action *paction)
Do a "regular" nuclear attack.
static bool can_unit_move_to_tile_with_notify(struct unit *punit, struct tile *dest_tile, bool igzoc, struct unit *embark_to, bool enter_enemy_city)
See also aiunit could_unit_move_to_tile()
void handle_unit_sscs_set(struct player *pplayer, int unit_id, enum unit_ss_data_type type, int value)
Change various unit server side client state.
static void send_bombardment(const unit *pattacker, const tile *ptarget)
Send bombardment info to players.
static bool do_unit_board(struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
Have the actor unit board the target unit.
static bool do_attack(struct unit *actor_unit, struct tile *target_tile, const struct action *paction)
Do a "regular" attack.
#define ACTION_STARTED_UNIT_UNITS(action, actor, target, action_performer)
#define ACTION_STARTED_UNIT_SELF(action, actor, action_performer)
static void unit_query_impossible(struct connection *pc, const int actor_id, const int target_id, bool disturb_player)
Inform the client that something went wrong during a unit diplomat query.
static struct player * need_war_player(const struct unit *actor, const action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Returns the first player that may enable the specified action if war is declared.
bool unit_server_side_agent_set(struct player *pplayer, struct unit *punit, enum server_side_agent agent)
Change controlling server side agent.
static bool do_unit_establish_trade(struct player *pplayer, struct unit *punit, struct city *pcity_dest, const struct action *paction)
Handle request to establish traderoute.
static void occupy_move(unit *punit, tile *def_tile)
Occupying move after an action.
static bool do_disembark(struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction)
Disembark actor unit from target unit to target tile.
static void unit_plans_clear(struct unit *punit)
Delete a unit's current plans.
static bool city_build(struct player *pplayer, struct unit *punit, struct tile *ptile, const char *name, const struct action *paction)
This function assumes a certain level of consistency checking: There is no city under punit->(x,...
void handle_unit_get_actions(struct connection *pc, const int actor_unit_id, const int target_unit_id_client, const int target_tile_id, const int target_extra_id_client, const bool disturb_player)
Handle a query for what actions a unit may do.
static void unit_attack_civilian_casualties(const struct unit *punit, struct city *pcity, const struct action *paction, const char *reason)
Reduce the city's population after an attack action.
enum ane_kind action_not_enabled_reason(struct unit *punit, action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Give the reason kind why an action isn't enabled.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
bool utype_may_act_tgt_city_tile(const struct unit_type *punit_type, const action_id act_id, const enum citytile_type prop, const bool is_there)
Return TRUE iff the given (action enabler controlled) action may be performed by a unit of the given ...
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
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.
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
Returns TRUE iff successfully performing the specified action always will move the actor unit of the ...
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Return whether this player can upgrade this unit type (to any other unit type).
Unit_type_id utype_count()
Return the number of unit types.
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Returns TRUE iff the unit type is unique and the player already has one.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
bool utype_can_do_act_when_ustate(const struct unit_type *punit_type, const action_id act_id, const enum ustate_prop prop, const bool is_there)
Return TRUE iff the unit type can do the specified (action enabler controlled) action while its unit ...
bool role_units_translations(QString &astr, int flag, bool alts)
Return a string with all the names of units with this flag.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
bool utype_is_consumed_by_action(const struct action *paction, const struct unit_type *utype)
Returns TRUE iff performing the specified action will consume an actor unit of the specified type.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.
int unit_pop_value(const struct unit *punit)
How much population is put to building this unit.
bool can_utype_do_act_if_tgt_diplrel(const struct unit_type *punit_type, const action_id act_id, const int prop, const bool is_there)
Return TRUE iff the given (action enabler controlled) action can be performed by a unit of the given ...
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Return the cost (gold) of upgrading a single unit of the specified type to the new type.
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end
struct vision * vision_new(struct player *pplayer, struct tile *ptile)
Create a new vision source.
void vision_free(struct vision *vision)
Free the vision source.
void worker_task_init(struct worker_task *ptask)
Initialize empty worker_task.
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end