Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.95 diff -u -r1.95 player.c --- common/player.c 2002/05/23 15:09:27 1.95 +++ common/player.c 2002/05/30 17:20:46 @@ -231,29 +231,31 @@ } /*************************************************************** -no map visibility check here! + Returns TRUE iff the player can see the unit. No map visibility + check here! Allied units and cities can be used for sub hunting. ***************************************************************/ bool player_can_see_unit(struct player *pplayer, struct unit *punit) { - if (pplayers_allied(unit_owner(punit), pplayer)) + if (pplayers_allied(unit_owner(punit), pplayer) + || !is_hiding_unit(punit)) { return TRUE; - if (is_hiding_unit(punit)) { - /* Search for units/cities that might be able to see the sub/missile */ - struct city *pcity; - square_iterate(punit->x, punit->y, 1, x, y) { - unit_list_iterate(map_get_tile(x, y)->units, punit2) { - if (pplayers_allied(unit_owner(punit2), pplayer)) - return TRUE; - } unit_list_iterate_end; + } - pcity = map_get_city(x, y); - if (pcity && (pplayers_allied(city_owner(pcity), pplayer))) + /* Search for units/cities that might be able to see the sub/missile */ + adjc_iterate(punit->x, punit->y, x1, y1) { + struct city *pcity = map_get_city(x1, y1); + unit_list_iterate(map_get_tile(x1, y1)->units, punit2) { + if (pplayers_allied(unit_owner(punit2), pplayer)) { return TRUE; - } square_iterate_end; - return FALSE; - } else { - return TRUE; - } + } + } unit_list_iterate_end; + + if (pcity && pplayers_allied(city_owner(pcity), pplayer)) { + return TRUE; + } + } adjc_iterate_end; + + return FALSE; } /*************************************************************** Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.159 diff -u -r1.159 unit.c --- common/unit.c 2002/05/28 22:08:49 1.159 +++ common/unit.c 2002/05/30 17:20:47 @@ -392,25 +392,16 @@ /************************************************************************** - Is the unit one that is invisible on the map, which is currently limited - to subs and missiles in subs. - FIXME: this should be made more general: does not handle cargo units - on an invisible transport, or planes on invisible carrier. + Is the unit one that is invisible on the map. A unit is invisible if + it has the F_PARTIAL_INVIS flag or if it transported by a unit with + this flag. **************************************************************************/ bool is_hiding_unit(struct unit *punit) { - if(unit_flag(punit, F_PARTIAL_INVIS)) return TRUE; - if(unit_flag(punit, F_MISSILE)) { - if(map_get_terrain(punit->x, punit->y)==T_OCEAN) { - unit_list_iterate(map_get_tile(punit->x, punit->y)->units, punit2) { - if(unit_flag(punit2, F_PARTIAL_INVIS) - && unit_flag(punit2, F_MISSILE_CARRIER)) { - return TRUE; - } - } unit_list_iterate_end; - } - } - return FALSE; + struct unit *transporter = find_unit_by_id(punit->transported_by); + + return (unit_flag(punit, F_PARTIAL_INVIS) + || (transporter && unit_flag(transporter, F_PARTIAL_INVIS))); } /************************************************************************** Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.177 diff -u -r1.177 unittools.c --- server/unittools.c 2002/05/28 22:08:49 1.177 +++ server/unittools.c 2002/05/30 17:20:50 @@ -2012,9 +2012,9 @@ conn_list_iterate(*dest, pconn) { struct player *pplayer = pconn->player; if (!pplayer && !pconn->observer) continue; - if (!pplayer - || map_get_known_and_seen(info.x, info.y, pplayer) - || map_get_known_and_seen(x, y, pplayer)) { + if (!pplayer || ((map_get_known_and_seen(info.x, info.y, pplayer) + || map_get_known_and_seen(x, y, pplayer)) + && player_can_see_unit(pplayer, punit))) { send_packet_unit_info(pconn, &info); } }