aboutsummaryrefslogtreecommitdiff
path: root/src/SFileAddFile.cpp
diff options
context:
space:
mode:
authorLadislav <Zezula>2013-11-18 12:35:21 +0100
committerLadislav <Zezula>2013-11-18 12:35:21 +0100
commit870acd582701bc67c29b48319972303e5ceb706d (patch)
tree01f5150ff893c17251db52b1163c8a4c0cc596d2 /src/SFileAddFile.cpp
parent1f2305cc35734a8f3198be4ce6145de1710308b5 (diff)
+ Adding files to MPQ no longer removes (listfile) and (attributes) when not enough space in the hash tablev8.99
+ Fixes in deletion of files from MPQs v 4.0
Diffstat (limited to 'src/SFileAddFile.cpp')
-rw-r--r--src/SFileAddFile.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/SFileAddFile.cpp b/src/SFileAddFile.cpp
index 59a245a..775a969 100644
--- a/src/SFileAddFile.cpp
+++ b/src/SFileAddFile.cpp
@@ -386,7 +386,7 @@ int SFileAddFile_Init(
if(nError == ERROR_SUCCESS)
{
// Find the position where the file will be stored
- FindFreeMpqSpace(ha, &hf->MpqFilePos);
+ hf->MpqFilePos = FindFreeMpqSpace(ha);
hf->RawFilePos = ha->MpqPos + hf->MpqFilePos;
hf->bIsWriteHandle = true;
@@ -418,15 +418,19 @@ int SFileAddFile_Init(
}
else
{
- // If the file exists and "replace existing" is not set, fail it
- if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0)
- nError = ERROR_ALREADY_EXISTS;
-
- // If the file entry already contains a file
- // and it is a pseudo-name, replace it
- if(nError == ERROR_SUCCESS)
+ // Only if the file really exists
+ if(pFileEntry->dwFlags & MPQ_FILE_EXISTS)
{
- AllocateFileName(pFileEntry, szFileName);
+ // If the file exists and "replace existing" is not set, fail it
+ if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0)
+ nError = ERROR_ALREADY_EXISTS;
+
+ // If the file entry already contains a file
+ // and it is a pseudo-name, replace it
+ if(nError == ERROR_SUCCESS)
+ {
+ AllocateFileName(pFileEntry, szFileName);
+ }
}
}
}