Display: removed all the invalidated locations code

This removes all the code related to invalidating locations, any functions used to set, modify, or propagate
location invalidation, and several functions that no longer serve any purpose anymore since their only purpose
was to handle invalidated locations.
This commit is contained in:
Charles Dang 2017-07-05 21:42:01 +11:00
parent ffc064eca2
commit c5be598cd0
42 changed files with 9 additions and 593 deletions

View file

@ -142,12 +142,9 @@ namespace
animator.start_animations();
animator.wait_for_end();
animator.set_all_standing();
display::get_singleton()->invalidate(loc);
events::pump();
}
display::get_singleton()->invalidate_all();
return true;
}

View file

@ -1249,7 +1249,6 @@ void attack::unit_killed(unit_info& attacker,
attacker.xp_ = game_config::kill_xp(defender.get_unit().level());
defender.xp_ = 0;
display::get_singleton()->invalidate(attacker.loc_);
game_events::entity_location death_loc(defender.loc_, defender.id_);
game_events::entity_location attacker_loc(attacker.loc_, attacker.id_);
@ -1341,10 +1340,6 @@ void attack::unit_killed(unit_info& attacker,
resources::game_events->pump().fire("unit_placed", reanim_loc);
preferences::encountered_units().insert(newunit->type_id());
if(update_display_) {
display::get_singleton()->invalidate(death_loc);
}
}
} else {
LOG_NG << "unit not reanimated\n";
@ -1493,11 +1488,6 @@ void attack::perform()
unit_display::unit_sheath_weapon(a_.loc_, a_.valid() ? &a_.get_unit() : nullptr, a_stats_->weapon, d_stats_->weapon,
d_.loc_, d_.valid() ? &d_.get_unit() : nullptr);
if(update_display_) {
game_display::get_singleton()->invalidate_unit();
display::get_singleton()->invalidate(a_.loc_);
display::get_singleton()->invalidate(d_.loc_);
}
if(OOS_error_) {
replay::process_error(errbuf_.str());

View file

@ -668,7 +668,6 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat
// Make sure the unit appears (if either !show or the animation is suppressed).
new_unit_itor->set_hidden(false);
if (display::get_singleton() != nullptr ) {
display::get_singleton()->invalidate(current_loc);
display::get_singleton()->redraw_minimap();
}

View file

@ -174,9 +174,6 @@ game_events::pump_result_t get_village(const map_location& loc, int side, bool *
}
if(not_defeated) {
if (display::get_singleton() != nullptr) {
display::get_singleton()->invalidate(loc);
}
return t->get_village(loc, old_owner_side, fire_event ? resources::gamedata : nullptr);
}
@ -537,7 +534,6 @@ namespace { // Private helpers for move_unit()
// but it works.
move_it_->anim_comp().set_standing(false);
disp.invalidate_unit_after_move(*move_loc_, *step_to);
disp.invalidate(*step_to);
move_loc_ = step_to;
// Show this move.
@ -903,8 +899,6 @@ namespace { // Private helpers for move_unit()
}
}
// Make sure this hex is drawn correctly.
disp.invalidate(hex);
// Fire sighted events.
bool wml_undo_blocked = false;

View file

@ -67,7 +67,6 @@ void recall_action::write(config & cfg) const
*/
bool recall_action::undo(int side)
{
game_display & gui = *game_display::get_singleton();
unit_map & units = resources::gameboard->units();
team &current_team = resources::gameboard->get_team(side);
@ -92,9 +91,7 @@ bool recall_action::undo(int side)
}
current_team.recall_list().add(un);
// invalidate before erasing allow us
// to also do the overlapped hexes
gui.invalidate(recall_loc);
units.erase(recall_loc);
this->return_village();
execute_undo_umc_wml();

View file

@ -68,7 +68,6 @@ void recruit_action::write(config & cfg) const
*/
bool recruit_action::undo(int side)
{
game_display & gui = *game_display::get_singleton();
unit_map & units = resources::gameboard->units();
team &current_team = resources::gameboard->get_team(side);
@ -85,9 +84,6 @@ bool recruit_action::undo(int side)
//MP_COUNTDOWN take away recruit bonus
current_team.set_action_bonus_count(current_team.action_bonus_count() - 1);
// invalidate before erasing allow us
// to also do the overlapped hexes
gui.invalidate(recruit_loc);
units.erase(recruit_loc);
this->return_village();
execute_undo_umc_wml();

View file

@ -236,14 +236,7 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
resources::game_events->pump().fire("unit_placed", loc);
}
if (display::get_singleton()!=nullptr) {
if (invalidate_ ) {
display::get_singleton()->invalidate(loc);
}
if (animate) {
unit_display::unit_recruited(loc);
}
if (animate) {
unit_display::unit_recruited(loc);
}
}

View file

@ -270,17 +270,6 @@ bool shroud_clearer::clear_loc(team &tm, const map_location &loc,
}
}
// Possible screen invalidation.
if ( was_fogged ) {
display::get_singleton()->invalidate(loc);
// Need to also invalidate adjacent hexes to get rid of the
// "fog edge" graphics.
adjacent_loc_array_t adjacent;
get_adjacent_tiles(loc, adjacent.data());
for (unsigned i = 0; i < adjacent.size(); ++i )
display::get_singleton()->invalidate(adjacent[i]);
}
// Check for units?
if ( result && check_units && loc != event_non_loc ) {
// Uncovered a unit?
@ -719,9 +708,6 @@ void recalculate_fog(int side)
}
tm.refog();
// Invalidate the screen before clearing the shroud.
// This speeds up the invalidations within clear_shroud_unit().
display::get_singleton()->invalidate_all();
shroud_clearer clearer;
for (const unit &u : resources::gameboard->units())

View file

@ -53,7 +53,6 @@ void arrow::hide()
hidden_ = true;
if(display* disp = display::get_singleton()) {
invalidate_arrow_path(path_);
disp->remove_arrow(*this);
}
}
@ -78,7 +77,6 @@ void arrow::set_path(const arrow_path_t& path)
update_symbols();
if(!hidden_)
{
invalidate_arrow_path(previous_path_);
notify_arrow_changed();
}
}
@ -86,8 +84,6 @@ void arrow::set_path(const arrow_path_t& path)
void arrow::reset()
{
invalidate_arrow_path(previous_path_);
invalidate_arrow_path(path_);
previous_path_.clear();
path_.clear();
symbols_map_.clear();
@ -163,7 +159,6 @@ void arrow::update_symbols()
}
symbols_map_.clear();
invalidate_arrow_path(path_);
const std::string mods = "~RC(FF00FF>"+ color_ + ")"; //magenta to current color
@ -284,15 +279,6 @@ void arrow::update_symbols()
}
}
void arrow::invalidate_arrow_path(const arrow_path_t& path)
{
if(display* disp = display::get_singleton()) {
for(const map_location& loc : path) {
disp->invalidate(loc);
}
}
}
void arrow::notify_arrow_changed()
{
if(display* disp = display::get_singleton()) {

View file

@ -77,8 +77,6 @@ public:
/// Checks that the path is not of length 0 or 1
static bool valid_path(const arrow_path_t& path);
/// Invalidates every hex along the given path
static void invalidate_arrow_path(const arrow_path_t& path);
virtual void notify_arrow_changed();

View file

@ -86,24 +86,6 @@ namespace {
unsigned int display::zoom_ = DefaultZoom;
unsigned int display::last_zoom_ = SmallZoom;
void display::parse_team_overlays()
{
const team& curr_team = dc_->teams()[playing_team()];
const team& prev_team = playing_team() == 0
? dc_->teams().back()
: dc_->get_team(playing_team());
for (const game_display::overlay_map::value_type i : *overlays_) {
const overlay& ov = i.second;
if (!ov.team_name.empty() &&
((ov.team_name.find(curr_team.team_name()) + 1) != 0) !=
((ov.team_name.find(prev_team.team_name()) + 1) != 0))
{
invalidate(i.first);
}
}
}
void display::add_overlay(const map_location& loc, const std::string& img, const std::string& halo, const std::string& team_name, const std::string& item_id, bool visible_under_fog)
{
if (halo_man_) {
@ -173,7 +155,6 @@ display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, repo
, minimap_location_(sdl::empty_rect)
, redrawMinimap_(false)
, redraw_background_(true)
, invalidateAll_(true)
, grid_(false)
, diagnostic_label_(0)
, panelsDrawn_(false)
@ -193,7 +174,6 @@ display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, repo
, reports_()
, menu_buttons_()
, action_buttons_()
, invalidated_()
, mouseover_hex_overlay_(nullptr)
, tod_hex_mask1(nullptr)
, tod_hex_mask2(nullptr)
@ -213,7 +193,6 @@ display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, repo
, reach_map_changed_(true)
, overlays_(nullptr)
, fps_handle_(0)
, invalidated_hexes_(0)
, drawn_hexes_(0)
, idle_anim_(preferences::idle_anim())
, idle_anim_rate_(1.0)
@ -261,10 +240,6 @@ display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, repo
rebuild_all();
assert(builder_);
//builder_->rebuild_cache_all();
invalidate_all();
//invalidate_locations_in_rect(map_area());
}
display::~display()
@ -805,7 +780,6 @@ surface display::screenshot(bool map_screenshot)
// we reroute render output to the screenshot surface and invalidate all
map_screenshot_= true;
invalidateAll_ = true;
DBG_DP << "draw() with map_screenshot\n";
draw(true,true);
@ -1246,14 +1220,9 @@ void display::draw_debugging_aids()
stream << "<tt>Time: " << std::setfill(' ') << std::setw(3) << *minmax_it.first << '/' << std::setw(3) << render_avg << '/' << std::setw(3) << *minmax_it.second << " ms</tt>\n";
if(game_config::debug) {
stream << "\nhex: " << drawn_hexes_ * 1.0 / sample_freq;
if(drawn_hexes_ != invalidated_hexes_) {
stream << " (" << (invalidated_hexes_ - drawn_hexes_) * 1.0 / sample_freq << ")";
}
}
drawn_hexes_ = 0;
invalidated_hexes_ = 0;
font::floating_label flabel(stream.str());
flabel.set_font_size(12);
@ -1267,7 +1236,6 @@ void display::draw_debugging_aids()
font::remove_floating_label(fps_handle_);
fps_handle_ = 0;
drawn_hexes_ = 0;
invalidated_hexes_ = 0;
}
}
@ -1395,17 +1363,13 @@ void display::draw_text_in_hex(const map_location& loc,
void display::select_hex(map_location hex)
{
invalidate(selectedHex_);
selectedHex_ = hex;
invalidate(selectedHex_);
recalculate_minimap();
}
void display::highlight_hex(map_location hex)
{
invalidate(mouseoverHex_);
mouseoverHex_ = hex;
invalidate(mouseoverHex_);
}
void display::set_diagnostic(const std::string& msg)
@ -1435,10 +1399,6 @@ void display::draw_init()
return;
}
if(benchmark) {
invalidateAll_ = true;
}
if(!panelsDrawn_) {
draw_all_panels();
panelsDrawn_ = true;
@ -1452,19 +1412,6 @@ void display::draw_init()
SDL_FillRect(screen, &clip_rect, 0x00000000);
draw_background(clip_rect, theme_.border().background_image);
redraw_background_ = false;
// Force a full map redraw
invalidateAll_ = true;
}
if(invalidateAll_) {
DBG_DP << "draw() with invalidateAll\n";
// toggle invalidateAll_ first to allow regular invalidations
invalidateAll_ = false;
invalidate_locations_in_rect(map_area());
redrawMinimap_ = true;
}
}
@ -1838,7 +1785,6 @@ bool display::set_zoom(unsigned int amount, const bool validate_value_and_set_in
labels().recalculate_labels();
redraw_background_ = true;
invalidate_all();
// Forces a redraw after zooming.
// This prevents some graphic glitches from occurring.
@ -2444,100 +2390,6 @@ void display::refresh_report(const std::string& report_name, const config * new_
}
}
void display::invalidate_all()
{
DBG_DP << "invalidate_all()\n";
invalidateAll_ = true;
#ifdef _OPENMP
#pragma omp critical(invalidated_)
#endif //_OPENMP
invalidated_.clear();
}
bool display::invalidate(const map_location& loc)
{
if(invalidateAll_)
return false;
bool tmp;
#ifdef _OPENMP
#pragma omp critical(invalidated_)
#endif //_OPENMP
tmp = invalidated_.insert(loc).second;
return tmp;
}
bool display::invalidate(const std::set<map_location>& locs)
{
if(invalidateAll_)
return false;
bool ret = false;
for (const map_location& loc : locs) {
#ifdef _OPENMP
#pragma omp critical(invalidated_)
#endif //_OPENMP
ret = invalidated_.insert(loc).second || ret;
}
return ret;
}
bool display::propagate_invalidation(const std::set<map_location>& locs)
{
if(invalidateAll_)
return false;
if(locs.size()<=1)
return false; // propagation never needed
bool result = false;
#ifdef _OPENMP
#pragma omp critical(invalidated_)
#endif //_OPENMP
{
// search the first hex invalidated (if any)
std::set<map_location>::const_iterator i = locs.begin();
for(; i != locs.end() && invalidated_.count(*i) == 0 ; ++i) {}
if (i != locs.end()) {
// propagate invalidation
// 'i' is already in, but I suspect that splitting the range is bad
// especially because locs are often adjacents
size_t previous_size = invalidated_.size();
invalidated_.insert(locs.begin(), locs.end());
result = previous_size < invalidated_.size();
}
}
return result;
}
bool display::invalidate_visible_locations_in_rect(const SDL_Rect& rect)
{
return invalidate_locations_in_rect(sdl::intersect_rects(map_area(),rect));
}
bool display::invalidate_locations_in_rect(const SDL_Rect& rect)
{
if(invalidateAll_)
return false;
bool result = false;
for (const map_location &loc : hexes_under_rect(rect)) {
result |= invalidate(loc);
}
return result;
}
void display::invalidate_animations_location(const map_location& loc) {
if (get_map().is_village(loc)) {
const int owner = dc_->village_owner(loc);
if (owner >= 0 && flags_[owner].need_update()
&& (!fogged(loc) || !dc_->teams()[currentTeam_].is_enemy(owner+1))) {
invalidate(loc);
}
}
}
void display::invalidate_animations()
{
new_animation_frame();
@ -2549,11 +2401,7 @@ void display::invalidate_animations()
continue;
}
if(builder_->update_animation(loc)) {
invalidate(loc);
} else {
invalidate_animations_location(loc);
}
builder_->update_animation(loc);
}
}
@ -2672,46 +2520,6 @@ void display::read(const config& cfg)
color_adjust_.b = cfg["color_adjust_blue"].to_int(0);
}
void display::process_reachmap_changes()
{
if (!reach_map_changed_) return;
if (reach_map_.empty() != reach_map_old_.empty()) {
// Invalidate everything except the non-darkened tiles
reach_map &full = reach_map_.empty() ? reach_map_old_ : reach_map_;
for (const auto& hex : get_visible_hexes()) {
reach_map::iterator reach = full.find(hex);
if (reach == full.end()) {
// Location needs to be darkened or brightened
invalidate(hex);
} else if (reach->second != 1) {
// Number needs to be displayed or cleared
invalidate(hex);
}
}
} else if (!reach_map_.empty()) {
// Invalidate only changes
reach_map::iterator reach, reach_old;
for (reach = reach_map_.begin(); reach != reach_map_.end(); ++reach) {
reach_old = reach_map_old_.find(reach->first);
if (reach_old == reach_map_old_.end()) {
invalidate(reach->first);
} else {
if (reach_old->second != reach->second) {
invalidate(reach->first);
}
reach_map_old_.erase(reach_old);
}
}
for (reach_old = reach_map_old_.begin(); reach_old != reach_map_old_.end(); ++reach_old) {
invalidate(reach_old->first);
}
}
reach_map_old_ = reach_map_;
reach_map_changed_ = false;
}
/* Debugging aid to slow things down a bit. Don't ever enable this in a release! */
#ifdef SLOW_THINGS_DOWN
#undef SLOW_THINGS_DOWN
@ -2765,8 +2573,7 @@ void display::draw(bool update, bool force)
// save it as the previous invalidated, and merge with the previous invalidated_
// we merge with the previous redraw because if a hex had a unit last redraw but
// not this one, nobody will tell us to redraw (cleanup)
previous_invalidated_.swap(invalidated_);
invalidated_.insert(previous_invalidated_.begin(),previous_invalidated_.end());
// these new invalidations cannot cause any propagation because
// if a hex was invalidated last turn but not this turn, then
// * case of no unit in neighbor hex=> no propagation
@ -2776,19 +2583,6 @@ void display::draw(bool update, bool force)
#ifdef SLOW_THINGS_DOWN
int simulate_delay = 0;
#endif
/*
* draw_invalidated() also invalidates the halos, so also needs to be
* ran if invalidated_.empty() == true.
*/
//drawing_queue_.set_clip_rect(map_area());
if(!invalidated_.empty() || preferences::show_haloes()) {
draw_invalidated();
invalidated_.clear();
}
//drawing_queue_.render_buffer();
post_commit();
draw_sidebar();
@ -2845,7 +2639,7 @@ void display::redraw_everything()
}
int ticks1 = SDL_GetTicks();
invalidate_all();
//invalidate_all();
int ticks2 = SDL_GetTicks();
draw(true,true);
int ticks3 = SDL_GetTicks();
@ -2855,44 +2649,6 @@ void display::redraw_everything()
}
void display::draw_invalidated() {
return;
// log_scope("display::draw_invalidated");
SDL_Rect clip_rect = get_clip_rect();
surface& screen = get_screen_surface();
clip_rect_setter set_clip_rect(screen, &clip_rect);
for (const map_location& loc : get_visible_hexes()) {
int xpos = get_location_x(loc);
int ypos = get_location_y(loc);
//const bool on_map = get_map().on_board(loc);
SDL_Rect hex_rect = sdl::create_rect(xpos, ypos, zoom_, zoom_);
if(!sdl::rects_overlap(hex_rect,clip_rect)) {
continue;
}
draw_hex(loc);
drawn_hexes_+=1;
}
invalidated_hexes_ += invalidated_.size();
if (dc_->teams().empty())
{
// The unit drawer can't function without teams
return;
}
unit_drawer drawer = unit_drawer(*this);
for (const map_location& loc : invalidated_) {
unit_map::const_iterator u_it = dc_->units().find(loc);
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
if (u_it != dc_->units().end()
&& (request == exclusive_unit_draw_requests_.end() || request->second == u_it->id()))
drawer.redraw_unit(*u_it);
}
}
//
// NEW RENDERING CODE =========================================================================
//

