mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Check for read-only UMM archives.
TODO: Skip merging as it's currently just doing duplicate loads.
This commit is contained in:
parent
ec79ef5e2d
commit
a37f2885ae
1 changed files with 24 additions and 6 deletions
|
|
@ -18,7 +18,7 @@ struct Mod
|
||||||
ModType type{};
|
ModType type{};
|
||||||
std::vector<std::filesystem::path> includeDirs;
|
std::vector<std::filesystem::path> includeDirs;
|
||||||
bool merge = false;
|
bool merge = false;
|
||||||
ankerl::unordered_dense::set<std::filesystem::path> readOnly;
|
ankerl::unordered_dense::set<XXH64_hash_t> readOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<Mod> g_mods;
|
static std::vector<Mod> g_mods;
|
||||||
|
|
@ -39,15 +39,18 @@ std::filesystem::path ModLoader::RedirectPath(std::string_view path)
|
||||||
if (findResult != s_pathCache.end())
|
if (findResult != s_pathCache.end())
|
||||||
return findResult->second;
|
return findResult->second;
|
||||||
|
|
||||||
|
std::string pathStr(path);
|
||||||
|
std::replace(pathStr.begin(), pathStr.end(), '\\', '/');
|
||||||
|
hash = XXH3_64bits(pathStr.data(), pathStr.size());
|
||||||
|
|
||||||
for (auto& mod : g_mods)
|
for (auto& mod : g_mods)
|
||||||
{
|
{
|
||||||
// TODO: Check for read only.
|
if (mod.type == ModType::UMM && mod.merge && !mod.readOnly.contains(hash))
|
||||||
if (mod.type == ModType::UMM && mod.merge)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (auto& includeDir : mod.includeDirs)
|
for (auto& includeDir : mod.includeDirs)
|
||||||
{
|
{
|
||||||
std::filesystem::path modPath = includeDir / path;
|
std::filesystem::path modPath = includeDir / pathStr;
|
||||||
if (std::filesystem::exists(modPath))
|
if (std::filesystem::exists(modPath))
|
||||||
return s_pathCache.emplace(hash, modPath).first->second;
|
return s_pathCache.emplace(hash, modPath).first->second;
|
||||||
}
|
}
|
||||||
|
|
@ -101,6 +104,23 @@ void ModLoader::Init()
|
||||||
mod.type = ModType::UMM;
|
mod.type = ModType::UMM;
|
||||||
mod.includeDirs.emplace_back(std::move(modDirectoryPath));
|
mod.includeDirs.emplace_back(std::move(modDirectoryPath));
|
||||||
mod.merge = modIni.getBool("Details", "Merge", modIni.getBool("Filesystem", "Merge", false));
|
mod.merge = modIni.getBool("Details", "Merge", modIni.getBool("Filesystem", "Merge", false));
|
||||||
|
|
||||||
|
std::string readOnly = modIni.getString("Details", "Read-only", modIni.getString("Filesystem", "Read-only", std::string()));
|
||||||
|
std::replace(readOnly.begin(), readOnly.end(), '\\', '/');
|
||||||
|
std::string_view iterator = readOnly;
|
||||||
|
|
||||||
|
while (!iterator.empty())
|
||||||
|
{
|
||||||
|
size_t index = iterator.find(',');
|
||||||
|
if (index == std::string_view::npos)
|
||||||
|
{
|
||||||
|
mod.readOnly.emplace(XXH3_64bits(iterator.data(), iterator.size()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.readOnly.emplace(XXH3_64bits(iterator.data(), index));
|
||||||
|
iterator.remove_prefix(index + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // HMM
|
else // HMM
|
||||||
{
|
{
|
||||||
|
|
@ -435,8 +455,6 @@ PPC_FUNC(sub_82E0B500)
|
||||||
{
|
{
|
||||||
if (mod.merge)
|
if (mod.merge)
|
||||||
{
|
{
|
||||||
// TODO: Check for read only.
|
|
||||||
|
|
||||||
if (arFilePath.empty())
|
if (arFilePath.empty())
|
||||||
arFilePath = arFilePathU8;
|
arFilePath = arFilePathU8;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue