[Freeciv-Dev] (PR#4437) Gold upkeep
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[remi - Wed Sep 17 16:33:50 2003]:
> Here is the patch. You probably need to find graphical stuff far away
> from me unless you want ugly dollar signs ;-p. But i promise i'm
> learning how to create decent graphism...
Re-updated...
Remi
diff -u -r -Xdiff_ignore ../freeciv/client/gui-gtk/mapview.c
./client/gui-gtk/mapview.c
--- ../freeciv/client/gui-gtk/mapview.c 2003-10-02 15:11:09.000000000 +0200
+++ ./client/gui-gtk/mapview.c 2003-10-06 20:06:45.000000000 +0200
@@ -816,25 +816,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 ../freeciv/client/gui-gtk/repodlgs.c
./client/gui-gtk/repodlgs.c
--- ../freeciv/client/gui-gtk/repodlgs.c 2003-09-16 17:23:40.000000000
+0200
+++ ./client/gui-gtk/repodlgs.c 2003-10-06 20:06:45.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;
@@ -664,14 +670,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());
+ }
}
/****************************************************************
@@ -696,35 +707,66 @@
*****************************************************************/
void economy_selloff_callback(GtkWidget *w, gpointer data)
{
- int i,count=0,gold=0;
+ int count = 0, gold = 0;
+ struct economy_row row_type;
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];
-
- 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);
- city_sell_improvement(pcity, i);
+ 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));
+ }
}
- } 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);
+
+ gtk_clist_unselect_row(GTK_CLIST(economy_list), row, 0);
+ popup_notify_dialog(_("Sell-Off:"),_("Results"), str);
+
}
return;
}
@@ -734,9 +776,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];
@@ -744,6 +788,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));
@@ -765,7 +810,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),
@@ -783,7 +847,7 @@
****************************************************************/
-#define AU_COL 6
+#define AU_COL 7
/****************************************************************
...
@@ -825,7 +889,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();
@@ -983,7 +1047,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;
@@ -1008,6 +1072,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;
@@ -1029,6 +1094,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 );
@@ -1037,17 +1103,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 ../freeciv/client/gui-gtk-2.0/mapview.c
./client/gui-gtk-2.0/mapview.c
--- ../freeciv/client/gui-gtk-2.0/mapview.c 2003-10-02 15:11:09.000000000
+0200
+++ ./client/gui-gtk-2.0/mapview.c 2003-10-06 20:06:45.000000000 +0200
@@ -900,13 +900,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);
@@ -916,6 +917,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 ../freeciv/client/gui-gtk-2.0/repodlgs.c
./client/gui-gtk-2.0/repodlgs.c
--- ../freeciv/client/gui-gtk-2.0/repodlgs.c 2003-09-16 17:23:40.000000000
+0200
+++ ./client/gui-gtk-2.0/repodlgs.c 2003-10-06 20:06:45.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;
@@ -702,17 +707,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);
@@ -725,7 +735,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;
gint row;
GtkWidget *shell;
@@ -737,28 +747,60 @@
/* 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) )) {
- count++; gold+=improvement_value(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);
city_sell_improvement(pcity, i);
- }
- } city_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,
- _("Sold %d %s for %d gold"), count, get_improvement_name(i), gold);
+ 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),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+ _("No %s could be sold"),
+ get_improvement_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 sold"), get_improvement_name(i));
+ 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"));
@@ -771,9 +813,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, };
@@ -794,7 +837,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),
@@ -809,7 +873,7 @@
****************************************************************/
-#define AU_COL 6
+#define AU_COL 7
/****************************************************************
...
@@ -878,7 +942,8 @@
N_("In-Prog"),
N_("Active"),
N_("Shield"),
- N_("Food")
+ N_("Food"),
+ N_("Gold")
};
static bool titles_done;
int i;
@@ -890,6 +955,7 @@
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
+ G_TYPE_INT,
G_TYPE_BOOLEAN
};
GtkWidget *view, *sw;
@@ -1067,7 +1133,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;
};
@@ -1089,6 +1155,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;
@@ -1113,7 +1180,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);
@@ -1124,6 +1192,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;
@@ -1135,7 +1204,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);
@@ -1148,7 +1218,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 ../freeciv/client/repodlgs_common.c
./client/repodlgs_common.c
--- ../freeciv/client/repodlgs_common.c 2003-04-04 17:47:46.000000000 +0200
+++ ./client/repodlgs_common.c 2003-10-06 20:06:45.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 ../freeciv/client/repodlgs_common.h
./client/repodlgs_common.h
--- ../freeciv/client/repodlgs_common.h 2003-07-29 17:16:31.000000000 +0200
+++ ./client/repodlgs_common.h 2003-10-06 20:06:45.000000000 +0200
@@ -15,6 +15,7 @@
#define FC__REPODLGS_COMMON_H
#include "improvement.h"
+#include "unittype.h"
#include "citydlg_common.h" /* for city request functions */
@@ -24,9 +25,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 ../freeciv/client/tilespec.c ./client/tilespec.c
--- ../freeciv/client/tilespec.c 2003-10-02 15:11:09.000000000 +0200
+++ ./client/tilespec.c 2003-10-06 20:06:45.000000000 +0200
@@ -935,6 +935,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 ../freeciv/client/tilespec.h ./client/tilespec.h
--- ../freeciv/client/tilespec.h 2003-08-12 20:54:37.000000000 +0200
+++ ./client/tilespec.h 2003-10-06 20:06:45.000000000 +0200
@@ -167,6 +167,7 @@
struct Sprite
*food[2],
*unhappy[2],
+ *gold[2],
*shield;
} upkeep;
struct {
diff -u -r -Xdiff_ignore ../freeciv/data/isotrident/tiles.spec
./data/isotrident/tiles.spec
--- ../freeciv/data/isotrident/tiles.spec 2002-05-02 07:47:05.000000000
+0200
+++ ./data/isotrident/tiles.spec 2003-10-06 20:06:45.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] |
- [Freeciv-Dev] (PR#4437) Gold upkeep,
Remi Bonnet <=
|
|