Author: pepeto
Date: Sun Sep  7 10:27:28 2014
New Revision: 26264

URL: http://svn.gna.org/viewcvs/freeciv?rev=26264&view=rev
Log:
Do not send the vote updates to the connecting user before he has received the
vote info itself. It happened in server initial state when a user joined when
they were running votes.

Reported by mir3x

See gna bug #22566

Modified:
    branches/S2_5/server/connecthand.c

Modified: branches/S2_5/server/connecthand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/connecthand.c?rev=26264&r1=26263&r2=26264&view=diff
==============================================================================
--- branches/S2_5/server/connecthand.c  (original)
+++ branches/S2_5/server/connecthand.c  Sun Sep  7 10:27:28 2014
@@ -223,7 +223,10 @@
       }
     } else {
       if (!game_was_started()) {
-        if (!connection_attach(pconn, NULL, FALSE)) {
+        if (connection_attach_real(pconn, NULL, FALSE, TRUE)) {
+          pplayer = conn_get_player(pconn);
+          fc_assert(pplayer != NULL);
+        } else {
           notify_conn(dest, NULL, E_CONNECTION, ftc_server,
                       _("Couldn't attach your connection to new player."));
           log_verbose("%s is not attached to a player", pconn->username);
@@ -235,25 +238,16 @@
 
   send_conn_info(game.est_connections, dest);
 
-  send_pending_events(pconn, TRUE);
-  send_running_votes(pconn, FALSE);
-
   if (NULL == pplayer) {
-    /* Else this has already been done in connection_attach(). */
+    /* Else this has already been done in connection_attach_real(). */
+    send_pending_events(pconn, TRUE);
+    send_running_votes(pconn, FALSE);
     restore_access_level(pconn);
     send_conn_info(dest, game.est_connections);
-  }
-
-  /* remind the connection who he is */
-  if (NULL == pconn->playing) {
+
     notify_conn(dest, NULL, E_CONNECTION, ftc_server,
                _("You are logged in as '%s' connected to no player."),
                 pconn->username);
-  } else if (strcmp(player_name(pconn->playing), ANON_PLAYER_NAME) == 0) {
-    notify_conn(dest, NULL, E_CONNECTION, ftc_server,
-               _("You are logged in as '%s' connected to an "
-                 "anonymous player."),
-               pconn->username);
   } else {
     notify_conn(dest, NULL, E_CONNECTION, ftc_server,
                _("You are logged in as '%s' connected to %s."),
@@ -646,6 +640,8 @@
    * connecthand.c::establish_new_connection(). */
   switch (server_state()) {
   case S_S_INITIAL:
+    send_pending_events(pconn, connecting);
+    send_running_votes(pconn, !connecting);
     break;
 
   case S_S_RUNNING:
@@ -659,11 +655,8 @@
     dsend_packet_start_phase(pconn, game.info.phase);
     /* Must be after C_S_RUNNING client state to be effective. */
     send_diplomatic_meetings(pconn);
-    if (!connecting) {
-      /* Those will be sent later in establish_new_connection(). */
-      send_pending_events(pconn, FALSE);
-      send_running_votes(pconn, TRUE);
-    }
+    send_pending_events(pconn, connecting);
+    send_running_votes(pconn, !connecting);
     break;
 
   case S_S_OVER:
@@ -674,10 +667,9 @@
     }
     conn_compression_thaw(pconn);
     report_final_scores(pconn->self);
+    send_pending_events(pconn, connecting);
+    send_running_votes(pconn, !connecting);
     if (!connecting) {
-      /* Those will be sent later in establish_new_connection(). */
-      send_pending_events(pconn, FALSE);
-      send_running_votes(pconn, TRUE);
       /* Send information about delegation(s). */
       send_delegation_info(pconn);
     }


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

Reply via email to