From d3926a62b71c27c9282580c228d6b450c76fb0b8 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 31 May 2021 07:05:59 +0200 Subject: [PATCH] ANEK: paradrop blocked by non allied unit. Use the action not enabled system to explain that a visible unit at the target tile blocks a Paradrop Unit action. See osdn #42435 --- server/unithand.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/unithand.c b/server/unithand.c index 9b3f967a6c..9268a64795 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -861,6 +861,24 @@ static struct player *need_war_player(const struct unit *actor, } } +/************************************************************************** + Returns TRUE iff the specified tile has a unit seen by and not allied to + the specified player. +**************************************************************************/ +static bool +tile_has_units_not_allied_to_but_seen_by(const struct tile *ptile, + const struct player *pplayer) +{ + unit_list_iterate(ptile->units, pother) { + if (can_player_see_unit(pplayer, pother) + && !pplayers_allied(pplayer, unit_owner(pother))) { + return TRUE; + } + } unit_list_iterate_end; + + return FALSE; +} + /************************************************************************** Returns TRUE iff the specified terrain type blocks the specified action. @@ -1125,6 +1143,10 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit, } else if (action_id_has_result_safe(act_id, ACTION_FOUND_CITY) && tile_city(target_tile)) { explnat->kind = ANEK_BAD_TARGET; + } else if ((action_has_result_safe(paction, ACTION_PARADROP)) + && tile_has_units_not_allied_to_but_seen_by(target_tile, + act_player)) { + explnat->kind = ANEK_TGT_NON_ALLIED_UNITS_ON_TILE; } else if ((!can_exist && !utype_can_do_act_when_ustate(unit_type_get(punit), act_id, USP_LIVABLE_TILE, FALSE)) -- 2.30.2