[Freeciv-Dev] bug in cr_entry_building (PR#1289)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
I've logged this as a separate bug report, although most of it is
related to #1283 (s/999/never/ in turns-to-build).
cr_entry_building has a bug: it checks whether the city is building
B_CAPITAL before checking to see whether or not the city is building a
unit or building (capitalization counts as a building). This means
whatever unit gets the same ID as capitalization will be shown incorrectly.
The attached patch fixes this in the process of special-casing the "999"
case as never (or in this case "-").
But really, what's up with cr_entry_building and the whole city_rep_data
file? This function is declared static and never used. It _looks_ like
it should take care of all the work for a city report entry, but
currently there is very similar code among the different GUIs to do
this. I get the impression there is some overridding structure for
automatically generating city reports here, but it's incomplete and I
don't think the original intent is completely clear. Should the full
system be implemented? Should individual functions be made public and
used in place of the (very similar code) among the gui's?
jason
Index: client/cityrepdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrepdata.c,v
retrieving revision 1.15
diff -u -r1.15 cityrepdata.c
--- client/cityrepdata.c 2002/02/27 11:46:15 1.15
+++ client/cityrepdata.c 2002/03/01 13:43:37
@@ -141,34 +141,41 @@
static char *cr_entry_building(struct city *pcity)
{
static char buf[128];
- char *name;
- int cost, turns;
char *from_worklist =
worklist_is_empty(&pcity->worklist) ? "" :
concise_city_production ? "*" : _("(worklist)");
-
- if(pcity->currently_building==B_CAPITAL) {
+
+ 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),
pcity->shield_stock,
from_worklist);
} else {
+ int turns = city_turns_to_build(pcity, pcity->currently_building,
+ pcity->is_building_unit, TRUE);
+ char time[32], *name;
+ int cost;
+
+ if (turns < 999) {
+ snprintf(time, sizeof(time), "%d", turns);
+ } else {
+ snprintf(time, sizeof(time), "-");
+ }
+
if(pcity->is_building_unit) {
name = get_unit_type(pcity->currently_building)->name;
cost = get_unit_type(pcity->currently_building)->build_cost;
- turns = city_turns_to_build(pcity, pcity->currently_building,
- TRUE, TRUE);
} else {
name = get_impr_name_ex(pcity, pcity->currently_building);
cost = get_improvement_type(pcity->currently_building)->build_cost;
- turns = city_turns_to_build(pcity, pcity->currently_building,
- FALSE, TRUE);
}
- my_snprintf(buf, sizeof(buf), "%s (%d/%d/%d/%d)%s",
+
+ my_snprintf(buf, sizeof(buf), "%s (%d/%d/%s/%d)%s",
name,
pcity->shield_stock,
cost,
- turns,
+ time,
city_buy_cost(pcity),
from_worklist);
}
- [Freeciv-Dev] bug in cr_entry_building (PR#1289),
jdorje <=
|
|