Index: ai/aicity.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v retrieving revision 1.101 diff -u -r1.101 aicity.c --- ai/aicity.c 2002/02/19 20:03:01 1.101 +++ ai/aicity.c 2002/02/27 21:36:36 @@ -595,22 +595,6 @@ return b; } -/************************************************************************** -... find a good (bad) tile to remove -**************************************************************************/ -static bool worst_elvis_tile(struct city *pcity, int x, int y, int bx, int by, - int foodneed, int prodneed) -{ - int a, b; - a = city_tile_value(pcity, x, y, - foodneed + city_get_food_tile(x, y, pcity), - prodneed + city_get_shields_tile(x, y, pcity)); - b = city_tile_value(pcity, bx, by, - foodneed + city_get_food_tile(bx, by, pcity), - prodneed + city_get_shields_tile(bx, by, pcity)); - return (a < b); -} - /************************************************************************** ... **************************************************************************/ @@ -840,8 +824,7 @@ static int ai_find_elvis_pos(struct city *pcity, int *xp, int *yp) { struct government *g = get_gov_pcity(pcity); - int foodneed, prodneed; - int luxneed, pwr, e; + int foodneed, prodneed, luxneed, pwr, e, worst_value = 0; foodneed=(pcity->size *2) + settler_eats(pcity); foodneed -= pcity->food_prod; /* much more robust now -- Syela */ @@ -868,14 +851,15 @@ if (is_city_center(x, y)) continue; if (get_worker_city(pcity, x, y) == C_TILE_WORKER) { - if (*xp==0 && *yp==0) { - *xp=x; - *yp=y; - } else { - if (worst_elvis_tile(pcity, x, y, *xp, *yp, foodneed, prodneed)) { - *xp=x; - *yp=y; - } + int value = city_tile_value(pcity, x, y, + foodneed + city_get_food_tile(x, y, pcity), + prodneed + city_get_shields_tile(x, y, + pcity)); + + if ((*xp == 0 && *yp == 0) || value < worst_value) { + *xp = x; + *yp = y; + worst_value = value; } } } city_map_iterate_end; Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.91 diff -u -r1.91 player.c --- common/player.c 2002/02/26 19:33:24 1.91 +++ common/player.c 2002/02/27 21:36:42 @@ -336,13 +336,7 @@ **************************************************************************/ int num_known_tech_with_flag(struct player *pplayer, enum tech_flag_id flag) { - int i, result = 0; - for (i = A_FIRST; i < game.num_tech_types; i++) { - if (get_invention(pplayer, i) == TECH_KNOWN && tech_flag(i, flag)) { - result++; - } - } - return result; + return pplayer->research.num_known_tech_with_flag[flag]; } /************************************************************************** Index: common/player.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.h,v retrieving revision 1.74 diff -u -r1.74 player.h --- common/player.h 2002/02/26 19:33:24 1.74 +++ common/player.h 2002/02/27 21:36:43 @@ -83,6 +83,11 @@ unsigned char required_techs[(A_LAST + 7) / 8]; int num_required_techs, bulbs_required; } inventions[A_LAST]; + + /* + * Cached values. Updated by update_research. + */ + int num_known_tech_with_flag[TF_LAST]; }; struct player_score { Index: common/tech.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v retrieving revision 1.45 diff -u -r1.45 tech.c --- common/tech.c 2002/02/26 16:58:13 1.45 +++ common/tech.c 2002/02/27 21:36:43 @@ -46,9 +46,8 @@ **************************************************************************/ enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech) { - if (!tech_exists(tech)) { - return TECH_UNKNOWN; - } + assert(tech >= 0 || tech < game.num_tech_types); + return pplayer->research.inventions[tech].state; } @@ -162,6 +161,7 @@ void update_research(struct player *pplayer) { Tech_Type_id i; + enum tech_flag_id flag; for (i = 0; i < game.num_tech_types; i++) { if (!tech_exists(i)) { @@ -178,6 +178,16 @@ } } build_required_techs(pplayer, i); + } + + for (flag = 0; flag < TF_LAST; flag++) { + pplayer->research.num_known_tech_with_flag[flag] = 0; + + for (i = A_FIRST; i < game.num_tech_types; i++) { + if (get_invention(pplayer, i) == TECH_KNOWN && tech_flag(i, flag)) { + pplayer->research.num_known_tech_with_flag[flag]++; + } + } } } Index: server/settlers.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v retrieving revision 1.132 diff -u -r1.132 settlers.c --- server/settlers.c 2002/02/27 11:12:53 1.132 +++ server/settlers.c 2002/02/27 21:36:45 @@ -646,12 +646,14 @@ int ii[12] = { -1, 0, 1, -1, 1, -1, 0, 1, 0, -2, 2, 0 }; int jj[12] = { -1, -1, -1, 0, 0, 1, 1, 1, -2, 0, 0, 2 }; struct tile *ptile; + bool is_border = IS_BORDER_MAP_POS(x, y, 2); + if (!normalize_map_pos(&x, &y)) return 0; for (k = 0; k < 12; k++) { int x1 = x + ii[k], y1 = y + jj[k]; - if (!normalize_map_pos(&x1, &y1)) { + if (is_border && !normalize_map_pos(&x1, &y1)) { rd[k] = FALSE; } else { ptile = map_get_tile(x1, y1);