diff --git a/src/unit.cpp b/src/unit.cpp index 1db5236575c..8527a404c67 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -1803,7 +1803,7 @@ const surface unit::still_image(bool scaled) const return unit_image; } -void unit::set_standing(bool with_bars) +void unit::set_standing(bool with_bars) const { display *disp = display::get_singleton(); if (preferences::show_standing_animations()&& !incapacitated()) { @@ -1815,28 +1815,28 @@ void unit::set_standing(bool with_bars) } } -void unit::set_ghosted(bool with_bars) +void unit::set_ghosted(bool with_bars) const { display *disp = display::get_singleton(); start_animation(INT_MAX, choose_animation(*disp, loc_, "ghosted"), with_bars); } -void unit::set_disabled_ghosted(bool with_bars) +void unit::set_disabled_ghosted(bool with_bars) const { display *disp = display::get_singleton(); start_animation(INT_MAX, choose_animation(*disp, loc_, "disabled_ghosted"), with_bars); } -void unit::set_idling() +void unit::set_idling() const { display *disp = display::get_singleton(); start_animation(INT_MAX, choose_animation(*disp, loc_, "idling"), true, "", 0, STATE_FORGET); } -void unit::set_selecting() +void unit::set_selecting() const { const display *disp = display::get_singleton(); if (preferences::show_standing_animations() && !get_state(STATE_PETRIFIED)) { @@ -1848,8 +1848,8 @@ void unit::set_selecting() } } -void unit::start_animation(int start_time, const unit_animation *animation, - bool with_bars, const std::string &text, Uint32 text_color, STATE state) +void unit::start_animation (int start_time, const unit_animation *animation, + bool with_bars, const std::string &text, Uint32 text_color, STATE state) const { const display * disp = display::get_singleton(); if (!animation) { @@ -1884,7 +1884,7 @@ void unit::set_facing(map_location::DIRECTION dir) { // Else look at yourself (not available so continue to face the same direction) } -void unit::redraw_unit() +void unit::redraw_unit () const { display &disp = *display::get_singleton(); const gamemap &map = disp.get_map(); @@ -2151,7 +2151,7 @@ void unit::redraw_unit() refreshing_ = false; } -void unit::clear_haloes() +void unit::clear_haloes () const { if(unit_halo_ != halo::NO_HALO) { halo::remove(unit_halo_); @@ -2159,7 +2159,7 @@ void unit::clear_haloes() } if(anim_ ) anim_->clear_haloes(); } -bool unit::invalidate(const display & disp) +bool unit::invalidate (const display & disp) const { bool result = false; @@ -3026,7 +3026,7 @@ int side_upkeep(int side) return res; } -void unit::refresh() +void unit::refresh() const { if (state_ == STATE_FORGET && anim_ && anim_->animation_finished_potential()) { diff --git a/src/unit.hpp b/src/unit.hpp index 0cba520ba23..02d323c06b4 100644 --- a/src/unit.hpp +++ b/src/unit.hpp @@ -204,7 +204,7 @@ public: void end_turn(); void new_scenario(); /** Called on every draw */ - void refresh(); + void refresh() const; bool take_hit(int damage) { hit_points_ -= damage; return hit_points_ <= 0; } void heal(int amount); @@ -249,23 +249,22 @@ public: const surface still_image(bool scaled = false) const; /** draw a unit. */ - void redraw_unit(); + void redraw_unit() const; /** Clear unit_halo_ */ - void clear_haloes(); + void clear_haloes() const; - void set_standing(bool with_bars = true); + void set_standing(bool with_bars = true) const; - void set_ghosted(bool with_bars = true); - void set_disabled_ghosted(bool with_bars = true); + void set_ghosted(bool with_bars = true) const; + void set_disabled_ghosted(bool with_bars = true) const; - void set_idling(); - void set_selecting(); - unit_animation* get_animation() { return anim_.get();} - const unit_animation* get_animation() const { return anim_.get();} + void set_idling() const; + void set_selecting() const; + unit_animation* get_animation() const { return anim_.get();} void set_facing(map_location::DIRECTION dir); map_location::DIRECTION facing() const { return facing_; } - bool invalidate(const display & disp); + bool invalidate(const display & disp) const; const std::vector& trait_names() const { return trait_names_; } const std::vector& trait_descriptions() const { return trait_descriptions_; } std::vector get_traits_list() const; @@ -327,9 +326,9 @@ public: STATE_STANDING, /** anim must fit in a hex */ STATE_FORGET, /** animation will be automatically replaced by a standing anim when finished */ STATE_ANIM}; /** normal anims */ - void start_animation(int start_time, const unit_animation *animation, + void start_animation (int start_time, const unit_animation *animation, bool with_bars, const std::string &text = "", - Uint32 text_color = 0, STATE state = STATE_ANIM); + Uint32 text_color = 0, STATE state = STATE_ANIM) const; /** The name of the file to game_display (used in menus). */ std::string absolute_image() const; @@ -488,7 +487,8 @@ private: config events_; config filter_recall_; bool emit_zoc_; - STATE state_; + + mutable STATE state_; //animation state std::vector overlays_; @@ -508,16 +508,16 @@ private: // Animations: std::vector animations_; - boost::scoped_ptr anim_; - int next_idling_; - int frame_begin_time_; + mutable boost::scoped_ptr anim_; + mutable int next_idling_; // used for animation + mutable int frame_begin_time_; // used for animation - int unit_halo_; + mutable int unit_halo_; // flag used for drawing / animation bool getsHit_; - bool refreshing_; // avoid infinite recursion + mutable bool refreshing_; // avoid infinite recursion. flag used for drawing / animation bool hidden_; - bool draw_bars_; + mutable bool draw_bars_; // flag used for drawing / animation double hp_bar_scaling_, xp_bar_scaling_; config modifications_;