aboutsummaryrefslogtreecommitdiff
path: root/src/SFileCompactArchive.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avg.com>2013-11-13 07:56:31 +0100
committerLadislav Zezula <ladislav.zezula@avg.com>2013-11-13 07:56:31 +0100
commita70863499e5e9e6560477b8f4a0a594d6e62650e (patch)
tree21118705bf1d412ed9aea0b51daf25f98b4fabad /src/SFileCompactArchive.cpp
parent66b71713c2a60e6f6ccc55245b067dad34fd6154 (diff)
+ Support for SQP and MPK archives
+ Makefiles fixed
Diffstat (limited to 'src/SFileCompactArchive.cpp')
-rw-r--r--src/SFileCompactArchive.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/SFileCompactArchive.cpp b/src/SFileCompactArchive.cpp
index 3362a20..a7706d0 100644
--- a/src/SFileCompactArchive.cpp
+++ b/src/SFileCompactArchive.cpp
@@ -539,13 +539,15 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const char * szListFile, bool /* bR
// Write the MPQ header
if(nError == ERROR_SUCCESS)
{
- // Remember the header size before swapping
- DWORD dwBytesToWrite = ha->pHeader->dwHeaderSize;
-
- BSWAP_TMPQHEADER(ha->pHeader);
- if(!FileStream_Write(pTempStream, NULL, ha->pHeader, dwBytesToWrite))
+ TMPQHeader SaveMpqHeader;
+
+ // Write the MPQ header to the file
+ memcpy(&SaveMpqHeader, ha->pHeader, ha->pHeader->dwHeaderSize);
+ BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_1);
+ BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_3);
+ BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_4);
+ if(!FileStream_Write(pTempStream, NULL, &SaveMpqHeader, ha->pHeader->dwHeaderSize))
nError = GetLastError();
- BSWAP_TMPQHEADER(ha->pHeader);
// Update the progress
ha->CompactBytesProcessed += ha->pHeader->dwHeaderSize;
@@ -696,8 +698,7 @@ bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount)
// Create new entry in the hash table
if(ha->pHashTable != NULL)
{
- dwHashIndex = AllocateHashEntry(ha, pFileEntry);
- if(dwHashIndex == HASH_ENTRY_FREE)
+ if(AllocateHashEntry(ha, pFileEntry) == NULL)
{
nError = ERROR_CAN_NOT_COMPLETE;
break;