saveload fix

This commit is contained in:
nillerusr
2022-01-09 19:59:13 +03:00
parent 1d8149a3b3
commit 1f3436945f
3 changed files with 25 additions and 15 deletions

View File

@@ -2128,8 +2128,8 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
int nNumberOfFields;
char *pData;
int nFieldSize;
short nFieldSize;
pData = pSaveData;
// Allocate a table for the strings, and parse the table
@@ -2148,9 +2148,12 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
pTokenList = NULL;
// short, short (size, index of field name)
nFieldSize = *(short *)pData;
Q_memcpy( &nFieldSize, pData, sizeof(short) );
pData += sizeof(short);
pFieldName = pTokenList[ *(short *)pData ];
short index = 0;
Q_memcpy( &index, pData, sizeof(short) );
pFieldName = pTokenList[index];
if ( !pFieldName || Q_stricmp( pFieldName, "GameHeader" ) )
{
@@ -2161,7 +2164,7 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
// int (fieldcount)
pData += sizeof(short);
nNumberOfFields = *(int*)pData;
Q_memcpy( &nNumberOfFields, pData, sizeof(int) );
pData += nFieldSize;
// Each field is a short (size), short (index of name), binary string of "size" bytes (data)
@@ -2172,10 +2175,11 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
// szName
// Actual Data
nFieldSize = *(short *)pData;
Q_memcpy( &nFieldSize, pData, sizeof(short) );
pData += sizeof(short);
pFieldName = pTokenList[ *(short *)pData ];
Q_memcpy( &index, pData, sizeof(short) );
pFieldName = pTokenList[index];
pData += sizeof(short);
if ( !Q_stricmp( pFieldName, "comment" ) )