[Freeciv-Dev] PATCH: optimized ai/advdomestic.c
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Hi,
removed compiler warnings from ai/advdomestic.c:
/ai/advdomestic.c 135: dead assignment eliminated "poppul"
/ai/advdomestic.c 135: dead assignment eliminated "mod"
/ai/advdomestic.c 189: dead assignment eliminated "a"
/ai/advdomestic.c 300: possibly uninitialized variable "values"
/ai/advdomestic.c 365: possibly uninitialized variable "values"
/ai/advdomestic.c 370: possibly uninitialized variable "values"
/ai/advdomestic.c 375: possibly uninitialized variable "values"
/ai/advdomestic.c 542: dead assignment eliminated "set"
- complete variable values now initialized using memset.
- obsolete popul, mod removed
- obsolete a, set including obsolete function calls removed
- ai/aicity.h and ai/aicity.c surrounded city_get_settlers() by
#ifdef UNUSED
Ciao
____ _ _ ____ _ _ _ _ ____
| | | | | | \ / | | | the cool Gremlin from Bischofswerda
| __ | ____| | \/ | | | WWW: http://home.pages.de/~stoecker/
| | | | | | | | PGP key available on www page.
|____| _|_ |____| _|_ _|_ |____| I hope AMIGA never ends to make fun!
diff -ur ../../freeciv-cvs/freeciv/ai/advdomestic.c ./ai/advdomestic.c
--- ../../freeciv-cvs/freeciv/ai/advdomestic.c Wed Sep 20 08:56:44 2000
+++ ./ai/advdomestic.c Wed Sep 20 09:07:44 2000
@@ -132,7 +132,7 @@
static int pollution_cost(struct player *pplayer, struct city *pcity,
Impr_Type_id id)
{
- int p, mod = 0, poppul = 0, a, b, c, x, y, tmp = 0;
+ int p, a, b, c, x, y, tmp = 0;
p = 0;
city_map_iterate(x, y) {
if(get_worker_city(pcity, x, y)==C_TILE_WORKER) {
@@ -156,9 +156,8 @@
id == B_HYDRO || id == B_HOOVER || id == B_NUCLEAR) p /= 2;
if (!city_got_building(pcity, B_MASS) && id != B_MASS) {
- mod = player_knows_techs_with_flag(pplayer, TF_POPULATION_POLLUTION_INC);
- poppul=(pcity->size*mod)/4;
- p += poppul;
+ p += (player_knows_techs_with_flag(pplayer, TF_POPULATION_POLLUTION_INC)*
+ pcity->size)/4;
}
p -= 20;
if (p < 0) p = 0;
@@ -179,14 +178,13 @@
void ai_eval_buildings(struct city *pcity)
{
struct government *g = get_gov_pcity(pcity);
- int i, val, a, t, food, j, k, hunger, bar, grana;
+ int i, val, t, food, j, k, hunger, bar, grana;
int tax, prod, sci, values[B_LAST];
int est_food = pcity->food_surplus + 2 * pcity->ppl_scientist + 2 *
pcity->ppl_taxman;
struct player *pplayer = city_owner(pcity);
int needpower;
int wwtv = worst_worker_tile_value(pcity);
- a = get_nation_by_plr(city_owner(pcity))->attack;
t = pcity->ai.trade_want; /* trade_weighting */
sci = (pcity->trade_prod * pplayer->economic.science + 50) / 100;
tax = pcity->trade_prod - sci;
@@ -213,9 +211,7 @@
if (i > 0 && !pcity->ppl_scientist && !pcity->ppl_taxman) hunger = i + 1;
else hunger = 1;
- for (i=0;i<game.num_impr_types;i++) {
- values[i]=0;
- } /* rewrite by Syela - old values seemed very random */
+ memset(values, 0, sizeof(values)); /* clear to initialize */
if (could_build_improvement(pcity, B_AQUEDUCT)) {
int asz = game.aqueduct_size;
@@ -530,7 +526,7 @@
struct ai_choice *choice)
{
struct government *g = get_gov_pplayer(pplayer);
- int set, con, utid, want, iunit, dw;
+ int con, utid, want, iunit, dw;
struct ai_choice cur;
int est_food = pcity->food_surplus + 2 * pcity->ppl_scientist + 2 *
pcity->ppl_taxman;
int vans = 0;
@@ -539,7 +535,6 @@
choice->choice = 0;
choice->want = 0;
choice->type = 0;
- set = city_get_settlers(pcity);
con = map_get_continent(pcity->x, pcity->y);
utid = best_role_unit(pcity, F_SETTLERS);
diff -ur ../../freeciv-cvs/freeciv/ai/aicity.c ./ai/aicity.c
--- ../../freeciv-cvs/freeciv/ai/aicity.c Wed Sep 20 08:56:44 2000
+++ ./ai/aicity.c Wed Sep 20 09:11:52 2000
@@ -604,6 +604,7 @@
return def;
}
+#ifdef UNUSED
/**************************************************************************
...
**************************************************************************/
@@ -617,6 +618,7 @@
unit_list_iterate_end;
return set;
}
+#endif
#ifdef UNUSED
/**************************************************************************
diff -ur ../../freeciv-cvs/freeciv/ai/aicity.h ./ai/aicity.h
--- ../../freeciv-cvs/freeciv/ai/aicity.h Wed Sep 20 08:56:43 2000
+++ ./ai/aicity.h Wed Sep 20 09:11:36 2000
@@ -22,7 +22,9 @@
void ai_manage_cities(struct player *pplayer);
int city_get_buildings(struct city *pcity);
int city_get_defenders(struct city *pcity);
+#ifdef UNUSED
int city_get_settlers(struct city *pcity);
+#endif
void ai_choose_ferryboat(struct player *pplayer, struct city *pcity, struct
ai_choice *choice);
int ai_choose_defender_versus(struct city *pcity, int v);
int ai_choose_defender_limited(struct city *pcity, int n, enum unit_move_type
which);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] PATCH: optimized ai/advdomestic.c,
Dirk Stoecker <=
|
|