From c6c929a90ce8e5326d644376802bec107dd5ff5d Mon Sep 17 00:00:00 2001 From: obligaron Date: Sun, 10 Apr 2022 09:53:19 +0200 Subject: [PATCH] Remove MpqDir and use PrefPath instead. --- Source/engine/assets.cpp | 4 ++-- Source/init.cpp | 1 - Source/utils/paths.cpp | 11 ----------- Source/utils/paths.h | 2 -- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/Source/engine/assets.cpp b/Source/engine/assets.cpp index 44eb5b46c..4e5a24567 100644 --- a/Source/engine/assets.cpp +++ b/Source/engine/assets.cpp @@ -43,8 +43,8 @@ SDL_RWops *OpenAsset(const char *filename, bool threadsafe) // Files next to the MPQ archives override MPQ contents. SDL_RWops *rwops; - if (paths::MpqDir()) { - const std::string path = *paths::MpqDir() + relativePath; + { + const std::string path = paths::PrefPath() + relativePath; // Avoid spamming DEBUG messages if the file does not exist. if ((FileExists(path.c_str())) && (rwops = SDL_RWFromFile(path.c_str(), "rb")) != nullptr) { LogVerbose("Loaded MPQ file override: {}", path); diff --git a/Source/init.cpp b/Source/init.cpp index 8c3deaac8..b1bb3e43f 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -69,7 +69,6 @@ std::optional LoadMPQ(const std::vector &paths, string_ mpqAbsPath = path + mpqName.data(); if ((archive = MpqArchive::Open(mpqAbsPath.c_str(), error))) { LogVerbose(" Found: {} in {}", mpqName, path); - paths::SetMpqDir(path); return archive; } if (error != 0) { diff --git a/Source/utils/paths.cpp b/Source/utils/paths.cpp index 8a5fc8eb7..4a869b9fb 100644 --- a/Source/utils/paths.cpp +++ b/Source/utils/paths.cpp @@ -24,7 +24,6 @@ std::optional basePath; std::optional prefPath; std::optional configPath; std::optional assetsPath; -std::optional mpqDir; void AddTrailingSlash(std::string &path) { @@ -99,11 +98,6 @@ const std::string &AssetsPath() return *assetsPath; } -const std::optional &MpqDir() -{ - return mpqDir; -} - void SetBasePath(const std::string &path) { basePath = path; @@ -128,11 +122,6 @@ void SetAssetsPath(const std::string &path) AddTrailingSlash(*assetsPath); } -void SetMpqDir(const std::string &path) -{ - mpqDir = std::string(path); -} - } // namespace paths } // namespace devilution diff --git a/Source/utils/paths.h b/Source/utils/paths.h index b12bd5266..639059a74 100644 --- a/Source/utils/paths.h +++ b/Source/utils/paths.h @@ -12,13 +12,11 @@ const std::string &BasePath(); const std::string &PrefPath(); const std::string &ConfigPath(); const std::string &AssetsPath(); -const std::optional &MpqDir(); void SetBasePath(const std::string &path); void SetPrefPath(const std::string &path); void SetConfigPath(const std::string &path); void SetAssetsPath(const std::string &path); -void SetMpqDir(const std::string &path); } // namespace paths