? auto.rc ? saves ? ttt ? ttt.gz ? ttt1 ? ttt2 ? ttt3 Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.254 diff -u -r1.254 packhand.c --- client/packhand.c 2002/09/11 17:04:39 1.254 +++ client/packhand.c 2002/09/12 12:20:29 @@ -34,6 +34,7 @@ #include "mem.h" #include "nation.h" #include "packets.h" +#include "player.h" #include "spaceship.h" #include "support.h" #include "unit.h" @@ -896,7 +897,9 @@ struct city *pcity; pcity=map_get_city(punit->x, punit->y); - if(tile_get_known(packet->x, packet->y) == TILE_KNOWN) { + if(tile_get_known(packet->x, packet->y) == TILE_KNOWN + && player_can_see_unit_at_location(game.player_ptr, punit, + packet->x, packet->y)) { do_move_unit(punit, packet); update_unit_focus(); } Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.99 diff -u -r1.99 player.c --- common/player.c 2002/08/07 11:21:47 1.99 +++ common/player.c 2002/09/12 12:20:29 @@ -233,10 +233,15 @@ } /*************************************************************** - Returns TRUE iff the player can see the unit. No map visibility - check here! Allied units and cities can be used for sub hunting. + Returns TRUE iff the player can see the unit at (x,y), i.e. if + the unit is not invisible or if it is adjacent to one of our + cities or units. No map visibility check here! The unit does + not have to be at (x,y)! + Allied units and cities can be used for sub hunting. ***************************************************************/ -bool player_can_see_unit(struct player *pplayer, struct unit *punit) +bool player_can_see_unit_at_location(struct player *pplayer, + struct unit *punit, + int x, int y) { if (pplayers_allied(unit_owner(punit), pplayer) || !is_hiding_unit(punit)) { @@ -244,7 +249,7 @@ } /* Search for units/cities that might be able to see the sub/missile */ - adjc_iterate(punit->x, punit->y, x1, y1) { + adjc_iterate(x, 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)) { @@ -258,6 +263,14 @@ } adjc_iterate_end; return FALSE; +} + +/*************************************************************** + Same thing as above only the location is the unit's current one. +***************************************************************/ +bool player_can_see_unit(struct player *pplayer, struct unit *punit) +{ + return player_can_see_unit_at_location(pplayer, punit, punit->x, punit->y); } /*************************************************************** Index: common/player.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.h,v retrieving revision 1.81 diff -u -r1.81 player.h --- common/player.h 2002/08/25 11:36:52 1.81 +++ common/player.h 2002/09/12 12:20:29 @@ -213,6 +213,10 @@ bool player_has_embassy(struct player *pplayer, struct player *pplayer2); bool player_can_see_unit(struct player *pplayer, struct unit *punit); +bool player_can_see_unit_at_location(struct player *pplayer, + struct unit *punit, + int x, int y); + bool player_owns_city(struct player *pplayer, struct city *pcity); struct city *player_find_city_by_id(struct player *pplayer, int city_id); Index: server/maphand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v retrieving revision 1.106 diff -u -r1.106 maphand.c --- server/maphand.c 2002/08/19 20:53:36 1.106 +++ server/maphand.c 2002/09/12 12:20:30 @@ -25,6 +25,7 @@ #include "packets.h" #include "rand.h" #include "support.h" +#include "unit.h" #include "citytools.h" #include "cityturn.h" @@ -451,6 +452,22 @@ pseen--; } } square_iterate_end; +} + +/************************************************************************* + * Checks for hidden units around (x,y). Such units can be invisible even + * on a KNOWN_AND_SEEN tile, so unfogging might not reveal them. + ************************************************************************/ +void reveal_hidden_units(struct player *pplayer, int x, int y) +{ + adjc_iterate(x, y, x1, y1) { + unit_list_iterate(map_get_tile(x1, y1)->units, punit) { + if (is_hiding_unit(punit)) { + /* send_unit_info will check whether it is visible */ + send_unit_info(pplayer, punit); + } + } unit_list_iterate_end; + } adjc_iterate_end; } /************************************************************************** Index: server/maphand.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/maphand.h,v retrieving revision 1.28 diff -u -r1.28 maphand.h --- server/maphand.h 2002/02/27 10:06:41 1.28 +++ server/maphand.h 2002/09/12 12:20:30 @@ -50,6 +50,7 @@ struct player *pfrom, struct player *pdest); void send_all_known_tiles(struct conn_list *dest); void send_tile_info(struct conn_list *dest, int x, int y); +void reveal_hidden_units(struct player *pplayer, int x, int y); void unfog_area(struct player *pplayer, int x, int y, int len); void fog_area(struct player *pplayer, int x, int y, int len); void upgrade_city_rails(struct player *pplayer, bool discovery); Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.181 diff -u -r1.181 unittools.c --- server/unittools.c 2002/08/31 02:24:34 1.181 +++ server/unittools.c 2002/09/12 12:20:30 @@ -2032,9 +2032,11 @@ 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)) - && player_can_see_unit(pplayer, punit))) { + 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) + || player_can_see_unit_at_location(pplayer, punit, x, y)))) { send_packet_unit_info(pconn, &info); } } @@ -3027,6 +3029,11 @@ set_unit_activity(punit, ACTIVITY_SENTRY); } send_unit_info_to_onlookers(NULL, punit, src_x, src_y, FALSE, FALSE); + + /* The hidden units might not have been previously revealed + * because when we did the unfogging, the unit was still + * at (src_x, src_y) */ + reveal_hidden_units(pplayer, dest_x, dest_y); if (unit_profits_of_watchtower(punit) && tile_has_special(psrctile, S_FORTRESS))