summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-19 19:31:45 +0100
committerPatric Stout <github@truebrain.nl>2021-02-19 19:56:40 +0100
commit8bf8c0f25188ecd17165dbb49739e7d193396790 (patch)
treeecb3ba26d79808a354e08a8aeddc0128fe3d6c5b /src/newgrf_config.cpp
parentcb8e1706b29d47f61e1a0419dcddc923503e0839 (diff)
downloadopenttd-8bf8c0f25188ecd17165dbb49739e7d193396790.tar.xz
Fix d437445c: also use std::chrono for the GRFFileScanner modal window
For some reason I only converted one of the two modal windows we have, and completely forgot the other. While at it, synchronize the way those two modal windows work in terms of "next_update".
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index cd95a4b8a..e56f878bd 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -578,12 +578,13 @@ compatible_grf:
/** Helper for scanning for files with GRF as extension */
class GRFFileScanner : FileScanner {
- uint next_update; ///< The next (realtime tick) we do update the screen.
+ std::chrono::steady_clock::time_point next_update; ///< The next moment we do update the screen.
uint num_scanned; ///< The number of GRFs we have scanned.
public:
- GRFFileScanner() : next_update(_realtime_tick), num_scanned(0)
+ GRFFileScanner() : num_scanned(0)
{
+ this->next_update = std::chrono::steady_clock::now();
}
bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename) override;
@@ -634,7 +635,9 @@ bool GRFFileScanner::AddFile(const std::string &filename, size_t basepath_length
}
this->num_scanned++;
- if (this->next_update <= _realtime_tick) {
+ if (std::chrono::steady_clock::now() >= this->next_update) {
+ this->next_update = std::chrono::steady_clock::now() + std::chrono::milliseconds(MODAL_PROGRESS_REDRAW_TIMEOUT);
+
_modal_progress_work_mutex.unlock();
_modal_progress_paint_mutex.lock();
@@ -645,8 +648,6 @@ bool GRFFileScanner::AddFile(const std::string &filename, size_t basepath_length
_modal_progress_work_mutex.lock();
_modal_progress_paint_mutex.unlock();
-
- this->next_update = _realtime_tick + MODAL_PROGRESS_REDRAW_TIMEOUT;
}
if (!added) {