Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4437) Gold upkeep (v2)
Home

[Freeciv-Dev] Re: (PR#4437) Gold upkeep (v2)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#4437) Gold upkeep (v2)
From: "remi.bonnet@xxxxxxxxxxx" <remi.bonnet@xxxxxxxxxxx>
Date: Mon, 21 Jul 2003 07:30:42 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Per I. Mathisen a écrit :

>and the gtk2 client (which is now the default client) must be supported.
>
This patch supports it.

Remi

diff -u -r -Xdiff_ignore ./client/gui-gtk/mapview.c 
../freeciv-gold/client/gui-gtk/mapview.c
--- ./client/gui-gtk/mapview.c  2003-07-21 09:30:39.000000000 +0200
+++ ../freeciv-gold/client/gui-gtk/mapview.c    2003-07-21 15:52:03.000000000 
+0200
@@ -821,25 +821,34 @@
   gtk_pixcomm_changed(GTK_PIXCOMM(p));
 }
 
-
 /**************************************************************************
-  FIXME:
-  For now only two food, one shield and two masks can be drawn per unit,
-  the proper way to do this is probably something like what Civ II does.
-  (One food/shield/mask drawn N times, possibly one top of itself. -- SKi 
+  FIXME: For now only two food, two golds, one shield and two masks can be 
+  drawn per unit, the proper way to do this is probably something like 
+  what Civ II does. (One food/shield/mask drawn N times, possibly one top 
+  of itself.)
 **************************************************************************/
 void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p)
 {
   int upkeep_food = CLIP(0, punit->upkeep_food, 2);
+  int upkeep_gold = CLIP(0, punit->upkeep_gold, 2);
   int unhappy = CLIP(0, punit->unhappiness, 2);
  
   /* draw overlay pixmaps */
-  if (punit->upkeep > 0)
+  if (punit->upkeep > 0) {
     put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, sprites.upkeep.shield);
-  if (upkeep_food > 0)
-    put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
sprites.upkeep.food[upkeep_food-1]);
-  if (unhappy > 0)
-    put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
sprites.upkeep.unhappy[unhappy-1]);
+  }
+  if (upkeep_food > 0) {
+    put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
+                             sprites.upkeep.food[upkeep_food-1]);
+  }
+  if (upkeep_gold > 0) {
+    put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
+                             sprites.upkeep.gold[upkeep_gold - 1]);
+  }
+  if (unhappy > 0) {
+    put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
+                             sprites.upkeep.unhappy[unhappy-1]);
+  }
 }
 
 /**************************************************************************
diff -u -r -Xdiff_ignore ./client/gui-gtk/repodlgs.c 
../freeciv-gold/client/gui-gtk/repodlgs.c
--- ./client/gui-gtk/repodlgs.c 2003-07-19 11:11:19.000000000 +0200
+++ ../freeciv-gold/client/gui-gtk/repodlgs.c   2003-07-21 15:52:03.000000000 
+0200
@@ -33,6 +33,7 @@
 #include "civclient.h"
 #include "clinet.h"
 #include "repodlgs_common.h"
+#include "control.h"
 
 #include "cityrep.h"
 #include "dialogs.h"
@@ -67,7 +68,12 @@
 static void economy_selloff_callback(GtkWidget * w, gpointer data);
 static void economy_list_callback(GtkWidget * w, gint row, gint column);
 static void economy_list_ucallback(GtkWidget * w, gint row, gint column);
-static int economy_improvement_type[B_LAST];
+
+struct economy_row {
+  int is_impr;
+  int type;
+};
+static struct economy_row economy_row_type[U_LAST + B_LAST];
 
 static GtkWidget *economy_dialog_shell = NULL;
 static GtkWidget *economy_label2;
@@ -653,14 +659,19 @@
 *****************************************************************/
 void economy_list_callback(GtkWidget *w, gint row, gint column)
 {
-  int i = economy_improvement_type[row];
-  bool is_sellable = (i >= 0 && i < game.num_impr_types && !is_wonder(i));
+  int i = economy_row_type[row].type;
+  
+  if (economy_row_type[row].is_impr == TRUE) {
+    bool is_sellable = (i >= 0 && i < game.num_impr_types && !is_wonder(i));
 
-  gtk_widget_set_sensitive(sellobsolete_command, is_sellable
-                          && can_client_issue_orders()
-                          && improvement_obsolete(game.player_ptr, i));
-  gtk_widget_set_sensitive(sellall_command, is_sellable
-                          && can_client_issue_orders());
+    gtk_widget_set_sensitive(sellobsolete_command, is_sellable
+                            && can_client_issue_orders()
+                            && improvement_obsolete(game.player_ptr, i));
+    gtk_widget_set_sensitive(sellall_command, is_sellable
+                            && can_client_issue_orders());
+  } else {
+    gtk_widget_set_sensitive(sellall_command, can_client_issue_orders());
+  }
 }
 
 /****************************************************************
@@ -685,38 +696,67 @@
 *****************************************************************/
 void economy_selloff_callback(GtkWidget *w, gpointer data)
 {
-  int i,count=0,gold=0;
+  int count = 0, gold = 0;
+  struct economy_row row_type;
   struct packet_city_request packet;
   char str[64];
-  GList              *selection;
-  gint                row;
+  GList *selection;
+  int row;
 
   while ((selection = GTK_CLIST(economy_list)->selection)) {
     row = GPOINTER_TO_INT(selection->data);
 
-  i=economy_improvement_type[row];
+    row_type = economy_row_type[row];
+
+    if (row_type.is_impr == TRUE) {
+      city_list_iterate(game.player_ptr->cities, pcity) {
+        if (!pcity->did_sell && city_got_building(pcity, row_type.type)
+            && (data
+               || improvement_obsolete(game.player_ptr, row_type.type)
+                || wonder_replacement(pcity, row_type.type))) {
+         count++;
+          gold += improvement_value(row_type.type);
+         packet.city_id = pcity->id;
+         packet.build_id = row_type.type;
+         send_packet_city_request(&aconnection, &packet, PACKET_CITY_SELL);
+       }
+      } city_list_iterate_end;
+
+      if (count) {
+       my_snprintf(str, sizeof(str), _("Sold %d %s for %d gold"),
+                   count, get_improvement_name(row_type.type), gold);
+      } else {
+       my_snprintf(str, sizeof(str), _("No %s could be sold"),
+               get_improvement_name(row_type.type));
+      }
+    } else {
+      /* With this code only units supported by cities will be disbanded
+       * That's like this because it is a non-sense of selling units with
+       * no upkeep */
+      city_list_iterate(game.player_ptr->cities, pcity) {
+       unit_list_iterate(pcity->units_supported, punit) {
+         /* We don't sell obsolete units when sell obsolete is clicked. 
+          * Indeed, unlike improvements, obsolete units can fight like
+           * up-to-date ones */
+         if (punit->type == row_type.type && data) {
+           count++;
+           request_unit_disband(punit);
+         }
+       } unit_list_iterate_end;
+      } city_list_iterate_end;
+
+      if (count > 0) {
+       my_snprintf(str, sizeof(str), "Disbanded %d %s", count,
+                   unit_name(row_type.type));
+      } else {
+       my_snprintf(str, sizeof(str), "No %s could be disbanded", 
+                   unit_name(row_type.type));
+      }
+    }
+
+    gtk_clist_unselect_row(GTK_CLIST(economy_list), row, 0);
+    popup_notify_dialog(_("Sell-Off:"),_("Results"), str);
 
-  city_list_iterate(game.player_ptr->cities, pcity) {
-    if(!pcity->did_sell && city_got_building(pcity, i) && 
-       (data ||
-       improvement_obsolete(game.player_ptr,i) ||
-        wonder_replacement(pcity, i) ))  {
-       count++; gold+=improvement_value(i);
-        packet.city_id=pcity->id;
-        packet.build_id=i;
-        send_packet_city_request(&aconnection, &packet, PACKET_CITY_SELL);
-    }
-  } city_list_iterate_end;
-
-  if(count)  {
-    my_snprintf(str, sizeof(str), _("Sold %d %s for %d gold"),
-               count, get_improvement_name(i), gold);
-  } else {
-    my_snprintf(str, sizeof(str), _("No %s could be sold"),
-               get_improvement_name(i));
-  }
-  gtk_clist_unselect_row(GTK_CLIST(economy_list),row,0);
-  popup_notify_dialog(_("Sell-Off:"),_("Results"),str);
   }
   return;
 }
