From 1fa1a3649002c3b117257176ff9cc16a917f0cec Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 11 Jun 2023 09:33:27 +0300 Subject: [PATCH 14/14] 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 | 32 ++++++++++++++++---------------- client/mapview_common.h | 3 ++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/mapview_common.c b/client/mapview_common.c index 6dd137a5d0..376445c2dc 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -2429,7 +2429,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. ****************************************************************************/ @@ -2444,27 +2444,27 @@ bool show_unit_orders(struct unit *punit) struct unit_order *order; if (punit->orders.index + i >= punit->orders.length - && !punit->orders.repeat) { - break; + && !punit->orders.repeat) { + break; + } + + if (ptile == NULL) { + /* This shouldn't happen unless the server gives us invalid + * data. */ + log_error("Unit orders with illegal tile."); + break; } order = &punit->orders.list[idx]; switch (order->order) { case ORDER_MOVE: - draw_segment(ptile, order->dir); - ptile = mapstep(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; + draw_segment(ptile, order->dir); + ptile = mapstep(ptile, order->dir); + break; default: - /* TODO: graphics for other orders. */ - break; + /* TODO: Graphics for other orders. */ + break; } } return TRUE; @@ -2474,7 +2474,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 7f8b411618..f7661bcc20 100644 --- a/client/mapview_common.h +++ b/client/mapview_common.h @@ -313,7 +313,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