Current News Archived News Search News Discussion Forum Old Forum Install Programs More Downloads... Troubleshooting Source Code Format Specs. Misc. Information Non-SF Stuff Links Small banner for links to this site: |
- Fixed hash table search for adding/replacing files. It should have finished searching for an existing file before considering free slots.
- Removed extra copy of SComp.h and instead references the one from SComp directly.
diff --git a/SComp.h b/SComp.h
--- a/SComp.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// SComp.h - Header for main compression/decompression routines
-// License information for this code is in license.txt
-
-#ifndef S_COMP_INCLUDED
-#define S_COMP_INCLUDED
-
-#if (defined(_WIN32) || defined(WIN32)) && !defined(NO_WINDOWS_H)
-#include <windows.h>
-#else
-#include "wintypes.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-BOOL WINAPI SCompCompress(LPVOID lpvDestinationMem, LPDWORD lpdwCompressedSize, LPVOID lpvSourceMem, DWORD dwDecompressedSize, DWORD dwCompressionType, DWORD dwCompressionSubType, DWORD dwCompressLevel);
-BOOL WINAPI SCompDecompress(LPVOID lpvDestinationMem, LPDWORD lpdwDecompressedSize, LPVOID lpvSourceMem, DWORD dwCompressedSize);
-
-#ifdef __cplusplus
-}; // extern "C"
-#endif
-
-#endif
-
diff --git a/SFmpqapi.cpp b/SFmpqapi.cpp
--- a/SFmpqapi.cpp
+++ b/SFmpqapi.cpp
#include <shellapi.h>
#endif
-#include "SComp.h"
+#include "../SComp/SComp.h"
#include "SFmpqapi.h"
@@ -3227,12 +3227,19 @@ MPQHANDLE GetFreeHashTableEntry(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID FileLoca
DWORD dwTablePos = HashString(lpFileName,HASH_POSITION) % mpqOpenArc->MpqHeader.dwHashTableSize;
DWORD dwNameHashA = HashString(lpFileName,HASH_NAME_A);
DWORD dwNameHashB = HashString(lpFileName,HASH_NAME_B);
- DWORD i=dwTablePos;
+ DWORD i=dwTablePos, nFirstFree = 0xFFFFFFFF;
do
{
- if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)==0xFFFFFFFE)
+ if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)==0xFFFFFFFE && nFirstFree == 0xFFFFFFFF)
{
- return (MPQHANDLE)&mpqOpenArc->lpHashTable[i];
+ if (mpqOpenArc->lpHashTable[i].dwBlockTableIndex == 0xFFFFFFFF)
+ {
+ if (nFirstFree == 0xFFFFFFFF)
+ return (MPQHANDLE)&mpqOpenArc->lpHashTable[i];
+ else
+ return (MPQHANDLE)&mpqOpenArc->lpHashTable[nFirstFree];
+ }
+ else nFirstFree = i;
}
else if (mpqOpenArc->lpHashTable[i].dwNameHashA==dwNameHashA && mpqOpenArc->lpHashTable[i].dwNameHashB==dwNameHashB && mpqOpenArc->lpHashTable[i].lcLocale==FileLocale)
{
diff --git a/SFmpqapi.vcproj b/SFmpqapi.vcproj
--- a/SFmpqapi.vcproj
+++ b/SFmpqapi.vcproj
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
+ EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Debug/SFmpqapi.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
RelativePath="..\SComp\SComp.h"
>
</File>
- <File
- RelativePath="SComp.h"
- >
- </File>
<File
RelativePath="..\SComp\SErr.h"
>
|