Skip to content

Commit

Permalink
separate fake units list from real units list
Browse files Browse the repository at this point in the history
This is a first step before brnaching off to fake units manager
  • Loading branch information
cbeck88 committed Jun 16, 2014
1 parent 1d4c0f2 commit 13155c4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
21 changes: 12 additions & 9 deletions src/display.cpp
Expand Up @@ -3033,12 +3033,9 @@ void display::invalidate_animations_location(const map_location& loc) {
}


std::vector<const unit*> display::get_unit_list_for_invalidation() {
std::vector<const unit*> unit_list;
BOOST_FOREACH(const unit &u, dc_->units()) {
unit_list.push_back(&u);
}
return unit_list;
const std::deque<unit*> & display::get_fake_unit_list_for_invalidation() {
static const std::deque<unit*> blah;
return blah;
}
void display::invalidate_animations()
{
Expand All @@ -3055,18 +3052,24 @@ void display::invalidate_animations()
}
}
}
std::vector<const unit*> unit_list=get_unit_list_for_invalidation();
const std::deque<unit*> & unit_list=get_fake_unit_list_for_invalidation();
BOOST_FOREACH(const unit* u, unit_list) {
u->refresh();
}
BOOST_FOREACH(const unit & u, dc_->units()) {
u.refresh();
}
bool new_inval;
do {
new_inval = false;
#ifdef _OPENMP
#pragma omp parallel for reduction(|:new_inval) shared(unit_list) schedule(guided)
#endif //_OPENMP
for(int i=0; i < static_cast<int>(unit_list.size()); i++) {
new_inval |= unit_list[i]->invalidate(*this);
BOOST_FOREACH(const unit* u, unit_list) {
new_inval |= u->invalidate(*this);
}
BOOST_FOREACH(const unit & u, dc_->units()) {
new_inval |= u.invalidate(*this);
}
}while(new_inval);
}
Expand Down
6 changes: 3 additions & 3 deletions src/display.hpp
Expand Up @@ -58,11 +58,11 @@ namespace wb {

#include "overlay.hpp"

#include <list>

#include <boost/function.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <deque>
#include <list>
#include <map>

class gamemap;
Expand Down Expand Up @@ -423,7 +423,7 @@ class display
* helper function for invalidate_animations
* returns a list of units to check for invalidation
*/
virtual std::vector<const unit*> get_unit_list_for_invalidation();
virtual const std::deque<unit*> & get_fake_unit_list_for_invalidation();

/**
* Per-location invalidation called by invalidate_animations()
Expand Down
8 changes: 2 additions & 6 deletions src/game_display.cpp
Expand Up @@ -624,12 +624,8 @@ void game_display::float_label(const map_location& loc, const std::string& text,
font::add_floating_label(flabel);
}

std::vector<const unit*> game_display::get_unit_list_for_invalidation() {
std::vector<const unit*> unit_list = display::get_unit_list_for_invalidation();;
BOOST_FOREACH(const unit *u, fake_units_) {
unit_list.push_back(u);
}
return unit_list;;
const std::deque<unit*> & game_display::get_fake_unit_list_for_invalidation() {
return fake_units_;
}


Expand Down
2 changes: 1 addition & 1 deletion src/game_display.hpp
Expand Up @@ -157,7 +157,7 @@ class game_display : public display
/**
* the list of units we need to look at, game_display adds fake units
*/
virtual std::vector<const unit*> get_unit_list_for_invalidation();
virtual const std::deque<unit*> & get_fake_unit_list_for_invalidation();


public:
Expand Down

0 comments on commit 13155c4

Please sign in to comment.