Skip to content

Commit

Permalink
facing and hidden become mutable attributes of unit
Browse files Browse the repository at this point in the history
This is needed to be able to do animation with const units.
  • Loading branch information
cbeck88 committed Jun 10, 2014
1 parent fe92895 commit ca01a4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/unit.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/unit.hpp
Expand Up @@ -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;
Expand All @@ -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_; }
Expand Down Expand Up @@ -494,8 +494,8 @@ class unit

std::string role_;
std::vector<attack_type> 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<t_string> trait_names_;
std::vector<t_string> trait_descriptions_;

Expand All @@ -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_;

Expand Down

0 comments on commit ca01a4b

Please sign in to comment.