From 8280f41fa584ffe1d89bbcfa6022de50332f1e74 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 11 Dec 2024 22:30:07 -0500 Subject: [PATCH] ResourceManager.DidLoadSuccessfully() -> ResourceManager.IsLoaded() (#751) --- src/Context.cpp | 2 +- src/public/bridge/resourcebridge.cpp | 4 ++-- src/public/bridge/resourcebridge.h | 2 +- src/resource/ResourceManager.cpp | 4 ++-- src/resource/ResourceManager.h | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index f3d717ceb..d96c09059 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -201,7 +201,7 @@ void Context::InitResourceManager(const std::vector& archivePaths, GetResourceManager()->Init(archivePaths, validHashes, reservedThreadCount); } - if (!GetResourceManager()->DidLoadSuccessfully()) { + if (!GetResourceManager()->IsLoaded()) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OTR file not found", "Main OTR file not found. Please generate one", nullptr); SPDLOG_ERROR("Main OTR file not found!"); diff --git a/src/public/bridge/resourcebridge.cpp b/src/public/bridge/resourcebridge.cpp index d9ba335f0..38411cea0 100644 --- a/src/public/bridge/resourcebridge.cpp +++ b/src/public/bridge/resourcebridge.cpp @@ -197,7 +197,7 @@ void ResourceUnloadDirectory(const char* name) { Ship::Context::GetInstance()->GetResourceManager()->UnloadDirectory(name); } -uint32_t ResourceDoesOtrFileExist() { - return Ship::Context::GetInstance()->GetResourceManager()->DidLoadSuccessfully(); +uint32_t IsResourceManagerLoaded() { + return Ship::Context::GetInstance()->GetResourceManager()->IsLoaded(); } } diff --git a/src/public/bridge/resourcebridge.h b/src/public/bridge/resourcebridge.h index bb83d2a0b..b1e382bb4 100644 --- a/src/public/bridge/resourcebridge.h +++ b/src/public/bridge/resourcebridge.h @@ -46,7 +46,7 @@ void ResourceUnloadDirectory(const char* name); void ResourceClearCache(); void ResourceGetGameVersions(uint32_t* versions, size_t versionsSize, size_t* versionsCount); uint32_t ResourceHasGameVersion(uint32_t hash); -uint32_t ResourceDoesOtrFileExist(); +uint32_t IsResourceManagerLoaded(); #ifdef __cplusplus }; diff --git a/src/resource/ResourceManager.cpp b/src/resource/ResourceManager.cpp index 5afef4d28..9326a0de6 100644 --- a/src/resource/ResourceManager.cpp +++ b/src/resource/ResourceManager.cpp @@ -50,7 +50,7 @@ void ResourceManager::Init(const std::vector& archivePaths, size_t threadCount = std::max(1, (int32_t)(std::thread::hardware_concurrency() - reservedThreadCount - 1)); mThreadPool = std::make_shared(threadCount); - if (!DidLoadSuccessfully()) { + if (!IsLoaded()) { // Nothing ever unpauses the thread pool since nothing will ever try to load the archive again. mThreadPool->pause(); } @@ -60,7 +60,7 @@ ResourceManager::~ResourceManager() { SPDLOG_INFO("destruct ResourceManager"); } -bool ResourceManager::DidLoadSuccessfully() { +bool ResourceManager::IsLoaded() { return mArchiveManager != nullptr && mArchiveManager->IsLoaded(); } diff --git a/src/resource/ResourceManager.h b/src/resource/ResourceManager.h index a7862f402..003c153a0 100644 --- a/src/resource/ResourceManager.h +++ b/src/resource/ResourceManager.h @@ -48,6 +48,8 @@ class ResourceManager { int32_t reservedThreadCount = 1); ~ResourceManager(); + bool IsLoaded(); + std::shared_ptr GetArchiveManager(); std::shared_ptr GetResourceLoader(); @@ -81,7 +83,6 @@ class ResourceManager { void DirtyDirectory(const std::string& searchMask); void UnloadDirectory(const std::string& searchMask); - bool DidLoadSuccessfully(); bool OtrSignatureCheck(const char* fileName); bool IsAltAssetsEnabled(); void SetAltAssetsEnabled(bool isEnabled);