View file

@ -135,12 +135,6 @@ public:
*/
std::string remove_exclusive_draw(const map_location& loc);
/**
* Check the overlay_map for proper team-specific overlays to be
* displayed/hidden
*/
void parse_team_overlays();
/**
* Functions to add and remove overlays from locations.
*
@ -408,37 +402,11 @@ public:
void draw_minimap_units();
/** Function to invalidate all tiles. */
void invalidate_all();
/** Function to invalidate a specific tile for redrawing. */
bool invalidate(const map_location& loc);
bool invalidate(const std::set<map_location>& locs);
/**
* If this set is partially invalidated, invalidate all its hexes.
* Returns if any new invalidation was needed
*/
bool propagate_invalidation(const std::set<map_location>& locs);
/** invalidate all hexes under the rectangle rect (in screen coordinates) */
bool invalidate_locations_in_rect(const SDL_Rect& rect);
bool invalidate_visible_locations_in_rect(const SDL_Rect& rect);
/**
* Function to invalidate animated terrains and units which may have changed.
*/
void invalidate_animations();
/**
* Per-location invalidation called by invalidate_animations()
* Extra game per-location invalidation (village ownership)
*/
void invalidate_animations_location(const map_location& loc);
void reset_standing_animations();
/**
* mouseover_hex_overlay_ require a prerendered surface
* and is drawn underneath the mouse's location
@ -713,14 +681,6 @@ protected:
*/
virtual const SDL_Rect& get_clip_rect();
/**
* Only called when there's actual redrawing to do. Loops through
* invalidated locations and redraws them. Derived classes can override
* this, possibly to insert pre- or post-processing around a call to the
* base class's function.
*/
virtual void draw_invalidated();
/**
* Hook for actions to take right after draw() renders the drawing buffer.
* No action here by default.
@ -778,7 +738,6 @@ protected:
SDL_Rect minimap_location_;
bool redrawMinimap_;
bool redraw_background_;
bool invalidateAll_;
bool grid_;
int diagnostic_label_;
bool panelsDrawn_;
@ -808,7 +767,6 @@ protected:
std::map<std::string, surface> reportSurfaces_;
std::map<std::string, config> reports_;
std::vector<std::shared_ptr<gui::button>> menu_buttons_, action_buttons_;
std::set<map_location> invalidated_;
surface mouseover_hex_overlay_;
// If we're transitioning from one time of day to the next,
// then we will use these two masks on top of all hexes when we blit.
@ -915,7 +873,6 @@ protected:
reach_map reach_map_;
reach_map reach_map_old_;
bool reach_map_changed_;
void process_reachmap_changes();
typedef std::multimap<map_location, overlay> overlay_map;
@ -927,7 +884,6 @@ private:
/** Handle for the label which displays frames per second. */
int fps_handle_;
/** Count work done for the debug info displayed under fps */
int invalidated_hexes_;
int drawn_hexes_;
bool idle_anim_;