@@ -726,9 +766,11 @@
 *****************************************************************/
 void economy_report_dialog_update(void)
 {
-  if(is_report_dialogs_frozen()) return;
-  if(economy_dialog_shell) {
-    int tax, total, i, entries_used;
+  if (is_report_dialogs_frozen()) {
+    return;
+  }
+  if (economy_dialog_shell) {
+    int tax, total, i, entries_used, nbr_impr;
     char   buf0 [64];
     char   buf1 [64];
     char   buf2 [64];
@@ -736,6 +778,7 @@
     gchar *row  [4];
     char economy_total[48];
     struct improvement_entry entries[B_LAST];
+    struct unit_entry entries_units[U_LAST];
 
     gtk_clist_freeze(GTK_CLIST(economy_list));
     gtk_clist_clear(GTK_CLIST(economy_list));
@@ -757,7 +800,26 @@
 
       gtk_clist_append(GTK_CLIST(economy_list), row);
 
-      economy_improvement_type[i] = p->type;
+      economy_row_type[i].is_impr = TRUE;
+      economy_row_type[i].type = p->type;
+    }
+
+    nbr_impr = entries_used;
+    entries_used = 0;
+    get_economy_report_units_data(entries_units, &entries_used, &total);
+
+    for (i = 0; i < entries_used; i++) {
+      my_snprintf(buf0, sizeof(buf0), "%-20s",
+                 unit_name(entries_units[i].type));
+      my_snprintf(buf1, sizeof(buf1), "%5d", entries_units[i].count);
+      my_snprintf(buf2, sizeof(buf2), "%5d", entries_units[i].cost);
+      my_snprintf(buf3, sizeof(buf3), "%6d", entries_units[i].total_cost);
+
+      gtk_clist_append(GTK_CLIST(economy_list), row);
+
+      economy_row_type[i + nbr_impr].is_impr = FALSE;
+      economy_row_type[i + nbr_impr].type = entries_units[i].type;
+      
     }
 
     my_snprintf(economy_total, sizeof(economy_total),
@@ -775,7 +837,7 @@
  
 ****************************************************************/
 
-#define AU_COL 6
+#define AU_COL 7
 
 /****************************************************************
 ...
@@ -817,7 +879,7 @@
   GtkWidget *close_command, *refresh_command;
   static const char *titles_[AU_COL]
     = { N_("Unit Type"), N_("U"), N_("In-Prog"), N_("Active"),
-       N_("Shield"), N_("Food") };
+       N_("Shield"), N_("Food"), N_("Gold") };
   static gchar **titles;
   int    i;
   GtkAccelGroup *accel=gtk_accel_group_new();
@@ -975,7 +1037,7 @@
     int active_count;
     int upkeep_shield;
     int upkeep_food;
-    /* int upkeep_gold;   FIXME: add gold when gold is implemented --jjm */
+    int upkeep_gold;   
     int building_count;
   };
   if(is_report_dialogs_frozen()) return;
@@ -1000,6 +1062,7 @@
       if (punit->homecity) {
        unitarray[punit->type].upkeep_shield += punit->upkeep;
        unitarray[punit->type].upkeep_food += punit->upkeep_food;
+       unitarray[punit->type].upkeep_gold += punit->upkeep_gold;
       }
     }
     unit_list_iterate_end;
@@ -1021,6 +1084,7 @@
         my_snprintf(buf[3], sizeof(buf[3]), "%9d", unitarray[i].active_count);
         my_snprintf(buf[4], sizeof(buf[4]), "%9d", unitarray[i].upkeep_shield);
         my_snprintf(buf[5], sizeof(buf[5]), "%9d", unitarray[i].upkeep_food);
+       my_snprintf(buf[6], sizeof(buf[6]), "%9d", unitarray[i].upkeep_gold);
 
        gtk_clist_append( GTK_CLIST( activeunits_list ), row );
 
@@ -1029,17 +1093,19 @@
        unittotals.active_count += unitarray[i].active_count;
        unittotals.upkeep_shield += unitarray[i].upkeep_shield;
        unittotals.upkeep_food += unitarray[i].upkeep_food;
+       unittotals.upkeep_gold += unitarray[i].upkeep_gold;
        unittotals.building_count += unitarray[i].building_count;
       }
     } unit_type_iterate_end;
 
     /* horrible kluge, but I can't get gtk_label_set_justify() to work --jjm */
     my_snprintf(activeunits_total, sizeof(activeunits_total),
-           _("Totals:                     %s%9d%s%9d%s%9d%s%9d"),
+           _("Totals:                     %s%9d%s%9d%s%9d%s%9d%s%9d"),
            "        ", unittotals.building_count,
            " ", unittotals.active_count,
            " ", unittotals.upkeep_shield,
-           " ", unittotals.upkeep_food);
+           " ", unittotals.upkeep_food,
+           " ", unittotals.upkeep_gold);
     gtk_set_label(activeunits_label2, activeunits_total); 
 
     gtk_widget_show_all(activeunits_list);
