From 864bc7fda94095e02398b8aa85b3e084ea56c2d6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 30 Sep 2023 22:27:06 +0300 Subject: [PATCH 43/43] Check "Tile_Workable" effect value at turn change Make cities to stop working tiles they no longer can. Reported by ihnatus See osdn #46423 Signed-off-by: Marko Lindqvist --- server/cityturn.c | 25 +++++++++++++++++++++++++ server/cityturn.h | 2 ++ server/srv_main.c | 1 + 3 files changed, 28 insertions(+) diff --git a/server/cityturn.c b/server/cityturn.c index 37aacdc04e..969bd624a8 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -4538,3 +4538,28 @@ void city_counters_refresh(struct city *pcity) lsend_packet_city_update_counters(pcity->owner->connections, &packet); lsend_packet_city_update_counters(game.glob_observers, &packet); } + +/**********************************************************************//** + Recalculate some city related effects on turn change +**************************************************************************/ +void city_tc_effect_refresh(struct player *pplayer) +{ + city_list_iterate(pplayer->cities, pcity) { + bool changed = FALSE; + + city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), + city_tile(pcity), ptile, idx, x, y) { + if (ptile->worked == pcity + && get_city_tile_output_bonus(pcity, ptile, NULL, EFT_TILE_WORKABLE) <= 0) { + city_map_update_empty(pcity, ptile); + pcity->specialists[DEFAULT_SPECIALIST]++; + changed = TRUE; + } + } city_tile_iterate_skip_free_worked_end; + + if (changed) { + auto_arrange_workers(pcity); + send_city_info(NULL, pcity); + } + } city_list_iterate_end; +} diff --git a/server/cityturn.h b/server/cityturn.h index 503fa42659..49df88073e 100644 --- a/server/cityturn.h +++ b/server/cityturn.h @@ -56,6 +56,8 @@ bool check_city_migrations(void); void check_disasters(void); +void city_tc_effect_refresh(struct player *pplayer); + void city_style_refresh(struct city *pcity); bool player_balance_treasury_units_and_buildings(struct player *pplayer); diff --git a/server/srv_main.c b/server/srv_main.c index 10a311a763..94a15e7280 100644 --- a/server/srv_main.c +++ b/server/srv_main.c @@ -1305,6 +1305,7 @@ static void begin_phase(bool is_new_phase) } phase_players_iterate_end; phase_players_iterate(pplayer) { + city_tc_effect_refresh(pplayer); unit_tc_effect_refresh(pplayer); } phase_players_iterate_end; -- 2.40.1