From 65784a4ee915fe9d737ba761acd084639df5b35e Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Mon, 31 Aug 2020 07:36:54 +0200 Subject: Fixed missing hash table in case when HET table exists --- src/SBaseFileTable.cpp | 4 +++- test/StormTest.cpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp index 7f67533..7c9a857 100644 --- a/src/SBaseFileTable.cpp +++ b/src/SBaseFileTable.cpp @@ -2340,7 +2340,9 @@ int LoadAnyHashTable(TMPQArchive * ha) ha->pHetTable = LoadHetTable(ha); // Try to load classic hash table - if(pHeader->dwHashTableSize && ha->pHetTable == NULL) + // Note that we load the classic hash table even when HET table exists, + // because if the MPQ gets modified and saved, hash table must be there + if(pHeader->dwHashTableSize) ha->pHashTable = LoadHashTable(ha); // At least one of the tables must be present diff --git a/test/StormTest.cpp b/test/StormTest.cpp index 6732ed0..979750c 100644 --- a/test/StormTest.cpp +++ b/test/StormTest.cpp @@ -4409,8 +4409,19 @@ int _tmain(int argc, TCHAR * argv[]) printf("==== Test Suite for StormLib version %s ====\n", STORMLIB_VERSION_STRING); nError = InitializeMpqDirectory(argv, argc); + SFILE_FIND_DATA sf; + HANDLE hFind = NULL; HANDLE hMpq = NULL; - SFileOpenArchive(_T("e:\\Multimedia\\MPQs\\2010 - Starcraft II\\25092\\Updates\\enGB\\s2-update-enGB-24540.MPQ"), 0, 0, &hMpq); + if(SFileOpenArchive(_T("e:\\Ladik\\Incoming\\mpq-issue\\SampleB-by861.SC2Map"), 0, MPQ_OPEN_FORCE_LISTFILE, &hMpq)) + { + if((hFind = SFileFindFirstFile(hMpq, "*", &sf, NULL)) != NULL) + { + SFileFindNextFile(hFind, &sf); + SFileFindClose(hFind); + } + + SFileCloseArchive(hMpq); + } // Not a test, but rather a tool for creating links to duplicated files // if(nError == ERROR_SUCCESS) -- cgit v1.2.3