Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify layer_units::fill_sprite_array
Browse files Browse the repository at this point in the history
We have layer::do_draw_unit, so use it.  Also simplify away the XOR.
lmoureaux committed Jul 6, 2022
1 parent eb7d818 commit 816a04e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions client/layer_units.cpp
Original file line number Diff line number Diff line change
@@ -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<drawn_sprite> 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<drawn_sprite> sprs;
fill_unit_sprite_array(tileset(), sprs, ptile, punit);
return sprs;
}

0 comments on commit 816a04e

Please sign in to comment.