Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2605) XAW nation selection dialog fix
Home

[Freeciv-Dev] (PR#2605) XAW nation selection dialog fix

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2605) XAW nation selection dialog fix
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Wed, 18 Dec 2002 00:42:48 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This patch fixes a bug in the XAW nation selection dialog, and removes
the dependency on MAX_NUM_NATIONS [1].

The bug is because the modular arithmetic is reversed.  This means any
time there are more leaders in a nation than MAX_NUM_NATIONS, the dialog
will break.

[1] Is it true that changing MAX_NUM_NATIONS requires a manditory
capability?

jason


Index: client//gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.74
diff -u -r1.74 dialogs.c
--- client//gui-xaw/dialogs.c   2002/12/14 01:13:17     1.74
+++ client//gui-xaw/dialogs.c   2002/12/18 08:39:30
@@ -2183,6 +2183,9 @@
   }
 }
 
+/* We store this value locally in case it changes globally. */
+static int nation_count;
+
 /**************************************************************************
 ...
 **************************************************************************/
@@ -2205,6 +2208,8 @@
                         races_leader_pick_menubutton,
                         NULL);
 
+  nation_count = game.nation_count;
+
   for(j=0; j<leader_count; j++) {
     entry =
       XtVaCreateManagedWidget(leaders[j],
@@ -2212,7 +2217,7 @@
                              races_leader_pick_popupmenu,
                              NULL);
     XtAddCallback(entry, XtNcallback, races_leader_pick_callback,
-                 INT_TO_XTPOINTER(MAX_NUM_NATIONS * race + j));
+                 INT_TO_XTPOINTER(nation_count * j + race));
   }
 
   races_leader_set_values(race, myrand(leader_count));
@@ -2229,8 +2234,8 @@
 void races_leader_pick_callback(Widget w, XtPointer client_data,
                                XtPointer call_data)
 {
-  int race = XTPOINTER_TO_INT(client_data) / MAX_NUM_NATIONS;
-  int lead = XTPOINTER_TO_INT(client_data) - (MAX_NUM_NATIONS * race);
+  int lead = XTPOINTER_TO_INT(client_data) / nation_count;
+  int race = XTPOINTER_TO_INT(client_data) - (nation_count * lead);
 
   races_leader_set_values(race, lead);
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2605) XAW nation selection dialog fix, Jason Short via RT <=