From 8e9f39887f8db1e005897af0f5119b2c5ae51a20 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 30 Sep 2023 22:29:34 +0300 Subject: [PATCH 31/31] 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 | 24 ++++++++++++++++++++++++ server/cityturn.h | 2 ++ server/srv_main.c | 1 + 3 files changed, 27 insertions(+) diff --git a/server/cityturn.c b/server/cityturn.c index 68fac21309..313f64d062 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -4368,3 +4368,27 @@ void city_style_refresh(struct city *pcity) { pcity->style = city_style(pcity); } + +/**********************************************************************//** + 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 (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 9b833c9d19..e4cc0d7a9d 100644 --- a/server/cityturn.h +++ b/server/cityturn.h @@ -53,6 +53,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); #endif /* FC__CITYTURN_H */ diff --git a/server/srv_main.c b/server/srv_main.c index 08bc89456d..c341c8a7b0 100644 --- a/server/srv_main.c +++ b/server/srv_main.c @@ -1282,6 +1282,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