Complete.Org: Mailing Lists: Archives: freeciv-dev: January 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: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7316) Remove government knowledge from clients
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sun, 25 Jan 2004 08:03:12 -0800
Reply-to: rt@xxxxxxxxxxx

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


The clients know too much. Especially that you can't change to
anarchy. This doesn't have to be duplicated over all clients.

I have tested gtk1 and xaw. I have changed gtk2 but didn't compile it.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "From what I am reading Win98 and NT5.0 will be getting rid of all that
  crap anyway. Seems that Microsoft has invented something called TCP/IP and
  another really revolutionary concept called DNS that eliminates the
  netbios crap too. All that arping from browsers is going to go away.
  I also hear rumors that they are on the verge of breakthrough discoveries
  called NFS, and LPD too. Given enough time and money, they might
  eventually invent Unix."
    -- George Bonser in linux-kernel

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.345
diff -u -u -r1.345 packhand.c
--- client/packhand.c   2004/01/20 21:52:07     1.345
+++ client/packhand.c   2004/01/25 15:46:17
@@ -1440,7 +1440,23 @@
 
     government_selected = FALSE;
   } else if (!client_is_observer()) {
-    popup_government_dialog();
+    int i = 0, governments = game.government_count - 1;
+    struct government **government =
+       fc_malloc(sizeof(*government) * governments);
+
+    assert(game.government_when_anarchy >= 0
+          && game.government_when_anarchy < game.government_count);
+
+    government_iterate(g) {
+      if (g->index != game.government_when_anarchy) {
+       government[i] = g;
+       i++;
+      }
+    } government_iterate_end;
+
+    popup_government_dialog(governments, government);
+
+    free(government);
   }
 }
 
Index: client/gui-gtk/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/dialogs.c,v
retrieving revision 1.133
diff -u -u -r1.133 dialogs.c
--- client/gui-gtk/dialogs.c    2004/01/12 16:59:16     1.133
+++ client/gui-gtk/dialogs.c    2004/01/25 15:46:19
@@ -1188,40 +1188,29 @@
 /****************************************************************
 ...
 *****************************************************************/
-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;
+    buttons[i].callback = government_callback;
+    buttons[i].data = GINT_TO_POINTER(i);
+    buttons[i].sensitive = can_change_to_government(game.player_ptr, 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);
 }
 
 /****************************************************************
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.57
diff -u -u -r1.57 dialogs.c
--- client/gui-gtk-2.0/dialogs.c        2004/01/12 16:59:16     1.57
+++ client/gui-gtk-2.0/dialogs.c        2004/01/25 15:46:21
@@ -1062,7 +1062,8 @@
 /****************************************************************
 ...
 *****************************************************************/
