aboutsummaryrefslogtreecommitdiff
path: root/dep/CascLib/src/CascFiles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dep/CascLib/src/CascFiles.cpp')
-rw-r--r--dep/CascLib/src/CascFiles.cpp87
1 files changed, 62 insertions, 25 deletions
diff --git a/dep/CascLib/src/CascFiles.cpp b/dep/CascLib/src/CascFiles.cpp
index 8709ea09e36..a32f411462f 100644
--- a/dep/CascLib/src/CascFiles.cpp
+++ b/dep/CascLib/src/CascFiles.cpp
@@ -41,7 +41,7 @@ static const TBuildFileInfo BuildTypes[] =
{NULL, CascBuildNone}
};
-static const TCHAR * DataDirs[] =
+static const TCHAR * DataDirs[] =
{
_T("SC2Data"), // Starcraft II (Legacy of the Void) build 38749
_T("Data\\Casc"), // Overwatch
@@ -381,7 +381,7 @@ static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char * szLineBegin, const c
size_t nLength = (szLineEnd - szLineBegin);
// We expect each blob to have length of the encoding key and one space between
- if(nLength > (dwBlobCount * MD5_STRING_SIZE) + ((dwBlobCount - 1) * sizeof(char)))
+ if(nLength > (dwBlobCount * MD5_STRING_SIZE) + ((dwBlobCount - 1) * sizeof(char)))
return ERROR_INVALID_PARAMETER;
// Allocate the blob buffer
@@ -401,7 +401,7 @@ static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char * szLineBegin, const c
static int LoadSingleBlob(PQUERY_KEY pBlob, const char * szLineBegin, const char * szLineEnd)
{
- return LoadMultipleBlobs(pBlob, szLineBegin, szLineEnd, 1);
+ return LoadMultipleBlobs(pBlob, szLineBegin, szLineEnd, 1);
}
static int GetGameType(TCascStorage * hs, const char * szVarBegin, const char * szLineEnd)
@@ -409,7 +409,7 @@ static int GetGameType(TCascStorage * hs, const char * szVarBegin, const char *
// Go through all games that we support
for(size_t i = 0; GameIds[i].szGameInfo != NULL; i++)
{
- // Check the length of the variable
+ // Check the length of the variable
if((size_t)(szLineEnd - szVarBegin) == GameIds[i].cchGameInfo)
{
// Check the string
@@ -475,7 +475,7 @@ static int GetDefaultLocaleMask(TCascStorage * hs, PQUERY_KEY pTagsString)
// Get the next part
if(szNext == NULL)
break;
-
+
// Skip spaces
while(szNext < szTagEnd && szNext[0] == ' ')
szNext++;
@@ -523,7 +523,7 @@ static int ParseFile_BuildInfo(TCascStorage * hs, void * pvListFile)
QUERY_KEY CdnHost = {NULL, 0};
QUERY_KEY CdnPath = {NULL, 0};
char szOneLine1[0x200];
- char szOneLine2[0x200];
+ char szOneLine2[0x400];
size_t nLength1;
size_t nLength2;
int nError = ERROR_BAD_FORMAT;
@@ -935,7 +935,7 @@ int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory)
return ERROR_SUCCESS;
}
}
-
+
CASC_FREE(szBuildFile);
}
}
@@ -943,15 +943,48 @@ int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory)
return nError;
}
-// Parses single line from Overwatch.
-// The line structure is: "#MD5|CHUNK_ID|FILENAME|INSTALLPATH"
+//-----------------------------------------------------------------------------
+// Helpers for a config files that have multiple variables separated by "|"
+// The line structure is (Overwatch 24919): "#MD5|CHUNK_ID|FILENAME|INSTALLPATH"
+// The line structure is (Overwatch 27759): "#MD5|CHUNK_ID|PRIORITY|MPRIORITY|FILENAME|INSTALLPATH"
// The line has all preceding spaces removed
-int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, PQUERY_KEY PtrEncodingKey, char * szFileName, size_t nMaxChars)
+
+// Retrieves the index of a variable from the initial line
+int GetRootVariableIndex(const char * szLinePtr, const char * szLineEnd, const char * szVariableName, int * PtrIndex)
{
- size_t nLength;
+ size_t nLength = strlen(szVariableName);
+ int nIndex = 0;
+
+ while(szLinePtr < szLineEnd)
+ {
+ // Check the variable there
+ if(!_strnicmp(szLinePtr, szVariableName, nLength))
+ {
+ // Does the length match?
+ if(szLinePtr[nLength] == '|' || szLinePtr[nLength] == '0')
+ {
+ PtrIndex[0] = nIndex;
+ return ERROR_SUCCESS;
+ }
+ }
+
+ // Get the next variable
+ szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd);
+ if(szLinePtr == NULL)
+ break;
+ nIndex++;
+ }
+
+ return ERROR_BAD_FORMAT;
+}
+
+// Parses single line from Overwatch.
+int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, int nFileNameIndex, PQUERY_KEY PtrEncodingKey, char * szFileName, size_t nMaxChars)
+{
+ int nIndex = 0;
int nError;
- // Check the MD5 (aka encoding key)
+ // Extract the MD5 (aka encoding key)
if(szLinePtr[MD5_STRING_SIZE] != '|')
return ERROR_BAD_FORMAT;
@@ -961,21 +994,25 @@ int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, PQUERY_KEY
if(nError != ERROR_SUCCESS)
return nError;
- // Skip the MD5
- szLinePtr += MD5_STRING_SIZE+1;
-
- // Skip the chunk ID
- szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd);
+ // Skip the variable
+ szLinePtr += MD5_STRING_SIZE + 1;
+ nIndex = 1;
- // Get the archived file name
- szLineEnd = SkipInfoVariable(szLinePtr, szLineEnd);
- nLength = (size_t)(szLineEnd - szLinePtr - 1);
+ // Skip the variables until we find the file name
+ while(szLinePtr < szLineEnd && nIndex < nFileNameIndex)
+ {
+ if(szLinePtr[0] == '|')
+ nIndex++;
+ szLinePtr++;
+ }
- // Get the file name
- if(nLength > nMaxChars)
- return ERROR_INSUFFICIENT_BUFFER;
+ // Extract the file name
+ while(szLinePtr < szLineEnd && szLinePtr[0] != '|' && nMaxChars > 1)
+ {
+ *szFileName++ = *szLinePtr++;
+ nMaxChars--;
+ }
- memcpy(szFileName, szLinePtr, nLength);
- szFileName[nLength] = 0;
+ *szFileName = 0;
return ERROR_SUCCESS;
}