diff -u -r -Xdiff_ignore ./client/gui-gtk-2.0/mapview.c 
../freeciv-gold/client/gui-gtk-2.0/mapview.c
--- ./client/gui-gtk-2.0/mapview.c      2003-07-21 09:30:39.000000000 +0200
+++ ../freeciv-gold/client/gui-gtk-2.0/mapview.c        2003-07-21 
15:55:33.000000000 +0200
@@ -905,13 +905,14 @@
 
 /**************************************************************************
   FIXME:
-  For now only two food, one shield and two masks can be drawn per unit,
-  the proper way to do this is probably something like what Civ II does.
+  For now only two food, two gold one shield and two masks can be drawn per
+  unit, the proper way to do this is probably something like what Civ II does.
   (One food/shield/mask drawn N times, possibly one top of itself. -- SKi 
 **************************************************************************/
 void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p)
 {
   int upkeep_food = CLIP(0, punit->upkeep_food, 2);
+  int upkeep_gold = CLIP(0, punit->upkeep_gold, 2);
   int unhappy = CLIP(0, punit->unhappiness, 2);
  
   gtk_pixcomm_freeze(p);
@@ -921,6 +922,8 @@
     put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, sprites.upkeep.shield);
   if (upkeep_food > 0)
     put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
sprites.upkeep.food[upkeep_food-1]);
+  if (upkeep_gold > 0)
+    put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
sprites.upkeep.gold[upkeep_gold-1]);
   if (unhappy > 0)
     put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, 
