fake unit manager returns a range rather than & to container
This commit is contained in:
parent
fd9379e276
commit
44a0752cb4
3 changed files with 11 additions and 6 deletions
|
@ -3056,7 +3056,7 @@ void display::invalidate_animations()
|
|||
}
|
||||
}
|
||||
}
|
||||
const std::deque<unit*> & unit_list = fake_unit_man_->get_fake_unit_list_for_invalidation();
|
||||
fake_unit_manager::range unit_list = fake_unit_man_->get_unit_range();
|
||||
|
||||
BOOST_FOREACH(const unit & u, dc_->units()) {
|
||||
u.anim_comp().refresh();
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include <deque>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
class display;
|
||||
class unit;
|
||||
class fake_unit;
|
||||
|
@ -28,7 +30,10 @@ public:
|
|||
//Anticipate making place_temporary_unit and remove_temporary_unit private to force exception safety
|
||||
friend class fake_unit;
|
||||
|
||||
const std::deque<unit*> & get_fake_unit_list_for_invalidation() {return fake_units_; }
|
||||
typedef unit* internal_ptr_type;
|
||||
typedef boost::iterator_range<std::deque<unit*>::const_iterator> range;
|
||||
|
||||
range get_unit_range() const { return boost::make_iterator_range(fake_units_.begin(), fake_units_.end()); }
|
||||
|
||||
private:
|
||||
/** Temporarily place a unit on map (moving: can overlap others).
|
||||
|
@ -36,15 +41,15 @@ private:
|
|||
* and therefore gets drawn last, over other units and temp units.
|
||||
* Adding the same unit twice isn't allowed.
|
||||
*/
|
||||
void place_temporary_unit(unit *u);
|
||||
void place_temporary_unit(internal_ptr_type);
|
||||
|
||||
/** Removes any instances of this temporary unit from the temporary unit vector.
|
||||
* Returns the number of temp units deleted (0 or 1, any other number indicates an error).
|
||||
*/
|
||||
int remove_temporary_unit(unit *u);
|
||||
int remove_temporary_unit(internal_ptr_type);
|
||||
|
||||
/// collection of units destined to be drawn but not put into the unit map
|
||||
std::deque<unit*> fake_units_;
|
||||
std::deque<internal_ptr_type> fake_units_;
|
||||
display & my_display_;
|
||||
};
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ void game_display::draw_invalidated()
|
|||
halo::unrender(invalidated_);
|
||||
display::draw_invalidated();
|
||||
|
||||
BOOST_FOREACH(const unit* temp_unit, fake_unit_man_->get_fake_unit_list_for_invalidation()) {
|
||||
BOOST_FOREACH(const unit* temp_unit, fake_unit_man_->get_unit_range()) {
|
||||
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()
|
||||
|
|
Loading…
Add table
Reference in a new issue