-void popup_government_dialog(void)
+void popup_government_dialog(int governments,
+                            struct government **government)
 {
   int i;
   GtkWidget *dshell, *dlabel, *vbox;
@@ -1092,50 +1093,38 @@
     gtk_container_add(GTK_CONTAINER(dlabel), vbox);
     gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
 
-    for (i = 0; i < game.government_count; i++) {
-      struct government *g = &governments[i];
-
-      if (i != game.government_when_anarchy) {
-        GtkWidget *label, *image, *hbox, *align, *button;
-       struct Sprite *gsprite;
-
-       /* create button. */
-        button = gtk_button_new();
-
-        label = gtk_label_new_with_mnemonic(g->name);
-        gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
-
-       gsprite = get_government(g->index)->sprite;
-
-        image = gtk_image_new_from_pixmap(gsprite->pixmap, gsprite->mask);
-        hbox = gtk_hbox_new(FALSE, 2);
-
-       align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
-
-        gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
-        gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, FALSE, 5);
-
-        gtk_container_add(GTK_CONTAINER(align), label);
-        gtk_container_add(GTK_CONTAINER(button), hbox);
-
-       /* tidy up. */
-        gtk_container_add(GTK_CONTAINER(vbox), button);
-        g_signal_connect(
-          button,
-          "clicked",
-          G_CALLBACK(government_callback),
-          GINT_TO_POINTER(g->index)
-        );
-        g_signal_connect_swapped(
-          button,
-          "clicked",
-          G_CALLBACK(gtk_widget_destroy),
-          dshell
-        );
-
-        if (!can_change_to_government(game.player_ptr, i))
-         gtk_widget_set_sensitive(button, FALSE);
-      }
+    for (i = 0; i < governments; i++) {
+      GtkWidget *label, *image, *hbox, *align, *button;
+      struct Sprite *gsprite = government[i]->sprite;
+
+      /* create button. */
+      button = gtk_button_new();
+
+      label = gtk_label_new_with_mnemonic(government[i]->name);
+      gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
+
+      image = gtk_image_new_from_pixmap(gsprite->pixmap, gsprite->mask);
+      hbox = gtk_hbox_new(FALSE, 2);
+
+      align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+
+      gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+      gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, FALSE, 5);
+
+      gtk_container_add(GTK_CONTAINER(align), label);
+      gtk_container_add(GTK_CONTAINER(button), hbox);
+
+      /* tidy up. */
+      gtk_container_add(GTK_CONTAINER(vbox), button);
+      g_signal_connect(button, "clicked", G_CALLBACK(government_callback),
+                      GINT_TO_POINTER(g->index));
+      g_signal_connect_swapped(button, "clicked",
+                              G_CALLBACK(gtk_widget_destroy), dshell);
+
+      gtk_widget_set_sensitive(button,
+                              can_change_to_government(game.player_ptr,
+                                                       government[i]->
+                                                       index));
     }
  
     gtk_widget_show_all(dlabel);
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.90
diff -u -u -r1.90 dialogs.c
--- client/gui-xaw/dialogs.c    2003/11/28 17:37:20     1.90
+++ client/gui-xaw/dialogs.c    2004/01/25 15:46:23
@@ -1231,10 +1231,11 @@
 /****************************************************************
 ...
 *****************************************************************/
-void popup_government_dialog(void)
+void popup_government_dialog(int governments,
+                            struct government **government)
 {
-  Widget shell, form, dlabel, button, prev;
-  int i, can_change;
+  Widget shell, form, dlabel, prev;
+  int i;
   
   if(is_showing_government_dialog) {
     return;
@@ -1249,23 +1250,23 @@
   dlabel = I_L(XtVaCreateManagedWidget("dlabel", labelWidgetClass, form, 
NULL));
 
   prev = dlabel;
-  for (i = 0; i < game.government_count; i++) {
-    if (i == game.government_when_anarchy) continue;
-    can_change = can_change_to_government(game.player_ptr, i);
-    button = XtVaCreateManagedWidget("button", commandWidgetClass, form,
-                                    XtNfromVert, prev,
-                                    XtNlabel, (XtArgVal)governments[i].name,
-                                    NULL);
+  for (i = 0; i < governments; i++) {
+    Widget button =
+       XtVaCreateManagedWidget("button", commandWidgetClass, form,
+                               XtNfromVert, prev,
+                               XtNlabel, (XtArgVal) government[i]->name,
+                               NULL);
     XtAddCallback(button, XtNcallback, government_callback,
-                 INT_TO_XTPOINTER(i));
-    XtSetSensitive(button, can_change ? TRUE : FALSE);
+                 INT_TO_XTPOINTER(government[i]->index));
+    XtSetSensitive(button,
+                  can_change_to_government(game.player_ptr,
+                                           government[i]->index));
     prev = button;
   }
   
   xaw_set_relative_position(toplevel, shell, 10, 0);
   XtPopup(shell, XtGrabNone);
 }
-
 
 /****************************************************************
 ...
Index: client/include/dialogs_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/dialogs_g.h,v
retrieving revision 1.13
diff -u -u -r1.13 dialogs_g.h
--- client/include/dialogs_g.h  2003/11/28 17:37:20     1.13
+++ client/include/dialogs_g.h  2004/01/25 15:46:23
@@ -33,7 +33,8 @@
                                 Nation_Type_id * nations_used);
 
 void popup_revolution_dialog(void);
-void popup_government_dialog(void);
+void popup_government_dialog(int governments,
+                            struct government **government);
 void popup_caravan_dialog(struct unit *punit,
                          struct city *phomecity, struct city *pdestcity);
 bool caravan_dialog_is_open(void);

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