Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#5117) sending access level info to client.
Home

[Freeciv-Dev] (PR#5117) sending access level info to client.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#5117) sending access level info to client.
From: "Rafa³ Bursig" <bursig@xxxxxxxxx>
Date: Sat, 16 Aug 2003 14:34:22 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Hi All

This code allow sending current client acces level info to client and 
set up client aconnection struct.

This is very usefull with start/setup server GUI and allow in easy way 
find that we have access to such command.

Rafal
diff -u -r freeciv/client/civclient.c fc/client/civclient.c
--- freeciv/client/civclient.c  2003-07-24 12:24:09.000000000 +0200
+++ fc/client/civclient.c       2003-08-16 21:56:23.000000000 +0200
@@ -441,6 +441,10 @@
     handle_conn_info((struct packet_conn_info *)packet);
     break;
     
+  case PACKET_NEW_ACCESS_LEVEL:  
+    handle_access_level_info((struct packet_generic_integer *)packet);
+    break;
+    
   case PACKET_CONN_PING:
     send_packet_generic_empty(&aconnection, PACKET_CONN_PONG);
     break;
diff -u -r freeciv/client/packhand.c fc/client/packhand.c
--- freeciv/client/packhand.c   2003-08-16 22:23:19.475666400 +0200
+++ fc/client/packhand.c        2003-08-16 22:21:50.499192880 +0200
@@ -126,6 +126,7 @@
   if (packet->you_can_login) {
     freelog(LOG_VERBOSE, "join game accept:%s", packet->message);
     aconnection.established = TRUE;
+    aconnection.access_level = packet->access_level;
     game.conn_id = packet->conn_id;
     agents_game_joined();
   } else {
@@ -1521,6 +1508,18 @@
 /*************************************************************************
 ...
 **************************************************************************/
+void handle_access_level_info(struct packet_generic_integer *packet)
+{
+  aconnection.access_level = packet->value;
+  freelog(LOG_DEBUG, "New Access Level : %s",
+                       cmdlevel_name(aconnection.access_level));
+  
+  update_conn_list_dialog();
+}
+
+/*************************************************************************
+...
+**************************************************************************/
 void handle_ping_info(struct packet_ping_info *packet)
 {
   int i;
diff -u -r freeciv/client/packhand.h fc/client/packhand.h
--- freeciv/client/packhand.h   2003-06-27 13:14:28.000000000 +0200
+++ fc/client/packhand.h        2003-08-16 21:50:51.000000000 +0200
@@ -19,6 +19,7 @@
 
 void handle_tile_info(struct packet_tile_info *packet);
 void handle_player_info(struct packet_player_info *pinfo);
+void handle_access_level_info(struct packet_generic_integer *packet);
 void handle_conn_info(struct packet_conn_info *pinfo);
 void handle_ping_info(struct packet_ping_info *packet);
 void handle_game_info(struct packet_game_info *pinfo);
diff -u -r freeciv/common/packets.c fc/common/packets.c
--- freeciv/common/packets.c    2003-08-07 22:49:19.000000000 +0200
+++ fc/common/packets.c 2003-08-16 22:15:45.000000000 +0200
@@ -330,6 +330,7 @@
   case PACKET_CITY_REFRESH:
   case PACKET_INCITE_INQ:
   case PACKET_CITY_NAME_SUGGEST_REQ:
+  case PACKET_NEW_ACCESS_LEVEL:
     return receive_packet_generic_integer(pc);
 
   case PACKET_PLAYER_CANCEL_PACT:
@@ -1681,7 +1682,8 @@
   dio_put_bool32(&dout, reply->you_can_login);
   dio_put_string(&dout, reply->message);
   dio_put_string(&dout, reply->capability);
-
+  dio_put_uint8(&dout, pc->access_level);
+  
   /* This must stay even at new releases! */
   if (has_capability("conn_info", pc->capability)) {
     dio_put_uint32(&dout, pc->id);
@@ -1695,12 +1697,15 @@
 **************************************************************************/
 struct packet_login_reply *receive_packet_login_reply(struct connection *pc)
 {
+  int data;
   RECEIVE_PACKET_START(packet_login_reply, packet);
 
   dio_get_bool32(&din, &packet->you_can_login);
   dio_get_string(&din, packet->message, sizeof(packet->message));
   dio_get_string(&din, packet->capability, sizeof(packet->capability));
-
+  dio_get_uint8(&din, &data);
+  packet->access_level = data;
+  
   /* This must stay even at new releases! */
   /* NOTE: pc doesn't yet have capability filled in!  Use packet value: */
   if (has_capability("conn_info", packet->capability)) {
diff -u -r freeciv/common/packets.h fc/common/packets.h
--- freeciv/common/packets.h    2003-08-05 09:49:28.000000000 +0200
+++ fc/common/packets.h 2003-08-16 19:02:19.000000000 +0200
@@ -130,6 +130,7 @@
   PACKET_PING_INFO,
   PACKET_AUTHENTICATION_REQUEST,
   PACKET_AUTHENTICATION_REPLY,
+  PACKET_NEW_ACCESS_LEVEL,
   PACKET_LAST  /* leave this last */
 };
 
@@ -421,6 +422,7 @@
   char message[MAX_LEN_MSG];
   char capability[MAX_LEN_CAPSTR];
   int conn_id;                 /* clients conn id as known in server */
+  enum cmdlevel_id access_level;       /* current client access level */
 };
 
 /*********************************************************
diff -u -r freeciv/server/stdinhand.c fc/server/stdinhand.c
--- freeciv/server/stdinhand.c  2003-08-11 12:03:13.000000000 +0200
+++ fc/server/stdinhand.c       2003-08-16 21:57:09.000000000 +0200
@@ -2104,7 +2104,11 @@
              cmdlevel_name(caller->access_level));
     return FALSE;
   } else {
+    struct packet_generic_integer packet;
+   
     ptarget->access_level = level;
+    packet.value = level;
+    send_packet_generic_integer(ptarget, PACKET_NEW_ACCESS_LEVEL, &packet);
     return TRUE;
   }
 }
@@ -2313,7 +2317,11 @@
        _("Someone else already has command access level '%s' or better."),
                cmdlevel_name(first_access_level));
   } else {
+    struct packet_generic_integer packet;
+   
     caller->access_level = first_access_level;
+    packet.value = first_access_level;
+    send_packet_generic_integer(caller, PACKET_NEW_ACCESS_LEVEL, &packet);
     cmd_reply(CMD_FIRSTLEVEL, caller, C_OK,
        _("Command access level '%s' has been grabbed by connection %s."),
                cmdlevel_name(first_access_level),

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#5117) sending access level info to client., Rafa³ Bursig <=