sprites.upkeep.unhappy[unhappy-1]);
 
diff -u -r -Xdiff_ignore ./client/gui-gtk-2.0/repodlgs.c 
../freeciv-gold/client/gui-gtk-2.0/repodlgs.c
--- ./client/gui-gtk-2.0/repodlgs.c     2003-07-19 11:11:19.000000000 +0200
+++ ../freeciv-gold/client/gui-gtk-2.0/repodlgs.c       2003-07-21 
15:52:03.000000000 +0200
@@ -38,6 +38,7 @@
 #include "gui_stuff.h"
 #include "helpdlg.h"
 #include "options.h"
+#include "control.h"
 
 #include "repodlgs_common.h"
 #include "repodlgs.h"
@@ -64,7 +65,11 @@
 static void economy_command_callback(GtkWidget *w, gint response_id);
 static void economy_selection_callback(GtkTreeSelection *selection,
                                       gpointer data);
-static int economy_improvement_type[B_LAST];
+struct economy_row {
+  int is_impr;
+  int type;
+};
+static struct economy_row economy_row_type[U_LAST + B_LAST];
 
 static GtkWidget *economy_dialog_shell = NULL;
 static GtkWidget *economy_label2;
@@ -691,17 +696,22 @@
                                       gpointer data)
 {
   gint row = gtk_tree_selection_get_row(selection);
+  int i = economy_row_type[row].type;
 
   if (row >= 0) {
-    /* The user has selected an improvement type. */
-    int i = economy_improvement_type[row];
-    bool is_sellable = (i >= 0 && i < game.num_impr_types && !is_wonder(i));
-
-    gtk_widget_set_sensitive(sellobsolete_command, is_sellable
-                            && can_client_issue_orders()
-                            && improvement_obsolete(game.player_ptr, i));
-    gtk_widget_set_sensitive(sellall_command, is_sellable
-                            && can_client_issue_orders());
+    if (economy_row_type[row].is_impr == TRUE) {
+      /* The user has selected an improvement type. */
+      bool is_sellable = (i >= 0 && i < game.num_impr_types && !is_wonder(i));
+
+      gtk_widget_set_sensitive(sellobsolete_command, is_sellable
+                              && can_client_issue_orders()
+                              && improvement_obsolete(game.player_ptr, i));
+      gtk_widget_set_sensitive(sellall_command, is_sellable
+                              && can_client_issue_orders());
+    } else {
+      /* An unit has been selected */
+      gtk_widget_set_sensitive(sellall_command, can_client_issue_orders());
+    }
   } else {
     /* No selection has been made. */
     gtk_widget_set_sensitive(sellobsolete_command, FALSE);
@@ -714,7 +724,7 @@
 *****************************************************************/
 static void economy_command_callback(GtkWidget *w, gint response_id)
 {
-  int i, count = 0, gold = 0;
+  int i, count = 0, gold = 0, is_impr;
   struct packet_city_request packet;
   gint row;
   GtkWidget *shell;
@@ -727,30 +737,59 @@
 
   /* sell obsolete and sell all. */
   row = gtk_tree_selection_get_row(economy_selection);
-  i = economy_improvement_type[row];
+  is_impr = economy_row_type[row].is_impr;
+  i = economy_row_type[row].type;
 
-  city_list_iterate(game.player_ptr->cities, pcity) {
-    if(!pcity->did_sell && city_got_building(pcity, i) && 
-       (response_id == 2 ||
-       improvement_obsolete(game.player_ptr,i) ||
-        wonder_replacement(pcity, i) ))  {
+  if (is_impr == TRUE) {
+    city_list_iterate(game.player_ptr->cities, pcity) {
+      if (!pcity->did_sell && city_got_building(pcity, i) && 
+        (response_id == 2 ||
+         improvement_obsolete(game.player_ptr,i) ||
+         wonder_replacement(pcity, i) ))  {
        count++; gold+=improvement_value(i);
         packet.city_id=pcity->id;
         packet.build_id=i;
         send_packet_city_request(&aconnection, &packet, PACKET_CITY_SELL);
-    }
-  } city_list_iterate_end;
+      }
+    } city_list_iterate_end;
 
-  if (count > 0) {
-    shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
+    if (count > 0) {
+      shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
        GTK_DIALOG_DESTROY_WITH_PARENT,
        GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
        _("Sold %d %s for %d gold"), count, get_improvement_name(i), gold);
-  } else {
-    shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
+    } else {
+      shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
        GTK_DIALOG_DESTROY_WITH_PARENT,
        GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
        _("No %s could be sold"), get_improvement_name(i));
+    }
+  } else {
+    city_list_iterate(game.player_ptr->cities, pcity) {
+      unit_list_iterate(pcity->units_supported, punit) {
+       /* We don't sell obsolete units when sell obsolete is clicked
+         * Indeed, unlike improvements, obsolete units can fight like
+        * up-to-dates ones. And they are also all obsolete at the same
+        * time so if the user want to sell them off, he can use the
+         * sell all button */
+       if (punit->type == i && response_id == 2) {
+         count++;
+         request_unit_disband(punit);
+       }
+      } unit_list_iterate_end;
+    } city_list_iterate_end;
+
+    if (count > 0) {
+      shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
+       GTK_DIALOG_DESTROY_WITH_PARENT,
+       GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+       _("Disbanded %d %s."), count, unit_name(i));
+    } else {
+      shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
+       GTK_DIALOG_DESTROY_WITH_PARENT,
+       GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+       _("No %s could be disbanded"), unit_name(i));
+    }
   }
   g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), NULL);
   gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
