From 2ace908c6a0302b9d56719934111f07f87118fcf Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 11 Jun 2023 10:15:25 +0300 Subject: [PATCH 43/43] 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 | 16 ++++++++-------- client/mapview_common.h | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client/mapview_common.c b/client/mapview_common.c index 56b211fd42..44a4726401 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -2468,22 +2468,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; } } diff --git a/client/mapview_common.h b/client/mapview_common.h index 3077d0b152..2d2a3c5fd7 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