Index: server/settlers.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v retrieving revision 1.154 diff -u -r1.154 settlers.c --- server/settlers.c 4 Dec 2002 13:34:27 -0000 1.154 +++ server/settlers.c 4 Dec 2002 14:12:18 -0000 @@ -52,8 +52,6 @@ static enemy_mask enemies[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS]; static void auto_settlers_player(struct player *pplayer); -static bool is_already_assigned(struct unit *myunit, struct player *pplayer, - int x, int y); static int city_desirability(struct player *pplayer, int x, int y); /************************************************************************** @@ -440,28 +438,6 @@ } /************************************************************************** - return 1 if there is already a unit on this square or one destined for it - (via goto) -**************************************************************************/ -static bool is_already_assigned(struct unit *myunit, struct player *pplayer, - int x, int y) -{ - if (same_pos(myunit->x, myunit->y, x, y) || - same_pos(myunit->goto_dest_x, myunit->goto_dest_y, x, y)) { -/* I'm still not sure this is exactly right -- Syela */ - unit_list_iterate(map_get_tile(x, y)->units, punit) - if (myunit==punit) continue; - if (!pplayers_allied(unit_owner(punit), pplayer)) - return TRUE; /* oops, tile is occupied! */ - if (unit_flag(punit, F_SETTLERS) && unit_flag(myunit, F_SETTLERS)) - return TRUE; - unit_list_iterate_end; - return FALSE; - } - return TEST_BIT(map_get_tile(x, y)->assigned, pplayer->player_no); -} - -/************************************************************************** Calculates the value of removing pollution. **************************************************************************/ static int ai_calc_pollution(struct city *pcity, int cx, int cy, int best, @@ -928,9 +904,10 @@ int near = real_map_distance(punit->x, punit->y, x, y); bool w_virtual = FALSE; /* I'm no entirely sure what this is --dwp */ int b, mv_cost, newv, moves = 0; + struct tile *ptile = map_get_tile(x, y); - if (!is_already_assigned(punit, pplayer, x, y) - && map_get_terrain(x, y) != T_OCEAN + if (!is_non_allied_unit_tile(ptile, pplayer) + && map_get_terrain(x, y) != T_OCEAN && !BV_CHECK_MASK(territory[x][y], my_enemies) /* pretty good, hope it's enough! -- Syela */ && (near < 8 || map_get_continent(x, y) != ucont) @@ -1069,6 +1046,8 @@ #endif /* try to work near the city */ city_map_checked_iterate(pcity->x, pcity->y, i, j, x, y) { + struct tile *ptile = map_get_tile(x, y); + if (get_worker_city(pcity, i, j) == C_TILE_UNAVAILABLE) continue; in_use = (get_worker_city(pcity, i, j) == C_TILE_WORKER); @@ -1076,10 +1055,7 @@ && warmap.cost[x][y] <= THRESHOLD * mv_rate && !BV_CHECK_MASK(territory[x][y], my_enemies) /* pretty good, hope it's enough! -- Syela */ - && !is_already_assigned(punit, pplayer, x, y)) { - /* calling is_already_assigned once instead of four times - for obvious reasons; structure is much the same as it once - was but subroutines are not -- Syela */ + && !is_non_allied_unit_tile(ptile, pplayer)) { int time; mv_turns = (warmap.cost[x][y]) / mv_rate; oldv = city_tile_value(pcity, i, j, 0, 0);