Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] Re: (PR#4787) observers shouldn't get nation selection dia
Home

[Freeciv-Dev] Re: (PR#4787) observers shouldn't get nation selection dia

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4787) observers shouldn't get nation selection dialog
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Sep 2003 22:28:01 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Well, a much more difficult problem to track down than expected. It seems
that until now, the client never could have known it was an observer at all.
struct aconnection never got updated.

I also fixed the revolution popup, so the observer doesn't get that either.

please test.

-mike

diff -Nur -Xsnap/diff_ignore snap/client/packhand.c snap-obs/client/packhand.c
--- snap/client/packhand.c      2003-09-09 22:24:42.000000000 -0500
+++ snap-obs/client/packhand.c  2003-09-13 00:22:42.000000000 -0500
@@ -148,13 +148,13 @@
   if (packet->you_can_login) {
     freelog(LOG_VERBOSE, "join game accept:%s", packet->message);
     aconnection.established = TRUE;
-    game.conn_id = packet->conn_id;
+    aconnection.id = packet->conn_id;
     agents_game_joined();
   } else {
     my_snprintf(msg, sizeof(msg),
                _("You were rejected from the game: %s"), packet->message);
     append_output_window(msg);
-    game.conn_id = 0;
+    aconnection.id = 0;
     if (auto_connect) {
       freelog(LOG_NORMAL, "%s", msg);
     }
@@ -1388,7 +1388,7 @@
                               PACKET_PLAYER_GOVERNMENT);
 
     government_selected = FALSE;
-  } else {
+  } else if (!client_is_observer()) {
     popup_government_dialog();
   }
 }
@@ -1516,7 +1516,7 @@
 void handle_conn_info(struct packet_conn_info *pinfo)
 {
   struct connection *pconn = find_conn_by_id(pinfo->id);
-  
+
   freelog(LOG_DEBUG, "conn_info id%d used%d est%d plr%d obs%d acc%d",
          pinfo->id, pinfo->used, pinfo->established, pinfo->player_num,
          pinfo->observer, (int)pinfo->access_level);
@@ -1531,8 +1531,7 @@
     }
     client_remove_cli_conn(pconn);
     pconn = NULL;
-  }
-  else {
+  } else {
     /* Add or update the connection */
     struct player *pplayer =
       ((pinfo->player_num >= 0 && pinfo->player_num < game.nplayers)
@@ -1541,6 +1540,7 @@
     if (!pconn) {
       freelog(LOG_VERBOSE, "Server reports new connection %d %s",
              pinfo->id, pinfo->username);
+
       pconn = fc_calloc(1, sizeof(struct connection));
       pconn->buffer = NULL;
       pconn->send_buffer = NULL;
@@ -1571,6 +1571,13 @@
     sz_strlcpy(pconn->username, pinfo->username);
     sz_strlcpy(pconn->addr, pinfo->addr);
     sz_strlcpy(pconn->capability, pinfo->capability);
+
+    if (pinfo->id == aconnection.id) {
+      aconnection.established = pconn->established;
+      aconnection.observer = pconn->observer;
+      aconnection.access_level = pconn->access_level;
+      aconnection.player = pplayer;
+    }
   }
   update_players_dialog();
   update_conn_list_dialog();
@@ -1909,9 +1916,12 @@
     }
   } else if (get_client_state() == CLIENT_PRE_GAME_STATE) {
     set_client_state(CLIENT_SELECT_RACE_STATE);
-    popup_races_dialog();
-    assert(packet != NULL);
-    races_toggles_set_sensitive(packet);
+
+    if (!client_is_observer()) {
+      popup_races_dialog();
+      assert(packet != NULL);
+      races_toggles_set_sensitive(packet);
+    }
   } else {
     freelog(LOG_ERROR,
            "got a select nation packet in an incompatible state");
diff -Nur -Xsnap/diff_ignore snap/common/game.c snap-obs/common/game.c
--- snap/common/game.c  2003-08-10 09:43:36.000000000 -0500
+++ snap-obs/common/game.c      2003-09-12 23:30:39.000000000 -0500
@@ -301,7 +301,6 @@
     game.global_advances[i]=0;
   for (i=0; i<B_LAST; i++)      /* game.num_impr_types = 0 here */
     game.global_wonders[i]=0;
-  game.conn_id = 0;
   game.player_idx=0;
   game.player_ptr=&game.players[0];
   terrain_control.river_help_text = NULL;
diff -Nur -Xsnap/diff_ignore snap/common/game.h snap-obs/common/game.h
--- snap/common/game.h  2003-09-09 22:24:44.000000000 -0500
+++ snap-obs/common/game.h      2003-09-12 23:28:38.000000000 -0500
@@ -97,7 +97,6 @@
   int unhappysize;
   bool angrycitizen;
   char *startmessage;
-  int conn_id;                 /* client-only: id client known to server as */
   int player_idx;
   struct player *player_ptr;
   struct player players[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
diff -Nur -Xsnap/diff_ignore snap/server/connecthand.c 
snap-obs/server/connecthand.c
--- snap/server/connecthand.c   2003-09-12 21:19:16.000000000 -0500
+++ snap-obs/server/connecthand.c       2003-09-12 23:51:17.000000000 -0500
@@ -92,9 +92,6 @@
 
   /* "establish" the connection */
   pconn->established = TRUE;
-  send_conn_info(dest, &game.est_connections);
-  conn_list_insert_back(&game.est_connections, pconn);
-  send_conn_info(&game.est_connections, dest);
 
   /* introduce the server to the connection */
   if (my_gethostname(hostname, sizeof(hostname)) == 0) {
@@ -179,6 +176,9 @@
     show_players(pconn);
   }
 
+  send_conn_info(dest, &game.est_connections);
+  conn_list_insert_back(&game.est_connections, pconn);
+  send_conn_info(&game.est_connections, dest);
   (void) send_server_info_to_metaserver(TRUE, FALSE);
 }
 
diff -Nur -Xsnap/diff_ignore snap/server/stdinhand.c snap-obs/server/stdinhand.c
--- snap/server/stdinhand.c     2003-09-09 22:24:44.000000000 -0500
+++ snap-obs/server/stdinhand.c 2003-09-12 21:26:04.000000000 -0500
@@ -3311,6 +3311,9 @@
     send_packet_generic_empty(pconn, PACKET_START_TURN);
   }
 
+  /* tell everyone that pconn is observing */
+  send_conn_info(&pconn->self, &game.est_connections);
+
   cmd_reply(CMD_OBSERVE, caller, C_OK, _("%s now observes %s"),
             pconn->username, pplayer->name);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#4787) observers shouldn't get nation selection dialog, Mike Kaufman <=