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

Updated my patch that fixes the currently broken global
observer in S2_2 and trunk.


----------------------------------------------------------------------
待たせてごめん。
diff --git a/client/packhand.c b/client/packhand.c
index e5bee13..e88381c 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -1896,8 +1896,6 @@ void handle_conn_info(struct packet_conn_info *pinfo)
     client_remove_cli_conn(pconn);
     pconn = NULL;
   } else {
-    /* Add or update the connection.  Note the connection may refer to
-     * a player we don't know about yet; assume we will observe it. */
     struct player *pplayer = valid_player_by_number(pinfo->player_num);
 
     if (!pconn) {
@@ -1932,14 +1930,6 @@ void handle_conn_info(struct packet_conn_info *pinfo)
     pconn->access_level = pinfo->access_level;
     pconn->playing = pplayer;
 
-    if (NULL == pconn->playing && !pconn->observer) {
-      pconn->observer = TRUE; /* illegal 4th case, assume global observer */
-
-      freelog(LOG_ERROR, "handle_conn_info()"
-              " not playing, but not observer: %d %s",
-              pinfo->id, pinfo->username);
-    }
-
     if (pinfo->id == client.conn.id) {
       client.conn.established = pconn->established;
       client.conn.observer = pconn->observer;
diff --git a/server/connecthand.c b/server/connecthand.c
index 7bd7090..2be6e7a 100644
--- a/server/connecthand.c
+++ b/server/connecthand.c
@@ -385,15 +385,6 @@ static void package_conn_info(struct connection *pconn,
   sz_strlcpy(packet->username, pconn->username);
   sz_strlcpy(packet->addr, pconn->addr);
   sz_strlcpy(packet->capability, pconn->capability);
-
-#if 0
-  if (NULL == pconn->playing && !pconn->observer) {
-    freelog(LOG_FATAL, "package_conn_info()"
-            " not playing, but not observer: %d %s",
-            pconn->id, pconn->username);
-    assert((int)((char *)NULL)[0]);
-  }
-#endif
 }
 
 /**************************************************************************
@@ -454,7 +445,8 @@ struct player *find_uncontrolled_player(void)
 
 /**************************************************************************
   Setup pconn as a client connected to pplayer:
-  Updates pconn, pplayer->connections, pplayer->is_connected.
+  Updates pconn->playing, pplayer->connections, pplayer->is_connected
+  and pconn->observer.
 
   If pplayer is NULL, take the next available player that is not connected.
   Note "observer" connections do not count for is_connected.
@@ -512,13 +504,19 @@ bool attach_connection_to_player(struct connection *pconn,
   
 /**************************************************************************
   Remove pconn as a client connected to pplayer:
-  Update pplayer->connections, pplayer->is_connected.
+  Updates pconn->playing, pconn->playing->connections,
+  pconn->playing->is_connected and pconn->observer.
 
   pconn remains a member of game.est_connections.
+
+  The 'observing' parameter should be TRUE if 'pconn' is to become
+  a global observer, FALSE otherwise.
 **************************************************************************/
 bool detach_connection_to_player(struct connection *pconn,
                                  bool observing)
 {
+  pconn->observer = observing;
+
   if (NULL == pconn->playing) {
     return FALSE; /* no player is attached to this conn */
   }
@@ -526,7 +524,6 @@ bool detach_connection_to_player(struct connection *pconn,
   conn_list_unlink(pconn->playing->connections, pconn);
 
   pconn->playing->is_connected = FALSE;
-  pconn->observer = observing;
 
   /* If any other (non-observing) conn is attached to 
    * this player, the player is still connected. */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to