Index: ai/aicity.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v retrieving revision 1.89 diff -u -r1.89 aicity.c --- ai/aicity.c 2001/09/30 21:27:01 1.89 +++ ai/aicity.c 2001/10/01 10:51:17 @@ -854,7 +854,7 @@ *xp = 0; *yp = 0; city_map_iterate(x, y) { - if (x==2 && y==2) + if (is_city_center(x, y)) continue; if (get_worker_city(pcity, x, y) == C_TILE_WORKER) { if (*xp==0 && *yp==0) { Index: client/gui-gtk/mapview.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v retrieving revision 1.101 diff -u -r1.101 mapview.c --- client/gui-gtk/mapview.c 2001/09/30 21:55:31 1.101 +++ client/gui-gtk/mapview.c 2001/10/01 10:51:22 @@ -1814,7 +1814,7 @@ get_canvas_xy(x, y, &canvas_x, &canvas_y); /* stipple the area */ - if (!(i == 2 && j == 2)) { + if (!is_city_center(i, j)) { if (worked == C_TILE_EMPTY) { gdk_gc_set_stipple(fill_tile_gc, gray25); } else if (worked == C_TILE_WORKER) { Index: client/gui-mui/mapclass.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapclass.c,v retrieving revision 1.65 diff -u -r1.65 mapclass.c --- client/gui-mui/mapclass.c 2001/09/30 21:55:32 1.65 +++ client/gui-mui/mapclass.c 2001/10/01 10:51:24 @@ -1216,7 +1216,7 @@ { enum city_tile_type t = get_worker_city(pcity, i, j); - if (!(i==2 && j==2)) + if (!is_city_center(i, j)) { int pix_x = (x + i - 2) * get_normal_tile_width() + _mleft(o); int pix_y = (y + j - 2) * get_normal_tile_height() + _mtop(o); Index: client/gui-xaw/mapview.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v retrieving revision 1.82 diff -u -r1.82 mapview.c --- client/gui-xaw/mapview.c 2001/09/30 21:55:33 1.82 +++ client/gui-xaw/mapview.c 2001/10/01 10:51:25 @@ -1178,7 +1178,7 @@ enum city_tile_type worked = get_worker_city(pcity, i, j); get_canvas_xy(x, y, &canvas_x, &canvas_y); - if (!(i == 2 && j == 2)) { + if (!is_city_center(i, j)) { if (worked == C_TILE_EMPTY) { XSetStipple(display, fill_tile_gc, gray25); } else if (worked == C_TILE_WORKER) { Index: common/city.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.c,v retrieving revision 1.124 diff -u -r1.124 city.c --- common/city.c 2001/09/30 21:27:07 1.124 +++ common/city.c 2001/10/01 10:51:26 @@ -93,6 +93,14 @@ } /************************************************************************** +... +**************************************************************************/ +int is_city_center(int city_x, int city_y) +{ + return (city_x == CITY_MAP_SIZE / 2) && (city_y == CITY_MAP_SIZE / 2); +} + +/************************************************************************** Finds the city map coordinate for a given map position and a city center. Returns whether the map position is inside of the city map. **************************************************************************/ @@ -558,7 +566,7 @@ if (spec_t & S_FALLOUT) s-=(s*terrain_control.fallout_shield_penalty)/100; - if (sirrigation_result + city_auto_water = (is_city_center(x, y) + && tile_t == type->irrigation_result && terrain_control.may_irrigate); if (spec_t & S_SPECIAL_1) @@ -753,7 +762,7 @@ if (spec_t & S_FALLOUT) f-=(f*terrain_control.fallout_food_penalty)/100; - if (fworker_x==2 && preq->worker_y==2) { + if (is_city_center(preq->worker_x, preq->worker_y)) { auto_arrange_workers(pcity); sync_cities(); return; @@ -150,7 +150,7 @@ if (!pcity) return; - if (preq->worker_x==CITY_MAP_SIZE/2 && preq->worker_y==CITY_MAP_SIZE/2) { + if (is_city_center(preq->worker_x, preq->worker_y)) { auto_arrange_workers(pcity); sync_cities(); return; Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.144 diff -u -r1.144 citytools.c --- server/citytools.c 2001/09/30 21:27:09 1.144 +++ server/citytools.c 2001/10/01 10:51:30 @@ -202,7 +202,9 @@ { int worst = 0, tmp; city_map_iterate(x, y) { - if ((x != 2 || y != 2) && get_worker_city(pcity, x, y) == C_TILE_WORKER) { + if (is_city_center(x, y)) + continue; + if (get_worker_city(pcity, x, y) == C_TILE_WORKER) { tmp = city_tile_value(pcity, x, y, 0, 0); if (tmp < worst || !worst) worst = tmp; } @@ -217,7 +219,7 @@ { int best = 0, tmp; city_map_iterate(x, y) { - if ((x == 2 && y == 2) || + if (is_city_center(x, y) || (get_worker_city(pcity, x, y) == C_TILE_WORKER) || can_place_worker_here(pcity, x, y)) { tmp = city_tile_value(pcity, x, y, 0, 0); @@ -1688,7 +1690,7 @@ ptile = map_get_tile(map_x, map_y); if (is_enemy_unit_tile(ptile, city_owner(pcity)) - && (city_x != CITY_MAP_SIZE/2 || city_y != CITY_MAP_SIZE/2)) + && !is_city_center(city_x, city_y)) return 0; if (!map_get_known(map_x, map_y, city_owner(pcity))) Index: server/cityturn.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v retrieving revision 1.164 diff -u -r1.164 cityturn.c --- server/cityturn.c 2001/09/25 19:58:14 1.164 +++ server/cityturn.c 2001/10/01 10:51:31 @@ -268,8 +268,8 @@ int foodneed, prodneed; city_map_iterate(x, y) { - if (get_worker_city(pcity, x, y)==C_TILE_WORKER - && (x != CITY_MAP_SIZE/2 || y != CITY_MAP_SIZE/2)) + if (get_worker_city(pcity, x, y) == C_TILE_WORKER + && !is_city_center(x, y)) server_remove_worker_city(pcity, x, y); } city_map_iterate_end; @@ -1100,17 +1100,19 @@ **************************************************************************/ static void check_pollution(struct city *pcity) { - int x,y; int k=100; if (pcity->pollution && myrand(100)<=pcity->pollution) { while (k) { /* place pollution somewhere in city radius */ - x=myrand(5)-2; - y=myrand(5)-2; - if ( ( x != -2 && x != 2 ) || ( y != -2 && y != 2 ) ) { - x = pcity->x + x; - y = pcity->y + y; - nearest_real_pos(&x, &y); + int cx = myrand(CITY_MAP_SIZE); + int cy = myrand(CITY_MAP_SIZE); + + if (is_valid_city_coords(cx, cy)) { + int x, y; + + if (!city_map_to_map(&x, &y, pcity, cx, cy)) { + nearest_real_pos(&x, &y); + } if ( (map_get_terrain(x,y)!=T_OCEAN && map_get_terrain(x,y)<=T_TUNDRA) && (!(map_get_special(x,y)&S_POLLUTION)) ) { map_set_special(x,y, S_POLLUTION); Index: server/settlers.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v retrieving revision 1.110 diff -u -r1.110 settlers.c --- server/settlers.c 2001/09/30 22:03:43 1.110 +++ server/settlers.c 2001/10/01 10:51:34 @@ -221,17 +221,22 @@ con2 = ptile->continent; ptype = get_tile_type(ptile->terrain); food[i][j] = (get_tile_food_base(ptile) - 2) * MORT; - if (i == 2 && j == 2) food[i][j] += 2 * MORT; + if (is_city_center(i, j)) { + food[i][j] += 2 * MORT; + } if (ptype->irrigation_result == ptile->terrain && con2 == con) { - if (ptile->special&S_IRRIGATION || (i == 2 && j == 2)) + if (ptile->special & S_IRRIGATION || is_city_center(i, j)) { irrig[i][j] = MORT * ptype->irrigation_food_incr; + } else if (is_water_adjacent_to_tile(map_x, map_y) && ptile->terrain != T_HILLS) irrig[i][j] = MORT * ptype->irrigation_food_incr - 9; /* KLUGE */ /* all of these kluges are hardcoded amortize calls to save much CPU use -- Syela */ } else if (ptile->terrain == T_OCEAN && har) food[i][j] += MORT; /* harbor */ shield[i][j] = get_tile_shield_base(ptile) * sh; - if (i == 2 && j == 2 && !shield[i][j]) shield[i][j] = sh; + if (is_city_center(i, j) && !shield[i][j]) { + shield[i][j] = sh; + } if (ptile->terrain == T_OCEAN && har) shield[i][j] += sh; /* above line is not sufficiently tested. AI was building on shores, but not as far out in the ocean as possible, which limits growth in the very long @@ -244,8 +249,9 @@ mine[i][j] = sh * ptype->mining_shield_incr - 300; /* KLUGE */ trade[i][j] = get_tile_trade_base(ptile) * t; if (ptype->road_trade_incr > 0) { - if (ptile->special&S_ROAD || (i == 2 && j == 2)) + if (ptile->special & S_ROAD || is_city_center(i, j)) { road[i][j] = t * ptype->road_trade_incr; + } else if (con2 == con) road[i][j] = t * ptype->road_trade_incr - 70; /* KLUGE */ /* actualy exactly 70 1/2 */ } @@ -262,7 +268,11 @@ cur = (food[i][j]) * food_weighting(n) + /* ignoring irrig on purpose */ (shield[i][j] + mine[i][j]) + (trade[i][j] + road[i][j]); - if (cur > best && (i != 2 || j != 2)) { best = cur; ii = i; jj = j; } + if (cur > best && !is_city_center(i, j)) { + best = cur; + ii = i; + jj = j; + } } city_map_iterate_end; if (!best) return(0); val = (shield[ii][jj] + mine[ii][jj]) + @@ -302,12 +312,20 @@ cur = (food[i][j]) * food_weighting(n) + /* ignoring irrig on purpose */ (shield[i][j] + mine[i][j]) + (trade[i][j] + road[i][j]); - if (!taken[i][j]) { - if (cur > best) { b2 = best; best = cur; ii = i; jj = j; } - else if (cur > b2) b2 = cur; - } else if (i != 2 || j != 2) { - if (cur < worst || worst < 0) { worst = cur; i0 = i; j0 = j; } - } + if (!taken[i][j]) { + if (cur > best) { + b2 = best; + best = cur; + ii = i; + jj = j; + } else if (cur > b2) { + b2 = cur; + } + } else if (!is_city_center(i, j) && (cur < worst || worst < 0)) { + worst = cur; + i0 = i; + j0 = j; + } } city_map_iterate_end; if (!best) break; cur = amortize((shield[ii][jj] + mine[ii][jj]) +