Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup quicksave (up to x2) by limiting ui_manager::redraw() rate #45634

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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