View file

@ -33,14 +33,6 @@ void mouse_action_item::move(editor_display& disp, const map_location& hex)
update_brush_highlights(disp, hex);
std::set<map_location> adjacent_set;
adjacent_loc_array_t adjacent;
get_adjacent_tiles(previous_move_hex_, adjacent.data());
for (unsigned i = 0; i < adjacent.size(); i++)
adjacent_set.insert(adjacent[i]);
disp.invalidate(adjacent_set);
previous_move_hex_ = hex;
// const item_map& items = disp.get_items();

View file

@ -37,14 +37,6 @@ void mouse_action_unit::move(editor_display& disp, const map_location& hex)
update_brush_highlights(disp, hex);
std::set<map_location> adjacent_set;
adjacent_loc_array_t adjacent;
get_adjacent_tiles(previous_move_hex_, adjacent.data());
for (unsigned i = 0; i < adjacent.size(); i++)
adjacent_set.insert(adjacent[i]);
disp.invalidate(adjacent_set);
previous_move_hex_ = hex;
const unit_map& units = disp.get_units();

View file

@ -969,17 +969,14 @@ bool editor_controller::do_execute_command(const hotkey::hotkey_command& cmd, in
case HOTKEY_EDITOR_DRAW_COORDINATES:
gui().set_draw_coordinates(!gui().get_draw_coordinates());
preferences::editor::set_draw_hex_coordinates(gui().get_draw_coordinates());
gui().invalidate_all();
return true;
case HOTKEY_EDITOR_DRAW_TERRAIN_CODES:
gui().set_draw_terrain_codes(!gui().get_draw_terrain_codes());
preferences::editor::set_draw_terrain_codes(gui().get_draw_terrain_codes());
gui().invalidate_all();
return true;
case HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS:
gui().set_draw_num_of_bitmaps(!gui().get_draw_num_of_bitmaps());
preferences::editor::set_draw_num_of_bitmaps(gui().get_draw_num_of_bitmaps());
gui().invalidate_all();
return true;
case HOTKEY_EDITOR_REMOVE_LOCATION: {
location_palette* lp = dynamic_cast<location_palette*>(&toolkit_->get_palette_manager()->active_palette());
@ -1111,7 +1108,6 @@ void editor_controller::preferences()
void editor_controller::toggle_grid()
{
preferences::set_grid(!preferences::grid());
gui_->invalidate_all();
}
void editor_controller::unit_description()

View file

@ -43,26 +43,21 @@ editor_display::editor_display(editor_controller& controller, reports& reports_o
void editor_display::add_brush_loc(const map_location& hex)
{
brush_locations_.insert(hex);
invalidate(hex);
}
void editor_display::set_brush_locs(const std::set<map_location>& hexes)
{
invalidate(brush_locations_);
brush_locations_ = hexes;
invalidate(brush_locations_);
}
void editor_display::clear_brush_locs()
{
invalidate(brush_locations_);
brush_locations_.clear();
}
void editor_display::remove_brush_loc(const map_location& hex)
{
brush_locations_.erase(hex);
invalidate(hex);
}
void editor_display::rebuild_terrain(const map_location &loc) {

View file

@ -118,7 +118,6 @@ void context_manager::refresh_all()
gui_.rebuild_all();
get_map_context().set_needs_terrain_rebuild(false);
gui_.create_buttons();
gui_.invalidate_all();
get_map_context().clear_changed_locations();
gui_.recalculate_minimap();
}
@ -527,18 +526,10 @@ void context_manager::refresh_after_action(bool drag_part)
{
gui_.rebuild_all();
get_map_context().set_needs_terrain_rebuild(false);
gui_.invalidate_all();
} else {
for(const map_location& loc : changed_locs) {
gui_.rebuild_terrain(loc);
}
gui_.invalidate(changed_locs);
}
} else {
if(get_map_context().everything_changed()) {
gui_.invalidate_all();
} else {
gui_.invalidate(changed_locs);
}
}

View file

@ -34,7 +34,6 @@ void fake_unit_manager::place_temporary_unit(internal_ptr_type u)
ERR_NG << "In fake_unit_manager::place_temporary_unit: attempt to add duplicate fake unit." << std::endl;
} else {
fake_units_.push_back(u);
my_display_.invalidate(u->get_location());
}
}
@ -50,7 +49,6 @@ int fake_unit_manager::remove_temporary_unit(internal_ptr_type u)
removed = std::distance(it, fake_units_.end());
//std::remove doesn't remove anything without using erase afterwards.
fake_units_.erase(it, fake_units_.end());
my_display_.invalidate(u->get_location());
// Redraw with no location to get rid of haloes
u->anim_comp().clear_haloes();
}

