Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13203) don't popup nation selection dialog if you don'
Home

[Freeciv-Dev] (PR#13203) don't popup nation selection dialog if you don'

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13203) don't popup nation selection dialog if you don't have permissions
From: "Jason Dorje Short" <jdorje@xxxxxxxxx>
Date: Wed, 1 Jun 2005 10:50:25 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13203 >

Unless you have ctrl access you can't edit other players' nations, but
you can still popup the selection dialog with no results.

This patch fixes it so you can't popup the selection dialog unless you
have the perms.

-jason

Index: client/gui-gtk-2.0/pages.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/pages.c,v
retrieving revision 1.31
diff -u -r1.31 pages.c
--- client/gui-gtk-2.0/pages.c  1 Jun 2005 01:02:33 -0000       1.31
+++ client/gui-gtk-2.0/pages.c  1 Jun 2005 17:05:12 -0000
@@ -977,7 +977,7 @@
   pplayer = get_player(player_no);
 
   if (column == nation_col) {
-    if (!pplayer) {
+    if (!pplayer || !can_conn_edit_players_nation(&aconnection, pplayer)) {
       return FALSE;
     }
 
Index: common/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.26
diff -u -r1.26 fc_types.h
--- common/fc_types.h   11 May 2005 08:03:27 -0000      1.26
+++ common/fc_types.h   1 Jun 2005 17:05:12 -0000
@@ -64,6 +64,7 @@
 typedef int Team_type_id;
 
 struct city;
+struct connection;
 struct government;
 struct nation_type;
 struct player;
Index: common/nation.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/nation.c,v
retrieving revision 1.49
diff -u -r1.49 nation.c
--- common/nation.c     17 May 2005 23:01:22 -0000      1.49
+++ common/nation.c     1 Jun 2005 17:05:12 -0000
@@ -21,17 +21,17 @@
 
 #include <assert.h>
 
+#include "connection.h"
 #include "fcintl.h"
 #include "game.h"
 #include "government.h"
 #include "log.h"
 #include "mem.h"
+#include "nation.h"
 #include "player.h"
 #include "support.h"
 #include "tech.h"
 
-#include "nation.h"
-
 static struct nation_type *nations = NULL;
 
 static int num_nation_groups;
@@ -359,3 +359,13 @@
   return FALSE;
 }
 
+/****************************************************************************
+  Return TRUE iff the editor is allowed to edit the player's nation in
+  pregame.
+****************************************************************************/
+bool can_conn_edit_players_nation(const struct connection *pconn,
+                                 const struct player *pplayer)
+{
+  return ((!pconn->observer && pconn->player == pplayer)
+         || pconn->access_level >= ALLOW_CTRL);
+}
Index: common/nation.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/nation.h,v
retrieving revision 1.48
diff -u -r1.48 nation.h
--- common/nation.h     17 May 2005 23:01:22 -0000      1.48
+++ common/nation.h     1 Jun 2005 17:05:12 -0000
@@ -127,6 +127,9 @@
 
 bool nation_in_group(struct nation_type* nation, const char* group_name);
 
+bool can_conn_edit_players_nation(const struct connection *pconn,
+                                 const struct player *pplayer);
+
 #define nations_iterate(nation)                                                
    \
 {                                                                          \
   int NI_index;                                                                
    \
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.265
diff -u -r1.265 srv_main.c
--- server/srv_main.c   1 Jun 2005 01:02:34 -0000       1.265
+++ server/srv_main.c   1 Jun 2005 17:05:13 -0000
@@ -1234,8 +1234,7 @@
     return;
   }
 
-  if (pplayer != requestor
-      && requestor->current_conn->access_level <= ALLOW_INFO) {
+  if (!can_conn_edit_players_nation(requestor->current_conn, pplayer)) {
     return;
   }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13203) don't popup nation selection dialog if you don't have permissions, Jason Dorje Short <=