Author: cazfi
Date: Fri Jun 24 12:10:48 2016
New Revision: 33004

URL: http://svn.gna.org/viewcvs/freeciv?rev=33004&view=rev
Log:
If there's international migration between two players' cities,
refresh cities on everyone's clients.

Reported by Frank <dunnoob>

See bug #24464

Modified:
    branches/S2_6/server/citytools.c
    branches/S2_6/server/cityturn.c
    branches/S2_6/server/cityturn.h
    branches/S2_6/server/srv_main.c

Modified: branches/S2_6/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/citytools.c?rev=33004&r1=33003&r2=33004&view=diff
==============================================================================
--- branches/S2_6/server/citytools.c    (original)
+++ branches/S2_6/server/citytools.c    Fri Jun 24 12:10:48 2016
@@ -2176,8 +2176,9 @@
 {
   struct player *powner = city_owner(pcity);
 
-  if (S_S_RUNNING != server_state() && S_S_OVER != server_state())
+  if (S_S_RUNNING != server_state() && S_S_OVER != server_state()) {
     return;
+  }
 
   if (dest == powner && send_city_suppressed) {
     return;

Modified: branches/S2_6/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/cityturn.c?rev=33004&r1=33003&r2=33004&view=diff
==============================================================================
--- branches/S2_6/server/cityturn.c     (original)
+++ branches/S2_6/server/cityturn.c     Fri Jun 24 12:10:48 2016
@@ -138,7 +138,7 @@
 static float city_migration_score(struct city *pcity);
 static bool do_city_migration(struct city *pcity_from,
                               struct city *pcity_to);
-static void check_city_migrations_player(const struct player *pplayer);
+static bool check_city_migrations_player(const struct player *pplayer);
 
 /**************************************************************************
   Updates unit upkeeps and city internal cached data. Returns whether
@@ -2890,7 +2890,7 @@
 }
 
 /**************************************************************************
- Called every turn, at end of turn, for every city.
+  Called every turn, at end of turn, for every city.
 **************************************************************************/
 static void update_city_activity(struct city *pcity)
 {
@@ -3467,17 +3467,21 @@
 
   'game.server.mgr_worldchance' gives the chance for migration between all
   nations.
-**************************************************************************/
-void check_city_migrations(void)
-{
+
+  Returns TRUE iff there has been INTERNATIONAL migration.
+**************************************************************************/
+bool check_city_migrations(void)
+{
+  bool internat = FALSE;
+
   if (!game.server.migration) {
-    return;
+    return FALSE;
   }
 
   if (game.server.mgr_turninterval <= 0
       || (game.server.mgr_worldchance <= 0
           && game.server.mgr_nationchance <= 0)) {
-    return;
+    return FALSE;
   }
 
   /* check for migration */
@@ -3486,8 +3490,12 @@
       continue;
     }
 
-    check_city_migrations_player(pplayer);
+    if (check_city_migrations_player(pplayer)) {
+      internat = TRUE;
+    }
   } players_iterate_end;
+
+  return internat;
 }
 
 /**************************************************************************
@@ -3646,13 +3654,14 @@
   * if a city is found check the distance
   * compare the migration score
 **************************************************************************/
-static void check_city_migrations_player(const struct player *pplayer)
+static bool check_city_migrations_player(const struct player *pplayer)
 {
   char city_link_text[MAX_LEN_LINK];
   float best_city_player_score, best_city_world_score;
   struct city *best_city_player, *best_city_world, *acity;
   float score_from, score_tmp, weight;
   int dist, mgr_dist;
+  bool internat = FALSE;
 
   /* check for each city
    * city_list_iterate_safe_end must be used because we could
@@ -3778,6 +3787,7 @@
       /* second, do the migration between all nations */
       if (fc_rand(100) >= game.server.mgr_worldchance) {
         const char *nname;
+
         nname = nation_adjective_for_player(city_owner(best_city_world));
         /* no migration */
         /* N.B.: city_link always returns the same pointer. */
@@ -3789,12 +3799,15 @@
                       city_link_text, city_link(best_city_world), nname);
       } else {
         do_city_migration(pcity, best_city_world);
+        internat = TRUE;
       }
 
       /* stop here */
       continue;
     }
   } city_list_iterate_safe_end;
+
+  return internat;
 }
 
 /**************************************************************************

Modified: branches/S2_6/server/cityturn.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/cityturn.h?rev=33004&r1=33003&r2=33004&view=diff
==============================================================================
--- branches/S2_6/server/cityturn.h     (original)
+++ branches/S2_6/server/cityturn.h     Fri Jun 24 12:10:48 2016
@@ -46,7 +46,7 @@
 
 void nullify_prechange_production(struct city *pcity);
 
-void check_city_migrations(void);
+bool check_city_migrations(void);
 
 void check_disasters(void);
 

Modified: branches/S2_6/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/srv_main.c?rev=33004&r1=33003&r2=33004&view=diff
==============================================================================
--- branches/S2_6/server/srv_main.c     (original)
+++ branches/S2_6/server/srv_main.c     Fri Jun 24 12:10:48 2016
@@ -1272,7 +1272,15 @@
 
   if (game.server.migration) {
     log_debug("Season of migrations");
-    check_city_migrations();
+    if (check_city_migrations()) {
+      /* Make sure everyone has updated information about BOTH ends of the
+       * migration movements. */
+      players_iterate(plr) {
+        city_list_iterate(plr->cities, pcity) {
+          send_city_info(NULL, pcity);
+        } city_list_iterate_end;
+      } players_iterate_end;
+    }
   }
 
   check_disasters();


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

Reply via email to