Skip to content

Commit

Permalink
Merge pull request #45634 from Aivean/speedup-quicksave
Browse files Browse the repository at this point in the history
Speedup quicksave (up to x2)  by limiting `ui_manager::redraw()` rate
  • Loading branch information
ZhilkinSerg authored Nov 26, 2020
2 parents df17a62 + fbbf38a commit afba8de
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/mapbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,18 @@ void mapbuffer::save( bool delete_after_save )
// A set of already-saved submaps, in global overmap coordinates.
std::set<tripoint> saved_submaps;
std::list<tripoint> submaps_to_delete;
int next_report = 0;
static constexpr std::chrono::milliseconds update_interval( 500 );
auto last_update = std::chrono::steady_clock::now();

for( auto &elem : submaps ) {
if( num_total_submaps > 100 && num_saved_submaps >= next_report ) {
auto now = std::chrono::steady_clock::now();
if( last_update + update_interval < now ) {
popup.message( _( "Please wait as the map saves [%d/%d]" ),
num_saved_submaps, num_total_submaps );
ui_manager::redraw();
refresh_display();
next_report += std::max( 100, num_total_submaps / 20 );
last_update = now;
}

// Whatever the coordinates of the current submap are,
// we're saving a 2x2 quad of submaps at a time.
// Submaps are generated in quads, so we know if we have one member of a quad,
Expand Down

0 comments on commit afba8de

Please sign in to comment.