Author: cazfi
Date: Sat Dec 13 23:58:08 2014
New Revision: 27288

URL: http://svn.gna.org/viewcvs/freeciv?rev=27288&view=rev
Log:
Send worker tasks to global observers.

See patch #5498

Modified:
    trunk/client/packhand.c
    trunk/common/game.h
    trunk/server/citytools.c
    trunk/server/connecthand.c
    trunk/server/sernet.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=27288&r1=27287&r2=27288&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Sat Dec 13 23:58:08 2014
@@ -1100,7 +1100,8 @@
 {
   struct city *pcity = game_city_by_number(packet->city_id);
 
-  if (pcity == NULL || pcity->owner != client.conn.playing) {
+  if (pcity == NULL
+      || (pcity->owner != client.conn.playing && 
!client_is_global_observer())) {
     return;
   }
 

Modified: trunk/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=27288&r1=27287&r2=27288&view=diff
==============================================================================
--- trunk/common/game.h (original)
+++ trunk/common/game.h Sat Dec 13 23:58:08 2014
@@ -82,6 +82,7 @@
 
   struct conn_list *all_connections;   /* including not yet established */
   struct conn_list *est_connections;   /* all established client conns */
+  struct conn_list *glob_observers;    /* global observers */
 
   struct veteran_system *veteran; /* veteran system */
 

Modified: trunk/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=27288&r1=27287&r2=27288&view=diff
==============================================================================
--- trunk/server/citytools.c    (original)
+++ trunk/server/citytools.c    Sat Dec 13 23:58:08 2014
@@ -3039,7 +3039,7 @@
   packet.want = 0;
 
   lsend_packet_worker_task(city_owner(pcity)->connections, &packet);
-  /* TODO: Send to global observers */
+  lsend_packet_worker_task(game.glob_observers, &packet);
 }
 
 /**************************************************************************
@@ -3064,5 +3064,5 @@
   packet.want = pcity->task_req.want;
 
   lsend_packet_worker_task(city_owner(pcity)->connections, &packet);
-  /* TODO: Send to global observers */
-}
+  lsend_packet_worker_task(game.glob_observers, &packet);
+}

Modified: trunk/server/connecthand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/connecthand.c?rev=27288&r1=27287&r2=27288&view=diff
==============================================================================
--- trunk/server/connecthand.c  (original)
+++ trunk/server/connecthand.c  Sat Dec 13 23:58:08 2014
@@ -613,6 +613,25 @@
     }
 
     send_player_info_c(pplayer, game.est_connections);
+
+    /* Remove from global observers list, if was there */
+    conn_list_remove(game.glob_observers, pconn);
+  } else if (pplayer == NULL) {
+    /* Global observer */
+    bool already = FALSE;
+
+    fc_assert(observing);
+
+    conn_list_iterate(game.glob_observers, pconn2) {
+      if (pconn2 == pconn) {
+        already = TRUE;
+        break;
+      }
+    } conn_list_iterate_end;
+
+    if (!already) {
+      conn_list_append(game.glob_observers, pconn);
+    }
   }
 
   /* We don't want the connection's username on another player. */

Modified: trunk/server/sernet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/sernet.c?rev=27288&r1=27287&r2=27288&view=diff
==============================================================================
--- trunk/server/sernet.c       (original)
+++ trunk/server/sernet.c       Sat Dec 13 23:58:08 2014
@@ -211,6 +211,7 @@
   pconn->server.ignore_list = NULL;
 
   /* safe to do these even if not in lists: */
+  conn_list_remove(game.glob_observers, pconn);
   conn_list_remove(game.all_connections, pconn);
   conn_list_remove(game.est_connections, pconn);
 
@@ -228,16 +229,18 @@
 void close_connections_and_socket(void)
 {
   int i;
+
   lsend_packet_server_shutdown(game.all_connections);
 
-  for(i=0; i<MAX_NUM_CONNECTIONS; i++) {
-    if(connections[i].used) {
+  for (i = 0; i < MAX_NUM_CONNECTIONS; i++) {
+    if (connections[i].used) {
       close_connection(&connections[i]);
     }
     conn_list_destroy(connections[i].self);
   }
 
   /* Remove the game connection lists and make sure they are empty. */
+  conn_list_destroy(game.glob_observers);
   conn_list_destroy(game.all_connections);
   conn_list_destroy(game.est_connections);
 
@@ -281,6 +284,7 @@
         closing[num++] = pconn;
         /* Remove closing connections from the lists (hard detach)
          * to avoid sending to closing connections. */
+        conn_list_remove(game.glob_observers, pconn);
         conn_list_remove(game.est_connections, pconn);
         conn_list_remove(game.all_connections, pconn);
         if (NULL != conn_get_player(pconn)) {
@@ -1287,6 +1291,7 @@
 
   game.all_connections = conn_list_new();
   game.est_connections = conn_list_new();
+  game.glob_observers = conn_list_new();
 
   for(i=0; i<MAX_NUM_CONNECTIONS; i++) { 
     struct connection *pconn = &connections[i];


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

Reply via email to