aboutsummaryrefslogtreecommitdiff
path: root/src/SBaseFileTable.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2020-11-23 12:56:00 +0100
committerLadislav Zezula <zezula@volny.cz>2020-11-23 12:56:00 +0100
commitb6102b2600f792f159320439686a872a72d20c70 (patch)
treea9cfacadc0c28b3cfde908d2a4511b6605a648a0 /src/SBaseFileTable.cpp
parent809005c7f025bcc55bfa4ede78cb4cc45d3c0e6c (diff)
Removed trailing whitespace
Diffstat (limited to 'src/SBaseFileTable.cpp')
-rw-r--r--src/SBaseFileTable.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp
index 7fe1042..98d8e44 100644
--- a/src/SBaseFileTable.cpp
+++ b/src/SBaseFileTable.cpp
@@ -52,7 +52,7 @@ static DWORD GetNecessaryBitCount(ULONGLONG MaxValue)
MaxValue >>= 1;
dwBitCount++;
}
-
+
return dwBitCount;
}
@@ -119,7 +119,7 @@ void TMPQBits::GetBits(
#ifndef STORMLIB_LITTLE_ENDIAN
// Adjust the buffer pointer for big endian platforms
pbBuffer += (nResultByteSize - 1);
-#endif
+#endif
// Copy whole bytes, if any
while(nByteLength > 0)
@@ -178,7 +178,7 @@ void TMPQBits::SetBits(
#ifndef STORMLIB_LITTLE_ENDIAN
// Adjust the buffer pointer for big endian platforms
pbBuffer += (nResultByteSize - 1);
-#endif
+#endif
// Copy whole bytes, if any
while(nBitLength > 8)
@@ -392,7 +392,7 @@ ULONGLONG CalculateRawSectorOffset(
// Must be used for files within a MPQ
assert(hf->ha != NULL);
assert(hf->ha->pHeader != NULL);
-
+
//
// Some MPQ protectors place the sector offset table after the actual file data.
// Sector offsets in the sector offset table are negative. When added
@@ -476,7 +476,7 @@ int ConvertMpqHeaderToFormat4(
pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock);
pHeader->HashTableSize64 = pHeader->dwHashTableSize * sizeof(TMPQHash);
pHeader->ArchiveSize64 = pHeader->dwArchiveSize;
-
+
// Block table position must be calculated as 32-bit value
// Note: BOBA protector puts block table before the MPQ header, so it is negative
BlockTablePos64 = (ULONGLONG)((DWORD)MpqOffset + pHeader->dwBlockTablePos);
@@ -626,7 +626,7 @@ int ConvertMpqHeaderToFormat4(
pHeader->HetTableSize64 = ByteOffset - pHeader->HetTablePos64;
// ByteOffset = pHeader->HetTablePos64;
}
-
+
// Add the MPQ Offset
BlockTablePos64 += MpqOffset;
break;
@@ -697,14 +697,14 @@ int ConvertMpqHeaderToFormat4(
bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash)
{
TFileEntry * pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash);
-
+
return ((MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) && (pFileEntry->dwFlags & MPQ_FILE_EXISTS)) ? true : false;
}
// Hash entry verification when the file table does not exist yet
static bool IsValidHashEntry1(TMPQArchive * ha, TMPQHash * pHash, TMPQBlock * pBlockTable)
{
- ULONGLONG ByteOffset;
+ ULONGLONG ByteOffset;
TMPQBlock * pBlock;
// The block index is considered valid if it's less than block table size
@@ -758,7 +758,7 @@ static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName,
}
// Get the next hash entry for that file
- pHash = GetNextHashEntry(ha, pFirstHash, pHash);
+ pHash = GetNextHashEntry(ha, pFirstHash, pHash);
}
// At the end, return neutral hash (if found), otherwise NULL
@@ -779,9 +779,9 @@ static TMPQHash * GetHashEntryExact(TMPQArchive * ha, const char * szFileName, L
// If the locales match, return it
if(pHash->lcLocale == lcLocale)
return pHash;
-
+
// Get the next hash entry for that file
- pHash = GetNextHashEntry(ha, pFirstHash, pHash);
+ pHash = GetNextHashEntry(ha, pFirstHash, pHash);
}
// Not found
@@ -1361,7 +1361,7 @@ TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwNa
// Copy the file indexes
memcpy(pHetTable->pBetIndexes->Elements, pbSrcData + dwTotalCount, pHetTable->pBetIndexes->NumberOfBytes);
}
-
+
// Return the result HET table
return pHetTable;
}
@@ -1445,7 +1445,7 @@ static TMPQHetTable * TranslateHetTable(TMPQHetHeader * pHetHeader)
// The size of index table (in entries) is expected
// to be the same like the hash table size (in bytes)
assert(((pHetHeader->dwTotalCount * pHetHeader->dwIndexSizeTotal) + 7) / 8 == pHetHeader->dwIndexTableSize);
-
+
// Create translated table
pHetTable = CreateHetTable(pHetHeader->dwEntryCount, pHetHeader->dwTotalCount, pHetHeader->dwNameHashBitSize, pbSrcData);
if(pHetTable != NULL)
@@ -1761,7 +1761,7 @@ static TMPQBetTable * TranslateBetTable(
pBetTable->dwBitTotal_NameHash2 = pBetHeader->dwBitTotal_NameHash2;
pBetTable->dwBitExtra_NameHash2 = pBetHeader->dwBitExtra_NameHash2;
pBetTable->dwBitCount_NameHash2 = pBetHeader->dwBitCount_NameHash2;
-
+
// Create and load the array of BET hashes
pBetTable->pNameHashes = TMPQBits::Create(pBetTable->dwBitTotal_NameHash2 * pBetHeader->dwEntryCount, 0);
if(pBetTable->pNameHashes != NULL)
@@ -1875,7 +1875,7 @@ TMPQExtHeader * TranslateBetTable(
BetHeader.dwBitCount_NameHash2,
&pFileEntry->FileNameHash,
8);
-
+
assert(dwFileIndex < BetHeader.dwEntryCount);
dwFileIndex++;
}
@@ -1983,7 +1983,7 @@ TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID l
return ha->pFileTable + dwFileIndex;
}
}
-
+
// Not found
return NULL;
}
@@ -2045,7 +2045,7 @@ TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID l
if(pFreeEntry == NULL)
pFreeEntry = pFileEntry;
dwFreeCount++;
-
+
// If the number of free items is greater than number
// of reserved items, We can add the file
if(dwFreeCount > dwReservedFiles)
@@ -2173,7 +2173,7 @@ int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf)
pFileEntry->dwFlags &= ~MPQ_FILE_EXISTS;
pFileEntry->FileNameHash = 0;
- return ERROR_SUCCESS;
+ return ERROR_SUCCESS;
}
DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew, DWORD dwForceAddTheFile = 0)
@@ -2206,7 +2206,7 @@ DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dw
else
{
ha->dwFlags |= dwFlagNone;
- dwFileFlags = 0;
+ dwFileFlags = 0;
}
// Return the intended file flags
@@ -2220,7 +2220,7 @@ void InvalidateInternalFiles(TMPQArchive * ha)
{
//
// We clear the file entries for (listfile), (attributes) and (signature)
- // For each internal file cleared, we increment the number
+ // For each internal file cleared, we increment the number
// of reserved entries in the file table.
//
@@ -2366,7 +2366,7 @@ TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool /* bDontFixEntries */)
// Read, decrypt and uncompress the block table
pBlockTable = (TMPQBlock * )LoadMpqTable(ha, ByteOffset, dwCmpSize, dwTableSize, MPQ_KEY_BLOCK_TABLE, &bBlockTableIsCut);
-
+
// If the block table was cut, we need to remember it
if(pBlockTable != NULL && bBlockTableIsCut)
ha->dwFlags |= (MPQ_FLAG_MALFORMED | MPQ_FLAG_BLOCK_TABLE_CUT);
@@ -2551,7 +2551,7 @@ static int BuildFileTable_HetBet(TMPQArchive * ha)
FreeBetTable(pBetTable);
return ERROR_FILE_CORRUPT;
}
-
+
// Step one: Fill the name indexes
for(i = 0; i < pHetTable->dwTotalCount; i++)
{
@@ -2586,7 +2586,7 @@ static int BuildFileTable_HetBet(TMPQArchive * ha)
// Go through the entire BET table and convert it to the file table.
pFileEntry = ha->pFileTable;
- pBitArray = pBetTable->pFileTable;
+ pBitArray = pBetTable->pFileTable;
for(i = 0; i < pBetTable->dwEntryCount; i++)
{
DWORD dwFlagIndex = 0;
@@ -2697,7 +2697,7 @@ void UpdateBlockTableSize(TMPQArchive * ha)
// Calculate the number of files
for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++)
{
- // If the source table entry is valid,
+ // If the source table entry is valid,
if(pFileEntry->dwFlags & MPQ_FILE_EXISTS)
dwBlockTableSize = (DWORD)(pFileEntry - ha->pFileTable) + 1;
}
@@ -2728,7 +2728,7 @@ int DefragmentFileTable(TMPQArchive * ha)
// Parse the entire file table and defragment it
for(; pSource < pFileTableEnd; pSource++)
{
- // If the source table entry is valid,
+ // If the source table entry is valid,
if(pSource->dwFlags & MPQ_FILE_EXISTS)
{
// Remember the index conversion
@@ -2920,7 +2920,7 @@ int SaveMPQTables(TMPQArchive * ha)
// We expect this function to be called only when tables have been changed
assert(ha->dwFlags & MPQ_FLAG_CHANGED);
- // Find the space where the MPQ tables will be saved
+ // Find the space where the MPQ tables will be saved
TablePos = FindFreeMpqSpace(ha);
// If the MPQ has HET table, we prepare a ready-to-save version
@@ -3011,7 +3011,7 @@ int SaveMPQTables(TMPQArchive * ha)
pHeader->HiBlockTableSize64 = HiBlockTableSize64;
pHeader->HiBlockTablePos64 = TablePos;
BSWAP_ARRAY16_UNSIGNED(pHiBlockTable, HiBlockTableSize64);
-
+
if(!FileStream_Write(ha->pStream, &ByteOffset, pHiBlockTable, (DWORD)HiBlockTableSize64))
nError = GetLastError();
TablePos += HiBlockTableSize64;
@@ -3034,7 +3034,7 @@ int SaveMPQTables(TMPQArchive * ha)
// Update the size of the archive
pHeader->ArchiveSize64 = TablePos;
pHeader->dwArchiveSize = (DWORD)TablePos;
-
+
// Update the MD5 of the archive header
CalculateDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader);