Skip to content

Commit

Permalink
display object uses a const unit_map * internally
Browse files Browse the repository at this point in the history
This was made possible because const units may now be drawn and
animated. There are some clients of the display object that still
call display::get_units, which is a non const getter, and which
we support by a const cast. The next step of refactor is to get
rid of that, but in this step we have at least gotten rid of all
internal uses of the non-const unit map.
  • Loading branch information
cbeck88 committed Jun 10, 2014
1 parent 16db25b commit 7690787
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/display.hpp
Expand Up @@ -96,7 +96,7 @@ class display
* Cancels all the exclusive draw requests.
*/
void clear_exclusive_draws() { exclusive_unit_draw_requests_.clear(); }
unit_map& get_units() {return *units_;}
unit_map& get_units() {return *const_cast<unit_map *> (units_);} //TODO: remove this when callers have been refactored not to require the non-const
const unit_map& get_const_units() const {return *units_;}

/**
Expand Down Expand Up @@ -628,7 +628,7 @@ class display

protected:
//TODO sort
unit_map* units_;
const unit_map* units_;

typedef std::map<map_location, std::string> exclusive_unit_draw_requests_t;
/// map of hexes where only one unit should be drawn, the one identified by the associated id string
Expand Down

0 comments on commit 7690787

Please sign in to comment.