100#define SPECLIST_TAG unit_move_data
102#define unit_move_data_list_iterate(_plist, _pdata) \
103 TYPED_LIST_ITERATE(struct unit_move_data, _plist, _pdata)
104#define unit_move_data_list_iterate_end LIST_ITERATE_END
105#define unit_move_data_list_iterate_rev(_plist, _pdata) \
106 TYPED_LIST_ITERATE_REV(struct unit_move_data, _plist, _pdata)
107#define unit_move_data_list_iterate_rev_end LIST_ITERATE_REV_END
118#define SPECLIST_TAG autoattack_prob
119#define SPECLIST_TYPE struct autoattack_prob
122#define autoattack_prob_list_iterate_safe(autoattack_prob_list, _aap_, \
124 TYPED_LIST_ITERATE(struct autoattack_prob, autoattack_prob_list, _aap_) \
125 struct unit *_unit_ = game_unit_by_number(_aap_->unit_id); \
127 if (_unit_ == NULL) { \
131#define autoattack_prob_list_iterate_safe_end LIST_ITERATE_END
137 bool helpless,
bool teleporting,
138 const struct city *pexclcity);
152 enum unit_loss_reason reason,
158 const struct tile *ptile);
175 enum unit_role_id role_tech)
180 if (role_tech != -1) {
183 const int minplayers = 2;
194 if (players > minplayers) {
195 which[num++] = iunit;
254 }
else if (!settler) {
287 int *att_hp,
int *def_hp,
int *att_vet,
int *def_vet)
291 int attack_firepower, defense_firepower;
300 *att_hp = attacker->
hp;
301 *def_hp = defender->
hp;
303 &attack_firepower, &defense_firepower);
305 log_verbose(
"attack:%d, defense:%d, attack firepower:%d, "
306 "defense firepower:%d", attackpower, defensepower,
307 attack_firepower, defense_firepower);
312 att_strength = attackpower * attacker->
hp * attack_firepower;
313 def_strength = defensepower * defender->
hp * defense_firepower;
318 *att_vet = 100 * def_strength * 2 / (att_strength + def_strength);
319 *def_vet = 100 * att_strength * 2 / (att_strength + def_strength);
321 if (attackpower == 0) {
323 }
else if (defensepower == 0) {
328 *att_hp > 0 && *def_hp > 0
329 && (max_rounds <= 0 || max_rounds > rounds);
331 if (
fc_rand(attackpower + defensepower) >= defensepower) {
332 *def_hp -= attack_firepower;
334 *att_hp -= defense_firepower;
344 return attackpower <= 0 || defensepower <= 0;
353 int *att_hp,
int *def_hp)
359 int attack_firepower, defense_firepower;
364 *att_hp = attacker->
hp;
365 *def_hp = defender->
hp;
367 &attack_firepower, &defense_firepower);
369 log_verbose(
"attack:%d, defense:%d, attack firepower:%d, "
370 "defense firepower:%d", attackpower, defensepower,
371 attack_firepower, defense_firepower);
376 for (i = 0; i < rate; i++) {
377 if (
fc_rand(attackpower + defensepower) >= defensepower) {
378 *def_hp -= attack_firepower;
393 bool powerless,
int att_vet,
int def_vet)
396 if (attacker->
hp <= 0 || defender->
hp <= 0
402 if (attacker->
hp > 0) {
405 if (defender->
hp > 0) {
419 struct unit_list *candidates;
424 candidates = unit_list_new();
430 unit_list_prepend(candidates,
punit);
434 while (upgrades > 0 && unit_list_size(candidates) > 0) {
437 int candidate_to_upgrade =
fc_rand(unit_list_size(candidates));
438 struct unit *
punit = unit_list_get(candidates, candidate_to_upgrade);
444 _(
"%s was upgraded for free to %s."),
447 unit_list_remove(candidates,
punit);
451 unit_list_destroy(candidates);
490 "because it was not supported by a city."),
494 _(
"Your %s has run out of hit points."),
511 struct unit *carrier;
544 log_error(
"rescue plane: unit %d died enroute!",
id);
549 log_debug(
"rescue plane: unit %d could not move to "
569 _(
"Your %s has returned to refuel."),
754 _(
"Your %s became more experienced and achieved the rank "
774 _(
"%s converted to %s."),
780 _(
"%s cannot be converted."),
793 _(
"Orders for %s aborted because activity "
794 "is no longer available."),
851 bool unit_activity_done =
FALSE;
858 case ACTIVITY_EXPLORE:
859 case ACTIVITY_FORTIFIED:
860 case ACTIVITY_SENTRY:
862 case ACTIVITY_PATROL_UNUSED:
863 case ACTIVITY_UNKNOWN:
868 case ACTIVITY_FORTIFYING:
869 case ACTIVITY_CONVERT:
873 case ACTIVITY_POLLUTION:
875 case ACTIVITY_IRRIGATE:
876 case ACTIVITY_PILLAGE:
877 case ACTIVITY_CULTIVATE:
879 case ACTIVITY_TRANSFORM:
880 case ACTIVITY_FALLOUT:
882 case ACTIVITY_GEN_ROAD:
890 case ACTIVITY_OLD_ROAD:
891 case ACTIVITY_OLD_RAILROAD:
892 case ACTIVITY_FORTRESS:
893 case ACTIVITY_AIRBASE:
902 case ACTIVITY_FORTIFIED:
903 case ACTIVITY_SENTRY:
905 case ACTIVITY_UNKNOWN:
906 case ACTIVITY_FORTIFYING:
907 case ACTIVITY_CONVERT:
908 case ACTIVITY_PATROL_UNUSED:
913 case ACTIVITY_EXPLORE:
917 case ACTIVITY_PILLAGE:
921 unit_activity_done =
TRUE;
930 case ACTIVITY_POLLUTION:
939 unit_activity_done =
TRUE;
943 case ACTIVITY_FALLOUT:
952 unit_activity_done =
TRUE;
961 unit_activity_done =
TRUE;
966 case ACTIVITY_GEN_ROAD:
971 unit_activity_done =
TRUE;
976 case ACTIVITY_IRRIGATE:
978 case ACTIVITY_CULTIVATE:
980 case ACTIVITY_TRANSFORM:
988 unit_activity_done =
TRUE;
992 case ACTIVITY_OLD_ROAD:
993 case ACTIVITY_OLD_RAILROAD:
994 case ACTIVITY_FORTRESS:
995 case ACTIVITY_AIRBASE:
1000 if (unit_activity_done) {
1002 if (ACTIVITY_CULTIVATE == activity
1003 || ACTIVITY_PLANT == activity
1004 || ACTIVITY_TRANSFORM == activity) {
1006 if (punit2->activity == activity) {
1016 if (punit2->activity == activity
1017 && punit2->activity_target == act_tgt) {
1030 if (activity == ACTIVITY_FORTIFYING) {
1035 unit_activity_done =
TRUE;
1039 if (activity == ACTIVITY_CONVERT) {
1045 unit_activity_done =
TRUE;
1049 if (unit_activity_done) {
1050 if (activity == ACTIVITY_PILLAGE) {
1081 case ACTIVITY_PILLAGE:
1099 enum unit_activity *activity,
1104 if (*activity == ACTIVITY_PILLAGE
1105 && *target == NULL) {
1121 *activity = ACTIVITY_IDLE;
1133 struct tile **dst_tile)
1150 if (0 < unit_list_size(ptile->units)) {
1165 if (value > bestvalue) {
1171 return bestvalue > 0;
1178 int count,
int sq_radius)
1180 struct tile *ptile = NULL;
1186 sq_radius, &ptile)) {
1204 int move_cost,
bool verbose)
1209 log_verbose(
"Teleported %s %s from (%d,%d) to %s",
1215 _(
"Teleported your %s to %s."),
1223 if (move_cost == -1) {
1244 struct tile *punit_tile;
1250 struct tile *tiles[(2 * DIST + 1) * (2 * DIST + 1)];
1264 if (ptile == punit_tile) {
1271 tiles[count++] = ptile;
1281 _(
"Moved your %s."),
1297 struct unit_list *pcargo_units;
1308 _(
"Disbanded your %s."),
1325 struct unit *ptrans;
1326 struct unit_list *pcargo_units;
1354 if (NULL == ptrans || pplayer !=
unit_owner(ptrans)) {
1367 "Failed to throw %s %d from %s %d (%d, %d)",
1386 struct player *aplayer,
bool verbose)
1430 const struct player *aplayer)
1432 struct unit_list *seen_units = unit_list_new();
1438 unit_list_append(seen_units,
punit);
1446 unit_list_append(seen_units,
punit);
1452 unit_list_unique(seen_units);
1465 const struct unit_list *seen_units)
1502 const struct player *pplayer,
1544 const struct player *pplayer,
1644 int homecity_id,
int moves_left,
int hp_left,
1645 struct unit *ptrans)
1724 struct city *pcity,
struct unit *ptrans,
bool force)
1805 enum unit_loss_reason reason)
1811 struct unit *ptrans;
1817#if defined(FREECIV_DEBUG) && !defined(FREECIV_NDEBUG)
1873 && ULR_EDITOR != reason) {
1875 _(
"Unable to defend %s, %s has lost the game."),
1879 _(
"Losing %s meant losing the game! "
1880 "Be more careful next time!"),
1888 unit_loss_reason_name((reason == ULR_UPKEEP)
1896 if (NULL != ptrans) {
1910 if (pcity && pcity != phomecity) {
1915 if (pcity && unit_list_size(ptile->
units) == 0) {
1926 enum unit_loss_reason reason)
1935 struct unit *pcargo,
1940 _(
"%s lost when %s was lost."),
1959 enum unit_loss_reason reason,
1965 struct unit_list *helpless = unit_list_new();
1966 struct unit_list *imperiled = unit_list_new();
1967 struct unit_list *unsaved = unit_list_new();
1969 struct city *pexclcity;
1982 _(
"You looted parts of %s map!"),
1991 PL_(
"You loot %d gold!",
"You loot %d gold!", ransom),
2006 log_debug(
"Worthless enemy doesn't have more techs to steal.");
2009 log_debug(
"Pressed tech %s from captured enemy",
2020 int vcsize = city_list_size(pplayer->
cities);
2021 int evcsize = vcsize;
2037 bool submit =
FALSE;
2043 if (
fc_rand(vcsize) < conqsize) {
2057 _(
"You conquer %s as loot!"),
2064 if (conqsize <= 0) {
2080 if (reason == ULR_CITY_LOST) {
2087 if (ptrans != NULL) {
2097 bool healthy =
FALSE;
2100 unit_list_prepend(helpless, pcargo);
2103 unit_list_prepend(imperiled, pcargo);
2117 if (pcargo->activity == ACTIVITY_SENTRY) {
2143 case ULR_ELIMINATED:
2144 case ULR_TRANSPORT_LOST:
2145 if (killer != NULL) {
2150 case ULR_BARB_UNLEASH:
2154 case ULR_NONNATIVE_TERR:
2158 case ULR_STACK_CONFLICT:
2166 case ULR_PLAYER_DIED:
2173 if (unit_list_size(helpless) > 0) {
2174 struct unit_list *remaining = unit_list_new();
2185 unit_list_prepend(unsaved, pcargo);
2188 unit_list_prepend(remaining, pcargo);
2195 unit_list_prepend(unsaved, pcargo);
2199 unit_list_destroy(remaining);
2201 unit_list_destroy(helpless);
2204 if (unit_list_size(imperiled) > 0) {
2205 struct unit_list *remaining = unit_list_new();
2216 unit_list_prepend(unsaved, pcargo);
2219 unit_list_prepend(remaining, pcargo);
2226 unit_list_prepend(unsaved, pcargo);
2230 unit_list_destroy(remaining);
2232 unit_list_destroy(imperiled);
2235 if (unit_list_size(unsaved) > 0) {
2240 unit_list_destroy(unsaved);
2260 bool helpless,
bool teleporting,
2261 const struct city *pexclcity)
2269 && ptransport != NULL) {
2280 if (pcity != NULL) {
2287 _(
"%s escaped the destruction of %s, and fled to %s."),
2308 int homecity,
enum unit_loss_reason reason)
2310 struct unit *gained_unit;
2313#ifndef FREECIV_NDEBUG
2336#ifndef FREECIV_NDEBUG
2345 id = gained_unit->
id;
2354#ifndef FREECIV_NDEBUG
2379 int ransom, unitcount = 0;
2381 bool collect_ransom =
FALSE;
2393 collect_ransom =
TRUE;
2398 collect_ransom =
FALSE;
2403 if (collect_ransom) {
2404 unitcount = unit_list_size(deftile->
units);
2412 PL_(
"%d Barbarian leader captured.",
2413 "%d Barbarian leaders captured.",
2417 PL_(
"%d gold ransom paid.",
2418 "%d gold ransom paid.",
2427 if (unitcount == 0) {
2444 int num_killed[
slots];
2445 int num_escaped[
slots];
2451 for (i = 0; i <
slots; i++) {
2453 other_killed[i] = NULL;
2472 struct tile *dsttile = NULL;
2481 if (pkiller->
moves_left <= vunit->moves_left - move_cost
2483 || unit_list_size(ptile2->units)) == 0) {
2486 if (def_bonus <= curr_def_bonus) {
2487 def_bonus = curr_def_bonus;
2494 if (dsttile != NULL) {
2497 NULL, NULL, dsttile,
2512 if (vunit !=
punit) {
2521 if (unitcount > 1 && !collect_ransom) {
2524 PL_(
"Your attacking %s succeeded against the %s %s "
2525 "(and %d other unit)!",
2526 "Your attacking %s succeeded against the %s %s "
2527 "(and %d other units)!", unitcount - 1),
2544 for (i = 0; i <
slots; i++) {
2545 if (num_killed[i] == 1) {
2551 _(
"%s lost to an attack by the %s %s."),
2561 _(
"%s lost when the %s %s attacked the %s %s."),
2568 }
else if (num_killed[i] > 1) {
2570 int others = num_killed[i] - 1;
2577 _(
"%s (and %s) lost to an attack from the %s %s."),
2588 PL_(
"%s and %d other unit lost to an attack "
2590 "%s and %d other units lost to an attack "
2591 "from the %s %s.", others),
2603 PL_(
"%d unit lost when the %s %s attacked the %s %s.",
2604 "%d units lost when the %s %s attacked the %s %s.",
2619 for (i = 0; i <
slots; i++) {
2620 if (0 < num_escaped[i]) {
2623 PL_(
"%d unit escaped from attack by %s %s",
2624 "%d units escaped from attack by %s %s",
2796 const struct player *powner;
2816 if (pplayer == NULL) {
2817 if (pconn->observer) {
2820 }
else if (pplayer == powner) {
2822 if (pdata != NULL) {
2827 if (pdata != NULL) {
2842 struct player *pplayer = pconn->playing;
2844 if (NULL == pplayer && !pconn->observer) {
2868 struct city *pcity = NULL;
2880 _(
"Your %s was nuked by %s."),
2887 _(
"The %s %s was nuked."),
2902 _(
"%s was nuked by %s."),
2908 if (
owner != pplayer) {
2921 _(
"%s was destroyed by the nuke."),
2923 if (
owner != pplayer) {
2925 _(
"Your nuke destroyed %s."),
2953 API_TYPE_PLAYER, pplayer);
2955 _(
"The %s detonated a nuke!"),
2964 const struct action *paction)
2970 _(
"%s transported successfully."),
3033 const struct action *paction)
3038 const struct city *pcity;
3050 if (NULL == plrtile->
site
3054 _(
"This unit cannot paradrop into %s."),
3059 if (NULL != plrtile->
site
3060 && plrtile->
owner != NULL
3065 _(
"%s cannot conquer a city with \"%s\"."),
3071 if (NULL != plrtile->
site
3072 && plrtile->
owner != NULL
3080 _(
"Cannot attack unless you declare war first."));
3094 _(
"Your %s paradropped into the %s and was lost."),
3107 struct player *main_victim = NULL;
3108 struct player *secondary_victim = NULL;
3114 _(
"Your %s was killed by enemy units at the "
3115 "paradrop destination."),
3122 if (pcity != NULL) {
3126 main_victim =
owner;
3128 secondary_victim =
owner;
3136 if (main_victim == NULL) {
3141 main_victim =
owner;
3143 }
else if (secondary_victim == NULL) {
3144 secondary_victim =
owner;
3148 if (main_victim == NULL) {
3151 main_victim = secondary_victim;
3169 ACT_SUB_RES_MAY_EMBARK),
3170 paction->
result == ACTRES_PARADROP_CONQUER,
3171 paction->
result == ACTRES_PARADROP_CONQUER,
3198 if (hut_chance != 0) {
3202 PL_(
"You found %d gold.",
3203 "You found %d gold.", cred), cred);
3209 _(
"An abandoned village is here."));
3212 _(
"Your %s has been killed by barbarians!"),
3278 bv_player can_see_unit;
3307 struct unit *ptrans,
3330 struct unit *ptrans;
3371 const struct unit *p1trans = p1unit, *q1trans = q1unit;
3376 while (p1trans && q1trans) {
3380 if (!p1trans && q1trans) {
3384 }
else if (p1trans && !q1trans) {
3406 struct autoattack_prob_list *autoattack;
3435 probability->
unit_id = penemy->id;
3436 autoattack_prob_list_prepend(autoattack, probability);
3445 if (autoattack_prob_list_size(autoattack) >= 2) {
3450 int sanity2 = penemy->id;
3453 double punitwin, penemywin;
3454 double threshold = 0.25;
3464 if (NULL != enemy_defender) {
3486 if ((penemywin > 1.0 - punitwin
3488 && penemywin > threshold) {
3490#ifdef REALLY_DEBUG_THIS
3491 log_test(
"AA %s -> %s (%d,%d) %.2f > %.2f && > %.2f",
3494 1.0 - punitwin, threshold);
3502#ifdef REALLY_DEBUG_THIS
3503 log_test(
"!AA %s -> %s (%d,%d) %.2f > %.2f && > %.2f",
3506 1.0 - punitwin, threshold);
3517 autoattack_prob_list_destroy(autoattack);
3522 autoattack_prob_list_destroy(autoattack);
3561 alone_in_city = (1 == count);
3563 alone_in_city =
FALSE;
3574 && penemy->activity == ACTIVITY_SENTRY
3575 && radius_sq >= distance_sq
3592 if (
punit != ppatrol
3596 cancel_orders(ppatrol,
" stopping because of nearby enemy");
3599 _(
"Orders for %s aborted after enemy movement was "
3618 struct tile *src_tile,
3619 struct tile *dst_tile,
3621 bool conquer_city_allowed)
3625 struct city *homecity_start_pos = NULL;
3626 struct city *homecity_end_pos = NULL;
3630 struct player *pplayer_end_pos = pplayer_start_pos;
3632 const struct unit_type *type_end_pos = type_start_pos;
3633 bool refresh_homecity_start_pos =
FALSE;
3634 bool refresh_homecity_end_pos =
FALSE;
3639 if (tocity && conquer_city_allowed) {
3658 if (homecity_id_start_pos != 0) {
3661 if (homecity_id_start_pos != homecity_id_end_pos) {
3664 homecity_end_pos = homecity_start_pos;
3675 if (tocity->
owner == pplayer_end_pos) {
3676 if (tocity != homecity_end_pos &&
is_human(pplayer_end_pos)) {
3681 if (homecity_start_pos) {
3682 refresh_homecity_start_pos =
TRUE;
3687 if (homecity_start_pos) {
3688 refresh_homecity_start_pos =
TRUE;
3690 if (fromcity != homecity_start_pos
3691 && fromcity->
owner == pplayer_start_pos
3699 if (homecity_start_pos || homecity_end_pos) {
3707 refresh_homecity_start_pos =
TRUE;
3708 refresh_homecity_end_pos =
TRUE;
3712 if (refresh_homecity_start_pos &&
is_human(pplayer_start_pos)) {
3716 if (refresh_homecity_end_pos
3717 && (!refresh_homecity_start_pos
3718 || homecity_start_pos != homecity_end_pos)
3738 case ACTIVITY_SENTRY:
3739 case ACTIVITY_EXPLORE:
3742 case ACTIVITY_POLLUTION:
3744 case ACTIVITY_IRRIGATE:
3745 case ACTIVITY_CULTIVATE:
3746 case ACTIVITY_PLANT:
3747 case ACTIVITY_FORTIFIED:
3748 case ACTIVITY_FORTRESS:
3749 case ACTIVITY_PILLAGE:
3750 case ACTIVITY_TRANSFORM:
3751 case ACTIVITY_UNKNOWN:
3752 case ACTIVITY_AIRBASE:
3753 case ACTIVITY_FORTIFYING:
3754 case ACTIVITY_FALLOUT:
3755 case ACTIVITY_PATROL_UNUSED:
3757 case ACTIVITY_GEN_ROAD:
3758 case ACTIVITY_CONVERT:
3759 case ACTIVITY_OLD_ROAD:
3760 case ACTIVITY_OLD_RAILROAD:
3771 struct tile *psrctile,
3772 struct tile *pdesttile)
3782 "Unit number %d (%p) was going to die, but "
3783 "server attempts to move it.",
3786 "Unit number %d (%p) has done an incomplete move.",
3806 struct tile *psrctile,
struct tile *pdesttile)
3808 struct vision *new_vision;
3819#ifndef FREECIV_NDEBUG
3860 "Unit number %d (%p) has done an incomplete move.",
3865 if (pdata->
punit != NULL) {
3885 struct unit *embark_to,
bool find_embark_target,
3886 bool conquer_city_allowed,
bool conquer_extras_allowed,
3890 struct tile *psrctile;
3891 struct city *psrccity;
3892 struct city *pdestcity;
3893 struct unit *ptransporter;
3896 struct unit_move_data_list *plist =
3902 enum direction8 facing;
3917 if (ptransporter != NULL) {
3938 unit_move_data_list_prepend(plist, pdata);
3959 if (conquer_extras_allowed
3971 unit_move_data_list_append(plist, pdata);
3975 pdata = unit_move_data_list_front(plist);
3997 if (adj && pmove_data == pdata) {
4006 pmove_data != pdata))
4008 pmove_data != pdata)) {
4013 pmove_data != pdata)) {
4023 bool new_information_for_enemy =
FALSE;
4028 if (penemy->is_connected
4029 && pplayer != penemy
4032 new_information_for_enemy =
TRUE;
4037 if (new_information_for_enemy) {
4064 if (aplayer == NULL) {
4065 if (pconn->observer) {
4071 if (aplayer == pplayer) {
4084 if (adj && pmove_data == pdata) {
4098 if (aplayer == NULL) {
4099 if (pconn->observer) {
4104 if (aplayer == pmove_data->powner) {
4115 if (pmove_data->old_vision != NULL) {
4118 pmove_data->old_vision = NULL;
4124 struct unit *aunit = pmove_data->punit;
4130 pdata != pmove_data,
4131 conquer_city_allowed);
4146 if (embark_to != NULL) {
4147 ptransporter = embark_to;
4148 }
else if (find_embark_target) {
4153 ptransporter = NULL;
4173 struct unit *aunit = pmove_data->punit;
4175 if (aunit == NULL) {
4191 if (pdestcity != NULL) {
4195 struct unit *ptrans;
4197 struct unit *act_unit;
4198 struct player *act_player;
4200 act_unit = pmove_data->punit;
4203 if (act_unit == NULL
4234 if (NULL == ptrans) {
4263 unit_move_data_list_destroy(plist);
4266 if (psrccity != NULL) {
4269 if (pdestcity != NULL) {
4318 bool cancel =
FALSE;
4377 bool res, last_order;
4400 struct tile *dst_tile;
4401 struct city *tgt_city;
4402 struct unit *tgt_unit;
4408 log_debug(
" stopping because we're done this turn");
4416 _(
"Orders for %s aborted as there are units nearby."),
4423 log_debug(
" stopping because we ran a round");
4438 switch (order.
order) {
4443 log_debug(
" stopping because of no more move points");
4449 log_debug(
" stopping. Not enough move points this turn");
4476 switch (order.
order) {
4489 enum unit_activity activity = order.
activity;
4504 _(
"Orders for %s aborted since they "
4505 "give an invalid activity."),
4514 _(
"Orders for %s aborted since they "
4515 "give an invalid location."),
4525 _(
"Orders for %s aborted as there "
4526 "are units in the way."),
4542 log_debug(
" orders resulted in combat.");
4570 _(
"Orders for %s aborted because of failed move."),
4587 if (dst_tile == NULL) {
4593 order.
action, dst_tile, NULL, NULL);
4601 if (tgt_city == NULL
4607 order.
action, dst_tile, tgt_city, NULL);
4615 if (tgt_unit == NULL
4621 order.
action, dst_tile, tgt_city, tgt_unit);
4667 tgt_id = dst_tile->
index;
4672 tgt_id = dst_tile->
index;
4677 tgt_id = dst_tile->
index;
4682 tgt_id = tgt_city->
id;
4688 tgt_id = tgt_unit->
id;
4696 log_error(
"Invalid action target kind");
4711 _(
"%s could not do %s to %s."),
4718 order.
action, dst_tile, tgt_city, tgt_unit);
4749 _(
"Orders for %s aborted because "
4750 "doing %s to %s failed."),
4773 _(
"Your %s has invalid orders."),
4780 log_debug(
" stopping because orders are complete");
4813 log_error(
"Unsupported vision layer variant: %d.", vlayer);
4822 const struct tile *ptile)
4829 EFT_UNIT_VISION_RADIUS_SQ));
4840 enum vision_layer
vlayer)
4901 ftc_server,
_(
"Your unit may not act for another %s "
4902 "this turn. See /help unitwaittime."), buf);
bool action_removes_extra(const struct action *paction, const struct extra_type *pextra)
const char * action_name_translation(const struct action *action)
bool action_mp_full_makes_legal(const struct unit *actor, const action_id act_id)
const char * action_id_name_translation(action_id act_id)
bool action_prob_possible(const struct act_prob probability)
struct act_prob action_prob_vs_tile(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
const char * action_rule_name(const struct action *action)
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
struct act_prob action_prob_vs_extras(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
struct act_prob action_prob_self(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id)
struct act_prob action_prob_vs_units(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
struct act_prob action_prob_vs_city(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
bool action_id_exists(const action_id act_id)
bool action_creates_extra(const struct action *paction, const struct extra_type *pextra)
int action_prob_cmp_pessimist(const struct act_prob ap1, const struct act_prob ap2)
struct act_prob action_prob_vs_unit(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
double action_prob_to_0_to_1_pessimist(const struct act_prob ap)
static struct action * action_by_number(action_id act_id)
#define action_has_result(_act_, _res_)
#define action_id_get_act_time(act_id, actor_unit, tgt_tile, tgt_extra)
#define ACTPROB_IMPOSSIBLE
#define action_id_get_target_kind(act_id)
#define action_id_has_result_safe(act_id, result)
bool adv_follow_path(struct unit *punit, struct pf_path *path, struct tile *ptile)
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
enum unit_move_result manage_auto_explorer(struct unit *punit)
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
#define BV_ISSET(bv, bit)
const char * city_name_get(const struct city *pcity)
bool is_friendly_city_near(const struct civ_map *nmap, const struct player *owner, const struct tile *ptile)
bool city_exists_within_max_city_map(const struct civ_map *nmap, const struct tile *ptile, bool may_be_on_center)
#define city_list_iterate_safe(citylist, _city)
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
static citizens city_size_get(const struct city *pcity)
static bool is_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
#define output_type_iterate(output)
#define city_owner(_pcity_)
#define city_list_iterate_end
#define city_list_iterate_safe_end
#define output_type_iterate_end
bool city_reduce_size(struct city *pcity, citizens pop_loss, struct player *destroyer, const char *reason)
bool city_refresh(struct city *pcity)
bool is_unit_reachable_at(const struct unit *defender, const struct unit *attacker, const struct tile *location)
bool is_stack_vulnerable(const struct tile *ptile)
int get_virtual_defense_power(const struct civ_map *nmap, const struct unit_type *att_type, const struct unit_type *def_type, struct player *def_player, struct tile *ptile, bool fortified, int veteran)
int unit_bombard_rate(struct unit *punit)
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
int get_total_attack_power(const struct unit *attacker, const struct unit *defender)
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender)
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile)
void get_modified_firepower(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender, int *att_fp, int *def_fp)
struct player * conn_get_player(const struct connection *pconn)
void conn_list_do_unbuffer(struct conn_list *dest)
void conn_list_do_buffer(struct conn_list *dest)
bool conn_is_global_observer(const struct connection *pconn)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
static void base(QVariant data1, QVariant data2)
static void enter_hut(QVariant data1, QVariant data2)
static void frighten_hut(QVariant data1, QVariant data2)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, const struct action *paction, enum effect_type effect_type)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
#define ACT_TIME_INSTANTANEOUS
#define IDENTITY_NUMBER_ZERO
#define PL_(String1, String2, n)
const char * tile_link(const struct tile *ptile)
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
const char * unit_link(const struct unit *punit)
const char * unit_tile_link(const struct unit *punit)
int current_turn_timeout(void)
void game_remove_unit(struct world *gworld, struct unit *punit)
struct unit * game_unit_by_number(int id)
struct city * game_city_by_number(int id)
void increase_timeout_because_unit_moved(void)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
void idex_register_unit(struct world *iworld, struct unit *punit)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert_exit_msg(condition, message,...)
#define log_verbose(message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_error(message,...)
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
bool base_get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile, enum direction8 *dir)
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define square_iterate_end
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
#define circle_iterate(nmap, center_tile, sq_radius, tile_itr)
#define circle_iterate_end
void vision_clear_sight(struct vision *vision)
void destroy_extra(struct tile *ptile, struct extra_type *pextra)
void bounce_units_on_terrain_change(struct tile *ptile)
void tile_claim_bases(struct tile *ptile, struct player *powner)
void create_extra(struct tile *ptile, struct extra_type *pextra, struct player *pplayer)
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
void update_tile_knowledge(struct tile *ptile)
void check_terrain_change(struct tile *ptile, struct terrain *oldter)
bool give_distorted_map(struct player *pfrom, struct player *pto, int prob, bool reveal_cities)
struct vision_site * map_get_player_site(const struct tile *ptile, const struct player *pplayer)
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
void vision_change_sight(struct vision *vision, const v_radius_t radius_sq)
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
int unit_move_rate(const struct unit *punit)
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
static const char * name_translation_get(const struct name_translation *ptrans)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_unit(const struct unit *punit)
const char * nation_adjective_for_player(const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
int send_packet_unit_remove(struct connection *pc, const struct packet_unit_remove *packet)
void lsend_packet_unit_remove(struct conn_list *dest, const struct packet_unit_remove *packet)
int send_packet_unit_short_info(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
int send_packet_unit_info(struct connection *pc, const struct packet_unit_info *packet)
void dlsend_packet_unit_remove(struct conn_list *dest, int unit_id16, int unit_id32)
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
struct player * player_by_number(const int player_id)
bool can_player_see_unit_at(const struct player *pplayer, const struct unit *punit, const struct tile *ptile, bool is_transported)
int player_slot_count(void)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
int player_index(const struct player *pplayer)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
struct player_slot * slots
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
void player_update_last_war_action(struct player *pplayer)
void player_status_add(struct player *plr, enum player_status pstatus)
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
void send_player_info_c(struct player *src, struct conn_list *dest)
struct conn_list * player_reply_dest(struct player *pplayer)
#define phase_players_iterate(pplayer)
#define phase_players_iterate_end
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
const char * research_advance_rule_name(const struct research *presearch, Tech_type_id tech)
struct research * research_get(const struct player *pplayer)
void script_server_signal_emit(const char *signal_name,...)
void script_server_remove_exported_object(void *object)
void format_time_duration(time_t t, char *buf, int maxlen)
#define CLIP(lower, current, upper)
int identity_number(void)
enum action_result result
bv_action_sub_results sub_results
enum act_tgt_compl target_complexity
struct unit_list * units_supported
struct civ_game::@30::@34 server
struct conn_list * est_connections
struct packet_game_info info
int autoupgrade_veteran_loss
enum gameloss_style gameloss_style
enum goods_selection_method goods_selection
enum happyborders_type happyborders
int nuke_defender_survival_chance_pct
bool only_real_fight_makes_veteran
enum airlifting_style airlifting_style
bool only_killing_makes_veteran
bool combat_odds_scaled_veterancy
enum action_decision action_decision_want
struct unit_order orders[MAX_LEN_ROUTE]
enum unit_activity activity
enum unit_activity changed_from
enum server_side_agent ssa_controller
struct vision_site * site
struct city_list * cities
struct conn_list * connections
struct player_economic economic
struct player_score score
struct player::@69::@71 server
const struct player * player
struct unit_class::@85 cache
struct extra_type_list * refuel_extras
struct vision * old_vision
enum unit_activity activity
const struct unit_type * converted_to
enum action_decision action_decision_want
enum unit_activity activity
struct extra_type * changed_from_target
struct extra_type * activity_target
enum unit_activity changed_from
struct player * nationality
void(* removal_callback)(struct unit *punit)
struct unit_move_data * moving
struct unit::@80::@83 server
struct goods_type * carrying
struct tile * action_decision_tile
const struct unit_type * utype
enum server_side_agent ssa_controller
struct name_translation name
#define sz_strlcpy(dest, src)
const char * terrain_name_translation(const struct terrain *pterrain)
struct extra_type * get_preferred_pillage(bv_extras extras)
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
bool tile_has_not_aggressive_extra_for_unit(const struct tile *ptile, const struct unit_type *punittype)
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
bool tile_apply_activity(struct tile *ptile, Activity_type_id act, struct extra_type *tgt)
int tile_extras_defense_bonus(const struct tile *ptile, const struct unit_type *punittype)
int tile_activity_time(enum unit_activity activity, const struct tile *ptile, const struct extra_type *tgt)
struct city * tile_city(const struct tile *ptile)
#define tile_terrain(_tile)
static const bv_extras * tile_extras(const struct tile *ptile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
struct goods_type * goods_from_city_to_unit(struct city *src, struct unit *punit)
Goods_type_id goods_index(const struct goods_type *pgood)
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer)
int get_transporter_occupancy(const struct unit *ptrans)
void free_unit_orders(struct unit *punit)
bool unit_is_alive(int id)
int get_activity_rate_this_turn(const struct unit *punit)
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
struct player * unit_nationality(const struct unit *punit)
struct unit * unit_transport_get(const struct unit *pcargo)
bool unit_transport_unload(struct unit *pcargo)
int unit_gain_hitpoints(const struct unit *punit)
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
void unit_virtual_destroy(struct unit *punit)
void unit_tile_set(struct unit *punit, struct tile *ptile)
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
bool unit_transported(const struct unit *pcargo)
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
bool unit_has_orders(const struct unit *punit)
struct unit * transporter_for_unit(const struct unit *pcargo)
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
bool activity_requires_target(enum unit_activity activity)
bool can_unit_do_activity_targeted(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, struct extra_type *target)
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
#define unit_cargo_iterate_end
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
#define unit_cargo_iterate(_ptrans, _pcargo)
#define CHECK_UNIT(punit)
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
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)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
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)
bool unit_move_handling(struct unit *punit, struct tile *pdesttile, bool move_do_not_act)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
const char * unit_name_translation(const struct unit *punit)
struct unit_type * get_role_unit(int role, int role_index)
const char * unit_rule_name(const struct unit *punit)
const struct veteran_system * utype_veteran_system(const struct unit_type *punittype)
int num_role_units(int role)
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype)
struct unit_class * unit_class_get(const struct unit *punit)
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
const struct veteran_level * vsystem_veteran_level(const struct veteran_system *vsystem, int level)
Unit_type_id utype_number(const struct unit_type *punittype)
const char * utype_name_translation(const struct unit_type *punittype)
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
struct vision * vision_new(struct player *pplayer, struct tile *ptile)
void vision_free(struct vision *vision)
#define V_RADIUS(main_sq, invis_sq, subs_sq)
#define vision_site_owner(v)
short int v_radius_t[V_COUNT]