From: ShadowFlare Date: Sun, 4 Jul 2010 23:01:31 +0000 (-0600) Subject: Merge branch 'master' into large_archive X-Git-Url: https://sfsrealm.hopto.org/projects/gitweb.cgi?a=commitdiff_plain;h=033f7f171bfdddc8a0db52fd03f932792c26f2dd;p=SFmpqapi.git Merge branch 'master' into large_archive Resolved conflicts: SFmpqapi.cpp --- 033f7f171bfdddc8a0db52fd03f932792c26f2dd diff --cc SFmpqapi.cpp index 68ff611,0f5acaf..628d29f --- a/SFmpqapi.cpp +++ b/SFmpqapi.cpp @@@ -1221,9 -1248,9 +1226,9 @@@ BOOL SFMPQAPI WINAPI SFileReadFile(MPQH if (lpOverlapped) lpOverlapped->InternalHigh = 0; return FALSE; } - if ((mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_COMPRESS) || (mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_COMPRESS2)) + if (((mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_COMPRESS) || (mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_COMPRESS2)) && !(mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_SINGLEBLOCK)) { - SFSetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset+HeaderLength,FILE_BEGIN); + SFSetFilePointer(mpqOpenArc->hFile, mpqOpenArc->qwMPQStart + MakeUInt64(mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset, mpqOpenArc->lpFileOffsetsHigh[BlockIndex]) + HeaderLength, FILE_BEGIN); ReadFile(mpqOpenArc->hFile,dwBlockPtrTable,(TotalBlocks+1)*4,&nBytesRead,0); if (mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_ENCRYPT) { DecryptData((LPBYTE)dwBlockPtrTable,(TotalBlocks+1)*4,dwCryptKey-1); @@@ -1248,13 -1278,13 +1256,13 @@@ } DWORD blk=0,blki=0; for (i=blockNum;ihFile,mpqOpenArc->dwMPQStart+mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset+HeaderLength+mpqOpenFile->lpdwBlockOffsets[i],FILE_BEGIN); + SFSetFilePointer(mpqOpenArc->hFile, mpqOpenArc->qwMPQStart + MakeUInt64(mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset, mpqOpenArc->lpFileOffsetsHigh[BlockIndex]) + HeaderLength + mpqOpenFile->lpdwBlockOffsets[i], FILE_BEGIN); blki=i; - if (i+16>nBlocks) { - if (ReadFile(mpqOpenArc->hFile,blk16Buffer,mpqOpenFile->lpdwBlockOffsets[nBlocks]-mpqOpenFile->lpdwBlockOffsets[i],&nBytesRead,0)==0) { - SFFree(compbuffer); - SFFree(blk16Buffer); + if (i+nBufferCount>nBlocks) { + if (ReadFile(mpqOpenArc->hFile,blkLargeBuffer,mpqOpenFile->lpdwBlockOffsets[nBlocks]-mpqOpenFile->lpdwBlockOffsets[i],&nBytesRead,0)==0) { + if (compbuffer) SFFree(compbuffer); + SFFree(blkLargeBuffer); SFFree(blkBuffer); if (lpNumberOfBytesRead) *lpNumberOfBytesRead = TotalBytesRead; if (lpOverlapped) lpOverlapped->InternalHigh = TotalBytesRead; @@@ -1273,7 -1303,20 +1281,20 @@@ } } } - memcpy(blkBuffer,((char *)blk16Buffer)+(mpqOpenFile->lpdwBlockOffsets[blki+blk]-mpqOpenFile->lpdwBlockOffsets[blki]),mpqOpenFile->lpdwBlockOffsets[i+1]-mpqOpenFile->lpdwBlockOffsets[i]); + if (blkLargeBuffer) { + memcpy(blkBuffer,((char *)blkLargeBuffer)+(mpqOpenFile->lpdwBlockOffsets[blki+blk]-mpqOpenFile->lpdwBlockOffsets[blki]),mpqOpenFile->lpdwBlockOffsets[i+1]-mpqOpenFile->lpdwBlockOffsets[i]); + } + else { - SFSetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset+HeaderLength+mpqOpenFile->lpdwBlockOffsets[i],FILE_BEGIN); ++ SFSetFilePointer(mpqOpenArc->hFile, mpqOpenArc->qwMPQStart + MakeUInt64(mpqOpenArc->lpBlockTable[BlockIndex].dwFileOffset, mpqOpenArc->lpFileOffsetsHigh[BlockIndex]) + HeaderLength + mpqOpenFile->lpdwBlockOffsets[i], FILE_BEGIN); + blki=i; + if (ReadFile(mpqOpenArc->hFile,blkBuffer,mpqOpenFile->lpdwBlockOffsets[i+1]-mpqOpenFile->lpdwBlockOffsets[i],&nBytesRead,0)==0) { + if (compbuffer) SFFree(compbuffer); + SFFree(blkBuffer); + if (lpNumberOfBytesRead) *lpNumberOfBytesRead = TotalBytesRead; + if (lpOverlapped) lpOverlapped->InternalHigh = TotalBytesRead; + return FALSE; + } + } if (mpqOpenArc->lpBlockTable[BlockIndex].dwFlags & MAFA_ENCRYPT) { DecryptData((LPBYTE)blkBuffer,mpqOpenFile->lpdwBlockOffsets[i+1]-mpqOpenFile->lpdwBlockOffsets[i],dwCryptKey+i);