Skip to content

Commit

Permalink
make fake_unit_manager foreachable, drop the "range" getter
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 23, 2014
1 parent c1f3af2 commit 4bb55f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/display.cpp
Expand Up @@ -3081,12 +3081,11 @@ void display::invalidate_animations()
}
}
}
fake_unit_manager::range unit_list = fake_unit_man_->get_unit_range();

BOOST_FOREACH(const unit & u, dc_->units()) {
u.anim_comp().refresh();
}
BOOST_FOREACH(const unit* u, unit_list) {
BOOST_FOREACH(const unit* u, *fake_unit_man_) {
u->anim_comp().refresh();
}

Expand All @@ -3096,7 +3095,7 @@ void display::invalidate_animations()
BOOST_FOREACH(const unit & u, dc_->units()) {
new_inval |= u.anim_comp().invalidate(*this);
}
BOOST_FOREACH(const unit* u, unit_list) {
BOOST_FOREACH(const unit* u, *fake_unit_man_) {
new_inval |= u->anim_comp().invalidate(*this);
}
}while(new_inval);
Expand Down
11 changes: 7 additions & 4 deletions src/fake_unit_manager.hpp
Expand Up @@ -17,8 +17,6 @@

#include <deque>

#include <boost/range/iterator_range.hpp>

class display;
class unit;
class fake_unit_ptr;
Expand All @@ -31,9 +29,14 @@ class fake_unit_manager {
friend class fake_unit_ptr;

typedef unit const * internal_ptr_type;
typedef boost::iterator_range<std::deque<internal_ptr_type>::const_iterator> range;
typedef std::deque<internal_ptr_type>::const_iterator iterator;
typedef std::deque<internal_ptr_type>::const_iterator const_iterator;

iterator begin() { return fake_units_.begin(); }
iterator end() { return fake_units_.end(); }

range get_unit_range() const { return boost::make_iterator_range(fake_units_.begin(), fake_units_.end()); }
const_iterator begin() const { return fake_units_.begin(); }
const_iterator end() const { return fake_units_.end(); }

private:
/** Temporarily place a unit on map (moving: can overlap others).
Expand Down
2 changes: 1 addition & 1 deletion src/game_display.cpp
Expand Up @@ -257,7 +257,7 @@ void game_display::draw_invalidated()

unit_drawer drawer = unit_drawer(*this);

BOOST_FOREACH(const unit* temp_unit, fake_unit_man_->get_unit_range()) {
BOOST_FOREACH(const unit* temp_unit, *fake_unit_man_) {
const map_location& loc = temp_unit->get_location();
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
if (invalidated_.find(loc) != invalidated_.end()
Expand Down

0 comments on commit 4bb55f4

Please sign in to comment.