diff options
author | Ladislav Zezula <zezula-at-volny-dot-cz> | 2018-11-08 17:06:12 +0100 |
---|---|---|
committer | Ladislav Zezula <zezula-at-volny-dot-cz> | 2018-11-08 17:06:12 +0100 |
commit | 17d51a8256d1d1dbab5fd7000ee5f4f31b74d338 (patch) | |
tree | 08055be5b9693cc052ae65afec12c2e24d438241 /src/SBaseFileTable.cpp | |
parent | f35d106059accbddaa602b6525f9542746b2c2b7 (diff) |
* New feature: Force add listfile
Diffstat (limited to 'src/SBaseFileTable.cpp')
-rw-r--r-- | src/SBaseFileTable.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp index 700df48..a54f152 100644 --- a/src/SBaseFileTable.cpp +++ b/src/SBaseFileTable.cpp @@ -2069,10 +2069,10 @@ int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf) return ERROR_SUCCESS;
}
-DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew)
+DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew, DWORD dwForceAddTheFile = 0)
{
TMPQFile * hf = NULL;
- DWORD dwFileFlags = 0;
+ DWORD dwFileFlags = MPQ_FILE_DEFAULT_INTERNAL;
int nError = ERROR_FILE_NOT_FOUND;
// Open the file from the MPQ
@@ -2084,17 +2084,25 @@ DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dw // Delete the file entry
nError = DeleteFileEntry(ha, hf);
if(nError == ERROR_SUCCESS)
- {
- ha->dwFlags |= dwFlagNew;
- ha->dwReservedFiles++;
- }
+ dwForceAddTheFile = 1;
- // Free the file entry
+ // Close the file
FreeFileHandle(hf);
}
- // If the deletion failed, set the "none" flag
- ha->dwFlags |= (nError != ERROR_SUCCESS) ? dwFlagNone : 0;
+ // Are we going to add the file?
+ if(dwForceAddTheFile)
+ {
+ ha->dwFlags |= dwFlagNew;
+ ha->dwReservedFiles++;
+ }
+ else
+ {
+ ha->dwFlags |= dwFlagNone;
+ dwFileFlags = 0;
+ }
+
+ // Return the intended file flags
return dwFileFlags;
}
@@ -2112,7 +2120,7 @@ void InvalidateInternalFiles(TMPQArchive * ha) // Invalidate the (listfile), if not done yet
if((ha->dwFlags & (MPQ_FLAG_LISTFILE_NONE | MPQ_FLAG_LISTFILE_NEW)) == 0)
{
- ha->dwFileFlags1 = InvalidateInternalFile(ha, LISTFILE_NAME, MPQ_FLAG_LISTFILE_NONE, MPQ_FLAG_LISTFILE_NEW);
+ ha->dwFileFlags1 = InvalidateInternalFile(ha, LISTFILE_NAME, MPQ_FLAG_LISTFILE_NONE, MPQ_FLAG_LISTFILE_NEW, (ha->dwFlags & MPQ_FLAG_LISTFILE_FORCE));
}
// Invalidate the (attributes), if not done yet
|