mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
CPackedStore::GetDirectoryFile optimizations
Break when we have a locale, or found the context. Removed extraneous logic/vars.
This commit is contained in:
parent
142c0d1de5
commit
780b968bc7
@ -63,47 +63,35 @@ VPKDir_t CPackedStore::GetDirectoryFile(string svPackDirFile, bool bSanitizeName
|
|||||||
StringReplace(svPackDirFile, smRegexMatches[0], "pak000_dir");
|
StringReplace(svPackDirFile, smRegexMatches[0], "pak000_dir");
|
||||||
|
|
||||||
bool bHasLocale = false;
|
bool bHasLocale = false;
|
||||||
bool bHasContext = false;
|
|
||||||
string svPackDirPrefix;
|
string svPackDirPrefix;
|
||||||
|
|
||||||
size_t nLocaleIndex = 0; // Default to ENGLISH;
|
|
||||||
size_t nContextIndex = 0; // Default to SERVER;
|
|
||||||
|
|
||||||
for (size_t i = 0, nl = DIR_LOCALE.size(); i < nl; i++)
|
for (size_t i = 0, nl = DIR_LOCALE.size(); i < nl; i++)
|
||||||
{
|
{
|
||||||
const string& svLocale = DIR_LOCALE[i];
|
const string& svLocale = DIR_LOCALE[i];
|
||||||
if (svPackDirFile.find(svLocale) != string::npos)
|
if (svPackDirFile.find(svLocale) != string::npos)
|
||||||
{
|
{
|
||||||
svPackDirPrefix.append(svLocale);
|
|
||||||
nLocaleIndex = i;
|
|
||||||
bHasLocale = true;
|
bHasLocale = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svPackDirPrefix.empty()) // No locale found.
|
|
||||||
{
|
|
||||||
svPackDirPrefix.append(DIR_LOCALE[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bHasLocale)
|
if (!bHasLocale)
|
||||||
{
|
{
|
||||||
|
svPackDirPrefix.append(DIR_LOCALE[0]);
|
||||||
|
|
||||||
for (size_t i = 0, nc = DIR_CONTEXT.size(); i < nc; i++)
|
for (size_t i = 0, nc = DIR_CONTEXT.size(); i < nc; i++)
|
||||||
{
|
{
|
||||||
const string& svContext = DIR_CONTEXT[i];
|
const string& svContext = DIR_CONTEXT[i];
|
||||||
if (svPackDirFile.find(svContext) != string::npos)
|
if (svPackDirFile.find(svContext) != string::npos)
|
||||||
{
|
{
|
||||||
svPackDirPrefix.append(svContext);
|
svPackDirPrefix.append(svContext);
|
||||||
nContextIndex = i;
|
StringReplace(svPackDirFile, svContext, svPackDirPrefix);
|
||||||
bHasContext = true;
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bHasContext) // Context is required for this to work.
|
|
||||||
{
|
|
||||||
StringReplace(svPackDirFile, DIR_CONTEXT[nContextIndex], svPackDirPrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
return VPKDir_t(svPackDirFile);
|
return VPKDir_t(svPackDirFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user