mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
VpkLib: actually search for corresponding data block file
Instead of just using English as default, actually scan for all supported directory tree files, error if not found. This completes the sanitization logic which allows the user to only pass in the data block file to load the directory tree file
This commit is contained in:
parent
6a60a46fc0
commit
241aefd6f3
@ -887,30 +887,55 @@ VPKDir_t::VPKDir_t(const CUtlString& dirFilePath, bool bSanitizeName)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: if we already have a locale, we call Init() anyways as that is the
|
||||
// directory tree file the user wants, despite requesting for sanitization
|
||||
bool found = false;
|
||||
|
||||
// If we don't have a locale prefix, replace the target name with
|
||||
// locale+target, so you get something like "englishserver", and
|
||||
// then we replace the target name in the passed in string with
|
||||
// the new prefix to finalize name sanitization.
|
||||
if (!bHasLocale)
|
||||
{
|
||||
CUtlString packDirPrefix;
|
||||
packDirPrefix.Append(g_LanguageNames[0]);
|
||||
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(DIR_TARGET); i++)
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); i++)
|
||||
{
|
||||
const char* targetName = DIR_TARGET[i];
|
||||
CUtlString packDirToSearch;
|
||||
packDirToSearch.Append(g_LanguageNames[i]);
|
||||
|
||||
for (size_t j = 0; j < SDK_ARRAYSIZE(DIR_TARGET); j++)
|
||||
{
|
||||
const char* targetName = DIR_TARGET[j];
|
||||
|
||||
if (sanitizedName.Find(targetName) != -1)
|
||||
{
|
||||
packDirPrefix.Append(targetName);
|
||||
sanitizedName = sanitizedName.Replace(targetName, packDirPrefix);
|
||||
packDirToSearch.Append(targetName);
|
||||
packDirToSearch = sanitizedName.Replace(targetName, packDirToSearch);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// R1 has multiple language VPK files, by default we check for english first
|
||||
// but if it doesn't exist we continue looking until we've found a directory
|
||||
// file
|
||||
if (FileSystem()->FileExists(packDirToSearch.String(), "GAME"))
|
||||
{
|
||||
sanitizedName = packDirToSearch;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bHasLocale || found)
|
||||
{
|
||||
Init(sanitizedName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(eDLL_T::FS, NO_ERROR, "Corresponding VPK directory file for '%s' not found\n", dirFilePath.Get());
|
||||
m_bInitFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user