aboutsummaryrefslogtreecommitdiff
path: root/src/SBaseCommon.cpp
diff options
context:
space:
mode:
authorLadislav <Zezula>2013-11-18 12:35:21 +0100
committerLadislav <Zezula>2013-11-18 12:35:21 +0100
commit870acd582701bc67c29b48319972303e5ceb706d (patch)
tree01f5150ff893c17251db52b1163c8a4c0cc596d2 /src/SBaseCommon.cpp
parent1f2305cc35734a8f3198be4ce6145de1710308b5 (diff)
+ Adding files to MPQ no longer removes (listfile) and (attributes) when not enough space in the hash tablev8.99
+ Fixes in deletion of files from MPQs v 4.0
Diffstat (limited to 'src/SBaseCommon.cpp')
-rw-r--r--src/SBaseCommon.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp
index c0bfffb..2e9366f 100644
--- a/src/SBaseCommon.cpp
+++ b/src/SBaseCommon.cpp
@@ -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;
}
//-----------------------------------------------------------------------------