|
Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
July 2004: [Freeciv-Dev] (PR#9311) accessors for city output values |
|
[Freeciv-Dev] (PR#9311) accessors for city output values[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9311 > I'd like to wrap the city output values with wrapper macros. This allows the underlying field names to change without touching lots and lots of code. E.g., instead of "pcity->shield_surplus" we would have "shield_surplus(pcity)". The (large) attached patch does this. The results can be duplicated with the other (city.h) patch and by running the convert.sh script. jason Index: common/city.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.h,v retrieving revision 1.150 diff -u -r1.150 city.h --- common/city.h 7 Jul 2004 07:26:04 -0000 1.150 +++ common/city.h 8 Jul 2004 04:32:29 -0000 @@ -344,6 +344,27 @@ /* properties */ +#define food_prod(pcity) (pcity->food_prod) +#define shield_prod(pcity) (pcity->shield_prod) +#define trade_prod(pcity) (pcity->trade_prod) +#define luxury_prod(pcity) (pcity->luxury_total) +#define science_prod(pcity) (pcity->tax_total) +#define gold_prod(pcity) (pcity->science_total) + +#define food_surplus(pcity) (pcity->food_surplus) +#define shield_surplus(pcity) (pcity->shield_surplus) +#define trade_surplus(pcity) (pcity->trade_surplus) +#define pollution(pcity) (pcity->pollution) + +#define shield_waste(pcity) (pcity->shield_waste) +#define trade_waste(pcity) (pcity->corruption) + +#define shield_stock(pcity) (pcity->shield_stock) +#define food_stock(pcity) (pcity->food_stock) + +#define shield_bonus(pcity) (pcity->shield_bonus) +#define science_bonus(pcity) (pcity->science_bonus) +#define gold_bonus(pcity) (pcity->tax_bonus) struct player *city_owner(const struct city *pcity); int city_population(const struct city *pcity);
? diff
? data/tridenthex
? data/tridenthex.tilespec
Index: ai/advdomestic.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v
retrieving revision 1.111
diff -u -r1.111 advdomestic.c
--- ai/advdomestic.c 25 Jun 2004 23:43:00 -0000 1.111
+++ ai/advdomestic.c 8 Jul 2004 04:32:13 -0000
@@ -376,13 +376,13 @@
/* Base is cost of actual pollution. */
- if (pcity->pollution > 0) {
- int amortized = amortize(weight, 100 / pcity->pollution);
+ if (pollution(pcity) > 0) {
+ int amortized = amortize(weight, 100 / pollution(pcity));
cost = ((amortized * weight) / (MAX(1, weight - amortized))) / 64;
freelog(LOG_DEBUG, "City: %s, Pollu: %d, cost: %d, Id: %d, P: %d",
- pcity->name, pcity->pollution, cost, impr_type, pollution);
+ pcity->name, pollution(pcity), cost, impr_type, pollution);
}
/* Subtract cost of future pollution. */
@@ -413,13 +413,13 @@
/* --- initialize control parameters --- */
t = pcity->ai.trade_want; /* trade_weighting */
- sci = (pcity->trade_prod * pplayer->economic.science + 50) / 100;
- tax = pcity->trade_prod - sci;
+ sci = (trade_prod(pcity) * pplayer->economic.science + 50) / 100;
+ tax = trade_prod(pcity) - sci;
/* better might be a longterm weighted average, this is a quick-n-dirty fix
-- Syela */
- sci = ((sci + pcity->trade_prod) * t)/2;
- tax = ((tax + pcity->trade_prod) * t)/2;
+ sci = ((sci + trade_prod(pcity)) * t)/2;
+ tax = ((tax + trade_prod(pcity)) * t)/2;
/* don't need libraries!! */
if (ai_wants_no_science(pplayer)) {
sci = 0;
@@ -427,9 +427,9 @@
est_food = (2 * pcity->specialists[SP_SCIENTIST]
+ 2 * pcity->specialists[SP_TAXMAN]
- + pcity->food_surplus);
+ + food_surplus(pcity));
prod =
- (pcity->shield_prod * SHIELD_WEIGHTING * 100) / city_shield_bonus(pcity);
+ (shield_prod(pcity) * SHIELD_WEIGHTING * 100) / city_shield_bonus(pcity);
needpower = (city_got_building(pcity, B_MFG) ? 2 :
(city_got_building(pcity, B_FACTORY) ? 1 : 0));
val = ai_best_tile_value(pcity);
@@ -443,7 +443,7 @@
food = food_weighting(grana);
grana = food_weighting(grana + 1);
hunger = 1;
- j = (pcity->size * 2) + settler_eats(pcity) - pcity->food_prod;
+ j = (pcity->size * 2) + settler_eats(pcity) - food_prod(pcity);
if (j >= 0
&& pcity->specialists[SP_SCIENTIST] <= 0
&& pcity->specialists[SP_TAXMAN] <= 0) {
@@ -457,7 +457,7 @@
j = 0; k = 0, tprod = 0;
city_list_iterate(pplayer->cities, acity) {
k++;
- tprod += acity->shield_prod;
+ tprod += shield_prod(acity);
if (acity->is_building_unit) {
if (!unit_type_flag(acity->currently_building, F_NONMIL)
&& unit_types[acity->currently_building].move_type == LAND_MOVING)
@@ -499,7 +499,7 @@
* j = num_pop_rollover * biggest_granary_size - current_food */
j = (k+1) - MIN(k, pcity->size);
j *= city_granary_size(MAX(k, pcity->size));
- j-= pcity->food_stock;
+ j-= food_stock(pcity);
/* value = some odd factors / food_required */
j = (k+1) * food * est_food * game.foodbox / MAX(1, j);
@@ -509,7 +509,7 @@
case B_GRANARY:
if (improvement_variant(B_PYRAMIDS) != 0
|| !built_elsewhere(pcity, B_PYRAMIDS))
- values[id] = grana * pcity->food_surplus;
+ values[id] = grana * food_surplus(pcity);
break;
case B_HARBOUR:
values[id] = ocean_workers(pcity) * food * hunger;
@@ -564,7 +564,7 @@
} else {
/* The use of TRADE_WEIGHTING here is deliberate, since
* t is corruption modified. */
- values[id] = (pcity->corruption * TRADE_WEIGHTING) / 2;
+ values[id] = (trade_waste(pcity) * TRADE_WEIGHTING) / 2;
}
break;
@@ -776,7 +776,7 @@
if (improvement_variant(B_PYRAMIDS)==0
&& !city_got_building(pcity, B_GRANARY)) {
/* different tech req's */
- values[id] = food * pcity->food_surplus;
+ values[id] = food * food_surplus(pcity);
}
break;
case B_SETI:
@@ -880,7 +880,7 @@
city_list_iterate(pplayer->cities, acity) {
if (acity->is_building_unit
&& unit_type_flag(acity->currently_building, F_HELP_WONDER)
- && (acity->shield_stock
+ && (shield_stock(acity)
>= unit_build_shield_cost(acity->currently_building))
&& map_get_continent(acity->x, acity->y) == continent) {
caravans++;
@@ -955,7 +955,7 @@
Unit_Type_id unit_type;
/* Food surplus assuming that workers and elvii are already accounted for
* and properly balanced. */
- int est_food = pcity->food_surplus
+ int est_food = food_surplus(pcity)
+ 2 * pcity->specialists[SP_SCIENTIST]
+ 2 * pcity->specialists[SP_TAXMAN];
Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.169
diff -u -r1.169 advmilitary.c
--- ai/advmilitary.c 25 Jun 2004 23:43:00 -0000 1.169
+++ ai/advmilitary.c 8 Jul 2004 04:32:13 -0000
@@ -654,7 +654,7 @@
if ((desire > best ||
(desire == best && unit_build_shield_cost(unit_type) <=
unit_build_shield_cost(best_unit_type)))
- && unit_build_shield_cost(unit_type) <= pcity->shield_stock + 40) {
+ && unit_build_shield_cost(unit_type) <= shield_stock(pcity) + 40) {
best = desire;
best_unit_type = unit_type;
}
@@ -1158,7 +1158,7 @@
case HELI_MOVING:
case AIR_MOVING:
if (player_knows_improvement_tech(pplayer, B_AIRPORT)
- && pcity->shield_surplus > impr_build_shield_cost(B_AIRPORT) / 10) {
+ && shield_surplus(pcity) > impr_build_shield_cost(B_AIRPORT) / 10) {
/* Only build this if we have really high production */
choice->choice = B_AIRPORT;
choice->type = CT_BUILDING;
@@ -1214,21 +1214,21 @@
} else {
danger = 100 * pcity->ai.danger / our_def;
}
- if (pcity->shield_surplus <= 0 && our_def != 0) {
+ if (shield_surplus(pcity) <= 0 && our_def != 0) {
/* Won't be able to support anything */
danger = 0;
}
/* FIXME: 1. Will tend to build walls beofre coastal irrespectfully what
* type of danger we are facing
- * 2. (80 - pcity->shield_stock) * 2 below is hardcoded price of walls */
+ * 2. (80 - shield_stock(pcity)) * 2 below is hardcoded price of walls */
/* We will build walls if we can and want and (have "enough" defenders or
* can just buy the walls straight away) */
if (pcity->ai.building_want[B_CITY] != 0 && our_def != 0
&& can_build_improvement(pcity, B_CITY)
&& (danger < 101 || num_defenders > 1
|| (pcity->ai.grave_danger == 0
- && pplayer->economic.gold > (80 - pcity->shield_stock) * 2))
+ && pplayer->economic.gold > (80 - shield_stock(pcity)) * 2))
&& ai_fuzzy(pplayer, TRUE)) {
/* NB: great wall is under domestic */
choice->choice = B_CITY;
@@ -1282,7 +1282,7 @@
}
} /* ok, don't need to defend */
- if (pcity->shield_surplus <= 0
+ if (shield_surplus(pcity) <= 0
|| pcity->ppl_unhappy[4] > pcity->ppl_unhappy[2]) {
/* Things we consider below are not life-saving so we don't want to
* build them if our populace doesn't feel like it */
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.157
diff -u -r1.157 aicity.c
--- ai/aicity.c 7 Jul 2004 07:32:02 -0000 1.157
+++ ai/aicity.c 8 Jul 2004 04:32:13 -0000
@@ -52,8 +52,8 @@
#include "aicity.h"
#define CITY_EMERGENCY(pcity) \
- (pcity->shield_surplus < 0 || city_unhappy(pcity) \
- || pcity->food_stock + pcity->food_surplus < 0)
+ (shield_surplus(pcity) < 0 || city_unhappy(pcity) \
+ || food_stock(pcity) + food_surplus(pcity) < 0)
#define LOG_BUY LOG_DEBUG
static void resolve_city_emergency(struct player *pplayer, struct city *pcity);
@@ -66,17 +66,17 @@
**************************************************************************/
int ai_eval_calc_city(struct city *pcity, struct ai_data *ai)
{
- int i = (pcity->food_surplus * ai->food_priority
- + pcity->shield_surplus * ai->shield_priority
- + pcity->luxury_total * ai->luxury_priority
- + pcity->tax_total * ai->gold_priority
- + pcity->science_total * ai->science_priority
+ int i = (food_surplus(pcity) * ai->food_priority
+ + shield_surplus(pcity) * ai->shield_priority
+ + luxury_prod(pcity) * ai->luxury_priority
+ + gold_prod(pcity) * ai->gold_priority
+ + science_prod(pcity) * ai->science_priority
+ pcity->ppl_happy[4] * ai->happy_priority
- pcity->ppl_unhappy[4] * ai->unhappy_priority
- pcity->ppl_angry[4] * ai->angry_priority
- - pcity->pollution * ai->pollution_priority);
+ - pollution(pcity) * ai->pollution_priority);
- if (pcity->food_surplus < 0 || pcity->shield_surplus < 0) {
+ if (food_surplus(pcity) < 0 || shield_surplus(pcity) < 0) {
/* The city is unmaintainable, it can't be good */
i = MIN(i, 0);
}
@@ -100,7 +100,7 @@
if (find_palace(pplayer) || g->corruption_level == 0) palace = TRUE;
city_list_iterate(pplayer->cities, pcity)
ai_eval_buildings(pcity);
- if (!palace) corr += pcity->corruption * 8;
+ if (!palace) corr += trade_waste(pcity) * 8;
impr_type_iterate(i) {
if (pcity->ai.building_want[i] > 0) values[i] +=
pcity->ai.building_want[i];
} impr_type_iterate_end;
@@ -164,7 +164,7 @@
if (!pcity->is_building_unit && is_wonder(i) &&
is_wonder(pcity->currently_building))
/* this should encourage completion of wonders, I hope! -- Syela */
- pcity->ai.building_want[i] += pcity->shield_stock / 2;
+ pcity->ai.building_want[i] += shield_stock(pcity) / 2;
} impr_type_iterate_end;
city_list_iterate_end;
}
@@ -490,7 +490,7 @@
if (!city_got_effect(pcity, B_GRANARY)
&& pcity->size == 1
&& city_granary_size(pcity->size)
- > pcity->food_stock + pcity->food_surplus) {
+ > food_stock(pcity) + food_surplus(pcity)) {
/* Don't buy settlers in size 1 cities unless we grow next turn */
continue;
} else if (city_list_size(&pplayer->cities) > 6) {
@@ -507,7 +507,7 @@
}
/* It costs x2 to buy something with no shields contributed */
- expensive = (pcity->shield_stock == 0)
+ expensive = (shield_stock(pcity) == 0)
|| (pplayer->economic.gold - buycost < limit);
if (bestchoice.type == CT_ATTACKER
@@ -682,7 +682,7 @@
"Emergency in %s (%s, angry%d, unhap%d food%d, prod%d)",
pcity->name, city_unhappy(pcity) ? "unhappy" : "content",
pcity->ppl_angry[4], pcity->ppl_unhappy[4],
- pcity->food_surplus, pcity->shield_surplus);
+ food_surplus(pcity), shield_surplus(pcity));
city_list_init(&minilist);
map_city_radius_iterate(pcity->x, pcity->y, x, y) {
Index: ai/aidata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidata.c,v
retrieving revision 1.29
diff -u -r1.29 aidata.c
--- ai/aidata.c 25 Jun 2004 23:43:00 -0000 1.29
+++ ai/aidata.c 8 Jul 2004 04:32:13 -0000
@@ -192,7 +192,7 @@
ai->stats.average_production = 0;
city_list_iterate(pplayer->cities, pcity) {
ai->stats.cities[(int)map_get_continent(pcity->x, pcity->y)]++;
- ai->stats.average_production += pcity->shield_surplus;
+ ai->stats.average_production += shield_surplus(pcity);
} city_list_iterate_end;
ai->stats.average_production /= MAX(1, city_list_size(&pplayer->cities));
BV_CLR_ALL(ai->stats.diplomat_reservations);
Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.36
diff -u -r1.36 aidiplomat.c
--- ai/aidiplomat.c 25 Jun 2004 23:43:00 -0000 1.36
+++ ai/aidiplomat.c 8 Jul 2004 04:32:14 -0000
@@ -181,11 +181,11 @@
pplayer->economic.gold - pplayer->ai.est_upkeep)) {
/* incite gain (FIXME: we should count wonders too but need to
cache that somehow to avoid CPU hog -- Per) */
- gain_incite = acity->food_prod * FOOD_WEIGHTING
- + acity->shield_prod * SHIELD_WEIGHTING
- + (acity->luxury_total
- + acity->tax_total
- + acity->science_total) * TRADE_WEIGHTING;
+ gain_incite = food_prod(acity) * FOOD_WEIGHTING
+ + shield_prod(acity) * SHIELD_WEIGHTING
+ + (luxury_prod(acity)
+ + gold_prod(acity)
+ + science_prod(acity)) * TRADE_WEIGHTING;
gain_incite *= SHIELD_WEIGHTING; /* WAG cost to take city otherwise */
gain_incite -= incite_cost * TRADE_WEIGHTING;
}
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.89
diff -u -r1.89 aihand.c
--- ai/aihand.c 7 Jul 2004 07:32:03 -0000 1.89
+++ ai/aihand.c 8 Jul 2004 04:32:14 -0000
@@ -168,7 +168,7 @@
total_cities++;
if (cmr.found_a_valid
- && pcity->food_surplus > 0
+ && food_surplus(pcity) > 0
&& pcity->size >= g->rapture_size
&& (pcity->size < game.aqueduct_size
|| city_got_building(pcity, B_AQUEDUCT))
Index: ai/aihunt.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihunt.c,v
retrieving revision 1.6
diff -u -r1.6 aihunt.c
--- ai/aihunt.c 25 Jun 2004 23:43:01 -0000 1.6
+++ ai/aihunt.c 8 Jul 2004 04:32:14 -0000
@@ -103,7 +103,7 @@
desire /= 2;
}
- desire = amortize(desire, ut->build_cost / MAX(pcity->shield_surplus, 1));
+ desire = amortize(desire, ut->build_cost / MAX(shield_surplus(pcity), 1));
if (desire > best) {
best = desire;
@@ -160,7 +160,7 @@
desire /= 2;
}
- desire = amortize(desire, ut->build_cost / MAX(pcity->shield_surplus, 1));
+ desire = amortize(desire, ut->build_cost / MAX(shield_surplus(pcity), 1));
if (desire > best) {
best = desire;
Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.114
diff -u -r1.114 aitools.c
--- ai/aitools.c 7 Jul 2004 07:32:03 -0000 1.114
+++ ai/aitools.c 8 Jul 2004 04:32:14 -0000
@@ -63,7 +63,7 @@
int value, int delay, int build_cost)
{
struct ai_data *ai = ai_data_get(pplayer);
- int city_output = (pcity ? pcity->shield_surplus : 1);
+ int city_output = (pcity ? shield_surplus(pcity) : 1);
int output = MAX(city_output, ai->stats.average_production);
int build_time = build_cost / MAX(output, 1);
@@ -405,8 +405,8 @@
the greater good -- Per */
return FALSE;
}
- if (pcity->shield_surplus - unit_type(punit)->shield_cost >= 0
- && pcity->food_surplus - unit_type(punit)->food_cost >= 0) {
+ if (shield_surplus(pcity) - unit_type(punit)->shield_cost >= 0
+ && food_surplus(pcity) - unit_type(punit)->food_cost >= 0) {
handle_unit_change_homecity(unit_owner(punit), punit->id, pcity->id);
return TRUE;
}
@@ -713,7 +713,7 @@
impr_type_iterate(i) {
if (!is_wonder(i)
|| (!pcity->is_building_unit && is_wonder(pcity->currently_building)
- && pcity->shield_stock >= impr_build_shield_cost(i) / 2)
+ && shield_stock(pcity) >= impr_build_shield_cost(i) / 2)
|| (!is_building_other_wonder(pcity)
/* otherwise caravans will be killed! */
&& pcity->ai.grave_danger == 0
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.321
diff -u -r1.321 aiunit.c
--- ai/aiunit.c 25 Jun 2004 23:43:01 -0000 1.321
+++ ai/aiunit.c 8 Jul 2004 04:32:15 -0000
@@ -2199,7 +2199,7 @@
if ((pcity = wonder_on_continent(pplayer,
map_get_continent(punit->x, punit->y)))
&& unit_flag(punit, F_HELP_WONDER)
- && build_points_left(pcity) > (pcity->shield_surplus * 2)) {
+ && build_points_left(pcity) > (shield_surplus(pcity) * 2)) {
if (!same_pos(pcity->x, pcity->y, punit->x, punit->y)) {
if (punit->moves_left == 0) {
return;
Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.39
diff -u -r1.39 citydlg_common.c
--- client/citydlg_common.c 25 Jun 2004 23:35:55 -0000 1.39
+++ client/citydlg_common.c 8 Jul 2004 04:32:15 -0000
@@ -231,7 +231,7 @@
turns = city_turns_to_build(pcity, pcity->currently_building,
pcity->is_building_unit, TRUE);
- stock = pcity->shield_stock;
+ stock = shield_stock(pcity);
if (pcity->is_building_unit) {
cost = unit_build_shield_cost(pcity->currently_building);
@@ -241,7 +241,7 @@
if (!pcity->is_building_unit && pcity->currently_building == B_CAPITAL) {
my_snprintf(buffer, buffer_len, _("%3d gold per turn"),
- MAX(0, pcity->shield_surplus));
+ MAX(0, shield_surplus(pcity)));
} else {
char time[50];
@@ -282,7 +282,7 @@
{
if (!is_unit && id == B_CAPITAL) {
my_snprintf(buffer, buffer_len, _("%s (XX) %d/turn"),
- get_impr_name_ex(pcity, id), MAX(0, pcity->shield_surplus));
+ get_impr_name_ex(pcity, id), MAX(0, shield_surplus(pcity)));
} else {
int turns = city_turns_to_build(pcity, id, is_unit, TRUE);
const char *name;
@@ -366,7 +366,7 @@
if (pcity) {
if (!is_unit && id == B_CAPITAL) {
my_snprintf(buf[3], column_size, _("%d/turn"),
- MAX(0, pcity->shield_surplus));
+ MAX(0, shield_surplus(pcity)));
} else {
int turns = city_turns_to_build(pcity, id, is_unit, FALSE);
if (turns < 999) {
Index: client/cityrepdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrepdata.c,v
retrieving revision 1.33
diff -u -r1.33 cityrepdata.c
--- client/cityrepdata.c 27 May 2004 22:14:18 -0000 1.33
+++ client/cityrepdata.c 8 Jul 2004 04:32:15 -0000
@@ -239,9 +239,9 @@
{
static char buf[32];
my_snprintf(buf, sizeof(buf), "%d/%d/%d",
- pcity->food_surplus,
- pcity->shield_surplus,
- pcity->trade_prod);
+ food_surplus(pcity),
+ shield_surplus(pcity),
+ trade_prod(pcity));
return buf;
}
@@ -249,7 +249,7 @@
{
static char buf[8];
my_snprintf(buf, sizeof(buf), "%3d",
- pcity->food_surplus);
+ food_surplus(pcity));
return buf;
}
@@ -257,7 +257,7 @@
{
static char buf[8];
my_snprintf(buf, sizeof(buf), "%3d",
- pcity->shield_surplus);
+ shield_surplus(pcity));
return buf;
}
@@ -265,7 +265,7 @@
{
static char buf[8];
my_snprintf(buf, sizeof(buf), "%3d",
- pcity->trade_prod);
+ trade_prod(pcity));
return buf;
}
@@ -278,8 +278,8 @@
my_snprintf(buf, sizeof(buf), "%s%d/%d/%d",
(goldie < 0) ? "-" : (goldie > 0) ? "+" : "",
(goldie < 0) ? (-goldie) : goldie,
- pcity->luxury_total,
- pcity->science_total);
+ luxury_prod(pcity),
+ science_prod(pcity));
return buf;
}
@@ -299,7 +299,7 @@
{
static char buf[8];
my_snprintf(buf, sizeof(buf), "%3d",
- pcity->luxury_total);
+ luxury_prod(pcity));
return buf;
}
@@ -307,7 +307,7 @@
{
static char buf[8];
my_snprintf(buf, sizeof(buf), "%3d",
- pcity->science_total);
+ science_prod(pcity));
return buf;
}
@@ -315,7 +315,7 @@
{
static char buf[32];
my_snprintf(buf, sizeof(buf), "%d/%d",
- pcity->food_stock,
+ food_stock(pcity),
city_granary_size(pcity->size) );
return buf;
}
@@ -337,7 +337,7 @@
static char *cr_entry_pollution(struct city *pcity)
{
static char buf[8];
- my_snprintf(buf, sizeof(buf), "%3d", pcity->pollution);
+ my_snprintf(buf, sizeof(buf), "%3d", pollution(pcity));
return buf;
}
@@ -358,7 +358,7 @@
if (!pcity->is_building_unit && pcity->currently_building == B_CAPITAL) {
my_snprintf(buf, sizeof(buf), "%s (%d/X/X/X)%s",
get_impr_name_ex(pcity, pcity->currently_building),
- MAX(0, pcity->shield_surplus), from_worklist);
+ MAX(0, shield_surplus(pcity)), from_worklist);
} else {
int turns = city_turns_to_build(pcity, pcity->currently_building,
pcity->is_building_unit, TRUE);
@@ -381,7 +381,7 @@
}
my_snprintf(buf, sizeof(buf), "%s (%d/%d/%s/%d)%s", name,
- pcity->shield_stock, cost, time, city_buy_cost(pcity),
+ shield_stock(pcity), cost, time, city_buy_cost(pcity),
from_worklist);
}
@@ -391,14 +391,14 @@
static char *cr_entry_corruption(struct city *pcity)
{
static char buf[8];
- my_snprintf(buf, sizeof(buf), "%3d", pcity->corruption);
+ my_snprintf(buf, sizeof(buf), "%3d", trade_waste(pcity));
return buf;
}
static char *cr_entry_waste(struct city *pcity)
{
static char buf[8];
- my_snprintf(buf, sizeof(buf), "%3d", pcity->shield_waste);
+ my_snprintf(buf, sizeof(buf), "%3d", shield_waste(pcity));
return buf;
}
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.383
diff -u -r1.383 packhand.c
--- client/packhand.c 7 Jul 2004 16:02:50 -0000 1.383
+++ client/packhand.c 8 Jul 2004 04:32:16 -0000
@@ -406,12 +406,12 @@
} else if (draw_city_productions &&
(pcity->is_building_unit != packet->is_building_unit ||
pcity->currently_building != packet->currently_building ||
- pcity->shield_surplus != packet->shield_surplus ||
- pcity->shield_stock != packet->shield_stock)) {
+ shield_surplus(pcity) != packet->shield_surplus ||
+ shield_stock(pcity) != packet->shield_stock)) {
update_descriptions = TRUE;
} else if (draw_city_names && draw_city_growth &&
- (pcity->food_stock != packet->food_stock ||
- pcity->food_surplus != packet->food_surplus)) {
+ (food_stock(pcity) != packet->food_stock ||
+ food_surplus(pcity) != packet->food_surplus)) {
/* If either the food stock or surplus have changed, the time-to-grow
is likely to have changed as well. */
update_descriptions = TRUE;
@@ -442,22 +442,22 @@
pcity->trade_value[i]=packet->trade_value[i];
}
- pcity->food_prod=packet->food_prod;
- pcity->food_surplus=packet->food_surplus;
- pcity->shield_prod=packet->shield_prod;
- pcity->shield_surplus=packet->shield_surplus;
- pcity->trade_prod=packet->trade_prod;
+ food_prod(pcity)=packet->food_prod;
+ food_surplus(pcity)=packet->food_surplus;
+ shield_prod(pcity)=packet->shield_prod;
+ shield_surplus(pcity)=packet->shield_surplus;
+ trade_prod(pcity)=packet->trade_prod;
pcity->tile_trade=packet->tile_trade;
- pcity->corruption=packet->corruption;
- pcity->shield_waste=packet->shield_waste;
+ trade_waste(pcity)=packet->corruption;
+ shield_waste(pcity)=packet->shield_waste;
- pcity->luxury_total=packet->luxury_total;
- pcity->tax_total=packet->tax_total;
- pcity->science_total=packet->science_total;
-
- pcity->food_stock=packet->food_stock;
- pcity->shield_stock=packet->shield_stock;
- pcity->pollution=packet->pollution;
+ luxury_prod(pcity)=packet->luxury_total;
+ gold_prod(pcity)=packet->tax_total;
+ science_prod(pcity)=packet->science_total;
+
+ food_stock(pcity)=packet->food_stock;
+ shield_stock(pcity)=packet->shield_stock;
+ pollution(pcity)=packet->pollution;
pcity->is_building_unit=packet->is_building_unit;
pcity->currently_building=packet->currently_building;
@@ -711,18 +711,18 @@
pcity->trade[i] = 0;
pcity->trade_value[i] = 0;
}
- pcity->food_prod = 0;
- pcity->food_surplus = 0;
- pcity->shield_prod = 0;
- pcity->shield_surplus = 0;
- pcity->trade_prod = 0;
- pcity->corruption = 0;
- pcity->luxury_total = 0;
- pcity->tax_total = 0;
- pcity->science_total = 0;
- pcity->food_stock = 0;
- pcity->shield_stock = 0;
- pcity->pollution = 0;
+ food_prod(pcity) = 0;
+ food_surplus(pcity) = 0;
+ shield_prod(pcity) = 0;
+ shield_surplus(pcity) = 0;
+ trade_prod(pcity) = 0;
+ trade_waste(pcity) = 0;
+ luxury_prod(pcity) = 0;
+ gold_prod(pcity) = 0;
+ science_prod(pcity) = 0;
+ food_stock(pcity) = 0;
+ shield_stock(pcity) = 0;
+ pollution(pcity) = 0;
pcity->city_options = 0;
pcity->is_building_unit = FALSE;
pcity->currently_building = 0;
Index: client/repodlgs_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/repodlgs_common.c,v
retrieving revision 1.10
diff -u -r1.10 repodlgs_common.c
--- client/repodlgs_common.c 25 Jun 2004 23:35:55 -0000 1.10
+++ client/repodlgs_common.c 8 Jul 2004 04:32:16 -0000
@@ -76,9 +76,9 @@
*total_income = 0;
city_list_iterate(game.player_ptr->cities, pcity) {
- *total_income += pcity->tax_total;
+ *total_income += gold_prod(pcity);
if (!pcity->is_building_unit && pcity->currently_building == B_CAPITAL) {
- *total_income += MAX(0, pcity->shield_surplus);
+ *total_income += MAX(0, shield_surplus(pcity));
}
} city_list_iterate_end;
}
Index: client/text.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.c,v
retrieving revision 1.5
diff -u -r1.5 text.c
--- client/text.c 25 Jun 2004 23:35:55 -0000 1.5
+++ client/text.c 8 Jul 2004 04:32:17 -0000
@@ -399,7 +399,7 @@
if (plr == pplayer) {
city_list_iterate(pplayer->cities, pcity) {
- ours += pcity->science_total;
+ ours += science_prod(pcity);
} city_list_iterate_end;
} else if (ds == DS_TEAM) {
theirs += pplayer->research.bulbs_last_turn;
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.53
diff -u -r1.53 cma_core.c
--- client/agents/cma_core.c 29 May 2004 20:34:31 -0000 1.53
+++ client/agents/cma_core.c 8 Jul 2004 04:32:17 -0000
@@ -169,16 +169,16 @@
} my_city_map_iterate_end;
freelog(LOG_NORMAL, " food = %3d (%+3d)",
- pcity->food_prod, pcity->food_surplus);
+ food_prod(pcity), food_surplus(pcity));
freelog(LOG_NORMAL, " shield = %3d (%+3d)",
- pcity->shield_prod + pcity->shield_waste, pcity->shield_prod);
+ shield_prod(pcity) + shield_waste(pcity), shield_prod(pcity));
freelog(LOG_NORMAL, " trade = %3d (%+3d)",
- pcity->trade_prod + pcity->corruption, pcity->trade_prod);
+ trade_prod(pcity) + trade_waste(pcity), trade_prod(pcity));
- freelog(LOG_NORMAL, " gold = %3d (%+3d)", pcity->tax_total,
+ freelog(LOG_NORMAL, " gold = %3d (%+3d)", gold_prod(pcity),
city_gold_surplus(pcity));
- freelog(LOG_NORMAL, " luxury = %3d", pcity->luxury_total);
- freelog(LOG_NORMAL, " science = %3d", pcity->science_total);
+ freelog(LOG_NORMAL, " luxury = %3d", luxury_prod(pcity));
+ freelog(LOG_NORMAL, " science = %3d", science_prod(pcity));
}
/****************************************************************************
@@ -242,17 +242,17 @@
*****************************************************************************/
static void copy_stats(struct city *pcity, struct cm_result *result)
{
- result->production[FOOD] = pcity->food_prod;
- result->production[SHIELD] = pcity->shield_prod + pcity->shield_waste;
- result->production[TRADE] = pcity->trade_prod + pcity->corruption;
-
- result->surplus[FOOD] = pcity->food_surplus;
- result->surplus[SHIELD] = pcity->shield_surplus;
- result->surplus[TRADE] = pcity->trade_prod;
-
- result->production[GOLD] = pcity->tax_total;
- result->production[LUXURY] = pcity->luxury_total;
- result->production[SCIENCE] = pcity->science_total;
+ result->production[FOOD] = food_prod(pcity);
+ result->production[SHIELD] = shield_prod(pcity) + shield_waste(pcity);
+ result->production[TRADE] = trade_prod(pcity) + trade_waste(pcity);
+
+ result->surplus[FOOD] = food_surplus(pcity);
+ result->surplus[SHIELD] = shield_surplus(pcity);
+ result->surplus[TRADE] = trade_prod(pcity);
+
+ result->production[GOLD] = gold_prod(pcity);
+ result->production[LUXURY] = luxury_prod(pcity);
+ result->production[SCIENCE] = science_prod(pcity);
result->surplus[GOLD] = city_gold_surplus(pcity);
result->surplus[LUXURY] = result->production[LUXURY];
Index: client/agents/cma_fec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v
retrieving revision 1.20
diff -u -r1.20 cma_fec.c
--- client/agents/cma_fec.c 29 May 2004 20:34:31 -0000 1.20
+++ client/agents/cma_fec.c 8 Jul 2004 04:32:17 -0000
@@ -264,7 +264,7 @@
return buffer;
}
- stock = pcity->food_stock;
+ stock = food_stock(pcity);
cost = city_granary_size(pcity->size);
stock += surplus;
@@ -298,7 +298,7 @@
return buffer;
}
- stock = pcity->shield_stock;
+ stock = shield_stock(pcity);
if (pcity->is_building_unit) {
cost = unit_build_shield_cost(pcity->currently_building);
} else {
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.183
diff -u -r1.183 citydlg.c
--- client/gui-gtk/citydlg.c 5 May 2004 20:39:15 -0000 1.183
+++ client/gui-gtk/citydlg.c 8 Jul 2004 04:32:17 -0000
@@ -1689,22 +1689,22 @@
/* fill the buffers with the necessary info */
my_snprintf(buf[FOOD], sizeof(buf[FOOD]), "%2d (%+2d)",
- pcity->food_prod, pcity->food_surplus);
+ food_prod(pcity), food_surplus(pcity));
my_snprintf(buf[SHIELD], sizeof(buf[SHIELD]), "%2d (%+2d)",
- pcity->shield_prod + pcity->shield_waste,
- pcity->shield_surplus);
+ shield_prod(pcity) + shield_waste(pcity),
+ shield_surplus(pcity));
my_snprintf(buf[TRADE], sizeof(buf[TRADE]), "%2d (%+2d)",
- pcity->trade_prod + pcity->corruption, pcity->trade_prod);
+ trade_prod(pcity) + trade_waste(pcity), trade_prod(pcity));
my_snprintf(buf[GOLD], sizeof(buf[GOLD]), "%2d (%+2d)",
- pcity->tax_total, city_gold_surplus(pcity));
+ gold_prod(pcity), city_gold_surplus(pcity));
my_snprintf(buf[LUXURY], sizeof(buf[LUXURY]), "%2d ",
- pcity->luxury_total);
+ luxury_prod(pcity));
my_snprintf(buf[SCIENCE], sizeof(buf[SCIENCE]), "%2d",
- pcity->science_total);
+ science_prod(pcity));
my_snprintf(buf[GRANARY], sizeof(buf[GRANARY]), "%d/%-d",
- pcity->food_stock, city_granary_size(pcity->size));
+ food_stock(pcity), city_granary_size(pcity->size));
granaryturns = city_turns_to_grow(pcity);
if (granaryturns == 0) {
@@ -1720,11 +1720,11 @@
}
my_snprintf(buf[CORRUPTION], sizeof(buf[CORRUPTION]), "%2d",
- pcity->corruption);
+ trade_waste(pcity));
my_snprintf(buf[WASTE], sizeof(buf[WASTE]), "%2d",
- pcity->shield_waste);
+ shield_waste(pcity));
my_snprintf(buf[POLLUTION], sizeof(buf[POLLUTION]), "%2d",
- pcity->pollution);
+ pollution(pcity));
/* stick 'em in the labels */
@@ -1739,13 +1739,13 @@
style = (granaryturns > -4 && granaryturns < 0) ? RED : NORMAL;
gtk_widget_modify_style(info_label[GRANARY], info_label_style[style]);
- style = (granaryturns == 0 || pcity->food_surplus < 0) ? RED : NORMAL;
+ style = (granaryturns == 0 || food_surplus(pcity) < 0) ? RED : NORMAL;
gtk_widget_modify_style(info_label[GROWTH], info_label_style[style]);
/* someone could add the info_label_style[ORANGE]
* style for better granularity here */
- style = (pcity->pollution >= 10) ? RED : NORMAL;
+ style = (pollution(pcity) >= 10) ? RED : NORMAL;
gtk_widget_modify_style(info_label[POLLUTION], info_label_style[style]);
}
@@ -1807,7 +1807,7 @@
}
if (cost > 0) {
- pct = (gfloat) pcity->shield_stock / (gfloat) cost;
+ pct = (gfloat) shield_stock(pcity) / (gfloat) cost;
pct = CLAMP(pct, 0.0, 1.0);
} else {
pct = 1.0;
Index: client/gui-gtk/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/happiness.c,v
retrieving revision 1.15
diff -u -r1.15 happiness.c
--- client/gui-gtk/happiness.c 8 May 2004 04:47:56 -0000 1.15
+++ client/gui-gtk/happiness.c 8 Jul 2004 04:32:17 -0000
@@ -264,7 +264,7 @@
struct city *pcity = pdialog->pcity;
my_snprintf(bptr, nleft, _("Luxury: %d total."),
- pcity->luxury_total);
+ luxury_prod(pcity));
gtk_set_label(pdialog->hlabels[LUXURIES], buf);
}
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.88
diff -u -r1.88 citydlg.c
--- client/gui-gtk-2.0/citydlg.c 24 May 2004 13:00:51 -0000 1.88
+++ client/gui-gtk-2.0/citydlg.c 8 Jul 2004 04:32:17 -0000
@@ -1311,22 +1311,22 @@
/* fill the buffers with the necessary info */
my_snprintf(buf[FOOD], sizeof(buf[FOOD]), "%2d (%+2d)",
- pcity->food_prod, pcity->food_surplus);
+ food_prod(pcity), food_surplus(pcity));
my_snprintf(buf[SHIELD], sizeof(buf[SHIELD]), "%2d (%+2d)",
- pcity->shield_prod + pcity->shield_waste,
- pcity->shield_surplus);
+ shield_prod(pcity) + shield_waste(pcity),
+ shield_surplus(pcity));
my_snprintf(buf[TRADE], sizeof(buf[TRADE]), "%2d (%+2d)",
- pcity->trade_prod + pcity->corruption, pcity->trade_prod);
+ trade_prod(pcity) + trade_waste(pcity), trade_prod(pcity));
my_snprintf(buf[GOLD], sizeof(buf[GOLD]), "%2d (%+2d)",
- pcity->tax_total, city_gold_surplus(pcity));
+ gold_prod(pcity), city_gold_surplus(pcity));
my_snprintf(buf[LUXURY], sizeof(buf[LUXURY]), "%2d ",
- pcity->luxury_total);
+ luxury_prod(pcity));
my_snprintf(buf[SCIENCE], sizeof(buf[SCIENCE]), "%2d",
- pcity->science_total);
+ science_prod(pcity));
my_snprintf(buf[GRANARY], sizeof(buf[GRANARY]), "%d/%-d",
- pcity->food_stock, city_granary_size(pcity->size));
+ food_stock(pcity), city_granary_size(pcity->size));
granaryturns = city_turns_to_grow(pcity);
if (granaryturns == 0) {
@@ -1341,11 +1341,11 @@
abs(granaryturns));
}
my_snprintf(buf[CORRUPTION], sizeof(buf[CORRUPTION]), "%2d",
- pcity->corruption);
+ trade_waste(pcity));
my_snprintf(buf[WASTE], sizeof(buf[WASTE]), "%2d",
- pcity->shield_waste);
+ shield_waste(pcity));
my_snprintf(buf[POLLUTION], sizeof(buf[POLLUTION]), "%2d",
- pcity->pollution);
+ pollution(pcity));
/* stick 'em in the labels */
@@ -1360,13 +1360,13 @@
style = (granaryturns > -4 && granaryturns < 0) ? RED : NORMAL;
gtk_widget_modify_style(info_label[GRANARY], info_label_style[style]);
- style = (granaryturns == 0 || pcity->food_surplus < 0) ? RED : NORMAL;
+ style = (granaryturns == 0 || food_surplus(pcity) < 0) ? RED : NORMAL;
gtk_widget_modify_style(info_label[GROWTH], info_label_style[style]);
/* someone could add the info_label_style[ORANGE]
* style for better granularity here */
- style = (pcity->pollution >= 10) ? RED : NORMAL;
+ style = (pollution(pcity) >= 10) ? RED : NORMAL;
gtk_widget_modify_style(info_label[POLLUTION], info_label_style[style]);
}
@@ -1430,7 +1430,7 @@
}
if (cost > 0) {
- pct = (gdouble) pcity->shield_stock / (gdouble) cost;
+ pct = (gdouble) shield_stock(pcity) / (gdouble) cost;
pct = CLAMP(pct, 0.0, 1.0);
} else {
pct = 1.0;
Index: client/gui-gtk-2.0/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/happiness.c,v
retrieving revision 1.12
diff -u -r1.12 happiness.c
--- client/gui-gtk-2.0/happiness.c 5 May 2004 20:39:15 -0000 1.12
+++ client/gui-gtk-2.0/happiness.c 8 Jul 2004 04:32:17 -0000
@@ -257,7 +257,7 @@
struct city *pcity = pdialog->pcity;
my_snprintf(bptr, nleft, _("Luxury: %d total."),
- pcity->luxury_total);
+ luxury_prod(pcity));
gtk_label_set_text(GTK_LABEL(pdialog->hlabels[LUXURIES]), buf);
}
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.75
diff -u -r1.75 citydlg.c
--- client/gui-mui/citydlg.c 5 May 2004 20:39:15 -0000 1.75
+++ client/gui-mui/citydlg.c 8 Jul 2004 04:32:18 -0000
@@ -104,7 +104,7 @@
return buffer;
}
- stock = pcity->food_stock;
+ stock = food_stock(pcity);
cost = city_granary_size(pcity->size);
stock += surplus;
@@ -139,7 +139,7 @@
return buffer;
}
- stock = pcity->shield_stock;
+ stock = shield_stock(pcity);
if (pcity->is_building_unit) {
cost = unit_build_shield_cost(pcity->currently_building);
} else {
@@ -1762,7 +1762,7 @@
get_city_dialog_production(pcity, buf, sizeof(buf));
if (pcity->is_building_unit) {
- shield = pcity->shield_stock;
+ shield = shield_stock(pcity);
max_shield = unit_build_shield_cost(pcity->currently_building);
descr = get_unit_type(pcity->currently_building)->name;
} else {
@@ -1773,7 +1773,7 @@
shield = 0;
max_shield = 1;
} else {
- shield = pcity->shield_stock;
+ shield = shield_stock(pcity);
max_shield =
impr_build_shield_cost(pcity->currently_building);
}
@@ -1802,32 +1802,32 @@
int granarystyle;
int pollutionstyle;
- if (pcity->food_surplus > 0) {
- granaryturns = (city_granary_size(pcity->size) - pcity->food_stock +
- pcity->food_surplus - 1) / pcity->food_surplus;
- } else if (pcity->food_surplus < 0) {
- granaryturns = 1 - (pcity->food_stock / pcity->food_surplus);
+ if (food_surplus(pcity) > 0) {
+ granaryturns = (city_granary_size(pcity->size) - food_stock(pcity) +
+ food_surplus(pcity) - 1) / food_surplus(pcity);
+ } else if (food_surplus(pcity) < 0) {
+ granaryturns = 1 - (food_stock(pcity) / food_surplus(pcity));
/* turns before famine loss */
} else {
granaryturns = 999;
}
- growthstyle = (granaryturns == 0 || pcity->food_surplus < 0) ? RED : NORMAL;
- granarystyle = (pcity->food_surplus < 0 && granaryturns < 4) ? RED : NORMAL;
- pollutionstyle = (pcity->pollution >= 10) ? RED : NORMAL;
-
- settextf(info->food_text, "%2d (%+2d)", pcity->food_prod,
pcity->food_surplus);
- settextf(info->shield_text, "%2d (%+2d)", pcity->shield_prod +
pcity->shield_waste, pcity->shield_surplus);
- settextf(info->trade_text, "%2d (%+2d)", pcity->trade_prod +
pcity->corruption, pcity->trade_prod);
- settextf(info->gold_text, "%2d (%+2d)", pcity->tax_total,
city_gold_surplus(pcity));
- settextf(info->luxury_text, "%2d", pcity->luxury_total);
- settextf(info->science_text, "%2d", pcity->science_total);
+ growthstyle = (granaryturns == 0 || food_surplus(pcity) < 0) ? RED : NORMAL;
+ granarystyle = (food_surplus(pcity) < 0 && granaryturns < 4) ? RED : NORMAL;
+ pollutionstyle = (pollution(pcity) >= 10) ? RED : NORMAL;
+
+ settextf(info->food_text, "%2d (%+2d)", food_prod(pcity),
food_surplus(pcity));
+ settextf(info->shield_text, "%2d (%+2d)", shield_prod(pcity) +
shield_waste(pcity), shield_surplus(pcity));
+ settextf(info->trade_text, "%2d (%+2d)", trade_prod(pcity) +
trade_waste(pcity), trade_prod(pcity));
+ settextf(info->gold_text, "%2d (%+2d)", gold_prod(pcity),
city_gold_surplus(pcity));
+ settextf(info->luxury_text, "%2d", luxury_prod(pcity));
+ settextf(info->science_text, "%2d", science_prod(pcity));
set(info->granary_text, MUIA_Text_PreParse, granarystyle==RED?MUIX_B:"");
set(info->growth_text, MUIA_Text_PreParse, growthstyle==RED?MUIX_B:"");
set(info->pollution_text, MUIA_Text_PreParse, pollutionstyle==RED?MUIX_B:"");
- settextf(info->granary_text, "%ld/%-ld", pcity->food_stock,
city_granary_size(pcity->size));
+ settextf(info->granary_text, "%ld/%-ld", food_stock(pcity),
city_granary_size(pcity->size));
if (granaryturns == 0) {
settext(info->growth_text, _("blocked"));
} else if (granaryturns == 999) {
@@ -1839,9 +1839,9 @@
settext(info->growth_text,buf);
}
- settextf(info->corruption_text, "%ld", pcity->corruption);
- settextf(info->waste_text, "%ld", pcity->shield_waste);
- settextf(info->pollution_text, "%ld", pcity->pollution);
+ settextf(info->corruption_text, "%ld", trade_waste(pcity));
+ settextf(info->waste_text, "%ld", shield_waste(pcity));
+ settextf(info->pollution_text, "%ld", pollution(pcity));
}
/****************************************************************
@@ -2237,7 +2237,7 @@
/* LUXURY */
my_snprintf(bptr, nleft, _("Luxury: %d total (maximum %d usable). "),
- pcity->luxury_total, 2 * pcity->size);
+ luxury_prod(pcity), 2 * pcity->size);
settext(pdialog->happiness_citizen_text[1], buf);
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.77
diff -u -r1.77 citydlg.c
--- client/gui-win32/citydlg.c 23 Jun 2004 04:33:13 -0000 1.77
+++ client/gui-win32/citydlg.c 8 Jul 2004 04:32:19 -0000
@@ -411,7 +411,7 @@
{
char buf[512];
struct city *pcity=pdialog->pcity;
- my_snprintf(buf, sizeof(buf), _("Pollution: %3d"), pcity->pollution);
+ my_snprintf(buf, sizeof(buf), _("Pollution: %3d"), pollution(pcity));
SetWindowText(pdialog->pollution_area[0],buf);
SetWindowText(pdialog->pollution_area[1],buf);
}
@@ -425,7 +425,7 @@
char buf[512];
struct city *pcity = pdialog->pcity;
- my_snprintf(buf, sizeof(buf), _("Granary: %3d/%-3d"), pcity->food_stock,
+ my_snprintf(buf, sizeof(buf), _("Granary: %3d/%-3d"), food_stock(pcity),
city_granary_size(pcity->size));
SetWindowText(pdialog->storage_area[0],buf);
SetWindowText(pdialog->storage_area[1],buf);
@@ -441,9 +441,9 @@
struct city *pcity=pdialog->pcity;
my_snprintf(buf, sizeof(buf),
_("Food: %2d (%+2d)\nProd: %2d (%+2d)\nTrade: %2d
(%+2d)"),
- pcity->food_prod, pcity->food_surplus,
- pcity->shield_prod + pcity->shield_waste, pcity->shield_surplus,
- pcity->trade_prod+pcity->corruption, pcity->trade_prod);
+ food_prod(pcity), food_surplus(pcity),
+ shield_prod(pcity) + shield_waste(pcity), shield_surplus(pcity),
+ trade_prod(pcity)+trade_waste(pcity), trade_prod(pcity));
SetWindowText(pdialog->prod_area[0],buf);
SetWindowText(pdialog->prod_area[1],buf);
}
@@ -458,9 +458,9 @@
struct city *pcity=pdialog->pcity;
my_snprintf(buf, sizeof(buf),
_("Gold: %2d (%+2d)\nLuxury: %2d\nScience: %2d"),
- pcity->tax_total, city_gold_surplus(pcity),
- pcity->luxury_total,
- pcity->science_total);
+ gold_prod(pcity), city_gold_surplus(pcity),
+ luxury_prod(pcity),
+ science_prod(pcity));
SetWindowText(pdialog->output_area[0],buf);
SetWindowText(pdialog->output_area[1],buf);
}
Index: client/gui-win32/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/happiness.c,v
retrieving revision 1.5
diff -u -r1.5 happiness.c
--- client/gui-win32/happiness.c 15 Dec 2002 22:43:47 -0000 1.5
+++ client/gui-win32/happiness.c 8 Jul 2004 04:32:19 -0000
@@ -216,7 +216,7 @@
struct city *pcity = pdialog->pcity;
my_snprintf(bptr, nleft, _("Luxury: %d total."),
- pcity->luxury_total);
+ luxury_prod(pcity));
SetWindowText(pdialog->mod_label[LUXURIES], buf);
}
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.115
diff -u -r1.115 citydlg.c
--- client/gui-xaw/citydlg.c 5 May 2004 20:39:16 -0000 1.115
+++ client/gui-xaw/citydlg.c 8 Jul 2004 04:32:19 -0000
@@ -200,7 +200,7 @@
if (pdialog) {
pcity=pdialog->pcity;
- pollution=pcity->pollution;
+ pollution=pollution(pcity);
}
my_snprintf(retbuf, n, _("Pollution: %3d"), pollution);
@@ -220,7 +220,7 @@
if (pdialog) {
pcity=pdialog->pcity;
granary=(city_got_effect(pcity, B_GRANARY) ? '*' : ' ');
- foodstock=pcity->food_stock;
+ foodstock=food_stock(pcity);
foodbox=city_granary_size(pcity->size);
}
@@ -244,12 +244,12 @@
if (pdialog) {
pcity=pdialog->pcity;
- foodprod=pcity->food_prod;
- foodsurplus=pcity->food_surplus;
- shieldprod=pcity->shield_prod + pcity->shield_waste;
- shieldsurplus=pcity->shield_surplus;
- tradeprod=pcity->trade_prod+pcity->corruption;
- tradesurplus=pcity->trade_prod;
+ foodprod=food_prod(pcity);
+ foodsurplus=food_surplus(pcity);
+ shieldprod=shield_prod(pcity) + shield_waste(pcity);
+ shieldsurplus=shield_surplus(pcity);
+ tradeprod=trade_prod(pcity)+trade_waste(pcity);
+ tradesurplus=trade_prod(pcity);
}
my_snprintf(retbuf, n,
@@ -275,10 +275,10 @@
if (pdialog) {
pcity=pdialog->pcity;
- goldtotal=pcity->tax_total;
+ goldtotal=gold_prod(pcity);
goldsurplus=city_gold_surplus(pcity);
- luxtotal=pcity->luxury_total;
- scitotal=pcity->science_total;
+ luxtotal=luxury_prod(pcity);
+ scitotal=science_prod(pcity);
}
my_snprintf(retbuf, n,
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.223
diff -u -r1.223 city.c
--- common/city.c 7 Jul 2004 12:11:01 -0000 1.223
+++ common/city.c 8 Jul 2004 04:32:20 -0000
@@ -356,7 +356,7 @@
**************************************************************************/
int city_buy_cost(const struct city *pcity)
{
- int cost, build = pcity->shield_stock;
+ int cost, build = shield_stock(pcity);
if (pcity->is_building_unit) {
cost = unit_buy_gold_cost(pcity->currently_building, build);
@@ -1088,7 +1088,7 @@
/* Should this be real_map_distance? */
tb = map_distance(pc1->x, pc1->y, pc2->x, pc2->y) + 10;
- tb = (tb * (pc1->trade_prod + pc2->trade_prod)) / 24;
+ tb = (tb * (trade_prod(pc1) + trade_prod(pc2))) / 24;
/* fudge factor to more closely approximate Civ2 behavior (Civ2 is
* really very different -- this just fakes it a little better) */
@@ -1136,7 +1136,7 @@
cost += punit->upkeep_gold;
} unit_list_iterate_end;
- return pcity->tax_total-cost;
+ return gold_prod(pcity)-cost;
}
/**************************************************************************
@@ -1275,7 +1275,7 @@
{
struct government *g = get_gov_pcity(pcity);
- return (pcity->rapture > 0 && pcity->food_surplus > 0
+ return (pcity->rapture > 0 && food_surplus(pcity) > 0
&& (pcity->rapture % game.rapturedelay) == 0
&& government_has_flag(g, G_RAPTURE_CITY_GROWTH));
}
@@ -1526,7 +1526,7 @@
int city_turns_to_build(const struct city *pcity, int id, bool id_is_unit,
bool include_shield_stock)
{
- int city_shield_surplus = pcity->shield_surplus;
+ int city_shield_surplus = shield_surplus(pcity);
int city_shield_stock = include_shield_stock ?
city_change_production_penalty(pcity, id, id_is_unit) : 0;
int improvement_cost = id_is_unit ?
@@ -1552,12 +1552,12 @@
**************************************************************************/
int city_turns_to_grow(const struct city *pcity)
{
- if (pcity->food_surplus > 0) {
- return (city_granary_size(pcity->size) - pcity->food_stock +
- pcity->food_surplus - 1) / pcity->food_surplus;
- } else if (pcity->food_surplus < 0) {
+ if (food_surplus(pcity) > 0) {
+ return (city_granary_size(pcity->size) - food_stock(pcity) +
+ food_surplus(pcity) - 1) / food_surplus(pcity);
+ } else if (food_surplus(pcity) < 0) {
/* turns before famine loss */
- return -1 + (pcity->food_stock / pcity->food_surplus);
+ return -1 + (food_stock(pcity) / food_surplus(pcity));
} else {
return FC_INFINITY;
}
@@ -1801,7 +1801,7 @@
/**************************************************************************
Get the incomes of a city according to the taxrates (ignore # of
- specialists). trade should usually be pcity->trade_prod.
+ specialists). trade should usually be trade_prod(pcity).
**************************************************************************/
void get_tax_income(struct player *pplayer, int trade, int *sci,
int *lux, int *tax)
@@ -1906,16 +1906,16 @@
**************************************************************************/
static inline void set_tax_income(struct city *pcity)
{
- get_tax_income(city_owner(pcity), pcity->trade_prod, &pcity->science_total,
- &pcity->luxury_total, &pcity->tax_total);
+ get_tax_income(city_owner(pcity), trade_prod(pcity), &science_prod(pcity),
+ &luxury_prod(pcity), &gold_prod(pcity));
- pcity->luxury_total += (pcity->specialists[SP_ELVIS]
+ luxury_prod(pcity) += (pcity->specialists[SP_ELVIS]
* game.rgame.specialists[SP_ELVIS].bonus);
- pcity->science_total += (pcity->specialists[SP_SCIENTIST]
+ science_prod(pcity) += (pcity->specialists[SP_SCIENTIST]
* game.rgame.specialists[SP_SCIENTIST].bonus);
- pcity->tax_total += (pcity->specialists[SP_TAXMAN]
+ gold_prod(pcity) += (pcity->specialists[SP_TAXMAN]
* game.rgame.specialists[SP_TAXMAN].bonus);
- pcity->tax_total += get_city_tithes_bonus(pcity);
+ gold_prod(pcity) += get_city_tithes_bonus(pcity);
}
/**************************************************************************
@@ -1924,15 +1924,15 @@
static void add_buildings_effect(struct city *pcity)
{
/* this is the place to set them */
- pcity->tax_bonus = get_city_tax_bonus(pcity);
- pcity->science_bonus = get_city_science_bonus(pcity);
- pcity->shield_bonus = get_city_shield_bonus(pcity);
-
- pcity->shield_prod = (pcity->shield_prod * pcity->shield_bonus) / 100;
- pcity->luxury_total = (pcity->luxury_total * pcity->tax_bonus) / 100;
- pcity->tax_total = (pcity->tax_total * pcity->tax_bonus) / 100;
- pcity->science_total = (pcity->science_total * pcity->science_bonus) / 100;
- pcity->shield_surplus = pcity->shield_prod;
+ gold_bonus(pcity) = get_city_tax_bonus(pcity);
+ science_bonus(pcity) = get_city_science_bonus(pcity);
+ shield_bonus(pcity) = get_city_shield_bonus(pcity);
+
+ shield_prod(pcity) = (shield_prod(pcity) * shield_bonus(pcity)) / 100;
+ luxury_prod(pcity) = (luxury_prod(pcity) * gold_bonus(pcity)) / 100;
+ gold_prod(pcity) = (gold_prod(pcity) * gold_bonus(pcity)) / 100;
+ science_prod(pcity) = (science_prod(pcity) * science_bonus(pcity)) / 100;
+ shield_surplus(pcity) = shield_prod(pcity);
}
/**************************************************************************
@@ -2019,7 +2019,7 @@
**************************************************************************/
static inline void citizen_happy_luxury(struct city *pcity)
{
- int x = pcity->luxury_total;
+ int x = luxury_prod(pcity);
happy_copy(pcity, 0);
@@ -2142,10 +2142,10 @@
static inline void unhappy_city_check(struct city *pcity)
{
if (city_unhappy(pcity)) {
- pcity->food_surplus = MIN(0, pcity->food_surplus);
- pcity->tax_total = 0;
- pcity->science_total = 0;
- pcity->shield_surplus = MIN(0, pcity->shield_surplus);
+ food_surplus(pcity) = MIN(0, food_surplus(pcity));
+ gold_prod(pcity) = 0;
+ science_prod(pcity) = 0;
+ shield_surplus(pcity) = MIN(0, shield_surplus(pcity));
}
}
@@ -2156,22 +2156,22 @@
{
struct player *pplayer = city_owner(pcity);
- pcity->pollution = pcity->shield_prod;
+ pollution(pcity) = shield_prod(pcity);
if (city_got_building(pcity, B_RECYCLING)) {
- pcity->pollution /= 3;
+ pollution(pcity) /= 3;
} else if (city_got_building(pcity, B_HYDRO) ||
city_affected_by_wonder(pcity, B_HOOVER) ||
city_got_building(pcity, B_NUCLEAR)) {
- pcity->pollution /= 2;
+ pollution(pcity) /= 2;
}
if (!city_got_building(pcity, B_MASS)) {
- pcity->pollution += (pcity->size *
+ pollution(pcity) += (pcity->size *
num_known_tech_with_flag
(pplayer, TF_POPULATION_POLLUTION_INC)) / 4;
}
- pcity->pollution = MAX(0, pcity->pollution - 20);
+ pollution(pcity) = MAX(0, pollution(pcity) - 20);
}
/**************************************************************************
@@ -2202,25 +2202,25 @@
static inline void set_food_trade_shields(struct city *pcity)
{
int i;
- pcity->food_surplus = 0;
- pcity->shield_surplus = 0;
+ food_surplus(pcity) = 0;
+ shield_surplus(pcity) = 0;
- get_food_trade_shields(pcity, &pcity->food_prod, &pcity->trade_prod,
- &pcity->shield_prod);
+ get_food_trade_shields(pcity, &food_prod(pcity), &trade_prod(pcity),
+ &shield_prod(pcity));
- pcity->tile_trade = pcity->trade_prod;
- pcity->food_surplus = pcity->food_prod - pcity->size * 2;
+ pcity->tile_trade = trade_prod(pcity);
+ food_surplus(pcity) = food_prod(pcity) - pcity->size * 2;
for (i = 0; i < NUM_TRADEROUTES; i++) {
pcity->trade_value[i] =
trade_between_cities(pcity, find_city_by_id(pcity->trade[i]));
- pcity->trade_prod += pcity->trade_value[i];
+ trade_prod(pcity) += pcity->trade_value[i];
}
- pcity->corruption = city_corruption(pcity, pcity->trade_prod);
- pcity->trade_prod -= pcity->corruption;
+ trade_waste(pcity) = city_corruption(pcity, trade_prod(pcity));
+ trade_prod(pcity) -= trade_waste(pcity);
- pcity->shield_waste = city_waste(pcity, pcity->shield_prod);
- pcity->shield_prod -= pcity->shield_waste;
+ shield_waste(pcity) = city_waste(pcity, shield_prod(pcity));
+ shield_prod(pcity) -= shield_waste(pcity);
}
/**************************************************************************
@@ -2330,14 +2330,14 @@
if (shield_cost > 0) {
adjust_city_free_cost(&free_shield, &shield_cost);
if (shield_cost > 0) {
- pcity->shield_surplus -= shield_cost;
+ shield_surplus(pcity) -= shield_cost;
this_unit->upkeep = shield_cost;
}
}
if (food_cost > 0) {
adjust_city_free_cost(&free_food, &food_cost);
if (food_cost > 0) {
- pcity->food_surplus -= food_cost;
+ food_surplus(pcity) -= food_cost;
this_unit->upkeep_food = food_cost;
}
}
@@ -2681,9 +2681,9 @@
for (i = 0; i < NUM_TRADEROUTES; i++) {
pcity->trade_value[i] = pcity->trade[i] = 0;
}
- pcity->food_stock = 0;
- pcity->shield_stock = 0;
- pcity->trade_prod = 0;
+ food_stock(pcity) = 0;
+ shield_stock(pcity) = 0;
+ trade_prod(pcity) = 0;
pcity->tile_trade = 0;
pcity->original = pplayer->player_no;
@@ -2732,11 +2732,11 @@
pcity->ai.bcost = 0;
pcity->ai.attack = 0;
- pcity->corruption = 0;
- pcity->shield_waste = 0;
- pcity->shield_bonus = 100;
- pcity->tax_bonus = 100;
- pcity->science_bonus = 100;
+ trade_waste(pcity) = 0;
+ shield_waste(pcity) = 0;
+ shield_bonus(pcity) = 100;
+ gold_bonus(pcity) = 100;
+ science_bonus(pcity) = 100;
pcity->client.occupied = FALSE;
pcity->client.happy = pcity->client.unhappy = FALSE;
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.150
diff -u -r1.150 city.h
--- common/city.h 7 Jul 2004 07:26:04 -0000 1.150
+++ common/city.h 8 Jul 2004 04:32:20 -0000
@@ -344,6 +344,27 @@
/* properties */
+#define food_prod(pcity) (pcity->food_prod)
+#define shield_prod(pcity) (pcity->shield_prod)
+#define trade_prod(pcity) (pcity->trade_prod)
+#define luxury_prod(pcity) (pcity->luxury_total)
+#define science_prod(pcity) (pcity->tax_total)
+#define gold_prod(pcity) (pcity->science_total)
+
+#define food_surplus(pcity) (pcity->food_surplus)
+#define shield_surplus(pcity) (pcity->shield_surplus)
+#define trade_surplus(pcity) (pcity->trade_surplus)
+#define pollution(pcity) (pcity->pollution)
+
+#define shield_waste(pcity) (pcity->shield_waste)
+#define trade_waste(pcity) (pcity->corruption)
+
+#define shield_stock(pcity) (pcity->shield_stock)
+#define food_stock(pcity) (pcity->food_stock)
+
+#define shield_bonus(pcity) (pcity->shield_bonus)
+#define science_bonus(pcity) (pcity->science_bonus)
+#define gold_bonus(pcity) (pcity->tax_bonus)
struct player *city_owner(const struct city *pcity);
int city_population(const struct city *pcity);
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.140
diff -u -r1.140 player.c
--- common/player.c 7 Jul 2004 07:32:03 -0000 1.140
+++ common/player.c 8 Jul 2004 04:32:20 -0000
@@ -411,7 +411,7 @@
/* City income/expenses. */
city_list_iterate(pplayer->cities, pcity) {
- int lux, tax, sci, trade = pcity->trade_prod;
+ int lux, tax, sci, trade = trade_prod(pcity);
get_tax_income(pplayer, trade, &sci, &lux, &tax);
income += tax;
@@ -428,7 +428,7 @@
/* Capitalization income. */
if (!pcity->is_building_unit && pcity->currently_building == B_CAPITAL) {
- income += pcity->shield_stock + pcity->shield_surplus;
+ income += shield_stock(pcity) + shield_surplus(pcity);
}
} city_list_iterate_end;
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.211
diff -u -r1.211 unit.c
--- common/unit.c 25 Jun 2004 23:29:59 -0000 1.211
+++ common/unit.c 8 Jul 2004 04:32:21 -0000
@@ -229,7 +229,7 @@
return (unit_flag(punit, F_HELP_WONDER)
&& punit->owner == pcity->owner
&& !pcity->is_building_unit && is_wonder(pcity->currently_building)
- && (pcity->shield_stock
+ && (shield_stock(pcity)
< impr_build_shield_cost(pcity->currently_building)));
}
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.28
diff -u -r1.28 cm.c
--- common/aicore/cm.c 25 Jun 2004 23:35:55 -0000 1.28
+++ common/aicore/cm.c 8 Jul 2004 04:32:21 -0000
@@ -354,16 +354,16 @@
} my_city_map_iterate_end;
freelog(LOG_NORMAL, " food = %3d (%+3d)",
- pcity->food_prod, pcity->food_surplus);
+ food_prod(pcity), food_surplus(pcity));
freelog(LOG_NORMAL, " shield = %3d (%+3d)",
- pcity->shield_prod + pcity->shield_waste, pcity->shield_prod);
+ shield_prod(pcity) + shield_waste(pcity), shield_prod(pcity));
freelog(LOG_NORMAL, " trade = %3d (%+3d)",
- pcity->trade_prod + pcity->corruption, pcity->trade_prod);
+ trade_prod(pcity) + trade_waste(pcity), trade_prod(pcity));
- freelog(LOG_NORMAL, " gold = %3d (%+3d)", pcity->tax_total,
+ freelog(LOG_NORMAL, " gold = %3d (%+3d)", gold_prod(pcity),
city_gold_surplus(pcity));
- freelog(LOG_NORMAL, " luxury = %3d", pcity->luxury_total);
- freelog(LOG_NORMAL, " science = %3d", pcity->science_total);
+ freelog(LOG_NORMAL, " luxury = %3d", luxury_prod(pcity));
+ freelog(LOG_NORMAL, " science = %3d", science_prod(pcity));
}
/****************************************************************************
@@ -450,17 +450,17 @@
*****************************************************************************/
static void copy_stats(struct city *pcity, struct cm_result *result)
{
- result->production[FOOD] = pcity->food_prod;
- result->production[SHIELD] = pcity->shield_prod + pcity->shield_waste;
- result->production[TRADE] = pcity->trade_prod + pcity->corruption;
-
- result->surplus[FOOD] = pcity->food_surplus;
- result->surplus[SHIELD] = pcity->shield_surplus;
- result->surplus[TRADE] = pcity->trade_prod;
-
- result->production[GOLD] = pcity->tax_total;
- result->production[LUXURY] = pcity->luxury_total;
- result->production[SCIENCE] = pcity->science_total;
+ result->production[FOOD] = food_prod(pcity);
+ result->production[SHIELD] = shield_prod(pcity) + shield_waste(pcity);
+ result->production[TRADE] = trade_prod(pcity) + trade_waste(pcity);
+
+ result->surplus[FOOD] = food_surplus(pcity);
+ result->surplus[SHIELD] = shield_surplus(pcity);
+ result->surplus[TRADE] = trade_prod(pcity);
+
+ result->production[GOLD] = gold_prod(pcity);
+ result->production[LUXURY] = luxury_prod(pcity);
+ result->production[SCIENCE] = science_prod(pcity);
result->surplus[GOLD] = city_gold_surplus(pcity);
result->surplus[LUXURY] = result->production[LUXURY];
Index: server/cityhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v
retrieving revision 1.132
diff -u -r1.132 cityhand.c
--- server/cityhand.c 2 Jun 2004 22:54:15 -0000 1.132
+++ server/cityhand.c 8 Jul 2004 04:32:22 -0000
@@ -259,11 +259,11 @@
*/
pplayer->economic.gold-=cost;
- if (pcity->shield_stock < total){
+ if (shield_stock(pcity) < total){
/* As we never put penalty on disbanded_shields, we can
* fully well add the missing shields there. */
- pcity->disbanded_shields += total - pcity->shield_stock;
- pcity->shield_stock=total; /* AI wants this -- Syela */
+ pcity->disbanded_shields += total - shield_stock(pcity);
+ shield_stock(pcity)=total; /* AI wants this -- Syela */
pcity->did_buy = TRUE; /* !PS: no need to set buy flag otherwise */
}
city_refresh(pcity);
@@ -344,7 +344,7 @@
return;
if (!is_build_id_unit_id && !can_build_improvement(pcity, build_id))
return;
- if (pcity->did_buy && pcity->shield_stock > 0) {
+ if (pcity->did_buy && shield_stock(pcity) > 0) {
notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT,
_("Game: You have bought this turn, can't change."));
return;
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.261
diff -u -r1.261 citytools.c
--- server/citytools.c 14 Jun 2004 23:43:08 -0000 1.261
+++ server/citytools.c 8 Jul 2004 04:32:22 -0000
@@ -418,7 +418,7 @@
{
int cost = impr_build_shield_cost(pcity->currently_building);
- return cost - pcity->shield_stock;
+ return cost - shield_stock(pcity);
}
/**************************************************************************
@@ -621,7 +621,7 @@
**************************************************************************/
int city_shield_bonus(struct city *pcity)
{
- return pcity->shield_bonus;
+ return shield_bonus(pcity);
}
/**************************************************************************
@@ -629,7 +629,7 @@
**************************************************************************/
int city_tax_bonus(struct city *pcity)
{
- return pcity->tax_bonus;
+ return gold_bonus(pcity);
}
/**************************************************************************
@@ -637,7 +637,7 @@
**************************************************************************/
int city_science_bonus(struct city *pcity)
{
- return pcity->science_bonus;
+ return science_bonus(pcity);
}
/**************************************************************************
@@ -833,7 +833,7 @@
} built_impr_iterate_end;
nullify_prechange_production(pcity);
- pcity->shield_stock = 0;
+ shield_stock(pcity) = 0;
}
/**************************************************************************
@@ -1695,23 +1695,23 @@
packet->trade_value[i]=pcity->trade_value[i];
}
- packet->food_prod=pcity->food_prod;
- packet->food_surplus=pcity->food_surplus;
- packet->shield_prod=pcity->shield_prod;
- packet->shield_surplus=pcity->shield_surplus;
- packet->trade_prod=pcity->trade_prod;
+ packet->food_prod=food_prod(pcity);
+ packet->food_surplus=food_surplus(pcity);
+ packet->shield_prod=shield_prod(pcity);
+ packet->shield_surplus=shield_surplus(pcity);
+ packet->trade_prod=trade_prod(pcity);
packet->tile_trade=pcity->tile_trade;
- packet->corruption=pcity->corruption;
+ packet->corruption=trade_waste(pcity);
- packet->shield_waste=pcity->shield_waste;
+ packet->shield_waste=shield_waste(pcity);
- packet->luxury_total=pcity->luxury_total;
- packet->tax_total=pcity->tax_total;
- packet->science_total=pcity->science_total;
+ packet->luxury_total=luxury_prod(pcity);
+ packet->tax_total=gold_prod(pcity);
+ packet->science_total=science_prod(pcity);
- packet->food_stock=pcity->food_stock;
- packet->shield_stock=pcity->shield_stock;
- packet->pollution=pcity->pollution;
+ packet->food_stock=food_stock(pcity);
+ packet->shield_stock=shield_stock(pcity);
+ packet->pollution=pollution(pcity);
packet->city_options=pcity->city_options;
@@ -1943,7 +1943,7 @@
/* Manage the city change-production penalty.
(May penalize, restore or do nothing to the shield_stock.) */
- pcity->shield_stock = city_change_production_penalty(pcity, target, is_unit);
+ shield_stock(pcity) = city_change_production_penalty(pcity, target, is_unit);
/* Change build target. */
pcity->currently_building = target;
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.250
diff -u -r1.250 cityturn.c
--- server/cityturn.c 7 Jul 2004 07:32:03 -0000 1.250
+++ server/cityturn.c 8 Jul 2004 04:32:24 -0000
@@ -248,7 +248,7 @@
cm_query_result(pcity, &cmp, &cmr);
if (!cmr.found_a_valid) {
- cmp.minimal_surplus[FOOD] = -(pcity->food_stock);
+ cmp.minimal_surplus[FOOD] = -(food_stock(pcity));
cmp.minimal_surplus[TRADE] = -FC_INFINITY;
cm_query_result(pcity, &cmp, &cmr);
}
@@ -311,15 +311,15 @@
int turns_growth, turns_granary;
bool can_grow;
- if (pcity->food_surplus > 0) {
- turns_growth = (city_granary_size(pcity->size) - pcity->food_stock - 1)
- / pcity->food_surplus;
+ if (food_surplus(pcity) > 0) {
+ turns_growth = (city_granary_size(pcity->size) - food_stock(pcity) - 1)
+ / food_surplus(pcity);
if (!city_got_effect(pcity,B_GRANARY) && !pcity->is_building_unit
&& pcity->currently_building == B_GRANARY
- && pcity->shield_surplus > 0) {
+ && shield_surplus(pcity) > 0) {
turns_granary = (impr_build_shield_cost(B_GRANARY)
- - pcity->shield_stock) / pcity->shield_surplus;
+ - shield_stock(pcity)) / shield_surplus(pcity);
/* if growth and granary completion occur simultaneously, granary
preserves food. -AJS */
if (turns_growth < 5 && turns_granary < 5
@@ -344,7 +344,7 @@
pcity->name, pcity->size + 1);
}
} else {
- if (pcity->food_stock + pcity->food_surplus <= 0 && pcity->food_surplus <
0) {
+ if (food_stock(pcity) + food_surplus(pcity) <= 0 && food_surplus(pcity) <
0) {
notify_conn_ex(dest, pcity->x, pcity->y,
E_CITY_FAMINE_FEARED,
_("Game: Warning: Famine feared in %s."),
@@ -397,8 +397,8 @@
pcity->size -= pop_loss;
/* Cap the food stock at the new granary size. */
- if (pcity->food_stock > city_granary_size(pcity->size)) {
- pcity->food_stock = city_granary_size(pcity->size);
+ if (food_stock(pcity) > city_granary_size(pcity->size)) {
+ food_stock(pcity) = city_granary_size(pcity->size);
}
/* First try to kill off the specialists */
@@ -462,7 +462,7 @@
/* Granary can only hold so much */
new_food = (city_granary_size(pcity->size) *
(100 - game.aqueductloss / (1 + (has_granary ? 1 : 0)))) / 100;
- pcity->food_stock = MIN(pcity->food_stock, new_food);
+ food_stock(pcity) = MIN(food_stock(pcity), new_food);
return;
}
@@ -481,7 +481,7 @@
/* Granary can only hold so much */
new_food = (city_granary_size(pcity->size) *
(100 - game.aqueductloss / (1 + (has_granary ? 1 : 0)))) / 100;
- pcity->food_stock = MIN(pcity->food_stock, new_food);
+ food_stock(pcity) = MIN(food_stock(pcity), new_food);
return;
}
@@ -495,7 +495,7 @@
else
new_food = 0;
}
- pcity->food_stock = MIN(pcity->food_stock, new_food);
+ food_stock(pcity) = MIN(food_stock(pcity), new_food);
/* If there is enough food, and the city is big enough,
* make new citizens into scientists or taxmen -- Massimo */
@@ -506,7 +506,7 @@
have_square = TRUE;
}
} city_map_iterate_end;
- if (((pcity->food_surplus >= 2) || !have_square) && pcity->size >= 5 &&
+ if (((food_surplus(pcity) >= 2) || !have_square) && pcity->size >= 5 &&
(is_city_option_set(pcity, CITYO_NEW_EINSTEIN) ||
is_city_option_set(pcity, CITYO_NEW_TAXMAN))) {
@@ -536,12 +536,12 @@
**************************************************************************/
static void city_populate(struct city *pcity)
{
- pcity->food_stock+=pcity->food_surplus;
- if(pcity->food_stock >= city_granary_size(pcity->size)
+ food_stock(pcity)+=food_surplus(pcity);
+ if(food_stock(pcity) >= city_granary_size(pcity->size)
|| city_rapture_grow(pcity)) {
city_increase_size(pcity);
}
- else if(pcity->food_stock<0) {
+ else if(food_stock(pcity)<0) {
/* FIXME: should this depend on units with ability to build
* cities or on units that require food in uppkeep?
* I'll assume citybuilders (units that 'contain' 1 pop) -- sjolie
@@ -560,9 +560,9 @@
gamelog(GAMELOG_UNITFS, _("%s lose %s (famine)"),
get_nation_name_plural(city_owner(pcity)->nation), utname);
if (city_got_effect(pcity, B_GRANARY))
- pcity->food_stock=city_granary_size(pcity->size)/2;
+ food_stock(pcity)=city_granary_size(pcity->size)/2;
else
- pcity->food_stock=0;
+ food_stock(pcity)=0;
return;
}
} unit_list_iterate_safe_end;
@@ -570,9 +570,9 @@
_("Game: Famine causes population loss in %s."),
pcity->name);
if (city_got_effect(pcity, B_GRANARY))
- pcity->food_stock = city_granary_size(pcity->size - 1) / 2;
+ food_stock(pcity) = city_granary_size(pcity->size - 1) / 2;
else
- pcity->food_stock = 0;
+ food_stock(pcity) = 0;
city_reduce_size(pcity, 1);
}
}
@@ -864,21 +864,21 @@
{
struct government *g = get_gov_pplayer(pplayer);
- if (pcity->shield_surplus < 0) {
+ if (shield_surplus(pcity) < 0) {
unit_list_iterate_safe(pcity->units_supported, punit) {
if (utype_shield_cost(unit_type(punit), g) > 0
- && pcity->shield_surplus < 0
+ && shield_surplus(pcity) < 0
&& !unit_flag(punit, F_UNDISBANDABLE)) {
notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_LOST,
_("Game: %s can't upkeep %s, unit disbanded."),
pcity->name, unit_type(punit)->name);
handle_unit_disband(pplayer, punit->id);
- /* pcity->shield_surplus is automatically updated. */
+ /* shield_surplus(pcity) is automatically updated. */
}
} unit_list_iterate_safe_end;
}
- if (pcity->shield_surplus < 0) {
+ if (shield_surplus(pcity) < 0) {
/* Special case: F_UNDISBANDABLE. This nasty unit won't go so easily.
* It'd rather make the citizens pay in blood for their failure to upkeep
* it! If we make it here all normal units are already disbanded, so only
@@ -886,7 +886,7 @@
unit_list_iterate_safe(pcity->units_supported, punit) {
int upkeep = utype_shield_cost(unit_type(punit), g);
- if (upkeep > 0 && pcity->shield_surplus < 0) {
+ if (upkeep > 0 && shield_surplus(pcity) < 0) {
assert(unit_flag(punit, F_UNDISBANDABLE));
notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_LOST,
_("Game: Citizens in %s perish for their failure to "
@@ -896,15 +896,15 @@
}
/* No upkeep for the unit this turn. */
- pcity->shield_surplus += upkeep;
+ shield_surplus(pcity) += upkeep;
}
} unit_list_iterate_safe_end;
}
/* Now we confirm changes made last turn. */
- pcity->shield_stock += pcity->shield_surplus;
- pcity->before_change_shields = pcity->shield_stock;
- pcity->last_turns_shield_surplus = pcity->shield_surplus;
+ shield_stock(pcity) += shield_surplus(pcity);
+ pcity->before_change_shields = shield_stock(pcity);
+ pcity->last_turns_shield_surplus = shield_surplus(pcity);
return TRUE;
}
@@ -917,12 +917,12 @@
bool space_part;
if (pcity->currently_building == B_CAPITAL) {
- assert(pcity->shield_surplus >= 0);
+ assert(shield_surplus(pcity) >= 0);
/* pcity->before_change_shields already contains the surplus from
* this turn. */
pplayer->economic.gold += pcity->before_change_shields;
pcity->before_change_shields = 0;
- pcity->shield_stock = 0;
+ shield_stock(pcity) = 0;
}
upgrade_building_prod(pcity);
if (!can_build_improvement(pcity, pcity->currently_building)) {
@@ -934,7 +934,7 @@
currently_building));
return TRUE;
}
- if (pcity->shield_stock
+ if (shield_stock(pcity)
>= impr_build_shield_cost(pcity->currently_building)) {
if (pcity->currently_building == B_PALACE) {
city_list_iterate(pplayer->cities, palace) {
@@ -958,7 +958,7 @@
}
pcity->before_change_shields -=
impr_build_shield_cost(pcity->currently_building);
- pcity->shield_stock -= impr_build_shield_cost(pcity->currently_building);
+ shield_stock(pcity) -= impr_build_shield_cost(pcity->currently_building);
pcity->turn_last_built = game.year;
/* to eliminate micromanagement */
if (is_wonder(pcity->currently_building)) {
@@ -1057,7 +1057,7 @@
pplayer->name, pcity->name, unit_name(pcity->currently_building));
return TRUE;
}
- if (pcity->shield_stock
+ if (shield_stock(pcity)
>= unit_build_shield_cost(pcity->currently_building)) {
int pop_cost = unit_pop_value(pcity->currently_building);
@@ -1094,7 +1094,7 @@
cost */
pcity->before_change_shields
-= unit_build_shield_cost(pcity->currently_building);
- pcity->shield_stock
+ shield_stock(pcity)
-= unit_build_shield_cost(pcity->currently_building);
notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_BUILT,
@@ -1166,7 +1166,7 @@
static void check_pollution(struct city *pcity)
{
int k=100;
- if (pcity->pollution != 0 && myrand(100) <= pcity->pollution) {
+ if (pollution(pcity) != 0 && myrand(100) <= pollution(pcity)) {
while (k > 0) {
/* place pollution somewhere in city radius */
int cx = myrand(CITY_MAP_SIZE);
@@ -1368,8 +1368,8 @@
pcity->airlift=TRUE;
else
pcity->airlift=FALSE;
- update_tech(pplayer, pcity->science_total);
- pplayer->economic.gold+=pcity->tax_total;
+ update_tech(pplayer, science_prod(pcity));
+ pplayer->economic.gold+=gold_prod(pcity);
pay_for_units(pplayer, pcity);
pay_for_buildings(pplayer, pcity);
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.56
diff -u -r1.56 diplomats.c
--- server/diplomats.c 14 Apr 2004 10:14:39 -0000 1.56
+++ server/diplomats.c 8 Jul 2004 04:32:24 -0000
@@ -821,7 +821,7 @@
_("Game: %s has revolted, %s influence suspected."),
pcity->name, get_nation_name(pplayer->nation));
- pcity->shield_stock = 0;
+ shield_stock(pcity) = 0;
nullify_prechange_production(pcity);
/* You get a technology advance, too! */
@@ -934,7 +934,7 @@
* Won't pick something that doesn't exit.
* If nothing to do, say so, deduct movement cost and return.
*/
- if (count == 0 && pcity->shield_stock == 0) {
+ if (count == 0 && shield_stock(pcity) == 0) {
notify_player_ex(pplayer, pcity->x, pcity->y, E_MY_DIPLOMAT_FAILED,
_("Game: Your %s could not find anything to"
" sabotage in %s."), unit_name(pdiplomat->type),
@@ -1004,7 +1004,7 @@
/* Sabotage current production. */
/* Do it. */
- pcity->shield_stock = 0;
+ shield_stock(pcity) = 0;
nullify_prechange_production(pcity); /* Make it impossible to recover */
/* Report it. */
Index: server/report.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/report.c,v
retrieving revision 1.51
diff -u -r1.51 report.c
--- server/report.c 23 Jun 2004 01:52:23 -0000 1.51
+++ server/report.c 8 Jul 2004 04:32:24 -0000
@@ -521,7 +521,7 @@
int result = 0;
city_list_iterate(pplayer->cities, pcity) {
- result += pcity->corruption;
+ result += trade_waste(pcity);
} city_list_iterate_end;
return result;
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.163
diff -u -r1.163 savegame.c
--- server/savegame.c 6 Jul 2004 21:48:48 -0000 1.163
+++ server/savegame.c 8 Jul 2004 04:32:24 -0000
@@ -1257,11 +1257,11 @@
pcity->trade[j]=secfile_lookup_int(file, "player%d.c%d.traderoute%d",
plrno, i, j);
- pcity->food_stock=secfile_lookup_int(file, "player%d.c%d.food_stock",
+ food_stock(pcity)=secfile_lookup_int(file, "player%d.c%d.food_stock",
plrno, i);
- pcity->shield_stock=secfile_lookup_int(file, "player%d.c%d.shield_stock",
+ shield_stock(pcity)=secfile_lookup_int(file, "player%d.c%d.shield_stock",
plrno, i);
- pcity->tile_trade=pcity->trade_prod=0;
+ pcity->tile_trade=trade_prod(pcity)=0;
pcity->anarchy=secfile_lookup_int(file, "player%d.c%d.anarchy", plrno,i);
pcity->rapture=secfile_lookup_int_default(file, 0, "player%d.c%d.rapture",
plrno,i);
pcity->was_happy=secfile_lookup_bool(file, "player%d.c%d.was_happy",
plrno,i);
@@ -1281,7 +1281,7 @@
secfile_lookup_bool_default(file, pcity->is_building_unit,
"player%d.c%d.changed_from_is_unit", plrno, i);
pcity->before_change_shields=
- secfile_lookup_int_default(file, pcity->shield_stock,
+ secfile_lookup_int_default(file, shield_stock(pcity),
"player%d.c%d.before_change_shields", plrno,
i);
pcity->disbanded_shields=
secfile_lookup_int_default(file, 0,
@@ -1876,9 +1876,9 @@
secfile_insert_int(file, pcity->trade[j], "player%d.c%d.traderoute%d",
plrno, i, j);
- secfile_insert_int(file, pcity->food_stock, "player%d.c%d.food_stock",
+ secfile_insert_int(file, food_stock(pcity), "player%d.c%d.food_stock",
plrno, i);
- secfile_insert_int(file, pcity->shield_stock, "player%d.c%d.shield_stock",
+ secfile_insert_int(file, shield_stock(pcity), "player%d.c%d.shield_stock",
plrno, i);
secfile_insert_int(file, pcity->turn_last_built,
"player%d.c%d.turn_last_built", plrno, i);
Index: server/score.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/score.c,v
retrieving revision 1.5
diff -u -r1.5 score.c
--- server/score.c 27 May 2004 22:14:19 -0000 1.5
+++ server/score.c 8 Jul 2004 04:32:25 -0000
@@ -417,10 +417,10 @@
pplayer->score.elvis += pcity->specialists[SP_ELVIS];
pplayer->score.population += city_population(pcity);
pplayer->score.cities++;
- pplayer->score.pollution += pcity->pollution;
- pplayer->score.techout += pcity->science_total;
- pplayer->score.bnp += pcity->trade_prod;
- pplayer->score.mfg += pcity->shield_surplus;
+ pplayer->score.pollution += pollution(pcity);
+ pplayer->score.techout += science_prod(pcity);
+ pplayer->score.bnp += trade_prod(pcity);
+ pplayer->score.mfg += shield_surplus(pcity);
if (city_got_building(pcity, B_UNIVERSITY)) {
pplayer->score.literacy += city_population(pcity);
} else if (city_got_building(pcity,B_LIBRARY)) {
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.171
diff -u -r1.171 srv_main.c
--- server/srv_main.c 30 Jun 2004 07:59:26 -0000 1.171
+++ server/srv_main.c 8 Jul 2004 04:32:25 -0000
@@ -599,9 +599,9 @@
} unit_list_iterate_end;
city_list_iterate(pplayer->cities, pcity) {
workers += pcity->size;
- shields += pcity->shield_prod;
- food += pcity->food_prod;
- trade += pcity->trade_prod;
+ shields += shield_prod(pcity);
+ food += food_prod(pcity);
+ trade += trade_prod(pcity);
} city_list_iterate_end;
gamelog(GAMELOG_NORMAL, "INFO %s cities %d, pop %d "
"food %d, prod %d, trade %d, settlers %d, units %d",
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.299
diff -u -r1.299 unithand.c
--- server/unithand.c 27 May 2004 22:14:19 -0000 1.299
+++ server/unithand.c 8 Jul 2004 04:32:26 -0000
@@ -363,7 +363,7 @@
if (!unit_flag(punit, F_UNDISBANDABLE)) { /* refuse to kill ourselves */
if (pcity) {
- pcity->shield_stock += unit_disband_shields(punit->type);
+ shield_stock(pcity) += unit_disband_shields(punit->type);
/* If we change production later at this turn. No penalty is added. */
pcity->disbanded_shields += unit_disband_shields(punit->type);
@@ -1196,7 +1196,7 @@
return;
}
- pcity_dest->shield_stock += unit_build_shield_cost(punit->type);
+ shield_stock(pcity_dest) += unit_build_shield_cost(punit->type);
pcity_dest->caravan_shields += unit_build_shield_cost(punit->type);
conn_list_do_buffer(&pplayer->connections);
|