Index: aitools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v retrieving revision 1.50 diff -u -r1.50 aitools.c --- aitools.c 2002/04/09 14:14:12 1.50 +++ aitools.c 2002/07/20 12:56:32 @@ -41,6 +41,20 @@ */ /************************************************************************** + This function returns only when we have a reply from the server and + we can tell the calling function what happened to the move request. + (Right now is not a big problem, since we call the server directly.) +**************************************************************************/ +bool ai_unit_move(struct unit *punit, int x, int y) +{ + struct packet_unit_move_request pmove; + pmove->x = x; + pmove->y = y; + handle_move_unit(punit->owner, &pmove); + return (same_pos(x, y, punit->x, punit->y)); +} + +/************************************************************************** This looks for the nearest city: If (x,y) is the land, it looks for cities only on the same continent unless (everywhere != 0) Index: aitools.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aitools.h,v retrieving revision 1.19 diff -u -r1.19 aitools.h --- aitools.h 2002/04/12 13:50:54 1.19 +++ aitools.h 2002/07/20 12:56:32 @@ -20,6 +20,8 @@ struct government; struct player; +bool ai_unit_move(struct unit *punit, int x, int y); + struct city *dist_nearest_city(struct player *pplayer, int x, int y, bool everywhere, bool enemy); Index: aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.200 diff -u -r1.200 aiunit.c --- aiunit.c 2002/07/15 17:06:21 1.200 +++ aiunit.c 2002/07/20 12:56:33 @@ -416,7 +416,7 @@ /* Some tile have unexplored territory adjacent, let's move there. */ - if (!handle_unit_move_request(punit, best_x, best_y, FALSE, FALSE)) { + if (!ai_unit_move(punit, best_x, best_y)) { /* This shouldn't happen, but occassionally it can. */ break; } @@ -1108,7 +1108,7 @@ "Stationary escort @(%d,%d) received %d best @(%d,%d)", punit->x, punit->y, i, x, y); if (i >= 40 * SHIELD_WEIGHTING) - handle_unit_move_request(punit, x, y, FALSE, FALSE); + ai_unit_move(punit, x, y); /* otherwise don't bother, but free cities are free cities and must be snarfed. -- Syela */ } if (aunit && unit_list_find(&map_get_tile(x, y)->units, id) && aunit->ai.bodyguard != 0) @@ -1311,7 +1311,7 @@ "Bodyguard at (%d, %d) is adjacent to (%d, %d)", i, j, punit->x, punit->y); if (aunit->moves_left > 0) return(0); - else return handle_unit_move_request(punit, i, j, FALSE, FALSE) ? 1 : 0; + else return ai_unit_move(punit, i, j) ? 1 : 0; } } unit_list_iterate_end; } adjc_iterate_end; @@ -1524,7 +1524,7 @@ /* aggro defense goes here -- Syela */ ai_military_findvictim(pplayer, punit, &dest_x, &dest_y); punit->ai.ai_role=AIUNIT_NONE; - handle_unit_move_request(punit, dest_x, dest_y, FALSE, FALSE); + ai_unit_move(punit, dest_x, dest_y, FALSE, FALSE); /* might bash someone */ } else { freelog(LOG_DEBUG, "GOHOME(%d,%d)", @@ -1948,7 +1948,7 @@ freelog(LOG_DEBUG, "%s's %s at (%d, %d) bashing (%d, %d)", pplayer->name, unit_type(punit)->name, punit->x, punit->y, dest_x, dest_y); - handle_unit_move_request(punit, dest_x, dest_y, FALSE, FALSE); + ai_unit_move(punit, dest_x, dest_y); punit = find_unit_by_id(id); if (punit) flag = punit->moves_left > 0; else flag = FALSE; }