pass display as an argument to unit::invalidate

Previously it always used the singleton display function, but this
seems better.
This commit is contained in:
Chris Beck 2014-06-09 23:06:49 -04:00
parent 03021c0482
commit 654fd22ba8
6 changed files with 10 additions and 11 deletions

View file

@ -494,7 +494,7 @@ namespace { // Private helpers for move_unit()
moves_left_.pop_front();
// Invalidate before moving so we invalidate neighbor hexes if needed.
move_it_->invalidate(*move_loc_);
move_it_->invalidate(disp, *move_loc_);
// Attempt actually moving.
// (Fails if *step_to is occupied).

View file

@ -3067,7 +3067,7 @@ void display::invalidate_animations()
#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());
new_inval |= unit_list[i]->invalidate(*this,unit_list[i]->get_location());
}
}while(new_inval);
}

View file

@ -945,7 +945,7 @@ WML_HANDLER_FUNCTION(kill, event_info, cfg)
resources::screen->invalidate(loc);
unit_map::iterator iun = resources::units->find(loc);
if ( iun != resources::units->end() && iun.valid() )
iun->invalidate(loc);
iun->invalidate(*resources::screen, loc);
}
resources::screen->redraw_minimap();

View file

@ -2159,19 +2159,18 @@ void unit::clear_haloes()
}
if(anim_ ) anim_->clear_haloes();
}
bool unit::invalidate(const map_location &loc)
bool unit::invalidate(const display & disp, const map_location &loc)
{
bool result = false;
// Very early calls, anim not initialized yet
if(get_animation()) {
frame_parameters params;
const display * disp = display::get_singleton();
const gamemap & map = disp->get_map();
const gamemap & map = disp.get_map();
const t_translation::t_terrain terrain = map.get_terrain(loc);
const terrain_type& terrain_info = map.get_terrain_info(terrain);
int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp->get_zoom_factor());
int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp.get_zoom_factor());
if (is_flying() && height_adjust < 0) {
height_adjust = 0;
}

View file

@ -265,7 +265,7 @@ public:
void set_facing(map_location::DIRECTION dir);
map_location::DIRECTION facing() const { return facing_; }
bool invalidate(const map_location &loc);
bool invalidate(const display & disp, const map_location &loc);
const std::vector<t_string>& trait_names() const { return trait_names_; }
const std::vector<t_string>& trait_descriptions() const { return trait_descriptions_; }
std::vector<std::string> get_traits_list() const;

View file

@ -716,7 +716,7 @@ void manager::create_temp_move()
}
unit_display::move_unit(path, *fake_unit, false); //get facing right
fake_unit->invalidate(fake_unit->get_location());
fake_unit->invalidate(*game_display::get_singleton(), fake_unit->get_location());
fake_unit->set_location(*curr_itor);
fake_unit->set_ghosted(true);
}
@ -728,7 +728,7 @@ void manager::create_temp_move()
}
//in case path shortens on next step and one ghosted unit has to be removed
int ind = fake_units_.size() - 1;
fake_units_[ind]->invalidate(fake_units_[ind]->get_location());
fake_units_[ind]->invalidate(*game_display::get_singleton(),fake_units_[ind]->get_location());
//toss out old arrows and fake units
move_arrows_.resize(turn+1);
fake_units_.resize(turn+1);
@ -739,7 +739,7 @@ void manager::erase_temp_move()
move_arrows_.clear();
BOOST_FOREACH(fake_unit_ptr const& tmp, fake_units_) {
if(tmp) {
tmp->invalidate(tmp->get_location());
tmp->invalidate(*game_display::get_singleton(),tmp->get_location());
}
}
fake_units_.clear();