Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Make client aware of eng game status, related to (PR#1883)
Home

[Freeciv-Dev] Make client aware of eng game status, related to (PR#1883)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Make client aware of eng game status, related to (PR#1883)
From: Davide Pagnin <nightmare@xxxxxxxxxx>
Date: Fri, 27 Sep 2002 06:26:10 -0700 (PDT)

        Hi all!
Content-Type: multipart/mixed; boundary="=-6hSAoFFbXC7lO/x8uHOx"


--=-6hSAoFFbXC7lO/x8uHOx
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

        Hi all!

This is a work in progress patch.

The original goal of the patch was to fix the bug #1883, also known as
"DONT GET MAP AT ENDGAME".

The problem is that the client don't handle properly the condition when
the game has ended, and consider this state as running game.

This condition end up in a bunch of related problem, that need a proper
fix.

This patch, although incomplete, is a step toward the solution.

I hope...

The patch introduces 2 new function:

can_client_issue_orders
can_client_change_view

The names can obviously be changed is something more meaningful.

A client that can issue order, is a client that is not an observer and
that is connected to a game that is running, and for which giving or
changing orders make sense

A client that can change view, is a client that is connected to a game
for which map handling make sense (thus observer or not, game already
started but also ended)

The patch was started by me, then handled by Raimar, and then back to
me, thus is somewhat miscellaneous.

The gtk client is the only one that can be considered nearly finished,
because I want some feedback.

To have a sensible look on what this patch do, you can take every
savegame and set a proper endyear to come to the end game status
immediately. (More advanced is the game, better look on all aspect can
be done)

I've said this patch is unfinished, also for the gtk client, because I
want to handle, in a better way, the city dialog, it doesn't make sense
that you can sell or buy or whatever with an observer client nor an
ended game. 
I should also eliminate the focus on the last units, that is displayed
on the screen, even if you can't do anything.

Comment and suggestion, are strongly encouraged!!! (Please!!)

        Ciao, Davide


--=-6hSAoFFbXC7lO/x8uHOx
Content-Disposition: attachment; filename=end_game_state.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=end_game_state.patch; charset=ISO-8859-1

diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/civclient.c freeci=
v-work/client/civclient.c
--- freeciv-orig/client/civclient.c     Thu Sep 26 14:22:22 2002
+++ freeciv-work/client/civclient.c     Thu Sep 26 15:55:53 2002
@@ -583,23 +583,6 @@
   bool connect_error =3D (client_state =3D=3D CLIENT_PRE_GAME_STATE)
       && (newstate =3D=3D CLIENT_PRE_GAME_STATE);
=20
-  /*
-   * We are currently ignoring the CLIENT_GAME_OVER_STATE state
-   * because the client hasen't been changed to take care of it. So it
-   * breaks the show-whole-map-at-the-end-of-the-game. Nevertheless
-   * the server is so kind and sends the client this information. And
-   * in the future the client can/should take advantage of this
-   * information.
-   *
-   * FIXME: audit all client code to that it copes with
-   * CLIENT_GAME_OVER_STATE and implement specific
-   * CLIENT_GAME_OVER_STATE actions like history browsing. Then remove
-   * the kludge below.
-   */
-  if (newstate =3D=3D CLIENT_GAME_OVER_STATE) {
-    newstate =3D CLIENT_GAME_RUNNING_STATE;
-  }
-
   if(client_state!=3Dnewstate) {
=20
     /* If changing from pre-game state to _either_ select race
@@ -765,3 +748,21 @@
=20
   flip =3D !flip;
 }
+
+/*************************************************************************=
*
+ Can the client now issue orders.
+**************************************************************************=
/
+bool can_client_issue_orders()
+{
+  return (!client_is_observer()
+         && get_client_state() =3D=3D CLIENT_GAME_RUNNING_STATE);
+}
+
+/*************************************************************************=
*
+ Can the client now change the view.
+**************************************************************************=
/
+bool can_client_change_view()
+{
+  return (get_client_state() =3D=3D CLIENT_GAME_RUNNING_STATE
+         || get_client_state() =3D=3D CLIENT_GAME_OVER_STATE);
+}
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/civclient.h freeci=
v-work/client/civclient.h
--- freeciv-orig/client/civclient.h     Sat Aug 24 16:37:33 2002
+++ freeciv-work/client/civclient.h     Thu Sep 26 15:52:15 2002
@@ -57,5 +57,7 @@
 void wait_till_request_got_processed(int request_id);
 bool client_is_observer(void);
 void real_timer_callback(void);
+bool can_client_issue_orders(void);
+bool can_client_change_view(void);
=20
 #endif  /* FC__CIVCLIENT_H */
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/climisc.c freeciv-=
work/client/climisc.c
--- freeciv-orig/client/climisc.c       Thu Sep 19 23:27:27 2002
+++ freeciv-work/client/climisc.c       Thu Sep 26 14:37:29 2002
@@ -490,7 +490,7 @@
   struct city *pcity;
   struct unit *punit;
=20
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE) {
+  if (get_client_state() < CLIENT_GAME_RUNNING_STATE) {
     return;
   }
=20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/control.c freeciv-=
work/client/control.c
--- freeciv-orig/client/control.c       Wed Sep 11 19:04:39 2002
+++ freeciv-work/client/control.c       Thu Sep 26 15:51:34 2002
@@ -910,7 +910,9 @@
 **************************************************************************=
/
 void request_toggle_map_grid(void)=20
 {
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) return;
+  if (!can_client_change_view()) {
+    return;
+  }
=20
   draw_map_grid^=3D1;
   update_map_canvas_visible();
@@ -921,8 +923,9 @@
 **************************************************************************=
/
 void request_toggle_city_names(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_city_names ^=3D 1;
   update_map_canvas_visible();
@@ -933,8 +936,9 @@
 **************************************************************************=
/
 void request_toggle_city_productions(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_city_productions ^=3D 1;
   update_map_canvas_visible();
@@ -945,8 +949,9 @@
 **************************************************************************=
/
 void request_toggle_terrain(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_terrain ^=3D 1;
   update_map_canvas_visible();
@@ -957,8 +962,9 @@
 **************************************************************************=
/
 void request_toggle_coastline(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_coastline ^=3D 1;
   update_map_canvas_visible();
@@ -969,8 +975,9 @@
 **************************************************************************=
/
 void request_toggle_roads_rails(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_roads_rails ^=3D 1;
   update_map_canvas_visible();
@@ -981,8 +988,9 @@
 **************************************************************************=
/
 void request_toggle_irrigation(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_irrigation ^=3D 1;
   update_map_canvas_visible();
@@ -993,8 +1001,9 @@
 **************************************************************************=
/
 void request_toggle_mines(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_mines ^=3D 1;
   update_map_canvas_visible();
@@ -1005,8 +1014,9 @@
 **************************************************************************=
/
 void request_toggle_fortress_airbase(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_fortress_airbase ^=3D 1;
   update_map_canvas_visible();
@@ -1017,8 +1027,9 @@
 **************************************************************************=
/
 void request_toggle_specials(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_specials ^=3D 1;
   update_map_canvas_visible();
@@ -1029,8 +1040,9 @@
 **************************************************************************=
/
 void request_toggle_pollution(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_pollution ^=3D 1;
   update_map_canvas_visible();
@@ -1041,8 +1053,9 @@
 **************************************************************************=
/
 void request_toggle_cities(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_cities ^=3D 1;
   update_map_canvas_visible();
@@ -1053,8 +1066,9 @@
 **************************************************************************=
/
 void request_toggle_units(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_units ^=3D 1;
   update_map_canvas_visible();
@@ -1065,8 +1079,9 @@
 **************************************************************************=
/
 void request_toggle_focus_unit(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_focus_unit ^=3D 1;
   update_map_canvas_visible();
@@ -1077,8 +1092,9 @@
 **************************************************************************=
/
 void request_toggle_fog_of_war(void)
 {
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
+  if (!can_client_change_view()) {
     return;
+  }
=20
   draw_fog_of_war ^=3D 1;
   update_map_canvas_visible();
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/citydlg.c =
freeciv-work/client/gui-gtk/citydlg.c
--- freeciv-orig/client/gui-gtk/citydlg.c       Wed Aug  7 13:21:40 2002
+++ freeciv-work/client/gui-gtk/citydlg.c       Thu Sep 26 18:01:11 2002
@@ -33,6 +33,7 @@
 #include "shared.h"
 #include "support.h"
=20
+#include "civclient.h"
 #include "cityrep.h"
 #include "cma_fe.h"
 #include "cma_fec.h"=20
@@ -403,10 +404,13 @@
     refresh_cma_dialog(pdialog->pcity, REFRESH_ALL);
=20
     gtk_widget_set_sensitive(pdialog->unit.activate_command,
+                            can_client_issue_orders() &&=20
                             have_present_units);
     gtk_widget_set_sensitive(pdialog->unit.sentry_all_command,
+                            can_client_issue_orders() &&=20
                             have_present_units);
     gtk_widget_set_sensitive(pdialog->unit.show_units_command,
+                            can_client_issue_orders() &&=20
                             have_present_units);
     gtk_widget_set_sensitive(pdialog->overview.sell_command, FALSE);
   } else {
@@ -1882,9 +1886,10 @@
   gfloat pct;
   int cost;
=20
-  gtk_widget_set_sensitive(pdialog->overview.buy_command, !pcity->did_buy)=
;
+  gtk_widget_set_sensitive(pdialog->overview.buy_command,
+                          can_client_issue_orders() && !pcity->did_buy);
   gtk_widget_set_sensitive(pdialog->overview.sell_command,
-                          !pcity->did_sell);
+                          can_client_issue_orders() && !pcity->did_sell);
                =09
   get_city_dialog_production(pcity, buf, sizeof(buf));
=20
@@ -3221,7 +3226,8 @@
                  improvement_value(id));
       gtk_set_label(GTK_BUTTON(pdialog->overview.sell_command)->child,
                    buf);
-      gtk_widget_set_sensitive(pdialog->overview.sell_command, TRUE);
+      gtk_widget_set_sensitive(pdialog->overview.sell_command,
+                              can_client_issue_orders());
     }
   }
 }
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/cityrep.c =
freeciv-work/client/gui-gtk/cityrep.c
--- freeciv-orig/client/gui-gtk/cityrep.c       Thu Sep 26 14:22:22 2002
+++ freeciv-work/client/gui-gtk/cityrep.c       Thu Sep 26 16:12:25 2002
@@ -32,6 +32,7 @@
 #include "support.h"
 #include "unit.h"
=20
+#include "civclient.h"
 #include "chatline.h"
 #include "citydlg.h"
 #include "cityrepdata.h"
@@ -668,11 +669,12 @@
 *****************************************************************/
 static void city_list_callback(GtkWidget *w, gint row, gint column)
 {
+  gtk_widget_set_sensitive(city_change_command, can_client_issue_orders())=
;
+  gtk_widget_set_sensitive(city_select_command, can_client_issue_orders())=
;
   if (GTK_CLIST(city_list)->selection) {
-    gtk_widget_set_sensitive(city_change_command, TRUE);
     gtk_widget_set_sensitive(city_center_command, TRUE);
     gtk_widget_set_sensitive(city_popup_command, TRUE);
-    gtk_widget_set_sensitive(city_buy_command, TRUE);
+    gtk_widget_set_sensitive(city_buy_command, can_client_issue_orders());
   } else {
     gtk_widget_set_sensitive(city_center_command, FALSE);
     gtk_widget_set_sensitive(city_popup_command, FALSE);
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/dialogs.c =
freeciv-work/client/gui-gtk/dialogs.c
--- freeciv-orig/client/gui-gtk/dialogs.c       Wed Aug  7 13:21:41 2002
+++ freeciv-work/client/gui-gtk/dialogs.c       Thu Sep 26 15:55:30 2002
@@ -2221,9 +2221,10 @@
   size_t i;
   int delta=3D10;
   struct packet_player_request packet;
- =20
-  if (get_client_state()!=3DCLIENT_GAME_RUNNING_STATE)
+
+  if (!can_client_issue_orders()) {
     return;
+  }
  =20
   i=3D (size_t)data;
  =20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/gotodlg.c =
freeciv-work/client/gui-gtk/gotodlg.c
--- freeciv-orig/client/gui-gtk/gotodlg.c       Wed Jun 12 09:24:35 2002
+++ freeciv-work/client/gui-gtk/gotodlg.c       Thu Sep 26 15:55:25 2002
@@ -74,9 +74,7 @@
   GtkWidget *scrolled;
   GtkAccelGroup *accel=3Dgtk_accel_group_new();
=20
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE)
-    return;
-  if (!get_unit_in_focus()) {
+  if (!can_client_issue_orders() || !get_unit_in_focus()) {
     return;
   }
=20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/mapctrl.c =
freeciv-work/client/gui-gtk/mapctrl.c
--- freeciv-orig/client/gui-gtk/mapctrl.c       Wed Sep 11 19:04:40 2002
+++ freeciv-work/client/gui-gtk/mapctrl.c       Thu Sep 26 15:55:15 2002
@@ -278,8 +278,7 @@
   int xtile, ytile;
=20
   /* when you get a <SHIFT>+<LMB> pow! */
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE
-      || !(ev->state & GDK_SHIFT_MASK)) {
+  if (!can_client_issue_orders() || (ev->state & GDK_SHIFT_MASK) =3D=3D GD=
K_SHIFT_MASK) {
     return TRUE;
   }
=20
@@ -296,10 +295,8 @@
 {
   int xtile, ytile;
  =20
-  if(get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
-    return TRUE;
- =20
-  if ((ev->button =3D=3D 1) && (ev->state & GDK_SHIFT_MASK)) {
+  if (can_client_issue_orders() && ev->button =3D=3D 1
+      && (ev->state & GDK_SHIFT_MASK) =3D=3D GDK_SHIFT_MASK) {
     adjust_workers(w, ev);
     return TRUE;
   }
@@ -309,10 +306,13 @@
   if (ev->button =3D=3D 1) {
     do_map_click(xtile, ytile);
     gtk_widget_grab_focus(turn_done_button);
-  } else if ((ev->button =3D=3D 2) || (ev->state & GDK_CONTROL_MASK)) {
-    popit(ev, xtile, ytile);
-  } else {
-    center_tile_mapcanvas(xtile, ytile);
+  } else if (can_client_change_view()) {
+    if (ev->button =3D=3D 2
+       || (ev->state & GDK_CONTROL_MASK) =3D=3D GDK_CONTROL_MASK) {
+      popit(ev, xtile, ytile);
+    } else {
+      center_tile_mapcanvas(xtile, ytile);
+    }
   }
   return TRUE;
 }
@@ -366,7 +366,7 @@
   struct packet_city_request packet;
   enum city_tile_type wrk;
=20
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_issue_orders()) {
     return;
   }
=20
@@ -420,14 +420,12 @@
   }
   ytile =3D ev->y / 2;
  =20
-  if(get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
-     return TRUE;
-
-  if (ev->button =3D=3D 1) {
-    do_unit_goto(xtile, ytile);
-  } else if (ev->button =3D=3D 3) {
+  if (can_client_change_view() && ev->button =3D=3D 3) {
     center_tile_mapcanvas(xtile, ytile);
+  } else if (can_client_issue_orders() && ev->button =3D=3D 1) {
+    do_unit_goto(xtile, ytile);
   }
+
   return TRUE;
 }
=20
@@ -447,7 +445,7 @@
   int x,y;
   struct city *pcity;
=20
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_change_view()) {
     return;
   }
  =20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/mapview.c =
freeciv-work/client/gui-gtk/mapview.c
--- freeciv-orig/client/gui-gtk/mapview.c       Sun Aug 25 13:20:56 2002
+++ freeciv-work/client/gui-gtk/mapview.c       Thu Sep 26 15:52:42 2002
@@ -760,7 +760,7 @@
 **************************************************************************=
/
 gint overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev)
 {
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_change_view()) {
     if(radar_gfx_sprite)
       gdk_draw_pixmap(overview_canvas->window, civ_gc,
                      radar_gfx_sprite->pixmap, ev->area.x, ev->area.y,
@@ -939,7 +939,7 @@
     map_resized=3DTRUE;
   }
=20
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_change_view()) {
     if (!intro_gfx_sprite) {
       load_intro_gfx();
     }
@@ -1733,8 +1733,9 @@
=20
   gfloat percent=3Dadj->value;
=20
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE)
-     return;
+  if (!can_client_change_view()) {
+    return;
+  }
=20
   last_map_view_x0=3Dmap_view_x0;
   last_map_view_y0=3Dmap_view_y0;
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/menu.c fre=
eciv-work/client/gui-gtk/menu.c
--- freeciv-orig/client/gui-gtk/menu.c  Sun Jun 23 18:06:24 2002
+++ freeciv-work/client/gui-gtk/menu.c  Thu Sep 26 15:55:19 2002
@@ -959,7 +959,7 @@
 *****************************************************************/
 void update_menus(void)
 {
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_change_view()) {
     menus_set_sensitive("<main>/_Reports", FALSE);
     menus_set_sensitive("<main>/_Kingdom", FALSE);
     menus_set_sensitive("<main>/_View", FALSE);
@@ -969,12 +969,11 @@
     menus_set_sensitive("<main>/_Reports", TRUE);
     menus_set_sensitive("<main>/_Kingdom", TRUE);
     menus_set_sensitive("<main>/_View", TRUE);
-    menus_set_sensitive("<main>/_Orders", !client_is_observer());
+    menus_set_sensitive("<main>/_Orders", can_client_issue_orders());
=20
-    menus_set_sensitive("<main>/_Kingdom/_Tax Rates", !client_is_observer(=
));
-    menus_set_sensitive("<main>/_Kingdom/Work_lists", !client_is_observer(=
));
-    menus_set_sensitive("<main>/_Kingdom/_Revolution",
-                       !client_is_observer());
+    menus_set_sensitive("<main>/_Kingdom/_Tax Rates", can_client_issue_ord=
ers());
+    menus_set_sensitive("<main>/_Kingdom/Work_lists", can_client_issue_ord=
ers());
+    menus_set_sensitive("<main>/_Kingdom/_Revolution", can_client_issue_or=
ders());
=20
     menus_set_sensitive("<main>/_Reports/S_paceship",
                        (game.player_ptr->spaceship.state!=3DSSHIP_NONE));
@@ -999,7 +998,7 @@
=20
     /* Remaining part of this function: Update Orders menu */
=20
-    if (client_is_observer()) {
+    if (!can_client_issue_orders()) {
       return;
     }
=20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/plrdlg.c f=
reeciv-work/client/gui-gtk/plrdlg.c
--- freeciv-orig/client/gui-gtk/plrdlg.c        Fri Aug  9 00:10:18 2002
+++ freeciv-work/client/gui-gtk/plrdlg.c        Thu Sep 26 17:16:08 2002
@@ -29,6 +29,7 @@
 #include "player.h"
 #include "support.h"
=20
+#include "civclient.h"
 #include "chatline.h"
 #include "climisc.h"
 #include "clinet.h"
@@ -469,18 +470,18 @@
     gtk_widget_set_sensitive(players_war_command, FALSE);
     break;
   default:
-    gtk_widget_set_sensitive(players_war_command,
+    gtk_widget_set_sensitive(players_war_command, can_client_issue_orders(=
) &&
                             game.player_idx !=3D player_index);
   }
=20
-  gtk_widget_set_sensitive(players_vision_command,
+  gtk_widget_set_sensitive(players_vision_command, can_client_issue_orders=
() &&
                           gives_shared_vision(game.player_ptr, pplayer));
=20
   if (pplayer->is_alive=20
       && pplayer !=3D game.player_ptr
       && player_has_embassy(game.player_ptr, pplayer)) {
     if (pplayer->is_connected)
-      gtk_widget_set_sensitive(players_meet_command, TRUE);
+      gtk_widget_set_sensitive(players_meet_command, can_client_issue_orde=
rs());
     else
       gtk_widget_set_sensitive(players_meet_command, FALSE);
     gtk_widget_set_sensitive(players_int_command, TRUE);
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk/repodlgs.c=
 freeciv-work/client/gui-gtk/repodlgs.c
--- freeciv-orig/client/gui-gtk/repodlgs.c      Thu Jun 27 02:59:15 2002
+++ freeciv-work/client/gui-gtk/repodlgs.c      Thu Sep 26 17:11:01 2002
@@ -625,8 +625,8 @@
=20
   i=3Deconomy_improvement_type[row];
   if(i>=3D0 && i<game.num_impr_types && !is_wonder(i))
-    gtk_widget_set_sensitive(sellobsolete_command, TRUE);
-    gtk_widget_set_sensitive(sellall_command, TRUE);
+    gtk_widget_set_sensitive(sellobsolete_command, can_client_issue_orders=
());
+    gtk_widget_set_sensitive(sellall_command, can_client_issue_orders());
   return;
 }
=20
@@ -853,7 +853,7 @@
 {
   if ((unit_type_exists(activeunits_type[row])) &&
       (can_upgrade_unittype(game.player_ptr, activeunits_type[row]) !=3D -=
1))
-    gtk_widget_set_sensitive(upgrade_command, TRUE);
+    gtk_widget_set_sensitive(upgrade_command, can_client_issue_orders());
 }
=20
 /****************************************************************
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk-2.0/dialog=
s.c freeciv-work/client/gui-gtk-2.0/dialogs.c
--- freeciv-orig/client/gui-gtk-2.0/dialogs.c   Sat Aug 10 18:35:12 2002
+++ freeciv-work/client/gui-gtk-2.0/dialogs.c   Fri Sep 27 15:14:54 2002
@@ -2220,8 +2220,9 @@
   int delta=3D10;
   struct packet_player_request packet;
  =20
-  if (get_client_state()!=3DCLIENT_GAME_RUNNING_STATE)
+  if (!can_client_issue_orders()) {
     return TRUE;
+  }
  =20
   i=3D (size_t)data;
  =20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk-2.0/gotodl=
g.c freeciv-work/client/gui-gtk-2.0/gotodlg.c
--- freeciv-orig/client/gui-gtk-2.0/gotodlg.c   Wed Jun 12 09:24:37 2002
+++ freeciv-work/client/gui-gtk-2.0/gotodlg.c   Fri Sep 27 15:14:58 2002
@@ -74,9 +74,7 @@
   GtkWidget *scrolled;
   GtkAccelGroup *accel=3Dgtk_accel_group_new();
=20
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE)
-    return;
-  if (!get_unit_in_focus()) {
+  if (!can_client_issue_orders() || !get_unit_in_focus()) {
     return;
   }
=20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk-2.0/mapctr=
l.c freeciv-work/client/gui-gtk-2.0/mapctrl.c
--- freeciv-orig/client/gui-gtk-2.0/mapctrl.c   Wed Sep 11 19:04:40 2002
+++ freeciv-work/client/gui-gtk-2.0/mapctrl.c   Fri Sep 27 15:15:44 2002
@@ -270,8 +270,7 @@
   int xtile, ytile;
=20
   /* when you get a <SHIFT>+<LMB> pow! */
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE
-      || !(ev->state & GDK_SHIFT_MASK)) {
+  if (!can_client_issue_orders() || (ev->state & GDK_SHIFT_MASK) =3D=3D GD=
K_SHIFT_MASK) {
     return TRUE;
   }
=20
@@ -287,11 +286,9 @@
 gboolean butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer da=
ta)
 {
   int xtile, ytile;
- =20
-  if(get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
-    return TRUE;
- =20
-  if ((ev->button =3D=3D 1) && (ev->state & GDK_SHIFT_MASK)) {
+
+  if (can_client_issue_orders() && ev->button =3D=3D 1
+      && (ev->state & GDK_SHIFT_MASK) =3D=3D GDK_SHIFT_MASK) {
     adjust_workers(w, ev);
     return TRUE;
   }
@@ -301,10 +298,12 @@
   if (ev->button =3D=3D 1) {
     do_map_click(xtile, ytile);
     gtk_widget_grab_focus(turn_done_button);
-  } else if ((ev->button =3D=3D 2) || (ev->state & GDK_CONTROL_MASK)) {
-    popit(ev, xtile, ytile);
-  } else {
-    center_tile_mapcanvas(xtile, ytile);
+  } else if (can_client_change_view()) {
+    if ((ev->button =3D=3D 2) || (ev->state & GDK_CONTROL_MASK)) {
+      popit(ev, xtile, ytile);
+    } else if () {
+      center_tile_mapcanvas(xtile, ytile);
+    }
   }
   return TRUE;
 }
@@ -358,7 +357,7 @@
   struct packet_city_request packet;
   enum city_tile_type wrk;
=20
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_issue_orders()) {
     return;
   }
=20
@@ -411,15 +410,13 @@
                         (map_view_x0 + map_canvas_store_twidth / 2));
   }
   ytile =3D ev->y / 2;
- =20
-  if(get_client_state() !=3D CLIENT_GAME_RUNNING_STATE)
-     return TRUE;
=20
-  if (ev->button =3D=3D 1) {
-    do_unit_goto(xtile, ytile);
-  } else if (ev->button =3D=3D 3) {
+  if (can_client_change_view() && ev->button =3D=3D 3) {
     center_tile_mapcanvas(xtile, ytile);
+  } else if (can_client_issue_orders() && ev->button =3D=3D 1) {
+    do_unit_goto(xtile, ytile);
   }
+
   return TRUE;
 }
=20
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk-2.0/mapvie=
w.c freeciv-work/client/gui-gtk-2.0/mapview.c
--- freeciv-orig/client/gui-gtk-2.0/mapview.c   Sun Aug 25 13:20:57 2002
+++ freeciv-work/client/gui-gtk-2.0/mapview.c   Fri Sep 27 15:15:47 2002
@@ -761,7 +761,7 @@
 **************************************************************************=
/
 gboolean overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer=
 data)
 {
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
+  if(get_client_state() < CLIENT_GAME_RUNNING_STATE) {
     if(radar_gfx_sprite)
       gdk_draw_pixmap(overview_canvas->window, civ_gc,
                      radar_gfx_sprite->pixmap, ev->area.x, ev->area.y,
@@ -932,7 +932,7 @@
     update_map_canvas_scrollbars_size();
   }
=20
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE) {
+  if (get_client_state() < CLIENT_GAME_RUNNING_STATE) {
     if (!intro_gfx_sprite) {
       load_intro_gfx();
     }
@@ -964,7 +964,7 @@
 {
   static bool cleared =3D FALSE;
=20
-  if (get_client_state() !=3D CLIENT_GAME_RUNNING_STATE) {
+  if (get_client_state() < CLIENT_GAME_RUNNING_STATE) {
     if (scaled_intro_sprite) {
       gdk_draw_pixmap(map_canvas->window, civ_gc,
                      scaled_intro_sprite->pixmap,
@@ -1778,8 +1778,9 @@
=20
   gfloat percent=3Dadj->value;
=20
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE)
-     return;
+  if (!can_client_change_view()) {
+    return;
+  }
=20
   last_map_view_x0=3Dmap_view_x0;
   last_map_view_y0=3Dmap_view_y0;
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-gtk-2.0/menu.c=
 freeciv-work/client/gui-gtk-2.0/menu.c
--- freeciv-orig/client/gui-gtk-2.0/menu.c      Thu Jun 13 04:18:20 2002
+++ freeciv-work/client/gui-gtk-2.0/menu.c      Fri Sep 27 15:15:06 2002
@@ -954,7 +954,7 @@
 *****************************************************************/
 void update_menus(void)
 {
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
+  if (get_client_state() < CLIENT_GAME_RUNNING_STATE) {
     menus_set_sensitive("<main>/_Reports", FALSE);
     menus_set_sensitive("<main>/_Kingdom", FALSE);
     menus_set_sensitive("<main>/_View", FALSE);
@@ -965,6 +965,10 @@
     menus_set_sensitive("<main>/_Kingdom", TRUE);
     menus_set_sensitive("<main>/_View", TRUE);
     menus_set_sensitive("<main>/_Orders", TRUE);
+
+    menus_set_sensitive("<main>/_Kingdom/_Tax Rates", can_client_issue_ord=
ers());
+    menus_set_sensitive("<main>/_Kingdom/Work_lists", can_client_issue_ord=
ers());
+    menus_set_sensitive("<main>/_Kingdom/_Revolution", can_client_issue_or=
ders());
  =20
     menus_set_sensitive("<main>/_Reports/S_paceship",
                        (game.player_ptr->spaceship.state!=3DSSHIP_NONE));
@@ -987,6 +991,12 @@
     menus_set_sensitive("<main>/_View/Focus Unit", !draw_units);
     menus_set_active("<main>/_View/Fog of War", draw_fog_of_war);
=20
+    /* Remaining part of this function: Update Orders menu */
+
+    if (!can_client_issue_orders()) {
+      return;
+    }
+
     if((punit=3Dget_unit_in_focus())) {
       char *irrfmt =3D _("Change to %s (_I)");
       char *minfmt =3D _("Change to %s (_M)");
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/gui-mui/gui_main.c=
 freeciv-work/client/gui-mui/gui_main.c
--- freeciv-orig/client/gui-mui/gui_main.c      Sat Aug 24 16:37:44 2002
+++ freeciv-work/client/gui-mui/gui_main.c      Thu Sep 26 14:37:29 2002
@@ -412,8 +412,7 @@
       }
       break;
     case END_TURN:
-      if (get_client_state() =3D=3D CLIENT_GAME_RUNNING_STATE)
-        key_end_turn();
+      key_end_turn();
       break;
     case NEXT_UNIT:
       advance_unit_focus();    /*focus_to_next_unit(); */
diff -urN -Xfreeciv-orig/diff_ignore freeciv-orig/client/packhand.c freeciv=
-work/client/packhand.c
--- freeciv-orig/client/packhand.c      Thu Sep 26 14:22:22 2002
+++ freeciv-work/client/packhand.c      Thu Sep 26 15:51:09 2002
@@ -280,7 +280,9 @@
     popdown_races_dialog();
   }
  =20
+  freelog(LOG_NORMAL,"Packet Status 1: %d",packet->value);
   set_client_state(packet->value);
+  freelog(LOG_NORMAL,"Packet Status 2: %d",packet->value);
=20
   if(get_client_state()=3D=3DCLIENT_GAME_RUNNING_STATE) {
     refresh_overview_canvas();
@@ -1061,7 +1063,7 @@
   game.heating=3Dpinfo->heating;
   game.nuclearwinter=3Dpinfo->nuclearwinter;
   game.cooling=3Dpinfo->cooling;
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
+  if (!can_client_change_view()) {
     improvement_status_init(game.improvements,
                            ARRAY_SIZE(game.improvements));
=20
@@ -1095,9 +1097,8 @@
   /* Only update effects if a new wonder appeared or was destroyed */
   try_update_effects(need_effect_update);
=20
-  if(get_client_state()!=3DCLIENT_GAME_RUNNING_STATE) {
-    if(get_client_state()=3D=3DCLIENT_SELECT_RACE_STATE)
-      popdown_races_dialog();
+  if (get_client_state() =3D=3D CLIENT_SELECT_RACE_STATE) {
+    popdown_races_dialog();
   }
   game.techpenalty=3Dpinfo->techpenalty;
   game.foodbox=3Dpinfo->foodbox;
@@ -1239,7 +1240,7 @@
   update_worklist_report_dialog();
=20
   if (pplayer =3D=3D game.player_ptr
-      && get_client_state() =3D=3D CLIENT_GAME_RUNNING_STATE) {
+      && get_client_state() >=3D CLIENT_GAME_RUNNING_STATE) {
     update_info_label();
   }
 }
@@ -1560,7 +1561,7 @@
   }
=20
   /* refresh tiles */
-  if(get_client_state()=3D=3DCLIENT_GAME_RUNNING_STATE) {
+  if (get_client_state() >=3D CLIENT_GAME_RUNNING_STATE) {
     int x =3D packet->x, y =3D packet->y;
=20
     /* the tile itself */

--=-6hSAoFFbXC7lO/x8uHOx--




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