View file

@ -36,7 +36,7 @@ namespace gui{
label_(0)
{}
void floating_textbox::close(game_display& gui)
void floating_textbox::close(game_display& /*gui*/)
{
if(!active()) {
return;
@ -50,7 +50,6 @@ namespace gui{
check_.reset(nullptr);
font::remove_floating_label(label_);
mode_ = TEXTBOX_NONE;
gui.invalidate_all();
}
void floating_textbox::update_location(game_display& gui)

View file

@ -124,7 +124,6 @@ void game_display::new_turn()
tod_hex_mask2.assign(new_mask);
}
invalidate_all();
const int cur_ticks = SDL_GetTicks();
const int wanted_ticks = starting_ticks + i*frame_time;
@ -142,7 +141,6 @@ void game_display::new_turn()
display::update_tod();
invalidate_all();
}
void game_display::select_hex(map_location hex)
@ -216,8 +214,6 @@ void game_display::pre_draw()
w->pre_draw();
}
process_reachmap_changes();
/**
* @todo FIXME: must modify changed, but best to do it at the
* floating_label level
@ -232,25 +228,6 @@ void game_display::post_draw()
}
}
void game_display::draw_invalidated()
{
return; // DONE
display::draw_invalidated();
if (fake_unit_man_->empty()) {
return;
}
unit_drawer drawer = unit_drawer(*this);
for (const unit* temp_unit : *fake_unit_man_) {
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()
&& (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
drawer.redraw_unit(*temp_unit);
}
}
void game_display::post_commit()
{
halo_man_->render();
@ -458,7 +435,6 @@ void game_display::set_game_mode(const game_mode mode)
{
if(mode != mode_) {
mode_ = mode;
invalidate_all();
}
}
@ -644,26 +620,14 @@ bool game_display::unhighlight_reach()
}
}
void game_display::invalidate_route()
{
for(std::vector<map_location>::const_iterator i = route_.steps.begin();
i != route_.steps.end(); ++i) {
invalidate(*i);
}
}
void game_display::set_route(const pathfind::marked_route *route)
{
invalidate_route();
if(route != nullptr) {
route_ = *route;
} else {
route_.steps.clear();
route_.marks.clear();
}
invalidate_route();
}
void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
@ -692,14 +656,8 @@ int& game_display::debug_highlight(const map_location& loc)
void game_display::set_attack_indicator(const map_location& src, const map_location& dst)
{
if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
invalidate(attack_indicator_src_);
invalidate(attack_indicator_dst_);
attack_indicator_src_ = src;
attack_indicator_dst_ = dst;
invalidate(attack_indicator_src_);
invalidate(attack_indicator_dst_);
}
}
@ -721,7 +679,6 @@ void game_display::begin_game()
{
in_game_ = true;
create_buttons();
invalidate_all();
}
void game_display::needs_rebuild(bool b) {
@ -734,7 +691,6 @@ bool game_display::maybe_rebuild() {
if (needs_rebuild_) {
needs_rebuild_ = false;
recalculate_minimap();
invalidate_all();
rebuild_all();
return true;
}

View file

@ -136,8 +136,6 @@ protected:
*/
virtual void post_draw() override;
virtual void draw_invalidated() override;
virtual void post_commit() override;
virtual void draw_hex(const map_location& loc) override;
@ -216,8 +214,6 @@ private:
pathfind::marked_route route_;
void invalidate_route();
map_location displayedUnitHex_;
double sidebarScaling_;

