? diff Index: ai/advdomestic.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v retrieving revision 1.78 diff -u -r1.78 advdomestic.c --- ai/advdomestic.c 2002/02/11 13:55:44 1.78 +++ ai/advdomestic.c 2002/02/11 14:45:23 @@ -232,8 +232,8 @@ /* Count technologies which affect the pollution. */ if (! city_got_building(pcity, B_MASS) && impr_type != B_MASS) { pollution += - (player_knows_techs_with_flag(pplayer, TF_POPULATION_POLLUTION_INC) * - pcity->size) / 4; + (count_techs_with_flag_player_knows + (pplayer, TF_POPULATION_POLLUTION_INC) * pcity->size) / 4; } /* Heuristic? */ Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.166 diff -u -r1.166 aiunit.c --- ai/aiunit.c 2002/02/11 13:55:44 1.166 +++ ai/aiunit.c 2002/02/11 14:45:26 @@ -146,7 +146,7 @@ m += SINGLE_MOVE; if (player_owns_active_wonder(pplayer, B_MAGELLAN)) m += (improvement_variant(B_MAGELLAN)==1) ? SINGLE_MOVE : 2 * SINGLE_MOVE; - m += player_knows_techs_with_flag(pplayer,TF_BOAT_FAST) * SINGLE_MOVE; + m += count_techs_with_flag_player_knows(pplayer,TF_BOAT_FAST) * SINGLE_MOVE; } if (unit_type(punit)->move_type == LAND_MOVING) Index: common/city.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.c,v retrieving revision 1.137 diff -u -r1.137 city.c --- common/city.c 2002/02/11 13:55:49 1.137 +++ common/city.c 2002/02/11 14:45:28 @@ -1815,7 +1815,6 @@ **************************************************************************/ static void set_pollution(struct city *pcity) { - int poppul = 0; struct player *pplayer = city_owner(pcity); pcity->pollution = pcity->shield_prod; @@ -1827,11 +1826,9 @@ pcity->pollution /= 2; if (!city_got_building(pcity, B_MASS)) { - int mod = - player_knows_techs_with_flag(pplayer, TF_POPULATION_POLLUTION_INC); - /* was: A_INDUSTRIALIZATION, A_AUTOMOBILE, A_MASS, A_PLASTICS */ - poppul = (pcity->size * mod) / 4; - pcity->pollution += poppul; + pcity->pollution += (pcity->size * + count_techs_with_flag_player_knows + (pplayer, TF_POPULATION_POLLUTION_INC)) / 4; } pcity->pollution = MAX(0, pcity->pollution - 20); Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.78 diff -u -r1.78 player.c --- common/player.c 2002/02/11 11:59:54 1.78 +++ common/player.c 2002/02/11 14:45:28 @@ -333,16 +333,26 @@ flag. Needs to be optimized later (e.g. int tech_flags[TF_LAST] in struct player) **************************************************************************/ +int count_techs_with_flag_player_knows(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; +} + +/************************************************************************** + Returns TRUE iff the player knows at least one tech which has the + given flag. +**************************************************************************/ int player_knows_techs_with_flag(struct player *pplayer, enum tech_flag_id flag) { - int i; - int count=0; - for( i=A_FIRST; i 0; } /************************************************************************** Index: common/player.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.h,v retrieving revision 1.69 diff -u -r1.69 player.h --- common/player.h 2002/01/11 11:11:51 1.69 +++ common/player.h 2002/02/11 14:45:28 @@ -207,6 +207,8 @@ Impr_Type_id id); int player_knows_techs_with_flag(struct player *pplayer, enum tech_flag_id flag); +int count_techs_with_flag_player_knows(struct player *pplayer, + enum tech_flag_id flag); void player_limit_to_government_rates(struct player *pplayer); Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.143 diff -u -r1.143 unit.c --- common/unit.c 2002/02/11 13:55:50 1.143 +++ common/unit.c 2002/02/11 14:45:29 @@ -49,7 +49,7 @@ val+=SINGLE_MOVE; if(player_owns_active_wonder(pplayer, B_MAGELLAN)) val += (improvement_variant(B_MAGELLAN)==1) ? SINGLE_MOVE : 2 * SINGLE_MOVE; - val += player_knows_techs_with_flag(pplayer,TF_BOAT_FAST) * SINGLE_MOVE; + val += count_techs_with_flag_player_knows(pplayer, TF_BOAT_FAST) * SINGLE_MOVE; if (val < 2 * SINGLE_MOVE) val = 2 * SINGLE_MOVE; } Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.159 diff -u -r1.159 citytools.c --- server/citytools.c 2002/02/11 13:55:51 1.159 +++ server/citytools.c 2002/02/11 14:45:30 @@ -1684,8 +1684,10 @@ * one time bonus is not affected by factors in * trade_between_cities() */ - for(i=0;i