From cd326ca9c727ec4e00c7ee11884cdc9d7d5b4dae Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 17 Dec 2022 16:42:12 +0200 Subject: [PATCH 32/32] Refresh unit vision at turn change Requested by Louis Moureaux See osdn #46182 Signed-off-by: Marko Lindqvist --- server/srv_main.c | 12 ++++++++++-- server/unittools.c | 12 +++++++++++- server/unittools.h | 3 ++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/server/srv_main.c b/server/srv_main.c index dc0e0781ed..0848ea5c09 100644 --- a/server/srv_main.c +++ b/server/srv_main.c @@ -1191,7 +1191,7 @@ static void begin_turn(bool is_new_turn) } /**********************************************************************//** - Begin a phase of movement. This handles all beginning-of-phase actions + Begin a phase of movement. This handles all beginning-of-phase actions for one or more players. **************************************************************************/ static void begin_phase(bool is_new_phase) @@ -1264,10 +1264,12 @@ static void begin_phase(bool is_new_phase) } } } whole_map_iterate_end; + phase_players_iterate(pplayer) { update_unit_activities(pplayer); flush_packets(); } phase_players_iterate_end; + /* Execute orders after activities have been completed (roads built, * pillage done, etc.). */ phase_players_iterate(pplayer) { @@ -1275,16 +1277,22 @@ static void begin_phase(bool is_new_phase) script_server_signal_emit("player_phase_begin", pplayer, is_new_phase); if (player_by_number(plrid) != pplayer) { - /* removed */ + /* Removed */ continue; } random_movements(pplayer); execute_unit_orders(pplayer); flush_packets(); } phase_players_iterate_end; + + phase_players_iterate(pplayer) { + unit_tc_effect_refresh(pplayer); + } phase_players_iterate_end; + phase_players_iterate(pplayer) { finalize_unit_phase_beginning(pplayer); } phase_players_iterate_end; + flush_packets(); } diff --git a/server/unittools.c b/server/unittools.c index 2059a9bdc2..d6a0e22e74 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -698,6 +698,16 @@ void execute_unit_orders(struct player *pplayer) } unit_list_iterate_safe_end; } +/**********************************************************************//** + Recalculate some unit related effects on turn change +**************************************************************************/ +void unit_tc_effect_refresh(struct player *pplayer) +{ + unit_list_iterate(pplayer->units, punit) { + unit_refresh_vision(punit); + } unit_list_iterate_end; +} + /**********************************************************************//** Iterate through all units and remember their current activities. **************************************************************************/ @@ -4785,7 +4795,7 @@ void unit_refresh_vision(struct unit *punit) } /**********************************************************************//** - Refresh the vision of all units in the list - see unit_refresh_vision. + Refresh the vision of all units in the list - see unit_refresh_vision(). **************************************************************************/ void unit_list_refresh_vision(struct unit_list *punitlist) { diff --git a/server/unittools.h b/server/unittools.h index 239b139878..3a2bf1055a 100644 --- a/server/unittools.h +++ b/server/unittools.h @@ -99,9 +99,10 @@ void player_restore_units(struct player *pplayer); void update_unit_activities(struct player *pplayer); void random_movements(struct player *pplayer); void execute_unit_orders(struct player *pplayer); +void unit_tc_effect_refresh(struct player *pplayer); void finalize_unit_phase_beginning(struct player *pplayer); -/* various */ +/* Various */ void place_partisans(struct tile *pcenter, struct player *powner, int count, int sq_radius); bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost, -- 2.35.1