Author: cazfi Date: Fri Jun 24 12:10:42 2016 New Revision: 33003 URL: http://svn.gna.org/viewcvs/freeciv?rev=33003&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: trunk/server/citytools.c trunk/server/cityturn.c trunk/server/cityturn.h trunk/server/srv_main.c Modified: trunk/server/citytools.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=33003&r1=33002&r2=33003&view=diff ============================================================================== --- trunk/server/citytools.c (original) +++ trunk/server/citytools.c Fri Jun 24 12:10:42 2016 @@ -2195,8 +2195,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: trunk/server/cityturn.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=33003&r1=33002&r2=33003&view=diff ============================================================================== --- trunk/server/cityturn.c (original) +++ trunk/server/cityturn.c Fri Jun 24 12:10:42 2016 @@ -144,7 +144,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 @@ -3040,7 +3040,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) { @@ -3622,17 +3622,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 */ @@ -3641,8 +3645,12 @@ continue; } - check_city_migrations_player(pplayer); + if (check_city_migrations_player(pplayer)) { + internat = TRUE; + } } players_iterate_end; + + return internat; } /************************************************************************** @@ -3819,13 +3827,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 @@ -3951,6 +3960,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. */ @@ -3962,12 +3972,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: trunk/server/cityturn.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.h?rev=33003&r1=33002&r2=33003&view=diff ============================================================================== --- trunk/server/cityturn.h (original) +++ trunk/server/cityturn.h Fri Jun 24 12:10:42 2016 @@ -48,7 +48,7 @@ void nullify_prechange_production(struct city *pcity); -void check_city_migrations(void); +bool check_city_migrations(void); void check_disasters(void); Modified: trunk/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=33003&r1=33002&r2=33003&view=diff ============================================================================== --- trunk/server/srv_main.c (original) +++ trunk/server/srv_main.c Fri Jun 24 12:10:42 2016 @@ -1307,7 +1307,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