[Freeciv-Dev] (PR#14706) Turn EFT_PROD_TO_GOLD into an improvement flag
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#14706) Turn EFT_PROD_TO_GOLD into an improvement flag |
From: |
"Vasco Alexandre da Silva Costa" <vasco.costa@xxxxxxxxx> |
Date: |
Sun, 27 Nov 2005 10:55:06 -0800 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14706 >
Hello,
This patch removes EFT_PROD_TO_GOLD and uses a new IF_GOLD improvement
flag instead. Effects should not be used as flags.
It removes a user of building_has_effect, which is IMO a kludge
function. In addition, some lingering 'b_special' cruft sections in the
rulesets were removed.
Index: server/cityhand.c
===================================================================
--- server/cityhand.c (revision 11280)
+++ server/cityhand.c (working copy)
@@ -229,8 +229,8 @@
return;
}
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
- assert(!pcity->production.is_unit);
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
notify_player(pplayer, pcity->tile, E_BAD_COMMAND,
_("You don't buy %s!"),
get_improvement_name(pcity->production.value));
Index: server/cityturn.c
===================================================================
--- server/cityturn.c (revision 11280)
+++ server/cityturn.c (working copy)
@@ -1048,7 +1048,8 @@
Impr_type_id id = pcity->production.value;
struct impr_type *building = get_improvement_type(id);
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
assert(pcity->surplus[O_SHIELD] >= 0);
/* pcity->before_change_shields already contains the surplus from
* this turn. */
Index: data/civ1/buildings.ruleset
===================================================================
--- data/civ1/buildings.ruleset (revision 11280)
+++ data/civ1/buildings.ruleset (working copy)
@@ -1062,9 +1062,3 @@
This means that in a Republic, units do not cause unhappiness, and in\
a Democracy, aggressive units cause only 1 unhappy citizen each.\
")
-
-[b_special]
-
-; Special values:
-
-default="Capitalization"
Index: data/civ2/effects.ruleset
===================================================================
--- data/civ2/effects.ruleset (revision 11280)
+++ data/civ2/effects.ruleset (working copy)
@@ -1493,14 +1493,6 @@
"Building", "Women's Suffrage", "Player"
}
-[effect_capitalization]
-name = "Prod_To_Gold"
-value = 1
-reqs =
- { "type", "name", "range"
- "Building", "Capitalization", "City"
- }
-
[effect_flight_trade_revenue_reduce]
name = "Trade_Revenue_Bonus"
value = -585
Index: data/civ2/buildings.ruleset
===================================================================
--- data/civ2/buildings.ruleset (revision 11280)
+++ data/civ2/buildings.ruleset (working copy)
@@ -1510,6 +1510,7 @@
[building_capitalization]
name = _("Capitalization")
genus = "Special"
+flags = "Gold"
reqs =
{ "type", "name", "range"
"Tech", "The Corporation", "Player"
@@ -1525,10 +1526,3 @@
production to Capitalization means its shield production is\
converted to tax output (money).\
")
-
-
-[b_special]
-
-; Special values:
-
-default="Capitalization"
Index: data/default/effects.ruleset
===================================================================
--- data/default/effects.ruleset (revision 11280)
+++ data/default/effects.ruleset (working copy)
@@ -1601,14 +1601,6 @@
"Building", "Women's Suffrage", "Player"
}
-[effect_coinage]
-name = "Prod_To_Gold"
-value = 1
-reqs =
- { "type", "name", "range"
- "Building", "Coinage", "City"
- }
-
[effect_flight_trade_revenue_reduce]
name = "Trade_Revenue_Bonus"
value = -585
Index: data/default/buildings.ruleset
===================================================================
--- data/default/buildings.ruleset (revision 11280)
+++ data/default/buildings.ruleset (working copy)
@@ -1530,6 +1530,7 @@
[building_capitalization]
name = _("Coinage")
genus = "Special"
+flags = "Gold"
reqs =
{ "type", "name", "range"
@@ -1553,10 +1554,3 @@
production to Coinage means its shield production is\
converted to tax output (money, coins!).\
")
-
-
-[b_special]
-
-; Special values:
-
-default="Coinage"
Index: data/history/effects.ruleset
===================================================================
--- data/history/effects.ruleset (revision 11280)
+++ data/history/effects.ruleset (working copy)
@@ -1162,14 +1162,6 @@
"Building", "Women's Suffrage", "Player"
}
-[effect_coinage]
-name = "Prod_To_Gold"
-value = 1
-reqs =
- { "type", "name", "range"
- "Building", "Coinage", "City"
- }
-
[effect_flight_trade_revenue_reduce]
name = "Trade_Revenue_Bonus"
value = -585
Index: data/history/buildings.ruleset
===================================================================
--- data/history/buildings.ruleset (revision 11280)
+++ data/history/buildings.ruleset (working copy)
@@ -1508,6 +1508,7 @@
; */
name = _("Coinage")
genus = "Special"
+flags = "Gold"
reqs =
{ "type", "name", "range"
; Nothing
@@ -1531,10 +1532,3 @@
production to Coinage means its shield production is\
converted to tax output (money, coins!).\
")
-
-
-[b_special]
-
-; Special values:
-
-default="Coinage"
Index: common/improvement.c
===================================================================
--- common/improvement.c (revision 11280)
+++ common/improvement.c (working copy)
@@ -32,7 +32,7 @@
};
static const char *flag_names[] = {
- "VisibleByOthers", "SaveSmallWonder"
+ "VisibleByOthers", "SaveSmallWonder", "Gold"
};
/* Note that these strings must correspond with the enums in impr_flag_id,
in common/improvement.h */
@@ -173,7 +173,7 @@
int cost = 0;
const int missing = impr_build_shield_cost(id) - shields_in_stock;
- if (building_has_effect(id, EFT_PROD_TO_GOLD)) {
+ if (impr_flag(id, IF_GOLD)) {
/* Can't buy capitalization. */
return 0;
}
Index: common/improvement.h
===================================================================
--- common/improvement.h (revision 11280)
+++ common/improvement.h (working copy)
@@ -37,8 +37,9 @@
/* Changing these breaks network compatibility. */
enum impr_flag_id {
- IF_VISIBLE_BY_OTHERS, /* improvement should be visible to others without
spying */
- IF_SAVE_SMALL_WONDER, /* this small wonder is moved to another city if
game.savepalace is on. */
+ IF_VISIBLE_BY_OTHERS, /* improvement should be visible to others without
spying */
+ IF_SAVE_SMALL_WONDER, /* this small wonder is moved to another city if
game.savepalace is on. */
+ IF_GOLD, /* when built, gives gold */
IF_LAST
};
Index: common/effects.c
===================================================================
--- common/effects.c (revision 11280)
+++ common/effects.c (working copy)
@@ -69,7 +69,6 @@
"Pollu_Pop_Pct",
/* TODO: "Pollu_Prod_Adj", */
"Pollu_Prod_Pct",
- "Prod_To_Gold",
"Reveal_Cities",
"Reveal_Map",
/* TODO: "Incite_Dist_Adj", */
Index: common/effects.h
===================================================================
--- common/effects.h (revision 11280)
+++ common/effects.h (working copy)
@@ -57,7 +57,6 @@
/* TODO: EFT_POLLU_PROD_ADJ, */
EFT_POLLU_PROD_PCT,
/* TODO: EFT_PROD_PCT, */
- EFT_PROD_TO_GOLD,
EFT_REVEAL_CITIES,
EFT_REVEAL_MAP,
/* TODO: EFT_INCITE_DIST_ADJ, */
Index: common/player.c
===================================================================
--- common/player.c (revision 11280)
+++ common/player.c (working copy)
@@ -488,7 +488,8 @@
income += pcity->surplus[O_GOLD];
/* Capitalization income. */
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
income += pcity->shield_stock + pcity->surplus[O_SHIELD];
}
} city_list_iterate_end;
Index: ai/aicity.c
===================================================================
--- ai/aicity.c (revision 11280)
+++ ai/aicity.c (working copy)
@@ -278,6 +278,13 @@
}
} players_iterate_end;
+ if (impr_flag(id, IF_GOLD)) {
+ /* Since coinage contains some entirely spurious ruleset values,
+ * we need to return here with some spurious want. */
+ pcity->ai.building_want[id] = TRADE_WEIGHTING;
+ return;
+ }
+
/* Base want is calculated above using a more direct approach. */
v += base_want(pplayer, pcity, id);
if (v != 0) {
@@ -327,16 +334,11 @@
int amount = peffect->value, c = cities[mypreq->range];
switch (peffect->type) {
- case EFT_PROD_TO_GOLD:
- /* Since coinage contains some entirely spurious ruleset values,
- * we need to return here with some spurious want. */
- pcity->ai.building_want[id] = TRADE_WEIGHTING;
- return;
- /* These have already been evaluated in base_want() */
- case EFT_CAPITAL_CITY:
- case EFT_UPKEEP_FREE:
- case EFT_POLLU_POP_PCT:
- case EFT_POLLU_PROD_PCT:
+ /* These have already been evaluated in base_want() */
+ case EFT_CAPITAL_CITY:
+ case EFT_UPKEEP_FREE:
+ case EFT_POLLU_POP_PCT:
+ case EFT_POLLU_PROD_PCT:
case EFT_OUTPUT_BONUS:
case EFT_OUTPUT_BONUS_2:
case EFT_OUTPUT_ADD_TILE:
Index: client/agents/cma_fec.c
===================================================================
--- client/agents/cma_fec.c (revision 11280)
+++ client/agents/cma_fec.c (working copy)
@@ -288,7 +288,8 @@
if (pcity->production.is_unit) {
cost = unit_build_shield_cost(get_unit_type(pcity->production.value));
} else {
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
my_snprintf(buffer, sizeof(buffer),
get_improvement_type(pcity->production.value)->name);
return buffer;
Index: client/citydlg_common.c
===================================================================
--- client/citydlg_common.c (revision 11280)
+++ client/citydlg_common.c (working copy)
@@ -223,7 +223,8 @@
cost = impr_build_shield_cost(pcity->production.value);
}
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
my_snprintf(buffer, buffer_len, _("%3d gold per turn"),
MAX(0, pcity->surplus[O_SHIELD]));
} else {
@@ -264,8 +265,7 @@
struct city_production target,
struct city *pcity)
{
- if (!target.is_unit
- && building_has_effect(target.value, EFT_PROD_TO_GOLD)) {
+ if (!target.is_unit && impr_flag(target.value, IF_GOLD)) {
my_snprintf(buffer, buffer_len, _("%s (XX) %d/turn"),
get_impr_name_ex(pcity, target.value),
MAX(0, pcity->surplus[O_SHIELD]));
@@ -321,7 +321,7 @@
struct player *pplayer = pcity ? pcity->owner : game.player_ptr;
/* Total & turns left meaningless on capitalization */
- if (building_has_effect(target.value, EFT_PROD_TO_GOLD)) {
+ if (impr_flag(target.value, IF_GOLD)) {
my_snprintf(buf[0], column_size, get_improvement_name(target.value));
buf[1][0] = '\0';
my_snprintf(buf[2], column_size, "---");
@@ -362,8 +362,7 @@
/* Add the turns-to-build entry in the 4th position */
if (pcity) {
- if (!target.is_unit
- && building_has_effect(target.value, EFT_PROD_TO_GOLD)) {
+ if (!target.is_unit && impr_flag(target.value, IF_GOLD)) {
my_snprintf(buf[3], column_size, _("%d/turn"),
MAX(0, pcity->surplus[O_SHIELD]));
} else {
@@ -802,7 +801,7 @@
&& pcity->owner == game.player_ptr
&& pcity->turn_founded != game.info.turn
&& !pcity->did_buy
- && get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) <= 0
+ && !impr_flag(pcity->production.value, IF_GOLD)
&& !(pcity->production.is_unit && pcity->anarchy != 0)
&& city_buy_cost(pcity) > 0);
}
Index: client/cityrepdata.c
===================================================================
--- client/cityrepdata.c (revision 11280)
+++ client/cityrepdata.c (working copy)
@@ -358,7 +358,8 @@
worklist_is_empty(&pcity->worklist) ? "" :
concise_city_production ? "+" : _("(worklist)");
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
my_snprintf(buf, sizeof(buf), "%s (%d/X/X/X)%s",
get_impr_name_ex(pcity, pcity->production.value),
MAX(0, pcity->surplus[O_SHIELD]), from_worklist);
Index: client/repodlgs_common.c
===================================================================
--- client/repodlgs_common.c (revision 11280)
+++ client/repodlgs_common.c (working copy)
@@ -85,7 +85,8 @@
city_list_iterate(game.player_ptr->cities, pcity) {
*total_income += pcity->prod[O_GOLD];
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
*total_income += MAX(0, pcity->surplus[O_SHIELD]);
}
} city_list_iterate_end;
Index: client/mapview_common.c
===================================================================
--- client/mapview_common.c (revision 11280)
+++ client/mapview_common.c (working copy)
@@ -1924,7 +1924,8 @@
} else {
struct impr_type *pimprovement_type =
get_improvement_type(pcity->production.value);
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
my_snprintf(buffer, buffer_len, "%s", pimprovement_type->name);
} else if (turns < 999) {
my_snprintf(buffer, buffer_len, "%s %d",
Index: client/climisc.c
===================================================================
--- client/climisc.c (revision 11280)
+++ client/climisc.c (working copy)
@@ -566,7 +566,7 @@
return 3;
}
} else {
- if (building_has_effect(target.value, EFT_PROD_TO_GOLD)) {
+ if (impr_flag(target.value, IF_GOLD)) {
return 1;
} else if (is_great_wonder(target.value)) {
return 4;
@@ -620,7 +620,7 @@
cost = unit_build_shield_cost(get_unit_type(target.value));
} else {
name = get_impr_name_ex(pcity, target.value);
- if (building_has_effect(target.value, EFT_PROD_TO_GOLD)) {
+ if (impr_flag(target.value, IF_GOLD)) {
cost = -1;
} else {
cost = impr_build_shield_cost(target.value);
@@ -1025,8 +1025,8 @@
{
int value = city_buy_cost(pcity);
- if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
- assert(!pcity->production.is_unit);
+ if (!pcity->production.is_unit
+ && impr_flag(pcity->production.value, IF_GOLD)) {
create_event(pcity->tile, E_BAD_COMMAND,
_("You don't buy %s in %s!"),
get_improvement_name(pcity->production.value),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#14706) Turn EFT_PROD_TO_GOLD into an improvement flag,
Vasco Alexandre da Silva Costa <=
|
|