diff client/packhand.c client/packhand.c --- client/packhand.c Tue Jan 23 19:39:19 2001 +++ client/packhand.c Tue Jan 23 20:05:17 2001 @@ -1031,6 +1031,20 @@ punit = fc_malloc(sizeof(struct unit)); unpackage_enemy_unit(punit, packet); + + /* Put previously unknown unit into tile it is coming from. + This way we can move it smoothly into known territory and even + player can see where it's coming from. -- Caz */ + if (packet->prev_x < map.xsize && + !player_find_unit_by_id(&game.players[punit->owner], punit->id)) { + punit->x = packet->prev_x; + punit->y = packet->prev_y; + handle_unit_packet_common(punit, packet->carried, 0); + + punit = fc_malloc(sizeof(struct unit)); + unpackage_enemy_unit(punit, packet); + } + handle_unit_packet_common(punit, packet->carried, 0); } diff common/packets.c common/packets.c --- common/packets.c Tue Jan 23 19:39:20 2001 +++ common/packets.c Tue Jan 23 19:24:34 2001 @@ -2256,6 +2256,8 @@ cptr=put_uint8(cptr, req->type); cptr=put_uint8(cptr, req->hp); cptr=put_uint8(cptr, req->activity); + cptr=put_uint8(cptr, req->prev_x); + cptr=put_uint8(cptr, req->prev_y); pack=(req->carried ? 0x08 : 0); cptr=put_uint8(cptr, pack); @@ -2288,6 +2290,8 @@ iget_uint8(&iter, &packet->type); iget_uint8(&iter, &packet->hp); iget_uint8(&iter, &packet->activity); + iget_uint8(&iter, &packet->prev_x); + iget_uint8(&iter, &packet->prev_y); iget_uint8(&iter, &pack); packet->carried = (pack&0x08) ? 1 : 0; diff common/packets.h common/packets.h --- common/packets.h Tue Jan 23 19:39:20 2001 +++ common/packets.h Tue Jan 23 19:24:34 2001 @@ -336,6 +336,9 @@ and UNIT_INFO_CITY_PRESENT uses */ int serial_num; /* a 16-bit unsigned number, never zero (not used by UNIT_INFO_IDENTITY) */ + + int prev_x; + int prev_y; }; diff server/diplomats.c server/diplomats.c --- server/diplomats.c Tue Jan 23 19:39:20 2001 +++ server/diplomats.c Tue Jan 23 19:35:18 2001 @@ -156,14 +156,14 @@ As this is a special case we bypass send_unit_info. */ first_packet = TRUE; unit_list_iterate(pcity->units_supported, punit) { - package_enemy_unit(punit, &unit_packet, FALSE, - UNIT_INFO_CITY_SUPPORTED, pcity->id, first_packet); + package_enemy_unit(punit, &unit_packet, FALSE, UNIT_INFO_CITY_SUPPORTED, + pcity->id, first_packet, -1, -1); lsend_packet_enemy_unit(&pplayer->connections, &unit_packet); first_packet = FALSE; } unit_list_iterate_end; unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, punit) { - package_enemy_unit(punit, &unit_packet, FALSE, - UNIT_INFO_CITY_PRESENT, pcity->id, first_packet); + package_enemy_unit(punit, &unit_packet, FALSE, UNIT_INFO_CITY_PRESENT, + pcity->id, first_packet, -1, -1); lsend_packet_enemy_unit(&pplayer->connections, &unit_packet); first_packet = FALSE; } unit_list_iterate_end; diff server/unithand.c server/unithand.c --- server/unithand.c Tue Jan 23 19:39:20 2001 +++ server/unithand.c Tue Jan 23 19:47:36 2001 @@ -1513,7 +1513,8 @@ **************************************************************************/ void package_enemy_unit(struct unit *punit, struct packet_enemy_unit *packet, int carried, enum unit_info_use packet_use, - int info_city_id, int new_serial_num) + int info_city_id, int new_serial_num, int prev_x, + int prev_y) { static unsigned int serial_num = 0; @@ -1541,6 +1542,14 @@ packet->activity = ACTIVITY_IDLE; packet->carried = carried; + + if (prev_x >= 0 && is_tiles_adjacent(prev_x, prev_y, punit->x, punit->y)) { + packet->prev_x = prev_x; + packet->prev_y = prev_y; + } else { + packet->prev_x = map.xsize; + packet->prev_y = map.ysize; + } } /************************************************************************** diff server/unithand.h server/unithand.h --- server/unithand.h Tue Jan 23 19:39:20 2001 +++ server/unithand.h Tue Jan 23 19:31:49 2001 @@ -65,7 +65,8 @@ void package_enemy_unit(struct unit *punit, struct packet_enemy_unit *packet, int carried, enum unit_info_use packet_use, - int info_city_id, int new_serial_num); + int info_city_id, int new_serial_num, int prev_x, + int prev_y); void handle_goto_route(struct player *pplayer, struct packet_goto_route *packet); void handle_patrol_route(struct player *pplayer, struct packet_goto_route *packet); diff server/unittools.c server/unittools.c --- server/unittools.c Tue Jan 23 19:39:20 2001 +++ server/unittools.c Tue Jan 23 19:36:44 2001 @@ -2290,7 +2290,7 @@ if (dest==NULL) dest = &game.game_connections; package_unit(punit, &info, carried, select_it); - package_enemy_unit(punit, &einfo, carried, UNIT_INFO_IDENTITY, 0, 0); + package_enemy_unit(punit, &einfo, carried, UNIT_INFO_IDENTITY, 0, 0, x, y); conn_list_iterate(*dest, pconn) { struct player *pplayer = pconn->player; @@ -2299,10 +2299,11 @@ || map_get_known_and_seen(info.x, info.y, pplayer->player_no) || map_get_known_and_seen(x, y, pplayer->player_no)) { if ((pplayer && pplayer->player_no == punit->owner) || - (!pplayer && pconn->observer)) + (!pplayer && pconn->observer)) { send_packet_unit_info(pconn, &info); - else + } else { send_packet_enemy_unit(pconn, &einfo); + } } } conn_list_iterate_end;