View file

@ -289,9 +289,6 @@ void custom_tod::update_tod_display()
disp->update_tod(&get_selected_tod());
// invalidate all tiles so they are redrawn with the new ToD tint next
disp->invalidate_all();
// redraw tiles
disp->draw(false);
}

View file

@ -961,13 +961,11 @@ void menu_handler::execute_gotos(mouse_handler& mousehandler, int side)
void menu_handler::toggle_ellipses()
{
preferences::set_ellipses(!preferences::ellipses());
gui_->invalidate_all();
}
void menu_handler::toggle_grid()
{
preferences::set_grid(!preferences::grid());
gui_->invalidate_all();
}
void menu_handler::unit_hold_position(mouse_handler& mousehandler, int side_num)
@ -975,7 +973,6 @@ void menu_handler::unit_hold_position(mouse_handler& mousehandler, int side_num)
const unit_map::iterator un = units().find(mousehandler.get_selected_hex());
if(un != units().end() && un->side() == side_num && un->movement_left() >= 0) {
un->toggle_hold_position();
gui_->invalidate(mousehandler.get_selected_hex());
mousehandler.set_current_paths(pathfind::paths());
@ -990,7 +987,6 @@ void menu_handler::end_unit_turn(mouse_handler& mousehandler, int side_num)
const unit_map::iterator un = units().find(mousehandler.get_selected_hex());
if(un != units().end() && un->side() == side_num && un->movement_left() >= 0) {
un->toggle_user_end_turn();
gui_->invalidate(mousehandler.get_selected_hex());
mousehandler.set_current_paths(pathfind::paths());
@ -1925,18 +1921,15 @@ void console_handler::do_event()
void console_handler::do_toggle_draw_coordinates()
{
menu_handler_.gui_->set_draw_coordinates(!menu_handler_.gui_->get_draw_coordinates());
menu_handler_.gui_->invalidate_all();
}
void console_handler::do_toggle_draw_terrain_codes()
{
menu_handler_.gui_->set_draw_terrain_codes(!menu_handler_.gui_->get_draw_terrain_codes());
menu_handler_.gui_->invalidate_all();
}
void console_handler::do_toggle_draw_num_of_bitmaps()
{
menu_handler_.gui_->set_draw_num_of_bitmaps(!menu_handler_.gui_->get_draw_num_of_bitmaps());
menu_handler_.gui_->invalidate_all();
}
void console_handler::do_toggle_whiteboard()

View file

@ -501,10 +501,6 @@ void play_controller::init_side_end()
if (current_side() == 1 || !init_side_done_now_)
sound::play_sound(tod.sounds, sound::SOUND_SOURCES);
if (!is_skipping_replay()){
gui_->invalidate_all();
}
if (!is_skipping_replay() && current_team().get_scroll_to_leader() && !map_start_.valid()){
gui_->scroll_to_leader(current_side(), game_display::ONSCREEN,false);
}
@ -888,10 +884,6 @@ void play_controller::check_victory()
gamestate().board_.check_victory(continue_level, found_player, found_network_player, invalidate_all, not_defeated, remove_from_carryover_on_defeat_);
if (invalidate_all) {
gui_->invalidate_all();
}
if (continue_level) {
return ;
}
@ -951,7 +943,6 @@ void play_controller::update_gui_to_player(const int team_index, const bool obse
{
gui_->set_team(team_index, observe);
gui_->recalculate_minimap();
gui_->invalidate_all();
}
void play_controller::do_autosave()
@ -1090,8 +1081,6 @@ std::set<std::string> play_controller::all_players() const
void play_controller::play_side()
{
//check for team-specific items in the scenario
gui_->parse_team_overlays();
do {
update_viewing_player();
{

View file

@ -571,7 +571,6 @@ void playsingle_controller::play_ai_turn()
gui_->recalculate_minimap();
gui_->invalidate_unit();
gui_->invalidate_game_status();
gui_->invalidate_all();
}

View file

@ -265,7 +265,6 @@ void replay_controller::update_gui()
{
controller_.get_display().recalculate_minimap();
controller_.get_display().redraw_minimap();
controller_.get_display().invalidate_all();
}
void replay_controller::handle_generic_event(const std::string& name)
@ -371,7 +370,6 @@ void replay_controller::replay_show_team1()
void replay_controller::update_teams()
{
update_viewing_player();
controller_.get_display().invalidate_all();
update_gui();
}

View file

@ -895,7 +895,6 @@ int game_lua_kernel::intf_shroud_op(lua_State *L, bool place_shroud)
game_display_->labels().recalculate_shroud();
game_display_->recalculate_minimap();
game_display_->invalidate_all();
return 0;
}
@ -2042,10 +2041,6 @@ int game_lua_kernel::intf_print(lua_State *L) {
void game_lua_kernel::put_unit_helper(const map_location& loc)
{
if(game_display_) {
game_display_->invalidate(loc);
}
units().erase(loc);
resources::whiteboard->on_kill_unit();
}
@ -3293,7 +3288,6 @@ int game_lua_kernel::intf_color_adjust(lua_State *L)
vconfig cfg(luaW_checkvconfig(L, 1));
game_display_->adjust_color_overlay(cfg["red"], cfg["green"], cfg["blue"]);
game_display_->invalidate_all();
game_display_->draw(true,true);
}
return 0;
@ -3346,13 +3340,6 @@ int game_lua_kernel::intf_redraw(lua_State *L)
vconfig cfg(luaW_checkvconfig(L, 1));
bool clear_shroud(luaW_toboolean(L, 2));
// We do this twice so any applicable redraws happen both before and after
// any events caused by redrawing shroud are fired
bool result = screen.maybe_rebuild();
if (!result) {
screen.invalidate_all();
}
if (clear_shroud) {
side_filter filter(cfg, &game_state_);
for (const int side : filter.get_teams()){
@ -3361,11 +3348,6 @@ int game_lua_kernel::intf_redraw(lua_State *L)
screen.recalculate_minimap();
}
result = screen.maybe_rebuild();
if (!result) {
screen.invalidate_all();
}
screen.draw(true,true);
}
return 0;
@ -3942,7 +3924,6 @@ int game_lua_kernel::intf_toggle_fog(lua_State *L, const bool clear)
// Flag a screen update.
game_display_->recalculate_minimap();
game_display_->invalidate_all();
return 0;
}

View file

@ -455,7 +455,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_unit, child, use_undo, /*show*/, /*error_
if (name == "fail") { //testcase for bug #18488
assert(i.valid());
}
display::get_singleton()->invalidate(loc);
game_display::get_singleton()->invalidate_unit();
return true;

View file

@ -1103,6 +1103,7 @@ void unit_animation::clear_haloes()
}
}
// TODO: see if this function can be removed!
bool unit_animation::invalidate(frame_parameters& value)
{
if(invalidated_) return false;
@ -1129,16 +1130,13 @@ bool unit_animation::invalidate(frame_parameters& value)
if(complete_redraw) {
if( need_update()) {
disp->invalidate(overlaped_hex_);
invalidated_ = true;
return true;
} else {
invalidated_ = disp->propagate_invalidation(overlaped_hex_);
return invalidated_;
}
} else {
if(need_minimal_update()) {
disp->invalidate(overlaped_hex_);
invalidated_ = true;
return true;
} else {

View file

@ -74,7 +74,6 @@ static void teleport_unit_between(const map_location& a, const map_location& b,
temp_unit.set_location(a);
if ( !disp.fogged(a) ) { // teleport
disp.invalidate(a);
temp_unit.set_facing(a.get_relative_dir(b));
disp.scroll_to_tiles(a, b, game_display::ONSCREEN, true, 0.0, false);
unit_animator animator;
@ -85,7 +84,6 @@ static void teleport_unit_between(const map_location& a, const map_location& b,
temp_unit.set_location(b);
if ( !disp.fogged(b) ) { // teleport
disp.invalidate(b);
temp_unit.set_facing(a.get_relative_dir(b));
disp.scroll_to_tiles(b, a, game_display::ONSCREEN, true, 0.0, false);
unit_animator animator;
@ -125,7 +123,6 @@ static int move_unit_between(const map_location& a, const map_location& b,
}
temp_unit->set_location(a);
disp.invalidate(a);
temp_unit->set_facing(a.get_relative_dir(b));
animator.replace_anim_if_invalid(temp_unit.get(),"movement",a,b,step_num,
false,"",{0,0,0},unit_animation::hit_type::INVALID,nullptr,nullptr,step_left);
@ -260,7 +257,6 @@ void unit_mover::start(unit_ptr u)
temp_unit_ptr_->set_location(path_[0]);
temp_unit_ptr_->set_facing(path_[0].get_relative_dir(path_[1]));
temp_unit_ptr_->anim_comp().set_standing(false);
disp_->invalidate(path_[0]);
// If the unit can be seen here by the viewing side:
if ( !is_enemy_ || !temp_unit_ptr_->invisible(path_[0], disp_->get_disp_context()) ) {
@ -329,7 +325,6 @@ void unit_mover::proceed_to(unit_ptr u, size_t path_index, bool update, bool wai
{
// prevent the unit from disappearing if we scroll here with i == 0
temp_unit_ptr_->set_location(path_[current_]);
disp_->invalidate(path_[current_]);
// scroll in as much of the remaining path as possible
if ( temp_unit_ptr_->anim_comp().get_animation() )
temp_unit_ptr_->anim_comp().get_animation()->pause_animation();
@ -376,19 +371,6 @@ void unit_mover::wait_for_anims()
animator_.wait_until(wait_until_);
// debug code, see unit_frame::redraw()
// std::cout << " end\n";
/// @todo For wesnoth 1.14+: check if efficient for redrawing?
/// Check with large animated units too make sure artifacts are
/// not left on screen after unit movement in particular.
if ( disp_ ) { // Should always be true if we get here.
// Invalidate the hexes around the move that prompted this wait.
adjacent_loc_array_t arr;
get_adjacent_tiles(path_[current_-1], arr.data());
for ( unsigned i = 0; i < arr.size(); ++i )
disp_->invalidate(arr[i]);
get_adjacent_tiles(path_[current_], arr.data());
for ( unsigned i = 0; i < arr.size(); ++i )
disp_->invalidate(arr[i]);
}
}
// Reset data.
@ -455,10 +437,6 @@ void unit_mover::finish(unit_ptr u, map_location::DIRECTION dir)
// Facing gets set even when not animating.
u->set_facing(dir == map_location::NDIRECTIONS ? final_dir : dir);
u->anim_comp().set_standing(true); // Need to reset u's animation so the new facing takes effect.
// Redraw path ends (even if not animating).
disp_->invalidate(path_.front());
disp_->invalidate(end_loc);
}

View file

@ -60,7 +60,6 @@ attack::attack(size_t team_index, bool hidden, unit& u, const map_location& targ
attack_movement_cost_(get_unit()->attacks()[weapon_choice_].movement_used()),
temp_movement_subtracted_(0)
{
this->init();
}
attack::attack(const config& cfg, bool hidden)
@ -80,18 +79,10 @@ attack::attack(const config& cfg, bool hidden)
// Construct attack_movement_cost_
attack_movement_cost_ = get_unit()->attacks()[weapon_choice_].movement_used();
this->init();
}
void attack::init()
{
display::get_singleton()->invalidate(target_hex_);
}
attack::~attack()
{
invalidate();
}
void attack::accept(visitor& v)
@ -99,17 +90,6 @@ void attack::accept(visitor& v)
v.visit(shared_from_this());
}
/* private */
void attack::invalidate()
{
if(display::get_singleton())
{
//invalidate dest and target hex so attack indicator is properly cleared
display::get_singleton()->invalidate(get_dest_hex());
display::get_singleton()->invalidate(target_hex_);
}
}
void attack::execute(bool& success, bool& complete)
{
if(!valid()) {
@ -220,7 +200,6 @@ void attack::draw_hex(const map_location& hex)
void attack::redraw()
{
move::redraw();
display::get_singleton()->invalidate(target_hex_);
}
action::error attack::check_validity() const

View file

@ -67,14 +67,6 @@ protected:
private:
void init();
virtual void do_hide() {invalidate();}
virtual void do_show() {invalidate();}
///invalidates the move-destination and attack-target hexes
void invalidate();
///the target of the attack
map_location target_hex_;

View file

@ -847,8 +847,6 @@ void manager::save_temp_attack(const map_location& attacker_loc, const map_locat
print_help_once();
display::get_singleton()->invalidate(defender_loc);
display::get_singleton()->invalidate(attacker_loc);
erase_temp_move();
LOG_WB << *viewer_actions() << "\n";
}

View file

@ -555,8 +555,6 @@ void move::calculate_move_cost()
void move::redraw()
{
display::get_singleton()->invalidate(get_source_hex());
display::get_singleton()->invalidate(get_dest_hex());
update_arrow_style();
}

View file

@ -196,11 +196,6 @@ void recall::draw_hex(const map_location& hex)
}
}
void recall::redraw()
{
display::get_singleton()->invalidate(recall_hex_);
}
action::error recall::check_validity() const
{
//Check that destination hex is still free

View file

@ -52,8 +52,6 @@ public:
/** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
virtual void draw_hex(const map_location& hex);
/** Redrawing function, called each time the action situation might have changed. */
virtual void redraw();
/**
* Indicates whether this hex is the preferred hex to draw the numbering for this action.

View file

@ -160,12 +160,6 @@ void recruit::draw_hex(const map_location& hex)
}
}
void recruit::redraw()
{
display::get_singleton()->invalidate(recruit_hex_);
}
unit_ptr recruit::create_corresponding_unit()
{
unit_type const* type = unit_types.find(unit_name_);

View file

@ -57,8 +57,6 @@ public:
/** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
virtual void draw_hex(const map_location& hex);
/** Redrawing function, called each time the action situation might have changed. */
virtual void redraw();
/**
* @return the preferred hex to draw the numbering for this action.

View file

@ -722,12 +722,6 @@ void side_actions::execute_net_cmd(const net_cmd& cmd)
}
LOG_WB << "Command received: action inserted on turn #" << turn << ", position #" << pos << ": " << act << "\n";
//update numbering hexes as necessary
++itor;
for(iterator end_itor = end(); itor != end_itor; ++itor) {
display::get_singleton()->invalidate((*itor)->get_numbering_hex());
}
} else if(type=="replace") {
size_t turn = cmd["turn"].to_int();
size_t pos = cmd["pos"].to_int();
@ -762,11 +756,6 @@ void side_actions::execute_net_cmd(const net_cmd& cmd)
itor = safe_erase(itor);
LOG_WB << "Command received: action removed on turn #" << turn << ", position #" << pos << "\n";
//update numbering hexes as necessary
for(iterator end_itor = end(); itor != end_itor; ++itor) {
display::get_singleton()->invalidate((*itor)->get_numbering_hex());
}
} else if(type=="bump_later") {
size_t turn = cmd["turn"].to_int();
size_t pos = cmd["pos"].to_int();
@ -782,10 +771,6 @@ void side_actions::execute_net_cmd(const net_cmd& cmd)
bump_later(itor);
LOG_WB << "Command received: action bumped later from turn #" << turn << ", position #" << pos << "\n";
//update numbering hexes as necessary
display::get_singleton()->invalidate(first_action->get_numbering_hex());
display::get_singleton()->invalidate(second_action->get_numbering_hex());
} else if(type=="clear") {
LOG_WB << "Command received: clear\n";
clear();

View file

@ -63,7 +63,6 @@ suppose_dead::suppose_dead(size_t team_index, bool hidden, unit& curr_unit, cons
, unit_id_(curr_unit.id())
, loc_(loc)
{
this->init();
}
suppose_dead::suppose_dead(const config& cfg, bool hidden)
@ -79,20 +78,10 @@ suppose_dead::suppose_dead(const config& cfg, bool hidden)
unit_underlying_id_ = unit_itor->underlying_id();
unit_id_ = unit_itor->id();
this->init();
}
void suppose_dead::init()
{
display::get_singleton()->invalidate(loc_);
}
suppose_dead::~suppose_dead()
{
//invalidate hex so that skull indicator is properly cleared
if(display::get_singleton())
display::get_singleton()->invalidate(loc_);
}
unit_ptr suppose_dead::get_unit() const
@ -149,7 +138,6 @@ void suppose_dead::draw_hex(const map_location& hex)
void suppose_dead::redraw()
{
display::get_singleton()->invalidate(loc_);
}
action::error suppose_dead::check_validity() const

View file

@ -77,9 +77,6 @@ protected:
size_t unit_underlying_id_;
std::string unit_id_;
map_location loc_;
private:
void init();
};
/** Dumps a suppose_dead on a stream, for debug purposes. */

View file

@ -142,13 +142,11 @@ temporary_unit_hider::~temporary_unit_hider()
void ghost_owner_unit(unit* unit)
{
unit->anim_comp().set_disabled_ghosted(false);
display::get_singleton()->invalidate(unit->get_location());
}
void unghost_owner_unit(unit* unit)
{
unit->anim_comp().set_standing(true);
display::get_singleton()->invalidate(unit->get_location());
}
bool has_actions()