mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-26 03:12:18 -05:00
cleanups
This commit is contained in:
parent
ac2127094b
commit
cf872d1e0d
@ -9,7 +9,7 @@
|
||||
|
||||
namespace Ship {
|
||||
|
||||
ResourceMgr::ResourceMgr(std::shared_ptr<GlobalCtx2> Context, std::string MainPath, std::string PatchesPath) : Context(Context), bIsRunning(false), FileLoadThread(nullptr) {
|
||||
ResourceMgr::ResourceMgr(std::shared_ptr<GlobalCtx2> Context, const std::string& MainPath, const std::string& PatchesPath) : Context(Context), bIsRunning(false), FileLoadThread(nullptr) {
|
||||
OTR = std::make_shared<Archive>(MainPath, PatchesPath, false);
|
||||
|
||||
gameVersion = OOT_UNKNOWN;
|
||||
@ -95,7 +95,7 @@ namespace Ship {
|
||||
|
||||
//Lock.unlock();
|
||||
|
||||
SPDLOG_DEBUG("Loaded File {} on ResourceMgr thread", ToLoad->path);
|
||||
SPDLOG_DEBUG("Loaded File {} on ResourceMgr thread", ToLoad->path.c_str());
|
||||
|
||||
ToLoad->FileLoadNotifier.notify_all();
|
||||
}
|
||||
@ -186,7 +186,7 @@ namespace Ship {
|
||||
gameVersion = newGameVersion;
|
||||
}
|
||||
|
||||
std::shared_ptr<File> ResourceMgr::LoadFileAsync(std::string FilePath) {
|
||||
std::shared_ptr<File> ResourceMgr::LoadFileAsync(const std::string& FilePath) {
|
||||
const std::lock_guard<std::mutex> Lock(FileLoadMutex);
|
||||
// File NOT already loaded...?
|
||||
auto fileCacheFind = FileCache.find(FilePath);
|
||||
@ -204,7 +204,7 @@ namespace Ship {
|
||||
return fileCacheFind->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<File> ResourceMgr::LoadFile(std::string FilePath) {
|
||||
std::shared_ptr<File> ResourceMgr::LoadFile(const std::string& FilePath) {
|
||||
auto ToLoad = LoadFileAsync(FilePath);
|
||||
// Wait for the File to actually be loaded if we are told to block.
|
||||
std::unique_lock<std::mutex> Lock(ToLoad->FileLoadMutex);
|
||||
@ -280,7 +280,7 @@ namespace Ship {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ResourcePromise>>> ResourceMgr::CacheDirectoryAsync(std::string SearchMask) {
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ResourcePromise>>> ResourceMgr::CacheDirectoryAsync(const std::string& SearchMask) {
|
||||
auto loadedList = std::make_shared<std::vector<std::shared_ptr<ResourcePromise>>>();
|
||||
auto fileList = OTR->ListFiles(SearchMask);
|
||||
|
||||
@ -299,7 +299,7 @@ namespace Ship {
|
||||
return loadedList;
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Resource>>> ResourceMgr::CacheDirectory(std::string SearchMask) {
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Resource>>> ResourceMgr::CacheDirectory(const std::string& SearchMask) {
|
||||
auto PromiseList = CacheDirectoryAsync(SearchMask);
|
||||
auto LoadedList = std::make_shared<std::vector<std::shared_ptr<Resource>>>();
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace Ship
|
||||
// It works with the original game's assets because the entire ROM is 64MB and fits into RAM of any semi-modern PC.
|
||||
class ResourceMgr {
|
||||
public:
|
||||
ResourceMgr(std::shared_ptr<GlobalCtx2> Context, std::string MainPath, std::string PatchesPath);
|
||||
ResourceMgr(std::shared_ptr<GlobalCtx2> Context, const std::string& MainPath, const std::string& PatchesPath);
|
||||
~ResourceMgr();
|
||||
|
||||
bool IsRunning();
|
||||
@ -32,14 +32,14 @@ namespace Ship
|
||||
|
||||
uint32_t GetGameVersion();
|
||||
void SetGameVersion(uint32_t newGameVersion);
|
||||
std::shared_ptr<File> LoadFileAsync(std::string FilePath);
|
||||
std::shared_ptr<File> LoadFile(std::string FilePath);
|
||||
std::shared_ptr<File> LoadFileAsync(const std::string& FilePath);
|
||||
std::shared_ptr<File> LoadFile(const std::string& FilePath);
|
||||
std::shared_ptr<Ship::Resource> GetCachedFile(const char* FilePath) const;
|
||||
std::shared_ptr<Resource> LoadResource(const char* FilePath);
|
||||
std::shared_ptr<Resource> LoadResource(const std::string& FilePath) { return LoadResource(FilePath.c_str()); }
|
||||
std::variant<std::shared_ptr<Resource>, std::shared_ptr<ResourcePromise>> LoadResourceAsync(const char* FilePath);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Resource>>> CacheDirectory(std::string SearchMask);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ResourcePromise>>> CacheDirectoryAsync(std::string SearchMask);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Resource>>> CacheDirectory(const std::string& SearchMask);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ResourcePromise>>> CacheDirectoryAsync(const std::string& SearchMask);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Resource>>> DirtyDirectory(std::string SearchMask);
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user