Fix a big slowdown spotted on NR-2...

...but probably existing on all map with many villages and many
teams. The flag animation caused villages to be updated (number of
teams) times too often.
This commit is contained in:
Ali El Gariani 2007-04-09 10:06:15 +00:00
parent 83b8c614e9
commit 23ae7b60ea

View file

@ -2149,22 +2149,19 @@ void display::invalidate_all()
void display::invalidate_animations()
{
new_animation_frame();
bool animate_flags = false;
gamemap::location topleft;
gamemap::location bottomright;
get_visible_hex_bounds(topleft, bottomright);
for(size_t i = 0; i < flags_.size(); ++i) {
if(flags_[i].need_update()) {
animate_flags = true;
}
}
for(int x = topleft.x; x <= bottomright.x; ++x) {
for(int y = topleft.y; y <= bottomright.y; ++y) {
gamemap::location loc(x,y);
if(builder_.update_animation(loc) || (map_.is_village(loc) && animate_flags && player_teams::village_owner(loc) != -1)) {
if (builder_.update_animation(loc))
invalidate(loc);
if (map_.is_village(loc)) {
const int owner = player_teams::village_owner(loc);
if (owner >= 0 && flags_[owner].need_update())
invalidate(loc);
}
}
}