+ Adding files to MPQ no longer removes (listfile) and (attributes) when not enough space in the hash table

+ Fixes in deletion of files from MPQs v 4.0
This commit is contained in:
Ladislav
2013-11-18 12:35:21 +01:00
parent 1f2305cc35
commit 870acd5827
12 changed files with 141 additions and 92 deletions

View File

@@ -843,7 +843,7 @@ TMPQHash * AllocateHashEntry(
// Finds a free space in the MPQ where to store next data
// The free space begins beyond the file that is stored at the fuhrtest
// position in the MPQ.
void FindFreeMpqSpace(TMPQArchive * ha, ULONGLONG * pFreeSpacePos)
ULONGLONG FindFreeMpqSpace(TMPQArchive * ha)
{
TMPQHeader * pHeader = ha->pHeader;
TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize;
@@ -854,8 +854,8 @@ void FindFreeMpqSpace(TMPQArchive * ha, ULONGLONG * pFreeSpacePos)
// Parse the entire block table
for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++)
{
// Only take existing files
if(pFileEntry->dwFlags & MPQ_FILE_EXISTS)
// Only take existing files with nonzero size
if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && (pFileEntry->dwCmpSize != 0))
{
// If the end of the file is bigger than current MPQ table pos, update it
if((pFileEntry->ByteOffset + pFileEntry->dwCmpSize) > FreeSpacePos)
@@ -874,8 +874,7 @@ void FindFreeMpqSpace(TMPQArchive * ha, ULONGLONG * pFreeSpacePos)
}
// Give the free space position to the caller
if(pFreeSpacePos != NULL)
*pFreeSpacePos = FreeSpacePos;
return FreeSpacePos;
}
//-----------------------------------------------------------------------------