diff options
author | unknown <E:\Ladik\Mail> | 2015-05-01 07:06:29 +0200 |
---|---|---|
committer | unknown <E:\Ladik\Mail> | 2015-05-01 07:06:29 +0200 |
commit | 46930855f500c1b494e3b16bb7a3323c07d4d5fb (patch) | |
tree | 6220cc643761137a930841d8ec828db9f3db53cf /src/SFileCompactArchive.cpp | |
parent | a205159d004871efbedd7cbfb686b8fe82bfb532 (diff) |
+ Removed back reference of FileTable -> HashTable, as it is logically incorrect
+ Optimized patching process so it consimes less memory
+ Added hash table and block table defragmenting for malformed War3 maps
Diffstat (limited to 'src/SFileCompactArchive.cpp')
-rw-r--r-- | src/SFileCompactArchive.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/SFileCompactArchive.cpp b/src/SFileCompactArchive.cpp index a70fa0a..2c0ef5a 100644 --- a/src/SFileCompactArchive.cpp +++ b/src/SFileCompactArchive.cpp @@ -598,18 +598,10 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const char * szListFile, bool /* bR if(nError == ERROR_SUCCESS) nError = CopyMpqFiles(ha, pFileKeys, pTempStream); - // We also need to rebuild the HET table, if any - if(nError == ERROR_SUCCESS) - { - // Rebuild the HET table, if we have any - if(ha->pHetTable != NULL) - nError = RebuildHetTable(ha); - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - // If succeeded, switch the streams if(nError == ERROR_SUCCESS) { + ha->dwFlags |= MPQ_FLAG_CHANGED; if(FileStream_Replace(ha->pStream, pTempStream)) pTempStream = NULL; else @@ -619,7 +611,7 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const char * szListFile, bool /* bR // Final user notification if(nError == ERROR_SUCCESS && ha->pfnCompactCB != NULL) { - ha->CompactBytesProcessed += (ha->dwHashTableSize * sizeof(TMPQHash)); + ha->CompactBytesProcessed += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); ha->CompactBytesProcessed += (ha->dwFileTableSize * sizeof(TMPQBlock)); ha->pfnCompactCB(ha->pvCompactUserData, CCB_CLOSING_ARCHIVE, ha->CompactBytesProcessed, ha->CompactTotalBytes); } @@ -658,21 +650,18 @@ bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount) if(dwMaxFileCount < ha->dwFileTableSize) nError = ERROR_DISK_FULL; - // ALL file names must be known in order to be able - // to rebuild hash table - if(nError == ERROR_SUCCESS) + // ALL file names must be known in order to be able to rebuild hash table + if(nError == ERROR_SUCCESS && ha->pHashTable != NULL) { nError = CheckIfAllFilesKnown(ha); - } - - // If the MPQ has a hash table, then we relocate the hash table - if(nError == ERROR_SUCCESS) - { - // Calculate the hash table size for the new file limit - dwNewHashTableSize = GetHashTableSizeForFileCount(dwMaxFileCount); + if(nError == ERROR_SUCCESS) + { + // Calculate the hash table size for the new file limit + dwNewHashTableSize = GetHashTableSizeForFileCount(dwMaxFileCount); - // Rebuild both file tables - nError = RebuildFileTable(ha, dwNewHashTableSize, dwMaxFileCount); + // Rebuild both file tables + nError = RebuildFileTable(ha, dwNewHashTableSize); + } } // We always have to rebuild the (attributes) file due to file table change |