Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9738) client_has_hack is bad
Home

[Freeciv-Dev] (PR#9738) client_has_hack is bad

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9738) client_has_hack is bad
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 Aug 2004 20:36:50 -0700
Reply-to: rt@xxxxxxxxxxx

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

In client/connectdlg_common.c there is a value client_has_hack.

1.  This value should be static.  An accessor function should be 
provided for the GUI to tell whether the client has hack.  But the GUI 
should not be changing this value.  (The value isn't changed outside of 
connectdlg_common, but this is hard to verify.)

2.  The value is initialized to FALSE when the client is launched.  It 
is later set to TRUE when the client acquires hack access.  But after 
this is is not reset to FALSE when the client disconnects.

This patch makes the value static, which is step toward fixing problem 
#2 (which is the real problem).

jason

? freeciv-1.14.99-devel.tar.gz
? server/civmanual.c
Index: client/connectdlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/connectdlg_common.c,v
retrieving revision 1.16
diff -u -r1.16 connectdlg_common.c
--- client/connectdlg_common.c  13 Aug 2004 19:38:20 -0000      1.16
+++ client/connectdlg_common.c  20 Aug 2004 03:36:07 -0000
@@ -62,7 +62,7 @@
 char player_name[MAX_LEN_NAME];
 char *current_filename = NULL;
 
-bool client_has_hack = FALSE;
+static bool client_has_hack = FALSE;
 
 int internal_server_port;
 
@@ -112,6 +112,14 @@
 } 
 
 /************************************************************************** 
+  Returns TRUE if the client has hack access.
+**************************************************************************/
+bool can_client_access_hack(void)
+{
+  return client_has_hack;
+}
+
+/************************************************************************** 
 Kills the server if the client has started it (FIXME: atexit handler?)
 **************************************************************************/ 
 void client_kill_server()
Index: client/connectdlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/connectdlg_common.h,v
retrieving revision 1.4
diff -u -r1.4 connectdlg_common.h
--- client/connectdlg_common.h  13 Aug 2004 19:38:20 -0000      1.4
+++ client/connectdlg_common.h  20 Aug 2004 03:36:07 -0000
@@ -21,7 +21,9 @@
 
 bool client_start_server(void);
 void client_kill_server(void);
+
 bool is_server_running(void);
+bool can_client_access_hack(void);
 
 void send_client_wants_hack(char *filename);
 void send_start_saved_game(void);
@@ -43,6 +45,4 @@
 
 extern const char *skill_level_names[NUM_SKILL_LEVELS];
 
-extern bool client_has_hack;
-
 #endif  /* FC__CONNECTDLG_COMMON_H */ 
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.34
diff -u -r1.34 menu.c
--- client/gui-gtk-2.0/menu.c   17 Aug 2004 07:25:27 -0000      1.34
+++ client/gui-gtk-2.0/menu.c   20 Aug 2004 03:36:08 -0000
@@ -1081,12 +1081,13 @@
 void update_menus(void)
 {
 
-  menus_set_sensitive("<main>/_Game/Save Game _As...", client_has_hack &&
-                     get_client_state() >= CLIENT_GAME_RUNNING_STATE);
-  menus_set_sensitive("<main>/_Game/_Save Game", client_has_hack &&
-                     get_client_state() >= CLIENT_GAME_RUNNING_STATE);
-  menus_set_sensitive("<main>/_Game/_End Game", client_has_hack &&
-                     get_client_state() >= CLIENT_GAME_RUNNING_STATE);
+  menus_set_sensitive("<main>/_Game/Save Game _As...",
+                     can_client_access_hack()
+                     && get_client_state() >= CLIENT_GAME_RUNNING_STATE);
+  menus_set_sensitive("<main>/_Game/_Save Game", can_client_access_hack()
+                     && get_client_state() >= CLIENT_GAME_RUNNING_STATE);
+  menus_set_sensitive("<main>/_Game/_End Game", can_client_access_hack()
+                     && get_client_state() >= CLIENT_GAME_RUNNING_STATE);
   menus_set_sensitive("<main>/_Game/Server O_ptions", 
                      aconnection.established);
   menus_set_sensitive("<main>/_Game/_Initial Server Options", 

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