@@ -763,9 +802,10 @@
 void economy_report_dialog_update(void)
 {
   if(!is_report_dialogs_frozen() && economy_dialog_shell) {
-    int tax, total, i, entries_used;
+    int tax, total, i, entries_used, nbr_impr;
     char economy_total[48];
     struct improvement_entry entries[B_LAST];
+    struct unit_entry entries_units[U_LAST];
     GtkTreeIter it;
     GValue value = { 0, };
 
@@ -786,7 +826,28 @@
       gtk_list_store_set_value(economy_store, &it, 0, &value);
       g_value_unset(&value);
 
-      economy_improvement_type[i] = p->type;
+      economy_row_type[i].is_impr = TRUE;
+      economy_row_type[i].type = p->type;
+    }
+
+    nbr_impr = entries_used;
+    entries_used = 0;
+    get_economy_report_units_data(entries_units, &entries_used, &total);
+
+    for (i = 0; i < entries_used; i++) {
+      gtk_list_store_append(economy_store, &it);
+      gtk_list_store_set(economy_store, &it,
+                        1, entries_units[i].count,
+                        2, entries_units[i].cost,
+                        3, entries_units[i].total_cost,
+                        -1);
+      g_value_init(&value, G_TYPE_STRING);
+      g_value_set_static_string(&value, unit_name(entries_units[i].type));
+      gtk_list_store_set_value(economy_store, &it, 0, &value);
+      g_value_unset(&value);
+    
+      economy_row_type[i + nbr_impr].is_impr = FALSE;
+      economy_row_type[i + nbr_impr].type = entries_units[i].type;
     }
 
     my_snprintf(economy_total, sizeof(economy_total),
@@ -801,7 +862,7 @@
  
 ****************************************************************/
 
-#define AU_COL 6
+#define AU_COL 7
 
 /****************************************************************
 ...
@@ -870,7 +931,8 @@
     N_("In-Prog"),
     N_("Active"),
     N_("Shield"),
-    N_("Food")
+    N_("Food"),
+    N_("Gold")
   };
   static bool titles_done;
   int i;
@@ -882,6 +944,7 @@
     G_TYPE_INT,
     G_TYPE_INT,
     G_TYPE_INT,
+    G_TYPE_INT,
     G_TYPE_BOOLEAN
   };
   GtkWidget *view, *sw;
@@ -1059,7 +1122,7 @@
     int active_count;
     int upkeep_shield;
     int upkeep_food;
-    /* int upkeep_gold;   FIXME: add gold when gold is implemented --jjm */
+    int upkeep_gold;
     int building_count;
   };
 
@@ -1081,6 +1144,7 @@
       if (punit->homecity) {
        unitarray[punit->type].upkeep_shield += punit->upkeep;
        unitarray[punit->type].upkeep_food += punit->upkeep_food;
+       unitarray[punit->type].upkeep_gold += punit->upkeep_gold;
       }
     }
     unit_list_iterate_end;
