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

Second step: notify to the clients all changes about connections:
+ new created players names when a client joins.
+ lost detached connections.
+ when a player get detached after a /remove usage.
+ when a game is loaded with /load, notify all changes. Don't change the
page if there are many connected users: the chat is removed, then the
people cannot communicate or type commands.

Patch attached

Index: server/connecthand.c
===================================================================
--- server/connecthand.c	(révision 13752)
+++ server/connecthand.c	(copie de travail)
@@ -136,8 +136,6 @@
       notify_conn(dest, NULL, E_CONNECTION,
 		  _("Couldn't attach your connection to new player."));
       freelog(LOG_VERBOSE, "%s is not attached to a player", pconn->username);
-    } else {
-      sz_strlcpy(pconn->player->name, pconn->username);
     }
   }
 
@@ -428,6 +426,7 @@
       pplayer = &game.players[game.info.nplayers];
       server_player_init(pplayer, FALSE, TRUE);
       game.info.nplayers++;
+      sz_strlcpy(pplayer->name, pconn->username);
     }
   }
 
Index: server/sernet.c
===================================================================
--- server/sernet.c	(révision 13752)
+++ server/sernet.c	(copie de travail)
@@ -211,6 +211,8 @@
   pconn->player = NULL;
   pconn->access_level = ALLOW_NONE;
   connection_common_close(pconn);
+
+  send_conn_info(pconn->self, game.est_connections);
 }
 
 /*****************************************************************************
Index: server/stdinhand.c
===================================================================
--- server/stdinhand.c	(révision 13752)
+++ server/stdinhand.c	(copie de travail)
@@ -3266,6 +3266,15 @@
     return TRUE;
   }
 
+  /* Detach all connection to prevent client crashes. */
+  conn_list_iterate(game.est_connections, pconn) {
+    if (pconn->player) {
+      unattach_connection_from_player(pconn);
+    }
+  } conn_list_iterate_end;
+  send_conn_info(game.est_connections, game.est_connections);
+  send_player_info(NULL, NULL);
+
   /* we found it, free all structures */
   server_game_free();
 
@@ -3290,16 +3299,17 @@
   send_game_info(game.est_connections);
   send_rulesets(game.est_connections);
 
-  /* Everything seemed to load ok; spread the good news. */
-  send_load_game_info(TRUE);
+  /* send_load_game_info() don't work well for multi-players games. */
+  if (conn_list_size(game.all_connections) == 1) {
+    send_load_game_info(TRUE);
+  } else {
+    send_player_info(NULL, NULL);
+  }
 
   /* attach connections to players. currently, this applies only 
    * to connections that have the correct username. Any attachments
    * made before the game load are unattached. */
   conn_list_iterate(game.est_connections, pconn) {
-    if (pconn->player) {
-      unattach_connection_from_player(pconn);
-    }
     players_iterate(pplayer) {
       if (strcmp(pconn->username, pplayer->username) == 0) {
         attach_connection_to_player(pconn, pplayer);
@@ -3307,6 +3316,8 @@
       }
     } players_iterate_end;
   } conn_list_iterate_end;
+  send_conn_info(game.est_connections, game.est_connections);
+
   return TRUE;
 }
 
Index: server/plrhand.c
===================================================================
--- server/plrhand.c	(révision 13752)
+++ server/plrhand.c	(copie de travail)
@@ -1127,6 +1127,7 @@
     if (!unattach_connection_from_player(pconn)) {
       die("player had a connection attached that didn't belong to it!");
     }
+    send_conn_info(pconn->self, game.est_connections);
   } conn_list_iterate_end;
 
   team_remove_player(pplayer);

_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to