diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/client/control.c diplbug/client/control.c --- freeciv/client/control.c Thu May 4 21:04:27 2000 +++ diplbug/client/control.c Thu May 4 22:00:02 2000 @@ -501,27 +501,41 @@ } /************************************************************************** -... - - No need to do caravan-specific stuff here any more: server does trade - routes to enemy cities automatically, and for friendly cities we wait - for the unit to enter the city. --dwp - - No need to do diplomat-specific stuff here any more: server notifies - client whenever diplomat attempts to enter enemy city. --jjm + This function is called whenever the player pressed an arrow key. + If punit is a diplomat trying to move to a tile with a unit we forward + it to popup_diplomat_dialog. + We do NOT take into account that punit might be a caravan or a diplomat + trying to move into a city; the server will handle those cases. **************************************************************************/ void request_move_unit_direction(struct unit *punit, int dx, int dy) { int dest_x, dest_y; struct unit req_unit; - dest_x=map_adjust_x(punit->x+dx); - dest_y=punit->y+dy; /* not adjusting on purpose*/ /* why? --dwp */ + dest_x = map_adjust_x(punit->x+dx); + dest_y = punit->y+dy; /* Not adjusted since if it needed to be adjusted it + would mean that we tried to move of the map... */ + + /* Catches attempts to move off map */ + if (!is_real_tile(dest_x, dest_y)) + return; + + if (unit_flag(punit->type, F_DIPLOMAT) + && !map_get_city(dest_x, dest_y) /* handled in the server */ + && is_diplomat_action_available(punit, DIPLOMAT_ANY_ACTION, + dest_x, dest_y)) { + if (diplomat_can_do_action(punit, DIPLOMAT_ANY_ACTION, dest_x, dest_y)) { + popup_diplomat_dialog(punit, dest_x, dest_y); + } else { + append_output_window(_("Game: You don't have enough movement left.")); + } + return; + } - req_unit=*punit; - req_unit.x=dest_x; - req_unit.y=dest_y; + req_unit = *punit; + req_unit.x = dest_x; + req_unit.y = dest_y; send_move_unit(&req_unit); }