Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7316) Remove government knowledge from clients
Home

[Freeciv-Dev] (PR#7316) Remove government knowledge from clients

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: i-freeciv-lists@xxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7316) Remove government knowledge from clients
From: "Guest" <rt-guest@xxxxxxxxxxx>
Date: Tue, 3 Feb 2004 03:42:00 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7316 >

 
There's a problem with this patch.  
 
popup_government_dialog is given a list without anarchy  
and uses i as an index into it. It then uses i as an 
index into the full government list.  
 
This causes an off-by-one error, so when I click on 
Democracy I get Republic.  
 
 
-void popup_government_dialog(void) 
+void popup_government_dialog(int governments, 
+                            struct government **government) 
 { 
-  int num, i, j; 
+  int i; 
   struct button_descr *buttons; 
 
   if (government_dialog_is_open) { 
     return; 
   } 
 
-  assert(game.government_when_anarchy >= 0 
-        && game.government_when_anarchy < 
game.government_count); 
-  num = game.government_count - 1; 
+  buttons = fc_malloc(sizeof(struct button_descr) * 
governments); 
 
-  buttons = fc_malloc(sizeof(struct button_descr) * 
num); 
- 
-  j = 0; 
-  for (i = 0; i < game.government_count; i++) { 
-    struct government *g = &governments[i]; 
- 
-    if (i == game.government_when_anarchy) { 
-      continue; 
-    } 
- 
-    buttons[j].text = g->name; 
-    buttons[j].callback = government_callback; 
-    buttons[j].data = GINT_TO_POINTER(i); 
-    buttons[j].sensitive = 
can_change_to_government(game.player_ptr, i); 
-    j++; 
+  for (i = 0; i < governments; i++) { 
+    buttons[i].text = government[i]->name; 
 
Here the button is labelled by government[i] 
 
+    buttons[i].callback = government_callback; 
+    buttons[i].data = GINT_TO_POINTER(i); 
 
but if the user chooses it, they get governments[i] 
 
+    buttons[i].sensitive = 
can_change_to_government(game.player_ptr, i); 
 
And the button is enabled if player can change to 
governments[i] 
 
   } 
 
   government_dialog_is_open = TRUE; 
   base_popup_message_dialog(top_vbox, _("Choose Your 
New Government"), 
                            _("Select government type:"), 
NULL, NULL, 
-                           num, buttons); 
+                           governments, buttons); 
 } 
 
 
David  


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7316) Remove government knowledge from clients, Guest <=