aboutsummaryrefslogtreecommitdiff
path: root/src/SFileListFile.cpp
diff options
context:
space:
mode:
authorunknown <E:\Ladik\Mail>2015-05-01 07:06:29 +0200
committerunknown <E:\Ladik\Mail>2015-05-01 07:06:29 +0200
commit46930855f500c1b494e3b16bb7a3323c07d4d5fb (patch)
tree6220cc643761137a930841d8ec828db9f3db53cf /src/SFileListFile.cpp
parenta205159d004871efbedd7cbfb686b8fe82bfb532 (diff)
+ Removed back reference of FileTable -> HashTable, as it is logically incorrect
+ Optimized patching process so it consimes less memory + Added hash table and block table defragmenting for malformed War3 maps
Diffstat (limited to 'src/SFileListFile.cpp')
-rw-r--r--src/SFileListFile.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/SFileListFile.cpp b/src/SFileListFile.cpp
index 5f8a9df..385098e 100644
--- a/src/SFileListFile.cpp
+++ b/src/SFileListFile.cpp
@@ -389,7 +389,7 @@ static int SListFileCreateNodeForAllLocales(TMPQArchive * ha, const char * szFil
// If we have HET table, use that one
if(ha->pHetTable != NULL)
{
- pFileEntry = GetFileEntryAny(ha, szFileName);
+ pFileEntry = GetFileEntryLocale(ha, szFileName, 0);
if(pFileEntry != NULL)
{
// Allocate file name for the file entry
@@ -402,18 +402,12 @@ static int SListFileCreateNodeForAllLocales(TMPQArchive * ha, const char * szFil
// If we have hash table, we use it
if(ha->pHashTable != NULL)
{
- // Look for the first hash table entry for the file
- pFirstHash = pHash = GetFirstHashEntry(ha, szFileName);
-
// Go while we found something
+ pFirstHash = pHash = GetFirstHashEntry(ha, szFileName);
while(pHash != NULL)
{
- // Is it a valid file table index ?
- if(pHash->dwBlockIndex < ha->dwFileTableSize)
- {
- // Allocate file name for the file entry
- AllocateFileName(ha, ha->pFileTable + pHash->dwBlockIndex, szFileName);
- }
+ // Allocate file name for the file entry
+ AllocateFileName(ha, ha->pFileTable + pHash->dwBlockIndex, szFileName);
// Now find the next language version of the file
pHash = GetNextHashEntry(ha, pFirstHash, pHash);
@@ -437,7 +431,7 @@ int SListFileSaveToMpq(TMPQArchive * ha)
if(ha->dwFileFlags1 != 0)
{
// At this point, we expect to have at least one reserved entry in the file table
- assert(ha->dwFlags & MPQ_FLAG_LISTFILE_INVALID);
+ assert(ha->dwFlags & MPQ_FLAG_LISTFILE_NEW);
assert(ha->dwReservedFiles > 0);
// Create the raw data that is to be written to (listfile)
@@ -470,6 +464,10 @@ int SListFileSaveToMpq(TMPQArchive * ha)
SFileAddFile_Finish(hf);
}
+ // Clear the listfile flags
+ ha->dwFlags &= ~(MPQ_FLAG_LISTFILE_NEW | MPQ_FLAG_LISTFILE_NONE);
+ ha->dwReservedFiles--;
+
// Free the listfile buffer
STORM_FREE(pbListFile);
}
@@ -478,10 +476,6 @@ int SListFileSaveToMpq(TMPQArchive * ha)
// If the (listfile) file would be empty, its OK
nError = (cbListFile == 0) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY;
}
-
- // Clear the listfile flags
- ha->dwFlags &= ~MPQ_FLAG_LISTFILE_INVALID;
- ha->dwReservedFiles--;
}
return nError;