From 816a04e644397f9304998580fdb8c6d438a107eb Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Thu, 7 Jul 2022 00:46:59 +0200 Subject: [PATCH] Simplify layer_units::fill_sprite_array We have layer::do_draw_unit, so use it. Also simplify away the XOR. --- client/layer_units.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/client/layer_units.cpp b/client/layer_units.cpp index f980ae6674..2fe6d2fcbf 100644 --- a/client/layer_units.cpp +++ b/client/layer_units.cpp @@ -33,23 +33,18 @@ layer_units::fill_sprite_array(const tile *ptile, const tile_edge *pedge, Q_UNUSED(pedge); Q_UNUSED(pcorner); - // We need to have something to draw - if (!punit) { + // Should we draw anything in the first place? + if (!do_draw_unit(ptile, punit)) { return {}; } - std::vector sprs; - - /* Unit drawing is disabled when the view options are turned off, - * but only where we're drawing on the mapview. */ - bool do_draw_unit = - gui_options.draw_units - || (gui_options.draw_focus_unit && unit_is_in_focus(punit)); - - if (do_draw_unit && XOR(type() == LAYER_UNIT, unit_is_in_focus(punit))) { - fill_unit_sprite_array(tileset(), sprs, ptile, punit); + // Only draw the focused unit on LAYER_FOCUS_UNIT + if (type() != LAYER_FOCUS_UNIT && unit_is_in_focus(punit)) { + return {}; } + std::vector sprs; + fill_unit_sprite_array(tileset(), sprs, ptile, punit); return sprs; }