<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39385 >

I've a different patch against trunk.  The documentation in comments on
how to add are wrong.  I shuffled the fields a bit.  To make up for the
extra space, I turned off the governor field default.

This doesn't show costs larger than 9999 (the previous patch had a bug
in that the field was declared as only 3 wide, but had no check).  In my
test with 7 wonders building, I didn't need more than that.

Index: client/cityrepdata.c
===================================================================
--- client/cityrepdata.c        (revision 12975)
+++ client/cityrepdata.c        (working copy)
@@ -362,21 +362,13 @@
        
   if (!pcity->production.is_unit
       && impr_flag(pcity->production.value, IF_GOLD)) {
-    my_snprintf(buf, sizeof(buf), "%s (%d/X/X/X)%s",
+    my_snprintf(buf, sizeof(buf), "%s (%d/X)%s",
                get_impr_name_ex(pcity, pcity->production.value),
                MAX(0, pcity->surplus[O_SHIELD]), from_worklist);
   } else {
-    int turns = city_turns_to_build(pcity, pcity->production, TRUE);
-    char time[32];
     const char *name;
     int cost;
 
-    if (turns < 999) {
-      my_snprintf(time, sizeof(time), "%d", turns);
-    } else {
-      my_snprintf(time, sizeof(time), "-");
-    }
-
     if(pcity->production.is_unit) {
       name = get_unit_type(pcity->production.value)->name;
       cost = unit_build_shield_cost(get_unit_type(pcity->production.value));
@@ -385,14 +377,42 @@
       cost = impr_build_shield_cost(pcity->production.value);
     }
 
-    my_snprintf(buf, sizeof(buf), "%s (%d/%d/%s/%d)%s", name,
-               pcity->shield_stock, cost, time, city_buy_cost(pcity),
+    my_snprintf(buf, sizeof(buf), "%s (%d/%d)%s", name,
+               pcity->shield_stock, cost,
                from_worklist);
   }
 
   return buf;
 }
 
+static const char *cr_entry_build_turns(const struct city *pcity,
+                                 const void *data)
+{
+  int turns = city_turns_to_build(pcity, pcity->production, TRUE);
+  static char buf[8];
+
+  if (turns < 9999) {
+    my_snprintf(buf, sizeof(buf), "%4d", turns);
+  } else {
+    my_snprintf(buf, sizeof(buf), "-");
+  }
+  return buf;
+}
+
+static const char *cr_entry_buy_cost(const struct city *pcity,
+                                 const void *data)
+{
+  int price = city_buy_cost(pcity);
+  static char buf[8];
+
+  if (price < 9999) {
+    my_snprintf(buf, sizeof(buf), "%4d", price);
+  } else {
+    my_snprintf(buf, sizeof(buf), "-");
+  }
+  return buf;
+}
+
 static const char *cr_entry_corruption(const struct city *pcity,
                                       const void *data)
 {
@@ -417,7 +437,6 @@
 
 /* City report options (which columns get shown)
  * To add a new entry, you should just have to:
- * - increment NUM_CREPORT_COLS in cityrepdata.h
  * - add a function like those above
  * - add an entry in the city_report_specs[] table
  */
@@ -454,12 +473,17 @@
     N_("Best attacking units"), NULL, FUNC_TAG(attack)},
   { FALSE, 8, 1, N_("Best"), N_("defense"),
     N_("Best defending units"), NULL, FUNC_TAG(defense)},
-  { FALSE, 2, 1, N_("Units"), N_("?Supported (units):Sup"),
+  { FALSE,  2, 1, N_("Units"), N_("?Present (units):Here"),
+    N_("Number of units present"), NULL, FUNC_TAG(present) },
+  { FALSE,  2, 1, N_("Units"), N_("?Supported (units):Home"),
     N_("Number of units supported"), NULL, FUNC_TAG(supported) },
-  { FALSE, 2, 1, N_("Units"), N_("?Present (units):Prs"),
-    N_("Number of units present"), NULL, FUNC_TAG(present) },
 
-  { TRUE,  10, 1, N_("Surplus"), N_("?food/prod/trade:F/P/T"),
+  { TRUE,   4, 1, NULL, N_("?turn:Grow"), N_("Turns until growth/famine"),
+    NULL, FUNC_TAG(growturns) },
+  { TRUE,   7, 1, N_("Food"), N_("Stock"), N_("Food Stock"),
+    NULL, FUNC_TAG(food) },
+
+  { TRUE,  10, 1, N_("Surplus"), N_("?food/production/trade:F/P/T"),
                                  N_("Surplus: Food, Production, Trade"),
     NULL, FUNC_TAG(resources) },
   { FALSE, 3, 1, NULL, N_("?Food surplus:F+"), N_("Surplus: Food"),
@@ -468,7 +492,12 @@
     N_("Surplus: Production"), NULL, FUNC_TAG(prodplus) },
   { FALSE, 3, 1, NULL, N_("?Trade surplus:T+"), N_("Surplus: Trade"),
     NULL, FUNC_TAG(tradeplus) },
-  { TRUE,  10, 1, N_("Economy"), N_("?gold/lux/sci:G/L/S"),
+  { FALSE,  3, 1, NULL, N_("?corruption:T-"), N_("Corruption"),
+    NULL, FUNC_TAG(corruption) },
+  { FALSE,  3, 1, NULL, N_("?waste:P-"), N_("Waste"),
+    NULL, FUNC_TAG(waste) },
+
+  { TRUE,  10, 1, N_("Economy"), N_("?gold/luxury/science:G/L/S"),
                                  N_("Economy: Gold, Luxuries, Science"),
     NULL, FUNC_TAG(output) },
   { FALSE, 3, 1, NULL, N_("?Gold:G"), N_("Economy: Gold"),
@@ -480,19 +509,16 @@
   { FALSE,  1, 1, N_("?trade_routes:n"), N_("?trade_routes:T"),
                                          N_("Number of Trade Routes"),
     NULL, FUNC_TAG(num_trade) },
-  { TRUE,   7, 1, N_("Food"), N_("Stock"), N_("Food Stock"),
-    NULL, FUNC_TAG(food) },
-  { FALSE,  3, 1, NULL, N_("?pollution:Pol"),        N_("Pollution"),
+  { FALSE,  3, 1, NULL, N_("?pollution:Pol"), N_("Pollution"),
     NULL, FUNC_TAG(pollution) },
-  { FALSE,  4, 1, N_("Grow"), N_("Turns"), N_("Turns until growth/famine"),
-    NULL, FUNC_TAG(growturns) },
-  { FALSE,  3, 1, NULL, N_("?corruption:Cor"),        N_("Corruption"),
-    NULL, FUNC_TAG(corruption) },
-  { FALSE,  3, 1, NULL, N_("?waste:Was"), N_("Waste"),
-    NULL, FUNC_TAG(waste) },
-  { TRUE,  15, 1, NULL, N_("?cma:Governor"),         N_("Citizen Governor"),
+  { FALSE, 15, 1, NULL, N_("?cma:Governor"), N_("Citizen Governor"),
     NULL, FUNC_TAG(cma) },
-  { TRUE,   0, 1, N_("Currently Building"), N_("(Stock,Target,Turns,Buy)"),
+
+  { TRUE,   4, 1, NULL, N_("?gold:Buy"), N_("Gold to purchase building"),
+    NULL, FUNC_TAG(buy_cost) },
+  { TRUE,   4, 1, NULL, N_("?turn:Done"), N_("Turns until building complete"),
+    NULL, FUNC_TAG(build_turns) },
+  { TRUE,   0, 1, N_("Currently Building"), N_("(Stock/Target)"),
                                             N_("Currently Building"),
     NULL, FUNC_TAG(building) }
 };
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to