From 9a157a51da44121c39639b68bcc8150b942c94cc Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 11 Jun 2023 09:52:19 +0300 Subject: [PATCH 22/22] show_unit_orders(): Check initial tile Loop to go through unit order steps checked target tile only when orders caused it to update, but not the tile unit starts from. See osdn #48139 Signed-off-by: Marko Lindqvist --- client/mapview_common.c | 20 ++++++++++---------- client/mapview_common.h | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/client/mapview_common.c b/client/mapview_common.c index 29e6dcf207..8721fcee86 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -2432,7 +2432,7 @@ void show_tile_labels(int canvas_base_x, int canvas_base_y, } /************************************************************************//** - Draw the goto route for the unit. Return TRUE if anything is drawn. + Draw the goto route for the unit. Return TRUE if anything is drawn. This duplicates drawing code that is run during the hover state. ****************************************************************************/ @@ -2451,22 +2451,22 @@ bool show_unit_orders(struct unit *punit) break; } + if (ptile == NULL) { + /* This shouldn't happen unless the server gives us invalid + * data. */ + log_warn("Unit orders with illegal tile."); + break; + } + order = &punit->orders.list[idx]; switch (order->order) { case ORDER_MOVE: draw_segment(ptile, order->dir); ptile = mapstep(&(wld.map), ptile, order->dir); - if (!ptile) { - /* This shouldn't happen unless the server gives us invalid - * data. To avoid disaster we need to break out of the - * switch and the enclosing for loop. */ - fc_assert(NULL != ptile); - i = punit->orders.length; - } break; default: - /* TODO: graphics for other orders. */ + /* TODO: Graphics for other orders. */ break; } } @@ -2477,7 +2477,7 @@ bool show_unit_orders(struct unit *punit) } /************************************************************************//** - Draw a goto line at the given location and direction. The line goes from + Draw a goto line at the given location and direction. The line goes from the source tile to the adjacent tile in the given direction. ****************************************************************************/ void draw_segment(struct tile *src_tile, enum direction8 dir) diff --git a/client/mapview_common.h b/client/mapview_common.h index da6292720b..ae9db84238 100644 --- a/client/mapview_common.h +++ b/client/mapview_common.h @@ -315,7 +315,8 @@ void show_tile_labels(int canvas_base_x, int canvas_base_y, int width_base, int height_base); bool show_unit_orders(struct unit *punit); -void draw_segment(struct tile *ptile, enum direction8 dir); +void draw_segment(struct tile *ptile, enum direction8 dir) + fc__attribute((nonnull (1))); void decrease_unit_hp_smooth(struct unit *punit0, int hp0, struct unit *punit1, int hp1); -- 2.39.2