@@ -1105,7 +1169,8 @@
                3, unitarray[i].active_count,
                4, unitarray[i].upkeep_shield,
                5, unitarray[i].upkeep_food,
-               6, TRUE, -1);
+               6, unitarray[i].upkeep_gold,
+               7, TRUE, -1);
        g_value_init(&value, G_TYPE_STRING);
        g_value_set_static_string(&value, unit_name(i));
        gtk_list_store_set_value(activeunits_store, &it, 0, &value);
@@ -1116,6 +1181,7 @@
        unittotals.active_count += unitarray[i].active_count;
        unittotals.upkeep_shield += unitarray[i].upkeep_shield;
        unittotals.upkeep_food += unitarray[i].upkeep_food;
+       unittotals.upkeep_gold += unitarray[i].upkeep_gold;
        unittotals.building_count += unitarray[i].building_count;
       }
     } unit_type_iterate_end;
@@ -1127,7 +1193,8 @@
            3, 0,
            4, 0,
            5, 0,
-           6, FALSE, -1);
+           6, 0,
+           7, FALSE, -1);
     g_value_init(&value, G_TYPE_STRING);
     g_value_set_static_string(&value, "");
     gtk_list_store_set_value(activeunits_store, &it, 0, &value);
@@ -1140,7 +1207,8 @@
            3, unittotals.active_count,
            4, unittotals.upkeep_shield,
            5, unittotals.upkeep_food,
-           6, FALSE, -1);
+           6, unittotals.upkeep_gold,
+           7, FALSE, -1);
     g_value_init(&value, G_TYPE_STRING);
     g_value_set_static_string(&value, _("Totals:"));
     gtk_list_store_set_value(activeunits_store, &it, 0, &value);
diff -u -r -Xdiff_ignore ./client/repodlgs_common.c 
../freeciv-gold/client/repodlgs_common.c
--- ./client/repodlgs_common.c  2003-04-05 07:56:48.000000000 +0200
+++ ../freeciv-gold/client/repodlgs_common.c    2003-07-21 15:52:03.000000000 
+0200
@@ -18,6 +18,7 @@
 #include <assert.h>
 
 #include "game.h"
+#include "government.h"
 
 #include "repodlgs_g.h"
 
@@ -74,6 +75,53 @@
   } city_list_iterate_end;
 }
 
