From 4ff2333c2359243cd662eda6c7a6aa7c3ebed343 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 23 Mar 2023 03:34:26 +0200 Subject: [PATCH 47/47] Make extra's unit hiding ability to depend unit, not extra owner Unit is visible within hiding extra if its owner is allied with the player watching it. See osdn #47655 Signed-off-by: Marko Lindqvist --- common/player.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/player.c b/common/player.c index a96444015f..1e398cc2a9 100644 --- a/common/player.c +++ b/common/player.c @@ -1018,17 +1018,18 @@ bool can_player_see_unit_at(const struct player *pplayer, bool is_transported) { struct city *pcity; + bool allied; /* If the player can't even see the tile... */ if (TILE_KNOWN_SEEN != tile_get_known(ptile, pplayer)) { return FALSE; } - /* Don't show non-allied units that are in transports. This is logical - * because allied transports can also contain our units. Shared vision + /* Don't show non-allied units that are in transports. This is logical + * because allied transports can also contain our units. Shared vision * isn't taken into account. */ - if (is_transported && unit_owner(punit) != pplayer - && !pplayers_allied(pplayer, unit_owner(punit))) { + allied = pplayers_allied(pplayer, unit_owner(punit)); + if (is_transported && !allied) { return FALSE; } @@ -1039,7 +1040,7 @@ bool can_player_see_unit_at(const struct player *pplayer, } /* Units within some extras may be hidden. */ - if (!pplayers_allied(pplayer, ptile->extras_owner)) { + if (!allied) { const struct unit_type *ptype = unit_type_get(punit); extra_type_list_iterate(extra_type_list_of_unit_hiders(), pextra) { @@ -1051,8 +1052,7 @@ bool can_player_see_unit_at(const struct player *pplayer, /* Allied or non-hiding units are always seen. * See also stealth unit hiding part in map_change_seen() */ - if (pplayers_allied(unit_owner(punit), pplayer) - || !is_hiding_unit(punit)) { + if (allied || !is_hiding_unit(punit)) { return TRUE; } -- 2.39.2