From: ShadowFlare Date: Sat, 22 Aug 2009 07:51:17 +0000 (-0600) Subject: Fixed header size bug and enabled some additional optimizations. X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=95d2f3da180aa6c7e67dcd3477cd133e2371e983;p=SFmpqapi.git Fixed header size bug and enabled some additional optimizations. - No longer attempts to write a larger header than this library supports if the archive says it is larger. - Various additional optimizations are now enabled in the Visual C++ 2008 DLL project. --- diff --git a/SFmpqapi.cpp b/SFmpqapi.cpp index 55f9fb8..c9a7322 100644 --- a/SFmpqapi.cpp +++ b/SFmpqapi.cpp @@ -2036,7 +2036,7 @@ BOOL SFMPQAPI WINAPI MpqAddFileToArchiveEx(MPQHANDLE hMPQ, LPCSTR lpSourceFileNa mpqOpenArc->lpBlockTable[BlockIndex].dwFlags = dwFlags|MAFA_EXISTS; DWORD dwFileOffset = mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset; SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart,0,FILE_BEGIN); - WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,mpqOpenArc->MpqHeader.dwHeaderSize,&tsz,0); + WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,sizeof(MPQHEADER),&tsz,0); if (dwFlags & MAFA_ENCRYPT) { DWORD dwCryptKey; if (dwFlags&MAFA_ENCRYPT) dwCryptKey = HashString(lpDestFileName,HASH_KEY); @@ -2381,7 +2381,7 @@ BOOL SFMPQAPI WINAPI MpqAddFileFromBufferEx(MPQHANDLE hMPQ, LPVOID lpBuffer, DWO mpqOpenArc->lpBlockTable[BlockIndex].dwFlags = dwFlags|MAFA_EXISTS; DWORD dwFileOffset = mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset; SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart,0,FILE_BEGIN); - WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,mpqOpenArc->MpqHeader.dwHeaderSize,&tsz,0); + WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,sizeof(MPQHEADER),&tsz,0); if (dwFlags & MAFA_ENCRYPT) { DWORD dwCryptKey; if (dwFlags&MAFA_ENCRYPT) dwCryptKey = HashString(lpFileName,HASH_KEY); @@ -2675,7 +2675,7 @@ BOOL SFMPQAPI WINAPI MpqCompactArchive(MPQHANDLE hMPQ) } if (i==10000) return FALSE; } - DWORD dwLastOffset = mpqOpenArc->MpqHeader.dwHeaderSize,tsz; + DWORD dwLastOffset = sizeof(MPQHEADER),tsz; char *buffer = (char *)SFAlloc(65536); if (buffer==0) { CloseHandle(hFile); @@ -3020,8 +3020,9 @@ BOOL SFMPQAPI WINAPI MpqCompactArchive(MPQHANDLE hMPQ) SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+dwLastOffset,0,FILE_BEGIN); SetEndOfFile(mpqOpenArc->hFile); SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart,0,FILE_BEGIN); + mpqOpenArc->MpqHeader.dwHeaderSize = sizeof(MPQHEADER); WriteFile(mpqOpenArc->hFile,&mpqOpenArc->MpqHeader,sizeof(MPQHEADER),&tsz,0); - dwLastOffset = mpqOpenArc->MpqHeader.dwHeaderSize; + dwLastOffset = sizeof(MPQHEADER); ReadSize = 65536; for (i=dwLastOffset;iMpqHeader.dwHashTableOffset;i+=65536) { SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+i,0,FILE_BEGIN); diff --git a/SFmpqapi.vcproj b/SFmpqapi.vcproj index f2a42f8..aedff70 100644 --- a/SFmpqapi.vcproj +++ b/SFmpqapi.vcproj @@ -4,6 +4,7 @@ Version="9.00" Name="SFmpqapi" ProjectGUID="{D677FDD7-F14A-403F-8D59-C75D1825260C}" + RootNamespace="SFmpqapi" TargetFrameworkVersion="0" > @@ -23,6 +24,7 @@ UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" + WholeProgramOptimization="1" >