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




ShadowFlare [Sun, 23 Aug 2009 08:59:27 +0000 (02:59 -0600)]
- 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.

SComp.h [deleted file]
SFmpqapi.cpp
SFmpqapi.vcproj

diff --git a/SComp.h b/SComp.h
deleted file mode 100644 (file)
index 37a8e93..0000000
--- 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
-
index c9a7322..a5b264f 100644 (file)
@@ -12,7 +12,7 @@
 #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)
                {
index aedff70..04ec697 100644 (file)
                                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"
                                >