+/******************************************************************
+  Returns an array of units with gold_upkeep. Number of units in 
+  the array is added to num_entries_used.
+******************************************************************/
+void get_economy_report_units_data(struct unit_entry *entries,
+                                  int *num_entries_used, int *total_cost)
+{
+  int count, cost, partial_cost;
+  struct unit_type *unittype;
+
+  unit_type_iterate(utype) {
+    unittype = get_unit_type(utype);
+    cost = utype_gold_cost(unittype, get_gov_pplayer(game.player_ptr));
+
+    if (cost == 0) {
+      continue;
+    }
+
+    count = 0;
+    partial_cost = 0;
+
+    city_list_iterate(game.player_ptr->cities, pcity) {
+      unit_list_iterate(pcity->units_supported, punit) {
+
+       if (punit->type == utype) {
+         count++;
+         partial_cost += punit->upkeep_gold;
+       }
+
+      } unit_list_iterate_end;
+    } city_list_iterate_end;
+
+    if (count == 0) {
+      continue;
+    }
+
+    (*total_cost) += partial_cost;
+
+    entries[*num_entries_used].type = utype;
+    entries[*num_entries_used].count = count;
+    entries[*num_entries_used].cost = cost;
+    entries[*num_entries_used].total_cost = partial_cost;
+    (*num_entries_used)++;
+
+  } unit_type_iterate_end;
+}
+
 static int frozen_level = 0;
 
 /******************************************************************
diff -u -r -Xdiff_ignore ./client/repodlgs_common.h 
../freeciv-gold/client/repodlgs_common.h
--- ./client/repodlgs_common.h  2002-06-27 08:32:50.000000000 +0200
+++ ../freeciv-gold/client/repodlgs_common.h    2003-07-21 15:52:03.000000000 
+0200
@@ -15,6 +15,7 @@
 #define FC__REPODLGS_COMMON_H
 
 #include "improvement.h"
+#include "unittype.h"
 
 struct improvement_entry
 {
@@ -22,9 +23,23 @@
   int count, cost, total_cost;
 };
 
+struct unit_entry
+{
+  Unit_Type_id type;
+  int count, cost, total_cost;
+};
+
 void get_economy_report_data(struct improvement_entry *entries,
                             int *num_entries_used, int *total_cost,
                             int *total_income);
+/* This function returns an array with the gold upkeeped units.
+ * FIXME: Many clients doesn't yet use this function and show also only the
+ * buildings in the economy reports 
+ * I think that there should be only one function which returns an array of
+ * char* arrays like some other common functions but that means updating all
+ * client simultaneously and I simply can't */
+void get_economy_report_units_data(struct unit_entry *entries,
+                                  int *num_entries_used, int *total_cost);
 
 void report_dialogs_freeze(void);
 void report_dialogs_thaw(void);
diff -u -r -Xdiff_ignore ./client/tilespec.c ../freeciv-gold/client/tilespec.c
--- ./client/tilespec.c 2003-07-21 09:30:41.000000000 +0200
+++ ../freeciv-gold/client/tilespec.c   2003-07-21 15:52:04.000000000 +0200
@@ -930,6 +930,8 @@
   SET_SPRITE(upkeep.food[1], "upkeep.food2");
   SET_SPRITE(upkeep.unhappy[0], "upkeep.unhappy");
   SET_SPRITE(upkeep.unhappy[1], "upkeep.unhappy2");
+  SET_SPRITE(upkeep.gold[0], "upkeep.gold");
+  SET_SPRITE(upkeep.gold[1], "upkeep.gold2");
   SET_SPRITE(upkeep.shield, "upkeep.shield");
   
   SET_SPRITE(user.attention, "user.attention");
diff -u -r -Xdiff_ignore ./client/tilespec.h ../freeciv-gold/client/tilespec.h
--- ./client/tilespec.h 2003-07-19 11:11:32.000000000 +0200
+++ ../freeciv-gold/client/tilespec.h   2003-07-21 15:52:04.000000000 +0200
@@ -158,6 +158,7 @@
     struct Sprite
       *food[2],
       *unhappy[2],
+      *gold[2],
       *shield;
   } upkeep;
   struct {
diff -u -r -Xdiff_ignore ./data/isotrident/tiles.spec 
../freeciv-gold/data/isotrident/tiles.spec
--- ./data/isotrident/tiles.spec        2002-05-02 07:47:05.000000000 +0200
+++ ../freeciv-gold/data/isotrident/tiles.spec  2003-07-21 15:52:04.000000000 
+0200
@@ -123,6 +123,8 @@
   7, 16, "upkeep.food2"
   7, 17, "upkeep.unhappy"
   7, 18, "upkeep.unhappy2"
+  8, 17, "upkeep.gold"
+  8, 18, "upkeep.gold2"
   7, 19, "upkeep.shield"
 
 ; Nuclear explosion: this could maybe now be handled as one 

[Prev in Thread] Current Thread [Next in Thread]