From 9dd6fe829cce3508a186874694da82a7d5495675 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 17 Dec 2022 16:49:09 +0200 Subject: [PATCH 17/17] Refresh unit vision at turn change Requested by Louis Moureaux See osdn #46182 Signed-off-by: Marko Lindqvist --- server/srv_main.c | 13 ++++++++++--- server/unittools.c | 12 +++++++++++- server/unittools.h | 5 +++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/server/srv_main.c b/server/srv_main.c index ff63ab2b13..4410425733 100644 --- a/server/srv_main.c +++ b/server/srv_main.c @@ -1202,7 +1202,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) @@ -1231,7 +1231,7 @@ static void begin_phase(bool is_new_phase) /* Must be the first thing as it is needed for lots of functions below! */ phase_players_iterate(pplayer) { - /* human players also need this for building advice */ + /* Human players also need this for building advice */ adv_data_phase_init(pplayer, is_new_phase); CALL_PLR_AI_FUNC(phase_begin, pplayer, pplayer, is_new_phase); } phase_players_iterate_end; @@ -1243,15 +1243,22 @@ static void begin_phase(bool is_new_phase) 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) { 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(); } @@ -1267,7 +1274,7 @@ static void begin_phase(bool is_new_phase) send_player_cities(pplayer); } phase_players_iterate_end; - flush_packets(); /* to curb major city spam */ + flush_packets(); /* To curb major city spam */ conn_list_do_unbuffer(game.est_connections); alive_phase_players_iterate(pplayer) { diff --git a/server/unittools.c b/server/unittools.c index 608dd16616..6ba96ef7fc 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -1481,6 +1481,16 @@ static bool is_refuel_tile(const struct tile *ptile, return FALSE; } +/**********************************************************************//** + 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; +} + /**********************************************************************//** Is unit being refueled in its current position **************************************************************************/ @@ -4592,7 +4602,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 7a0a25bb93..68e675ce31 100644 --- a/server/unittools.h +++ b/server/unittools.h @@ -95,9 +95,10 @@ bool is_refuel_point(const struct tile *ptile, void player_restore_units(struct player *pplayer); void update_unit_activities(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, @@ -176,4 +177,4 @@ void unit_activities_cancel_all_illegal_area(const struct tile *ptile); void unit_get_goods(struct unit *punit); -#endif /* FC__UNITTOOLS_H */ +#endif /* FC__UNITTOOLS_H */ -- 2.35.1