Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] (PR#3935) remove MAX_NUM_NATIONS from gui-gtk-2.0
Home

[Freeciv-Dev] (PR#3935) remove MAX_NUM_NATIONS from gui-gtk-2.0

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3935) remove MAX_NUM_NATIONS from gui-gtk-2.0
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 4 Apr 2003 15:37:45 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This patch removes the use of MAX_NUM_NATIONS in the gtk2 client.  This
is a small step toward removing this value completely.

There may be a better way to do this; I'm not sure.

jason

Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.19
diff -u -r1.19 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 2003/04/04 15:47:47     1.19
+++ client/gui-gtk-2.0/plrdlg.c 2003/04/04 23:32:49
@@ -54,7 +54,7 @@
 static GtkWidget *players_sship_command;
 static GtkListStore *store;
 
-static GdkPixbuf *flags[MAX_NUM_NATIONS];
+static GdkPixbuf **flags;
 
 static void create_players_dialog(void);
 static void players_meet_callback(GtkMenuItem *item, gpointer data);
@@ -214,6 +214,11 @@
   int i;
   GtkAccelGroup *accel = gtk_accel_group_new();
   GtkWidget *sep, *sw;
+
+  /* The flag array is dynamically allocated, and its size may change from
+   * time to time.  (Re)allocating it when the players dialog is opened is
+   * safe, but may be wasteful. */
+  flags = fc_realloc(game.nation_count * sizeof(*flags));
 
   model_types[1] = GDK_TYPE_PIXBUF;
   model_types[COLOR_COLUMN] = GDK_TYPE_COLOR;

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