Bug #1564 » 3_4-airlift_possible_corr.patch
common/unit.c | ||
---|---|---|
{
|
||
const struct city *psrc_city = tile_city(unit_tile(punit));
|
||
const struct player *punit_owner;
|
||
struct tile *dst_tile = nullptr;
|
||
enum unit_airlift_result ok_result = AR_OK;
|
||
if (0 == punit->moves_left
|
||
... | ... | |
return AR_OCCUPIED;
|
||
}
|
||
if (NULL == psrc_city) {
|
||
if (nullptr == psrc_city) {
|
||
/* No city there. */
|
||
return AR_NOT_IN_CITY;
|
||
}
|
||
... | ... | |
return AR_BAD_DST_CITY;
|
||
}
|
||
if (pdest_city
|
||
&& (NULL == restriction
|
||
|| (tile_get_known(city_tile(pdest_city), restriction)
|
||
== TILE_KNOWN_SEEN))
|
||
&& !can_unit_exist_at_tile(nmap, punit, city_tile(pdest_city))) {
|
||
/* Can't exist at the destination tile. */
|
||
return AR_BAD_DST_CITY;
|
||
if (nullptr != pdest_city) {
|
||
dst_tile = city_tile(pdest_city);
|
||
if ((nullptr == restriction
|
||
|| (tile_get_known(dst_tile, restriction)
|
||
== TILE_KNOWN_SEEN))
|
||
&& !can_unit_exist_at_tile(nmap, punit, dst_tile)) {
|
||
/* Can't exist at the destination tile. */
|
||
return AR_BAD_DST_CITY;
|
||
}
|
||
}
|
||
punit_owner = unit_owner(punit);
|
||
... | ... | |
return AR_BAD_SRC_CITY;
|
||
}
|
||
if (pdest_city
|
||
if (nullptr != pdest_city
|
||
&& punit_owner != city_owner(pdest_city)
|
||
&& !(game.info.airlifting_style & AIRLIFTING_ALLIED_DEST
|
||
&& pplayers_allied(punit_owner, city_owner(pdest_city)))) {
|
||
&& (!(game.info.airlifting_style & AIRLIFTING_ALLIED_DEST
|
||
&& pplayers_allied(punit_owner, city_owner(pdest_city)))
|
||
|| is_non_allied_unit_tile(dst_tile, punit_owner,
|
||
unit_has_type_flag(punit, UTYF_FLAGLESS)))) {
|
||
/* Not allowed to airlift to this destination. */
|
||
return AR_BAD_DST_CITY;
|
||
}
|
||
if (NULL == restriction || city_owner(psrc_city) == restriction) {
|
||
/* We know for sure whether or not src can airlift this turn. */
|
||
if (0 >= psrc_city->airlift
|
||
&& (!(game.info.airlifting_style & AIRLIFTING_UNLIMITED_SRC)
|
||
|| !game.info.airlift_from_always_enabled)) {
|
||
/* The source cannot airlift for this turn (maybe already airlifted
|
||
* or no airport).
|
||
* See also do_airline() in server/unittools.h. */
|
||
return AR_SRC_NO_FLIGHTS;
|
||
} /* else, there is capacity; continue to other checks */
|
||
} else {
|
||
/* We don't have access to the 'airlift' field. Assume it's OK; can
|
||
* only find out for sure by trying it. */
|
||
ok_result = AR_OK_SRC_UNKNOWN;
|
||
/* Test airlift counters */
|
||
if (!game.info.airlift_from_always_enabled) {
|
||
if (nullptr == restriction || city_owner(psrc_city) == restriction) {
|
||
/* We know for sure whether or not src can airlift this turn. */
|
||
if (0 >= psrc_city->airlift
|
||
&& !(game.info.airlifting_style & AIRLIFTING_UNLIMITED_SRC)) {
|
||
/* The source cannot airlift for this turn (maybe already airlifted
|
||
* or no airport).
|
||
* See also do_airline() in server/unittools.h. */
|
||
return AR_SRC_NO_FLIGHTS;
|
||
} /* else, there is capacity; continue to other checks */
|
||
} else {
|
||
/* We don't have access to the 'airlift' field. Assume it's OK; can
|
||
* only find out for sure by trying it. */
|
||
ok_result = AR_OK_SRC_UNKNOWN;
|
||
}
|
||
}
|
||
if (pdest_city) {
|
||
if (NULL == restriction || city_owner(pdest_city) == restriction) {
|
||
if (nullptr != pdest_city && !game.info.airlift_to_always_enabled) {
|
||
if (nullptr == restriction || city_owner(pdest_city) == restriction) {
|
||
if (0 >= pdest_city->airlift
|
||
&& (!(game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)
|
||
|| !game.info.airlift_to_always_enabled)) {
|
||
&& !(game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)) {
|
||
/* The destination cannot support airlifted units for this turn
|
||
* (maybe already airlifted or no airport).
|
||
* See also do_airline() in server/unittools.h. */
|
server/unittools.c | ||
---|---|---|
/**********************************************************************//**
|
||
Moves a unit. No checks whatsoever! This is meant as a practical
|
||
function for other functions, like do_airline(), which do the checking
|
||
themselves.
|
||
either themselves or by their callers via is_action_possible()
|
||
If you move a unit you should always use this function, as it also sets
|
||
the transport status of the unit correctly. Note that the source tile (the
|