Index: server/gotohand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v retrieving revision 1.146 diff -u -r1.146 gotohand.c --- server/gotohand.c 2002/08/08 19:22:05 1.146 +++ server/gotohand.c 2002/08/13 23:09:07 @@ -1313,7 +1313,7 @@ /* This has the side effect of marking the warmap with the possible paths */ if (find_the_shortest_path(punit, waypoint_x, waypoint_y, restriction)) { do { /* move the unit along the path chosen by find_the_shortest_path() while we can */ - bool last_tile, is_real; + bool last_tile, is_real, success; struct unit *penemy = NULL; int dir; @@ -1338,19 +1338,22 @@ last_tile = same_pos(x, y, punit->goto_dest_x, punit->goto_dest_y); - /* Call handle_unit_ for humans; in the long run we want humans out */ - if ((!pplayer->ai.control - && !handle_unit_move_request(punit, x, y, FALSE, - !(last_tile && trigger_special_ability))) - || (pplayer->ai.control && !ai_unit_move(punit, x, y))) { - if (punit->moves_left > 0) { - punit->activity=ACTIVITY_IDLE; - send_unit_info(NULL, punit); - return GR_FAILED; - } - } + /* Call handle_unit_move_request for humans and ai_unit_move for AI */ + success = (!pplayer->ai.control + && !handle_unit_move_request(punit, x, y, FALSE, + !(last_tile && trigger_special_ability))) + || !ai_unit_move(punit, x, y); + if (!player_find_unit_by_id(pplayer, unit_id)) { return GR_DIED; /* unit died during goto! */ + } + + if (!success && punit->moves_left > 0) { + /* failure other than ran out of movement during an + attempt to utilize the rand() move feature */ + punit->activity=ACTIVITY_IDLE; + send_unit_info(NULL, punit); + return GR_FAILED; } /* Don't attack more than once per goto */