aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avg.com>2014-08-26 10:51:32 +0200
committerLadislav Zezula <ladislav.zezula@avg.com>2014-08-26 10:51:32 +0200
commit03380128b59e982fcc52c41d69023075e5cfbca2 (patch)
treecd660ad99a502a8d9726313d8573d5a4f934a236
parent7dbb19b5079f2c8ddec3ec88bc3b0be9ad27e443 (diff)
+ When adding a file in the MPQ, a space used by internal MPQ files is reused
-rw-r--r--src/SBaseCommon.cpp7
-rw-r--r--test/StormTest.cpp4
2 files changed, 8 insertions, 3 deletions
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp
index f363c28..c8d4ba6 100644
--- a/src/SBaseCommon.cpp
+++ b/src/SBaseCommon.cpp
@@ -651,7 +651,8 @@ 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.
+// position in the MPQ. (listfile), (attributes) and (signature) are ignored,
+// unless the MPQ is being flushed.
ULONGLONG FindFreeMpqSpace(TMPQArchive * ha)
{
TMPQHeader * pHeader = ha->pHeader;
@@ -666,6 +667,10 @@ ULONGLONG FindFreeMpqSpace(TMPQArchive * ha)
// Only take existing files with nonzero size
if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && (pFileEntry->dwCmpSize != 0))
{
+ // If we are not saving MPQ tables, ignore internal MPQ files
+ if((ha->dwFlags & MPQ_FLAG_SAVING_TABLES) == 0 && IsInternalMpqFileName(pFileEntry->szFileName))
+ continue;
+
// If the end of the file is bigger than current MPQ table pos, update it
if((pFileEntry->ByteOffset + pFileEntry->dwCmpSize) > FreeSpacePos)
{
diff --git a/test/StormTest.cpp b/test/StormTest.cpp
index dda622d..e0ed8ca 100644
--- a/test/StormTest.cpp
+++ b/test/StormTest.cpp
@@ -3615,7 +3615,7 @@ int main(int argc, char * argv[])
// Open a stream, paired with remote master (takes hell lot of time!)
// if(nError == ERROR_SUCCESS)
// nError = TestReadFile_MasterMirror("MPQ_2013_v4_alternate-downloaded.MPQ", "http://www.zezula.net\\mpqs\\alternate.zip", false);
-*/
+
// Search in listfile
if(nError == ERROR_SUCCESS)
nError = TestSearchListFile("ListFile_Blizzard.txt");
@@ -3805,7 +3805,7 @@ int main(int argc, char * argv[])
// Create an archive and fill it with files up to the max file count
if(nError == ERROR_SUCCESS)
nError = TestCreateArchive_FillArchive("StormLibTest_FileTableFull.mpq", MPQ_CREATE_ATTRIBUTES);
-
+*/
// Create an archive and fill it with files up to the max file count
if(nError == ERROR_SUCCESS)
nError = TestCreateArchive_FillArchive("StormLibTest_FileTableFull.mpq", MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_LISTFILE);