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;
354 int *att_hp,
int *def_hp)
360 int attack_firepower, defense_firepower;
365 *att_hp = attacker->
hp;
366 *def_hp = defender->
hp;
368 &attack_firepower, &defense_firepower);
370 log_verbose(
"attack:%d, defense:%d, attack firepower:%d, "
371 "defense firepower:%d", attackpower, defensepower,
372 attack_firepower, defense_firepower);
377 for (i = 0; i < rate; i++) {
378 if (
fc_rand(attackpower + defensepower) >= defensepower) {
379 *def_hp -= attack_firepower;
394 bool powerless,
int att_vet,
int def_vet)
397 if (attacker->
hp <= 0 || defender->
hp <= 0
403 if (attacker->
hp > 0) {
406 if (defender->
hp > 0) {
420 struct unit_list *candidates;
425 candidates = unit_list_new();
431 unit_list_prepend(candidates,
punit);
435 while (upgrades > 0 && unit_list_size(candidates) > 0) {
438 int candidate_to_upgrade =
fc_rand(unit_list_size(candidates));
439 struct unit *
punit = unit_list_get(candidates, candidate_to_upgrade);
445 _(
"%s was upgraded for free to %s."),
448 unit_list_remove(candidates,
punit);
452 unit_list_destroy(candidates);
491 "because it was not supported by a city."),
495 _(
"Your %s has run out of hit points."),
512 struct unit *carrier;
545 log_error(
"rescue plane: unit %d died enroute!",
id);
550 log_debug(
"rescue plane: unit %d could not move to "
570 _(
"Your %s has returned to refuel."),
755 _(
"Your %s became more experienced and achieved the rank "
775 _(
"%s converted to %s."),
781 _(
"%s cannot be converted."),
794 _(
"Orders for %s aborted because activity "
795 "is no longer available."),
852 bool unit_activity_done =
FALSE;
859 case ACTIVITY_EXPLORE:
860 case ACTIVITY_FORTIFIED:
861 case ACTIVITY_SENTRY:
863 case ACTIVITY_PATROL_UNUSED:
864 case ACTIVITY_UNKNOWN:
869 case ACTIVITY_FORTIFYING:
870 case ACTIVITY_CONVERT:
874 case ACTIVITY_POLLUTION:
876 case ACTIVITY_IRRIGATE:
877 case ACTIVITY_PILLAGE:
878 case ACTIVITY_CULTIVATE:
880 case ACTIVITY_TRANSFORM:
881 case ACTIVITY_FALLOUT:
883 case ACTIVITY_GEN_ROAD:
891 case ACTIVITY_OLD_ROAD:
892 case ACTIVITY_OLD_RAILROAD:
893 case ACTIVITY_FORTRESS:
894 case ACTIVITY_AIRBASE:
903 case ACTIVITY_FORTIFIED:
904 case ACTIVITY_SENTRY:
906 case ACTIVITY_UNKNOWN:
907 case ACTIVITY_FORTIFYING:
908 case ACTIVITY_CONVERT:
909 case ACTIVITY_PATROL_UNUSED:
914 case ACTIVITY_EXPLORE:
918 case ACTIVITY_PILLAGE:
922 unit_activity_done =
TRUE;
931 case ACTIVITY_POLLUTION:
940 unit_activity_done =
TRUE;
944 case ACTIVITY_FALLOUT:
953 unit_activity_done =
TRUE;
962 unit_activity_done =
TRUE;
967 case ACTIVITY_GEN_ROAD:
972 unit_activity_done =
TRUE;
977 case ACTIVITY_IRRIGATE:
979 case ACTIVITY_CULTIVATE:
981 case ACTIVITY_TRANSFORM:
989 unit_activity_done =
TRUE;
993 case ACTIVITY_OLD_ROAD:
994 case ACTIVITY_OLD_RAILROAD:
995 case ACTIVITY_FORTRESS:
996 case ACTIVITY_AIRBASE:
1001 if (unit_activity_done) {
1003 if (ACTIVITY_CULTIVATE == activity
1004 || ACTIVITY_PLANT == activity
1005 || ACTIVITY_TRANSFORM == activity) {
1007 if (punit2->activity == activity) {
1017 if (punit2->activity == activity
1018 && punit2->activity_target == act_tgt) {
1031 if (activity == ACTIVITY_FORTIFYING) {
1036 unit_activity_done =
TRUE;
1040 if (activity == ACTIVITY_CONVERT) {
1046 unit_activity_done =
TRUE;
1050 if (unit_activity_done) {
1051 if (activity == ACTIVITY_PILLAGE) {
1082 case ACTIVITY_PILLAGE:
1100 enum unit_activity *activity,
1105 if (*activity == ACTIVITY_PILLAGE
1106 && *target == NULL) {
1122 *activity = ACTIVITY_IDLE;
1134 struct tile **dst_tile)
1151 if (0 < unit_list_size(ptile->units)) {
1166 if (value > bestvalue) {
1172 return bestvalue > 0;
1179 int count,
int sq_radius)
1181 struct tile *ptile = NULL;
1187 sq_radius, &ptile)) {
1205 int move_cost,
bool verbose)
1210 log_verbose(
"Teleported %s %s from (%d,%d) to %s",
1216 _(
"Teleported your %s to %s."),
1224 if (move_cost == -1) {
1245 struct tile *punit_tile;
1251 struct tile *tiles[(2 * DIST + 1) * (2 * DIST + 1)];
1265 if (ptile == punit_tile) {
1272 tiles[count++] = ptile;
1282 _(
"Moved your %s."),
1298 struct unit_list *pcargo_units;
1309 _(
"Disbanded your %s."),
1326 struct unit *ptrans;
1327 struct unit_list *pcargo_units;
1355 if (NULL == ptrans || pplayer !=
unit_owner(ptrans)) {
1368 "Failed to throw %s %d from %s %d (%d, %d)",
1387 struct player *aplayer,
bool verbose)
1431 const struct player *aplayer)
1433 struct unit_list *seen_units = unit_list_new();
1439 unit_list_append(seen_units,
punit);
1447 unit_list_append(seen_units,
punit);
1453 unit_list_unique(seen_units);
1466 const struct unit_list *seen_units)
1503 const struct player *pplayer,
1545 const struct player *pplayer,
1645 int homecity_id,
int moves_left,
int hp_left,
1646 struct unit *ptrans)
1725 struct city *pcity,
struct unit *ptrans,
bool force)
1806 enum unit_loss_reason reason)
1812 struct unit *ptrans;
1818#if defined(FREECIV_DEBUG) && !defined(FREECIV_NDEBUG)
1874 && ULR_EDITOR != reason) {
1876 _(
"Unable to defend %s, %s has lost the game."),
1880 _(
"Losing %s meant losing the game! "
1881 "Be more careful next time!"),
1889 unit_loss_reason_name((reason == ULR_UPKEEP)
1897 if (NULL != ptrans) {
1911 if (pcity && pcity != phomecity) {
1916 if (pcity && unit_list_size(ptile->
units) == 0) {
1927 enum unit_loss_reason reason)
1936 struct unit *pcargo,
1941 _(
"%s lost when %s was lost."),
1960 enum unit_loss_reason reason,
1966 struct unit_list *helpless = unit_list_new();
1967 struct unit_list *imperiled = unit_list_new();
1968 struct unit_list *unsaved = unit_list_new();
1970 struct city *pexclcity;
1983 _(
"You looted parts of %s map!"),
1992 PL_(
"You loot %d gold!",
"You loot %d gold!", ransom),
2007 log_debug(
"Worthless enemy doesn't have more techs to steal.");
2010 log_debug(
"Pressed tech %s from captured enemy",
2021 int vcsize = city_list_size(pplayer->
cities);
2022 int evcsize = vcsize;
2038 bool submit =
FALSE;
2044 if (
fc_rand(vcsize) < conqsize) {
2058 _(
"You conquer %s as loot!"),
2065 if (conqsize <= 0) {
2081 if (reason == ULR_CITY_LOST) {
2088 if (ptrans != NULL) {
2098 bool healthy =
FALSE;
2101 unit_list_prepend(helpless, pcargo);
2104 unit_list_prepend(imperiled, pcargo);
2118 if (pcargo->activity == ACTIVITY_SENTRY) {
2144 case ULR_ELIMINATED:
2145 case ULR_TRANSPORT_LOST:
2146 if (killer != NULL) {
2151 case ULR_BARB_UNLEASH:
2155 case ULR_NONNATIVE_TERR:
2159 case ULR_STACK_CONFLICT:
2167 case ULR_PLAYER_DIED:
2174 if (unit_list_size(helpless) > 0) {
2175 struct unit_list *remaining = unit_list_new();
2186 unit_list_prepend(unsaved, pcargo);
2189 unit_list_prepend(remaining, pcargo);
2196 unit_list_prepend(unsaved, pcargo);
2200 unit_list_destroy(remaining);
2202 unit_list_destroy(helpless);
2205 if (unit_list_size(imperiled) > 0) {
2206 struct unit_list *remaining = unit_list_new();
2217 unit_list_prepend(unsaved, pcargo);
2220 unit_list_prepend(remaining, pcargo);
2227 unit_list_prepend(unsaved, pcargo);
2231 unit_list_destroy(remaining);
2233 unit_list_destroy(imperiled);
2236 if (unit_list_size(unsaved) > 0) {
2241 unit_list_destroy(unsaved);
2261 bool helpless,
bool teleporting,
2262 const struct city *pexclcity)
2270 && ptransport != NULL) {
2281 if (pcity != NULL) {
2288 _(
"%s escaped the destruction of %s, and fled to %s."),
2309 int homecity,
enum unit_loss_reason reason)
2311 struct unit *gained_unit;
2314#ifndef FREECIV_NDEBUG
2337#ifndef FREECIV_NDEBUG
2346 id = gained_unit->
id;
2355#ifndef FREECIV_NDEBUG
2380 int ransom, unitcount = 0;
2382 bool collect_ransom =
FALSE;
2394 collect_ransom =
TRUE;
2399 collect_ransom =
FALSE;
2404 if (collect_ransom) {
2405 unitcount = unit_list_size(deftile->
units);
2413 PL_(
"%d Barbarian leader captured.",
2414 "%d Barbarian leaders captured.",
2418 PL_(
"%d gold ransom paid.",
2419 "%d gold ransom paid.",
2428 if (unitcount == 0) {
2445 int num_killed[
slots];
2446 int num_escaped[
slots];
2452 for (i = 0; i <
slots; i++) {
2454 other_killed[i] = NULL;
2473 struct tile *dsttile = NULL;
2482 if (pkiller->
moves_left <= vunit->moves_left - move_cost
2484 || unit_list_size(ptile2->units)) == 0) {
2487 if (def_bonus <= curr_def_bonus) {
2488 def_bonus = curr_def_bonus;
2495 if (dsttile != NULL) {
2498 NULL, NULL, dsttile,
2513 if (vunit !=
punit) {
2522 if (unitcount > 1 && !collect_ransom) {
2525 PL_(
"Your attacking %s succeeded against the %s %s "
2526 "(and %d other unit)!",
2527 "Your attacking %s succeeded against the %s %s "
2528 "(and %d other units)!", unitcount - 1),
2545 for (i = 0; i <
slots; i++) {
2546 if (num_killed[i] == 1) {
2552 _(
"%s lost to an attack by the %s %s."),
2562 _(
"%s lost when the %s %s attacked the %s %s."),
2569 }
else if (num_killed[i] > 1) {
2571 int others = num_killed[i] - 1;
2578 _(
"%s (and %s) lost to an attack from the %s %s."),
2589 PL_(
"%s and %d other unit lost to an attack "
2591 "%s and %d other units lost to an attack "
2592 "from the %s %s.", others),
2604 PL_(
"%d unit lost when the %s %s attacked the %s %s.",
2605 "%d units lost when the %s %s attacked the %s %s.",
2620 for (i = 0; i <
slots; i++) {
2621 if (0 < num_escaped[i]) {
2624 PL_(
"%d unit escaped from attack by %s %s",
2625 "%d units escaped from attack by %s %s",
2797 const struct player *powner;
2817 if (pplayer == NULL) {
2818 if (pconn->observer) {
2821 }
else if (pplayer == powner) {
2823 if (pdata != NULL) {
2828 if (pdata != NULL) {
2843 struct player *pplayer = pconn->playing;
2845 if (NULL == pplayer && !pconn->observer) {
2869 struct city *pcity = NULL;
2881 _(
"Your %s was nuked by %s."),
2888 _(
"The %s %s was nuked."),
2903 _(
"%s was nuked by %s."),
2909 if (
owner != pplayer) {
2922 _(
"%s was destroyed by the nuke."),
2924 if (
owner != pplayer) {
2926 _(
"Your nuke destroyed %s."),
2954 API_TYPE_PLAYER, pplayer);
2956 _(
"The %s detonated a nuke!"),
2965 const struct action *paction)
2971 _(
"%s transported successfully."),
3034 const struct action *paction)
3039 const struct city *pcity;
3051 if (NULL == plrtile->
site
3055 _(
"This unit cannot paradrop into %s."),
3060 if (NULL != plrtile->
site
3061 && plrtile->
owner != NULL
3066 _(
"%s cannot conquer a city with \"%s\"."),
3072 if (NULL != plrtile->
site
3073 && plrtile->
owner != NULL
3081 _(
"Cannot attack unless you declare war first."));
3095 _(
"Your %s paradropped into the %s and was lost."),
3108 struct player *main_victim = NULL;
3109 struct player *secondary_victim = NULL;
3115 _(
"Your %s was killed by enemy units at the "
3116 "paradrop destination."),
3123 if (pcity != NULL) {
3127 main_victim =
owner;
3129 secondary_victim =
owner;
3137 if (main_victim == NULL) {
3142 main_victim =
owner;
3144 }
else if (secondary_victim == NULL) {
3145 secondary_victim =
owner;
3149 if (main_victim == NULL) {
3152 main_victim = secondary_victim;
3170 ACT_SUB_RES_MAY_EMBARK),
3171 paction->
result == ACTRES_PARADROP_CONQUER,
3172 paction->
result == ACTRES_PARADROP_CONQUER,
3199 if (hut_chance != 0) {
3203 PL_(
"You found %d gold.",
3204 "You found %d gold.", cred), cred);
3210 _(
"An abandoned village is here."));
3213 _(
"Your %s has been killed by barbarians!"),
3279 bv_player can_see_unit;
3308 struct unit *ptrans,
3331 struct unit *ptrans;
3372 const struct unit *p1trans = p1unit, *q1trans = q1unit;
3377 while (p1trans && q1trans) {
3381 if (!p1trans && q1trans) {
3385 }
else if (p1trans && !q1trans) {
3407 struct autoattack_prob_list *autoattack;
3436 probability->
unit_id = penemy->id;
3437 autoattack_prob_list_prepend(autoattack, probability);
3446 if (autoattack_prob_list_size(autoattack) >= 2) {
3451 int sanity2 = penemy->id;
3454 double punitwin, penemywin;
3455 double threshold = 0.25;
3465 if (NULL != enemy_defender) {
3487 if ((penemywin > 1.0 - punitwin
3489 && penemywin > threshold) {
3491#ifdef REALLY_DEBUG_THIS
3492 log_test(
"AA %s -> %s (%d,%d) %.2f > %.2f && > %.2f",
3495 1.0 - punitwin, threshold);
3503#ifdef REALLY_DEBUG_THIS
3504 log_test(
"!AA %s -> %s (%d,%d) %.2f > %.2f && > %.2f",
3507 1.0 - punitwin, threshold);
3518 autoattack_prob_list_destroy(autoattack);
3523 autoattack_prob_list_destroy(autoattack);
3562 alone_in_city = (1 == count);
3564 alone_in_city =
FALSE;
3575 && penemy->activity == ACTIVITY_SENTRY
3576 && radius_sq >= distance_sq
3593 if (
punit != ppatrol
3597 cancel_orders(ppatrol,
" stopping because of nearby enemy");
3600 _(
"Orders for %s aborted after enemy movement was "
3619 struct tile *src_tile,
3620 struct tile *dst_tile,
3622 bool conquer_city_allowed)
3626 struct city *homecity_start_pos = NULL;
3627 struct city *homecity_end_pos = NULL;
3631 struct player *pplayer_end_pos = pplayer_start_pos;
3633 const struct unit_type *type_end_pos = type_start_pos;
3634 bool refresh_homecity_start_pos =
FALSE;
3635 bool refresh_homecity_end_pos =
FALSE;
3640 if (tocity && conquer_city_allowed) {
3659 if (homecity_id_start_pos != 0) {
3662 if (homecity_id_start_pos != homecity_id_end_pos) {
3665 homecity_end_pos = homecity_start_pos;
3676 if (tocity->
owner == pplayer_end_pos) {
3677 if (tocity != homecity_end_pos &&
is_human(pplayer_end_pos)) {
3682 if (homecity_start_pos) {
3683 refresh_homecity_start_pos =
TRUE;
3688 if (homecity_start_pos) {
3689 refresh_homecity_start_pos =
TRUE;
3691 if (fromcity != homecity_start_pos
3692 && fromcity->
owner == pplayer_start_pos
3700 if (homecity_start_pos || homecity_end_pos) {
3708 refresh_homecity_start_pos =
TRUE;
3709 refresh_homecity_end_pos =
TRUE;
3713 if (refresh_homecity_start_pos &&
is_human(pplayer_start_pos)) {
3717 if (refresh_homecity_end_pos
3718 && (!refresh_homecity_start_pos
3719 || homecity_start_pos != homecity_end_pos)
3739 case ACTIVITY_SENTRY:
3740 case ACTIVITY_EXPLORE:
3743 case ACTIVITY_POLLUTION:
3745 case ACTIVITY_IRRIGATE:
3746 case ACTIVITY_CULTIVATE:
3747 case ACTIVITY_PLANT:
3748 case ACTIVITY_FORTIFIED:
3749 case ACTIVITY_FORTRESS:
3750 case ACTIVITY_PILLAGE:
3751 case ACTIVITY_TRANSFORM:
3752 case ACTIVITY_UNKNOWN:
3753 case ACTIVITY_AIRBASE:
3754 case ACTIVITY_FORTIFYING:
3755 case ACTIVITY_FALLOUT:
3756 case ACTIVITY_PATROL_UNUSED:
3758 case ACTIVITY_GEN_ROAD:
3759 case ACTIVITY_CONVERT:
3760 case ACTIVITY_OLD_ROAD:
3761 case ACTIVITY_OLD_RAILROAD:
3772 struct tile *psrctile,
3773 struct tile *pdesttile)
3783 "Unit number %d (%p) was going to die, but "
3784 "server attempts to move it.",
3787 "Unit number %d (%p) has done an incomplete move.",
3807 struct tile *psrctile,
struct tile *pdesttile)
3809 struct vision *new_vision;
3820#ifndef FREECIV_NDEBUG
3861 "Unit number %d (%p) has done an incomplete move.",
3866 if (pdata->
punit != NULL) {
3886 struct unit *embark_to,
bool find_embark_target,
3887 bool conquer_city_allowed,
bool conquer_extras_allowed,
3891 struct tile *psrctile;
3892 struct city *psrccity;
3893 struct city *pdestcity;
3894 struct unit *ptransporter;
3897 struct unit_move_data_list *plist =
3903 enum direction8 facing;
3918 if (ptransporter != NULL) {
3939 unit_move_data_list_prepend(plist, pdata);
3960 if (conquer_extras_allowed
3972 unit_move_data_list_append(plist, pdata);
3976 pdata = unit_move_data_list_front(plist);
3998 if (adj && pmove_data == pdata) {
4007 pmove_data != pdata))
4009 pmove_data != pdata)) {
4014 pmove_data != pdata)) {
4024 bool new_information_for_enemy =
FALSE;
4029 if (penemy->is_connected
4030 && pplayer != penemy
4033 new_information_for_enemy =
TRUE;
4038 if (new_information_for_enemy) {
4065 if (aplayer == NULL) {
4066 if (pconn->observer) {
4072 if (aplayer == pplayer) {
4085 if (adj && pmove_data == pdata) {
4099 if (aplayer == NULL) {
4100 if (pconn->observer) {
4105 if (aplayer == pmove_data->powner) {
4116 if (pmove_data->old_vision != NULL) {
4119 pmove_data->old_vision = NULL;
4125 struct unit *aunit = pmove_data->punit;
4131 pdata != pmove_data,
4132 conquer_city_allowed);
4147 if (embark_to != NULL) {
4148 ptransporter = embark_to;
4149 }
else if (find_embark_target) {
4154 ptransporter = NULL;
4174 struct unit *aunit = pmove_data->punit;
4176 if (aunit == NULL) {
4192 if (pdestcity != NULL) {
4196 struct unit *ptrans;
4198 struct unit *act_unit;
4199 struct player *act_player;
4201 act_unit = pmove_data->punit;
4204 if (act_unit == NULL
4235 if (NULL == ptrans) {
4264 unit_move_data_list_destroy(plist);
4267 if (psrccity != NULL) {
4270 if (pdestcity != NULL) {
4319 bool cancel =
FALSE;
4378 bool res, last_order;
4401 struct tile *dst_tile;
4402 struct city *tgt_city;
4403 struct unit *tgt_unit;
4409 log_debug(
" stopping because we're done this turn");
4417 _(
"Orders for %s aborted as there are units nearby."),
4424 log_debug(
" stopping because we ran a round");
4439 switch (order.
order) {
4444 log_debug(
" stopping because of no more move points");
4450 log_debug(
" stopping. Not enough move points this turn");
4477 switch (order.
order) {
4490 enum unit_activity activity = order.
activity;
4505 _(
"Orders for %s aborted since they "
4506 "give an invalid activity."),
4515 _(
"Orders for %s aborted since they "
4516 "give an invalid location."),
4526 _(
"Orders for %s aborted as there "
4527 "are units in the way."),
4543 log_debug(
" orders resulted in combat.");
4571 _(
"Orders for %s aborted because of failed move."),
4588 if (dst_tile == NULL) {
4594 order.
action, dst_tile, NULL, NULL);
4602 if (tgt_city == NULL
4608 order.
action, dst_tile, tgt_city, NULL);
4616 if (tgt_unit == NULL
4622 order.
action, dst_tile, tgt_city, tgt_unit);
4668 tgt_id = dst_tile->
index;
4673 tgt_id = dst_tile->
index;
4678 tgt_id = dst_tile->
index;
4683 tgt_id = tgt_city->
id;
4689 tgt_id = tgt_unit->
id;
4697 log_error(
"Invalid action target kind");
4712 _(
"%s could not do %s to %s."),
4719 order.
action, dst_tile, tgt_city, tgt_unit);
4750 _(
"Orders for %s aborted because "
4751 "doing %s to %s failed."),
4774 _(
"Your %s has invalid orders."),
4781 log_debug(
" stopping because orders are complete");
4814 log_error(
"Unsupported vision layer variant: %d.", vlayer);
4823 const struct tile *ptile)
4830 EFT_UNIT_VISION_RADIUS_SQ));
4841 enum vision_layer
vlayer)
4902 ftc_server,
_(
"Your unit may not act for another %s "
4903 "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]