From ca01a4be02fb529d854c2eea3239c3827119fc64 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Tue, 10 Jun 2014 12:58:53 -0400 Subject: [PATCH] facing and hidden become mutable attributes of unit This is needed to be able to do animation with const units. --- src/unit.cpp | 4 ++-- src/unit.hpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unit.cpp b/src/unit.cpp index 8527a404c677..f1f517e73e87 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -1877,7 +1877,7 @@ void unit::start_animation (int start_time, const unit_animation *animation, } -void unit::set_facing(map_location::DIRECTION dir) { +void unit::set_facing(map_location::DIRECTION dir) const { if(dir != map_location::NDIRECTIONS) { facing_ = dir; } @@ -3118,7 +3118,7 @@ void unit::remove_movement_ai() } -void unit::set_hidden(bool state) { +void unit::set_hidden(bool state) const { hidden_ = state; if(!state) return; // We need to get rid of haloes immediately to avoid display glitches diff --git a/src/unit.hpp b/src/unit.hpp index 02d323c06b49..4f769c6a9a96 100644 --- a/src/unit.hpp +++ b/src/unit.hpp @@ -261,7 +261,7 @@ class unit void set_idling() const; void set_selecting() const; unit_animation* get_animation() const { return anim_.get();} - void set_facing(map_location::DIRECTION dir); + void set_facing(map_location::DIRECTION dir) const; map_location::DIRECTION facing() const { return facing_; } bool invalidate(const display & disp) const; @@ -281,7 +281,7 @@ class unit int upkeep() const; bool loyal() const; - void set_hidden(bool state); + void set_hidden(bool state) const; bool get_hidden() const { return hidden_; } bool is_flying() const { return movement_type_.is_flying(); } bool is_fearless() const { return is_fearless_; } @@ -494,8 +494,8 @@ class unit std::string role_; std::vector attacks_; - map_location::DIRECTION facing_; - + mutable map_location::DIRECTION facing_; //TODO: I think we actually consider this to be part of the gamestate, so it might be better if it's not mutable + //But it's not easy to separate this guy from the animation code right now. std::vector trait_names_; std::vector trait_descriptions_; @@ -516,7 +516,7 @@ class unit mutable int unit_halo_; // flag used for drawing / animation bool getsHit_; mutable bool refreshing_; // avoid infinite recursion. flag used for drawing / animation - bool hidden_; + mutable bool hidden_; mutable bool draw_bars_; // flag used for drawing / animation double hp_bar_scaling_, xp_bar_scaling_;