diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 9b5e6a0dfe..8281accbde 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -34,6 +34,7 @@ private: std::vector _downloadedEntries; size_t _currentDownloadIndex{}; std::mutex _downloadedEntriesMutex; + bool _nextDownloadQueued{}; // TODO static due to INTENT_EXTRA_CALLBACK not allowing a std::function inline static bool _downloadingObjects; @@ -44,7 +45,7 @@ public: _entries = entries; _currentDownloadIndex = 0; _downloadingObjects = true; - NextDownload(); + QueueNextDownload(); } bool IsDownloading() const @@ -58,6 +59,15 @@ public: return _downloadedEntries; } + void Update() + { + if (_nextDownloadQueued) + { + _nextDownloadQueued = false; + NextDownload(); + } + } + private: void UpdateProgress(const std::string& name, size_t count, size_t total) { @@ -75,6 +85,11 @@ private: context_open_intent(&intent); } + void QueueNextDownload() + { + _nextDownloadQueued = true; + } + void DownloadObject(const rct_object_entry& entry, const std::string name, const std::string_view url) { using namespace OpenRCT2::Network; @@ -103,13 +118,13 @@ private: { throw std::runtime_error("Non 200 status"); } - NextDownload(); + QueueNextDownload(); }); } catch (const std::exception&) { std::printf(" Failed to download %s\n", name.c_str()); - NextDownload(); + QueueNextDownload(); } } @@ -153,12 +168,12 @@ private: else if (response.status == Http::Status::NotFound) { std::printf(" %s not found\n", name.c_str()); - NextDownload(); + QueueNextDownload(); } else { std::printf(" %s query failed (status %d)\n", name.c_str(), (int32_t)response.status); - NextDownload(); + QueueNextDownload(); } }); } @@ -393,6 +408,8 @@ static void window_object_load_error_update(rct_window* w) } #ifndef DISABLE_HTTP + _objDownloader.Update(); + // Remove downloaded objects from our invalid entry list if (_objDownloader.IsDownloading()) {