diff options
author | Ladislav Zezula <zezula@volny.cz> | 2025-08-25 20:11:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-25 20:11:44 +0200 |
commit | 249b1c0490af45965ac5e75e138b80b8699da665 (patch) | |
tree | b643c0a85f51dac862f08902771d043355313c50 /src/SFileCompactArchive.cpp | |
parent | 519927d280f75b80223986c615f4383a36255b7c (diff) | |
parent | e6e9ad2bc81868d93038b5e5198e31b19cdec265 (diff) |
Thanks for the contribution. I'll run tests against the new code.
Diffstat (limited to 'src/SFileCompactArchive.cpp')
-rw-r--r-- | src/SFileCompactArchive.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/SFileCompactArchive.cpp b/src/SFileCompactArchive.cpp index 8ad1b4b..63a6de2 100644 --- a/src/SFileCompactArchive.cpp +++ b/src/SFileCompactArchive.cpp @@ -463,15 +463,17 @@ DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq) bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
- DWORD dwNewHashTableSize = 0;
DWORD dwErrCode = ERROR_SUCCESS;
+ // Calculate the hash table size for the new file limit
+ DWORD dwNewHashTableSize = GetNearestPowerOfTwo(dwMaxFileCount);
+
// Test the valid parameters
if(!IsValidMpqHandle(hMpq))
dwErrCode = ERROR_INVALID_HANDLE;
if(ha->dwFlags & MPQ_FLAG_READ_ONLY)
dwErrCode = ERROR_ACCESS_DENIED;
- if(dwMaxFileCount < ha->dwFileTableSize)
+ if(dwNewHashTableSize < ha->dwFileTableSize)
dwErrCode = ERROR_DISK_FULL;
// ALL file names must be known in order to be able to rebuild hash table
@@ -480,9 +482,6 @@ bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount) dwErrCode = CheckIfAllFilesKnown(ha);
if(dwErrCode == ERROR_SUCCESS)
{
- // Calculate the hash table size for the new file limit
- dwNewHashTableSize = GetNearestPowerOfTwo(dwMaxFileCount);
-
// Rebuild both file tables
dwErrCode = RebuildFileTable(ha, dwNewHashTableSize);
}
|