From 8272ccade5fc58d3ec42cd719aeefb3f58c57039 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 24 Mar 2021 22:44:46 +0200 Subject: [PATCH 22/23] Wait until city is in sane state before sending info packets Don't send city info packets to client in the middle of the city processing when city might be in inconsistent state. See osdn #41851 Signed-off-by: Marko Lindqvist --- server/citytools.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/server/citytools.c b/server/citytools.c index 58cc822f63..18c4da834f 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -2086,10 +2086,16 @@ static void broadcast_city_info(struct city *pcity) struct player *powner = city_owner(pcity); /* Send to everyone who can see the city. */ - package_city(pcity, &packet, FALSE); + if (!pcity->server.needs_arrange) { + /* Send city only when it's in sane state. + * If it's not, it will be sent to everyone once + * rearrangement has been finished. */ + package_city(pcity, &packet, FALSE); + } players_iterate(pplayer) { if (can_player_see_city_internals(pplayer, pcity)) { - if (!send_city_suppressed || pplayer != powner) { + if ((!send_city_suppressed || pplayer != powner) + && !pcity->server.needs_arrange) { update_dumb_city(powner, pcity); lsend_packet_city_info(powner->connections, &packet, FALSE); } @@ -2104,11 +2110,13 @@ static void broadcast_city_info(struct city *pcity) } players_iterate_end; /* Send to global observers. */ - conn_list_iterate(game.est_connections, pconn) { - if (conn_is_global_observer(pconn)) { - send_packet_city_info(pconn, &packet, FALSE); - } - } conn_list_iterate_end; + if (!pcity->server.needs_arrange) { + conn_list_iterate(game.est_connections, pconn) { + if (conn_is_global_observer(pconn)) { + send_packet_city_info(pconn, &packet, FALSE); + } + } conn_list_iterate_end; + } } /************************************************************************** @@ -2223,8 +2231,11 @@ void send_city_info_at_tile(struct player *pviewer, struct conn_list *dest, if (powner && powner == pviewer) { /* send info to owner */ /* This case implies powner non-NULL which means pcity non-NULL */ - if (!send_city_suppressed) { - /* send all info to the owner */ + if (!send_city_suppressed && !pcity->server.needs_arrange) { + /* Send all info to the owner. + * Wait that city has been rearranged, if it's currently + * not in sane state. + */ update_dumb_city(powner, pcity); package_city(pcity, &packet, FALSE); lsend_packet_city_info(dest, &packet, FALSE); @@ -2240,7 +2251,7 @@ void send_city_info_at_tile(struct player *pviewer, struct conn_list *dest, } else { /* send info to non-owner */ if (!pviewer) { /* observer */ - if (pcity) { + if (pcity && !pcity->server.needs_arrange) { package_city(pcity, &packet, FALSE); /* should be dumb_city info? */ lsend_packet_city_info(dest, &packet, FALSE); } -- 2.30.2