fix bug #20098 you can't invalidate separately fake and real units,
...they need to be invalidated at the same time
This commit is contained in:
parent
635199be7e
commit
c0287b85ba
4 changed files with 24 additions and 28 deletions
|
@ -2766,6 +2766,14 @@ void display::invalidate_animations_location(const map_location& loc) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<unit*> display::get_unit_list_for_invalidation() {
|
||||
std::vector<unit*> unit_list;
|
||||
BOOST_FOREACH(unit &u, *units_) {
|
||||
unit_list.push_back(&u);
|
||||
}
|
||||
return unit_list;;
|
||||
}
|
||||
void display::invalidate_animations()
|
||||
{
|
||||
new_animation_frame();
|
||||
|
@ -2781,12 +2789,9 @@ void display::invalidate_animations()
|
|||
}
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH(unit& u, *units_) {
|
||||
u.refresh();
|
||||
}
|
||||
std::vector<unit*> unit_list;
|
||||
BOOST_FOREACH(unit &u, *units_) {
|
||||
unit_list.push_back(&u);
|
||||
std::vector<unit*> unit_list=get_unit_list_for_invalidation();
|
||||
BOOST_FOREACH(unit* u, unit_list) {
|
||||
u->refresh();
|
||||
}
|
||||
bool new_inval;
|
||||
do {
|
||||
|
|
|
@ -377,9 +377,14 @@ public:
|
|||
bool invalidate_visible_locations_in_rect(const SDL_Rect& rect);
|
||||
|
||||
/**
|
||||
* Function to invalidate animated terrains which may have changed.
|
||||
* Function to invalidate animated terrains and unitswhich may have changed.
|
||||
*/
|
||||
virtual void invalidate_animations();
|
||||
void invalidate_animations();
|
||||
/**
|
||||
* helper function for invalidate_animations
|
||||
* returns a list of units to check for invalidation
|
||||
*/
|
||||
virtual std::vector<unit*> get_unit_list_for_invalidation();
|
||||
|
||||
/**
|
||||
* Per-location invalidation called by invalidate_animations()
|
||||
|
|
|
@ -656,29 +656,15 @@ void game_display::float_label(const map_location& loc, const std::string& text,
|
|||
font::add_floating_label(flabel);
|
||||
}
|
||||
|
||||
|
||||
void game_display::invalidate_animations()
|
||||
{
|
||||
display::invalidate_animations();
|
||||
BOOST_FOREACH(unit* temp_unit, fake_units_) {
|
||||
temp_unit->refresh();
|
||||
}
|
||||
std::vector<unit*> unit_list;
|
||||
std::vector<unit*> game_display::get_unit_list_for_invalidation() {
|
||||
std::vector<unit*> unit_list = display::get_unit_list_for_invalidation();;
|
||||
BOOST_FOREACH(unit *u, fake_units_) {
|
||||
unit_list.push_back(u);
|
||||
}
|
||||
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(unit_list[i]->get_location());
|
||||
}
|
||||
}while(new_inval);
|
||||
return unit_list;;
|
||||
}
|
||||
|
||||
|
||||
int& game_display::debug_highlight(const map_location& loc)
|
||||
{
|
||||
assert(game_config::debug);
|
||||
|
|
|
@ -155,9 +155,9 @@ protected:
|
|||
void draw_hex(const map_location& loc);
|
||||
|
||||
/**
|
||||
* Animated hex invalidation specific to gameplay
|
||||
* the list of units we need to look at, game_display adds fake units
|
||||
*/
|
||||
void invalidate_animations();
|
||||
virtual std::vector<unit*> get_unit_list_for_invalidation();
|
||||
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue