diff options
177 files changed, 5476 insertions, 5436 deletions
diff --git a/contrib/vmap_assembler/vmap_assembler.cpp b/contrib/vmap_assembler/vmap_assembler.cpp index bf720099788..e6a3089f328 100644 --- a/contrib/vmap_assembler/vmap_assembler.cpp +++ b/contrib/vmap_assembler/vmap_assembler.cpp @@ -78,42 +78,44 @@ bool readConfigFile(char *pConffile, VMAP::TileAssembler* pTa) //======================================================= int main(int argc, char* argv[]) { - if(argc == 3 || argc == 4) + if(argc != 3 && argc != 4) { - bool ok = true; - char *src = argv[1]; - char *dest = argv[2]; - char *conffile = NULL; - if(argc >= 4) { - conffile = argv[3]; - } - VMAP::TileAssembler* ta = new VMAP::TileAssembler(std::string(src), std::string(dest)); - ta->setModelNameFilterMethod(modelNameFilter); + printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]); + return 1; + } - /* - All the names in the list are considered to be world maps or huge instances. - These maps will be spilt into tiles in the vmap assemble process - */ - if(conffile != NULL) { - ok = readConfigFile(conffile, ta); - if(!ok) { - printf("Can not open file config file: %s\n", conffile); - } - } - if(ok) { ok = ta->convertWorld(); } - if(ok) { - printf("Ok, all done\n"); - } else { - printf("exit with errors\n"); + char *src = argv[1]; + char *dest = argv[2]; + char *conffile = NULL; + if(argc >= 4) + conffile = argv[3]; + + VMAP::TileAssembler* ta = new VMAP::TileAssembler(std::string(src), std::string(dest)); + ta->setModelNameFilterMethod(modelNameFilter); + + /* + All the names in the list are considered to be world maps or huge instances. + These maps will be spilt into tiles in the vmap assemble process + */ + if(conffile != NULL) + { + if(!readConfigFile(conffile, ta)) + { + printf("Can not open file config file: %s\n", conffile); + delete ta; return 1; } - delete ta; } - else + + if(!ta->convertWorld()) { - printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]); + printf("exit with errors\n"); + delete ta; return 1; } + + delete ta; + printf("Ok, all done\n"); return 0; } diff --git a/contrib/vmap_extract_assembler_bin/vmap_assembler.exe b/contrib/vmap_extract_assembler_bin/vmap_assembler.exe Binary files differindex a6ef74dc086..9c8b5f2d3fb 100644 --- a/contrib/vmap_extract_assembler_bin/vmap_assembler.exe +++ b/contrib/vmap_extract_assembler_bin/vmap_assembler.exe diff --git a/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe b/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe Binary files differindex a1e982f0cba..213705f6cdf 100644 --- a/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe +++ b/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.cpp b/contrib/vmap_extractor_v2/stormdll/StormDll.cpp index c0772e9b2da..2031180c7e3 100644 --- a/contrib/vmap_extractor_v2/stormdll/StormDll.cpp +++ b/contrib/vmap_extractor_v2/stormdll/StormDll.cpp @@ -115,4 +115,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbI SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } - diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.h b/contrib/vmap_extractor_v2/stormdll/StormDll.h index 6be20e59bd7..6d67820a22f 100644 --- a/contrib/vmap_extractor_v2/stormdll/StormDll.h +++ b/contrib/vmap_extractor_v2/stormdll/StormDll.h @@ -65,4 +65,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pb #endif #endif // __STORM_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp b/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp index 7fd3c855f1c..665e5d38e49 100644 --- a/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp +++ b/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp @@ -3,9 +3,9 @@ * Description: GfxDecode -- functions for reading Diablo's GFX files * Author: Marko Friedemann <marko.friedemann@bmx-chemnitz.de> * Created at: Son Jan 27 15:20:43 CET 2002 -* Computer: hangloose.flachland-chemnitz.de +* Computer: hangloose.flachland-chemnitz.de * System: Linux 2.4.16 on i686 -* +* * Copyright (c) 2002 BMX-Chemnitz.DE All rights reserved. * * --------------------------------------------------------------------- @@ -60,12 +60,12 @@ static const uint16_t c_RampOffsetRight[17] = { 2, // __ before this, there are 2 Pixels 14, // + 12 --__ 4^2 - 2 34, // + 20 --__ 6^2 - 2 - 62, // + 28 this area --__ 8^2 - 2 + 62, // + 28 this area --__ 8^2 - 2 98, // + 36 is always --__ 10^2 - 2 pattern anyone? ;) - 142, // + 44 colored --__ + 142, // + 44 colored --__ 194, // + 52 --__ 254, // + 60 lower ramp ends here --__ (-30 == 224) - 318, // + 64 upper ramp might be missing __-- + 318, // + 64 upper ramp might be missing __-- 374, // + 56 __-- | 422, // + 48 this area __-- | note that this 462, // + 40 is always __-- | "drawing" @@ -133,7 +133,7 @@ class FrameBuf cerr << "\n +++ at (" << uCols << "," << uRows << "), see for yourself *** \n\n"; uColorNum = TRANS_COL; // sane setting to avoid segfaults } - + memcpy(pCurrRow + 4*uCols, pPalette + 4*uColorNum, 4*sizeof(uint8_t)); if (++uCols == uXSize) addLine(); @@ -147,18 +147,18 @@ class FrameBuf vector <uint8_t *>::reverse_iterator vri; // allocate a buffer to hold the actual image size uint8_t *tmp = new uint8_t[4*uXSize*uRows]; - + // the lines are upside down inside the vector, use reverse iterator for (i=0, vri=vecData.rbegin(); vri!=vecData.rend(); vri++, i++) memcpy(tmp+4*uXSize*i, *vri, 4*uXSize*sizeof(uint8_t)); - + *upYSize = uRows; // set height - + if (uCols > 0) { cerr << "\n*** there seemed to be an error (last line does not match boundary, " << uCols << " pixels left)"; cerr << "\n +++ this is often caused by specifying an invalid width, see for yourself *** \n\n"; } - + return tmp; } }; @@ -183,17 +183,17 @@ uint8_t *celDecodeBlocks(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framesta if (!pFrame->bHasBlocks) // sanity check return NULL; - + while (uFilePos < framestart[pFrame->uFrameNum+1]) { cRead = pFileBuf[uFilePos++]; - + if ((uFilePos == framestart[pFrame->uFrameNum]+1)) // TODO: what is this 0x0A 0x00 stuff all about? if ((cRead == 0x0A) && (pFileBuf[uFilePos] == 0x00)) { uFilePos += 9; cRead = pFileBuf[uFilePos++]; } - + if (cRead > 0x7F) // transparent block (complement, 256-val) for (i=0; i<256-cRead; i++) @@ -220,10 +220,10 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar uint32_t uFilePos=0; uint16_t uBlockLen=0, i=0, j=0; bool bFirstLonger=false; - + if (!pFrame->bHasRamps) // sanity check return NULL; - + if (pFrame->uXSize != 32) // only used in that case return NULL; @@ -265,7 +265,7 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar pFrame->addPixel(pFileBuf[uFilePos++]); } } - + // now read the last 0x00 pair and fill up uBlockLen = (uFrameLen == c_2RampSize ? 30 : 2); // one or two ramps? uFilePos = framestart[pFrame->uFrameNum] + (bLeft ? c_RampOffsetLeft[i] : c_RampOffsetRight[i]) + 2; @@ -276,16 +276,16 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar for (j=0; j<pFrame->uXSize - uBlockLen; j++) pFrame->addPixel(pFileBuf[uFilePos++]); } - + // now the rest of the file (plain) while (uFilePos < framestart[pFrame->uFrameNum+1]) pFrame->addPixel(pFileBuf[uFilePos++]); - + // the uppermost line is emtpy when 2 ramps are used if (uFrameLen == c_2RampSize) for (j=0; j<pFrame->uXSize; j++) pFrame->addPixel(TRANS_COL); - + return pFrame->getData(); } @@ -308,17 +308,17 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar * Comments: dirty hack, started from scratch @ 2000-10-11 * cleanly rewritten during incorporation into ladiks StormLib * status: structured hack ;) - * + * * It took me approx. 6 days to understand the format basics (hex viewer) * For this I had a little help from a dos tool ("ddecode", from - * www.cowlevel.com, binary only, no sources) which, however, gave + * www.cowlevel.com, binary only, no sources) which, however, gave * me the general idea what the pictures are actually supposed to look like. - * + * * The fine adjustments, however, took quite some time and a little luck. * After I had written to various people (mickyk and ladik), which could * not help me, but wished best luck (thanks, btw, it helped ;)), I tried * some reverse engineering which was not succesful in the end. - * + * * I then had incidentally a new idea of what could be going on @ 2002-01-23. * It just came to my mind that I could retry some actual painting in * reverse order (had done that before to no avail) and when looking closer @@ -334,48 +334,48 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u uint32_t *framestart=NULL, frames=0, uFilePos=0; uint16_t i, tmpWord=0; uint8_t cRead=0, *data; - + memcpy(&frames, pFileBuf, sizeof(uint32_t)); uFilePos += sizeof(uint32_t); - + if (pFileBuf == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (palette == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (uFrameNum > frames-1) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (uYSize == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + // in case we want to know the rightmost pixels column (usable eg. for fonts) if (uMaxX != NULL) *uMaxX = 0; - + // get the frame offsets framestart = new uint32_t[frames+1]; for (i=0; i<frames+1; i++) { memcpy(&framestart[i], pFileBuf+uFilePos, sizeof(uint32_t)); uFilePos += sizeof(uint32_t); } - + /****** block size ************************************************* * depends on the image width ******************************/ - + double erg = rint(sqrt(pow(2, rint(log((double)(framestart[uFrameNum+1] - framestart[uFrameNum])) / log(2.0))))); pFrame = new FrameBuf(palette, uFrameNum, uXSize, uYSize, uMaxX, max((uint16_t)min((int)erg, 0x7F), uXSize)); - + /****** ramp detection -- AFAIK only needed for 32x32 tiles ******** * here I use hard coded constants because this is the only simple * way to get the detection done; plus this stuff is only to be @@ -385,7 +385,7 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u uint32_t uFrameLen = framestart[uFrameNum+1] - framestart[uFrameNum]; if ((uXSize == 32) && ((uFrameLen == c_2RampSize) || (uFrameLen == c_1RampSize))) { - // use the static arrays for the check + // use the static arrays for the check for (i=0; i<(uFrameLen == c_2RampSize ? 16 : 8); i++) { memcpy(&tmpWord, pFileBuf+framestart[uFrameNum]+c_RampOffsetLeft[i], sizeof(uint16_t)); if (tmpWord != 0) @@ -400,7 +400,7 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u } pFrame->bHasRamps = (i==(uFrameLen == c_2RampSize ? 16 : 8)); // bRampsLeft stays false in this case } - + if (pFrame->bHasRamps) { // decode ramps and be off (if appropriate) data = celDecodeRamps(pFileBuf, pFrame, framestart, bRampsLeft); delete pFrame; @@ -408,25 +408,25 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u return data; } } - + /*********** block detection *************************************** * 0x0A as start byte seems to be sufficient (though I still dunno * what the trailing 10 bytes mean); in any other case we act as if * blocks were to be used and check afterwards if the image looks * OK (that is, the last line has no pixels in it) ******************************************************************/ - + cRead = pFileBuf[framestart[uFrameNum]]; if (cRead == 0x0A) // sufficient pFrame->bHasBlocks = true; // if width == 32 && framelen == 32*32, assume plain else if ((uXSize != 32) || (uFrameLen != 32*32)) { // check needed - uFilePos=framestart[uFrameNum]; + uFilePos=framestart[uFrameNum]; i=0; // rush through the frame while (uFilePos < framestart[uFrameNum+1]) { cRead = pFileBuf[uFilePos++]; - + // transparency blocks while (cRead > 0x7F) { i += 256-cRead; @@ -436,7 +436,7 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u else cRead = 0; } - + // colored pixel block if (uFilePos < framestart[uFrameNum+1]) { if (cRead < pFrame->uMaxBlock + 1) { @@ -453,19 +453,19 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u if (i%uXSize == 0) // looks as if we got it right pFrame->bHasBlocks=true; } - + if (pFrame->bHasBlocks) { // use block decoder if appropriate data = celDecodeBlocks(pFileBuf, pFrame, framestart); delete pFrame; delete[] framestart; return data; } - + // plain mode (#3), read each color index and write the pixel uFilePos=framestart[uFrameNum]; while (uFilePos < framestart[uFrameNum+1]) pFrame->addPixel(pFileBuf[uFilePos++]); - + // cleanup, return image data and height data = pFrame->getData(); delete pFrame; @@ -496,7 +496,7 @@ uint16_t WINAPI cl2GetFrameCount(uint8_t *pFileBuf) * * --------------------------------------------------------------- * Comments: dirty hack, started from scratch @ 2000-10-12 - * + * * The format basics are similar to .cel, with the main difference * that the values read have reverse interpretation. In .cel a value * greater than 0x7F means transparency, while in .cl2 this means @@ -507,7 +507,7 @@ uint16_t WINAPI cl2GetFrameCount(uint8_t *pFileBuf) * .cl2 only uses the block scheme, so there is no detection * necessary in order to get it right. The only thing still unknown * is that 0x0A 0x00 stuff... - * + * * TODO: learn what 0x0A 0x00 means ***********************************************************************/ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uDirNum, WORD *uYSize) @@ -516,27 +516,27 @@ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uD uint32_t frames=0, *framestart=NULL, uFilePos=0; uint16_t i, fc; uint8_t cRead=0, **data=NULL; - + if (pFileBuf == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (palette == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (uDirNum > 7) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (uYSize == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + // get direction offsets uint32_t dirstart[8]; for (i=0; i<8; i++) { @@ -545,23 +545,23 @@ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uD } uFilePos = dirstart[uDirNum]; - + memcpy(&frames, pFileBuf+uFilePos, sizeof(uint32_t)); uFilePos += sizeof(uint32_t); - + data = new uint8_t*[frames]; - + // get frame offsets framestart = new uint32_t[frames+1]; for (i=0; i<frames+1; i++) { memcpy(&framestart[i], pFileBuf+uFilePos, sizeof(uint32_t)); uFilePos += sizeof(uint32_t); } - - // get frame data + + // get frame data for (fc=0; fc<frames; fc++) { pFrame = new FrameBuf(palette, 0, uXSize, uYSize, NULL, 0); - + uFilePos = dirstart[uDirNum] + framestart[fc]; while (uFilePos < dirstart[uDirNum] + framestart[fc+1]) { @@ -583,12 +583,12 @@ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uD for (i=0; i < 256-cRead; i++) pFrame->addPixel(pFileBuf[uFilePos++]); } - + // got the frame data, save it data[fc] = pFrame->getData(); delete pFrame; } - + delete[] framestart; return data; } @@ -616,7 +616,7 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD uint16_t i=0; uint8_t *data, *palette; uint8_t uColorNum=0, uCount=0; - + struct pcx_header_t { uint8_t id; uint8_t version; @@ -635,17 +635,17 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD uint16_t colortype; uint8_t pad[58]; } pcxHeader; - + if (pFileBuf == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (uXSize == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + if (uYSize == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; @@ -655,12 +655,12 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD memcpy(&pcxHeader, pFileBuf, sizeof(struct pcx_header_t)); *uXSize = (pcxHeader.x1 - pcxHeader.x0 + 1); *uYSize = (pcxHeader.y1 - pcxHeader.y0 + 1); - + if ((pcxHeader.version != 2) && (pcxHeader.version != 5)) { cerr << "cannot handle pcx v" << pcxHeader.version << "\n"; return NULL; } - + // get palette palette = new uint8_t[256*4]; if (pFileBuf[uFileSize - 768 - 1] != 0x0C) { @@ -672,7 +672,7 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD palette[i*4+3] = 0xFF; } memset(palette+uTransColor*4, 0, 4*sizeof(uint8_t)); // transparent black - + // start right after the header uFilePos = sizeof(struct pcx_header_t); data = new uint8_t[*uXSize * *uYSize * 4]; @@ -684,15 +684,14 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD uColorNum = pFileBuf[uFilePos++]; } else uCount = 1; - + // draw count pixels with color val for (i=0; i<uCount; i++) memcpy(data+(uDataRead++)*4, palette+uColorNum*4, 4*sizeof(uint8_t)); } - + // cleanup delete[] palette; - + return data; } - diff --git a/contrib/vmap_extractor_v2/stormlib/SCommon.cpp b/contrib/vmap_extractor_v2/stormlib/SCommon.cpp index f7e29ab7a24..393310f675d 100644 --- a/contrib/vmap_extractor_v2/stormlib/SCommon.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SCommon.cpp @@ -26,7 +26,7 @@ USHORT wPlatform = 0; // File platform //----------------------------------------------------------------------------- // Compression types -// +// // Data compressions // // Can be combination of MPQ_COMPRESSION_PKWARE, MPQ_COMPRESSION_BZIP2 @@ -261,16 +261,16 @@ DWORD DetectFileSeed2(DWORD * pdwBlock, UINT nDwords, ...) DWORD saveSeed1; DWORD dwTemp; DWORD i, j; - + // We need at least two DWORDS to detect the seed if(nDwords < 0x02 || nDwords > 0x10) return 0; - + va_start(argList, nDwords); for(i = 0; i < nDwords; i++) dwDecrypted[i] = va_arg(argList, DWORD); va_end(argList); - + dwTemp = (*pdwBlock ^ dwDecrypted[0]) - 0xEEEEEEEE; for(i = 0; i < 0x100; i++) // Try all 255 possibilities { @@ -427,7 +427,7 @@ TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName) // If filename is given by index, we have to search all hash entries for the right index. if(dwIndex <= ha->pHeader->dwBlockTableSize) { - // Pass all the hash entries and find the + // Pass all the hash entries and find the for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) { if(pHash->dwBlockIndex == dwIndex) @@ -441,7 +441,7 @@ TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName) dwName1 = DecryptName1(szFileName); dwName2 = DecryptName2(szFileName); pHash = pHash0 = ha->pHashTable + dwIndex; - + // Look for hash index while(pHash->dwBlockIndex != HASH_ENTRY_FREE) { @@ -562,7 +562,7 @@ BOOL IsValidMpqHandle(TMPQArchive * ha) return FALSE; if(ha->pHeader == NULL || IsBadReadPtr(ha->pHeader, sizeof(TMPQHeader))) return FALSE; - + return (ha->pHeader->dwID == ID_MPQ); } @@ -620,7 +620,7 @@ int AddFileToArchive( { if(nFileType == SFILE_TYPE_DATA) nCmpFirst = nCmpNext = nDataCmp; - + if(nFileType == SFILE_TYPE_WAVE) { nCmpNext = uWaveCmpType[dwQuality]; @@ -721,7 +721,7 @@ int AddFileToArchive( // Get pointers to both block entries of the file pBlockEx = ha->pExtBlockTable + pHash->dwBlockIndex; pBlock = ha->pBlockTable + pHash->dwBlockIndex; - + // Save the file size info pBlockEx->wFilePosHigh = (USHORT)RelativePos.HighPart; pBlock->dwFilePos = RelativePos.LowPart; @@ -735,7 +735,7 @@ int AddFileToArchive( if(dwFlags & MPQ_FILE_ENCRYPTED) { dwSeed1 = DecryptFileSeed(szArchivedName); - + if(dwFlags & MPQ_FILE_FIXSEED) dwSeed1 = (dwSeed1 + pBlock->dwFilePos) ^ pBlock->dwFSize; } @@ -785,7 +785,7 @@ int AddFileToArchive( memset(pdwBlockPos, 0, dwBlockPosLen); pdwBlockPos[0] = dwBlockPosLen; - + // Write the block positions BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); @@ -852,7 +852,7 @@ int AddFileToArchive( EncryptMPQBlock((DWORD *)pbToWrite, dwOutLength, dwSeed1 + nBlock); BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); } - + // Write the block WriteFile(ha->hFile, pbToWrite, dwOutLength, &dwTransferred, NULL); if(dwTransferred != dwOutLength) @@ -876,10 +876,10 @@ int AddFileToArchive( // If file is encrypted, block positions are also encrypted if(dwFlags & MPQ_FILE_ENCRYPTED) EncryptMPQBlock(pdwBlockPos, dwBlockPosLen, dwSeed1 - 1); - + // Set the position back to the block table SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - + // Write block positions to the archive BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); @@ -1015,7 +1015,7 @@ int SaveMPQTables(TMPQArchive * ha) // Encrypt the block table and write it to the file EncryptBlockTable((DWORD *)pbBuffer, (BYTE *)"(block table)", dwBytes >> 2); - + // Convert to little endian for file save BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); @@ -1072,4 +1072,3 @@ void FreeMPQArchive(TMPQArchive *& ha) ha = NULL; } } - diff --git a/contrib/vmap_extractor_v2/stormlib/SCommon.h b/contrib/vmap_extractor_v2/stormlib/SCommon.h index b038c7f04dd..b53be0ae2a8 100644 --- a/contrib/vmap_extractor_v2/stormlib/SCommon.h +++ b/contrib/vmap_extractor_v2/stormlib/SCommon.h @@ -86,4 +86,3 @@ int SListFileSaveToMpq(TMPQArchive * ha); #endif // __SCOMMON_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/SCompression.cpp b/contrib/vmap_extractor_v2/stormlib/SCompression.cpp index 7162cd04f50..612ef2cc262 100644 --- a/contrib/vmap_extractor_v2/stormlib/SCompression.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SCompression.cpp @@ -2,7 +2,7 @@ /* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */ /*---------------------------------------------------------------------------*/ /* This module serves as a bridge between StormLib code and (de)compression */ -/* functions. All (de)compression calls go (and should only go) through this */ +/* functions. All (de)compression calls go (and should only go) through this */ /* module. No system headers should be included in this module to prevent */ /* compile-time problems. */ /*---------------------------------------------------------------------------*/ @@ -19,7 +19,7 @@ #include <string.h> // Include functions from Pkware Data Compression Library -#include "pklib/pklib.h" +#include "pklib/pklib.h" // Include functions from zlib #ifndef __SYS_ZLIB @@ -29,10 +29,10 @@ #endif // Include functions from Huffmann compression -#include "huffman/huff.h" +#include "huffman/huff.h" // Include functions from WAVe compression -#include "wave/wave.h" +#include "wave/wave.h" // Include functions from BZip2 compression library #ifndef __SYS_BZLIB @@ -57,7 +57,7 @@ typedef struct // Table of compression functions typedef int (*COMPRESS)(char *, int *, char *, int, int *, int); -typedef struct +typedef struct { unsigned long dwMask; // Compression mask COMPRESS Compress; // Compression function @@ -81,7 +81,7 @@ typedef struct // Function loads data from the input buffer. Used by Pklib's "implode" // and "explode" function as user-defined callback // Returns number of bytes loaded -// +// // char * buf - Pointer to a buffer where to store loaded data // unsigned int * size - Max. number of bytes to read // void * param - Custom pointer, parameter of implode/explode @@ -95,7 +95,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) // Check the case when not enough data available if(nToRead > nMaxAvail) nToRead = nMaxAvail; - + // Load data and increment offsets memcpy(buf, pInfo->pInBuff + pInfo->nInPos, nToRead); pInfo->nInPos += nToRead; @@ -105,7 +105,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) // Function for store output data. Used by Pklib's "implode" and "explode" // as user-defined callback -// +// // char * buf - Pointer to data to be written // unsigned int * size - Number of bytes to write // void * param - Custom pointer, parameter of implode/explode @@ -272,7 +272,7 @@ int Compress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int { // Call zlib to compress the data nResult = deflate(&z, Z_FINISH); - + if(nResult == Z_OK || nResult == Z_STREAM_END) *pdwOutLength = z.total_out; @@ -359,7 +359,7 @@ int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, // Do the decompression explode(ReadInputData, WriteOutputData, work_buf, &Info); - + // Fix: If PKLIB is unable to decompress the data, they are uncompressed if(Info.nOutPos == 0) { @@ -487,7 +487,7 @@ int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncom int dwInSize = dwInLength; int dwEntries = (sizeof(cmp_table) / sizeof(TCompressTable)); int nResult = 1; - int i; + int i; // Check for valid parameters if(!pdwOutLength || *pdwOutLength < dwInLength || !pbCompressed || !pbUncompressed) @@ -523,7 +523,7 @@ int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncom { if(uCompressions2 & cmp_table[i].dwMask) { - // Set the right output buffer + // Set the right output buffer dwCompressCount--; pbOutput = (dwCompressCount & 1) ? pbTempBuff : pbCompressed; @@ -611,7 +611,7 @@ int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBu int dwCount = 0; // Counter for every use int dwEntries = (sizeof(dcmp_table) / sizeof(TDecompressTable)); int nResult = 1; - int i; + int i; // If the input length is the same as output, do nothing. if(dwInLength == dwOutLength) @@ -623,11 +623,11 @@ int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBu *pdwOutLength = dwInLength; return 1; } - + // Get applied compression types and decrement data length - fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++; + fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++; dwInLength--; - + // Search decompression table type and get all types of compression for(i = 0; i < dwEntries; i++) { @@ -681,13 +681,13 @@ int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBu { if(pbWorkBuff != pbOutBuffer) memcpy(pbOutBuffer, pbInBuffer, dwOutLength); - + } // Delete temporary buffer, if necessary if(pbTempBuff != NULL) FREEMEM(pbTempBuff); - + *pdwOutLength = dwOutLength; return nResult; } @@ -713,4 +713,3 @@ int WINAPI SCompSetDataCompression(int nDataCompression) } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp b/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp index b5a8530f61e..9510b15ae1f 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp @@ -143,7 +143,7 @@ static int CheckIfAllFilesKnown(TMPQArchive * ha, const char * szListFile, DWORD SFileCloseFile(hFile); } - // If the file is encrypted, we have to check + // If the file is encrypted, we have to check // If we can apply the file decryption seed if(dwFlags & MPQ_FILE_ENCRYPTED && dwSeed == 0) { @@ -269,7 +269,7 @@ static int CopyMpqFileBlocks( DecryptMPQBlock(pdwBlockPos, dwBytes, dwSeed1 - 1); if(pdwBlockPos[0] != dwBytes) nError = ERROR_FILE_CORRUPT; - + memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); EncryptMPQBlock(pdwBlockPos2, dwBytes, dwSeed2 - 1); } @@ -315,7 +315,7 @@ static int CopyMpqFileBlocks( } // If necessary, re-encrypt the block - // Note: Recompression is not necessary here. Unlike encryption, + // Note: Recompression is not necessary here. Unlike encryption, // the compression does not depend on the position of the file in MPQ. if((pBlock->dwFlags & MPQ_FILE_ENCRYPTED) && dwSeed1 != dwSeed2) { @@ -583,7 +583,7 @@ BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bR TempPos.LowPart = pBlock->dwFilePos; if(TempPos.QuadPart < FirstFilePos.QuadPart) FirstFilePos = TempPos; - + pBlockEx++; pBlock++; } @@ -689,4 +689,3 @@ BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bR CompactCB = NULL; return (nError == ERROR_SUCCESS); } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp b/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp index 58f33e459ca..2410920fc93 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp @@ -20,7 +20,7 @@ //----------------------------------------------------------------------------- // Local tables -static DWORD PowersOfTwo[] = +static DWORD PowersOfTwo[] = { 0x0000002, 0x0000004, 0x0000008, 0x0000010, 0x0000020, 0x0000040, 0x0000080, @@ -52,7 +52,7 @@ static DWORD PowersOfTwo[] = // // MPQ_CREATE_ARCHIVE_V1 - Creates MPQ archive version 1 // MPQ_CREATE_ARCHIVE_V2 - Creates MPQ archive version 2 -// +// // dwHashTableSize - Size of the hash table (only if creating a new archive). // Must be between 2^4 (= 16) and 2^18 (= 262 144) // @@ -118,7 +118,7 @@ BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposi dwHashTableSize = HASH_TABLE_SIZE_MIN; if(dwHashTableSize > HASH_TABLE_SIZE_MAX) dwHashTableSize = HASH_TABLE_SIZE_MAX; - + // Round the hash table size up to the nearest power of two for(nIndex = 0; PowersOfTwo[nIndex] != 0; nIndex++) { @@ -249,7 +249,7 @@ BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposi BSWAP_TMPQHEADER(ha->pHeader); WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwTransferred, NULL); BSWAP_TMPQHEADER(ha->pHeader); - + if(dwTransferred != ha->pHeader->dwHeaderSize) nError = ERROR_DISK_FULL; @@ -273,7 +273,7 @@ BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposi CloseHandle(hFile); SetLastError(nError); } - + // Return the values *phMPQ = (HANDLE)ha; return (nError == ERROR_SUCCESS); @@ -355,7 +355,7 @@ BOOL WINAPI SFileAddFileEx(HANDLE hMPQ, const char * szFileName, const char * sz SetLastError(nError); return (nError == ERROR_SUCCESS); } - + // Adds a data file into the archive // TODO: Test for archives > 4GB BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags) @@ -375,7 +375,7 @@ BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szAr // // This function removes a file from the archive. The file content // remains there, only the entries in the hash table and in the block -// table are updated. +// table are updated. // TODO: Test for archives > 4GB BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope) @@ -528,4 +528,3 @@ BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szFileName, const char * s return (nError == ERROR_SUCCESS); } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp index d6afc19426b..7f16cde0171 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp @@ -61,4 +61,3 @@ BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * SetLastError(nError); return (BOOL)(nError == ERROR_SUCCESS); } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp index ff8ab2688fd..41dbeba900c 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp @@ -67,7 +67,7 @@ BOOL CheckWildCard(const char * szString, const char * szWildCard) // The next N characters must not agree nMustNotMatch |= 0x70000000; break; - + case '?': // Means "One or no character" while(*szWildCard == '?') { @@ -111,7 +111,7 @@ BOOL CheckWildCard(const char * szString, const char * szWildCard) { if((nResult = _strnicmp(szString, szWildCard, nMustMatch)) == 0) break; - + szString++; nMustNotMatch--; } @@ -207,7 +207,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DA { if(!IsValidMpqHandle(ha)) nError = ERROR_INVALID_PARAMETER; - + if(szMask == NULL || lpFindFileData == NULL) nError = ERROR_INVALID_PARAMETER; @@ -245,7 +245,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DA FreeMPQSearch(hs); SetLastError(nError); } - + // Return the result value return (HANDLE)hs; } @@ -289,4 +289,3 @@ BOOL WINAPI SFileFindClose(HANDLE hFind) FreeMPQSearch(hs); return TRUE; } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp b/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp index b4a84e2d6ab..cadb4e023a2 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp @@ -74,7 +74,7 @@ static int RelocateMpqTablePositions(TMPQArchive * ha) TempSize.QuadPart = ha->ExtBlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); if(TempSize.QuadPart > ha->MpqSize.QuadPart) ha->MpqSize = TempSize; - + // MPQ size does not include the bytes before MPQ header ha->MpqSize.QuadPart -= ha->MpqPos.QuadPart; return ERROR_SUCCESS; @@ -122,7 +122,7 @@ BOOL SFileOpenArchiveEx( DWORD dwBlockTableSize = 0; // Block table size. DWORD dwTransferred; // Number of bytes read DWORD dwBytes = 0; // Number of bytes to read - int nError = ERROR_SUCCESS; + int nError = ERROR_SUCCESS; // Check the right parameters if(nError == ERROR_SUCCESS) @@ -142,7 +142,7 @@ BOOL SFileOpenArchiveEx( if(hFile == INVALID_HANDLE_VALUE) nError = GetLastError(); } - + // Allocate the MPQhandle if(nError == ERROR_SUCCESS) { @@ -241,7 +241,7 @@ BOOL SFileOpenArchiveEx( break; } - // If a MPQ shunt already has been found, + // If a MPQ shunt already has been found, // and no MPQ header was at potision pointed by the shunt, // then the archive is corrupt if(ha->pShunt != NULL) @@ -327,7 +327,7 @@ BOOL SFileOpenArchiveEx( nError = ERROR_BAD_FORMAT; break; } - + // Remember the highest block table entry if(pHash->dwBlockIndex > dwMaxBlockIndex) dwMaxBlockIndex = pHash->dwBlockIndex; @@ -437,7 +437,7 @@ BOOL SFileOpenArchiveEx( } } - // If the user didn't specified otherwise, + // If the user didn't specified otherwise, // include the internal listfile to the TMPQArchive structure if((dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) { @@ -479,7 +479,7 @@ BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwF BOOL WINAPI SFileCloseArchive(HANDLE hMPQ) { TMPQArchive * ha = (TMPQArchive *)hMPQ; - + if(!IsValidMpqHandle(ha)) { SetLastError(ERROR_INVALID_PARAMETER); @@ -495,4 +495,3 @@ BOOL WINAPI SFileCloseArchive(HANDLE hMPQ) return TRUE; } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp b/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp index aae55cc6899..dae312144eb 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp @@ -25,7 +25,7 @@ static BOOL OpenLocalFile(const char * szFileName, HANDLE * phFile) if(hFile != INVALID_HANDLE_VALUE) { // Allocate and initialize file handle - size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName); + size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName); if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) != NULL) { memset(hf, 0, nHandleSize); @@ -62,7 +62,7 @@ static void FreeMPQFile(TMPQFile *& hf) /*****************************************************************************/ //----------------------------------------------------------------------------- -// SFileEnumLocales enums all locale versions within MPQ. +// SFileEnumLocales enums all locale versions within MPQ. // Functions fills all available language identifiers on a file into the buffer // pointed by plcLocales. There must be enough entries to copy the localed, // otherwise the function returns ERROR_INSUFFICIENT_BUFFER. @@ -220,7 +220,7 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch size_t nHandleSize = 0; // Memory space necessary to allocate TMPQHandle int nError = ERROR_SUCCESS; -#ifdef _DEBUG +#ifdef _DEBUG // Due to increasing numbers of files in MPQs, I had to change the behavior // of opening by file index. Now, the SFILE_OPEN_BY_INDEX value of dwSearchScope // must be entered. This check will allow to find code places that are incompatible @@ -321,13 +321,13 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch hf->pBlock = pBlock; hf->nBlocks = (hf->pBlock->dwFSize + ha->dwBlockSize - 1) / ha->dwBlockSize; hf->pHash = pHash; - + hf->MpqFilePos.HighPart = pBlockEx->wFilePosHigh; hf->MpqFilePos.LowPart = pBlock->dwFilePos; hf->MpqFilePos.QuadPart += ha->MpqPos.QuadPart; hf->dwHashIndex = dwHashIndex; - hf->dwFileIndex = dwBlockIndex; + hf->dwFileIndex = dwBlockIndex; // Allocate buffers for decompression. if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) @@ -337,11 +337,11 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch // As for newer MPQs, there may be one additional entry in the block table // (if the MPQ_FILE_HAS_EXTRA flag is set). // Allocate the buffer to include this DWORD as well - + if((hf->pdwBlockPos = ALLOCMEM(DWORD, hf->nBlocks + 2)) == NULL) nError = ERROR_NOT_ENOUGH_MEMORY; } - + // Decrypt file seed. Cannot be used if the file is given by index if(dwSearchScope != SFILE_OPEN_BY_INDEX) { @@ -386,7 +386,7 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch BOOL WINAPI SFileCloseFile(HANDLE hFile) { TMPQFile * hf = (TMPQFile *)hFile; - + if(!IsValidFileHandle(hf)) { SetLastError(ERROR_INVALID_PARAMETER); @@ -401,4 +401,3 @@ BOOL WINAPI SFileCloseFile(HANDLE hFile) FreeMPQFile(hf); return TRUE; } - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp index 288d63e9049..27fd1e0f085 100644 --- a/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp @@ -154,8 +154,8 @@ static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer } } - // Set file pointer, if necessary - if(ha->FilePointer.QuadPart != FilePos.QuadPart) + // Set file pointer, if necessary + if(ha->FilePointer.QuadPart != FilePos.QuadPart) { SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); } @@ -245,7 +245,7 @@ static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer // TODO: Test for archives > 4GB static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) { - TMPQArchive * ha = hf->ha; + TMPQArchive * ha = hf->ha; DWORD dwBytesRead = 0; if(ha->FilePointer.QuadPart != hf->MpqFilePos.QuadPart) @@ -311,7 +311,7 @@ static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE * // TODO: Test for archives > 4GB static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) { - TMPQArchive * ha = hf->ha; + TMPQArchive * ha = hf->ha; TMPQBlock * pBlock = hf->pBlock; // Pointer to file block DWORD dwBytesRead = 0; // Number of bytes read from the file DWORD dwBlockPos; // Position in the file aligned to the whole blocks @@ -359,7 +359,7 @@ static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, // Copy data from block buffer into target buffer memcpy(pbBuffer, ha->pbBlockBuffer + ha->dwBuffPos, dwToCopy); - + // Update pointers dwToRead -= dwToCopy; dwBytesRead += dwToCopy; @@ -374,7 +374,7 @@ static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, // Load the whole ("middle") blocks only if there are more or equal one block if(dwToRead > ha->dwBlockSize) - { + { DWORD dwBlockBytes = dwToRead & ~(ha->dwBlockSize - 1); dwLoaded = ReadMPQBlocks(hf, dwBlockPos, pbBuffer, dwBlockBytes); @@ -419,7 +419,7 @@ static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, dwBytesRead += dwToCopy; ha->dwBuffPos = dwToCopy; } - + // Return what we've read return dwBytesRead; } @@ -456,7 +456,7 @@ BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * SetLastError(ERROR_HANDLE_EOF); return FALSE; } - + if(pdwRead != NULL) *pdwRead = dwTransferred; return TRUE; @@ -498,7 +498,7 @@ BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh) { TMPQFile * hf = (TMPQFile *)hFile; - + if(pdwFilePosHigh != NULL) *pdwFilePosHigh = 0; @@ -525,7 +525,7 @@ DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh) DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh) { TMPQFile * hf = (TMPQFile *)hFile; - + if(pdwFileSizeHigh != NULL) *pdwFileSizeHigh = 0; @@ -604,7 +604,7 @@ DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosH //----------------------------------------------------------------------------- // Tries to retrieve the file name -static TID2Ext id2ext[] = +static TID2Ext id2ext[] = { {0x1A51504D, "mpq"}, // MPQ archive header ID ('MPQ\x1A') {0x46464952, "wav"}, // WAVE header 'RIFF' @@ -623,7 +623,7 @@ static TID2Ext id2ext[] = {0x3032444D, "m2"}, // WoW ??? .m2 {0x43424457, "dbc"}, // ??? .dbc {0x47585053, "bls"}, // WoW pixel shaders - {0, NULL} // Terminator + {0, NULL} // Terminator }; // TODO: Test for archives > 4GB @@ -646,7 +646,7 @@ BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) if(hf == NULL || szFileName == NULL) nError = ERROR_INVALID_PARAMETER; } - + // If the file name is already filled, return it. if(nError == ERROR_SUCCESS && *hf->szFileName != 0) { @@ -665,7 +665,7 @@ BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) if(nError == ERROR_SUCCESS) { dwFirstBytes[0] = dwFirstBytes[1] = 0; - dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT); + dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT); if(!SFileReadFile(hFile, &dwFirstBytes, sizeof(dwFirstBytes), NULL)) nError = GetLastError(); BSWAP_ARRAY32_UNSIGNED(dwFirstBytes, sizeof(dwFirstBytes) / sizeof(DWORD)); @@ -824,4 +824,3 @@ DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType) SetLastError(ERROR_INVALID_PARAMETER); return 0xFFFFFFFF; } - diff --git a/contrib/vmap_extractor_v2/stormlib/SListFile.cpp b/contrib/vmap_extractor_v2/stormlib/SListFile.cpp index 385e6e8ac40..c3723d17dcd 100644 --- a/contrib/vmap_extractor_v2/stormlib/SListFile.cpp +++ b/contrib/vmap_extractor_v2/stormlib/SListFile.cpp @@ -71,7 +71,7 @@ static size_t ReadLine(TListFileCache * pCache, char * szLine, int nMaxChars) { char * szLineBegin = szLine; char * szLineEnd = szLine + nMaxChars - 1; - + __BeginLoading: // Skip newlines, spaces, tabs and another non-printable stuff @@ -156,7 +156,7 @@ int SListFileAddNode(TMPQArchive * ha, const char * szFileName) dwName2 = pHash->dwName2; if((DWORD_PTR)ha->pListFile[dwHashIndex] <= LISTFILE_ENTRY_DELETED) return ERROR_SUCCESS; - + // Create the listfile node and insert it into the listfile table nLength = strlen(szFileName); pNode = (TFileNode *)ALLOCMEM(char, sizeof(TFileNode) + nLength); @@ -310,8 +310,8 @@ int SListFileSaveToMpq(TMPQArchive * ha) szBuffer[nLength + 0] = 0x0D; szBuffer[nLength + 1] = 0x0A; WriteFile(hFile, szBuffer, (DWORD)(nLength + 2), &dwTransferred, NULL); - } - + } + // Add the listfile into the archive. SFileSetLocale(LANG_NEUTRAL); nError = AddFileToArchive(ha, hFile, LISTFILE_NAME, MPQ_FILE_COMPRESS_PKWARE | MPQ_FILE_ENCRYPTED | MPQ_FILE_REPLACEEXISTING, 0, SFILE_TYPE_DATA, NULL); @@ -329,7 +329,7 @@ int SListFileSaveToMpq(TMPQArchive * ha) // File functions // Adds a listfile into the MPQ archive. -// Note that the function does not remove the +// Note that the function does not remove the // TODO: Test for archives > 4GB int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile) { @@ -359,7 +359,7 @@ int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile) if(nError == ERROR_SUCCESS) { - dwCacheSize = + dwCacheSize = dwFileSize = SFileGetFileSize(hListFile, NULL); // Try to allocate memory for the complete file. If it fails, @@ -443,7 +443,7 @@ HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * if(nError == ERROR_SUCCESS) { - dwCacheSize = + dwCacheSize = dwFileSize = SFileGetFileSize(hListFile, NULL); // Try to allocate memory for the complete file. If it fails, @@ -493,7 +493,7 @@ HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * // If some mask entered, check it if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) - break; + break; } } @@ -559,4 +559,3 @@ BOOL SListFileFindClose(HANDLE hFind) return FALSE; } - diff --git a/contrib/vmap_extractor_v2/stormlib/StormDll.h b/contrib/vmap_extractor_v2/stormlib/StormDll.h index 6be20e59bd7..6d67820a22f 100644 --- a/contrib/vmap_extractor_v2/stormlib/StormDll.h +++ b/contrib/vmap_extractor_v2/stormlib/StormDll.h @@ -65,4 +65,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pb #endif #endif // __STORM_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/StormLib.h b/contrib/vmap_extractor_v2/stormlib/StormLib.h index e3b9381b9f1..eeb8daa6468 100644 --- a/contrib/vmap_extractor_v2/stormlib/StormLib.h +++ b/contrib/vmap_extractor_v2/stormlib/StormLib.h @@ -55,7 +55,7 @@ // // The library type is encoded in the library name as the following // StormLibXYZ.lib -// +// // X - D for Debug version, R for Release version // Y - A for ANSI version, U for Unicode version (Unicode version does not exist yet) // Z - S for static C library, D for multithreaded DLL C-library @@ -63,15 +63,15 @@ #if defined(_MSC_VER) && !defined (__STORMLIB_SELF__) #ifdef _DEBUG // DEBUG VERSIONS - #ifdef _DLL + #ifdef _DLL #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi Dynamic version - #else + #else #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi Static version #endif #else // RELEASE VERSIONS #ifdef _DLL #pragma comment(lib, "StormLibRAD.lib") // Release Ansi Dynamic version - #else + #else #pragma comment(lib, "StormLibRAS.lib") // Release Ansi Static version #endif #endif @@ -109,7 +109,7 @@ #define MPQ_FILE_COMPRESS_PKWARE 0x00000100 // Compression made by PKWARE Data Compression Library #define MPQ_FILE_COMPRESS_MULTI 0x00000200 // Multiple compressions #define MPQ_FILE_COMPRESSED 0x0000FF00 // File is compressed -#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted +#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted #define MPQ_FILE_FIXSEED 0x00020000 // File decrypt seed has to be fixed #define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) #define MPQ_FILE_DUMMY_FILE 0x02000000 // The file is only 1 byte long and its name is a hash @@ -132,8 +132,8 @@ #define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression #define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression #define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression -#define MPQ_COMPRESSION_WAVE_MONO 0x40 // -#define MPQ_COMPRESSION_WAVE_STEREO 0x80 // +#define MPQ_COMPRESSION_WAVE_MONO 0x40 // +#define MPQ_COMPRESSION_WAVE_STEREO 0x80 // // Constants for SFileAddWave @@ -168,7 +168,7 @@ #define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used #define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) #define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used - + #define LISTFILE_NAME "(listfile)" // Name of internal listfile #define SIGNATURE_NAME "(signature)" // Name of internal signature #define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file @@ -213,10 +213,10 @@ struct TMPQShunt struct TMPQHeader { // The ID_MPQ ('MPQ\x1A') signature - DWORD dwID; + DWORD dwID; // Size of the archive header - DWORD dwHeaderSize; + DWORD dwHeaderSize; // Size of MPQ archive // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive @@ -235,14 +235,14 @@ struct TMPQHeader // Offset to the beginning of the hash table, relative to the beginning of the archive. DWORD dwHashTablePos; - + // Offset to the beginning of the block table, relative to the beginning of the archive. DWORD dwBlockTablePos; - + // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. DWORD dwHashTableSize; - + // Number of entries in the block table DWORD dwBlockTableSize; }; @@ -267,7 +267,7 @@ struct TMPQHash { // The hash of the file path, using method A. DWORD dwName1; - + // The hash of the file path, using method B. DWORD dwName2; @@ -303,16 +303,16 @@ struct TMPQBlock { // Offset of the beginning of the block, relative to the beginning of the archive. DWORD dwFilePos; - + // Compressed file size DWORD dwCSize; - + // Only valid if the block is a file; otherwise meaningless, and should be 0. // If the file is compressed, this is the size of the uncompressed file data. - DWORD dwFSize; - + DWORD dwFSize; + // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; + DWORD dwFlags; }; @@ -333,7 +333,7 @@ struct TFileNode // There can be more files that have the same name. // (e.g. multiple language files). We don't want to // have an entry for each of them, so the entries will be referenced. - // When a number of node references reaches zero, + // When a number of node references reaches zero, // the node will be deleted size_t nLength; // File name length @@ -372,7 +372,7 @@ struct TMPQArchive TMPQHash * pHashTable; // Hash table TMPQBlock * pBlockTable; // Block table TMPQBlockEx * pExtBlockTable; // Extended block table - + TMPQShunt Shunt; // MPQ shunt. Valid only when ID_MPQ_SHUNT has been found TMPQHeader2 Header; // MPQ header @@ -520,8 +520,8 @@ int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile); // Archive creating and editing BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ); -BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags); -BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); +BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags); +BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szOldFileName, const char * szNewFileName); BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); @@ -577,4 +577,3 @@ BYTE ** WINAPI cl2GetDirData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT BYTE * WINAPI pcxGetData(BYTE *filebuf, DWORD filesize, BYTE transcol, USHORT *xsize, USHORT *ysize); #endif // __STORMLIB_H_ - diff --git a/contrib/vmap_extractor_v2/stormlib/StormPort.h b/contrib/vmap_extractor_v2/stormlib/StormPort.h index eb8b1e6d0d0..4cb8d84bd57 100644 --- a/contrib/vmap_extractor_v2/stormlib/StormPort.h +++ b/contrib/vmap_extractor_v2/stormlib/StormPort.h @@ -20,7 +20,7 @@ /* 12.11.03 1.02 Dan Macintosh compatibility */ /* 24.07.04 1.03 Sam Mac OS X compatibility */ /* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ -/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ +/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ /*****************************************************************************/ #ifndef __STORMPORT_H__ @@ -35,9 +35,9 @@ #define _CRT_NON_CONFORMING_SWPRINTFS #endif - #include <assert.h> - #include <stdio.h> - #include <windows.h> + #include <assert.h> + #include <stdio.h> + #include <windows.h> #define PLATFORM_LITTLE_ENDIAN 1 #ifdef WIN64 @@ -50,20 +50,20 @@ #endif -// Defines for Mac Carbon +// Defines for Mac Carbon #if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac Carbon API // Macintosh using Carbon #include <Carbon/Carbon.h> // Mac OS X #define _stricmp strcasecmp // Case insensitive strcmp has a different name on this platform. #define _strnicmp strncasecmp - + typedef void * LPCSTR; typedef unsigned long * LPDWORD; typedef long * PLONG; typedef void * LPVOID; typedef unsigned int UINT; - + #define PKEXPORT #define __SYS_ZLIB #define __SYS_BZLIB @@ -120,17 +120,17 @@ typedef void * LPOVERLAPPED; // Unsupported on Linux typedef char TCHAR; typedef unsigned long LCID; - + typedef void * LPCSTR; typedef unsigned long * LPDWORD; typedef long * PLONG; typedef void * LPVOID; typedef unsigned int UINT; - + typedef struct _FILETIME - { - DWORD dwLowDateTime; - DWORD dwHighDateTime; + { + DWORD dwLowDateTime; + DWORD dwHighDateTime; } FILETIME, *PFILETIME; @@ -152,7 +152,7 @@ LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; - + // Some Windows-specific defines #ifndef MAX_PATH #define MAX_PATH 1024 @@ -167,24 +167,24 @@ #endif #define VOID void - #define WINAPI + #define WINAPI #define FILE_BEGIN SEEK_SET #define FILE_CURRENT SEEK_CUR #define FILE_END SEEK_END - + #define CREATE_NEW 1 #define CREATE_ALWAYS 2 #define OPEN_EXISTING 3 #define OPEN_ALWAYS 4 - + #define FILE_SHARE_READ 0x00000001L #define GENERIC_WRITE 0x40000000 #define GENERIC_READ 0x80000000 - + #define FILE_FLAG_DELETE_ON_CLOSE 1 // Sam: Added these two defines so it would compile. #define FILE_FLAG_SEQUENTIAL_SCAN 2 - + #define ERROR_SUCCESS 0 #define ERROR_INVALID_FUNCTION 1 #define ERROR_FILE_NOT_FOUND 2 @@ -204,22 +204,22 @@ #define ERROR_PARAMETER_QUOTA_EXCEEDED 1283 #define ERROR_FILE_CORRUPT 1392 #define ERROR_INSUFFICIENT_BUFFER 4999 - + #define INVALID_HANDLE_VALUE ((HANDLE) -1) - + #ifndef min #define min(a, b) ((a < b) ? a : b) #endif - + #ifndef max #define max(a, b) ((a > b) ? a : b) #endif - + #define _stricmp strcasecmp #define _strnicmp strncasecmp - + extern int globalerr; - + void SetLastError(int err); int GetLastError(); char *ErrString(int err); @@ -276,4 +276,3 @@ #endif #endif // __STORMPORT_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp b/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp index 09eeef58949..0cd827fde9f 100644 --- a/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp +++ b/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp @@ -2,7 +2,7 @@ * * Description: implementation for StormLib - linux port * intended to be used in GLdiablo -* +* * ----> StormLib was originally developed for Windows by * Ladislav Zezula (www.zezula.net), and he did * a _great_ job! Thanks Ladislav! @@ -17,9 +17,9 @@ * * Author: Marko Friedemann <marko.friedemann@bmx-chemnitz.de> * Created at: Mon Jan 29 19:01:37 CEST 2001 -* Computer: whiplash.flachland-chemnitz.de +* Computer: whiplash.flachland-chemnitz.de * System: Linux 2.4.0 on i686 -* +* * Copyright (c) 2001 BMX-Chemnitz.DE All rights reserved. * ********************************************************************/ @@ -97,7 +97,7 @@ DWORD GetFileSize(HANDLE hFile, DWORD *ulOffSetHigh) struct stat fileinfo; fstat((int)hFile, &fileinfo); - + return fileinfo.st_size; } @@ -163,7 +163,6 @@ BOOL DeleteFile(const char *lpFileName) BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName) { return rename(lpExistingFileName, lpNewFileName); -} +} #endif - diff --git a/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp b/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp index 0904ab30f76..2477333ae02 100644 --- a/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp +++ b/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp @@ -1,7 +1,7 @@ /******************************************************************** * * Description: implementation for StormLib - Macintosh port -* +* * these are function wraps to execute Windows API calls * as native Macintosh file calls (open/close/read/write/...) * requires Mac OS X @@ -15,7 +15,7 @@ * ********************************************************************/ -#ifndef _WIN32 || _WIN64 +#ifndef _WIN32 #include "StormPort.h" #include "StormLib.h" @@ -45,14 +45,14 @@ static OSErr FSGetFullPath(const FSRef *ref, UInt8 *fullPath, UInt32 fullPathLen OSErr result; result = FSRefMakePath(ref, fullPath, fullPathLength); - + return result; } static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref) { OSErr result; - + result = FSPathMakeRef((UInt8 *)fullPath, ref, NULL); // Create an FSRef from the path return result; } @@ -61,7 +61,7 @@ static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref) /*****************************************************************************/ -static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName, +static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName, UniCharCount nameLength, FSRef *ref) { FSCatalogInfo theCatInfo; @@ -71,7 +71,7 @@ static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileT ((FileInfo *)&theCatInfo.finderInfo)->finderFlags = 0; SetPt(&((FileInfo *)&theCatInfo.finderInfo)->location, 0, 0); ((FileInfo *)&theCatInfo.finderInfo)->reservedField = 0; - + theErr = FSCreateFileUnicode(parentRef, nameLength, fileName, kFSCatInfoFinderInfo, &theCatInfo, ref, NULL); return theErr; } @@ -84,11 +84,11 @@ static OSErr FSOpenDFCompat(FSRef *ref, char permission, short *refNum) HFSUniStr255 forkName; OSErr theErr; Boolean isFolder, wasChanged; - + theErr = FSResolveAliasFile(ref, TRUE, &isFolder, &wasChanged); if (theErr != noErr) return theErr; - + FSGetDataForkName(&forkName); theErr = FSOpenFork(ref, forkName.length, forkName.unicode, permission, refNum); return theErr; @@ -209,7 +209,7 @@ void ConvertTMPQShunt(void *shunt) void ConvertTMPQHeader(void *header) { TMPQHeader2 * theHeader = (TMPQHeader2 *)header; - + theHeader->dwID = SwapULong(theHeader->dwID); theHeader->dwHeaderSize = SwapULong(theHeader->dwHeaderSize); theHeader->dwArchiveSize = SwapULong(theHeader->dwArchiveSize); @@ -271,7 +271,7 @@ int GetLastError() ********************************************************************/ char *ErrString(int err) { - switch (err) + switch (err) { case ERROR_INVALID_FUNCTION: return "function not implemented"; @@ -324,7 +324,7 @@ void GetTempPath(DWORD szTempLength, char * szTemp) // I think I'll change this else szTemp[0] = '\0'; strcat(szTemp, "/"); - + SetLastError(theErr); } @@ -347,7 +347,7 @@ void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWO strcpy(szLFName, lpTempFolderPath); strcat(szLFName, lpFileName); strcat(szLFName, tmp); - + if ((fHandle = CreateFile(szLFName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) // OK we found it! break; @@ -364,16 +364,16 @@ BOOL DeleteFile(const char * lpFileName) { OSErr theErr; FSRef theFileRef; - + theErr = FSLocationFromFullPath(lpFileName, &theFileRef); if (theErr != noErr) { SetLastError(theErr); return FALSE; } - + theErr = FSDeleteObject(&theFileRef); - + SetLastError(theErr); return theErr == noErr; @@ -390,7 +390,7 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) FSRef fromFileRef; FSRef toFileRef; FSRef parentFolderRef; - + // Get the path to the old file theErr = FSLocationFromFullPath(lpFromFileName, &fromFileRef); if (theErr != noErr) @@ -398,7 +398,7 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) SetLastError(theErr); return false; } - + // Get the path to the new folder for the file char folderName[strlen(lpToFileName)]; CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); @@ -409,7 +409,7 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) CFRelease(fileURL); CFRelease(folderURL); CFRelease(folderPathCFString); - + // Move the old file theErr = FSMoveObject(&fromFileRef, &parentFolderRef, &toFileRef); if (theErr != noErr) @@ -417,19 +417,19 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) SetLastError(theErr); return false; } - + // Get a CFString for the new file name CFStringRef newFileNameCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); fileURL = CFURLCreateWithFileSystemPath(NULL, newFileNameCFString, kCFURLPOSIXPathStyle, FALSE); CFRelease(newFileNameCFString); newFileNameCFString = CFURLCopyLastPathComponent(fileURL); CFRelease(fileURL); - + // Convert CFString to Unicode and rename the file - UniChar unicodeFileName[256]; - CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)), + UniChar unicodeFileName[256]; + CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)), unicodeFileName); - theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName, + theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName, kTextEncodingUnknown, NULL); if (theErr != noErr) { @@ -437,9 +437,9 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) CFRelease(newFileNameCFString); return false; } - + CFRelease(newFileNameCFString); - + SetLastError(theErr); return true; } @@ -470,7 +470,7 @@ HANDLE CreateFile( const char *sFileName, /* file name */ char permission; static OSType gCreator; static OSType gType; - + theErr = FSLocationFromFullPath(sFileName, &theFileRef); if (theErr == fnfErr) { // Create the FSRef for the parent directory. @@ -484,23 +484,23 @@ HANDLE CreateFile( const char *sFileName, /* file name */ CFRelease(fileURL); CFRelease(folderURL); CFRelease(folderPathCFString); - } + } if (theErr != noErr) { SetLastError(theErr); if (ulCreation == OPEN_EXISTING || theErr != fnfErr) return INVALID_HANDLE_VALUE; } - + if (ulCreation != OPEN_EXISTING) { /* We create the file */ UniChar unicodeFileName[256]; CFStringRef filePathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, filePathCFString, kCFURLPOSIXPathStyle, FALSE); CFStringRef fileNameCFString = CFURLCopyLastPathComponent(fileURL); - CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)), + CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)), unicodeFileName); - theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName, + theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName, CFStringGetLength(fileNameCFString), &theFileRef); CFRelease(fileNameCFString); CFRelease(filePathCFString); @@ -522,7 +522,7 @@ HANDLE CreateFile( const char *sFileName, /* file name */ permission = fsRdWrPerm; } theErr = FSOpenDFCompat(&theFileRef, permission, &fileRef); - + SetLastError(theErr); if (theErr == noErr) @@ -537,14 +537,14 @@ HANDLE CreateFile( const char *sFileName, /* file name */ BOOL CloseHandle( HANDLE hFile ) /* handle to object */ { OSErr theErr; - + if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) return FALSE; theErr = FSCloseFork((short)(int)hFile); - + SetLastError(theErr); - + return theErr != noErr; } @@ -562,19 +562,19 @@ DWORD GetFileSize( HANDLE hFile, /* handle to file */ SetLastError(theErr); return -1u; } - + theErr = FSGetForkSize((short)(int)hFile, &fileLength); if (theErr != noErr) { SetLastError(theErr); return -1u; } - + if (ulOffSetHigh != NULL) *ulOffSetHigh = fileLength >> 32; SetLastError(theErr); - + return fileLength; } @@ -593,81 +593,81 @@ DWORD SetFilePointer( HANDLE hFile, /* handle to file */ if (ulMethod == FILE_CURRENT) { SInt64 bytesToMove; - + if (pOffSetHigh != NULL) bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; else bytesToMove = lOffSetLow; - + SInt64 newPos; - + theErr = FSSetForkPosition((short)(int)hFile, fsFromMark, bytesToMove); if (theErr != noErr) { SetLastError(theErr); return -1u; } - + theErr = FSGetForkPosition((short)(int)hFile, &newPos); if (theErr != noErr) { SetLastError(theErr); return -1u; } - + if (pOffSetHigh != NULL) *pOffSetHigh = newPos >> 32; - + SetLastError(theErr); return newPos; } else if (ulMethod == FILE_BEGIN) { SInt64 bytesToMove; - + if (pOffSetHigh != NULL) bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; else bytesToMove = lOffSetLow; - + theErr = FSSetForkPosition((short)(int)hFile, fsFromStart, bytesToMove); if (theErr != noErr) { SetLastError(theErr); return -1u; } - + SetLastError(theErr); return lOffSetLow; } else { SInt64 bytesToMove; - + if (pOffSetHigh != NULL) bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; else bytesToMove = lOffSetLow; - + SInt64 newPos; - + theErr = FSSetForkPosition((short)(int)hFile, fsFromLEOF, bytesToMove); if (theErr != noErr) { SetLastError(theErr); return -1u; } - + theErr = FSGetForkPosition((short)(int)hFile, &newPos); if (theErr != noErr) { SetLastError(theErr); return -1u; } - + if (pOffSetHigh != NULL) *pOffSetHigh = newPos >> 32; - + SetLastError(theErr); return newPos; } @@ -679,11 +679,11 @@ DWORD SetFilePointer( HANDLE hFile, /* handle to file */ BOOL SetEndOfFile( HANDLE hFile ) /* handle to file */ { OSErr theErr; - + theErr = FSSetForkSize((short)(int)hFile, fsAtMark, 0); - + SetLastError(theErr); - + return theErr == noErr; } @@ -701,13 +701,13 @@ BOOL ReadFile( HANDLE hFile, /* handle to file */ ByteCount nbCharsRead; OSErr theErr; - + nbCharsRead = ulLen; theErr = FSReadFork((short)(int)hFile, fsAtMark, 0, nbCharsRead, pBuffer, &nbCharsRead); *ulRead = nbCharsRead; - + SetLastError(theErr); - + return theErr == noErr; } @@ -725,13 +725,13 @@ BOOL WriteFile( HANDLE hFile, /* handle to file */ ByteCount nbCharsToWrite; OSErr theErr; - - nbCharsToWrite = ulLen; + + nbCharsToWrite = ulLen; theErr = FSWriteFork((short)(int)hFile, fsAtMark, 0, nbCharsToWrite, pBuffer, &nbCharsToWrite); *ulWritten = nbCharsToWrite; - + SetLastError(theErr); - + return theErr == noErr; } @@ -744,15 +744,15 @@ BOOL IsBadReadPtr(const void * ptr, int size) return FALSE; } -// Returns attributes of a file. Actually, it doesn't, it just checks if +// Returns attributes of a file. Actually, it doesn't, it just checks if // the file exists, since that's all StormLib uses it for DWORD GetFileAttributes(const char * szFileName) { FSRef theRef; OSErr theErr; - + theErr = FSLocationFromFullPath(szFileName, &theRef); - + if (theErr != noErr) return -1u; else @@ -760,4 +760,3 @@ DWORD GetFileAttributes(const char * szFileName) } #endif - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c b/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c index 4c09446422a..33ec9f5dcb0 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -57,8 +57,8 @@ For more information on these sources, see the manual. - To get some idea how the block sorting algorithms in this file - work, read my paper + To get some idea how the block sorting algorithms in this file + work, read my paper On the Performance of BWT Sorting Algorithms in Proceedings of the IEEE Data Compression Conference 2000, Snowbird, Utah, USA, 27-30 March 2000. The main sort in this @@ -74,11 +74,11 @@ /*---------------------------------------------*/ /*---------------------------------------------*/ -static +static __inline__ -void fallbackSimpleSort ( UInt32* fmap, - UInt32* eclass, - Int32 lo, +void fallbackSimpleSort ( UInt32* fmap, + UInt32* eclass, + Int32 lo, Int32 hi ) { Int32 i, j, tmp; @@ -137,9 +137,9 @@ void fallbackSimpleSort ( UInt32* fmap, static -void fallbackQSort3 ( UInt32* fmap, +void fallbackQSort3 ( UInt32* fmap, UInt32* eclass, - Int32 loSt, + Int32 loSt, Int32 hiSt ) { Int32 unLo, unHi, ltLo, gtHi, n, m; @@ -164,9 +164,9 @@ void fallbackQSort3 ( UInt32* fmap, } /* Random partitioning. Median of 3 sometimes fails to - avoid bad cases. Median of 9 seems to help but + avoid bad cases. Median of 9 seems to help but looks rather expensive. This too seems to work but - is cheaper. Guidance for the magic constants + is cheaper. Guidance for the magic constants 7621 and 32768 is taken from Sedgewick's algorithms book, chapter 35. */ @@ -183,10 +183,10 @@ void fallbackQSort3 ( UInt32* fmap, while (1) { if (unLo > unHi) break; n = (Int32)eclass[fmap[unLo]] - (Int32)med; - if (n == 0) { - fswap(fmap[unLo], fmap[ltLo]); - ltLo++; unLo++; - continue; + if (n == 0) { + fswap(fmap[unLo], fmap[ltLo]); + ltLo++; unLo++; + continue; }; if (n > 0) break; unLo++; @@ -194,10 +194,10 @@ void fallbackQSort3 ( UInt32* fmap, while (1) { if (unLo > unHi) break; n = (Int32)eclass[fmap[unHi]] - (Int32)med; - if (n == 0) { - fswap(fmap[unHi], fmap[gtHi]); - gtHi--; unHi--; - continue; + if (n == 0) { + fswap(fmap[unHi], fmap[gtHi]); + gtHi--; unHi--; + continue; }; if (n < 0) break; unHi--; @@ -256,8 +256,8 @@ void fallbackQSort3 ( UInt32* fmap, #define UNALIGNED_BH(zz) ((zz) & 0x01f) static -void fallbackSort ( UInt32* fmap, - UInt32* eclass, +void fallbackSort ( UInt32* fmap, + UInt32* eclass, UInt32* bhtab, Int32 nblock, Int32 verb ) @@ -298,7 +298,7 @@ void fallbackSort ( UInt32* fmap, --*/ /*-- set sentinel bits for block-end detection --*/ - for (i = 0; i < 32; i++) { + for (i = 0; i < 32; i++) { SET_BH(nblock + 2*i); CLEAR_BH(nblock + 2*i + 1); } @@ -307,7 +307,7 @@ void fallbackSort ( UInt32* fmap, H = 1; while (1) { - if (verb >= 4) + if (verb >= 4) VPrintf1 ( " depth %6d has ", H ); j = 0; @@ -321,7 +321,7 @@ void fallbackSort ( UInt32* fmap, r = -1; while (1) { - /*-- find the next non-singleton bucket --*/ + /*-- find the next non-singleton bucket --*/ k = r + 1; while (ISSET_BH(k) && UNALIGNED_BH(k)) k++; if (ISSET_BH(k)) { @@ -352,14 +352,14 @@ void fallbackSort ( UInt32* fmap, } } - if (verb >= 4) + if (verb >= 4) VPrintf1 ( "%6d unresolved strings\n", nNotDone ); H *= 2; if (H > nblock || nNotDone == 0) break; } - /*-- + /*-- Reconstruct the original block in eclass8 [0 .. nblock-1], since the previous phase destroyed it. @@ -391,9 +391,9 @@ void fallbackSort ( UInt32* fmap, /*---------------------------------------------*/ static __inline__ -Bool mainGtU ( UInt32 i1, +Bool mainGtU ( UInt32 i1, UInt32 i2, - UChar* block, + UChar* block, UInt16* quadrant, UInt32 nblock, Int32* budget ) @@ -533,8 +533,8 @@ void mainSimpleSort ( UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, - Int32 lo, - Int32 hi, + Int32 lo, + Int32 hi, Int32 d, Int32* budget ) { @@ -558,8 +558,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -572,8 +572,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -586,8 +586,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -625,13 +625,13 @@ void mainSimpleSort ( UInt32* ptr, } \ } -static +static __inline__ UChar mmed3 ( UChar a, UChar b, UChar c ) { UChar t; if (a > b) { t = a; a = b; b = t; }; - if (b > c) { + if (b > c) { b = c; if (a > b) b = a; } @@ -669,8 +669,8 @@ void mainQSort3 ( UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, - Int32 loSt, - Int32 hiSt, + Int32 loSt, + Int32 hiSt, Int32 dSt, Int32* budget ) { @@ -693,14 +693,14 @@ void mainQSort3 ( UInt32* ptr, AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 ); mpop ( lo, hi, d ); - if (hi - lo < MAIN_QSORT_SMALL_THRESH || + if (hi - lo < MAIN_QSORT_SMALL_THRESH || d > MAIN_QSORT_DEPTH_THRESH) { mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); if (*budget < 0) return; continue; } - med = (Int32) + med = (Int32) mmed3 ( block[ptr[ lo ]+d], block[ptr[ hi ]+d], block[ptr[ (lo+hi)>>1 ]+d] ); @@ -712,9 +712,9 @@ void mainQSort3 ( UInt32* ptr, while (True) { if (unLo > unHi) break; n = ((Int32)block[ptr[unLo]+d]) - med; - if (n == 0) { - mswap(ptr[unLo], ptr[ltLo]); - ltLo++; unLo++; continue; + if (n == 0) { + mswap(ptr[unLo], ptr[ltLo]); + ltLo++; unLo++; continue; }; if (n > 0) break; unLo++; @@ -722,9 +722,9 @@ void mainQSort3 ( UInt32* ptr, while (True) { if (unLo > unHi) break; n = ((Int32)block[ptr[unHi]+d]) - med; - if (n == 0) { - mswap(ptr[unHi], ptr[gtHi]); - gtHi--; unHi--; continue; + if (n == 0) { + mswap(ptr[unHi], ptr[gtHi]); + gtHi--; unHi--; continue; }; if (n < 0) break; unHi--; @@ -795,9 +795,9 @@ void mainQSort3 ( UInt32* ptr, #define CLEARMASK (~(SETMASK)) static -void mainSort ( UInt32* ptr, +void mainSort ( UInt32* ptr, UChar* block, - UInt16* quadrant, + UInt16* quadrant, UInt32* ftab, Int32 nblock, Int32 verb, @@ -925,7 +925,7 @@ void mainSort ( UInt32* ptr, /*-- Step 1: Complete the big bucket [ss] by quicksorting - any unsorted small buckets [ss, j], for j != ss. + any unsorted small buckets [ss, j], for j != ss. Hopefully previous pointer-scanning phases have already completed many of the small buckets [ss, j], so we don't have to sort them at all. @@ -941,10 +941,10 @@ void mainSort ( UInt32* ptr, VPrintf4 ( " qsort [0x%x, 0x%x] " "done %d this %d\n", ss, j, numQSorted, hi - lo + 1 ); - mainQSort3 ( - ptr, block, quadrant, nblock, - lo, hi, BZ_N_RADIX, budget - ); + mainQSort3 ( + ptr, block, quadrant, nblock, + lo, hi, BZ_N_RADIX, budget + ); numQSorted += (hi - lo + 1); if (*budget < 0) return; } @@ -976,16 +976,16 @@ void mainSort ( UInt32* ptr, for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { k = ptr[j]-1; if (k < 0) k += nblock; c1 = block[k]; - if (!bigDone[c1]) + if (!bigDone[c1]) ptr[ copyEnd[c1]-- ] = k; } } AssertH ( (copyStart[ss]-1 == copyEnd[ss]) - || + || /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1. - Necessity for this case is demonstrated by compressing - a sequence of approximately 48.5 million of character + Necessity for this case is demonstrated by compressing + a sequence of approximately 48.5 million of character 251; 1.0.0/1.0.1 will then die here. */ (copyStart[ss] == 0 && copyEnd[ss] == nblock-1), 1007 ) @@ -1002,7 +1002,7 @@ void mainSort ( UInt32* ptr, updating for the last bucket is pointless. The quadrant array provides a way to incrementally - cache sort orderings, as they appear, so as to + cache sort orderings, as they appear, so as to make subsequent comparisons in fullGtU() complete faster. For repetitive blocks this makes a big difference (but not big enough to be able to avoid @@ -1012,9 +1012,9 @@ void mainSort ( UInt32* ptr, for 0 <= i < nblock and 0 <= j <= nblock - if block[i] != block[j], + if block[i] != block[j], - then the relative values of quadrant[i] and + then the relative values of quadrant[i] and quadrant[j] are meaningless. else { @@ -1077,7 +1077,7 @@ void mainSort ( UInt32* ptr, */ void BZ2_blockSort ( EState* s ) { - UInt32* ptr = s->ptr; + UInt32* ptr = s->ptr; UChar* block = s->block; UInt32* ftab = s->ftab; Int32 nblock = s->nblock; @@ -1101,8 +1101,8 @@ void BZ2_blockSort ( EState* s ) quadrant = (UInt16*)(&(block[i])); /* (wfact-1) / 3 puts the default-factor-30 - transition point at very roughly the same place as - with v0.1 and v0.9.0. + transition point at very roughly the same place as + with v0.1 and v0.9.0. Not that it particularly matters any more, since the resulting compressed stream is now the same regardless of whether or not we use the main sort or fallback sort. @@ -1113,14 +1113,14 @@ void BZ2_blockSort ( EState* s ) budget = budgetInit; mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); - if (verb >= 3) + if (verb >= 3) VPrintf3 ( " %d work, %d block, ratio %5.2f\n", budgetInit - budget, - nblock, + nblock, (float)(budgetInit - budget) / - (float)(nblock==0 ? 1 : nblock) ); + (float)(nblock==0 ? 1 : nblock) ); if (budget < 0) { - if (verb >= 2) + if (verb >= 2) VPrintf0 ( " too repetitive; using fallback" " sorting algorithm\n" ); fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c index 2e54697670a..79f87a51986 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c @@ -16,16 +16,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -64,12 +64,12 @@ /*-- WARNING: - This program and library (attempts to) compress data by - performing several non-trivial transformations on it. - Unless you are 100% familiar with *all* the algorithms - contained herein, and with the consequences of modifying them, - you should NOT meddle with the compression or decompression - machinery. Incorrect changes can and very likely *will* + This program and library (attempts to) compress data by + performing several non-trivial transformations on it. + Unless you are 100% familiar with *all* the algorithms + contained herein, and with the consequences of modifying them, + you should NOT meddle with the compression or decompression + machinery. Incorrect changes can and very likely *will* lead to disasterous loss of data. DISCLAIMER: @@ -84,8 +84,8 @@ of various special cases in the code which occur with very low but non-zero probability make it impossible to rule out the possibility of bugs remaining in the program. DO NOT COMPRESS - ANY DATA WITH THIS PROGRAM AND/OR LIBRARY UNLESS YOU ARE PREPARED - TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL + ANY DATA WITH THIS PROGRAM AND/OR LIBRARY UNLESS YOU ARE PREPARED + TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. That is not to say this program is inherently unreliable. @@ -93,9 +93,9 @@ has been carefully constructed and extensively tested. PATENTS: - To the best of my knowledge, bzip2/libbzip2 does not use any - patented algorithms. However, I do not have the resources - available to carry out a full patent search. Therefore I cannot + To the best of my knowledge, bzip2/libbzip2 does not use any + patented algorithms. However, I do not have the resources + available to carry out a full patent search. Therefore I cannot give any guarantee of the above statement. --*/ @@ -257,7 +257,7 @@ typedef int Int32; typedef unsigned int UInt32; typedef short Int16; typedef unsigned short UInt16; - + #define True ((Bool)1) #define False ((Bool)0) @@ -321,7 +321,7 @@ static void* myMalloc ( Int32 ); /*---------------------------------------------------*/ typedef - struct { UChar b[8]; } + struct { UChar b[8]; } UInt64; @@ -364,7 +364,7 @@ Bool uInt64_isZero ( UInt64* n ) /* Divide *n by 10, and return the remainder. */ -static +static Int32 uInt64_qrm10 ( UInt64* n ) { UInt32 rem, tmp; @@ -395,7 +395,7 @@ void uInt64_toAscii ( char* outbuf, UInt64* n ) nBuf++; } while (!uInt64_isZero(&n_copy)); outbuf[nBuf] = 0; - for (i = 0; i < nBuf; i++) + for (i = 0; i < nBuf; i++) outbuf[i] = buf[nBuf-i-1]; } @@ -405,7 +405,7 @@ void uInt64_toAscii ( char* outbuf, UInt64* n ) /*---------------------------------------------------*/ /*---------------------------------------------*/ -static +static Bool myfeof ( FILE* f ) { Int32 c = fgetc ( f ); @@ -416,7 +416,7 @@ Bool myfeof ( FILE* f ) /*---------------------------------------------*/ -static +static void compressStream ( FILE *stream, FILE *zStream ) { BZFILE* bzf = NULL; @@ -432,8 +432,8 @@ void compressStream ( FILE *stream, FILE *zStream ) if (ferror(stream)) goto errhandler_io; if (ferror(zStream)) goto errhandler_io; - bzf = BZ2_bzWriteOpen ( &bzerr, zStream, - blockSize100k, verbosity, workFactor ); + bzf = BZ2_bzWriteOpen ( &bzerr, zStream, + blockSize100k, verbosity, workFactor ); if (bzerr != BZ_OK) goto errhandler; if (verbosity >= 2) fprintf ( stderr, "\n" ); @@ -448,7 +448,7 @@ void compressStream ( FILE *stream, FILE *zStream ) } - BZ2_bzWriteClose64 ( &bzerr, bzf, 0, + BZ2_bzWriteClose64 ( &bzerr, bzf, 0, &nbytes_in_lo32, &nbytes_in_hi32, &nbytes_out_lo32, &nbytes_out_hi32 ); if (bzerr != BZ_OK) goto errhandler; @@ -468,34 +468,34 @@ void compressStream ( FILE *stream, FILE *zStream ) if (verbosity >= 1) { if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) { - fprintf ( stderr, " no data compressed.\n"); + fprintf ( stderr, " no data compressed.\n"); } else { - Char buf_nin[32], buf_nout[32]; - UInt64 nbytes_in, nbytes_out; - double nbytes_in_d, nbytes_out_d; - uInt64_from_UInt32s ( &nbytes_in, - nbytes_in_lo32, nbytes_in_hi32 ); - uInt64_from_UInt32s ( &nbytes_out, - nbytes_out_lo32, nbytes_out_hi32 ); - nbytes_in_d = uInt64_to_double ( &nbytes_in ); - nbytes_out_d = uInt64_to_double ( &nbytes_out ); - uInt64_toAscii ( buf_nin, &nbytes_in ); - uInt64_toAscii ( buf_nout, &nbytes_out ); - fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, " - "%5.2f%% saved, %s in, %s out.\n", - nbytes_in_d / nbytes_out_d, - (8.0 * nbytes_out_d) / nbytes_in_d, - 100.0 * (1.0 - nbytes_out_d / nbytes_in_d), - buf_nin, - buf_nout - ); + Char buf_nin[32], buf_nout[32]; + UInt64 nbytes_in, nbytes_out; + double nbytes_in_d, nbytes_out_d; + uInt64_from_UInt32s ( &nbytes_in, + nbytes_in_lo32, nbytes_in_hi32 ); + uInt64_from_UInt32s ( &nbytes_out, + nbytes_out_lo32, nbytes_out_hi32 ); + nbytes_in_d = uInt64_to_double ( &nbytes_in ); + nbytes_out_d = uInt64_to_double ( &nbytes_out ); + uInt64_toAscii ( buf_nin, &nbytes_in ); + uInt64_toAscii ( buf_nout, &nbytes_out ); + fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, " + "%5.2f%% saved, %s in, %s out.\n", + nbytes_in_d / nbytes_out_d, + (8.0 * nbytes_out_d) / nbytes_in_d, + 100.0 * (1.0 - nbytes_out_d / nbytes_in_d), + buf_nin, + buf_nout + ); } } return; errhandler: - BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, + BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, &nbytes_in_lo32, &nbytes_in_hi32, &nbytes_out_lo32, &nbytes_out_hi32 ); switch (bzerr) { @@ -517,7 +517,7 @@ void compressStream ( FILE *stream, FILE *zStream ) /*---------------------------------------------*/ -static +static Bool uncompressStream ( FILE *zStream, FILE *stream ) { BZFILE* bzf = NULL; @@ -539,8 +539,8 @@ Bool uncompressStream ( FILE *zStream, FILE *stream ) while (True) { - bzf = BZ2_bzReadOpen ( - &bzerr, zStream, verbosity, + bzf = BZ2_bzReadOpen ( + &bzerr, zStream, verbosity, (int)smallMode, unused, nUnused ); if (bzf == NULL || bzerr != BZ_OK) goto errhandler; @@ -584,19 +584,19 @@ Bool uncompressStream ( FILE *zStream, FILE *stream ) if (verbosity >= 2) fprintf ( stderr, "\n " ); return True; - trycat: + trycat: if (forceOverwrite) { rewind(zStream); while (True) { - if (myfeof(zStream)) break; - nread = fread ( obuf, sizeof(UChar), 5000, zStream ); - if (ferror(zStream)) goto errhandler_io; - if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream ); - if (ferror(stream)) goto errhandler_io; + if (myfeof(zStream)) break; + nread = fread ( obuf, sizeof(UChar), 5000, zStream ); + if (ferror(zStream)) goto errhandler_io; + if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream ); + if (ferror(stream)) goto errhandler_io; } goto closeok; } - + errhandler: BZ2_bzReadClose ( &bzerr_dummy, bzf ); switch (bzerr) { @@ -618,10 +618,10 @@ Bool uncompressStream ( FILE *zStream, FILE *stream ) return False; } else { if (noisy) - fprintf ( stderr, + fprintf ( stderr, "\n%s: %s: trailing garbage after EOF ignored\n", progName, inName ); - return True; + return True; } default: panic ( "decompress:unexpected error" ); @@ -633,7 +633,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream ) /*---------------------------------------------*/ -static +static Bool testStream ( FILE *zStream ) { BZFILE* bzf = NULL; @@ -652,8 +652,8 @@ Bool testStream ( FILE *zStream ) while (True) { - bzf = BZ2_bzReadOpen ( - &bzerr, zStream, verbosity, + bzf = BZ2_bzReadOpen ( + &bzerr, zStream, verbosity, (int)smallMode, unused, nUnused ); if (bzf == NULL || bzerr != BZ_OK) goto errhandler; @@ -686,7 +686,7 @@ Bool testStream ( FILE *zStream ) errhandler: BZ2_bzReadClose ( &bzerr_dummy, bzf ); - if (verbosity == 0) + if (verbosity == 0) fprintf ( stderr, "%s: %s: ", progName, inName ); switch (bzerr) { case BZ_CONFIG_ERROR: @@ -707,14 +707,14 @@ Bool testStream ( FILE *zStream ) case BZ_DATA_ERROR_MAGIC: if (zStream != stdin) fclose(zStream); if (streamNo == 1) { - fprintf ( stderr, + fprintf ( stderr, "bad magic number (file not created by bzip2)\n" ); return False; } else { if (noisy) - fprintf ( stderr, + fprintf ( stderr, "trailing garbage after EOF ignored\n" ); - return True; + return True; } default: panic ( "test:unexpected error" ); @@ -738,7 +738,7 @@ void setExit ( Int32 v ) /*---------------------------------------------*/ -static +static void cadvise ( void ) { if (noisy) @@ -753,26 +753,26 @@ void cadvise ( void ) /*---------------------------------------------*/ -static +static void showFileNames ( void ) { if (noisy) fprintf ( stderr, "\tInput file = %s, output file = %s\n", - inName, outName + inName, outName ); } /*---------------------------------------------*/ -static +static void cleanUpAndFail ( Int32 ec ) { IntNative retVal; struct MY_STAT statBuf; - if ( srcMode == SM_F2F + if ( srcMode == SM_F2F && opMode != OM_TEST && deleteOutputOnInterrupt ) { @@ -784,7 +784,7 @@ void cleanUpAndFail ( Int32 ec ) retVal = MY_STAT ( inName, &statBuf ); if (retVal == 0) { if (noisy) - fprintf ( stderr, + fprintf ( stderr, "%s: Deleting output file %s, if it exists.\n", progName, outName ); if (outputHandleJustInCase != NULL) @@ -805,7 +805,7 @@ void cleanUpAndFail ( Int32 ec ) fprintf ( stderr, "%s: `%s' may be incomplete.\n", progName, outName ); - fprintf ( stderr, + fprintf ( stderr, "%s: I suggest doing an integrity test (bzip2 -tv)" " of it.\n", progName ); @@ -813,7 +813,7 @@ void cleanUpAndFail ( Int32 ec ) } if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) { - fprintf ( stderr, + fprintf ( stderr, "%s: WARNING: some files have not been processed:\n" "%s: %d specified on command line, %d not processed yet.\n\n", progName, progName, @@ -825,7 +825,7 @@ void cleanUpAndFail ( Int32 ec ) /*---------------------------------------------*/ -static +static void panic ( Char* s ) { fprintf ( stderr, @@ -840,7 +840,7 @@ void panic ( Char* s ) /*---------------------------------------------*/ -static +static void crcError ( void ) { fprintf ( stderr, @@ -853,14 +853,14 @@ void crcError ( void ) /*---------------------------------------------*/ -static +static void compressedStreamEOF ( void ) { if (noisy) { fprintf ( stderr, - "\n%s: Compressed file ends unexpectedly;\n\t" - "perhaps it is corrupted? *Possible* reason follows.\n", - progName ); + "\n%s: Compressed file ends unexpectedly;\n\t" + "perhaps it is corrupted? *Possible* reason follows.\n", + progName ); perror ( progName ); showFileNames(); cadvise(); @@ -870,7 +870,7 @@ void compressedStreamEOF ( void ) /*---------------------------------------------*/ -static +static void ioError ( void ) { fprintf ( stderr, @@ -884,7 +884,7 @@ void ioError ( void ) /*---------------------------------------------*/ -static +static void mySignalCatcher ( IntNative n ) { fprintf ( stderr, @@ -895,11 +895,11 @@ void mySignalCatcher ( IntNative n ) /*---------------------------------------------*/ -static +static void mySIGSEGVorSIGBUScatcher ( IntNative n ) { if (opMode == OM_Z) - fprintf ( + fprintf ( stderr, "\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n" "\n" @@ -920,7 +920,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n ) "\n", progName ); else - fprintf ( + fprintf ( stderr, "\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n" "\n" @@ -951,7 +951,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n ) /*---------------------------------------------*/ -static +static void outOfMemory ( void ) { fprintf ( stderr, @@ -963,7 +963,7 @@ void outOfMemory ( void ) /*---------------------------------------------*/ -static +static void configError ( void ) { fprintf ( stderr, @@ -983,11 +983,11 @@ void configError ( void ) /* All rather crufty. The main problem is that input files are stat()d multiple times before use. This should be - cleaned up. + cleaned up. */ /*---------------------------------------------*/ -static +static void pad ( Char *s ) { Int32 i; @@ -998,8 +998,8 @@ void pad ( Char *s ) /*---------------------------------------------*/ -static -void copyFileName ( Char* to, Char* from ) +static +void copyFileName ( Char* to, Char* from ) { if ( strlen(from) > FILE_NAME_LEN-10 ) { fprintf ( @@ -1019,7 +1019,7 @@ void copyFileName ( Char* to, Char* from ) /*---------------------------------------------*/ -static +static Bool fileExists ( Char* name ) { FILE *tmp = fopen ( name, "rb" ); @@ -1059,7 +1059,7 @@ FILE* fopen_output_safely ( Char* name, const char* mode ) /*-- if in doubt, return True --*/ -static +static Bool notAStandardFile ( Char* name ) { IntNative i; @@ -1076,9 +1076,9 @@ Bool notAStandardFile ( Char* name ) /*-- rac 11/21/98 see if file has hard links to it --*/ -static +static Int32 countHardLinks ( Char* name ) -{ +{ IntNative i; struct MY_STAT statBuf; @@ -1109,14 +1109,14 @@ Int32 countHardLinks ( Char* name ) It sounds pretty fragile to me. Whether this carries across robustly to arbitrary Unix-like platforms (or even works robustly - on this one, RedHat 7.2) is unknown to me. Nevertheless ... + on this one, RedHat 7.2) is unknown to me. Nevertheless ... */ #if BZ_UNIX -static +static struct MY_STAT fileMetaInfo; #endif -static +static void saveInputFileMetaInfo ( Char *srcName ) { # if BZ_UNIX @@ -1128,7 +1128,7 @@ void saveInputFileMetaInfo ( Char *srcName ) } -static +static void applySavedMetaInfoToOutputFile ( Char *dstName ) { # if BZ_UNIX @@ -1153,7 +1153,7 @@ void applySavedMetaInfoToOutputFile ( Char *dstName ) /*---------------------------------------------*/ -static +static Bool containsDubiousChars ( Char* name ) { # if BZ_UNIX @@ -1162,7 +1162,7 @@ Bool containsDubiousChars ( Char* name ) */ return False; # else /* ! BZ_UNIX */ - /* On non-unix (Win* platforms), wildcard characters are not allowed in + /* On non-unix (Win* platforms), wildcard characters are not allowed in * filenames. */ for (; *name != '\0'; name++) @@ -1175,12 +1175,12 @@ Bool containsDubiousChars ( Char* name ) /*---------------------------------------------*/ #define BZ_N_SUFFIX_PAIRS 4 -Char* zSuffix[BZ_N_SUFFIX_PAIRS] +Char* zSuffix[BZ_N_SUFFIX_PAIRS] = { ".bz2", ".bz", ".tbz2", ".tbz" }; -Char* unzSuffix[BZ_N_SUFFIX_PAIRS] +Char* unzSuffix[BZ_N_SUFFIX_PAIRS] = { "", "", ".tar", ".tar" }; -static +static Bool hasSuffix ( Char* s, Char* suffix ) { Int32 ns = strlen(s); @@ -1190,8 +1190,8 @@ Bool hasSuffix ( Char* s, Char* suffix ) return False; } -static -Bool mapSuffix ( Char* name, +static +Bool mapSuffix ( Char* name, Char* oldSuffix, Char* newSuffix ) { if (!hasSuffix(name,oldSuffix)) return False; @@ -1202,7 +1202,7 @@ Bool mapSuffix ( Char* name, /*---------------------------------------------*/ -static +static void compress ( Char *name ) { FILE *inStr; @@ -1216,18 +1216,18 @@ void compress ( Char *name ) panic ( "compress: bad modes\n" ); switch (srcMode) { - case SM_I2O: + case SM_I2O: copyFileName ( inName, "(stdin)" ); - copyFileName ( outName, "(stdout)" ); + copyFileName ( outName, "(stdout)" ); break; - case SM_F2F: + case SM_F2F: copyFileName ( inName, name ); copyFileName ( outName, name ); - strcat ( outName, ".bz2" ); + strcat ( outName, ".bz2" ); break; - case SM_F2O: + case SM_F2O: copyFileName ( inName, name ); - copyFileName ( outName, "(stdout)" ); + copyFileName ( outName, "(stdout)" ); break; } @@ -1247,7 +1247,7 @@ void compress ( Char *name ) for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) { if (hasSuffix(inName, zSuffix[i])) { if (noisy) - fprintf ( stderr, + fprintf ( stderr, "%s: Input file %s already has %s suffix.\n", progName, inName, zSuffix[i] ); setExit(1); @@ -1273,12 +1273,12 @@ void compress ( Char *name ) } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - remove(outName); + remove(outName); } else { - fprintf ( stderr, "%s: Output file %s already exists.\n", - progName, outName ); - setExit(1); - return; + fprintf ( stderr, "%s: Output file %s already exists.\n", + progName, outName ); + setExit(1); + return; } } if ( srcMode == SM_F2F && !forceOverwrite && @@ -1383,7 +1383,7 @@ void compress ( Char *name ) /*---------------------------------------------*/ -static +static void uncompress ( Char *name ) { FILE *inStr; @@ -1400,22 +1400,22 @@ void uncompress ( Char *name ) cantGuess = False; switch (srcMode) { - case SM_I2O: + case SM_I2O: copyFileName ( inName, "(stdin)" ); - copyFileName ( outName, "(stdout)" ); + copyFileName ( outName, "(stdout)" ); break; - case SM_F2F: + case SM_F2F: copyFileName ( inName, name ); copyFileName ( outName, name ); for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) if (mapSuffix(outName,zSuffix[i],unzSuffix[i])) - goto zzz; + goto zzz; cantGuess = True; strcat ( outName, ".out" ); break; - case SM_F2O: + case SM_F2O: copyFileName ( inName, name ); - copyFileName ( outName, "(stdout)" ); + copyFileName ( outName, "(stdout)" ); break; } @@ -1452,14 +1452,14 @@ void uncompress ( Char *name ) } if ( /* srcMode == SM_F2F implied && */ cantGuess ) { if (noisy) - fprintf ( stderr, + fprintf ( stderr, "%s: Can't guess original name for %s -- using %s\n", progName, inName, outName ); /* just a warning, no return */ - } + } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - remove(outName); + remove(outName); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1581,7 +1581,7 @@ void uncompress ( Char *name ) /*---------------------------------------------*/ -static +static void testf ( Char *name ) { FILE *inStr; @@ -1670,7 +1670,7 @@ void testf ( Char *name ) /*---------------------------------------------*/ -static +static void license ( void ) { fprintf ( stderr, @@ -1695,7 +1695,7 @@ void license ( void ) /*---------------------------------------------*/ -static +static void usage ( Char *fullProgName ) { fprintf ( @@ -1739,11 +1739,11 @@ void usage ( Char *fullProgName ) /*---------------------------------------------*/ -static +static void redundant ( Char* flag ) { - fprintf ( - stderr, + fprintf ( + stderr, "%s: %s is redundant in versions 0.9.5 and above\n", progName, flag ); } @@ -1755,8 +1755,8 @@ void redundant ( Char* flag ) implement a linked list of command-line arguments, into which main() copies argv[1 .. argc-1]. - The purpose of this exercise is to facilitate - the expansion of wildcard characters * and ? in + The purpose of this exercise is to facilitate + the expansion of wildcard characters * and ? in filenames for OSs which don't know how to do it themselves, like MSDOS, Windows 95 and NT. @@ -1773,7 +1773,7 @@ typedef /*---------------------------------------------*/ -static +static void *myMalloc ( Int32 n ) { void* p; @@ -1785,7 +1785,7 @@ void *myMalloc ( Int32 n ) /*---------------------------------------------*/ -static +static Cell *mkCell ( void ) { Cell *c; @@ -1798,7 +1798,7 @@ Cell *mkCell ( void ) /*---------------------------------------------*/ -static +static Cell *snocString ( Cell *root, Char *name ) { if (root == NULL) { @@ -1816,8 +1816,8 @@ Cell *snocString ( Cell *root, Char *name ) /*---------------------------------------------*/ -static -void addFlagsFromEnvVar ( Cell** argList, Char* varName ) +static +void addFlagsFromEnvVar ( Cell** argList, Char* varName ) { Int32 i, j, k; Char *envbase, *p; @@ -1894,7 +1894,7 @@ IntNative main ( IntNative argc, Char *argv[] ) if (*tmp == PATH_SEP) progName = tmp + 1; - /*-- Copy flags from env var BZIP2, and + /*-- Copy flags from env var BZIP2, and expand filename wildcards in arg list. --*/ argList = NULL; @@ -1977,7 +1977,7 @@ IntNative main ( IntNative argc, Char *argv[] ) } } } - + /*-- And again ... --*/ for (aa = argList; aa != NULL; aa = aa->link) { if (ISFLAG("--")) break; @@ -1991,7 +1991,7 @@ IntNative main ( IntNative argc, Char *argv[] ) if (ISFLAG("--quiet")) noisy = False; else if (ISFLAG("--version")) license(); else if (ISFLAG("--license")) license(); else - if (ISFLAG("--exponential")) workFactor = 1; else + if (ISFLAG("--exponential")) workFactor = 1; else if (ISFLAG("--repetitive-best")) redundant(aa->name); else if (ISFLAG("--repetitive-fast")) redundant(aa->name); else if (ISFLAG("--fast")) blockSize100k = 1; else @@ -2007,7 +2007,7 @@ IntNative main ( IntNative argc, Char *argv[] ) } if (verbosity > 4) verbosity = 4; - if (opMode == OM_Z && smallMode && blockSize100k > 2) + if (opMode == OM_Z && smallMode && blockSize100k > 2) blockSize100k = 2; if (opMode == OM_TEST && srcMode == SM_F2O) { @@ -2041,7 +2041,7 @@ IntNative main ( IntNative argc, Char *argv[] ) compress ( aa->name ); } } - } + } else if (opMode == OM_UNZ) { @@ -2055,13 +2055,13 @@ IntNative main ( IntNative argc, Char *argv[] ) if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; uncompress ( aa->name ); - } + } } - if (unzFailsExist) { - setExit(2); + if (unzFailsExist) { + setExit(2); exit(exitValue); } - } + } else { testFailsExist = False; @@ -2070,11 +2070,11 @@ IntNative main ( IntNative argc, Char *argv[] ) } else { decode = True; for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) { decode = False; continue; } + if (ISFLAG("--")) { decode = False; continue; } if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; testf ( aa->name ); - } + } } if (testFailsExist && noisy) { fprintf ( stderr, @@ -2087,7 +2087,7 @@ IntNative main ( IntNative argc, Char *argv[] ) } } - /* Free the argument list memory to mollify leak detectors + /* Free the argument list memory to mollify leak detectors (eg) Purify, Checker. Serves no other useful purpose. */ aa = argList; diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c index d1b8da845db..5cd405dd4cb 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c @@ -5,7 +5,7 @@ /*-----------------------------------------------------------*/ /*-- - This program is bzip2recover, a program to attempt data + This program is bzip2recover, a program to attempt data salvage from damaged files created by the accompanying bzip2-1.0.3 program. @@ -18,16 +18,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -107,7 +107,7 @@ MaybeUInt64 bytesIn = 0; #define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_0 0x30 /* '0' */ - + /*---------------------------------------------------*/ /*--- I/O errors ---*/ @@ -160,7 +160,7 @@ void tooManyBlocks ( Int32 max_handled_blocks ) fprintf ( stderr, "%s: and cannot be handled. To fix, increase\n", progName ); - fprintf ( stderr, + fprintf ( stderr, "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n", progName ); exit ( 1 ); @@ -344,7 +344,7 @@ Int32 main ( Int32 argc, Char** argv ) strcpy ( progName, argv[0] ); inFileName[0] = outFileName[0] = 0; - fprintf ( stderr, + fprintf ( stderr, "bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.\n" ); if (argc != 2) { @@ -352,18 +352,18 @@ Int32 main ( Int32 argc, Char** argv ) progName, progName ); switch (sizeof(MaybeUInt64)) { case 8: - fprintf(stderr, + fprintf(stderr, "\trestrictions on size of recovered file: None\n"); break; case 4: - fprintf(stderr, + fprintf(stderr, "\trestrictions on size of recovered file: 512 MB\n"); - fprintf(stderr, + fprintf(stderr, "\tto circumvent, recompile with MaybeUInt64 as an\n" "\tunsigned 64-bit int.\n"); break; default: - fprintf(stderr, + fprintf(stderr, "\tsizeof(MaybeUInt64) is not 4 or 8 -- " "configuration error.\n"); break; @@ -372,7 +372,7 @@ Int32 main ( Int32 argc, Char** argv ) } if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) { - fprintf ( stderr, + fprintf ( stderr, "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n", progName, (int)strlen(argv[1]) ); exit(1); @@ -404,7 +404,7 @@ Int32 main ( Int32 argc, Char** argv ) (bitsRead - bStart[currBlock]) >= 40) { bEnd[currBlock] = bitsRead-1; if (currBlock > 0) - fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT + fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT " to " MaybeUInt64_FMT " (incomplete)\n", currBlock, bStart[currBlock], bEnd[currBlock] ); } else @@ -413,10 +413,10 @@ Int32 main ( Int32 argc, Char** argv ) } buffHi = (buffHi << 1) | (buffLo >> 31); buffLo = (buffLo << 1) | (b & 1); - if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI + if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI && buffLo == BLOCK_HEADER_LO) - || - ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI + || + ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI && buffLo == BLOCK_ENDMARK_LO) ) { if (bitsRead > 49) { @@ -425,8 +425,8 @@ Int32 main ( Int32 argc, Char** argv ) bEnd[currBlock] = 0; } if (currBlock > 0 && - (bEnd[currBlock] - bStart[currBlock]) >= 130) { - fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT + (bEnd[currBlock] - bStart[currBlock]) >= 130) { + fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT " to " MaybeUInt64_FMT "\n", rbCtr+1, bStart[currBlock], bEnd[currBlock] ); rbStart[rbCtr] = bStart[currBlock]; @@ -472,7 +472,7 @@ Int32 main ( Int32 argc, Char** argv ) if (b == 2) break; buffHi = (buffHi << 1) | (buffLo >> 31); buffLo = (buffLo << 1) | (b & 1); - if (bitsRead == 47+rbStart[wrBlock]) + if (bitsRead == 47+rbStart[wrBlock]) blockCRC = (buffHi << 16) | (buffLo >> 16); if (outFile != NULL && bitsRead >= rbStart[wrBlock] @@ -494,11 +494,11 @@ Int32 main ( Int32 argc, Char** argv ) wrBlock++; } else if (bitsRead == rbStart[wrBlock]) { - /* Create the output file name, correctly handling leading paths. + /* Create the output file name, correctly handling leading paths. (31.10.2001 by Sergey E. Kusikov) */ Char* split; Int32 ofs, k; - for (k = 0; k < BZ_MAX_FILENAME; k++) + for (k = 0; k < BZ_MAX_FILENAME; k++) outFileName[k] = 0; strcpy (outFileName, inFileName); split = strrchr (outFileName, BZ_SPLIT_SYM); @@ -506,8 +506,8 @@ Int32 main ( Int32 argc, Char** argv ) split = outFileName; } else { ++split; - } - /* Now split points to the start of the basename. */ + } + /* Now split points to the start of the basename. */ ofs = split - outFileName; sprintf (split, "rec%5d", wrBlock+1); for (p = split; *p != 0; p++) if (*p == ' ') *p = '0'; @@ -525,9 +525,9 @@ Int32 main ( Int32 argc, Char** argv ) exit(1); } bsWr = bsOpenWriteStream ( outFile ); - bsPutUChar ( bsWr, BZ_HDR_B ); - bsPutUChar ( bsWr, BZ_HDR_Z ); - bsPutUChar ( bsWr, BZ_HDR_h ); + bsPutUChar ( bsWr, BZ_HDR_B ); + bsPutUChar ( bsWr, BZ_HDR_Z ); + bsPutUChar ( bsWr, BZ_HDR_h ); bsPutUChar ( bsWr, BZ_HDR_0 + 9 ); bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 ); bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 ); diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c index 785306827fb..195f51a7840 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -86,7 +86,7 @@ #ifndef BZ_NO_STDIO void BZ2_bz__AssertH__fail ( int errcode ) { - fprintf(stderr, + fprintf(stderr, "\n\nbzip2/libbzip2: internal error number %d.\n" "This is a bug in bzip2/libbzip2, %s.\n" "Please report it to me at: jseward@bzip.org. If this happened\n" @@ -191,8 +191,8 @@ Bool isempty_RL ( EState* s ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzCompressInit) + ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ) @@ -202,7 +202,7 @@ int BZ_API(BZ2_bzCompressInit) if (!bz_config_ok()) return BZ_CONFIG_ERROR; - if (strm == NULL || + if (strm == NULL || blockSize100k < 1 || blockSize100k > 9 || workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; @@ -345,7 +345,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- no input? --*/ if (s->strm->avail_in == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -363,7 +363,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- flush/finish end? --*/ if (s->avail_in_expect == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -409,18 +409,18 @@ Bool handle_compress ( bz_stream* strm ) Bool progress_in = False; Bool progress_out = False; EState* s = strm->state; - + while (True) { if (s->state == BZ_S_OUTPUT) { progress_out |= copy_output_until_stop ( s ); if (s->state_out_pos < s->numZ) break; - if (s->mode == BZ_M_FINISHING && + if (s->mode == BZ_M_FINISHING && s->avail_in_expect == 0 && isempty_RL(s)) break; prepare_new_block ( s ); s->state = BZ_S_INPUT; - if (s->mode == BZ_M_FLUSHING && + if (s->mode == BZ_M_FLUSHING && s->avail_in_expect == 0 && isempty_RL(s)) break; } @@ -469,9 +469,9 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) if (action == BZ_RUN) { progress = handle_compress ( strm ); return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; - } + } else - if (action == BZ_FLUSH) { + if (action == BZ_FLUSH) { s->avail_in_expect = strm->avail_in; s->mode = BZ_M_FLUSHING; goto preswitch; @@ -482,12 +482,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) s->mode = BZ_M_FINISHING; goto preswitch; } - else + else return BZ_PARAM_ERROR; case BZ_M_FLUSHING: if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (s->avail_in_expect > 0 || !isempty_RL(s) || @@ -497,7 +497,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) case BZ_M_FINISHING: if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (!progress) return BZ_SEQUENCE_ERROR; @@ -524,7 +524,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) if (s->ftab != NULL) BZFREE(s->ftab); BZFREE(strm->state); - strm->state = NULL; + strm->state = NULL; return BZ_OK; } @@ -535,8 +535,8 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) /*---------------------------------------------------*/ /*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzDecompressInit) + ( bz_stream* strm, int verbosity, int small ) { @@ -601,34 +601,34 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return False; - + /* Only caused by corrupt data stream? */ if (s->nblock_used > s->save_nblock+1) return True; - + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -665,7 +665,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) } s_state_out_len_eq_one: { - if (cs_avail_out == 0) { + if (cs_avail_out == 0) { c_state_out_len = 1; goto return_notr; }; *( (UChar*)(cs_next_out) ) = c_state_out_ch; @@ -673,7 +673,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) cs_next_out++; cs_avail_out--; } - } + } /* Only caused by corrupt data stream? */ if (c_nblock_used > s_save_nblockPP) return True; @@ -681,25 +681,25 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) /* can a new run be started? */ if (c_nblock_used == s_save_nblockPP) { c_state_out_len = 0; goto return_notr; - }; + }; c_state_out_ch = c_k0; BZ_GET_FAST_C(k1); c_nblock_used++; - if (k1 != c_k0) { - c_k0 = k1; goto s_state_out_len_eq_one; + if (k1 != c_k0) { + c_k0 = k1; goto s_state_out_len_eq_one; }; - if (c_nblock_used == s_save_nblockPP) + if (c_nblock_used == s_save_nblockPP) goto s_state_out_len_eq_one; - + c_state_out_len = 2; BZ_GET_FAST_C(k1); c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + c_state_out_len = 3; BZ_GET_FAST_C(k1); c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + BZ_GET_FAST_C(k1); c_nblock_used++; c_state_out_len = ((Int32)k1) + 4; BZ_GET_FAST_C(c_k0); c_nblock_used++; @@ -767,37 +767,37 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return False; /* Only caused by corrupt data stream? */ if (s->nblock_used > s->save_nblock+1) return True; - + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -816,30 +816,30 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return False; /* Only caused by corrupt data stream? */ if (s->nblock_used > s->save_nblock+1) return True; - + s->state_out_len = 1; s->state_out_ch = s->k0; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + BZ_GET_SMALL(k1); s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; BZ_GET_SMALL(s->k0); s->nblock_used++; @@ -868,14 +868,14 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) if (corrupt) return BZ_DATA_ERROR; if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { BZ_FINALISE_CRC ( s->calculatedBlockCRC ); - if (s->verbosity >= 3) - VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, + if (s->verbosity >= 3) + VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, s->calculatedBlockCRC ); if (s->verbosity >= 2) VPrintf0 ( "]" ); if (s->calculatedBlockCRC != s->storedBlockCRC) return BZ_DATA_ERROR; - s->calculatedCombinedCRC - = (s->calculatedCombinedCRC << 1) | + s->calculatedCombinedCRC + = (s->calculatedCombinedCRC << 1) | (s->calculatedCombinedCRC >> 31); s->calculatedCombinedCRC ^= s->calculatedBlockCRC; s->state = BZ_X_BLKHDR_1; @@ -887,7 +887,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) Int32 r = BZ2_decompress ( s ); if (r == BZ_STREAM_END) { if (s->verbosity >= 3) - VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", + VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", s->storedCombinedCRC, s->calculatedCombinedCRC ); if (s->calculatedCombinedCRC != s->storedCombinedCRC) return BZ_DATA_ERROR; @@ -934,7 +934,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) if (bzf != NULL) bzf->lastErr = eee; \ } -typedef +typedef struct { FILE* handle; Char buf[BZ_MAX_UNUSED]; @@ -958,10 +958,10 @@ static Bool myfeof ( FILE* f ) /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzWriteOpen) - ( int* bzerror, - FILE* f, - int blockSize100k, +BZFILE* BZ_API(BZ2_bzWriteOpen) + ( int* bzerror, + FILE* f, + int blockSize100k, int verbosity, int workFactor ) { @@ -993,23 +993,23 @@ BZFILE* BZ_API(BZ2_bzWriteOpen) bzf->strm.opaque = NULL; if (workFactor == 0) workFactor = 30; - ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, + ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) { BZ_SETERR(ret); free(bzf); return NULL; }; bzf->strm.avail_in = 0; bzf->initialisedOk = True; - return bzf; + return bzf; } /*---------------------------------------------------*/ void BZ_API(BZ2_bzWrite) - ( int* bzerror, - BZFILE* b, - void* buf, + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, n2, ret; @@ -1038,7 +1038,7 @@ void BZ_API(BZ2_bzWrite) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -1052,20 +1052,20 @@ void BZ_API(BZ2_bzWrite) /*---------------------------------------------------*/ void BZ_API(BZ2_bzWriteClose) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ) { - BZ2_bzWriteClose64 ( bzerror, b, abandon, + BZ2_bzWriteClose64 ( bzerror, b, abandon, nbytes_in, NULL, nbytes_out, NULL ); } void BZ_API(BZ2_bzWriteClose64) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, @@ -1097,7 +1097,7 @@ void BZ_API(BZ2_bzWriteClose64) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -1129,9 +1129,9 @@ void BZ_API(BZ2_bzWriteClose64) /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzReadOpen) - ( int* bzerror, - FILE* f, +BZFILE* BZ_API(BZ2_bzReadOpen) + ( int* bzerror, + FILE* f, int verbosity, int small, void* unused, @@ -1142,7 +1142,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) BZ_SETERR(BZ_OK); - if (f == NULL || + if (f == NULL || (small != 0 && small != 1) || (verbosity < 0 || verbosity > 4) || (unused == NULL && nUnused != 0) || @@ -1153,7 +1153,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) { BZ_SETERR(BZ_IO_ERROR); return NULL; }; bzf = malloc ( sizeof(bzFile) ); - if (bzf == NULL) + if (bzf == NULL) { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; BZ_SETERR(BZ_OK); @@ -1165,7 +1165,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.bzalloc = NULL; bzf->strm.bzfree = NULL; bzf->strm.opaque = NULL; - + while (nUnused > 0) { bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; unused = ((void*)( 1 + ((UChar*)(unused)) )); @@ -1180,7 +1180,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.next_in = bzf->buf; bzf->initialisedOk = True; - return bzf; + return bzf; } @@ -1203,10 +1203,10 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzRead) - ( int* bzerror, - BZFILE* b, - void* buf, +int BZ_API(BZ2_bzRead) + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, ret; @@ -1228,11 +1228,11 @@ int BZ_API(BZ2_bzRead) while (True) { - if (ferror(bzf->handle)) + if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { - n = fread ( bzf->buf, sizeof(UChar), + n = fread ( bzf->buf, sizeof(UChar), BZ_MAX_UNUSED, bzf->handle ); if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; @@ -1246,7 +1246,7 @@ int BZ_API(BZ2_bzRead) if (ret != BZ_OK && ret != BZ_STREAM_END) { BZ_SETERR(ret); return 0; }; - if (ret == BZ_OK && myfeof(bzf->handle) && + if (ret == BZ_OK && myfeof(bzf->handle) && bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; @@ -1255,7 +1255,7 @@ int BZ_API(BZ2_bzRead) return len - bzf->strm.avail_out; }; if (bzf->strm.avail_out == 0) { BZ_SETERR(BZ_OK); return len; }; - + } return 0; /*not reached*/ @@ -1263,10 +1263,10 @@ int BZ_API(BZ2_bzRead) /*---------------------------------------------------*/ -void BZ_API(BZ2_bzReadGetUnused) - ( int* bzerror, - BZFILE* b, - void** unused, +void BZ_API(BZ2_bzReadGetUnused) + ( int* bzerror, + BZFILE* b, + void** unused, int* nUnused ) { bzFile* bzf = (bzFile*)b; @@ -1289,30 +1289,30 @@ void BZ_API(BZ2_bzReadGetUnused) /*---------------------------------------------------*/ /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, + int blockSize100k, + int verbosity, int workFactor ) { bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) + workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; if (workFactor == 0) workFactor = 30; strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, + ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; @@ -1326,7 +1326,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; + *destLen -= strm.avail_out; BZ2_bzCompressEnd ( &strm ); return BZ_OK; @@ -1341,10 +1341,10 @@ int BZ_API(BZ2_bzBuffToBuffCompress) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffDecompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffDecompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, int small, int verbosity ) @@ -1352,10 +1352,10 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || (small != 0 && small != 1) || - verbosity < 0 || verbosity > 4) + verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; strm.bzalloc = NULL; @@ -1385,11 +1385,11 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) } else { BZ2_bzDecompressEnd ( &strm ); return BZ_OUTBUFF_FULL; - }; + }; errhandler: BZ2_bzDecompressEnd ( &strm ); - return ret; + return ret; } @@ -1442,7 +1442,7 @@ BZFILE * bzopen_or_bzdopen int verbosity = 0; int workFactor = 30; int smallMode = 0; - int nUnused = 0; + int nUnused = 0; if (mode == NULL) return NULL; while (*mode) { @@ -1482,7 +1482,7 @@ BZFILE * bzopen_or_bzdopen if (writing) { /* Guard against total chaos and anarchy -- JRS */ if (blockSize100k < 1) blockSize100k = 1; - if (blockSize100k > 9) blockSize100k = 9; + if (blockSize100k > 9) blockSize100k = 9; bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, verbosity,workFactor); } else { @@ -1561,7 +1561,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) { int bzerr; FILE *fp = ((bzFile *)b)->handle; - + if (b==NULL) {return;} if(((bzFile*)b)->writing){ BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); @@ -1579,7 +1579,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) /*---------------------------------------------------*/ /*-- - return last error code + return last error code --*/ static char *bzerrorstrings[] = { "OK" diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h index 25b2d140eb2..323724394a2 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -85,7 +85,7 @@ extern "C" { #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) -typedef +typedef struct { char *next_in; unsigned int avail_in; @@ -102,7 +102,7 @@ typedef void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; - } + } bz_stream; @@ -137,34 +137,34 @@ typedef /*-- Core (low-level) library functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action ); -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, int small ); -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm ); @@ -176,64 +176,64 @@ BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( typedef void BZFILE; -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, int small, - void* unused, - int nUnused + void* unused, + int nUnused ); -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b ); -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused ); -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); #endif @@ -241,23 +241,23 @@ BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( /*-- Utility functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int small, - int verbosity + int small, + int verbosity ); @@ -285,17 +285,17 @@ BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); - + BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( @@ -307,7 +307,7 @@ BZ_EXTERN void BZ_API(BZ2_bzclose) ( ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, + BZFILE *b, int *errnum ); #endif @@ -321,4 +321,3 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( /*-------------------------------------------------------------*/ /*--- end bzlib.h ---*/ /*-------------------------------------------------------------*/ - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h index 85b20c6e8a6..ca76fe62b3b 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -91,7 +91,7 @@ typedef unsigned short UInt16; #ifndef __GNUC__ #define __inline__ /* */ -#endif +#endif #ifndef BZ_NO_STDIO extern void BZ2_bz__AssertH__fail ( int errcode ); @@ -143,7 +143,7 @@ extern void bz_internal_error ( int errcode ); #define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_0 0x30 /* '0' */ - + /*-- Constants for the back end. --*/ #define BZ_MAX_ALPHA_SIZE 258 @@ -303,19 +303,19 @@ typedef /*-- externs for compression. --*/ -extern void +extern void BZ2_blockSort ( EState* ); -extern void +extern void BZ2_compressBlock ( EState*, Bool ); -extern void +extern void BZ2_bsInitWrite ( EState* ); -extern void +extern void BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); -extern void +extern void BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); @@ -459,7 +459,7 @@ typedef Int32 save_N; Int32 save_curr; Int32 save_zt; - Int32 save_zn; + Int32 save_zn; Int32 save_zvec; Int32 save_zj; Int32 save_gSel; @@ -509,13 +509,13 @@ typedef /*-- externs for decompression. --*/ -extern Int32 +extern Int32 BZ2_indexIntoF ( Int32, Int32* ); -extern Int32 +extern Int32 BZ2_decompress ( DState* ); -extern void +extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); @@ -535,4 +535,3 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, /*-------------------------------------------------------------*/ /*--- end bzlib_private.h ---*/ /*-------------------------------------------------------------*/ - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c b/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c index c328ef137fd..7e0c29155ab 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -66,7 +66,7 @@ 0.9.0a/b -- no changes in this file. 0.9.0c - * changed setting of nGroups in sendMTFValues() so as to + * changed setting of nGroups in sendMTFValues() so as to do a bit better on small files --*/ @@ -169,11 +169,11 @@ void generateMTFValues ( EState* s ) Int32 wr; Int32 EOB; - /* + /* After sorting (eg, here), s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, and - ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] + ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] holds the original block data. The first thing to do is generate the MTF values, @@ -188,7 +188,7 @@ void generateMTFValues ( EState* s ) (UChar*) (&((UChar*)s->arr2)[s->nblock]) These storage aliases are set up in bzCompressInit(), - except for the last one, which is arranged in + except for the last one, which is arranged in compressBlock(). */ UInt32* ptr = s->ptr; @@ -211,7 +211,7 @@ void generateMTFValues ( EState* s ) ll_i = s->unseqToSeq[block[j]]; AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); - if (yy[0] == ll_i) { + if (yy[0] == ll_i) { zPend++; } else { @@ -219,11 +219,11 @@ void generateMTFValues ( EState* s ) zPend--; while (True) { if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; @@ -257,11 +257,11 @@ void generateMTFValues ( EState* s ) zPend--; while (True) { if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; @@ -304,7 +304,7 @@ void sendMTFValues ( EState* s ) if (s->verbosity >= 3) VPrintf3( " %d in block, %d after MTF & 1-2 coding, " - "%d+2 syms in use\n", + "%d+2 syms in use\n", s->nblock, s->nMTF, s->nInUse ); alphaSize = s->nInUse+2; @@ -321,7 +321,7 @@ void sendMTFValues ( EState* s ) nGroups = 6; /*--- Generate an initial set of coding tables ---*/ - { + { Int32 nPart, remF, tFreq, aFreq; nPart = nGroups; @@ -336,8 +336,8 @@ void sendMTFValues ( EState* s ) aFreq += s->mtfFreq[ge]; } - if (ge > gs - && nPart != nGroups && nPart != 1 + if (ge > gs + && nPart != nGroups && nPart != 1 && ((nGroups-nPart) % 2 == 1)) { aFreq -= s->mtfFreq[ge]; ge--; @@ -346,21 +346,21 @@ void sendMTFValues ( EState* s ) if (s->verbosity >= 3) VPrintf5( " initial group %d, [%d .. %d], " "has %d syms (%4.1f%%)\n", - nPart, gs, ge, aFreq, + nPart, gs, ge, aFreq, (100.0 * (float)aFreq) / (float)(s->nMTF) ); - + for (v = 0; v < alphaSize; v++) - if (v >= gs && v <= ge) + if (v >= gs && v <= ge) s->len[nPart-1][v] = BZ_LESSER_ICOST; else s->len[nPart-1][v] = BZ_GREATER_ICOST; - + nPart--; gs = ge+1; remF -= aFreq; } } - /*--- + /*--- Iterate up to BZ_N_ITERS times to improve the tables. ---*/ for (iter = 0; iter < BZ_N_ITERS; iter++) { @@ -373,14 +373,14 @@ void sendMTFValues ( EState* s ) /*--- Set up an auxiliary length table which is used to fast-track - the common case (nGroups == 6). + the common case (nGroups == 6). ---*/ if (nGroups == 6) { for (v = 0; v < alphaSize; v++) { s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; - } + } } nSelectors = 0; @@ -390,10 +390,10 @@ void sendMTFValues ( EState* s ) /*--- Set group start & end marks. --*/ if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; + ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; - /*-- + /*-- Calculate the cost of this group as coded by each of the coding tables. --*/ @@ -429,14 +429,14 @@ void sendMTFValues ( EState* s ) cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; } else { - /*--- slow version which correctly handles all situations ---*/ - for (i = gs; i <= ge; i++) { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) { UInt16 icv = mtfv[i]; for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; } } - - /*-- + + /*-- Find the coding table which is best for this group, and record its identity in the selector table. --*/ @@ -448,7 +448,7 @@ void sendMTFValues ( EState* s ) s->selector[nSelectors] = bt; nSelectors++; - /*-- + /*-- Increment the symbol frequencies for the selected table. --*/ if (nGroups == 6 && 50 == ge-gs+1) { @@ -470,7 +470,7 @@ void sendMTFValues ( EState* s ) # undef BZ_ITUR } else { - /*--- slow version which correctly handles all situations ---*/ + /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) s->rfreq[bt][ mtfv[i] ]++; } @@ -478,7 +478,7 @@ void sendMTFValues ( EState* s ) gs = ge+1; } if (s->verbosity >= 3) { - VPrintf2 ( " pass %d: size is %d, grp uses are ", + VPrintf2 ( " pass %d: size is %d, grp uses are ", iter+1, totc/8 ); for (t = 0; t < nGroups; t++) VPrintf1 ( "%d ", fave[t] ); @@ -488,10 +488,10 @@ void sendMTFValues ( EState* s ) /*-- Recompute the tables based on the accumulated frequencies. --*/ - /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See + /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See comment in huffman.c for details. */ for (t = 0; t < nGroups; t++) - BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), + BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/ ); } @@ -531,19 +531,19 @@ void sendMTFValues ( EState* s ) } AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); AssertH ( !(minLen < 1), 3005 ); - BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), + BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); } /*--- Transmit the mapping table. ---*/ - { + { Bool inUse16[16]; for (i = 0; i < 16; i++) { inUse16[i] = False; for (j = 0; j < 16; j++) if (s->inUse[i * 16 + j]) inUse16[i] = True; } - + nBytes = s->numZ; for (i = 0; i < 16; i++) if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); @@ -554,7 +554,7 @@ void sendMTFValues ( EState* s ) if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); } - if (s->verbosity >= 3) + if (s->verbosity >= 3) VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); } @@ -562,7 +562,7 @@ void sendMTFValues ( EState* s ) nBytes = s->numZ; bsW ( s, 3, nGroups ); bsW ( s, 15, nSelectors ); - for (i = 0; i < nSelectors; i++) { + for (i = 0; i < nSelectors; i++) { for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); bsW(s,1,0); } @@ -591,14 +591,14 @@ void sendMTFValues ( EState* s ) gs = 0; while (True) { if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; + ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; AssertH ( s->selector[selCtr] < nGroups, 3006 ); if (nGroups == 6 && 50 == ge-gs+1) { /*--- fast track the common case ---*/ UInt16 mtfv_i; - UChar* s_len_sel_selCtr + UChar* s_len_sel_selCtr = &(s->len[s->selector[selCtr]][0]); Int32* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]); @@ -623,9 +623,9 @@ void sendMTFValues ( EState* s ) # undef BZ_ITAH } else { - /*--- slow version which correctly handles all situations ---*/ + /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { - bsW ( s, + bsW ( s, s->len [s->selector[selCtr]] [mtfv[i]], s->code [s->selector[selCtr]] [mtfv[i]] ); } @@ -680,8 +680,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block ) /*-- Now the block's CRC, so it is in a known place. --*/ bsPutUInt32 ( s, s->blockCRC ); - /*-- - Now a single bit indicating (non-)randomisation. + /*-- + Now a single bit indicating (non-)randomisation. As of version 0.9.5, we use a better sorting algorithm which makes randomisation unnecessary. So always set the randomised bit to 'no'. Of course, the decoder diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c b/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c index 7b394805429..b6dadfc62f2 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c b/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c index 855b98bb631..81c3d2cc3f4 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -167,7 +167,7 @@ Int32 BZ2_decompress ( DState* s ) Int32 N; Int32 curr; Int32 zt; - Int32 zn; + Int32 zn; Int32 zvec; Int32 zj; Int32 gSel; @@ -221,7 +221,7 @@ Int32 BZ2_decompress ( DState* s ) N = s->save_N; curr = s->save_curr; zt = s->save_zt; - zn = s->save_zn; + zn = s->save_zn; zvec = s->save_zvec; zj = s->save_zj; gSel = s->save_gSel; @@ -244,14 +244,14 @@ Int32 BZ2_decompress ( DState* s ) if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) - if (s->blockSize100k < (BZ_HDR_0 + 1) || + if (s->blockSize100k < (BZ_HDR_0 + 1) || s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); s->blockSize100k -= BZ_HDR_0; if (s->smallDecompress) { s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); - s->ll4 = BZALLOC( - ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) + s->ll4 = BZALLOC( + ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); } else { @@ -277,7 +277,7 @@ Int32 BZ2_decompress ( DState* s ) s->currBlockNo++; if (s->verbosity >= 2) VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); - + s->storedBlockCRC = 0; GET_UCHAR(BZ_X_BCRC_1, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); @@ -300,14 +300,14 @@ Int32 BZ2_decompress ( DState* s ) if (s->origPtr < 0) RETURN(BZ_DATA_ERROR); - if (s->origPtr > 10 + 100000*s->blockSize100k) + if (s->origPtr > 10 + 100000*s->blockSize100k) RETURN(BZ_DATA_ERROR); /*--- Receive the mapping table ---*/ for (i = 0; i < 16; i++) { GET_BIT(BZ_X_MAPPING_1, uc); - if (uc == 1) - s->inUse16[i] = True; else + if (uc == 1) + s->inUse16[i] = True; else s->inUse16[i] = False; } @@ -343,7 +343,7 @@ Int32 BZ2_decompress ( DState* s ) { UChar pos[BZ_N_GROUPS], tmp, v; for (v = 0; v < nGroups; v++) pos[v] = v; - + for (i = 0; i < nSelectors; i++) { v = s->selectorMtf[i]; tmp = pos[v]; @@ -376,10 +376,10 @@ Int32 BZ2_decompress ( DState* s ) if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } - BZ2_hbCreateDecodeTables ( - &(s->limit[t][0]), - &(s->base[t][0]), - &(s->perm[t][0]), + BZ2_hbCreateDecodeTables ( + &(s->limit[t][0]), + &(s->base[t][0]), + &(s->perm[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); @@ -471,23 +471,23 @@ Int32 BZ2_decompress ( DState* s ) s->mtfa[(z)-3] = s->mtfa[(z)-4]; nn -= 4; } - while (nn > 0) { - s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; + while (nn > 0) { + s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; }; s->mtfa[pp] = uc; - } else { + } else { /* general case */ lno = nn / MTFL_SIZE; off = nn % MTFL_SIZE; pp = s->mtfbase[lno] + off; uc = s->mtfa[pp]; - while (pp > s->mtfbase[lno]) { - s->mtfa[pp] = s->mtfa[pp-1]; pp--; + while (pp > s->mtfbase[lno]) { + s->mtfa[pp] = s->mtfa[pp-1]; pp--; }; s->mtfbase[lno]++; while (lno > 0) { s->mtfbase[lno]--; - s->mtfa[s->mtfbase[lno]] + s->mtfa[s->mtfbase[lno]] = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; lno--; } @@ -569,7 +569,7 @@ Int32 BZ2_decompress ( DState* s ) if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_SMALL(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_SMALL(s->k0); s->nblock_used++; } @@ -588,7 +588,7 @@ Int32 BZ2_decompress ( DState* s ) if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_FAST(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_FAST(s->k0); s->nblock_used++; } @@ -657,7 +657,7 @@ Int32 BZ2_decompress ( DState* s ) s->save_gBase = gBase; s->save_gPerm = gPerm; - return retVal; + return retVal; } diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c b/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c index 2049906ea53..eb86bb61a59 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c @@ -19,7 +19,7 @@ #ifdef _WIN32 -#define BZ2_LIBNAME "libbz2-1.0.2.DLL" +#define BZ2_LIBNAME "libbz2-1.0.2.DLL" #include <windows.h> static int BZ2DLLLoaded = 0; diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c b/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c index 871eed4f23e..5bf190be9a1 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -100,7 +100,7 @@ /*---------------------------------------------------*/ -void BZ2_hbMakeCodeLengths ( UChar *len, +void BZ2_hbMakeCodeLengths ( UChar *len, Int32 *freq, Int32 alphaSize, Int32 maxLen ) @@ -114,7 +114,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; - Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; + Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; for (i = 0; i < alphaSize; i++) weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; @@ -136,7 +136,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, } AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); - + while (nHeap > 1) { n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); @@ -159,7 +159,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, len[i-1] = j; if (j > maxLen) tooLong = True; } - + if (! tooLong) break; /* 17 Oct 04: keep-going condition for the following loop used diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c b/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c index b8e74070f82..940462d693d 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -63,58 +63,58 @@ /*---------------------------------------------*/ -Int32 BZ2_rNums[512] = { - 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, - 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, - 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, - 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, - 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, - 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, - 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, - 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, - 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, - 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, - 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, - 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, - 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, - 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, - 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, - 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, - 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, - 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, - 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, - 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, - 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, - 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, - 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, - 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, - 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, - 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, - 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, - 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, - 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, - 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, - 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, - 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, - 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, - 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, - 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, - 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, - 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, - 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, - 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, - 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, - 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, - 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, - 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, - 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, - 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, - 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, - 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, - 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, - 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, - 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, - 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, +Int32 BZ2_rNums[512] = { + 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, + 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, + 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, + 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, + 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, + 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, + 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, + 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, + 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, + 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, + 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, + 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, + 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, + 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, + 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, + 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, + 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, + 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, + 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, + 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, + 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, + 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, + 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, + 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, + 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, + 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, + 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, + 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, + 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, + 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, + 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, + 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, + 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, + 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, + 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, + 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, + 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, + 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, + 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, + 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, + 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, + 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, + 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, + 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, + 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, + 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, + 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, + 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, + 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, + 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, + 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 936, 638 }; diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c b/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c index 6caca9baa94..7934e765818 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c @@ -4,7 +4,7 @@ support for large files (> 2GB) in a reasonable amount of time. I suggest you use the undocumented --exponential option to bzip2 when compressing the resulting file; this saves a bit of - time. Note: *don't* bother with --exponential when compressing + time. Note: *don't* bother with --exponential when compressing Real Files; it'll just waste a lot of CPU time :-) (but is otherwise harmless). */ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c b/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c index 623aacc9f3f..f0f17fcca53 100644 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c +++ b/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c @@ -1,11 +1,11 @@ /* A test program written to test robustness to decompression of - corrupted data. Usage is + corrupted data. Usage is unzcrash filename and the program will read the specified file, compress it (in memory), and then repeatedly decompress it, each time with a different bit of the compressed data inverted, so as to test all possible one-bit errors. - This should not cause any invalid memory accesses. If it does, + This should not cause any invalid memory accesses. If it does, I want to know about it! p.s. As you can see from the above description, the process is @@ -100,9 +100,9 @@ int main ( int argc, char** argv ) return 1; } else { for (i = 0; i < nOut; i++) - if (inbuf[i] != outbuf[i]) { - fprintf(stderr, "mismatch at %d\n", i ); - return 1; + if (inbuf[i] != outbuf[i]) { + fprintf(stderr, "mismatch at %d\n", i ); + return 1; } if (i == nOut) fprintf(stderr, "really ok!\n" ); } diff --git a/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp b/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp index d4410dc9beb..612fcb08386 100644 --- a/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp +++ b/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp @@ -14,10 +14,10 @@ /* 19.11.03 1.01 Dan Big endian handling */ /* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ /*****************************************************************************/ - + #include <assert.h> #include <string.h> - + #include "huff.h" // Special for Mac - we have to know if normal pointer greater or less @@ -29,10 +29,10 @@ static long mul = 1; #define PTR_INVALID(ptr) (((LONG_PTR)(ptr) * mul) < 0) #define PTR_INVALID_OR_NULL(ptr) (((LONG_PTR)(ptr) * mul) <= 0) - + //----------------------------------------------------------------------------- // Methods of the THTreeItem struct - + // 1501DB70 THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) { @@ -40,83 +40,83 @@ THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) pLast = this + 1; return pLast; } - + // Gets previous Huffman tree item (?) THTreeItem * THTreeItem::GetPrevItem(LONG_PTR value) { if(PTR_INVALID(prev)) return PTR_NOT(prev); - + if(value == -1 || PTR_INVALID(value)) value = (long)(this - next->prev); return prev + value; - + // OLD VERSION // if(PTR_INT(value) < 0) // value = PTR_INT((item - item->next->prev)); // return (THTreeItem *)((char *)prev + value); } - + // 1500F5E0 void THTreeItem::ClearItemLinks() { next = prev = NULL; } - + // 1500BC90 void THTreeItem::RemoveItem() { THTreeItem * pTemp; // EDX - + if(next != NULL) { pTemp = prev; - + if(PTR_INVALID_OR_NULL(pTemp)) pTemp = PTR_NOT(pTemp); else pTemp += (this - next->prev); - + pTemp->next = next; next->prev = prev; next = prev = NULL; } } - + /* // OLD VERSION : Removes item from the tree (?) static void RemoveItem(THTreeItem * item) { THTreeItem * next = item->next; // ESI THTreeItem * prev = item->prev; // EDX - + if(next == NULL) return; - + if(PTR_INT(prev) < 0) prev = PTR_NOT(prev); else // ??? usually item == next->prev, so what is it ? prev = (THTreeItem *)((unsigned char *)prev + (unsigned long)((unsigned char *)item - (unsigned char *)(next->prev))); - + // Remove HTree item from the chain prev->next = next; // Sets the 'first' pointer next->prev = item->prev; - + // Invalidate pointers item->next = NULL; item->prev = NULL; } */ - + //----------------------------------------------------------------------------- // TOutputStream functions - + void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) { dwBitBuff |= (dwBuff << nBits); nBits += nPutBits; - + // Flush completed bytes while(nBits >= 8) { @@ -125,20 +125,20 @@ void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) *pbOutPos++ = (unsigned char)dwBitBuff; dwOutSize--; } - + dwBitBuff >>= 8; nBits -= 8; } } - + //----------------------------------------------------------------------------- // TInputStream functions - + // Gets one bit from input stream unsigned long TInputStream::GetBit() { unsigned long dwBit = (dwBitBuff & 1); - + dwBitBuff >>= 1; if(--nBits == 0) { @@ -147,8 +147,8 @@ unsigned long TInputStream::GetBit() nBits = 32; } return dwBit; -} - +} + // Gets 7 bits from the stream unsigned long TInputStream::Get7Bits() { @@ -158,32 +158,32 @@ unsigned long TInputStream::Get7Bits() pbInBuffer += sizeof(unsigned short); nBits += 16; } - + // Get 7 bits from input stream return (dwBitBuff & 0x7F); } - + // Gets the whole byte from the input stream. unsigned long TInputStream::Get8Bits() { unsigned long dwOneByte; - + if(nBits <= 8) { dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; pbInBuffer += sizeof(unsigned short); nBits += 16; } - + dwOneByte = (dwBitBuff & 0xFF); dwBitBuff >>= 8; nBits -= 8; return dwOneByte; } - + //----------------------------------------------------------------------------- // Functions for huffmann tree items - + // Inserts item into the tree (?) static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long where, THTreeItem * item2) { @@ -191,7 +191,7 @@ static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long w THTreeItem * prev = item->prev; // ESI - prev to the first item THTreeItem * prev2; // Pointer to previous item LONG_PTR next2; // Pointer to the next item - + // The same code like in RemoveItem(item); if(next != 0) // If the first item already has next one { @@ -199,20 +199,20 @@ static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long w prev = PTR_NOT(prev); else prev += (item - next->prev); - + // 150083C1 // Remove the item from the tree prev->next = next; next->prev = prev; - + // Invalidate 'prev' and 'next' pointer item->next = 0; item->prev = 0; } - + if(item2 == NULL) // EDX - If the second item is not entered, item2 = PTR_PTR(&itemPtr[1]); // take the first tree item - + switch(where) { case SWITCH_ITEMS : // Switch the two items @@ -221,68 +221,68 @@ static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long w item2->next->prev = item; item2->next = item; // Set the first item return; - + case INSERT_ITEM: // Insert as the last item item->next = item2; // Set next item (or pointer to pointer to first item) item->prev = item2->prev; // Set prev item (or last item in the tree) - + next2 = PTR_INT(itemPtr[0]);// Usually NULL prev2 = item2->prev; // Prev item to the second (or last tree item) - + if(PTR_INVALID(prev2)) { prev2 = PTR_NOT(prev); - + prev2->next = item; item2->prev = item; // Next after last item return; } - + if(PTR_INVALID(next2)) next2 = (long)(item2 - item2->next->prev); // next2 = (THTreeItem *)(unsigned long)((unsigned char *)item2 - (unsigned char *)(item2->next->prev)); - + // prev2 = (THTreeItem *)((char *)prev2 + (unsigned long)next2);// ??? prev2 += next2; prev2->next = item; item2->prev = item; // Set the next/last item return; - + default: return; } } - + //----------------------------------------------------------------------------- // THuffmannTree class functions - + THuffmannTree::THuffmannTree() { // We have to check if the "this" pointer is less than zero if((LONG_PTR)this < 0) mul = -1; } - + void THuffmannTree::InitTree(bool bCompression) { THTreeItem * pItem; unsigned int nCount; - + // Clear links for all the items in the tree for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--) pItem->ClearItemLinks(); - + pItem3050 = NULL; pItem3054 = PTR_PTR(&pItem3054); pItem3058 = PTR_NOT(pItem3054); - + pItem305C = NULL; pFirst = PTR_PTR(&pFirst); pLast = PTR_NOT(pFirst); - + offs0004 = 1; nItems = 0; - + // Clear all TQDecompress items. Do this only if preparing for decompression if(bCompression == false) { @@ -290,7 +290,7 @@ void THuffmannTree::InitTree(bool bCompression) qd3474[nCount].offs00 = 0; } } - + // Builds Huffman tree. Called with the first 8 bits loaded from input stream void THuffmannTree::BuildTree(unsigned int nCmpType) { @@ -299,55 +299,55 @@ void THuffmannTree::BuildTree(unsigned int nCmpType) unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630 THTreeItem * child1; unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i - + // Loop while pointer has a valid value while(PTR_VALID(pLast)) // ESI - Last entry { THTreeItem * temp; // EAX - + if(pLast->next != NULL) // ESI->next pLast->RemoveItem(); // EDI = &offs3054 pItem3058 = PTR_PTR(&pItem3054);// [EDI+4] pLast->prev = pItem3058; // EAX - + temp = PTR_PTR(&pItem3054)->GetPrevItem(PTR_INT(&pItem3050)); - + temp->next = pLast; pItem3054 = pLast; } - + // Clear all pointers in HTree item array memset(items306C, 0, sizeof(items306C)); - + maxByte = 0; // Greatest character found init to zero. itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array - + // Ensure we have low 8 bits only nCmpType &= 0xFF; byteArray = Table1502A630 + nCmpType * 258; // EDI also - + for(i = 0; i < 0x100; i++, itemPtr++) { THTreeItem * item = pItem3058; // Item to be created THTreeItem * pItem3 = pItem3058; unsigned char oneByte = byteArray[i]; - + // Skip all the bytes which are zero. if(byteArray[i] == 0) continue; - + // If not valid pointer, take the first available item in the array if(PTR_INVALID_OR_NULL(item)) item = &items0008[nItems++]; - + // Insert this item as the top of the tree InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); - + item->parent = NULL; // Invalidate child and parent item->child = NULL; *itemPtr = item; // Store pointer into pointer array - + item->dcmpByte = i; // Store counter item->byteValue = oneByte; // Store byte value if(oneByte >= maxByte) @@ -355,7 +355,7 @@ void THuffmannTree::BuildTree(unsigned int nCmpType) maxByte = oneByte; continue; } - + // Find the first item which has byte value greater than current one byte if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item { @@ -372,35 +372,35 @@ void THuffmannTree::BuildTree(unsigned int nCmpType) } } pItem3 = NULL; - + // 15006B09 _15006B09: if(item->next != NULL) item->RemoveItem(); - + // 15006B15 if(pItem3 == NULL) pItem3 = PTR_PTR(&pFirst); - + // 15006B1F item->next = pItem3->next; item->prev = pItem3->next->prev; pItem3->next->prev = item; pItem3->next = item; } - + // 15006B4A for(; i < 0x102; i++) { THTreeItem ** itemPtr = &items306C[i]; // EDI - + // 15006B59 THTreeItem * item = pItem3058; // ESI if(PTR_INVALID_OR_NULL(item)) item = &items0008[nItems++]; - + InsertItem(&pItem305C, item, INSERT_ITEM, NULL); - + // 15006B89 item->dcmpByte = i; item->byteValue = 1; @@ -408,42 +408,42 @@ void THuffmannTree::BuildTree(unsigned int nCmpType) item->child = NULL; *itemPtr++ = item; } - + // 15006BAA if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item { THTreeItem * child2; // EBP THTreeItem * item; // ESI - + // 15006BB8 while(PTR_VALID(child2 = child1->prev)) { if(PTR_INVALID_OR_NULL(item = pItem3058)) item = &items0008[nItems++]; - + // 15006BE3 InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); - + // 15006BF3 item->parent = NULL; item->child = NULL; - + //EDX = child2->byteValue + child1->byteValue; //EAX = child1->byteValue; //ECX = maxByte; // The greatest character (0xFF usually) - + item->byteValue = child1->byteValue + child2->byteValue; // 0x02 item->child = child1; // Prev item in the child1->parent = item; child2->parent = item; - + // EAX = item->byteValue; if(item->byteValue >= maxByte) maxByte = item->byteValue; else { THTreeItem * pItem2 = child2->prev; // EDI - + // 15006C2D while(PTR_VALID(pItem2)) { @@ -452,22 +452,22 @@ void THuffmannTree::BuildTree(unsigned int nCmpType) pItem2 = pItem2->prev; } pItem2 = NULL; - + _15006C3B: if(item->next != 0) { THTreeItem * temp4 = item->GetPrevItem(-1); - + temp4->next = item->next; // The first item changed item->next->prev = item->prev; // First->prev changed to negative value item->next = NULL; item->prev = NULL; } - + // 15006C62 if(pItem2 == NULL) pItem2 = PTR_PTR(&pFirst); - + item->next = pItem2->next; // Set item with 0x100 byte value item->prev = pItem2->next->prev; // Set item with 0x17 byte value pItem2->next->prev = item; // Changed prev of item with @@ -489,48 +489,48 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex) THTreeItem * pItem1 = pItem3058; // ESI THTreeItem * pSaveLast = (PTR_INT(pLast) <= 0) ? NULL : pLast; // EBX THTreeItem * temp; // EAX - + // Prepare the first item to insert to the tree if(PTR_INT(pItem1) <= 0) pItem1 = &items0008[nItems++]; - + // If item has any next item, remove it from the chain if(pItem1->next != NULL) { THTreeItem * temp = pItem1->GetPrevItem(-1); // EAX - + temp->next = pItem1->next; pItem1->next->prev = pItem1->prev; pItem1->next = NULL; pItem1->prev = NULL; } - + pItem1->next = PTR_PTR(&pFirst); pItem1->prev = pLast; temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); - + // 150068E9 temp->next = pItem1; pLast = pItem1; - + pItem1->parent = NULL; pItem1->child = NULL; - + // 150068F6 pItem1->dcmpByte = pSaveLast->dcmpByte; // Copy item index pItem1->byteValue = pSaveLast->byteValue; // Copy item byte value pItem1->parent = pSaveLast; // Set parent to last item items306C[pSaveLast->dcmpByte] = pItem1; // Insert item into item pointer array - + // Prepare the second item to insert into the tree if(PTR_INT((pItem1 = pItem3058)) <= 0) pItem1 = &items0008[nItems++]; - + // 1500692E if(pItem1->next != NULL) { temp = pItem1->GetPrevItem(-1); // EAX - + temp->next = pItem1->next; pItem1->next->prev = pItem1->prev; pItem1->next = NULL; @@ -540,11 +540,11 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex) pItem1->next = PTR_PTR(&pFirst); pItem1->prev = pLast; temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); - + // 15006968 temp->next = pItem1; pLast = pItem1; - + // 1500696E pItem1->child = NULL; pItem1->dcmpByte = dwIndex; @@ -552,45 +552,45 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex) pItem1->parent = pSaveLast; pSaveLast->child = pItem1; items306C[dwIndex] = pItem1; - + do { THTreeItem * pItem2 = pItem1; THTreeItem * pItem3; unsigned long byteValue; - + // 15006993 byteValue = ++pItem1->byteValue; - + // Pass through all previous which have its value greater than byteValue while(PTR_INT((pItem3 = pItem2->prev)) > 0) // EBX { if(pItem3->byteValue >= byteValue) goto _150069AE; - + pItem2 = pItem2->prev; } // 150069AC pItem3 = NULL; - + _150069AE: if(pItem2 == pItem1) continue; - + // 150069B2 // Switch pItem2 with item InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - + // 150069D0 // Switch parents of pItem1 and pItem2 temp = pItem2->parent->child; if(pItem1 == pItem1->parent->child) pItem1->parent->child = pItem2; - + if(pItem2 == temp) pItem2->parent->child = pItem1; - + // 150069ED // Switch parents of pItem1 and pItem3 temp = pItem1->parent; @@ -600,7 +600,7 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex) } while(PTR_INT((pItem1 = pItem1->parent)) > 0); } - + void THuffmannTree::UninitTree() { while(PTR_INT(pLast) > 0) @@ -608,11 +608,11 @@ void THuffmannTree::UninitTree() pItem = pItem305C->Call1501DB70(pLast); pItem->RemoveItem(); } - + for(pItem = pFirst; PTR_INT(pItem3058) > 0; pItem = pItem3058) pItem->RemoveItem(); PTR_PTR(&pItem3054)->RemoveItem(); - + for(pItem = items0008 + 0x203, nCount = 0x203; nCount != 0; nCount--) { pItem--; @@ -621,7 +621,7 @@ void THuffmannTree::UninitTree() } } */ - + THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) { THTreeItem * pItem1 = pItem3058; // EDX @@ -629,7 +629,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) THTreeItem * pNext; THTreeItem * pPrev; THTreeItem ** ppItem; - + if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL) { if((pItem2 = &items0008[nItems++]) != NULL) @@ -639,7 +639,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) } else pItem1 = pItem2; - + pNext = pItem1->next; if(pNext != NULL) { @@ -648,23 +648,23 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) pPrev = PTR_NOT(pPrev); else pPrev += (pItem1 - pItem1->next->prev); - + pPrev->next = pNext; pNext->prev = pPrev; pItem1->next = NULL; pItem1->prev = NULL; } - + ppItem = &pFirst; // esi if(nValue > 1) { // ecx = pFirst->next; pItem1->next = *ppItem; pItem1->prev = (*ppItem)->prev; - + (*ppItem)->prev = pItem2; *ppItem = pItem1; - + pItem2->parent = NULL; pItem2->child = NULL; } @@ -679,7 +679,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) pPrev = PTR_NOT(pPrev); pPrev->next = pItem1; pPrev->prev = pItem2; - + pItem2->parent = NULL; pItem2->child = NULL; } @@ -689,7 +689,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) pPrev += (THTreeItem *)ppItem - (*ppItem)->prev; else pPrev += PTR_INT(pItem305C); - + pPrev->next = pItem1; ppItem[1] = pItem2; pItem2->parent = NULL; @@ -698,18 +698,18 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) } return pItem2; } - + void THuffmannTree::Call1500E820(THTreeItem * pItem) { THTreeItem * pItem1; // edi THTreeItem * pItem2 = NULL; // eax THTreeItem * pItem3; // edx THTreeItem * pPrev; // ebx - + for(; pItem != NULL; pItem = pItem->parent) { pItem->byteValue++; - + for(pItem1 = pItem; ; pItem1 = pPrev) { pPrev = pItem1->prev; @@ -718,14 +718,14 @@ void THuffmannTree::Call1500E820(THTreeItem * pItem) pPrev = NULL; break; } - + if(pPrev->byteValue >= pItem->byteValue) break; } - + if(pItem1 == pItem) continue; - + if(pItem1->next != NULL) { pItem2 = pItem1->GetPrevItem(-1); @@ -734,7 +734,7 @@ void THuffmannTree::Call1500E820(THTreeItem * pItem) pItem1->next = NULL; pItem1->prev = NULL; } - + pItem2 = pItem->next; pItem1->next = pItem2; pItem1->prev = pItem2->prev; @@ -748,30 +748,30 @@ void THuffmannTree::Call1500E820(THTreeItem * pItem) pItem->next = NULL; pItem->prev = NULL; } - + if(pPrev == NULL) pPrev = PTR_PTR(&pFirst); - + pItem2 = pPrev->next; pItem->next = pItem2; pItem->prev = pItem2->prev; pItem2->prev = pItem; pPrev->next = pItem; - + pItem3 = pItem1->parent->child; pItem2 = pItem->parent; if(pItem2->child == pItem) pItem2->child = pItem1; if(pItem3 == pItem1) pItem1->parent->child = pItem; - + pItem2 = pItem->parent; pItem->parent = pItem1->parent; pItem1->parent = pItem2; offs0004++; } } - + // 1500E920 unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType) { @@ -782,14 +782,14 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb unsigned long dwBitBuff; unsigned int nBits; unsigned int nBit; - + BuildTree(nCmpType); bIsCmp0 = (nCmpType == 0); - + // Store the compression type into output buffer os->dwBitBuff |= (nCmpType << os->nBits); os->nBits += 8; - + // Flush completed bytes while(os->nBits >= 8) { @@ -798,22 +798,22 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb *os->pbOutPos++ = (unsigned char)os->dwBitBuff; os->dwOutSize--; } - + os->dwBitBuff >>= 8; os->nBits -= 8; } - + for(; nInLength != 0; nInLength--) { unsigned char bOneByte = *pbInBuffer++; - + if((pItem1 = items306C[bOneByte]) == NULL) { pItem2 = items306C[0x101]; // ecx pItem3 = pItem2->parent; // eax dwBitBuff = 0; nBits = 0; - + for(; pItem3 != NULL; pItem3 = pItem3->parent) { nBit = (pItem3->child != pItem2) ? 1 : 0; @@ -822,11 +822,11 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb pItem2 = pItem3; } os->PutBits(dwBitBuff, nBits); - + // Store the loaded byte into output stream os->dwBitBuff |= (bOneByte << os->nBits); os->nBits += 8; - + // Flush the whole byte(s) while(os->nBits >= 8) { @@ -838,34 +838,34 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb os->dwBitBuff >>= 8; os->nBits -= 8; } - + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; pItem2 = Call1500E740(1); pItem2->dcmpByte = pItem1->dcmpByte; pItem2->byteValue = pItem1->byteValue; pItem2->parent = pItem1; items306C[pItem2->dcmpByte] = pItem2; - + pItem2 = Call1500E740(1); pItem2->dcmpByte = bOneByte; pItem2->byteValue = 0; pItem2->parent = pItem1; items306C[pItem2->dcmpByte] = pItem2; pItem1->child = pItem2; - + Call1500E820(pItem2); - + if(bIsCmp0 != 0) { Call1500E820(items306C[bOneByte]); continue; } - + for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent) { pItem1->byteValue++; pItem2 = pItem1; - + for(;;) { pItem3 = pItem2->prev; @@ -878,19 +878,19 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb break; pItem2 = pItem3; } - + if(pItem2 != pItem1) { InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - + pItem3 = pItem2->parent->child; if(pItem1->parent->child == pItem1) pItem1->parent->child = pItem2; - + if(pItem3 == pItem2) pItem2->parent->child = pItem1; - + pTemp = pItem1->parent; pItem1->parent = pItem2->parent; pItem2->parent = pTemp; @@ -912,13 +912,13 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb } os->PutBits(dwBitBuff, nBits); } - + // 1500EB98 if(bIsCmp0 != 0) Call1500E820(items306C[bOneByte]); // 1500EB9D // 1500EBAF } // for(; nInLength != 0; nInLength--) - + // 1500EBB8 pItem1 = items306C[0x100]; dwBitBuff = 0; @@ -930,10 +930,10 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb nBits++; pItem1 = pItem2; } - + // 1500EBE6 os->PutBits(dwBitBuff, nBits); - + // 1500EBEF // Flush the remaining bits while(os->nBits != 0) @@ -946,10 +946,10 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb os->dwBitBuff >>= 8; os->nBits -= ((os->nBits > 8) ? 8 : os->nBits); } - + return (unsigned int)(os->pbOutPos - os->pbOutBuffer); } - + // Decompression using Huffman tree (1500E450) unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) { @@ -962,29 +962,29 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne unsigned int n8Bits; // 8 bits loaded from input stream unsigned int n7Bits; // 7 bits loaded from input stream bool bHasQdEntry; - + // Test the output length. Must not be NULL. if(dwOutLength == 0) return 0; - + // Get the compression type from the input stream n8Bits = is->Get8Bits(); - + // Build the Huffman tree - BuildTree(n8Bits); + BuildTree(n8Bits); bIsCmp0 = (n8Bits == 0) ? 1 : 0; - + for(;;) { n7Bits = is->Get7Bits(); // Get 7 bits from input stream - + // Try to use quick decompression. Check TQDecompress array for corresponding item. // If found, ise the result byte instead. qd = &qd3474[n7Bits]; - + // If there is a quick-pass possible (ebx) bHasQdEntry = (qd->offs00 >= offs0004) ? true : false; - + // If we can use quick decompress, use it. if(bHasQdEntry) { @@ -1004,21 +1004,21 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne pItem1 = pFirst->next->prev; if(PTR_INVALID_OR_NULL(pItem1)) pItem1 = NULL; -_1500E549: +_1500E549: nBitCount = 0; pItem2 = NULL; - + do { pItem1 = pItem1->child; // Move down by one level if(is->GetBit()) // If current bit is set, move to previous pItem1 = pItem1->prev; - + if(++nBitCount == 7) // If we are at 7th bit, save current HTree item. pItem2 = pItem1; } while(pItem1->child != NULL); // Walk until tree has no deeper level - + if(bHasQdEntry == false) { if(nBitCount > 7) @@ -1031,7 +1031,7 @@ _1500E549: { unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount)); unsigned long nAdd = (1 << nBitCount); - + for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd) { qd->offs00 = offs0004; @@ -1042,46 +1042,46 @@ _1500E549: } nDcmpByte = pItem1->dcmpByte; } - + if(nDcmpByte == 0x101) // Huffman tree needs to be modified { n8Bits = is->Get8Bits(); pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; - + pItem2 = Call1500E740(1); pItem2->parent = pItem1; pItem2->dcmpByte = pItem1->dcmpByte; pItem2->byteValue = pItem1->byteValue; items306C[pItem2->dcmpByte] = pItem2; - + pItem2 = Call1500E740(1); pItem2->parent = pItem1; pItem2->dcmpByte = n8Bits; pItem2->byteValue = 0; items306C[pItem2->dcmpByte] = pItem2; - + pItem1->child = pItem2; Call1500E820(pItem2); if(bIsCmp0 == 0) Call1500E820(items306C[n8Bits]); - + nDcmpByte = n8Bits; } - + if(nDcmpByte == 0x100) break; - + *pbOutPos++ = (unsigned char)nDcmpByte; if(--dwOutLength == 0) break; - + if(bIsCmp0) Call1500E820(items306C[nDcmpByte]); } - + return (unsigned int)(pbOutPos - pbOutBuffer); } - + /* OLD VERSION unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) { @@ -1094,38 +1094,38 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne THTreeItem * temp; // For every use unsigned long dcmpByte = 0; // Decompressed byte value bool bFlag = 0; - + // Test the output length. Must not be NULL. if(dwOutLength == 0) return 0; - + // If too few bits in input bit buffer, we have to load next 16 bits is->EnsureHasMoreThan8Bits(); - + // Get 8 bits from input stream oneByte = is->Get8Bits(); - + // Build the Huffman tree - BuildTree(oneByte); - + BuildTree(oneByte); + bIsCmp0 = (oneByte == 0) ? 1 : 0; outPtr = pbOutBuffer; // Copy pointer to output data - + for(;;) { TQDecompress * qd; // For quick decompress unsigned long sevenBits = is->Get7Bits();// 7 bits from input stream - + // Try to use quick decompression. Check TQDecompress array for corresponding item. // If found, ise the result byte instead. qd = &qd3474[sevenBits]; - + // If there is a quick-pass possible hasQDEntry = (qd->offs00 == offs0004) ? 1 : 0; - + // Start passing the Huffman tree. Set item to tree root item pItem1 = pFirst; - + // If we can use quick decompress, use it. bFlag = 1; if(hasQDEntry == 1) @@ -1152,22 +1152,22 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne if(PTR_INT(pItem1) <= 0) pItem1 = NULL; } - + if(bFlag == 1) { // Walk through Huffman Tree bitCount = 0; // Clear bit counter do { - pItem1 = pItem1->child; + pItem1 = pItem1->child; if(is->GetBit() != 0) // If current bit is set, move to previous pItem1 = pItem1->prev; // item in current level - + if(++bitCount == 7) // If we are at 7th bit, store current HTree item. itemAt7 = pItem1; // Store Huffman tree item } while(pItem1->child != NULL); // Walk until tree has no deeper level - + // If quick decompress entry is not filled yet, fill it. if(hasQDEntry == 0) { @@ -1178,19 +1178,19 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne qd->item = itemAt7; // Store item at 7th bit } // If we passed less than 7 bits, fill entry and bit count multipliers - else + else { unsigned long index = sevenBits & (0xFFFFFFFF >> (32 - bitCount)); // Index for quick-decompress entry unsigned long addIndex = (1 << bitCount); // Add value for index - + qd = &qd3474[index]; - + do { qd->offs00 = offs0004; qd->bitCount = bitCount; qd->dcmpByte = pItem1->dcmpByte; - + index += addIndex; qd += addIndex; } @@ -1199,21 +1199,21 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne } dcmpByte = pItem1->dcmpByte; } - + if(dcmpByte == 0x101) // Huffman tree needs to be modified { // Check if there is enough bits in the buffer is->EnsureHasMoreThan8Bits(); - + // Get 8 bits from the buffer oneByte = is->Get8Bits(); - + // Modify Huffman tree ModifyTree(oneByte); - + // Get lastly added tree item pItem1 = items306C[oneByte]; - + if(bIsCmp0 == 0 && pItem1 != NULL) { // 15006F15 @@ -1222,32 +1222,32 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne THTreeItem * pItem2 = pItem1; THTreeItem * pItem3; unsigned long byteValue; - + byteValue = ++pItem1->byteValue; - + while(PTR_INT((pItem3 = pItem2->prev)) > 0) { if(pItem3->byteValue >= byteValue) goto _15006F30; - + pItem2 = pItem2->prev; } pItem3 = NULL; - + _15006F30: if(pItem2 == pItem1) continue; - + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - + temp = pItem2->parent->child; if(pItem1 == pItem1->parent->child) pItem1->parent->child = pItem2; - + if(pItem2 == temp) pItem2->parent->child = pItem1; - + // Switch parents of pItem1 and pItem3 temp = pItem1->parent; pItem1->parent = pItem2->parent; @@ -1258,7 +1258,7 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne } dcmpByte = oneByte; } - + if(dcmpByte != 0x100) // Not at the end of data ? { *outPtr++ = (unsigned char)dcmpByte; @@ -1266,7 +1266,7 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne { if(bIsCmp0 != 0) Call1500E820(items306C[pItem1->byteValue]); - } + } else break; } @@ -1276,7 +1276,7 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne return (unsigned long)(outPtr - pbOutBuffer); } */ - + // Table for (de)compression. Every compression type has 258 entries unsigned char THuffmannTree::Table1502A630[] = { @@ -1298,7 +1298,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - + // Data for compression type 0x01 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, @@ -1317,7 +1317,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, 0x00, 0x00, - + // Data for compression type 0x02 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1336,7 +1336,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - + // Data for compression type 0x03 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, @@ -1355,7 +1355,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x00, 0x00, - + // Data for compression type 0x04 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1374,7 +1374,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - + // Data for compression type 0x05 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, @@ -1393,7 +1393,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - + // Data for compression type 0x06 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1412,7 +1412,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - + // Data for compression type 0x07 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1431,7 +1431,7 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - + // Data for compression type 0x08 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, @@ -1450,5 +1450,4 @@ unsigned char THuffmannTree::Table1502A630[] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - +};
\ No newline at end of file diff --git a/contrib/vmap_extractor_v2/stormlib/huffman/huff.h b/contrib/vmap_extractor_v2/stormlib/huffman/huff.h index af7cdc14539..f06aa771acd 100644 --- a/contrib/vmap_extractor_v2/stormlib/huffman/huff.h +++ b/contrib/vmap_extractor_v2/stormlib/huffman/huff.h @@ -9,67 +9,67 @@ /* 03.05.03 2.00 Lad Added compression */ /* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ /*****************************************************************************/ - + #ifndef __HUFFMAN_H__ #define __HUFFMAN_H__ #include "../StormPort.h" - + //----------------------------------------------------------------------------- // Defines - -#define INSERT_ITEM 1 + +#define INSERT_ITEM 1 #define SWITCH_ITEMS 2 // Switch the item1 and item2 - + #define PTR_NOT(ptr) (THTreeItem *)(~(DWORD_PTR)(ptr)) #define PTR_PTR(ptr) ((THTreeItem *)(ptr)) #define PTR_INT(ptr) (LONG_PTR)(ptr) - + #ifndef NULL #define NULL 0 #endif - + //----------------------------------------------------------------------------- // Structures and classes - + // Input stream for Huffmann decompression class TInputStream { public: - + unsigned long GetBit(); unsigned long Get7Bits(); unsigned long Get8Bits(); - + unsigned char * pbInBuffer; // 00 - Input data unsigned long dwBitBuff; // 04 - Input bit buffer unsigned int nBits; // 08 - Number of bits remaining in 'dwValue' }; - + // Output stream for Huffmann compression class TOutputStream { public: - + void PutBits(unsigned long dwBuff, unsigned int nPutBits); - + unsigned char * pbOutBuffer; // 00 : Output buffer unsigned long dwOutSize; // 04 : Size of output buffer unsigned char * pbOutPos; // 08 : Current output position unsigned long dwBitBuff; // 0C : Bit buffer unsigned long nBits; // 10 : Number of bits in the bit buffer }; - + // Huffmann tree item (?) struct THTreeItem { public: - + THTreeItem * Call1501DB70(THTreeItem * pLast); THTreeItem * GetPrevItem(LONG_PTR value); void ClearItemLinks(); void RemoveItem(); - + THTreeItem * next; // 00 - Pointer to next THTreeItem THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none) unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value @@ -78,7 +78,7 @@ struct THTreeItem THTreeItem * child; // 14 - Pointer to child THTreeItem int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive }; - + // Structure used for quick decompress. The 'bitCount' contains number of bits // and byte value contains result decompressed byte value. // After each walk through Huffman tree are filled all entries which are @@ -96,48 +96,47 @@ struct TQDecompress THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7 }; }; - + // Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert // for the decompression, I do not know actually if the class is really a Hufmann // tree. If someone knows the decompression details, please let me know class THuffmannTree { public: - + THuffmannTree(); void InitTree(bool bCompression); void BuildTree(unsigned int nCmpType); // void ModifyTree(unsigned long dwIndex); // void UninitTree(); - + // void Call15007010(Bit32 dwInLength, THTreeItem * item); THTreeItem * Call1500E740(unsigned int nValue); void Call1500E820(THTreeItem * pItem); unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType); unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is); - + unsigned long bIsCmp0; // 0000 - 1 if compression type 0 unsigned long offs0004; // 0004 - Some flag THTreeItem items0008[0x203]; // 0008 - HTree items - + //- Sometimes used as HTree item ----------- THTreeItem * pItem3050; // 3050 - Always NULL (?) THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid) - + //- Sometimes used as HTree item ----------- THTreeItem * pItem305C; // 305C - Usually NULL THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) unsigned long nItems; // 3068 - Number of used HTree items - + //------------------------------------------- THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive - + static unsigned char Table1502A630[];// Some table }; - + #endif // __HUFFMAN_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/explode.c b/contrib/vmap_extractor_v2/stormlib/pklib/explode.c index 8e6825dfcd1..a5b41e3dcf9 100644 --- a/contrib/vmap_extractor_v2/stormlib/pklib/explode.c +++ b/contrib/vmap_extractor_v2/stormlib/pklib/explode.c @@ -18,7 +18,7 @@ //----------------------------------------------------------------------------- // Tables -static unsigned char DistBits[] = +static unsigned char DistBits[] = { 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, @@ -26,7 +26,7 @@ static unsigned char DistBits[] = 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }; -static unsigned char DistCode[] = +static unsigned char DistCode[] = { 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, @@ -75,7 +75,7 @@ static unsigned char ChBitsAsc[] = 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D }; -static unsigned short ChCodeAsc[] = +static unsigned short ChCodeAsc[] = { 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, @@ -108,7 +108,7 @@ static unsigned short ChCodeAsc[] = 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 + 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 }; //----------------------------------------------------------------------------- @@ -266,11 +266,11 @@ static unsigned long DecodeLit(TDcmpStruct * pWork) { // Skip current bit in the buffer if(WasteBits(pWork, 1)) - return 0x306; + return 0x306; // The next bits are position in buffers value = pWork->position2[(pWork->bit_buff & 0xFF)]; - + // Get number of bits to skip if(WasteBits(pWork, pWork->LenBits[value])) return 0x306; @@ -337,7 +337,7 @@ static unsigned long DecodeLit(TDcmpStruct * pWork) } //----------------------------------------------------------------------------- -// Retrieves the number of bytes to move back +// Retrieves the number of bytes to move back static unsigned long DecodeDist(TDcmpStruct * pWork, unsigned long dwLength) { @@ -402,7 +402,7 @@ static unsigned long Expand(TDcmpStruct * pWork) } else pWork->out_buff[pWork->outputPos++] = (unsigned char)oneByte; - + // If number of extracted bytes has reached 1/2 of output buffer, // flush output buffer. if(pWork->outputPos >= 0x2000) @@ -453,7 +453,7 @@ unsigned int explode( pWork->in_pos = 3; // Position in input buffer // Test for the valid dictionary size - if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) + if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) return CMP_INVALID_DICTSIZE; pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction @@ -475,6 +475,6 @@ unsigned int explode( GenDecodeTabs(0x40, pWork->DistBits, DistCode, pWork->position1); if(Expand(pWork) != 0x306) return CMP_NO_ERROR; - + return CMP_ABORT; } diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/implode.c b/contrib/vmap_extractor_v2/stormlib/pklib/implode.c index 2ffa0f62764..68d5301cc8d 100644 --- a/contrib/vmap_extractor_v2/stormlib/pklib/implode.c +++ b/contrib/vmap_extractor_v2/stormlib/pklib/implode.c @@ -28,7 +28,7 @@ //----------------------------------------------------------------------------- // Tables -static unsigned char DistBits[] = +static unsigned char DistBits[] = { 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, @@ -36,7 +36,7 @@ static unsigned char DistBits[] = 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }; -static unsigned char DistCode[] = +static unsigned char DistCode[] = { 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, @@ -79,7 +79,7 @@ static unsigned char ChBitsAsc[] = 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D }; -static unsigned short ChCodeAsc[] = +static unsigned short ChCodeAsc[] = { 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, @@ -112,7 +112,7 @@ static unsigned short ChCodeAsc[] = 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 + 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 }; //----------------------------------------------------------------------------- @@ -215,7 +215,7 @@ static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit { pWork->out_bytes++; bit_buff >>= (8 - out_bits); - + pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff; pWork->out_bits &= 7; } @@ -341,7 +341,7 @@ static unsigned long FindRep(TCmpStruct * pWork, unsigned char * srcbuff) esi = nreps; pin27CC = pWork->work_buff + pin49D0[0] + nreps; esp14 = pin27CC; - + for(;;) // 0040268B { esi = pWork->offs09BC[esi]; @@ -473,7 +473,7 @@ static void WriteCmpData(TCmpStruct * pWork) // switch(esp20) { - case 0: + case 0: SortBuffer(pWork, uncmp_begin, uncmp_end + 1); esp20++; if(pWork->dsize_bytes != 0x1000) @@ -590,7 +590,7 @@ unsigned int PKEXPORT implode( // Initialize the work buffer. This is not in the Pklib, // but it seems to be a bug. Storm always pre-fills the data with zeros, // and always compresses one block only. So the bug will not appear. - // But when a larger data block (size > 0x1000) is compressed, + // But when a larger data block (size > 0x1000) is compressed, // it may fail. memset(pWork, 0, sizeof(TCmpStruct)); @@ -650,7 +650,7 @@ unsigned int PKEXPORT implode( for(i = 0; i < 0x10; i++) { - int nCount2 = 0; // EBX + int nCount2 = 0; // EBX if((1 << ExLenBits[i]) == 0) continue; diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h b/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h index d4c405b240d..881262e3839 100644 --- a/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h +++ b/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h @@ -29,7 +29,7 @@ // Define calling convention #ifndef PKEXPORT -#define PKEXPORT //__cdecl // Use for normal __cdecl calling +#define PKEXPORT //__cdecl // Use for normal __cdecl calling #endif //#define PKEXPORT __stdcall //#define PKEXPORT __fastcall @@ -40,8 +40,8 @@ // Compression structure typedef struct { - unsigned int offs0000; // 0000 : - unsigned int out_bytes; // 0004 : # bytes available in out_buff + unsigned int offs0000; // 0000 : + unsigned int out_bytes; // 0004 : # bytes available in out_buff unsigned int out_bits; // 0008 : # of bits available in the last out byte unsigned int dsize_bits; // 000C : Dict size : 4=0x400, 5=0x800, 6=0x1000 unsigned int dsize_mask; // 0010 : Dict size : 0x0F=0x400, 0x1F=0x800, 0x3F=0x1000 @@ -49,23 +49,23 @@ typedef struct unsigned int dsize_bytes; // 0018 : Dictionary size in bytes unsigned char dist_bits[0x40]; // 001C : Distance bits unsigned char dist_codes[0x40]; // 005C : Distance codes - unsigned char nChBits[0x306]; // 009C : - unsigned short nChCodes[0x306]; // 03A2 : - unsigned short offs09AE; // 09AE : + unsigned char nChBits[0x306]; // 009C : + unsigned short nChCodes[0x306]; // 03A2 : + unsigned short offs09AE; // 09AE : void * param; // 09B0 : User parameter unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4 void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8 unsigned short offs09BC[0x204]; // 09BC : - unsigned long offs0DC4; // 0DC4 : + unsigned long offs0DC4; // 0DC4 : unsigned short offs0DC8[0x900]; // 0DC8 : - unsigned short offs1FC8; // 1FC8 : + unsigned short offs1FC8; // 1FC8 : char out_buff[0x802]; // 1FCA : Output (compressed) data unsigned char work_buff[0x2204]; // 27CC : Work buffer // + DICT_OFFSET => Dictionary // + UNCMP_OFFSET => Uncompressed data - unsigned short offs49D0[0x2000]; // 49D0 : + unsigned short offs49D0[0x2000]; // 49D0 : } TCmpStruct; #define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression buffer @@ -91,15 +91,15 @@ typedef struct unsigned char in_buff[0x800]; // 2234 - Buffer for data to be decompressed unsigned char position1[0x100]; // 2A34 - Positions in buffers unsigned char position2[0x100]; // 2B34 - Positions in buffers - unsigned char offs2C34[0x100]; // 2C34 - Buffer for - unsigned char offs2D34[0x100]; // 2D34 - Buffer for - unsigned char offs2E34[0x80]; // 2EB4 - Buffer for - unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for - unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for + unsigned char offs2C34[0x100]; // 2C34 - Buffer for + unsigned char offs2D34[0x100]; // 2D34 - Buffer for + unsigned char offs2E34[0x80]; // 2EB4 - Buffer for + unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for + unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for unsigned char DistBits[0x40]; // 30B4 - Numbers of bytes to skip copied block length unsigned char LenBits[0x10]; // 30F4 - Numbers of bits for skip copied block length unsigned char ExLenBits[0x10]; // 3104 - Number of valid bits for copied block - unsigned short LenBase[0x10]; // 3114 - Buffer for + unsigned short LenBase[0x10]; // 3114 - Buffer for } TDcmpStruct; #define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompress buffer @@ -135,4 +135,3 @@ unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long * #endif #endif // __PKLIB_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp b/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp index 1400fad37de..936525f4eae 100644 --- a/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp +++ b/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp @@ -35,8 +35,8 @@ static long Table1503F120[] = { 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 + 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, + 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 }; static long Table1503F1A0[] = @@ -112,10 +112,10 @@ int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffe nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer); nLength = (nLength < 0) ? 0 : nLength; - + nIndex = nChannels - 1; // edi nWordsRemains = dwInLength / 2; // eax - + // ebx - nChannels // ecx - pwOutPos for(int chnl = nChannels; chnl < nWordsRemains; chnl++) @@ -184,7 +184,7 @@ int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffe } if(dwBit == dwStopBit) break; - + nTableValue >>= 1; } @@ -205,7 +205,7 @@ int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffe SInt32Array2[nIndex] = nValue; *out.pb++ = (unsigned char)(dwBitBuff | ebx); nTableValue = Table1503F120[dwBitBuff & 0x1F]; - SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; + SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; if(SInt32Array1[nIndex] < 0) SInt32Array1[nIndex] = 0; else if(SInt32Array1[nIndex] > 0x58) @@ -280,7 +280,7 @@ int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * SInt32Array1[nIndex] += 8; if(SInt32Array1[nIndex] > 0x58) SInt32Array1[nIndex] = 0x58; - + if(nChannels == 2) nIndex = (nIndex == 0) ? 1 : 0; break; @@ -354,4 +354,3 @@ int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * } return (int)(out.pb - pbOutBuffer); } - diff --git a/contrib/vmap_extractor_v2/stormlib/wave/wave.h b/contrib/vmap_extractor_v2/stormlib/wave/wave.h index bc116b91ce7..81b5add9cfc 100644 --- a/contrib/vmap_extractor_v2/stormlib/wave/wave.h +++ b/contrib/vmap_extractor_v2/stormlib/wave/wave.h @@ -20,4 +20,3 @@ int CompressWave (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBu int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels); #endif // __WAVE_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c b/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c index d74de704d62..fae88b65593 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c @@ -1,6 +1,6 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ @@ -34,12 +34,12 @@ uLong ZEXPORT adler32(adler, buf, len) len -= k; while (k >= 16) { DO16(buf); - buf += 16; + buf += 16; k -= 16; } if (k != 0) do { s1 += *buf++; - s2 += s1; + s2 += s1; } while (--k); s1 %= BASE; s2 %= BASE; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/compress.c b/contrib/vmap_extractor_v2/stormlib/zlib/compress.c index c44f8ba9dfa..814bd9d6061 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/compress.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/compress.c @@ -1,6 +1,6 @@ /* compress.c -- compress a memory buffer * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c index 4ee6051aeb0..d853bb7ce8a 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c @@ -20,7 +20,7 @@ /* if your C compiler don't add underline before function name, - define ADD_UNDERLINE_ASMFUNC */ + define ADD_UNDERLINE_ASMFUNC */ #ifdef ADD_UNDERLINE_ASMFUNC #define longest_match_7fff _longest_match_7fff #endif @@ -46,15 +46,15 @@ uInt longest_match( deflate_state *s, IPos cur_match) /* current match */ { - static uInt iIsPPro=2; + static uInt iIsPPro=2; if ((s->w_mask == 0x7fff) && (iIsPPro==0)) return longest_match_7fff(s,cur_match); - if (iIsPPro==2) - iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; + if (iIsPPro==2) + iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; - return longest_match_c(s,cur_match); + return longest_match_c(s,cur_match); } diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp index 25b15e30a8c..f5dea59b762 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp @@ -15,4 +15,3 @@ USEUNIT("trees.c"); // To add a file to the library use the Project menu 'Add to Project'. - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp index 0673927e015..bf6953ba198 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp @@ -20,4 +20,3 @@ USEUNIT("zutil.c"); // To add a file to the library use the Project menu 'Add to Project'. - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp index 0458f5447cb..7372f6b985f 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp @@ -40,4 +40,3 @@ int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) { return 1; } - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp index e416a1c7649..7d265b3b5c0 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp @@ -22,4 +22,3 @@ int main() { return 0; } - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp index 2959b3b349b..a690bbefceb 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp @@ -17,7 +17,7 @@ gzfilebuf::~gzfilebuf() { } gzfilebuf *gzfilebuf::open( const char *name, - int io_mode ) { + int io_mode ) { if ( is_open() ) return NULL; @@ -58,7 +58,7 @@ gzfilebuf *gzfilebuf::open( const char *name, } gzfilebuf *gzfilebuf::attach( int file_descriptor, - int io_mode ) { + int io_mode ) { if ( is_open() ) return NULL; @@ -151,7 +151,7 @@ int gzfilebuf::underflow() { if ( out_waiting() ) { if ( flushbuf() == EOF ) - return EOF; + return EOF; } } @@ -180,11 +180,11 @@ int gzfilebuf::overflow( int c ) { setg(0,0,0); } else { if (in_avail()) { - return EOF; + return EOF; } if (out_waiting()) { if (flushbuf() == EOF) - return EOF; + return EOF; } } @@ -287,7 +287,7 @@ gzfilebuf *gzfilestream_common::rdbuf() { return &buffer; } - + gzifstream::gzifstream() : ios( gzfilestream_common::rdbuf() ) { @@ -327,4 +327,3 @@ gzofstream::gzofstream( int fd, int io_mode ) : } gzofstream::~gzofstream() { } - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h index 81ff4e26258..c87fa08e9d1 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h @@ -99,9 +99,9 @@ private: }; template<class T> gzofstream &operator<<(gzofstream &s, - const gzomanip<T> &m) { + const gzomanip<T> &m) { return (*m.func)(s, m.val); - + } inline gzofstream &setcompressionlevel( gzofstream &s, int l ) { @@ -140,4 +140,3 @@ inline gzomanip<int> setcompressionstrategy(int l) - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h index a69b189a16f..43d2332b79b 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h @@ -305,4 +305,3 @@ inline ostream& operator<<(ozstream& zs, const T& x) { } #endif - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp index b2fc9e66902..5bbd56c3ad8 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp @@ -4,9 +4,9 @@ #include <iomanip.h> void main() { - char h[256] = "Hello"; - char* g = "Goodbye"; - ozstream out("temp.gz"); + char h[256] = "Hello"; + char* g = "Goodbye"; + ozstream out("temp.gz"); out < "This works well" < h < g; out.close(); @@ -23,4 +23,3 @@ void main() { delete[] x; delete[] y; } - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c index 741e8dca566..f3b7832878f 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c @@ -34,9 +34,9 @@ dosdate : the new date at the MSDos format (4 bytes) tmu_date : the SAME new date at the tm_unz format */ void change_file_date(filename,dosdate,tmu_date) - const char *filename; - uLong dosdate; - tm_unz tmu_date; + const char *filename; + uLong dosdate; + tm_unz tmu_date; { #ifdef WIN32 HANDLE hFile; @@ -75,17 +75,17 @@ void change_file_date(filename,dosdate,tmu_date) As I don't know well Unix, I wait feedback for the unix portion */ int mymkdir(dirname) - const char* dirname; + const char* dirname; { int ret=0; #ifdef WIN32 - ret = mkdir(dirname); + ret = mkdir(dirname); #else #ifdef unix - ret = mkdir (dirname,0775); + ret = mkdir (dirname,0775); #endif #endif - return ret; + return ret; } int makedir (newdir) @@ -93,14 +93,14 @@ int makedir (newdir) { char *buffer ; char *p; - int len = strlen(newdir); + int len = strlen(newdir); - if (len <= 0) + if (len <= 0) return 0; buffer = (char*)malloc(len+1); strcpy(buffer,newdir); - + if (buffer[len-1] == '/') { buffer[len-1] = '\0'; } @@ -135,104 +135,104 @@ int makedir (newdir) void do_banner() { - printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n"); - printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); + printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n"); + printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); } void do_help() -{ - printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ; +{ + printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ; } int do_list(uf) - unzFile uf; + unzFile uf; { - uLong i; - unz_global_info gi; - int err; + uLong i; + unz_global_info gi; + int err; - err = unzGetGlobalInfo (uf,&gi); - if (err!=UNZ_OK) - printf("error %d with zipfile in unzGetGlobalInfo \n",err); + err = unzGetGlobalInfo (uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); - for (i=0;i<gi.number_entry;i++) - { - char filename_inzip[256]; - unz_file_info file_info; - uLong ratio=0; - const char *string_method; - err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); - break; - } - if (file_info.uncompressed_size>0) - ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; - - if (file_info.compression_method==0) - string_method="Stored"; - else - if (file_info.compression_method==Z_DEFLATED) - { - uInt iLevel=(uInt)((file_info.flag & 0x6)/2); - if (iLevel==0) - string_method="Defl:N"; - else if (iLevel==1) - string_method="Defl:X"; - else if ((iLevel==2) || (iLevel==3)) - string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ - } - else - string_method="Unkn. "; - - printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", - file_info.uncompressed_size,string_method,file_info.compressed_size, - ratio, - (uLong)file_info.tmu_date.tm_mon + 1, + for (i=0;i<gi.number_entry;i++) + { + char filename_inzip[256]; + unz_file_info file_info; + uLong ratio=0; + const char *string_method; + err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); + break; + } + if (file_info.uncompressed_size>0) + ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; + + if (file_info.compression_method==0) + string_method="Stored"; + else + if (file_info.compression_method==Z_DEFLATED) + { + uInt iLevel=(uInt)((file_info.flag & 0x6)/2); + if (iLevel==0) + string_method="Defl:N"; + else if (iLevel==1) + string_method="Defl:X"; + else if ((iLevel==2) || (iLevel==3)) + string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ + } + else + string_method="Unkn. "; + + printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", + file_info.uncompressed_size,string_method,file_info.compressed_size, + ratio, + (uLong)file_info.tmu_date.tm_mon + 1, (uLong)file_info.tmu_date.tm_mday, - (uLong)file_info.tmu_date.tm_year % 100, - (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, - (uLong)file_info.crc,filename_inzip); - if ((i+1)<gi.number_entry) - { - err = unzGoToNextFile(uf); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzGoToNextFile\n",err); - break; - } - } - } - - return 0; + (uLong)file_info.tmu_date.tm_year % 100, + (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, + (uLong)file_info.crc,filename_inzip); + if ((i+1)<gi.number_entry) + { + err = unzGoToNextFile(uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzGoToNextFile\n",err); + break; + } + } + } + + return 0; } int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite) - unzFile uf; - const int* popt_extract_without_path; + unzFile uf; + const int* popt_extract_without_path; int* popt_overwrite; { - char filename_inzip[256]; - char* filename_withoutpath; - char* p; + char filename_inzip[256]; + char* filename_withoutpath; + char* p; int err=UNZ_OK; FILE *fout=NULL; void* buf; uInt size_buf; + + unz_file_info file_info; + uLong ratio=0; + err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); - unz_file_info file_info; - uLong ratio=0; - err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); - - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); - return err; - } + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); + return err; + } size_buf = WRITEBUFFERSIZE; buf = (void*)malloc(size_buf); @@ -242,71 +242,71 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite) return UNZ_INTERNALERROR; } - p = filename_withoutpath = filename_inzip; - while ((*p) != '\0') - { - if (((*p)=='/') || ((*p)=='\\')) - filename_withoutpath = p+1; - p++; - } - - if ((*filename_withoutpath)=='\0') - { - if ((*popt_extract_without_path)==0) - { - printf("creating directory: %s\n",filename_inzip); - mymkdir(filename_inzip); - } - } - else - { - const char* write_filename; - int skip=0; - - if ((*popt_extract_without_path)==0) - write_filename = filename_inzip; - else - write_filename = filename_withoutpath; - - err = unzOpenCurrentFile(uf); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzOpenCurrentFile\n",err); - } - - if (((*popt_overwrite)==0) && (err==UNZ_OK)) - { - char rep; - FILE* ftestexist; - ftestexist = fopen(write_filename,"rb"); - if (ftestexist!=NULL) - { - fclose(ftestexist); - do - { - char answer[128]; - printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); - scanf("%1s",answer); - rep = answer[0] ; - if ((rep>='a') && (rep<='z')) - rep -= 0x20; - } - while ((rep!='Y') && (rep!='N') && (rep!='A')); - } - - if (rep == 'N') - skip = 1; - - if (rep == 'A') - *popt_overwrite=1; - } - - if ((skip==0) && (err==UNZ_OK)) - { - fout=fopen(write_filename,"wb"); + p = filename_withoutpath = filename_inzip; + while ((*p) != '\0') + { + if (((*p)=='/') || ((*p)=='\\')) + filename_withoutpath = p+1; + p++; + } + + if ((*filename_withoutpath)=='\0') + { + if ((*popt_extract_without_path)==0) + { + printf("creating directory: %s\n",filename_inzip); + mymkdir(filename_inzip); + } + } + else + { + const char* write_filename; + int skip=0; + + if ((*popt_extract_without_path)==0) + write_filename = filename_inzip; + else + write_filename = filename_withoutpath; + + err = unzOpenCurrentFile(uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzOpenCurrentFile\n",err); + } + + if (((*popt_overwrite)==0) && (err==UNZ_OK)) + { + char rep; + FILE* ftestexist; + ftestexist = fopen(write_filename,"rb"); + if (ftestexist!=NULL) + { + fclose(ftestexist); + do + { + char answer[128]; + printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); + scanf("%1s",answer); + rep = answer[0] ; + if ((rep>='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + } + + if (rep == 'N') + skip = 1; + + if (rep == 'A') + *popt_overwrite=1; + } + + if ((skip==0) && (err==UNZ_OK)) + { + fout=fopen(write_filename,"wb"); /* some zipfile don't contain directory alone before file */ - if ((fout==NULL) && ((*popt_extract_without_path)==0) && + if ((fout==NULL) && ((*popt_extract_without_path)==0) && (filename_withoutpath!=(char*)filename_inzip)) { char c=*(filename_withoutpath-1); @@ -316,94 +316,94 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite) fout=fopen(write_filename,"wb"); } - if (fout==NULL) - { - printf("error opening %s\n",write_filename); - } - } - - if (fout!=NULL) - { - printf(" extracting: %s\n",write_filename); - - do - { - err = unzReadCurrentFile(uf,buf,size_buf); - if (err<0) - { - printf("error %d with zipfile in unzReadCurrentFile\n",err); - break; - } - if (err>0) - if (fwrite(buf,err,1,fout)!=1) - { - printf("error in writing extracted file\n"); + if (fout==NULL) + { + printf("error opening %s\n",write_filename); + } + } + + if (fout!=NULL) + { + printf(" extracting: %s\n",write_filename); + + do + { + err = unzReadCurrentFile(uf,buf,size_buf); + if (err<0) + { + printf("error %d with zipfile in unzReadCurrentFile\n",err); + break; + } + if (err>0) + if (fwrite(buf,err,1,fout)!=1) + { + printf("error in writing extracted file\n"); err=UNZ_ERRNO; - break; - } - } - while (err>0); - fclose(fout); - if (err==0) - change_file_date(write_filename,file_info.dosDate, - file_info.tmu_date); - } + break; + } + } + while (err>0); + fclose(fout); + if (err==0) + change_file_date(write_filename,file_info.dosDate, + file_info.tmu_date); + } if (err==UNZ_OK) { - err = unzCloseCurrentFile (uf); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzCloseCurrentFile\n",err); - } + err = unzCloseCurrentFile (uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzCloseCurrentFile\n",err); + } } else - unzCloseCurrentFile(uf); /* don't lose the error */ - } + unzCloseCurrentFile(uf); /* don't lose the error */ + } - free(buf); + free(buf); return err; } int do_extract(uf,opt_extract_without_path,opt_overwrite) - unzFile uf; - int opt_extract_without_path; + unzFile uf; + int opt_extract_without_path; int opt_overwrite; { - uLong i; - unz_global_info gi; - int err; - FILE* fout=NULL; + uLong i; + unz_global_info gi; + int err; + FILE* fout=NULL; - err = unzGetGlobalInfo (uf,&gi); - if (err!=UNZ_OK) - printf("error %d with zipfile in unzGetGlobalInfo \n",err); + err = unzGetGlobalInfo (uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); - for (i=0;i<gi.number_entry;i++) - { + for (i=0;i<gi.number_entry;i++) + { if (do_extract_currentfile(uf,&opt_extract_without_path, &opt_overwrite) != UNZ_OK) break; - if ((i+1)<gi.number_entry) - { - err = unzGoToNextFile(uf); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzGoToNextFile\n",err); - break; - } - } - } - - return 0; + if ((i+1)<gi.number_entry) + { + err = unzGoToNextFile(uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzGoToNextFile\n",err); + break; + } + } + } + + return 0; } int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite) - unzFile uf; - const char* filename; - int opt_extract_without_path; + unzFile uf; + const char* filename; + int opt_extract_without_path; int opt_overwrite; { int err = UNZ_OK; @@ -422,87 +422,87 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite) int main(argc,argv) - int argc; - char *argv[]; + int argc; + char *argv[]; { - const char *zipfilename=NULL; + const char *zipfilename=NULL; const char *filename_to_extract=NULL; - int i; - int opt_do_list=0; - int opt_do_extract=1; - int opt_do_extract_withoutpath=0; - int opt_overwrite=0; - char filename_try[512]; - unzFile uf=NULL; - - do_banner(); - if (argc==1) - { - do_help(); - exit(0); - } - else - { - for (i=1;i<argc;i++) - { - if ((*argv[i])=='-') - { - const char *p=argv[i]+1; - - while ((*p)!='\0') - { - char c=*(p++);; - if ((c=='l') || (c=='L')) - opt_do_list = 1; - if ((c=='v') || (c=='V')) - opt_do_list = 1; - if ((c=='x') || (c=='X')) - opt_do_extract = 1; - if ((c=='e') || (c=='E')) - opt_do_extract = opt_do_extract_withoutpath = 1; - if ((c=='o') || (c=='O')) - opt_overwrite=1; - } - } - else + int i; + int opt_do_list=0; + int opt_do_extract=1; + int opt_do_extract_withoutpath=0; + int opt_overwrite=0; + char filename_try[512]; + unzFile uf=NULL; + + do_banner(); + if (argc==1) + { + do_help(); + exit(0); + } + else + { + for (i=1;i<argc;i++) + { + if ((*argv[i])=='-') + { + const char *p=argv[i]+1; + + while ((*p)!='\0') + { + char c=*(p++);; + if ((c=='l') || (c=='L')) + opt_do_list = 1; + if ((c=='v') || (c=='V')) + opt_do_list = 1; + if ((c=='x') || (c=='X')) + opt_do_extract = 1; + if ((c=='e') || (c=='E')) + opt_do_extract = opt_do_extract_withoutpath = 1; + if ((c=='o') || (c=='O')) + opt_overwrite=1; + } + } + else { - if (zipfilename == NULL) - zipfilename = argv[i]; + if (zipfilename == NULL) + zipfilename = argv[i]; else if (filename_to_extract==NULL) filename_to_extract = argv[i] ; } - } - } - - if (zipfilename!=NULL) - { - strcpy(filename_try,zipfilename); - uf = unzOpen(zipfilename); - if (uf==NULL) - { - strcat(filename_try,".zip"); - uf = unzOpen(filename_try); - } - } - - if (uf==NULL) - { - printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); - exit (1); - } + } + } + + if (zipfilename!=NULL) + { + strcpy(filename_try,zipfilename); + uf = unzOpen(zipfilename); + if (uf==NULL) + { + strcat(filename_try,".zip"); + uf = unzOpen(filename_try); + } + } + + if (uf==NULL) + { + printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); + exit (1); + } printf("%s opened\n",filename_try); - if (opt_do_list==1) - return do_list(uf); - else if (opt_do_extract==1) + if (opt_do_list==1) + return do_list(uf); + else if (opt_do_extract==1) { if (filename_to_extract == NULL) - return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite); + return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite); else return do_extract_onefile(uf,filename_to_extract, opt_do_extract_withoutpath,opt_overwrite); } - unzCloseCurrentFile(uf); + unzCloseCurrentFile(uf); - return 0; /* to avoid warning */ + return 0; /* to avoid warning */ } diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c index 2d32452a9ad..5e492d209b1 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c @@ -55,7 +55,7 @@ uLong filetime(f, tmzip, dt) struct stat s; /* results of stat() */ struct tm* filedate; time_t tm_t=0; - + if (strcmp(f,"-")!=0) { char name[MAXFILENAME]; @@ -98,10 +98,10 @@ uLong filetime(f, tmzip, dt) int check_exist_file(filename) const char* filename; { - FILE* ftestexist; + FILE* ftestexist; int ret = 1; - ftestexist = fopen(filename,"rb"); - if (ftestexist==NULL) + ftestexist = fopen(filename,"rb"); + if (ftestexist==NULL) ret = 0; else fclose(ftestexist); @@ -110,59 +110,59 @@ int check_exist_file(filename) void do_banner() { - printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n"); - printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); + printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n"); + printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); } void do_help() -{ - printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ; +{ + printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ; } int main(argc,argv) - int argc; - char *argv[]; + int argc; + char *argv[]; { - int i; - int opt_overwrite=0; + int i; + int opt_overwrite=0; int opt_compress_level=Z_DEFAULT_COMPRESSION; int zipfilenamearg = 0; - char filename_try[MAXFILENAME]; + char filename_try[MAXFILENAME]; int zipok; int err=0; int size_buf=0; void* buf=NULL, - do_banner(); - if (argc==1) - { - do_help(); - exit(0); + do_banner(); + if (argc==1) + { + do_help(); + exit(0); return 0; - } - else - { - for (i=1;i<argc;i++) - { - if ((*argv[i])=='-') - { - const char *p=argv[i]+1; - - while ((*p)!='\0') - { - char c=*(p++);; - if ((c=='o') || (c=='O')) - opt_overwrite = 1; + } + else + { + for (i=1;i<argc;i++) + { + if ((*argv[i])=='-') + { + const char *p=argv[i]+1; + + while ((*p)!='\0') + { + char c=*(p++);; + if ((c=='o') || (c=='O')) + opt_overwrite = 1; if ((c>='0') && (c<='9')) opt_compress_level = c-'0'; - } - } - else - if (zipfilenamearg == 0) + } + } + else + if (zipfilenamearg == 0) zipfilenamearg = i ; - } - } + } + } size_buf = WRITEBUFFERSIZE; buf = (void*)malloc(size_buf); @@ -172,15 +172,15 @@ int main(argc,argv) return ZIP_INTERNALERROR; } - if (zipfilenamearg==0) + if (zipfilenamearg==0) zipok=0; else - { + { int i,len; int dot_found=0; zipok = 1 ; - strcpy(filename_try,argv[zipfilenamearg]); + strcpy(filename_try,argv[zipfilenamearg]); len=strlen(filename_try); for (i=0;i<len;i++) if (filename_try[i]=='.') @@ -191,21 +191,21 @@ int main(argc,argv) if (opt_overwrite==0) if (check_exist_file(filename_try)!=0) - { + { char rep; - do - { - char answer[128]; - printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try); - scanf("%1s",answer); - rep = answer[0] ; - if ((rep>='a') && (rep<='z')) - rep -= 0x20; - } - while ((rep!='Y') && (rep!='N')); + do + { + char answer[128]; + printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try); + scanf("%1s",answer); + rep = answer[0] ; + if ((rep>='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N')); if (rep=='N') zipok = 0; - } + } } if (zipok==1) @@ -218,7 +218,7 @@ int main(argc,argv) printf("error opening %s\n",filename_try); err= ZIP_ERRNO; } - else + else printf("creating %s\n",filename_try); for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) @@ -230,7 +230,7 @@ int main(argc,argv) const char* filenameinzip = argv[i]; zip_fileinfo zi; - zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = + zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = zi.tmz_date.tm_mday = zi.tmz_date.tm_min = zi.tmz_date.tm_year = 0; zi.dosDate = 0; zi.internal_fa = 0; @@ -275,7 +275,7 @@ int main(argc,argv) printf("error in writing %s in the zipfile\n", filenameinzip); } - + } } while ((err == ZIP_OK) && (size_read>0)); @@ -283,7 +283,7 @@ int main(argc,argv) if (err<0) err=ZIP_ERRNO; else - { + { err = zipCloseFileInZip(zf); if (err!=ZIP_OK) printf("error in closing %s in the zipfile\n", @@ -298,5 +298,5 @@ int main(argc,argv) free(buf); exit(0); - return 0; /* to avoid warning */ + return 0; /* to avoid warning */ } diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c index e41da922fea..ff71a474da1 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c @@ -1,4 +1,4 @@ -/* unzip.c -- IO on .zip files using zlib +/* unzip.c -- IO on .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Read unzip.h for more info @@ -83,23 +83,23 @@ typedef struct unz_file_info_internal_s when reading and decompress it */ typedef struct { - char *read_buffer; /* internal buffer for compressed data */ - z_stream stream; /* zLib stream structure for inflate */ - - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ - - uLong offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ - - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - FILE* file; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + FILE* file; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ } file_in_zip_read_info_s; @@ -107,22 +107,22 @@ typedef struct */ typedef struct { - FILE* file; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ - - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ + FILE* file; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ + file if we are decompressing it */ } unz_s; @@ -134,11 +134,11 @@ typedef struct local int unzlocal_getByte(fin,pi) - FILE *fin; - int *pi; + FILE *fin; + int *pi; { unsigned char c; - int err = fread(&c, 1, 1, fin); + int err = fread(&c, 1, 1, fin); if (err==1) { *pi = (int)c; @@ -146,7 +146,7 @@ local int unzlocal_getByte(fin,pi) } else { - if (ferror(fin)) + if (ferror(fin)) return UNZ_ERRNO; else return UNZ_EOF; @@ -155,10 +155,10 @@ local int unzlocal_getByte(fin,pi) /* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets + Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort (fin,pX) - FILE* fin; + FILE* fin; uLong *pX; { uLong x ; @@ -167,11 +167,11 @@ local int unzlocal_getShort (fin,pX) err = unzlocal_getByte(fin,&i); x = (uLong)i; - + if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; - + if (err==UNZ_OK) *pX = x; else @@ -180,7 +180,7 @@ local int unzlocal_getShort (fin,pX) } local int unzlocal_getLong (fin,pX) - FILE* fin; + FILE* fin; uLong *pX; { uLong x ; @@ -189,7 +189,7 @@ local int unzlocal_getLong (fin,pX) err = unzlocal_getByte(fin,&i); x = (uLong)i; - + if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; @@ -201,7 +201,7 @@ local int unzlocal_getLong (fin,pX) if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<24; - + if (err==UNZ_OK) *pX = x; else @@ -212,26 +212,26 @@ local int unzlocal_getLong (fin,pX) /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; + const char* fileName1; + const char* fileName2; { - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1<c2) - return -1; - if (c1>c2) - return 1; - } + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1<c2) + return -1; + if (c1>c2) + return 1; + } } @@ -245,7 +245,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2) #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif -/* +/* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi @@ -255,18 +255,18 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2) */ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; + const char* fileName1; + const char* fileName2; + int iCaseSensitivity; { - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); +} #define BUFREADCOMMENT (0x400) @@ -275,161 +275,161 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit the global comment) */ local uLong unzlocal_SearchCentralDir(fin) - FILE *fin; + FILE *fin; { - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (fseek(fin,0,SEEK_END) != 0) - return 0; - - - uSizeFile = ftell( fin ); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackRead<uMaxBack) - { - uLong uReadSize,uReadPos ; - int i; - if (uBackRead+BUFREADCOMMENT>uMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (fseek(fin,0,SEEK_END) != 0) + return 0; + + + uSizeFile = ftell( fin ); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackRead<uMaxBack) + { + uLong uReadSize,uReadPos ; + int i; + if (uBackRead+BUFREADCOMMENT>uMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (fseek(fin,uReadPos,SEEK_SET)!=0) - break; + if (fseek(fin,uReadPos,SEEK_SET)!=0) + break; - if (fread(buf,(uInt)uReadSize,1,fin)!=1) - break; + if (fread(buf,(uInt)uReadSize,1,fin)!=1) + break; for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; } /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer - "zlib/zlib109.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. + "zlib/zlib109.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. Else, the return value is a unzFile Handle, usable with other function - of this unzip package. + of this unzip package. */ extern unzFile ZEXPORT unzOpen (path) - const char *path; + const char *path; { - unz_s us; - unz_s *s; - uLong central_pos,uL; - FILE * fin ; + unz_s us; + unz_s *s; + uLong central_pos,uL; + FILE * fin ; - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ - int err=UNZ_OK; + int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; fin=fopen(path,"rb"); - if (fin==NULL) - return NULL; - - central_pos = unzlocal_SearchCentralDir(fin); - if (central_pos==0) - err=UNZ_ERRNO; - - if (fseek(fin,central_pos,SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unzlocal_getLong(fin,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir */ - if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* zipfile comment length */ - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((central_pos<us.offset_central_dir+us.size_central_dir) && - (err==UNZ_OK)) - err=UNZ_BADZIPFILE; - - if (err!=UNZ_OK) - { - fclose(fin); - return NULL; - } - - us.file=fin; - us.byte_before_the_zipfile = central_pos - - (us.offset_central_dir+us.size_central_dir); - us.central_pos = central_pos; + if (fin==NULL) + return NULL; + + central_pos = unzlocal_SearchCentralDir(fin); + if (central_pos==0) + err=UNZ_ERRNO; + + if (fseek(fin,central_pos,SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unzlocal_getLong(fin,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir */ + if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* zipfile comment length */ + if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((central_pos<us.offset_central_dir+us.size_central_dir) && + (err==UNZ_OK)) + err=UNZ_BADZIPFILE; + + if (err!=UNZ_OK) + { + fclose(fin); + return NULL; + } + + us.file=fin; + us.byte_before_the_zipfile = central_pos - + (us.offset_central_dir+us.size_central_dir); + us.central_pos = central_pos; us.pfile_in_zip_read = NULL; + - - s=(unz_s*)ALLOC(sizeof(unz_s)); - *s=us; - unzGoToFirstFile((unzFile)s); - return (unzFile)s; + s=(unz_s*)ALLOC(sizeof(unz_s)); + *s=us; + unzGoToFirstFile((unzFile)s); + return (unzFile)s; } @@ -439,19 +439,19 @@ extern unzFile ZEXPORT unzOpen (path) these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzClose (file) - unzFile file; + unzFile file; { - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; if (s->pfile_in_zip_read!=NULL) unzCloseCurrentFile(file); - fclose(s->file); - TRYFREE(s); - return UNZ_OK; + fclose(s->file); + TRYFREE(s); + return UNZ_OK; } @@ -460,15 +460,15 @@ extern int ZEXPORT unzClose (file) No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; + unzFile file; + unz_global_info *pglobal_info; { - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; } @@ -495,14 +495,14 @@ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) */ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, unz_file_info *pfile_info, - unz_file_info_internal + unz_file_info_internal *pfile_info_internal, char *szFileName, - uLong fileNameBufferSize, + uLong fileNameBufferSize, void *extraField, - uLong extraFieldBufferSize, + uLong extraFieldBufferSize, char *szComment, - uLong commentBufferSize)); + uLong commentBufferSize)); local int unzlocal_GetCurrentFileInfoInternal (file, pfile_info, @@ -510,156 +510,156 @@ local int unzlocal_GetCurrentFileInfoInternal (file, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; + unzFile file; + unz_file_info *pfile_info; + unz_file_info_internal *pfile_info_internal; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; { - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK) - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; + /* we check the magic */ + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename<fileNameBufferSize) - { - *(szFileName+file_info.size_filename)='\0'; - uSizeRead = file_info.size_filename; - } - else - uSizeRead = fileNameBufferSize; - - if ((file_info.size_filename>0) && (fileNameBufferSize>0)) - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extra<extraFieldBufferSize) - uSizeRead = file_info.size_file_extra; - else - uSizeRead = extraFieldBufferSize; - - if (lSeek!=0) - if (fseek(s->file,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; - - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_comment<commentBufferSize) - { - *(szComment+file_info.size_file_comment)='\0'; - uSizeRead = file_info.size_file_comment; - } - else - uSizeRead = commentBufferSize; - - if (lSeek!=0) - if (fseek(s->file,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; + if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; + if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - return err; + if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename<fileNameBufferSize) + { + *(szFileName+file_info.size_filename)='\0'; + uSizeRead = file_info.size_filename; + } + else + uSizeRead = fileNameBufferSize; + + if ((file_info.size_filename>0) && (fileNameBufferSize>0)) + if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extra<extraFieldBufferSize) + uSizeRead = file_info.size_file_extra; + else + uSizeRead = extraFieldBufferSize; + + if (lSeek!=0) + if (fseek(s->file,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_comment<commentBufferSize) + { + *(szComment+file_info.size_file_comment)='\0'; + uSizeRead = file_info.size_file_comment; + } + else + uSizeRead = commentBufferSize; + + if (lSeek!=0) + if (fseek(s->file,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; } @@ -674,19 +674,19 @@ extern int ZEXPORT unzGetCurrentFileInfo (file, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; + unzFile file; + unz_file_info *pfile_info; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; { - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); } /* @@ -694,20 +694,20 @@ extern int ZEXPORT unzGetCurrentFileInfo (file, return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; + unzFile file; { - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; } @@ -717,27 +717,27 @@ extern int ZEXPORT unzGoToFirstFile (file) return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzGoToNextFile (file) - unzFile file; + unzFile file; { - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; - - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; } @@ -750,48 +750,48 @@ extern int ZEXPORT unzGoToNextFile (file) UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; + unzFile file; + const char *szFileName; + int iCaseSensitivity; { - unz_s* s; - int err; + unz_s* s; + int err; + + uLong num_fileSaved; + uLong pos_in_central_dirSaved; - uLong num_fileSaved; - uLong pos_in_central_dirSaved; - - if (file==NULL) - return UNZ_PARAMERROR; + if (file==NULL) + return UNZ_PARAMERROR; if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; - - err = unzGoToFirstFile(file); - - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - unzGetCurrentFileInfo(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } - - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - return err; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + return err; } @@ -803,182 +803,182 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) (filename and size of extra field data) */ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; + poffset_local_extrafield, + psize_local_extrafield) + unz_s* s; + uInt* piSizeVar; + uLong *poffset_local_extrafield; + uInt *psize_local_extrafield; { - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; - if (fseek(s->file,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; + if (fseek(s->file,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; - if (err==UNZ_OK) - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; /* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; */ - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; + if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; - if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; + if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; - *piSizeVar += (uInt)size_filename; + *piSizeVar += (uInt)size_filename; - if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; + if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; - *piSizeVar += (uInt)size_extra_field; + *piSizeVar += (uInt)size_extra_field; - return err; + return err; } - + /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; + unzFile file; { - int err=UNZ_OK; - int Store; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; + int err=UNZ_OK; + int Store; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; - - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; - - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } - - pfile_in_zip_read_info->stream_initialised=0; - - if ((s->cur_file_info.compression_method!=0) && + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - Store = s->cur_file_info.compression_method==0; + err=UNZ_BADZIPFILE; + Store = s->cur_file_info.compression_method==0; - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; - pfile_in_zip_read_info->file=s->file; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + pfile_in_zip_read_info->file=s->file; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; - if (!Store) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; + if (!Store) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ - } - pfile_in_zip_read_info->rest_read_compressed = + } + pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = + pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; - - s->pfile_in_zip_read = pfile_in_zip_read_info; + s->pfile_in_zip_read = pfile_in_zip_read_info; return UNZ_OK; } @@ -994,126 +994,126 @@ extern int ZEXPORT unzOpenCurrentFile (file) (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; + unzFile file; + voidp buf; + unsigned len; { - int err=UNZ_OK; - uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - if ((pfile_in_zip_read_info->read_buffer == NULL)) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; - pfile_in_zip_read_info->stream.avail_out = (uInt)len; + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - if (len>pfile_in_zip_read_info->rest_read_uncompressed) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) - uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->pos_in_zipfile + + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) + uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, + return UNZ_ERRNO; + if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + return UNZ_ERRNO; + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - pfile_in_zip_read_info->stream.next_in = + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } - if (pfile_in_zip_read_info->compression_method==0) - { - uInt uDoCopy,i ; - if (pfile_in_zip_read_info->stream.avail_out < + if (pfile_in_zip_read_info->compression_method==0) + { + uInt uDoCopy,i ; + if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;i<uDoCopy;i++) - *(pfile_in_zip_read_info->stream.next_out+i) = + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;i<uDoCopy;i++) + *(pfile_in_zip_read_info->stream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - int flush=Z_SYNC_FLUSH; - - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; - - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); - pfile_in_zip_read_info->rest_read_uncompressed -= + pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) - break; - } - } - - if (err==Z_OK) - return iRead; - return err; + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; } @@ -1121,42 +1121,42 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) Give the current position in uncompressed data */ extern z_off_t ZEXPORT unztell (file) - unzFile file; + unzFile file; { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - return (z_off_t)pfile_in_zip_read_info->stream.total_out; + return (z_off_t)pfile_in_zip_read_info->stream.total_out; } /* - return 1 if the end of file was reached, 0 elsewhere + return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (file) - unzFile file; + unzFile file; { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - return 1; - else - return 0; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; } @@ -1169,51 +1169,51 @@ extern int ZEXPORT unzeof (file) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; + unzFile file; + voidp buf; + unsigned len; { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uInt read_now; - uLong size_to_read; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); - - if (buf==NULL) - return (int)size_to_read; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - if (len>size_to_read) - read_now = (uInt)size_to_read; - else - read_now = (uInt)len ; + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); - if (read_now==0) - return 0; + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) - return UNZ_ERRNO; + if (read_now==0) + return 0; + + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) + return UNZ_ERRNO; - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; + if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; - return (int)read_now; + return (int)read_now; } /* @@ -1221,39 +1221,39 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; + unzFile file; { - int err=UNZ_OK; + int err=UNZ_OK; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) - inflateEnd(&pfile_in_zip_read_info->stream); + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; - return err; + return err; } @@ -1263,32 +1263,32 @@ extern int ZEXPORT unzCloseCurrentFile (file) return the number of byte copied or an error code <0 */ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; + unzFile file; + char *szComment; + uLong uSizeBuf; { - int err=UNZ_OK; - unz_s* s; - uLong uReadThis ; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + int err=UNZ_OK; + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) - return UNZ_ERRNO; + if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) + return UNZ_ERRNO; - if (uReadThis>0) + if (uReadThis>0) { *szComment='\0'; - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) - return UNZ_ERRNO; + if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) + return UNZ_ERRNO; } - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; } diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h index 44bd2b493c1..76692cb703c 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h @@ -1,4 +1,4 @@ -/* unzip.h -- IO for uncompress .zip files using zlib +/* unzip.h -- IO for uncompress .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Copyright (C) 1998 Gilles Vollant @@ -33,7 +33,7 @@ */ -/* for more info about .ZIP format, see +/* for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip */ @@ -52,7 +52,7 @@ extern "C" { #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; +typedef struct TagunzFile__ { int unused; } unzFile__; typedef unzFile__ *unzFile; #else typedef voidp unzFile; @@ -69,23 +69,23 @@ typedef voidp unzFile; #define UNZ_CRCERROR (-105) /* tm_unz contain date/time info */ -typedef struct tm_unz_s +typedef struct tm_unz_s { - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ typedef struct unz_global_info_s { - uLong number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; @@ -98,8 +98,8 @@ typedef struct unz_file_info_s uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ @@ -112,15 +112,15 @@ typedef struct unz_file_info_s } unz_file_info; extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); + const char* fileName2, + int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) + or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) + (like 1 on Unix, 2 on Windows) */ @@ -128,11 +128,11 @@ extern unzFile ZEXPORT unzOpen OF((const char *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer - "zlib/zlib111.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. + "zlib/zlib111.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. Else, the return value is a unzFile Handle, usable with other function - of this unzip package. + of this unzip package. */ extern int ZEXPORT unzClose OF((unzFile file)); @@ -143,7 +143,7 @@ extern int ZEXPORT unzClose OF((unzFile file)); return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); + unz_global_info *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed @@ -151,8 +151,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); + char *szComment, + uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. @@ -176,9 +176,9 @@ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); +extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare @@ -190,24 +190,24 @@ extern int ZEXPORT unzLocateFile OF((unzFile file, extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about - the current file + the current file if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) + (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - This is the Central-header version of the extra field + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment - (commentBufferSize is the size of the buffer) + (commentBufferSize is the size of the buffer) */ /***************************************************************************/ @@ -227,10 +227,10 @@ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); Return UNZ_CRCERROR if all the file was read but the CRC is not good */ - -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); + +extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied @@ -249,12 +249,12 @@ extern z_off_t ZEXPORT unztell OF((unzFile file)); extern int ZEXPORT unzeof OF((unzFile file)); /* - return 1 if the end of file was reached, 0 elsewhere + return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); + voidp buf, + unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is @@ -263,9 +263,9 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, if buf==NULL, it return the size of the local extra field if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code */ #ifdef __cplusplus @@ -273,4 +273,3 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, #endif #endif /* _unz_H */ - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c index 25abe71f88c..0cae64ab7b1 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c @@ -1,4 +1,4 @@ -/* zip.c -- IO on .zip files using zlib +/* zip.c -- IO on .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Read zip.h for more info @@ -99,11 +99,11 @@ typedef struct linkedlist_data_s typedef struct { - z_stream stream; /* zLib stream structure for inflate */ + z_stream stream; /* zLib stream structure for inflate */ int stream_initialised; /* 1 is stream is initialised */ uInt pos_in_buffered_data; /* last written byte in buffered_data */ - uLong pos_local_header; /* offset of the local header of the file + uLong pos_local_header; /* offset of the local header of the file currenty writing */ char* central_header; /* central header data for the current file */ uLong size_centralheader; /* size of the central header for cur file */ @@ -166,7 +166,7 @@ local void free_linkedlist(ll) local int add_data_in_datablock(ll,buf,len) - linkedlist_data* ll; + linkedlist_data* ll; const void* buf; uLong len; { @@ -222,7 +222,7 @@ local int add_data_in_datablock(ll,buf,len) local int write_datablock(fout,ll) FILE * fout; - linkedlist_data* ll; + linkedlist_data* ll; { linkedlist_datablock_internal* ldi; ldi = ll->first_block; @@ -322,7 +322,7 @@ extern zipFile ZEXPORT zipOpen (pathname, append) return (zipFile)zi; } -extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, +extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level) @@ -390,7 +390,7 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, zi->ci.stream_initialised = 0; zi->ci.pos_in_buffered_data = 0; zi->ci.pos_local_header = ftell(zi->filezip); - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + + zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); @@ -410,12 +410,12 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); else - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); + ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); else ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); @@ -568,10 +568,10 @@ extern int ZEXPORT zipCloseFileInZip (file) return ZIP_PARAMERROR; zi = (zip_internal*)file; - if (zi->in_opened_file_inzip == 0) + if (zi->in_opened_file_inzip == 0) return ZIP_PARAMERROR; zi->ci.stream.avail_in = 0; - + if (zi->ci.method == Z_DEFLATED) while (err==ZIP_OK) { @@ -618,22 +618,22 @@ extern int ZEXPORT zipCloseFileInZip (file) if (err==ZIP_OK) { long cur_pos_inzip = ftell(zi->filezip); - if (fseek(zi->filezip, + if (fseek(zi->filezip, zi->ci.pos_local_header + 14,SEEK_SET)!=0) - err = ZIP_ERRNO; + err = ZIP_ERRNO; if (err==ZIP_OK) err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */ if (err==ZIP_OK) /* compressed size, unknown */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4); + err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4); if (err==ZIP_OK) /* uncompressed size, unknown */ err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4); - if (fseek(zi->filezip, + if (fseek(zi->filezip, cur_pos_inzip,SEEK_SET)!=0) - err = ZIP_ERRNO; + err = ZIP_ERRNO; } zi->number_entry ++; @@ -701,8 +701,8 @@ extern int ZEXPORT zipClose (file, global_comment) if (err==ZIP_OK) /* size of the central directory */ err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4); - if (err==ZIP_OK) /* offset of start of central directory with respect to the - starting disk number */ + if (err==ZIP_OK) /* offset of start of central directory with respect to the + starting disk number */ err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4); if (err==ZIP_OK) /* zipfile comment length */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h index f6ed94c180f..678260b330b 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h @@ -1,4 +1,4 @@ -/* zip.h -- IO for compress .zip files using zlib +/* zip.h -- IO for compress .zip files using zlib Version 0.15 alpha, Mar 19th, 1998, Copyright (C) 1998 Gilles Vollant @@ -36,7 +36,7 @@ */ -/* for more info about .ZIP format, see +/* for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip @@ -56,7 +56,7 @@ extern "C" { #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zipFile__; +typedef struct TagzipFile__ { int unused; } zipFile__; typedef zipFile__ *zipFile; #else typedef voidp zipFile; @@ -68,19 +68,19 @@ typedef voidp zipFile; #define ZIP_INTERNALERROR (-104) /* tm_zip contain date/time info */ -typedef struct tm_zip_s +typedef struct tm_zip_s { - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ } tm_zip; typedef struct { - tm_zip tmz_date; /* date in understandable format */ + tm_zip tmz_date; /* date in understandable format */ uLong dosDate; /* if dos_date == 0, tmu_date is used */ /* uLong flag; */ /* general purpose bit flag 2 bytes */ @@ -91,27 +91,27 @@ typedef struct extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); /* Create a zipfile. - pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on - an Unix computer "zlib/zlib111.zip". - if the file pathname exist and append=1, the zip will be created at the end - of the file. (useful if the file contain a self extractor code) - If the zipfile cannot be opened, the return value is NULL. + pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on + an Unix computer "zlib/zlib111.zip". + if the file pathname exist and append=1, the zip will be created at the end + of the file. (useful if the file contain a self extractor code) + If the zipfile cannot be opened, the return value is NULL. Else, the return value is a zipFile Handle, usable with other function - of this zip package. + of this zip package. */ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level)); /* Open a file in the ZIP for writing. filename : the filename in zip (if NULL, '-' without quote will be used @@ -126,8 +126,8 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, */ extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const voidp buf, - unsigned len)); + const voidp buf, + unsigned len)); /* Write data in the zipfile */ @@ -138,7 +138,7 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); */ extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); + const char* global_comment)); /* Close the zipfile */ @@ -148,4 +148,3 @@ extern int ZEXPORT zipClose OF((zipFile file, #endif #endif /* _zip_H */ - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c index bfde094c044..4a431ff3163 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c @@ -39,37 +39,37 @@ /* Values used in typeflag field. */ -#define REGTYPE '0' /* regular file */ -#define AREGTYPE '\0' /* regular file */ -#define LNKTYPE '1' /* link */ -#define SYMTYPE '2' /* reserved */ -#define CHRTYPE '3' /* character special */ -#define BLKTYPE '4' /* block special */ -#define DIRTYPE '5' /* directory */ -#define FIFOTYPE '6' /* FIFO special */ -#define CONTTYPE '7' /* reserved */ +#define REGTYPE '0' /* regular file */ +#define AREGTYPE '\0' /* regular file */ +#define LNKTYPE '1' /* link */ +#define SYMTYPE '2' /* reserved */ +#define CHRTYPE '3' /* character special */ +#define BLKTYPE '4' /* block special */ +#define DIRTYPE '5' /* directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* reserved */ #define BLOCKSIZE 512 struct tar_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ +{ /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ }; union tar_buffer { @@ -79,21 +79,21 @@ union tar_buffer { enum { TGZ_EXTRACT = 0, TGZ_LIST }; -static char *TGZfname OF((const char *)); -void TGZnotfound OF((const char *)); +static char *TGZfname OF((const char *)); +void TGZnotfound OF((const char *)); -int getoct OF((char *, int)); -char *strtime OF((time_t *)); -int ExprMatch OF((char *,char *)); +int getoct OF((char *, int)); +char *strtime OF((time_t *)); +int ExprMatch OF((char *,char *)); -int makedir OF((char *)); -int matchname OF((int,int,char **,char *)); +int makedir OF((char *)); +int matchname OF((int,int,char **,char *)); -void error OF((const char *)); -int tar OF((gzFile, int, int, int, char **)); +void error OF((const char *)); +int tar OF((gzFile, int, int, int, char **)); -void help OF((int)); -int main OF((int, char **)); +void help OF((int)); +int main OF((int, char **)); char *prog; @@ -108,7 +108,7 @@ static char *TGZfname OF((const char *fname)) { static char buffer[1024]; int origlen,i; - + strcpy(buffer,fname); origlen = strlen(buffer); @@ -142,14 +142,14 @@ int getoct(char *p,int width) { int result = 0; char c; - + while (width --) { c = *p++; if (c == ' ') - continue; + continue; if (c == 0) - break; + break; result = result * 8 + (c - '0'); } return result; @@ -162,8 +162,8 @@ char *strtime (time_t *t) local = localtime(t); sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", - local->tm_mday, local->tm_mon+1, local->tm_year+1900, - local->tm_hour, local->tm_min, local->tm_sec); + local->tm_mday, local->tm_mon+1, local->tm_year+1900, + local->tm_hour, local->tm_min, local->tm_sec); return result; } @@ -177,30 +177,30 @@ int ExprMatch(char *string,char *expr) while (1) { if (ISSPECIAL(*expr)) - { - if (*expr == '/') - { - if (*string != '\\' && *string != '/') - return 0; - string ++; expr++; - } - else if (*expr == '*') - { - if (*expr ++ == 0) - return 1; - while (*++string != *expr) - if (*string == 0) - return 0; - } - } + { + if (*expr == '/') + { + if (*string != '\\' && *string != '/') + return 0; + string ++; expr++; + } + else if (*expr == '*') + { + if (*expr ++ == 0) + return 1; + while (*++string != *expr) + if (*string == 0) + return 0; + } + } else - { - if (*string != *expr) - return 0; - if (*expr++ == 0) - return 1; - string++; - } + { + if (*string != *expr) + return 0; + if (*expr++ == 0) + return 1; + string++; + } } } @@ -216,7 +216,7 @@ int makedir (char *newdir) char *buffer = strdup(newdir); char *p; int len = strlen(buffer); - + if (len <= 0) { free(buffer); return 0; @@ -234,19 +234,19 @@ int makedir (char *newdir) while (1) { char hold; - + while(*p && *p != '\\' && *p != '/') - p++; + p++; hold = *p; *p = 0; if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) - { - fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); - free(buffer); - return 0; - } + { + fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); + free(buffer); + return 0; + } if (hold == 0) - break; + break; *p++ = hold; } free(buffer); @@ -255,7 +255,7 @@ int makedir (char *newdir) int matchname (int arg,int argc,char **argv,char *fname) { - if (arg == argc) /* no arguments given (untgz tgzarchive) */ + if (arg == argc) /* no arguments given (untgz tgzarchive) */ return 1; while (arg < argc) @@ -278,144 +278,144 @@ int tar (gzFile in,int action,int arg,int argc,char **argv) FILE *outfile = NULL; char fname[BLOCKSIZE]; time_t tartime; - + if (action == TGZ_LIST) printf(" day time size file\n" - " ---------- -------- --------- -------------------------------------\n"); + " ---------- -------- --------- -------------------------------------\n"); while (1) { len = gzread(in, &buffer, BLOCKSIZE); if (len < 0) - error (gzerror(in, &err)); + error (gzerror(in, &err)); /* * Always expect complete blocks to process * the tar information. */ if (len != BLOCKSIZE) - error("gzread: incomplete block read"); - + error("gzread: incomplete block read"); + /* * If we have to get a tar header */ if (getheader == 1) - { - /* - * if we met the end of the tar - * or the end-of-tar block, - * we are done - */ - if ((len == 0) || (buffer.header.name[0]== 0)) break; - - tartime = (time_t)getoct(buffer.header.mtime,12); - strcpy(fname,buffer.header.name); - - switch (buffer.header.typeflag) - { - case DIRTYPE: - if (action == TGZ_LIST) - printf(" %s <dir> %s\n",strtime(&tartime),fname); - if (action == TGZ_EXTRACT) - makedir(fname); - break; - case REGTYPE: - case AREGTYPE: - remaining = getoct(buffer.header.size,12); - if (action == TGZ_LIST) - printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); - if (action == TGZ_EXTRACT) - { - if ((remaining) && (matchname(arg,argc,argv,fname))) - { - outfile = fopen(fname,"wb"); - if (outfile == NULL) { - /* try creating directory */ - char *p = strrchr(fname, '/'); - if (p != NULL) { - *p = '\0'; - makedir(fname); - *p = '/'; - outfile = fopen(fname,"wb"); - } - } - fprintf(stderr, - "%s %s\n", - (outfile) ? "Extracting" : "Couldn't create", - fname); - } - else - outfile = NULL; - } - /* - * could have no contents - */ - getheader = (remaining) ? 0 : 1; - break; - default: - if (action == TGZ_LIST) - printf(" %s <---> %s\n",strtime(&tartime),fname); - break; - } - } + { + /* + * if we met the end of the tar + * or the end-of-tar block, + * we are done + */ + if ((len == 0) || (buffer.header.name[0]== 0)) break; + + tartime = (time_t)getoct(buffer.header.mtime,12); + strcpy(fname,buffer.header.name); + + switch (buffer.header.typeflag) + { + case DIRTYPE: + if (action == TGZ_LIST) + printf(" %s <dir> %s\n",strtime(&tartime),fname); + if (action == TGZ_EXTRACT) + makedir(fname); + break; + case REGTYPE: + case AREGTYPE: + remaining = getoct(buffer.header.size,12); + if (action == TGZ_LIST) + printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); + if (action == TGZ_EXTRACT) + { + if ((remaining) && (matchname(arg,argc,argv,fname))) + { + outfile = fopen(fname,"wb"); + if (outfile == NULL) { + /* try creating directory */ + char *p = strrchr(fname, '/'); + if (p != NULL) { + *p = '\0'; + makedir(fname); + *p = '/'; + outfile = fopen(fname,"wb"); + } + } + fprintf(stderr, + "%s %s\n", + (outfile) ? "Extracting" : "Couldn't create", + fname); + } + else + outfile = NULL; + } + /* + * could have no contents + */ + getheader = (remaining) ? 0 : 1; + break; + default: + if (action == TGZ_LIST) + printf(" %s <---> %s\n",strtime(&tartime),fname); + break; + } + } else - { - unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - - if ((action == TGZ_EXTRACT) && (outfile != NULL)) - { - if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) - { - fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); - fclose(outfile); - unlink(fname); - } - } - remaining -= bytes; - if (remaining == 0) - { - getheader = 1; - if ((action == TGZ_EXTRACT) && (outfile != NULL)) - { + { + unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; + + if ((action == TGZ_EXTRACT) && (outfile != NULL)) + { + if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) + { + fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); + fclose(outfile); + unlink(fname); + } + } + remaining -= bytes; + if (remaining == 0) + { + getheader = 1; + if ((action == TGZ_EXTRACT) && (outfile != NULL)) + { #ifdef WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal; - SYSTEMTIME st; - struct tm localt; - - fclose(outfile); - - localt = *localtime(&tartime); - - hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, 0, NULL); - - st.wYear = (WORD)localt.tm_year+1900; - st.wMonth = (WORD)localt.tm_mon; - st.wDayOfWeek = (WORD)localt.tm_wday; - st.wDay = (WORD)localt.tm_mday; - st.wHour = (WORD)localt.tm_hour; - st.wMinute = (WORD)localt.tm_min; - st.wSecond = (WORD)localt.tm_sec; - st.wMilliseconds = 0; - SystemTimeToFileTime(&st,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,NULL,&ftm); - CloseHandle(hFile); - - outfile = NULL; + HANDLE hFile; + FILETIME ftm,ftLocal; + SYSTEMTIME st; + struct tm localt; + + fclose(outfile); + + localt = *localtime(&tartime); + + hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + + st.wYear = (WORD)localt.tm_year+1900; + st.wMonth = (WORD)localt.tm_mon; + st.wDayOfWeek = (WORD)localt.tm_wday; + st.wDay = (WORD)localt.tm_mday; + st.wHour = (WORD)localt.tm_hour; + st.wMinute = (WORD)localt.tm_min; + st.wSecond = (WORD)localt.tm_sec; + st.wMilliseconds = 0; + SystemTimeToFileTime(&st,&ftLocal); + LocalFileTimeToFileTime(&ftLocal,&ftm); + SetFileTime(hFile,&ftm,NULL,&ftm); + CloseHandle(hFile); + + outfile = NULL; #else - struct utimbuf settime; + struct utimbuf settime; - settime.actime = settime.modtime = tartime; + settime.actime = settime.modtime = tartime; - fclose(outfile); - outfile = NULL; - utime(fname,&settime); + fclose(outfile); + outfile = NULL; + utime(fname,&settime); #endif - } - } + } + } + } } - } - + if (gzclose(in) != Z_OK) error("failed gzclose"); @@ -428,8 +428,8 @@ int tar (gzFile in,int action,int arg,int argc,char **argv) void help(int exitval) { fprintf(stderr, - "untgz v 0.1\n" - " an sample application of zlib 1.0.4\n\n" + "untgz v 0.1\n" + " an sample application of zlib 1.0.4\n\n" "Usage : untgz TGZfile to extract all files\n" " untgz TGZfile fname ... to extract selected files\n" " untgz -l TGZfile to list archive contents\n" @@ -446,50 +446,50 @@ void error(const char *msg) /* ====================================================================== */ -int _CRT_glob = 0; /* disable globbing of the arguments */ +int _CRT_glob = 0; /* disable globbing of the arguments */ int main(int argc,char **argv) { - int action = TGZ_EXTRACT; - int arg = 1; - char *TGZfile; - gzFile *f; - + int action = TGZ_EXTRACT; + int arg = 1; + char *TGZfile; + gzFile *f; + prog = strrchr(argv[0],'\\'); if (prog == NULL) { - prog = strrchr(argv[0],'/'); - if (prog == NULL) - { - prog = strrchr(argv[0],':'); - if (prog == NULL) - prog = argv[0]; - else - prog++; - } - else - prog++; + prog = strrchr(argv[0],'/'); + if (prog == NULL) + { + prog = strrchr(argv[0],':'); + if (prog == NULL) + prog = argv[0]; + else + prog++; + } + else + prog++; } else prog++; - + if (argc == 1) help(0); if (strcmp(argv[arg],"-l") == 0) { - action = TGZ_LIST; - if (argc == ++arg) - help(0); + action = TGZ_LIST; + if (argc == ++arg) + help(0); } else if (strcmp(argv[arg],"-h") == 0) { - help(0); + help(0); } if ((TGZfile = TGZfname(argv[arg])) == NULL) - TGZnotfound(argv[arg]); + TGZnotfound(argv[arg]); ++arg; if ((action == TGZ_LIST) && (arg != argc)) @@ -502,20 +502,20 @@ int main(int argc,char **argv) { case TGZ_LIST: case TGZ_EXTRACT: - f = gzopen(TGZfile,"rb"); - if (f == NULL) - { - fprintf(stderr,"%s: Couldn't gzopen %s\n", - prog, - TGZfile); - return 1; - } - exit(tar(f, action, arg, argc, argv)); + f = gzopen(TGZfile,"rb"); + if (f == NULL) + { + fprintf(stderr,"%s: Couldn't gzopen %s\n", + prog, + TGZfile); + return 1; + } + exit(tar(f, action, arg, argc, argv)); break; - + default: - error("Unknown option!"); - exit(1); + error("Unknown option!"); + exit(1); } return 0; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c b/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c index 797f4f982fa..60deca2ddf4 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c @@ -1,6 +1,6 @@ /* crc32.c -- compute the CRC-32 of a data stream * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ @@ -51,7 +51,7 @@ local void make_crc_table() poly = 0L; for (n = 0; n < sizeof(p)/sizeof(Byte); n++) poly |= 1L << (31 - p[n]); - + for (n = 0; n < 256; n++) { c = (uLong)n; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c index 11568941c4c..16ebdade3f1 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c @@ -1,6 +1,6 @@ /* deflate.c -- compress data using the deflation algorithm * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @@ -194,13 +194,13 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size) int stream_size; { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); + Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) + version, stream_size) z_streamp strm; int level; int method; @@ -221,14 +221,14 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; + return Z_VERSION_ERROR; } if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; if (strm->zalloc == Z_NULL) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; } if (strm->zfree == Z_NULL) strm->zfree = zcfree; @@ -243,7 +243,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, } if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_HUFFMAN_ONLY) { + strategy < 0 || strategy > Z_HUFFMAN_ONLY) { return Z_STREAM_ERROR; } s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); @@ -306,9 +306,9 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) if (length < MIN_MATCH) return Z_OK; if (length > MAX_DIST(s)) { - length = MAX_DIST(s); + length = MAX_DIST(s); #ifndef USE_DICT_HEAD - dictionary += dictLength - length; /* use the tail of the dictionary */ + dictionary += dictLength - length; /* use the tail of the dictionary */ #endif } zmemcpy(s->window, dictionary, length); @@ -322,7 +322,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) s->ins_h = s->window[0]; UPDATE_HASH(s, s->ins_h, s->window[1]); for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); + INSERT_STRING(s, n, hash_head); } if (hash_head) hash_head = 0; /* to make compiler happy */ return Z_OK; @@ -333,7 +333,7 @@ int ZEXPORT deflateReset (strm) z_streamp strm; { deflate_state *s; - + if (strm == Z_NULL || strm->state == Z_NULL || strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; @@ -372,23 +372,23 @@ int ZEXPORT deflateParams(strm, level, strategy) s = strm->state; if (level == Z_DEFAULT_COMPRESSION) { - level = 6; + level = 6; } if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; + return Z_STREAM_ERROR; } func = configuration_table[s->level].func; if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); + /* Flush the last buffer: */ + err = deflate(strm, Z_PARTIAL_FLUSH); } if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; } s->strategy = strategy; return err; @@ -405,7 +405,7 @@ local void putShortMSB (s, b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); -} +} /* ========================================================================= * Flush as much pending output as possible. All deflate() output goes @@ -441,14 +441,14 @@ int ZEXPORT deflate (strm, flush) deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { + flush > Z_FINISH || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { + (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); @@ -465,40 +465,40 @@ int ZEXPORT deflate (strm, flush) if (level_flags > 3) level_flags = 3; header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; + if (s->strstart != 0) header |= PRESET_DICT; header += 31 - (header % 31); s->status = BUSY_STATE; putShortMSB(s, header); - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = 1L; + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = 1L; } /* Flush as much pending output as possible */ if (s->pending != 0) { flush_pending(strm); if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: */ - s->last_flush = -1; - return Z_OK; - } + s->last_flush = -1; + return Z_OK; + } /* Make sure there is something to do and avoid duplicate consecutive * flushes. For repeated and useless calls with Z_FINISH, we keep * returning Z_STREAM_END instead of Z_BUFF_ERROR. */ } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { + flush != Z_FINISH) { ERR_RETURN(strm, Z_BUF_ERROR); } @@ -513,24 +513,24 @@ int ZEXPORT deflate (strm, flush) (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { block_state bstate; - bstate = (*(configuration_table[s->level].func))(s, flush); + bstate = (*(configuration_table[s->level].func))(s, flush); if (bstate == finish_started || bstate == finish_done) { s->status = FINISH_STATE; } if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } if (bstate == block_done) { if (flush == Z_PARTIAL_FLUSH) { _tr_align(s); @@ -544,10 +544,10 @@ int ZEXPORT deflate (strm, flush) } } flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } } } Assert(strm->avail_out > 0, "bug2"); @@ -576,7 +576,7 @@ int ZEXPORT deflateEnd (strm) status = strm->state->status; if (status != INIT_STATE && status != BUSY_STATE && - status != FINISH_STATE) { + status != FINISH_STATE) { return Z_STREAM_ERROR; } @@ -903,10 +903,10 @@ local uInt longest_match(s, cur_match) */ do { } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); @@ -933,10 +933,10 @@ local void check_match(s, start, match, length) if (zmemcmp(s->window + match, s->window + start, length) != EQUAL) { fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + start, match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); z_error("invalid match"); } if (z_verbose > 1) { @@ -995,23 +995,23 @@ local void fill_window(s) later. (Using level 0 permanently is not an optimal usage of zlib, so we don't care about this pathological case.) */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; #ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); #endif more += wsize; } @@ -1056,8 +1056,8 @@ local void fill_window(s) _tr_flush_block(s, (s->block_start >= 0L ? \ (charf *)&s->window[(unsigned)s->block_start] : \ (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ + (ulg)((long)s->strstart - s->block_start), \ + (eof)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ Tracev((stderr,"[FLUSH]")); \ @@ -1098,32 +1098,32 @@ local block_state deflate_stored(s, flush) if (s->lookahead <= 1) { Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); + s->block_start >= (long)s->w_size, "slide too late"); fill_window(s); if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; if (s->lookahead == 0) break; /* flush the current block */ } - Assert(s->block_start >= 0L, "block gone"); + Assert(s->block_start >= 0L, "block gone"); - s->strstart += s->lookahead; - s->lookahead = 0; + s->strstart += s->lookahead; + s->lookahead = 0; - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become + } + /* Flush if we may have to slide, otherwise block_start may become * negative and the data will be gone: */ if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { FLUSH_BLOCK(s, 0); - } + } } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; @@ -1152,8 +1152,8 @@ local block_state deflate_fast(s, flush) if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } + return need_more; + } if (s->lookahead == 0) break; /* flush the current block */ } @@ -1199,10 +1199,10 @@ local block_state deflate_fast(s, flush) * always MIN_MATCH bytes ahead. */ } while (--s->match_length != 0); - s->strstart++; + s->strstart++; } else #endif - { + { s->strstart += s->match_length; s->match_length = 0; s->ins_h = s->window[s->strstart]; @@ -1219,7 +1219,7 @@ local block_state deflate_fast(s, flush) Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; - s->strstart++; + s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } @@ -1249,8 +1249,8 @@ local block_state deflate_slow(s, flush) if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } + return need_more; + } if (s->lookahead == 0) break; /* flush the current block */ } @@ -1297,7 +1297,7 @@ local block_state deflate_slow(s, flush) check_match(s, s->strstart-1, s->prev_match, s->prev_length); _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); + s->prev_length - MIN_MATCH, bflush); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. If there is not @@ -1323,8 +1323,8 @@ local block_state deflate_slow(s, flush) * is longer, truncate the previous match to a single literal. */ Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { FLUSH_BLOCK_ONLY(s, 0); } s->strstart++; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h index 1f5d73ce85d..b99a48a5214 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h @@ -1,6 +1,6 @@ /* deflate.h -- internal compression state * Copyright (C) 1995-2002 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is @@ -269,7 +269,7 @@ typedef struct internal_state { void _tr_init OF((deflate_state *s)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); + int eof)); void _tr_align OF((deflate_state *s)); void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); @@ -312,8 +312,7 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) + flush = _tr_tally(s, distance, length) #endif #endif - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/example.c b/contrib/vmap_extractor_v2/stormlib/zlib/example.c index 83e5d8f0341..e7e3673333e 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/example.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/example.c @@ -1,6 +1,6 @@ /* example.c -- usage example of the zlib compression library * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ @@ -37,22 +37,22 @@ const char dictionary[] = "hello"; uLong dictId; /* Adler32 value of the dictionary */ void test_compress OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_gzio OF((const char *out, const char *in, - Byte *uncompr, int uncomprLen)); + Byte *uncompr, uLong uncomprLen)); +void test_gzio OF((const char *out, const char *in, + Byte *uncompr, int uncomprLen)); void test_deflate OF((Byte *compr, uLong comprLen)); void test_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); + Byte *uncompr, uLong uncomprLen)); void test_large_deflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); + Byte *uncompr, uLong uncomprLen)); void test_large_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); + Byte *uncompr, uLong uncomprLen)); void test_flush OF((Byte *compr, uLong *comprLen)); void test_sync OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); + Byte *uncompr, uLong uncomprLen)); void test_dict_deflate OF((Byte *compr, uLong comprLen)); void test_dict_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); + Byte *uncompr, uLong uncomprLen)); int main OF((int argc, char *argv[])); /* =========================================================================== @@ -75,7 +75,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad uncompress\n"); - exit(1); + exit(1); } else { printf("uncompress(): %s\n", (char *)uncompr); } @@ -103,11 +103,11 @@ void test_gzio(out, in, uncompr, uncomprLen) gzputc(file, 'h'); if (gzputs(file, "ello") != 4) { fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); - exit(1); + exit(1); } if (gzprintf(file, ", %s!", "hello") != 8) { fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); - exit(1); + exit(1); } gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ gzclose(file); @@ -121,36 +121,36 @@ void test_gzio(out, in, uncompr, uncomprLen) uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); if (uncomprLen != len) { fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); - exit(1); + exit(1); } if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); - exit(1); + exit(1); } else { printf("gzread(): %s\n", (char *)uncompr); } pos = gzseek(file, -8L, SEEK_CUR); if (pos != 6 || gztell(file) != pos) { - fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", - (long)pos, (long)gztell(file)); - exit(1); + fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", + (long)pos, (long)gztell(file)); + exit(1); } if (gzgetc(file) != ' ') { - fprintf(stderr, "gzgetc error\n"); - exit(1); + fprintf(stderr, "gzgetc error\n"); + exit(1); } gzgets(file, (char*)uncompr, uncomprLen); uncomprLen = strlen((char*)uncompr); if (uncomprLen != 6) { /* "hello!" */ fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); - exit(1); + exit(1); } if (strcmp((char*)uncompr, hello+7)) { fprintf(stderr, "bad gzgets after gzseek\n"); - exit(1); + exit(1); } else { printf("gzgets() after gzseek: %s\n", (char *)uncompr); } @@ -231,7 +231,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad inflate\n"); - exit(1); + exit(1); } else { printf("inflate(): %s\n", (char *)uncompr); } @@ -266,7 +266,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) CHECK_ERR(err, "deflate"); if (c_stream.avail_in != 0) { fprintf(stderr, "deflate not greedy\n"); - exit(1); + exit(1); } /* Feed in already compressed data and switch to no compression: */ @@ -286,7 +286,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); + exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); @@ -316,7 +316,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) for (;;) { d_stream.next_out = uncompr; /* discard the output */ - d_stream.avail_out = (uInt)uncomprLen; + d_stream.avail_out = (uInt)uncomprLen; err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "large inflate"); @@ -327,7 +327,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) if (d_stream.total_out != 2*uncomprLen + comprLen/2) { fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); - exit(1); + exit(1); } else { printf("large_inflate(): OK\n"); } @@ -407,7 +407,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) if (err != Z_DATA_ERROR) { fprintf(stderr, "inflate should report DATA_ERROR\n"); /* Because of incorrect adler32 */ - exit(1); + exit(1); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); @@ -433,7 +433,7 @@ void test_dict_deflate(compr, comprLen) CHECK_ERR(err, "deflateInit"); err = deflateSetDictionary(&c_stream, - (const Bytef*)dictionary, sizeof(dictionary)); + (const Bytef*)dictionary, sizeof(dictionary)); CHECK_ERR(err, "deflateSetDictionary"); dictId = c_stream.adler; @@ -446,7 +446,7 @@ void test_dict_deflate(compr, comprLen) err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); + exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); @@ -480,14 +480,14 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) for (;;) { err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; - if (err == Z_NEED_DICT) { - if (d_stream.adler != dictId) { - fprintf(stderr, "unexpected dictionary"); - exit(1); - } - err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, - sizeof(dictionary)); - } + if (err == Z_NEED_DICT) { + if (d_stream.adler != dictId) { + fprintf(stderr, "unexpected dictionary"); + exit(1); + } + err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, + sizeof(dictionary)); + } CHECK_ERR(err, "inflate with dict"); } @@ -496,7 +496,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad inflate with dict\n"); - exit(1); + exit(1); } else { printf("inflate with dictionary: %s\n", (char *)uncompr); } @@ -530,13 +530,13 @@ int main(argc, argv) */ if (compr == Z_NULL || uncompr == Z_NULL) { printf("out of memory\n"); - exit(1); + exit(1); } test_compress(compr, comprLen, uncompr, uncomprLen); test_gzio((argc > 1 ? argv[1] : TESTFILE), (argc > 2 ? argv[2] : TESTFILE), - uncompr, (int)uncomprLen); + uncompr, (int)uncomprLen); test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c b/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c index 36a371cdebc..09e0a20b8ce 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c @@ -112,17 +112,17 @@ local gzFile gz_open (path, mode, fd) if (*p == 'r') s->mode = 'r'; if (*p == 'w' || *p == 'a') s->mode = 'w'; if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else { - *m++ = *p; /* copy the mode */ - } + level = *p - '0'; + } else if (*p == 'f') { + strategy = Z_FILTERED; + } else if (*p == 'h') { + strategy = Z_HUFFMAN_ONLY; + } else { + *m++ = *p; /* copy the mode */ + } } while (*p++ && m != fmode + sizeof(fmode)); if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - + if (s->mode == 'w') { #ifdef NO_DEFLATE err = Z_STREAM_ERROR; @@ -163,17 +163,17 @@ local gzFile gz_open (path, mode, fd) */ fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->startpos = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an + s->startpos = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an * fflush on some systems. This version of the library doesn't use * startpos anyway in write mode, so this initialization is not * necessary. */ } else { - check_header(s); /* skip the .gz header */ - s->startpos = (ftell(s->file) - s->stream.avail_in); + check_header(s); /* skip the .gz header */ + s->startpos = (ftell(s->file) - s->stream.avail_in); } - + return (gzFile)s; } @@ -218,11 +218,11 @@ int ZEXPORT gzsetparams (file, level, strategy) /* Make room to allow flushing */ if (s->stream.avail_out == 0) { - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + } + s->stream.avail_out = Z_BUFSIZE; } return deflateParams (&(s->stream), level, strategy); @@ -238,14 +238,14 @@ local int get_byte(s) { if (s->z_eof) return EOF; if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; + errno = 0; + s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) s->z_err = Z_ERRNO; + return EOF; + } + s->stream.next_in = s->inbuf; } s->stream.avail_in--; return *(s->stream.next_in)++; @@ -270,41 +270,41 @@ local void check_header(s) /* Check the gzip magic header */ for (len = 0; len < 2; len++) { - c = get_byte(s); - if (c != gz_magic[len]) { - if (len != 0) s->stream.avail_in++, s->stream.next_in--; - if (c != EOF) { - s->stream.avail_in++, s->stream.next_in--; - s->transparent = 1; - } - s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; - return; - } + c = get_byte(s); + if (c != gz_magic[len]) { + if (len != 0) s->stream.avail_in++, s->stream.next_in--; + if (c != EOF) { + s->stream.avail_in++, s->stream.next_in--; + s->transparent = 1; + } + s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; + return; + } } method = get_byte(s); flags = get_byte(s); if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; + s->z_err = Z_DATA_ERROR; + return; } /* Discard time, xflags and OS code: */ for (len = 0; len < 6; len++) (void)get_byte(s); if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; + len = (uInt)get_byte(s); + len += ((uInt)get_byte(s))<<8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(s) != EOF) ; } if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; + while ((c = get_byte(s)) != 0 && c != EOF) ; } if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; + while ((c = get_byte(s)) != 0 && c != EOF) ; } if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); + for (len = 0; len < 2; len++) (void)get_byte(s); } s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; } @@ -323,21 +323,21 @@ local int destroy (s) TRYFREE(s->msg); if (s->stream.state != NULL) { - if (s->mode == 'w') { + if (s->mode == 'w') { #ifdef NO_DEFLATE - err = Z_STREAM_ERROR; + err = Z_STREAM_ERROR; #else - err = deflateEnd(&(s->stream)); + err = deflateEnd(&(s->stream)); #endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } + } else if (s->mode == 'r') { + err = inflateEnd(&(s->stream)); + } } if (s->file != NULL && fclose(s->file)) { #ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ + if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ #endif - err = Z_ERRNO; + err = Z_ERRNO; } if (s->z_err < 0) err = s->z_err; @@ -372,69 +372,69 @@ int ZEXPORT gzread (file, buf, len) while (s->stream.avail_out != 0) { - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, - s->file); - } - len -= s->stream.avail_out; - s->stream.total_in += (uLong)len; - s->stream.total_out += (uLong)len; + if (s->transparent) { + /* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + if (n > s->stream.avail_out) n = s->stream.avail_out; + if (n > 0) { + zmemcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) { + s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, + s->file); + } + len -= s->stream.avail_out; + s->stream.total_in += (uLong)len; + s->stream.total_out += (uLong)len; if (len == 0) s->z_eof = 1; - return (int)len; - } + return (int)len; + } if (s->stream.avail_in == 0 && !s->z_eof) { errno = 0; s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); if (s->stream.avail_in == 0) { s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } + if (ferror(s->file)) { + s->z_err = Z_ERRNO; + break; + } } s->stream.next_in = s->inbuf; } s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; + if (s->z_err == Z_STREAM_END) { + /* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + start = s->stream.next_out; - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); + if (getLong(s) != s->crc) { + s->z_err = Z_DATA_ERROR; + } else { + (void)getLong(s); /* The uncompressed length returned by above getlong() may * be different from s->stream.total_out) in case of - * concatenated .gz files. Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - uLong total_in = s->stream.total_in; - uLong total_out = s->stream.total_out; - - inflateReset(&(s->stream)); - s->stream.total_in = total_in; - s->stream.total_out = total_out; - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; + * concatenated .gz files. Check for such files: + */ + check_header(s); + if (s->z_err == Z_OK) { + uLong total_in = s->stream.total_in; + uLong total_out = s->stream.total_out; + + inflateReset(&(s->stream)); + s->stream.total_in = total_in; + s->stream.total_out = total_out; + s->crc = crc32(0L, Z_NULL, 0); + } + } + } + if (s->z_err != Z_OK || s->z_eof) break; } s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); @@ -543,21 +543,21 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) #else /* not ANSI C */ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) gzFile file; const char *format; int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; { char buf[Z_PRINTF_BUFSIZE]; int len; #ifdef HAS_snprintf snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); #else sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); #endif len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */ if (len <= 0) return 0; @@ -623,14 +623,14 @@ local int do_flush (file, flush) if (done) break; s->z_err = deflate(&(s->stream), flush); - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; + /* Ignore the second of two consecutive flushes: */ + if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: + * all the available space in the output buffer: */ done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; } return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; @@ -665,84 +665,84 @@ z_off_t ZEXPORT gzseek (file, offset, whence) gz_stream *s = (gz_stream*)file; if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; + s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { + return -1L; } - + if (s->mode == 'w') { #ifdef NO_DEFLATE - return -1L; + return -1L; #else - if (whence == SEEK_SET) { - offset -= s->stream.total_in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return (z_off_t)s->stream.total_in; + if (whence == SEEK_SET) { + offset -= s->stream.total_in; + } + if (offset < 0) return -1L; + + /* At this point, offset is the number of zero bytes to write. */ + if (s->inbuf == Z_NULL) { + s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ + zmemzero(s->inbuf, Z_BUFSIZE); + } + while (offset > 0) { + uInt size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (uInt)offset; + + size = gzwrite(file, s->inbuf, size); + if (size == 0) return -1L; + + offset -= size; + } + return (z_off_t)s->stream.total_in; #endif } /* Rest of function is for reading only */ /* compute absolute position */ if (whence == SEEK_CUR) { - offset += s->stream.total_out; + offset += s->stream.total_out; } if (offset < 0) return -1L; if (s->transparent) { - /* map to fseek */ - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; + /* map to fseek */ + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - s->stream.total_in = s->stream.total_out = (uLong)offset; - return offset; + s->stream.total_in = s->stream.total_out = (uLong)offset; + return offset; } /* For a negative seek, rewind and use positive seek */ if ((uLong)offset >= s->stream.total_out) { - offset -= s->stream.total_out; + offset -= s->stream.total_out; } else if (gzrewind(file) < 0) { - return -1L; + return -1L; } /* offset is now the number of bytes to skip. */ if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); + s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); } while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; + int size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (int)offset; - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; + size = gzread(file, s->outbuf, (uInt)size); + if (size <= 0) return -1L; + offset -= size; } return (z_off_t)s->stream.total_out; } /* =========================================================================== - Rewinds input file. + Rewinds input file. */ int ZEXPORT gzrewind (file) gzFile file; { gz_stream *s = (gz_stream*)file; - + if (s == NULL || s->mode != 'r') return -1; s->z_err = Z_OK; @@ -750,10 +750,10 @@ int ZEXPORT gzrewind (file) s->stream.avail_in = 0; s->stream.next_in = s->inbuf; s->crc = crc32(0L, Z_NULL, 0); - + if (s->startpos == 0) { /* not a compressed file */ - rewind(s->file); - return 0; + rewind(s->file); + return 0; } (void) inflateReset(&s->stream); @@ -779,7 +779,7 @@ int ZEXPORT gzeof (file) gzFile file; { gz_stream *s = (gz_stream*)file; - + return (s == NULL || s->mode != 'r') ? 0 : s->z_eof; } @@ -829,7 +829,7 @@ int ZEXPORT gzclose (file) if (s->mode == 'w') { #ifdef NO_DEFLATE - return Z_STREAM_ERROR; + return Z_STREAM_ERROR; #else err = do_flush (file, Z_FINISH); if (err != Z_OK) return destroy((gz_stream*)file); diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c index 4e4e2e15d96..dd7a6d40a8d 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c @@ -1,6 +1,6 @@ /* infblock.c -- interpret and process block types to last block * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" @@ -393,7 +393,7 @@ uInt n; /* Returns true if inflate is currently at the end of a block generated - * by Z_SYNC_FLUSH or Z_FULL_FLUSH. + * by Z_SYNC_FLUSH or Z_FULL_FLUSH. * IN assertion: s != Z_NULL */ int inflate_blocks_sync_point(s) diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h index 0754c173476..173b2267ade 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h @@ -1,6 +1,6 @@ /* infblock.h -- header to use infblock.c * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is @@ -37,4 +37,3 @@ extern void inflate_set_dictionary OF(( extern int inflate_blocks_sync_point OF(( inflate_blocks_statef *s)); - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c index 0af7a5be75c..9abe5412b9c 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c @@ -1,6 +1,6 @@ /* infcodes.c -- process literals and length/distance pairs * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h index 7e237254d41..46821a02be6 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h @@ -1,6 +1,6 @@ /* infcodes.h -- header to use infcodes.c * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is @@ -25,4 +25,3 @@ extern void inflate_codes_free OF(( inflate_codes_statef *, z_streamp )); - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c index 4e918dbdc67..aa7f1d4d2ad 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c @@ -1,6 +1,6 @@ /* inffast.c -- process literals and length/distance pairs fast * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h index ba2d3a85c49..a31a4bbb058 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h @@ -1,6 +1,6 @@ /* inffast.h -- header to use inffast.c * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is @@ -15,4 +15,3 @@ extern int inflate_fast OF(( inflate_huft *, inflate_blocks_statef *, z_streamp )); - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h b/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h index 708d69016ea..77f7e763145 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h @@ -149,4 +149,3 @@ local inflate_huft fixed_td[] = { {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} }; - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c b/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c index 3ac2efb900d..dfb2e867d81 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c @@ -1,6 +1,6 @@ /* inflate.c -- zlib interface to inflate modules * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" @@ -44,7 +44,7 @@ struct internal_state { /* mode independent information */ int nowrap; /* flag for no wrapper */ uInt wbits; /* log2(window size) (8..15, defaults to 15) */ - inflate_blocks_statef + inflate_blocks_statef *blocks; /* current inflate_blocks state */ }; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c index a64a23ff61d..4c32ca30d99 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c @@ -1,6 +1,6 @@ /* inftrees.c -- generate Huffman trees for efficient decoding * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h index abd115caf7a..04b73b7296a 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h @@ -1,6 +1,6 @@ /* inftrees.h -- header to use inftrees.c * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is @@ -56,4 +56,3 @@ extern int inflate_trees_fixed OF(( inflate_huft * FAR *, /* literal/length tree result */ inflate_huft * FAR *, /* distance tree result */ z_streamp)); /* for memory allocation */ - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c index b3189642085..9a076221f2a 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c @@ -1,6 +1,6 @@ /* inflate_util.c -- data and routines common to blocks and codes * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h index 404a8042ebb..4401df82fc8 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h @@ -1,6 +1,6 @@ /* infutil.h -- types and macros common to blocks and codes * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is @@ -41,7 +41,7 @@ struct inflate_blocks_state { inflate_huft *tb; /* bit length decoding tree */ } trees; /* if DTREE, decoding info for trees */ struct { - inflate_codes_statef + inflate_codes_statef *codes; } decode; /* if CODES, current state */ } sub; /* submode */ @@ -96,4 +96,3 @@ extern int inflate_flush OF(( struct internal_state {int dummy;}; /* for buggy compilers */ #endif - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c b/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c index 6eea67ed6da..a16d4b14608 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c @@ -1,6 +1,6 @@ /* maketree.c -- make inffixed.h table for decoding fixed codes * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c b/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c index c71e743a548..97b7c2d93b2 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c @@ -1,6 +1,6 @@ /* minigzip.c -- simulate gzip using the zlib compression library * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @@ -147,7 +147,7 @@ int gz_compress_mmap(in, out) if (buf_len <= 0) return Z_ERRNO; /* Now do the actual mmap: */ - buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); + buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); if (buf == (caddr_t)(-1)) return Z_ERRNO; /* Compress the whole file at once: */ @@ -179,8 +179,8 @@ void gz_uncompress(in, out) if (len == 0) break; if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { - error("failed fwrite"); - } + error("failed fwrite"); + } } if (fclose(out)) error("failed fclose"); @@ -282,16 +282,16 @@ int main(argc, argv) while (argc > 0) { if (strcmp(*argv, "-d") == 0) - uncompr = 1; + uncompr = 1; else if (strcmp(*argv, "-f") == 0) - outmode[3] = 'f'; + outmode[3] = 'f'; else if (strcmp(*argv, "-h") == 0) - outmode[3] = 'h'; + outmode[3] = 'h'; else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && - (*argv)[2] == 0) - outmode[2] = (*argv)[1]; + (*argv)[2] == 0) + outmode[2] = (*argv)[1]; else - break; + break; argc--, argv++; } if (argc == 0) { diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/trees.c b/contrib/vmap_extractor_v2/stormlib/zlib/trees.c index d4da040ae9d..0a984056738 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/trees.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/trees.c @@ -1,6 +1,6 @@ /* trees.c -- output deflated data using Huffman coding * Copyright (C) 1995-2002 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @@ -335,42 +335,42 @@ void gen_trees_header() Assert (header != NULL, "Can't open trees.h"); fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); + "/* header created automatically with -DGEN_TREES_H */\n\n"); fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); } fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); } fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); } fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); } fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); } fprintf(header, "local const int base_dist[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); } fclose(header); @@ -930,39 +930,39 @@ void _tr_flush_block(s, buf, stored_len, eof) /* Build the Huffman trees unless a stored block is forced */ if (s->level > 0) { - /* Check if the file is ascii or binary */ - if (s->data_type == Z_UNKNOWN) set_data_type(s); + /* Check if the file is ascii or binary */ + if (s->data_type == Z_UNKNOWN) set_data_type(s); - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); - /* Determine the best encoding. Compute first the block length in bytes*/ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; + /* Determine the best encoding. Compute first the block length in bytes*/ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; } else { Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } #ifdef FORCE_STORED @@ -1199,7 +1199,7 @@ local void copy_block(s, buf, len, header) s->last_eob_len = 8; /* enough lookahead for inflate */ if (header) { - put_short(s, (ush)len); + put_short(s, (ush)len); put_short(s, (ush)~len); #ifdef DEBUG s->bits_sent += 2*16; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/trees.h b/contrib/vmap_extractor_v2/stormlib/zlib/trees.h index ba8cd78357b..72facf900f7 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/trees.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/trees.h @@ -126,4 +126,3 @@ local const int base_dist[D_CODES] = { 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 }; - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c b/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c index fdd495ff4ba..a287714f5de 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c @@ -1,6 +1,6 @@ /* uncompr.c -- decompress a memory buffer * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h b/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h index a22b4b058e6..eb0ae2e1a0c 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h @@ -1,6 +1,6 @@ /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ @@ -13,39 +13,39 @@ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. */ #ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ # define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define inflateInit2_ z_inflateInit2_ +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync +# define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint -# define inflateReset z_inflateReset -# define compress z_compress -# define compress2 z_compress2 -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 # define get_crc_table z_get_crc_table -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp #endif #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) @@ -277,4 +277,3 @@ typedef uLong FAR uLongf; #endif #endif /* _ZCONF_H */ - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h index 4f6380eeb9c..52cb529f6f3 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h @@ -39,7 +39,7 @@ extern "C" { #define ZLIB_VERSION "1.1.4" -/* +/* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method @@ -175,7 +175,7 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); This check is automatically made by deflateInit and inflateInit. */ -/* +/* ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); Initializes the internal stream state for compression. The fields @@ -253,7 +253,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. - + Z_FINISH can be used immediately after deflateInit if all the compression is to be done in a single step. In this case, avail_out must be at least 0.1% larger than avail_in plus 12 bytes. If deflate does not return @@ -290,7 +290,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); */ -/* +/* ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields @@ -359,7 +359,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); If a preset dictionary is needed at this point (see inflateSetDictionary below), inflate sets strm-adler to the adler32 checksum of the - dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() @@ -397,7 +397,7 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); The following functions are needed only in some special applications. */ -/* +/* ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, int level, int method, @@ -440,7 +440,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, method). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ - + ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); @@ -507,8 +507,8 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); */ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); + int level, + int strategy)); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be @@ -527,7 +527,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, if strm->avail_out was zero. */ -/* +/* ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, int windowBits)); @@ -570,7 +570,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, */ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* +/* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. @@ -701,8 +701,8 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); gzread returns the number of uncompressed bytes actually read (0 for end of file, -1 for error). */ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written @@ -755,8 +755,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); */ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* + z_off_t offset, int whence)); +/* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); @@ -891,4 +891,3 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #endif #endif /* _ZLIB_H */ - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c index b3189642085..9a076221f2a 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c +++ b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c @@ -1,6 +1,6 @@ /* inflate_util.c -- data and routines common to blocks and codes * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h index c11cd2ef1f5..718ebc15be1 100644 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h +++ b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h @@ -208,7 +208,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, - uInt len)); + uInt len)); voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); void zcfree OF((voidpf opaque, voidpf ptr)); @@ -218,4 +218,3 @@ void zcfree OF((voidpf opaque, voidpf ptr)); #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} #endif /* _Z_UTIL_H */ - diff --git a/contrib/vmap_extractor_v2/stormlibdll/DllMain.c b/contrib/vmap_extractor_v2/stormlibdll/DllMain.c index d5ef37fc106..cbfa84a08a8 100644 --- a/contrib/vmap_extractor_v2/stormlibdll/DllMain.c +++ b/contrib/vmap_extractor_v2/stormlibdll/DllMain.c @@ -20,5 +20,5 @@ DWORD WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved) UNREFERENCED_PARAMETER(dwReason); UNREFERENCED_PARAMETER(lpReserved); - return TRUE; + return TRUE; } diff --git a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp index f624a3263cd..49717c04748 100644 --- a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp @@ -1,5 +1,6 @@ #include "adtfile.h" +#include <algorithm> char * GetPlainName(char * FileName) { @@ -12,7 +13,8 @@ char * GetPlainName(char * FileName) void fixnamen(char *name, size_t len) { - for (size_t i=0; i<len-3; i++) { + for (size_t i=0; i<len-3; i++) + { if (i>0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1])) { name[i] |= 0x20; @@ -22,6 +24,7 @@ void fixnamen(char *name, size_t len) } } } + void fixname2(char *name, size_t len) { for (size_t i=0; i<len-3; i++) @@ -38,7 +41,6 @@ ADTFile::ADTFile(char* filename): ADT(filename) bool ADTFile::init(char *map_id) { - if(ADT.isEof ()) return false; @@ -68,8 +70,7 @@ bool ADTFile::init(char *map_id) return false; } - - while (!ADT.isEof ()) + while (!ADT.isEof()) { char fourcc[5]; ADT.read(&fourcc,4); @@ -77,18 +78,16 @@ bool ADTFile::init(char *map_id) flipcc(fourcc); fourcc[4] = 0; - size_t nextpos = ADT.getPos () + size; + size_t nextpos = ADT.getPos() + size; - if (!strcmp(fourcc,"MCIN"))//MCIN + if (!strcmp(fourcc,"MCIN")) { - } else if (!strcmp(fourcc,"MTEX")) { } else if (!strcmp(fourcc,"MMDX")) { - if (size) { char *buf = new char[size]; @@ -104,35 +103,39 @@ bool ADTFile::init(char *map_id) fixname2(s,strlen(s)); p=p+strlen(p)+1; ModelInstansName[t++] = s; - path.erase(path.length()-2,2); - path.append("2"); - char* szLocalFile[512]; - sprintf((char*)szLocalFile, ".\\buildings\\%s", s); - FILE * output = fopen((char*)szLocalFile,"rb"); - if(!output) + + // < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file + std::string ext3 = path.size() >= 4 ? path.substr(path.size()-4,4) : ""; + std::transform( ext3.begin(), ext3.end(), ext3.begin(), ::tolower ); + if(ext3 == ".mdx") { + // replace .mdx -> .m2 + path.erase(path.length()-2,2); + path.append("2"); + } + // >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file + // nothing do + char szLocalFile[MAX_PATH]; + sprintf(szLocalFile, ".\\buildings\\%s", s); + FILE * output = fopen(szLocalFile,"rb"); + if(!output) + { Model * m2 = new Model(path); if(m2->open()) - { - m2->ConvertToVMAPModel((char*)szLocalFile); - } + m2->ConvertToVMAPModel(szLocalFile); delete m2; - } else - fclose(output); + fclose(output); } - delete[] buf; } - } else if (!strcmp(fourcc,"MWMO")) { if (size) { - char *buf = new char[size]; ADT.read(buf, size); char *p=buf; @@ -148,23 +151,21 @@ bool ADTFile::init(char *map_id) WmoInstansName[q++] = s; } delete[] buf; - } - } //====================== else if (!strcmp(fourcc,"MDDF")) { if (size) { - nMDX = (int)size / 36; - for (int i=0; i<nMDX; i++) + nMDX = (int)size / 36; + for (int i=0; i<nMDX; ++i) { int id; ADT.read(&id, 4); ModelInstance inst(ADT,ModelInstansName[id].c_str(),map_id, dirfile);//!!!!!!!!!!! } - delete[] ModelInstansName; + delete[] ModelInstansName; } } else if (!strcmp(fourcc,"MODF")) @@ -172,7 +173,7 @@ bool ADTFile::init(char *map_id) if (size) { nWMO = (int)size / 64; - for (int i=0; i<nWMO; i++) + for (int i=0; i<nWMO; ++i) { int id; ADT.read(&id, 4); @@ -187,14 +188,14 @@ bool ADTFile::init(char *map_id) { if (size) { - nMDX = (int)size / 36; - for (int i=0; i<nMDX; i++) + nMDX = (int)size / 36; + for (int i=0; i<nMDX; ++i) { int id; ADT.read(&id, 4); ModelInstance inst(ADT,ModelInstansName[id].c_str(),AdtMapNumber.c_str(), dirfile); } - delete[] ModelInstansName; + delete[] ModelInstansName; } } else if (!strcmp(fourcc,"MODF")) @@ -202,7 +203,7 @@ bool ADTFile::init(char *map_id) if (size) { nWMO = (int)size / 64; - for (int i=0; i<nWMO; i++) + for (int i=0; i<nWMO; ++i) { int id; ADT.read(&id, 4); @@ -223,6 +224,3 @@ ADTFile::~ADTFile() { ADT.close(); } - - - diff --git a/contrib/vmap_extractor_v2/vmapextract/adtfile.h b/contrib/vmap_extractor_v2/vmapextract/adtfile.h index 959e1a05f7f..0ce5851ab79 100644 --- a/contrib/vmap_extractor_v2/vmapextract/adtfile.h +++ b/contrib/vmap_extractor_v2/vmapextract/adtfile.h @@ -17,43 +17,48 @@ typedef unsigned int uint32; class Liquid; -typedef struct { -float x; -float y; -float z; +typedef struct +{ + float x; + float y; + float z; }svec; -typedef struct { -double x; -double y; -double z; -}vec; +struct vec +{ + double x; + double y; + double z; +}; -typedef struct{ +struct triangle +{ vec v[3]; +}; -}triangle; - -typedef struct{ -float v9[16*8+1][16*8+1]; -float v8[16*8][16*8]; +typedef struct +{ + float v9[16*8+1][16*8+1]; + float v8[16*8][16*8]; }Cell; -typedef struct{ -double v9[9][9]; -double v8[8][8]; -uint16 area_id; -//Liquid *lq; -float waterlevel[9][9]; -uint8 flag; +typedef struct +{ + double v9[9][9]; + double v8[8][8]; + uint16 area_id; + //Liquid *lq; + float waterlevel[9][9]; + uint8 flag; }chunk; typedef struct { -chunk ch[16][16]; + chunk ch[16][16]; }mcell; -struct MapChunkHeader { +struct MapChunkHeader +{ uint32 flags; uint32 ix; uint32 iy; @@ -119,7 +124,4 @@ private: void fixnamen(char *name, size_t len); //void fixMapNamen(char *name, size_t len); - #endif - - diff --git a/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp b/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp index 909f7afd570..52eb18c42b7 100644 --- a/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp @@ -22,8 +22,8 @@ bool DBCFile::open() f.read(header,4); // File Header - if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C') { - + if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C') + { f.close(); data = NULL; printf("Critical Error: An error occured while trying to read the DBCFile %s.", filename.c_str()); @@ -67,10 +67,9 @@ DBCFile::Iterator DBCFile::begin() assert(data); return Iterator(*this, data); } + DBCFile::Iterator DBCFile::end() { assert(data); return Iterator(*this, stringTable); } - - diff --git a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h index 4106342a2cc..002e7eeeb20 100644 --- a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h +++ b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h @@ -137,4 +137,3 @@ private: }; #endif - diff --git a/contrib/vmap_extractor_v2/vmapextract/model.cpp b/contrib/vmap_extractor_v2/vmapextract/model.cpp index e5106dca65a..9605e3320ab 100644 --- a/contrib/vmap_extractor_v2/vmapextract/model.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/model.cpp @@ -12,7 +12,7 @@ bool Model::open() ok = !f.isEof(); - if (!ok) + if (!ok) { f.close(); printf("Error loading model %s\n", filename.c_str()); @@ -20,20 +20,20 @@ bool Model::open() } memcpy(&header, f.getBuffer(), sizeof(ModelHeader)); - if(header.nBoundingTriangles > 0) + if(header.nBoundingTriangles > 0) { f.seek(0); - f.seekRelative(header.ofsBoundingVertices); - vertices = new Vec3D[header.nBoundingVertices]; - f.read(vertices,header.nBoundingVertices*12); + f.seekRelative(header.ofsBoundingVertices); + vertices = new Vec3D[header.nBoundingVertices]; + f.read(vertices,header.nBoundingVertices*12); for (uint32 i=0; i<header.nBoundingVertices; i++) { vertices[i] = fixCoordSystem(vertices[i]); } f.seek(0); - f.seekRelative(header.ofsBoundingTriangles); - indices = new uint16[header.nBoundingTriangles]; - f.read(indices,header.nBoundingTriangles*2); + f.seekRelative(header.ofsBoundingTriangles); + indices = new uint16[header.nBoundingTriangles]; + f.read(indices,header.nBoundingTriangles*2); f.close(); } else @@ -45,10 +45,8 @@ bool Model::open() return true; } - bool Model::ConvertToVMAPModel(char * outfilename) { - int N[] = {0x00000000}; FILE * output=fopen(outfilename,"wb"); if(!output) @@ -76,7 +74,7 @@ bool Model::ConvertToVMAPModel(char * outfilename) wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes; fwrite(&wsize, sizeof(int), 1, output); fwrite(&nIndexes, sizeof(uint32), 1, output); - if(nIndexes >0) + if(nIndexes >0) { fwrite(indices, sizeof(unsigned short), nIndexes, output); } @@ -84,7 +82,7 @@ bool Model::ConvertToVMAPModel(char * outfilename) wsize = sizeof(int) + sizeof(float) * 3 * nVertices; fwrite(&wsize, sizeof(int), 1, output); fwrite(&nVertices, sizeof(int), 1, output); - if(nVertices >0) + if(nVertices >0) { for(uint32 vpos=0; vpos <nVertices; ++vpos) { @@ -133,27 +131,25 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map sprintf(tempname, ".\\buildings\\%s", ModelInstName); FILE *input; input = fopen(tempname, "r+b"); + if(!input) - { return; - } + fseek(input, 8, SEEK_SET); // get the correct no of vertices - int nVertices; - fread(&nVertices, sizeof (int), 1, input); - fclose(input); + int nVertices; + fread(&nVertices, sizeof (int), 1, input); + fclose(input); + if(nVertices == 0) - { return; - } - if(pDirfile) + if(pDirfile) { int realx1 = (int) ((float) pos.x / 533.333333f); int realy1 = (int) ((float) pos.z / 533.333333f); int realx2 = (int) ((float) pos.x / 533.333333f); int realy2 = (int) ((float) pos.z / 533.333333f); - fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n", MapName, ModelInstName, @@ -163,7 +159,6 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map nVertices, realx1, realy1, realx2, realy2 - ); + ); } } - diff --git a/contrib/vmap_extractor_v2/vmapextract/model.h b/contrib/vmap_extractor_v2/vmapextract/model.h index 4e1a37328f3..2bcb20b1172 100644 --- a/contrib/vmap_extractor_v2/vmapextract/model.h +++ b/contrib/vmap_extractor_v2/vmapextract/model.h @@ -11,51 +11,41 @@ class WMOInstance; Vec3D fixCoordSystem(Vec3D v); - - - class Model -{ -public: - - ModelHeader header; - +{ public: + ModelHeader header; + uint32 offsBB_vertices, offsBB_indices; + Vec3D *BB_vertices, *vertices; + uint16 *BB_indices, *indices; + size_t nIndices; - uint32 offsBB_vertices, offsBB_indices; - Vec3D *BB_vertices, *vertices; - uint16 *BB_indices, *indices; - size_t nIndices; - - bool open(); - bool ConvertToVMAPModel(char * outfilename); + bool open(); + bool ConvertToVMAPModel(char * outfilename); -public: + bool ok; - bool ok; + Model(std::string &filename); + ~Model(); - Model(std::string &filename); - ~Model(); - private: - std::string filename; - char outfilename; + std::string filename; + char outfilename; }; class ModelInstance { public: - Model *model; + Model *model; - int id; - Vec3D pos, rot; - unsigned int d1, scale; - float w,sc; + int id; + Vec3D pos, rot; + unsigned int d1, scale; + float w,sc; - ModelInstance() {} - ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile); + ModelInstance() {} + ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile); }; #endif - diff --git a/contrib/vmap_extractor_v2/vmapextract/modelheaders.h b/contrib/vmap_extractor_v2/vmapextract/modelheaders.h index 30adf61801f..445ab3843e1 100644 --- a/contrib/vmap_extractor_v2/vmapextract/modelheaders.h +++ b/contrib/vmap_extractor_v2/vmapextract/modelheaders.h @@ -10,74 +10,72 @@ typedef int int32; #pragma pack(push,1) -struct ModelHeader { - char id[4]; - uint8 version[4]; - uint32 nameLength; - uint32 nameOfs; - uint32 type; - uint32 nGlobalSequences; - uint32 ofsGlobalSequences; - uint32 nAnimations; - uint32 ofsAnimations; +struct ModelHeader +{ + char id[4]; + uint8 version[4]; + uint32 nameLength; + uint32 nameOfs; + uint32 type; + uint32 nGlobalSequences; + uint32 ofsGlobalSequences; + uint32 nAnimations; + uint32 ofsAnimations; uint32 nAnimationLookup; uint32 ofsAnimationLookup; uint32 nBones; uint32 ofsBones; - uint32 nKeyBoneLookup; - uint32 ofsKeyBoneLookup; - uint32 nVertices; - uint32 ofsVertices; - uint32 nViews; - uint32 nColors; - uint32 ofsColors; - uint32 nTextures; - uint32 ofsTextures; - uint32 nTransparency; - uint32 ofsTransparency; - uint32 nTextureanimations; - uint32 ofsTextureanimations; - uint32 nTexReplace; - uint32 ofsTexReplace; - uint32 nRenderFlags; - uint32 ofsRenderFlags; - uint32 nBoneLookupTable; - uint32 ofsBoneLookupTable; - uint32 nTexLookup; - uint32 ofsTexLookup; - uint32 nTexUnits; - uint32 ofsTexUnits; - uint32 nTransLookup; - uint32 ofsTransLookup; - uint32 nTexAnimLookup; - uint32 ofsTexAnimLookup; - float floats[14]; - uint32 nBoundingTriangles; - uint32 ofsBoundingTriangles; - uint32 nBoundingVertices; - uint32 ofsBoundingVertices; - uint32 nBoundingNormals; - uint32 ofsBoundingNormals; - uint32 nAttachments; - uint32 ofsAttachments; - uint32 nAttachLookup; - uint32 ofsAttachLookup; - uint32 nAttachments_2; - uint32 ofsAttachments_2; - uint32 nLights; - uint32 ofsLights; - uint32 nCameras; - uint32 ofsCameras; - uint32 nCameraLookup; - uint32 ofsCameraLookup; - uint32 nRibbonEmitters; - uint32 ofsRibbonEmitters; - uint32 nParticleEmitters; - uint32 ofsParticleEmitters; + uint32 nKeyBoneLookup; + uint32 ofsKeyBoneLookup; + uint32 nVertices; + uint32 ofsVertices; + uint32 nViews; + uint32 nColors; + uint32 ofsColors; + uint32 nTextures; + uint32 ofsTextures; + uint32 nTransparency; + uint32 ofsTransparency; + uint32 nTextureanimations; + uint32 ofsTextureanimations; + uint32 nTexReplace; + uint32 ofsTexReplace; + uint32 nRenderFlags; + uint32 ofsRenderFlags; + uint32 nBoneLookupTable; + uint32 ofsBoneLookupTable; + uint32 nTexLookup; + uint32 ofsTexLookup; + uint32 nTexUnits; + uint32 ofsTexUnits; + uint32 nTransLookup; + uint32 ofsTransLookup; + uint32 nTexAnimLookup; + uint32 ofsTexAnimLookup; + float floats[14]; + uint32 nBoundingTriangles; + uint32 ofsBoundingTriangles; + uint32 nBoundingVertices; + uint32 ofsBoundingVertices; + uint32 nBoundingNormals; + uint32 ofsBoundingNormals; + uint32 nAttachments; + uint32 ofsAttachments; + uint32 nAttachLookup; + uint32 ofsAttachLookup; + uint32 nAttachments_2; + uint32 ofsAttachments_2; + uint32 nLights; + uint32 ofsLights; + uint32 nCameras; + uint32 ofsCameras; + uint32 nCameraLookup; + uint32 ofsCameraLookup; + uint32 nRibbonEmitters; + uint32 ofsRibbonEmitters; + uint32 nParticleEmitters; + uint32 ofsParticleEmitters; }; #pragma pack(pop) - - #endif - diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.cpp b/contrib/vmap_extractor_v2/vmapextract/mpq.cpp index cd9d62869aa..0d72f06a7da 100644 --- a/contrib/vmap_extractor_v2/vmapextract/mpq.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/mpq.cpp @@ -3,24 +3,16 @@ #include "Stormlib.h" #define __STORMLIB_SELF__ -typedef std::vector<MPQArchive*> ArchiveSet; -ArchiveSet gOpenArchives; +MPQArchiveSet gOpenArchives; + //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx MPQArchive::MPQArchive(const char* filename) { BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ); if (succ) - { - MPQArchive*ar = (MPQArchive*)(hMPQ); printf("Opening %s\n", filename); - gOpenArchives.push_back(ar); - succ = true; - - } else - { printf("Error!!!Not open archive %s\n", filename); - } } void MPQArchive::close() @@ -28,41 +20,57 @@ void MPQArchive::close() SFileCloseArchive(hMPQ); } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +bool MPQArchiveSet::Open( std::vector<std::string> const& archiveNames ) +{ + for (size_t i=0; i < archiveNames.size(); ++i) + { + MPQArchive mpqarch(archiveNames[i].c_str()); + if(mpqarch.isOpen()) + archives.push_back(mpqarch); + } + + return !archives.empty(); +} + +MPQArchiveSet::~MPQArchiveSet() +{ + // close archives + for (ArchiveSet::iterator ar_itr = archives.begin(); ar_itr != archives.end(); ++ar_itr) + ar_itr->close(); +} + MPQFile::MPQFile(const char* filename): eof(false), buffer(0), pointer(0), size(0) { - for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i) + for(ArchiveSet::const_iterator i=gOpenArchives.archives.begin(); i!=gOpenArchives.archives.end();++i) { - - HANDLE hFile = ""; - MPQArchive*(hMPQ) = *i; - BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile); - if (succ) - { - DWORD s = SFileGetFileSize(hFile, 0); - if (!s) - { - eof = true; - buffer = 0; + HANDLE hFile = ""; + hMPQ = i->hMPQ; + BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile); + if (succ) + { + DWORD s = SFileGetFileSize(hFile, 0); + if (!s) + { + eof = true; + buffer = 0; + return; + } + size = (size_t)s; + buffer = new char[s]; + SFileReadFile(hFile, buffer, s, 0, 0); + SFileCloseFile(hFile); + + eof = false; return; - } - size = (size_t)s; - buffer = new char[s]; - SFileReadFile(hFile, buffer, s, 0, 0); - SFileCloseFile(hFile); - - eof = false; - return; - } + } } eof = true; buffer = 0; - } MPQFile::~MPQFile() @@ -73,7 +81,7 @@ MPQFile::~MPQFile() size_t MPQFile::read(void* dest, size_t bytes) { if (eof) - return 0; + return 0; size_t rpos = pointer + bytes; if (rpos > size) @@ -109,7 +117,7 @@ void MPQFile::seekRelative(int offset) void MPQFile::close() { if (buffer) - delete[] buffer; + delete[] buffer; buffer = 0; eof = true; } @@ -133,5 +141,3 @@ char* MPQFile::getPointer() { return buffer + pointer; } - - diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.h b/contrib/vmap_extractor_v2/vmapextract/mpq.h index dc51998ba25..0d1d1485135 100644 --- a/contrib/vmap_extractor_v2/vmapextract/mpq.h +++ b/contrib/vmap_extractor_v2/vmapextract/mpq.h @@ -15,16 +15,30 @@ using namespace std; typedef unsigned int uint32; - class MPQArchive { + public: + HANDLE hMPQ; + MPQArchive(const char* filename); + void close(); + bool isOpen() const { return hMPQ != 0; } +}; -public: - HANDLE hMPQ; - MPQArchive(const char* filename); - void close(); +typedef std::vector<MPQArchive> ArchiveSet; + +class MPQArchiveSet +{ + public: + MPQArchiveSet() {} + ~MPQArchiveSet(); + + bool Open(std::vector<std::string> const& archiveNames); + + ArchiveSet archives; }; +extern MPQArchiveSet gOpenArchives; + class MPQFile { HANDLE hFile; @@ -63,8 +77,4 @@ inline void flipcc(char *fcc) fcc[2]=t; } - - #endif - - diff --git a/contrib/vmap_extractor_v2/vmapextract/vec3d.h b/contrib/vmap_extractor_v2/vmapextract/vec3d.h index c6d2ae57ed2..40513552181 100644 --- a/contrib/vmap_extractor_v2/vmapextract/vec3d.h +++ b/contrib/vmap_extractor_v2/vmapextract/vec3d.h @@ -4,9 +4,8 @@ #include <iostream> #include <cmath> - - -class Vec3D { +class Vec3D +{ public: float x,y,z; @@ -112,11 +111,11 @@ public: { return (float*)this; } - }; -class Vec2D { +class Vec2D +{ public: float x,y; @@ -213,10 +212,8 @@ public: { return (float*)this; } - }; - inline void rotate(float x0, float y0, float *x, float *y, float angle) { float xa = *x - x0, ya = *y - y0; @@ -224,8 +221,4 @@ inline void rotate(float x0, float y0, float *x, float *y, float angle) *y = xa*sinf(angle) + ya*cosf(angle) + y0; } - - #endif - - diff --git a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp index 3dd58a4e3d5..a96a404f62d 100644 --- a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp @@ -44,7 +44,8 @@ typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; -typedef struct{ +typedef struct +{ char name[64]; unsigned int id; }map_id; @@ -86,9 +87,10 @@ static const char * GetPlainName(const char * szFileName) szFileName = szTemp + 1; return szFileName; } -//------------------------------------------------------------------------------ + static void ShowProcessedFile(const char * szFileName) { +/* not truncate file names in output char szLine[80]; size_t nLength = strlen(szFileName); @@ -99,16 +101,14 @@ static void ShowProcessedFile(const char * szFileName) nLength = sizeof(szLine)-1; memcpy(szLine, szFileName, nLength); printf("\r%s\n", szLine); +*/ + printf("\r%s\n", szFileName); } - -//---------------------------------------------------------------------------------------------------------------------------------------------------------------------- -int ExtractWmo(const std::vector<std::string>& pArchiveNames) +int ExtractWmo() { - char* szListFile = ""; char szLocalFile[MAX_PATH] = ""; - HANDLE hMpq = ""; BOOL bResult = FALSE; //const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"}; @@ -116,21 +116,14 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames) int nError = ERROR_SUCCESS; if(szListFile == NULL || *szListFile == 0) szListFile = NULL; - //char tmp[1024]; - //for (size_t i=0; i<4; i++) - for (size_t i=0; i<pArchiveNames.size(); i++) - { - - //sprintf(tmp,"%s\\%s", input_path, ParsArchiveNames[i]); - //if(!SFileOpenArchive(tmp, 0, 0, &hMpq)) - if(!SFileOpenArchive(pArchiveNames[i].c_str(), 0, 0, &hMpq)) - printf("NOT open!!! %s\n",pArchiveNames[i].c_str()); + for (ArchiveSet::const_iterator ar_itr = gOpenArchives.archives.begin(); ar_itr != gOpenArchives.archives.end(); ++ar_itr) + { // Copy files from archive if(nError == ERROR_SUCCESS) { SFILE_FIND_DATA wf; - HANDLE hFind = SFileFindFirstFile(hMpq,"*.wmo*", &wf, szListFile); + HANDLE hFind = SFileFindFirstFile(ar_itr->hMPQ,"*.wmo*", &wf, szListFile); bResult = TRUE; while(hFind != NULL && bResult == TRUE) @@ -149,7 +142,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames) { char cpy[4]; strncpy((char*)cpy,rchr,4); - for (int i=0;i<4;i++) + for (int i=0;i<4; ++i) { int m = cpy[i]; if(isdigit(m)) @@ -167,17 +160,17 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames) bResult = SFileFindNextFile(hFind, &wf); continue; } - FILE *output=fopen(szLocalFile,"wb"); + FILE *output=fopen(szLocalFile,"wb"); froot->ConvertToVMAPRootWmo(output); int Wmo_nVertices = 0; if(froot->nGroups !=0) { - for (int i=0; i<froot->nGroups; i++) + for (int i=0; i<froot->nGroups; ++i) { - char temp[512]; + char temp[MAX_PATH]; strcpy(temp, wf.cFileName); temp[strlen(wf.cFileName)-4] = 0; - char groupFileName[512]; + char groupFileName[MAX_PATH]; sprintf(groupFileName,"%s_%03d.wmo",temp, i); printf("%s\n",groupFileName); //printf("GroupWmo!\n"); @@ -196,7 +189,9 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames) fwrite(&Wmo_nVertices,sizeof(int),1,output); fclose(output); } - } else { + } + else + { fclose(n); } wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA; @@ -210,39 +205,34 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames) // Close the search handle if(hFind != NULL) SFileFindClose(hFind); - } } - // Close both archives - if(hMpq != NULL) - //SFileCloseArchive(hMpq); - if(nError == ERROR_SUCCESS) - printf("\nExtract wmo complete (No errors)\n"); - return nError; + if(nError == ERROR_SUCCESS) + printf("\nExtract wmo complete (No errors)\n"); + return nError; } void ExtractMapsFromMpq() { - } -//----------------------------------------------------------------------------- + void ParsMapFiles() { char fn[512]; char id_filename[64]; char id[10]; - for (unsigned int i=0; i<map_count; i++) + for (unsigned int i=0; i<map_count; ++i) { sprintf(id,"%03u",map_ids[i].id); sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name); WDTFile WDT(fn,map_ids[i].name); if(WDT.init(id)) { - for (int x=0; x<64; x++) + for (int x=0; x<64; ++x) { - for (int y=0; y<64; y++) + for (int y=0; y<64; ++y) { if (ADTFile*ADT = WDT.GetMap(x,y)) { @@ -250,7 +240,6 @@ void ParsMapFiles() ADT->init(id_filename); delete ADT; } - } } } @@ -259,31 +248,28 @@ void ParsMapFiles() #if 0 void ParsMapFiles() { - char fn[512]; - for (unsigned int i=0; i<map_count; i++) + for (unsigned int i=0; i<map_count; ++i) { sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name); WDTFile WDT(fn,map_ids[i].name); if(WDT.init()) { - for (int x=0; x<64; x++) + for (int x=0; x<64; ++x) { - for (int y=0; y<64; y++) + for (int y=0; y<64; ++y) { if (ADTFile*ADT = WDT.GetMap(x,y)) { ADT->init(); delete ADT; } - } } } } } #endif -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx void getGamePath() { @@ -307,8 +293,6 @@ void getGamePath() #endif } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames) { int i; @@ -338,7 +322,7 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames) } matches.reverse(); - for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); i++) + for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); ++i) { pArchiveNames.push_back(i->c_str()); } @@ -348,11 +332,8 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames) return(true); } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - -bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) { - //srand((unsigned int)time(0)); - +bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) +{ if(!hasInputPathParam) getGamePath(); @@ -408,11 +389,12 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) { // now, scan for the patch levels in the core dir printf("Loading patch levels from data directory.\n"); sprintf(path, "%spatch", input_path); - if (!scan_patches(path, pArchiveNames)) return(false); + if (!scan_patches(path, pArchiveNames)) + return(false); // now, scan for the patch levels in locale dirs printf("Loading patch levels from locale directories.\n"); - for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++) + for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i) { printf("Locale: %s\n", i->c_str()); sprintf(path, "%s%s\\patch-%s", input_path, i->c_str(), i->c_str()); @@ -433,7 +415,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) { // open locale expansion and common files printf("Opening data files from locale directories.\n"); - for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++) + for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i) { printf("Locale: %s\n", i->c_str()); sprintf(path, "%s%s\\lichking-locale-%s.mpq", input_path, i->c_str(), i->c_str()); @@ -446,8 +428,6 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) { } return true; } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -// return false it normal processing can not proceed bool processArgv(int argc, char ** argv, char*versionString) { @@ -455,29 +435,43 @@ bool processArgv(int argc, char ** argv, char*versionString) hasInputPathParam = false; bool preciseVectorData = false; - for(int i=1; i< argc; ++i) { - if(strcmp("-s",argv[i]) == 0) { + for(int i=1; i< argc; ++i) + { + if(strcmp("-s",argv[i]) == 0) + { preciseVectorData = false; - } else if(strcmp("-d",argv[i]) == 0) { - if((i+1)<argc) { + } + else if(strcmp("-d",argv[i]) == 0) + { + if((i+1)<argc) + { hasInputPathParam = true; strcpy(input_path, argv[i+1]); if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/') strcat(input_path, "\\"); ++i; - } else { + } + else + { result = false; } - } else if(strcmp("-?",argv[1]) == 0) { + } + else if(strcmp("-?",argv[1]) == 0) + { result = false; - } else if(strcmp("-l",argv[i]) == 0) { + } + else if(strcmp("-l",argv[i]) == 0) + { preciseVectorData = true; - } else { + } + else + { result = false; break; } } - if(!result) { + if(!result) + { printf("Extract %s.\n",versionString); printf("%s [-?][-s][-l][-d <path>]\n", argv[0]); printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n"); @@ -490,7 +484,7 @@ bool processArgv(int argc, char ** argv, char*versionString) //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // Main -// +// // The program must be run with two command line arguments // // Arg1 - The source MPQ name (for testing reading and file find) @@ -529,28 +523,33 @@ int main(int argc, char ** argv) if(nError == ERROR_ALREADY_EXISTS) nError = ERROR_SUCCESS; } - //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - // patch goes first -> fake priority handling - std::vector<MPQArchive*> archives; - //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + // prepare archive name list std::vector<std::string> archiveNames; - fillArchiveNameVector(archiveNames); - for (size_t i=0; i<archiveNames.size(); i++) { - archives.push_back(new MPQArchive(archiveNames[i].c_str())); + if(!gOpenArchives.Open(archiveNames)) + { + printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n",input_path); + return 1; } - ExtractWmo(archiveNames); - //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + // extract data + ExtractWmo(); + + //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //map.dbc if(nError == ERROR_SUCCESS) { DBCFile * dbc = new DBCFile("DBFilesClient\\Map.dbc"); - dbc->open(); + if(!dbc->open()) + { + delete dbc; + printf("FATAL ERROR: Map.dbc not found in data file.\n"); + return 1; + } map_count=dbc->getRecordCount (); map_ids=new map_id[map_count]; - for(unsigned int x=0;x<map_count;x++) + for(unsigned int x=0;x<map_count;++x) { map_ids[x].id=dbc->getRecord (x).getUInt(0); strcpy(map_ids[x].name,dbc->getRecord(x).getString(1)); @@ -564,10 +563,11 @@ int main(int argc, char ** argv) } clreol(); - if(nError != ERROR_SUCCESS) { + if(nError != ERROR_SUCCESS) + { printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData); _getch(); } + printf("Extract %s. Work complete. No errors.",versionString); } - diff --git a/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp index 290d0b2feeb..697f9b33b5b 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp @@ -3,7 +3,6 @@ #include "wdtfile.h" #include "adtfile.h" - char * wdtGetPlainName(char * FileName) { char * szTemp; @@ -20,17 +19,15 @@ WDTFile::WDTFile(char* file_name, char* file_name1):WDT(file_name) bool WDTFile::init(char *map_id) { - if (WDT.isEof()) { - //printf("Can't find WDT file.\n"); - return false; + //printf("Can't find WDT file.\n"); + return false; } char fourcc[5]; size_t size; - const char dirname[] = "buildings\\dir"; FILE *dirfile; dirfile = fopen(dirname, "ab"); @@ -40,7 +37,6 @@ bool WDTFile::init(char *map_id) return false; } - while (!WDT.isEof()) { WDT.read(fourcc,4); @@ -75,8 +71,7 @@ bool WDTFile::init(char *map_id) delete[] buf; } } - else - if (!strcmp(fourcc,"MODF")) + else if (!strcmp(fourcc,"MODF")) { // global wmo instance data if (size) @@ -87,13 +82,13 @@ bool WDTFile::init(char *map_id) fake_mapname = "65 65 "; //gWMO_mapname = fake_mapname + filename; gWMO_mapname = fake_mapname + std::string(map_id); - for (int i=0; i<gnWMO; i++) + for (int i=0; i<gnWMO; ++i) { int id; WDT.read(&id, 4); WMOInstance inst(WDT,gWmoInstansName[id].c_str(),gWMO_mapname.c_str(), dirfile); } - delete[] gWmoInstansName; + delete[] gWmoInstansName; } } WDT.seek((int)nextpos); @@ -111,11 +106,11 @@ WDTFile::~WDTFile(void) ADTFile* WDTFile::GetMap(int x, int z) { - if(!(x>=0 && z >= 0 && x<64 && z<64)) return NULL; + if(!(x>=0 && z >= 0 && x<64 && z<64)) + return NULL; char name[512]; sprintf(name,"World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z); return new ADTFile(name); } - diff --git a/contrib/vmap_extractor_v2/vmapextract/wdtfile.h b/contrib/vmap_extractor_v2/vmapextract/wdtfile.h index e9dcc77562d..0baef22f185 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wdtfile.h +++ b/contrib/vmap_extractor_v2/vmapextract/wdtfile.h @@ -28,4 +28,3 @@ private: }; #endif - diff --git a/contrib/vmap_extractor_v2/vmapextract/wmo.cpp b/contrib/vmap_extractor_v2/vmapextract/wmo.cpp index 9d8b8f79770..4817e14c85b 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wmo.cpp +++ b/contrib/vmap_extractor_v2/vmapextract/wmo.cpp @@ -6,15 +6,12 @@ using namespace std; - WMORoot::WMORoot(std::string &filename) : filename(filename) { } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx bool WMORoot::open() { - MPQFile f(filename.c_str()); if(f.isEof ()) { @@ -27,7 +24,7 @@ bool WMORoot::open() bbcorn1[3] = 0; bbcorn2[3]= 0; - while (!f.isEof ()) + while (!f.isEof()) { f.read(fourcc,4); f.read(&size, 4); @@ -39,7 +36,6 @@ bool WMORoot::open() if (!strcmp(fourcc,"MOHD"))//header { - f.read(&nTextures, 4); f.read(&nGroups, 4); f.read(&nP, 4); @@ -56,55 +52,42 @@ bool WMORoot::open() /* else if (!strcmp(fourcc,"MOTX")) { - } else if (!strcmp(fourcc,"MOMT")) { - } else if (!strcmp(fourcc,"MOGN")) { - } else if (!strcmp(fourcc,"MOGI")) { - } else if (!strcmp(fourcc,"MOLT")) { - } else if (!strcmp(fourcc,"MODN")) { - } else if (!strcmp(fourcc,"MODS")) { - } else if (!strcmp(fourcc,"MODD")) { - } else if (!strcmp(fourcc,"MOSB")) { - } else if (!strcmp(fourcc,"MOPV")) { - } else if (!strcmp(fourcc,"MOPT")) { - } else if (!strcmp(fourcc,"MOPR")) { - } else if (!strcmp(fourcc,"MFOG")) { - } */ f.seek((int)nextpos); @@ -112,7 +95,6 @@ bool WMORoot::open() f.close (); return true; } -//--------------------------------------------------------------------------- bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile) { @@ -125,16 +107,14 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile) return true; } -//---------------------------------------------------------------------------- WMORoot::~WMORoot() { } -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WMOGroup::WMOGroup(std::string &filename) : filename(filename) { } -//--------------------------------------------------------------------------- + bool WMOGroup::open() { MPQFile f(filename.c_str()); @@ -147,7 +127,7 @@ bool WMOGroup::open() char fourcc[5]; bbcorn1[3] = 0; bbcorn2[3] = 0; - while (!f.isEof ()) + while (!f.isEof()) { f.read(fourcc,4); f.read(&size, 4); @@ -188,7 +168,6 @@ bool WMOGroup::open() { MOVI = new uint16[size/2]; f.read(MOVI, size); - } else if (!strcmp(fourcc,"MOVT")) { @@ -222,228 +201,262 @@ bool WMOGroup::open() LiquEx = new float[sizeof(float) * 3 * noVer]; int p = 0; - for (int j=0; j<hlq.yverts; j++) + for (int j=0; j<hlq.yverts; ++j) { - for (int i=0; i<hlq.xverts; i++) + for (int i=0; i<hlq.xverts; ++i) { LiquEx[p++] = hlq.pos_x + tilesize * i; LiquEx[p++] = hlq.pos_z; LiquEx[p++] = ydir * (hlq.pos_y + tilesize * j); } } - } f.seek((int)nextpos); } - f.close (); + f.close(); return true; } -//---------------------------------------------------------------------------- + int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData) { - if(pPreciseVectorData) { - fwrite(&liquflags,sizeof(uint32),1,output); - char GRP[] = "GRP "; - fwrite(GRP,1,4,output); - - int k = 0; - int moba_batch = moba_size/12; - MobaEx = new int[moba_batch*4]; - for(int i=8; i<moba_size; i+=12) - { - MobaEx[k++] = MOBA[i]; - } - delete [] MOBA; - int moba_size_grp = moba_batch*4+4; - fwrite(&moba_size_grp,4,1,output); - fwrite(&moba_batch,4,1,output); - fwrite(MobaEx,4,k,output); - delete [] MobaEx; - - uint32 nIdexes = nTriangles * 3; - - if(fwrite("INDX",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); } - int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes; - if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); } - if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1) { printf("Error while writing file nIndexes"); exit(0); } - if(nIdexes >0) { - if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes) { printf("Error while writing file indexarray"); exit(0); } - } - - if(fwrite("VERT",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); } - wsize = sizeof(int) + sizeof(float) * 3 * nVertices; - if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); } - if(fwrite(&nVertices, sizeof(int), 1, output) != 1) { printf("Error while writing file nVertices"); exit(0); } - if(nVertices >0) { - if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices) { printf("Error while writing file vectors"); exit(0); } - } - - if(LiquEx_size != 0) - { - int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU" - fwrite(LIQU_h,4,4,output); - fwrite(LiquEx,4,LiquEx_size/4,output); - delete [] LiquEx; - } - - return nTriangles; - } else { - //printf("Convert GroupWmo...\n"); - //-------GRP ------------------------------------- - fwrite(&liquflags,sizeof(uint32),1,output); - char GRP[] = "GRP "; - fwrite(GRP,1,4,output); - int k = 0; - int moba_batch = moba_size/12; - MobaEx = new int[moba_batch*4]; - for(int i=8; i<moba_size; i+=12) - { - MobaEx[k++] = MOBA[i]; - } - delete [] MOBA; - int moba_size_grp = moba_batch*4+4; - fwrite(&moba_size_grp,4,1,output); - fwrite(&moba_batch,4,1,output); - fwrite(MobaEx,4,k,output); - delete [] MobaEx; - - //-------INDX------------------------------------ - //-------MOPY-------- - int n = 0; - int j = 0; - MopyEx = new char[mopy_size]; - IndexExTr = new int[mopy_size]; - for (int i=0; i<mopy_size; i+=2) - { + if(pPreciseVectorData) + { + fwrite(&liquflags,sizeof(uint32),1,output); + char GRP[] = "GRP "; + fwrite(GRP,1,4,output); + + int k = 0; + int moba_batch = moba_size/12; + MobaEx = new int[moba_batch*4]; + for(int i=8; i<moba_size; i+=12) + { + MobaEx[k++] = MOBA[i]; + } + delete [] MOBA; + int moba_size_grp = moba_batch*4+4; + fwrite(&moba_size_grp,4,1,output); + fwrite(&moba_batch,4,1,output); + fwrite(MobaEx,4,k,output); + delete [] MobaEx; + + uint32 nIdexes = nTriangles * 3; + + if(fwrite("INDX",4, 1, output) != 1) + { + printf("Error while writing file nbraches ID"); + exit(0); + } + int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes; + if(fwrite(&wsize, sizeof(int), 1, output) != 1) + { + printf("Error while writing file wsize"); + // no need to exit? + } + if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1) + { + printf("Error while writing file nIndexes"); + exit(0); + } + if(nIdexes >0) + { + if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes) + { + printf("Error while writing file indexarray"); + exit(0); + } + } + + if(fwrite("VERT",4, 1, output) != 1) + { + printf("Error while writing file nbraches ID"); + exit(0); + } + wsize = sizeof(int) + sizeof(float) * 3 * nVertices; + if(fwrite(&wsize, sizeof(int), 1, output) != 1) + { + printf("Error while writing file wsize"); + // no need to exit? + } + if(fwrite(&nVertices, sizeof(int), 1, output) != 1) + { + printf("Error while writing file nVertices"); + exit(0); + } + if(nVertices >0) + { + if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices) + { + printf("Error while writing file vectors"); + exit(0); + } + } + + if(LiquEx_size != 0) + { + int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU" + fwrite(LIQU_h,4,4,output); + fwrite(LiquEx,4,LiquEx_size/4,output); + delete [] LiquEx; + } + + return nTriangles; + } + else + { + //printf("Convert GroupWmo...\n"); + //-------GRP ------------------------------------- + fwrite(&liquflags,sizeof(uint32),1,output); + char GRP[] = "GRP "; + fwrite(GRP,1,4,output); + int k = 0; + int moba_batch = moba_size/12; + MobaEx = new int[moba_batch*4]; + for(int i=8; i<moba_size; i+=12) + { + MobaEx[k++] = MOBA[i]; + } + delete [] MOBA; + int moba_size_grp = moba_batch*4+4; + fwrite(&moba_size_grp,4,1,output); + fwrite(&moba_batch,4,1,output); + fwrite(MobaEx,4,k,output); + delete [] MobaEx; + + //-------INDX------------------------------------ + //-------MOPY-------- + int n = 0; + int j = 0; + MopyEx = new char[mopy_size]; + IndexExTr = new int[mopy_size]; + for (int i=0; i<mopy_size; i+=2) + { // Skip no collision triangles if ((int)MOPY[i]&WMO_MATERIAL_NO_COLLISION) continue; // Use only this triangles if ((int)MOPY[i]&(WMO_MATERIAL_HINT|WMO_MATERIAL_COLLIDE_HIT)) - { - MopyEx[n] = MOPY[i]; - MopyEx[(n+1)] = MOPY[(i+1)]; - IndexExTr[j] = i/2; - j+=1; - n+=2; - } - } - MopyEx_size = n; - IndexExTr_size = j; - delete [] MOPY; - delete [] MopyEx; - - //---------MOVI----------- - MoviEx = new uint16[IndexExTr_size*3]; - int m = 0; - for (int i=0; i<IndexExTr_size; i++) - { - int n = 0; - n = IndexExTr[i]*3; - for (int x=0; x<3; x++) - { - MoviEx[m] = MOVI[n]; - n++; - m++; - } - } - delete [] MOVI; - - MoviExSort = new uint16[IndexExTr_size*3]; - for(int y=0; y<IndexExTr_size*3; y++) - { - MoviExSort[y]=MoviEx[y]; - } - - uint16 hold; - for (int pass = 1; pass < IndexExTr_size*3; pass++) - { - for (int i=0; i < IndexExTr_size*3-1; i++) - { - if (MoviExSort[i] > MoviExSort[i+1]) - { - hold = MoviExSort[i]; - MoviExSort[i] = MoviExSort[i+1]; - MoviExSort[i+1] = hold; - } - //double = 65535 - else - if (MoviExSort[i] == MoviExSort[i+1]) - MoviExSort[i+1] = 65535; - } - } - // double delet - uint16 s = 0; - for (int i=0; i < IndexExTr_size*3; i++) - { - if (MoviExSort[i]!=65535) - { - MoviExSort[s] = MoviExSort[i]; - s++; - } - } - MovtExSort = new uint16[s]; - for (int i=0; i < s; i++) - { - MovtExSort[i] = MoviExSort[i]; - } - - for (int i=0; i < IndexExTr_size*3; i++) - { - uint16 b = MoviEx[i]; - for (uint16 x = 0; x < s; x++) - { - if(MoviExSort[x] == b) - { - - MoviEx[i] = x; - break; - } - } - - } - int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3}; - fwrite(INDX,4,3,output); - fwrite(MoviEx,2,IndexExTr_size*3,output); - - delete [] MoviEx; - delete [] MoviExSort; - delete [] IndexExTr; - - //----------VERT--------- - //-----MOVT---------- - int d = 0; - MovtEx = new float[s*3]; - for (uint16 i=0; i<s; i++) - { - int c=0;//!!!!data in MovtExSort[i] more uint16 in great group wmo files!!!! - c = MovtExSort[i]*3; - for (int y=0; y<3; y++) - { - MovtEx[d] = MOVT[c]; - c++; - d++; - } - } - int VERT[] = {0x54524556,d*4+4,d*4/12};// "VERT" - fwrite(VERT,4,3,output); - fwrite(MovtEx,4,d,output); - //------LIQU------------------------ - if(LiquEx_size != 0) - { - int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU" - fwrite(LIQU_h,4,4,output); - fwrite(LiquEx,4,LiquEx_size/4,output); - delete [] LiquEx; - } - - delete [] MOVT; - delete [] MovtEx; - delete [] MovtExSort; - - //--------------------------------------------- - return IndexExTr_size; - } + { + MopyEx[n] = MOPY[i]; + MopyEx[(n+1)] = MOPY[(i+1)]; + IndexExTr[j] = i/2; + j+=1; + n+=2; + } + } + MopyEx_size = n; + IndexExTr_size = j; + delete [] MOPY; + delete [] MopyEx; + + //---------MOVI----------- + MoviEx = new uint16[IndexExTr_size*3]; + int m = 0; + for (int i=0; i<IndexExTr_size; ++i) + { + int n = 0; + n = IndexExTr[i]*3; + for (int x=0; x<3; ++x) + { + MoviEx[m] = MOVI[n]; + n++; + m++; + } + } + delete [] MOVI; + + MoviExSort = new uint16[IndexExTr_size*3]; + for(int y=0; y<IndexExTr_size*3; ++y) + { + MoviExSort[y]=MoviEx[y]; + } + + uint16 hold; + for (int pass = 1; pass < IndexExTr_size*3; ++pass) + { + for (int i=0; i < IndexExTr_size*3-1; ++i) + { + if (MoviExSort[i] > MoviExSort[i+1]) + { + hold = MoviExSort[i]; + MoviExSort[i] = MoviExSort[i+1]; + MoviExSort[i+1] = hold; + } + //double = 65535 + else + if (MoviExSort[i] == MoviExSort[i+1]) + MoviExSort[i+1] = 65535; + } + } + // double delet + uint16 s = 0; + for (int i=0; i < IndexExTr_size*3; ++i) + { + if (MoviExSort[i]!=65535) + { + MoviExSort[s] = MoviExSort[i]; + s++; + } + } + MovtExSort = new uint16[s]; + for (int i=0; i < s; ++i) + { + MovtExSort[i] = MoviExSort[i]; + } + + for (int i=0; i < IndexExTr_size*3; ++i) + { + uint16 b = MoviEx[i]; + for (uint16 x = 0; x < s; ++x) + { + if(MoviExSort[x] == b) + { + MoviEx[i] = x; + break; + } + } + } + int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3}; + fwrite(INDX,4,3,output); + fwrite(MoviEx,2,IndexExTr_size*3,output); + + delete [] MoviEx; + delete [] MoviExSort; + delete [] IndexExTr; + + //----------VERT--------- + //-----MOVT---------- + int d = 0; + MovtEx = new float[s*3]; + for (uint16 i=0; i<s; ++i) + { + int c=0;//!!!!data in MovtExSort[i] more uint16 in great group wmo files!!!! + c = MovtExSort[i]*3; + for (int y=0; y<3; ++y) + { + MovtEx[d] = MOVT[c]; + c++; + d++; + } + } + int VERT[] = {0x54524556,d*4+4,d*4/12};// "VERT" + fwrite(VERT,4,3,output); + fwrite(MovtEx,4,d,output); + //------LIQU------------------------ + if(LiquEx_size != 0) + { + int LIQU_h[] = {0x5551494C,LiquEx_size+8,hlq_xverts,hlq_yverts};// "LIQU" + fwrite(LIQU_h,4,4,output); + fwrite(LiquEx,4,LiquEx_size/4,output); + delete [] LiquEx; + } + + delete [] MOVT; + delete [] MovtEx; + delete [] MovtExSort; + + //--------------------------------------------- + return IndexExTr_size; + } } WMOGroup::~WMOGroup() @@ -486,25 +499,24 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName, //-----------add_in _dir_file---------------- char tempname[512]; - // const char dirname[] = "buildings\\dir"; + // const char dirname[] = "buildings\\dir"; sprintf(tempname, "buildings\\%s", WmoInstName); FILE *input; input = fopen(tempname, "r+b"); + if(!input) - { return; - } + fseek(input, 8, SEEK_SET); // get the correct no of vertices int nVertices; fread(&nVertices, sizeof (int), 1, input); fclose(input); + if(nVertices == 0) - { return; - } - /* FILE *dirfile; + /* FILE *dirfile; dirfile = fopen(dirname, "ab"); if(!dirfile) { @@ -516,7 +528,11 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName, x = pos.x; z = pos.z; if(x==0 && z == 0) - { x = 533.33333f*32; z = 533.33333f*32; } + { + x = 533.33333f*32; + z = 533.33333f*32; + } + fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f 1.0 %d %d %d,%d %d\n", MapName, WmoInstName, @@ -529,8 +545,3 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName, // fclose(dirfile); } - - - - - diff --git a/contrib/vmap_extractor_v2/vmapextract/wmo.h b/contrib/vmap_extractor_v2/vmapextract/wmo.h index 436aa1ac60e..3000050c170 100644 --- a/contrib/vmap_extractor_v2/vmapextract/wmo.h +++ b/contrib/vmap_extractor_v2/vmapextract/wmo.h @@ -43,13 +43,11 @@ public: private: std::string filename; char outfilename; - }; class WMOGroup { public: - int offsize,flag,flag1,Xid,Xid2,Xid3,zero1,Xflag,nTexture,GroupID; int mopy_size,moba_size,hlq_xverts,hlq_yverts; int MopyEx_size,IndexExTr_size,LiquEx_size; @@ -82,10 +80,9 @@ public: private: std::string filename; char outfilename; - }; -struct WMOLiquidHeader +struct WMOLiquidHeader { int xverts, yverts, xtiles, ytiles; float pos_x; @@ -94,7 +91,7 @@ struct WMOLiquidHeader short type; }; -class WMOInstance +class WMOInstance { static std::set<int> ids; public: @@ -113,4 +110,3 @@ public: }; #endif - diff --git a/doc/EventAI.txt b/doc/EventAI.txt index 5137c26dd18..76e4fa20c35 100644 --- a/doc/EventAI.txt +++ b/doc/EventAI.txt @@ -530,10 +530,12 @@ This is commonly used in combination with EVENT_T_RANGE and ACTION_T_COMBAT_MOVE 21 = ACTION_T_COMBAT_MOVEMENT: ------------------------------ Parameter 1: If zero, then the creature will stop moving towards its victim (if its victim gets out of melee range) and will be stationary. If non-zero, then the creature will either continue to follow its victim (the action would have no effect) or it will start to follow the target with the top threat if its movement was disabled before. +Parameter 2: If non-zero, then stop melee combat state (if param1=0) or start melee combat state (if param1!=0) and creature in combat with selected target. This action controls whether or not the creature will always move towards its target. NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values. (0 = Stop Movement, 1 = Start Movement) This is commonly used with EVENT_T_RANGE and ACTION_T_AUTO_ATTACK for NPC's who engage in Ranged Comabt (Either Spells or Ranged Attacks) +Parameter 2 specialy used for ranged combat proper client side visual show ranged weapon in proper state. ------------------------ 22 = ACTION_T_SET_PHASE: diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index dad2a5eb488..c2eb744d3f1 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -589,6 +589,8 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS: case ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL: case ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL: + case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED: + case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED: case ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED: case ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN: case ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS: @@ -1063,7 +1065,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if(miscvalue1 != achievementCriteria->equip_item.itemID) continue; - SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE); + SetCriteriaProgress(achievementCriteria, 1); break; case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT: // miscvalue1 = go entry @@ -1202,8 +1204,6 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS: case ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM: case ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM: - case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED: - case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED: case ACHIEVEMENT_CRITERIA_TYPE_TOTAL: break; // Not implemented yet :( } @@ -1360,6 +1360,8 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION: case ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION: case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS: + case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED: + case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR: @@ -1536,7 +1538,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) return; // titles - if(uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE?0:1]) + if(uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 0 : 1]) { if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId)) GetPlayer()->SetTitle(titleEntry); diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index f195ccc93c3..ab3319ce2ad 100644 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -28,7 +28,7 @@ #include "World.h" #include "SocialMgr.h" -void WorldSession::HandleInspectArenaStatsOpcode(WorldPacket & recv_data) +void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recv_data) { sLog.outDebug("MSG_INSPECT_ARENA_TEAMS"); @@ -36,7 +36,7 @@ void WorldSession::HandleInspectArenaStatsOpcode(WorldPacket & recv_data) uint64 guid; recv_data >> guid; - sLog.outDebug("Inspect Arena stats " I64FMTD, guid); + sLog.outDebug("Inspect Arena stats (GUID: %u TypeId: %u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid))); if(Player *plr = objmgr.GetPlayer(guid)) { @@ -84,9 +84,9 @@ void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recv_data) arenateam->Roster(this); } -void WorldSession::HandleArenaTeamAddMemberOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) { - sLog.outDebug("CMSG_ARENA_TEAM_ADD_MEMBER"); + sLog.outDebug("CMSG_ARENA_TEAM_INVITE"); CHECK_PACKET_SIZE(recv_data, 4+1); @@ -164,9 +164,9 @@ void WorldSession::HandleArenaTeamAddMemberOpcode(WorldPacket & recv_data) sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_INVITE"); } -void WorldSession::HandleArenaTeamInviteAcceptOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) { - sLog.outDebug("CMSG_ARENA_TEAM_INVITE_ACCEPT"); // empty opcode + sLog.outDebug("CMSG_ARENA_TEAM_ACCEPT"); // empty opcode ArenaTeam *at = objmgr.GetArenaTeamById(_player->GetArenaTeamIdInvited()); if(!at) @@ -196,9 +196,9 @@ void WorldSession::HandleArenaTeamInviteAcceptOpcode(WorldPacket & /*recv_data*/ at->BroadcastPacket(&data); } -void WorldSession::HandleArenaTeamInviteDeclineOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleArenaTeamDeclineOpcode(WorldPacket & /*recv_data*/) { - sLog.outDebug("CMSG_ARENA_TEAM_INVITE_DECLINE"); // empty opcode + sLog.outDebug("CMSG_ARENA_TEAM_DECLINE"); // empty opcode _player->SetArenaTeamIdInvited(0); // no more invited } @@ -263,9 +263,9 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data) delete at; } -void WorldSession::HandleArenaTeamRemoveFromTeamOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data) { - sLog.outDebug("CMSG_ARENA_TEAM_REMOVE_FROM_TEAM"); + sLog.outDebug("CMSG_ARENA_TEAM_REMOVE"); CHECK_PACKET_SIZE(recv_data, 4+1); @@ -309,9 +309,9 @@ void WorldSession::HandleArenaTeamRemoveFromTeamOpcode(WorldPacket & recv_data) at->BroadcastPacket(&data); } -void WorldSession::HandleArenaTeamPromoteToCaptainOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recv_data) { - sLog.outDebug("CMSG_ARENA_TEAM_PROMOTE_TO_CAPTAIN"); + sLog.outDebug("CMSG_ARENA_TEAM_LEADER"); CHECK_PACKET_SIZE(recv_data, 4+1); diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index 921db551508..1a70162de11 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -615,7 +615,8 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); - //sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); + //sLog.outDebug("Auctionhouse search (GUID: %u TypeId: %u)", , list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", + // GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) ); uint32 count = 0; diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index bfb24b15e7a..1b3a96f7584 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -682,6 +682,6 @@ void AuctionEntry::SaveToDB() const { //No SQL injection (no strings) CharacterDatabase.PExecute("INSERT INTO auctionhouse (id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u')", + "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u')", Id, auctioneer, item_guidlow, item_template, owner, buyout, (uint64)expire_time, bidder, bid, startbid, deposit); } diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index a995157786f..118c9769480 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -486,7 +486,7 @@ void BattleGround::SendPacketToAll(WorldPacket *packet) if (plr) plr->GetSession()->SendPacket(packet); else - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); } } @@ -498,7 +498,7 @@ void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player * if (!plr) { - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); continue; } @@ -530,7 +530,7 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID) if (!plr) { - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); continue; } @@ -553,7 +553,7 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID) if (!plr) { - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); continue; } @@ -573,7 +573,7 @@ void BattleGround::YellToAll(Creature* creature, const char* text, uint32 langua Player *plr = objmgr.GetPlayer(itr->first); if(!plr) { - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player " UI64FMTD " not found!", itr->first); continue; } creature->BuildMonsterChat(&data,CHAT_MSG_MONSTER_YELL,text,language,creature->GetName(),itr->first); @@ -590,7 +590,7 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID) if (!plr) { - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); continue; } @@ -615,7 +615,7 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, if (!plr) { - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); continue; } @@ -714,7 +714,7 @@ void BattleGround::EndBattleGround(uint32 winner) else loser_arena_team->OfflineMemberLost(itr->first, winner_rating); } - sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first); + sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first)); continue; } diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index 7e6063a09d2..385ec3d9bc1 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -152,7 +152,7 @@ void BattleGroundEY::CheckSomeoneJoinedPoint() Player *plr = objmgr.GetPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]); if (!plr) { - sLog.outError("BattleGroundEY: Player " I64FMTD " not found!", m_PlayersNearPoint[EY_POINTS_MAX][j]); + sLog.outError("BattleGroundEY: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j])); ++j; continue; } @@ -192,7 +192,7 @@ void BattleGroundEY::CheckSomeoneLeftPoint() Player *plr = objmgr.GetPlayer(m_PlayersNearPoint[i][j]); if (!plr) { - sLog.outError("BattleGroundEY: Player " I64FMTD " not found!", m_PlayersNearPoint[i][j]); + sLog.outError("BattleGroundEY: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j])); //move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 903f7888813..b22c47e75d5 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -34,13 +34,13 @@ #include "ArenaTeam.h" #include "Language.h" -void WorldSession::HandleBattleGroundHelloOpcode( WorldPacket & recv_data ) +void WorldSession::HandleBattlemasterHelloOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 8); uint64 guid; recv_data >> guid; - sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from: " I64FMT, guid); + sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid))); Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) @@ -71,7 +71,7 @@ void WorldSession::SendBattlegGroundList( uint64 guid, BattleGroundTypeId bgType SendPacket( &data ); } -void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data ) +void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 8+4+4+1); @@ -95,7 +95,7 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data ) BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_); - sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from: " I64FMT, guid); + sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid))); // can do this, since it's battleground, not arena BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, 0); @@ -272,7 +272,7 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv } } -void WorldSession::HandleBattleGroundPVPlogdataOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandlePVPLogDataOpcode( WorldPacket & /*recv_data*/ ) { sLog.outDebug( "WORLD: Recvd MSG_PVP_LOG_DATA Message"); @@ -287,7 +287,7 @@ void WorldSession::HandleBattleGroundPVPlogdataOpcode( WorldPacket & /*recv_data sLog.outDebug( "WORLD: Sent MSG_PVP_LOG_DATA Message"); } -void WorldSession::HandleBattleGroundListOpcode( WorldPacket &recv_data ) +void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data ) { CHECK_PACKET_SIZE(recv_data, 4); @@ -308,7 +308,7 @@ void WorldSession::HandleBattleGroundListOpcode( WorldPacket &recv_data ) SendPacket( &data ); } -void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) +void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) { CHECK_PACKET_SIZE(recv_data, 1+1+4+2+1); @@ -504,7 +504,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) } } -void WorldSession::HandleBattleGroundLeaveOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLeaveBattlefieldOpcode( WorldPacket & /*recv_data*/ ) { //CHECK_PACKET_SIZE(recv_data, 1+1+4+2); @@ -632,7 +632,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data ) bg->AddPlayerToResurrectQueue(guid, _player->GetGUID()); } -void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data ) +void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 8+1+1+1); @@ -673,7 +673,7 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data ) arenatype = ARENA_TYPE_5v5; break; default: - sLog.outError("Unknown arena slot %u at HandleBattleGroundArenaJoin()", arenaslot); + sLog.outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot); return; } @@ -793,7 +793,7 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data ) sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenatype, isRated, arenaRating); } -void WorldSession::HandleBattleGroundReportAFK( WorldPacket & recv_data ) +void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 8); @@ -803,11 +803,11 @@ void WorldSession::HandleBattleGroundReportAFK( WorldPacket & recv_data ) if (!reportedPlayer) { - sLog.outDebug("WorldSession::HandleBattleGroundReportAFK: player not found"); + sLog.outDebug("WorldSession::HandleReportPvPAFK: player not found"); return; } - sLog.outDebug("WorldSession::HandleBattleGroundReportAFK: %s reported %s", _player->GetName(), reportedPlayer->GetName()); + sLog.outDebug("WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName(), reportedPlayer->GetName()); reportedPlayer->ReportedAfkBy(_player); } diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index f0f801c3060..561953cbf02 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -1190,7 +1190,7 @@ void BattleGroundMgr::Update(uint32 diff) { DistributeArenaPoints(); m_NextAutoDistributionTime = time(NULL) + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS); - CharacterDatabase.PExecute("UPDATE saved_variables SET NextArenaPointDistributionTime = '"I64FMTD"'", m_NextAutoDistributionTime); + CharacterDatabase.PExecute("UPDATE saved_variables SET NextArenaPointDistributionTime = '"UI64FMTD"'", m_NextAutoDistributionTime); } m_AutoDistributionTimeChecker = 600000; // check 10 minutes } @@ -1761,7 +1761,7 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution() { sLog.outDebug("Battleground: Next arena point distribution time not found in SavedVariables, reseting it now."); m_NextAutoDistributionTime = time(NULL) + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS); - CharacterDatabase.PExecute("INSERT INTO saved_variables (NextArenaPointDistributionTime) VALUES ('"I64FMTD"')", m_NextAutoDistributionTime); + CharacterDatabase.PExecute("INSERT INTO saved_variables (NextArenaPointDistributionTime) VALUES ('"UI64FMTD"')", m_NextAutoDistributionTime); } else { diff --git a/src/game/ChannelHandler.cpp b/src/game/ChannelHandler.cpp index 9b06693c589..7359c104751 100644 --- a/src/game/ChannelHandler.cpp +++ b/src/game/ChannelHandler.cpp @@ -25,7 +25,7 @@ INSTANTIATE_SINGLETON_1( AllianceChannelMgr ); INSTANTIATE_SINGLETON_1( HordeChannelMgr ); -void WorldSession::HandleChannelJoin(WorldPacket& recvPacket) +void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); @@ -50,7 +50,7 @@ void WorldSession::HandleChannelJoin(WorldPacket& recvPacket) chn->Join(_player->GetGUID(), pass.c_str()); } -void WorldSession::HandleChannelLeave(WorldPacket& recvPacket) +void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); @@ -315,7 +315,7 @@ void WorldSession::HandleChannelUnban(WorldPacket& recvPacket) chn->UnBan(_player->GetGUID(), otp.c_str()); } -void WorldSession::HandleChannelAnnounce(WorldPacket& recvPacket) +void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); @@ -341,7 +341,7 @@ void WorldSession::HandleChannelModerate(WorldPacket& recvPacket) chn->Moderate(_player->GetGUID()); } -void WorldSession::HandleChannelRosterQuery(WorldPacket &recvPacket) +void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); @@ -354,7 +354,7 @@ void WorldSession::HandleChannelRosterQuery(WorldPacket &recvPacket) chn->List(_player); } -void WorldSession::HandleChannelInfoQuery(WorldPacket &recvPacket) +void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); @@ -375,7 +375,7 @@ void WorldSession::HandleChannelInfoQuery(WorldPacket &recvPacket) } } -void WorldSession::HandleChannelJoinNotify(WorldPacket &recvPacket) +void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 75e5611ea07..0f4cb5ee0b5 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -74,7 +74,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT data,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACTIONS, "SELECT button,action,type,misc FROM character_action WHERE guid = '%u' ORDER BY button", GUID_LOPART(m_guid)); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" I64FMTD "'", GUID_LOPART(m_guid),(uint64)time(NULL)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(m_guid),(uint64)time(NULL)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILDATE, "SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT friend,flags,note FROM character_social WHERE guid = '%u' LIMIT 255", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(m_guid)); @@ -942,7 +942,7 @@ void WorldSession::HandleTutorialReset( WorldPacket & /*recv_data*/ ) GetPlayer()->SetTutorialInt( i, 0x00000000 ); } -void WorldSession::HandleSetWatchedFactionIndexOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data) { CHECK_PACKET_SIZE(recv_data,4); @@ -952,7 +952,7 @@ void WorldSession::HandleSetWatchedFactionIndexOpcode(WorldPacket & recv_data) GetPlayer()->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fact); } -void WorldSession::HandleSetWatchedFactionInactiveOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data) { CHECK_PACKET_SIZE(recv_data,4+1); @@ -964,19 +964,19 @@ void WorldSession::HandleSetWatchedFactionInactiveOpcode(WorldPacket & recv_data _player->GetReputationMgr().SetInactive(replistid, inactive); } -void WorldSession::HandleToggleHelmOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleShowingHelmOpcode( WorldPacket & /*recv_data*/ ) { - DEBUG_LOG("CMSG_TOGGLE_HELM for %s", _player->GetName()); + DEBUG_LOG("CMSG_SHOWING_HELM for %s", _player->GetName()); _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); } -void WorldSession::HandleToggleCloakOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleShowingCloakOpcode( WorldPacket & /*recv_data*/ ) { - DEBUG_LOG("CMSG_TOGGLE_CLOAK for %s", _player->GetName()); + DEBUG_LOG("CMSG_SHOWING_CLOAK for %s", _player->GetName()); _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); } -void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data) +void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) { CHECK_PACKET_SIZE(recv_data, 8+1); @@ -1059,7 +1059,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin session->SendPacket(&data); } -void WorldSession::HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data) +void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) { uint64 guid; diff --git a/src/game/Chat.h b/src/game/Chat.h index 725217ef69b..0b8b076969b 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -597,6 +597,7 @@ class ChatHandler bool HandleBanInfoHelper(uint32 accountid, char const* accountname); bool HandleUnBanHelper(BanMode mode,char const* args); void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel); + void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id); void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; private: diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 0627f6419fb..72d7f0212d5 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -2139,10 +2139,33 @@ bool Creature::LoadCreaturesAddon(bool reload) Mount(cainfo->mount); if (cainfo->bytes1 != 0) - SetUInt32Value(UNIT_FIELD_BYTES_1, cainfo->bytes1); + { + // 0 StandState + // 1 FreeTalentPoints Pet only, so always 0 for default creature + // 2 StandFlags + // 3 StandMiscFlags + + SetByteValue(UNIT_FIELD_BYTES_1, 0, uint8(cainfo->bytes1 & 0xFF)); + //SetByteValue(UNIT_FIELD_BYTES_1, 1, uint8((cainfo->bytes1 >> 8) & 0xFF)); + SetByteValue(UNIT_FIELD_BYTES_1, 1, 0); + SetByteValue(UNIT_FIELD_BYTES_1, 2, uint8((cainfo->bytes1 >> 16) & 0xFF)); + SetByteValue(UNIT_FIELD_BYTES_1, 3, uint8((cainfo->bytes1 >> 24) & 0xFF)); + } if (cainfo->bytes2 != 0) - SetUInt32Value(UNIT_FIELD_BYTES_2, cainfo->bytes2); + { + // 0 SheathState + // 1 Bytes2Flags + // 2 UnitRename Pet only, so always 0 for default creature + // 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura + + SetByteValue(UNIT_FIELD_BYTES_2, 0, uint8(cainfo->bytes2 & 0xFF)); + SetByteValue(UNIT_FIELD_BYTES_2, 1, uint8((cainfo->bytes2 >> 8) & 0xFF)); + //SetByteValue(UNIT_FIELD_BYTES_2, 2, uint8((cainfo->bytes2 >> 16) & 0xFF)); + SetByteValue(UNIT_FIELD_BYTES_2, 2, 0); + //SetByteValue(UNIT_FIELD_BYTES_2, 3, uint8((cainfo->bytes2 >> 24) & 0xFF)); + SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); + } if (cainfo->emote != 0) SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote); diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 267ceb5f7de..e2c51f40804 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -413,12 +413,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: { - if (action.morph.creatireId || action.morph.modelId) + if (action.morph.creatureId || action.morph.modelId) { //set model based on entry from creature_template - if (action.morph.creatireId) + if (action.morph.creatureId) { - if (CreatureInfo const* ci = GetCreatureTemplateStore(action.morph.creatireId)) + if (CreatureInfo const* ci = GetCreatureTemplateStore(action.morph.creatureId)) { //use default display if (ci->Modelid_A1) @@ -520,12 +520,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 Creature* pCreature = NULL; if (action.summon.duration) - pCreature = m_creature->SummonCreature(action.summon.creatured, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); + pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); else - pCreature = m_creature->SummonCreature(action.summon.creatured, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); if (!pCreature) - sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatured, EventId, m_creature->GetEntry()); + sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); else if (action.summon.target != TARGET_T_SELF && target) pCreature->AI()->AttackStart(target); break; @@ -577,15 +577,27 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 MeleeEnabled = action.auto_attack.state != 0; break; case ACTION_T_COMBAT_MOVEMENT: + // ignore no affect case + if(CombatMovementEnabled==(action.combat_movement.state!=0)) + return; + CombatMovementEnabled = action.combat_movement.state != 0; //Allow movement (create new targeted movement gen only if idle) if (CombatMovementEnabled) { - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); + if(action.combat_movement.melee && m_creature->isInCombat()) + if(Unit* victim = m_creature->getVictim()) + m_creature->SendMeleeAttackStart(victim); + + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); } else { + if(action.combat_movement.melee && m_creature->isInCombat()) + if(Unit* victim = m_creature->getVictim()) + m_creature->SendMeleeAttackStop(victim); + m_creature->GetMotionMaster()->MoveIdle(); } break; @@ -605,7 +617,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 sLog.outErrorDb( "CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, m_creature->GetEntry()); Phase = MAX_PHASE-1; } - else + else Phase = new_phase; break; diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index eb9a2a2dff5..d94ceeeac18 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -199,73 +199,73 @@ struct CreatureEventAI_Action // ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3 struct { - uint32 creatireId; // set one from fields (or 0 for both to demorph) + uint32 creatureId; // set one from fields (or 0 for both to demorph) uint32 modelId; } morph; // ACTION_T_SOUND = 4 - struct + struct { uint32 soundId; } sound; // ACTION_T_EMOTE = 5 - struct + struct { uint32 emoteId; } emote; // ACTION_T_RANDOM_SOUND = 9 - struct + struct { int32 soundId1; // (-1 in any field means no output if randomed that field) int32 soundId2; int32 soundId3; } random_sound; // ACTION_T_RANDOM_EMOTE = 10 - struct + struct { int32 emoteId1; // (-1 in any field means no output if randomed that field) int32 emoteId2; int32 emoteId3; } random_emote; // ACTION_T_CAST = 11 - struct + struct { uint32 spellId; uint32 target; uint32 castFlags; } cast; // ACTION_T_SUMMON = 12 - struct + struct { - uint32 creatured; + uint32 creatureId; uint32 target; uint32 duration; } summon; // ACTION_T_THREAT_SINGLE_PCT = 13 - struct + struct { int32 percent; uint32 target; } threat_single_pct; // ACTION_T_THREAT_ALL_PCT = 14 - struct + struct { int32 percent; } threat_all_pct; // ACTION_T_QUEST_EVENT = 15 - struct + struct { uint32 questId; uint32 target; } quest_event; // ACTION_T_CAST_EVENT = 16 - struct + struct { uint32 creatureId; uint32 spellId; uint32 target; } cast_event; // ACTION_T_SET_UNIT_FIELD = 17 - struct + struct { uint32 field; uint32 value; @@ -273,94 +273,95 @@ struct CreatureEventAI_Action } set_unit_field; // ACTION_T_SET_UNIT_FLAG = 18, // value provided mask bits that will be set // ACTION_T_REMOVE_UNIT_FLAG = 19, // value provided mask bits that will be clear - struct + struct { uint32 value; uint32 target; } unit_flag; // ACTION_T_AUTO_ATTACK = 20 - struct + struct { uint32 state; // 0 = stop attack, anything else means continue attacking } auto_attack; // ACTION_T_COMBAT_MOVEMENT = 21 - struct + struct { uint32 state; // 0 = stop combat based movement, anything else continue attacking + uint32 melee; // if set: at stop send melee combat stop if in combat, use for terminate melee fighting state for switch to ranged } combat_movement; // ACTION_T_SET_PHASE = 22 - struct + struct { uint32 phase; } set_phase; // ACTION_T_INC_PHASE = 23 - struct + struct { int32 step; } set_inc_phase; // ACTION_T_QUEST_EVENT_ALL = 26 - struct + struct { uint32 questId; } quest_event_all; // ACTION_T_CAST_EVENT_ALL = 27 - struct + struct { uint32 creatureId; uint32 spellId; } cast_event_all; // ACTION_T_REMOVEAURASFROMSPELL = 28 - struct + struct { uint32 target; uint32 spellId; } remove_aura; // ACTION_T_RANGED_MOVEMENT = 29 - struct + struct { uint32 distance; int32 angle; } ranged_movement; // ACTION_T_RANDOM_PHASE = 30 - struct + struct { uint32 phase1; uint32 phase2; uint32 phase3; } random_phase; // ACTION_T_RANDOM_PHASE_RANGE = 31 - struct + struct { uint32 phaseMin; uint32 phaseMax; } random_phase_range; // ACTION_T_SUMMON_ID = 32 - struct + struct { uint32 creatureId; uint32 target; uint32 spawnId; } summon_id; // ACTION_T_KILLED_MONSTER = 33 - struct + struct { uint32 creatureId; uint32 target; } killed_monster; // ACTION_T_SET_INST_DATA = 34 - struct + struct { uint32 field; uint32 value; } set_inst_data; // ACTION_T_SET_INST_DATA64 = 35 - struct + struct { uint32 field; uint32 target; } set_inst_data64; // ACTION_T_UPDATE_TEMPLATE = 36 - struct + struct { uint32 creatureId; uint32 team; @@ -508,7 +509,7 @@ struct CreatureEventAI_Event } receive_emote; // RAW - struct + struct { uint32 param1; uint32 param2; diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index af79ae5189c..0a6fb8bdb59 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -438,19 +438,19 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() } break; case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: - if (action.morph.creatireId !=0 || action.morph.modelId !=0) + if (action.morph.creatureId !=0 || action.morph.modelId !=0) { - if (action.morph.creatireId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.morph.creatireId)) + if (action.morph.creatureId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.morph.creatureId)) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant Creature entry %u.", i, j+1, action.morph.creatireId); - action.morph.creatireId = 0; + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant Creature entry %u.", i, j+1, action.morph.creatureId); + action.morph.creatureId = 0; } if (action.morph.modelId) { - if (action.morph.creatireId) + if (action.morph.creatureId) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.morph.modelId,action.morph.creatireId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.morph.modelId,action.morph.creatureId); action.morph.modelId = 0; } else if (!sCreatureDisplayInfoStore.LookupEntry(action.morph.modelId)) @@ -512,8 +512,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; } case ACTION_T_SUMMON: - if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatured)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.summon.creatured); + if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatureId)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.summon.creatureId); if (action.summon.target >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 50a543859cd..c35048548bb 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -756,7 +756,8 @@ struct CurrencyTypesEntry { //uint32 ID; // 0 not used uint32 ItemId; // 1 used as real index - uint32 BitIndex; // 2 bit index in PLAYER_FIELD_KNOWN_CURRENCIES (1 << (index-1)) + //uint32 Category; // 2 may be category + uint32 BitIndex; // 3 bit index in PLAYER_FIELD_KNOWN_CURRENCIES (1 << (index-1)) }; struct DurabilityCostsEntry @@ -1038,8 +1039,8 @@ struct ItemLimitCategoryEntry uint32 ID; // 0 Id //char* name[16] // 1-16 m_name_lang // 17 name flags - uint32 maxCount; // max allowed equipped as item or in gem slot - //uint32 unk; // 1 for prismatic gems only... + uint32 maxCount; // 18, max allowed equipped as item or in gem slot + //uint32 unk; // 19, 1 for gems only... }; struct ItemRandomPropertiesEntry @@ -1276,7 +1277,7 @@ struct SkillLineEntry uint32 spellIcon; // 37 m_spellIconID //char* alternateVerb[16]; // 38-53 m_alternateVerb_lang // 54 string flags - // 55 m_canLink + uint32 canLink; // 55 m_canLink (prof. with recipes }; struct SkillLineAbilityEntry diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index 9187cc85e3d..cf3d723a364 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -81,7 +81,7 @@ const char QuestSortEntryfmt[]="nxxxxxxxxxxxxxxxxx"; const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii"; const char ScalingStatDistributionfmt[]="niiiiiiiiiiiiiiiiiiiii"; const char ScalingStatValuesfmt[]="iniiiiiiiiiiiiiiiii"; -const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxx"; +const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxi"; const char SkillLineAbilityfmt[]="niiiixxiiiiixx"; const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char SpellCastTimefmt[]="nixx"; diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index 018b20e0b3f..0d70a4f5cde 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -1618,7 +1618,7 @@ void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("DELETE FROM game_event_save WHERE event_id = '%u'",event_id); if(mGameEvent[event_id].nextstart) - CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart)); + CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("UI64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart)); else CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u','0000-00-00 00:00:00')",event_id,mGameEvent[event_id].state); CharacterDatabase.CommitTransaction(); diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 3493bec6bb0..e1693e0bdbe 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -105,6 +105,7 @@ struct GameObjectInfo uint32 openTextID; //14 can be used to replace castBarCaption? uint32 groupLootRules; //15 } chest; + //4 GAMEOBJECT_TYPE_BINDER - empty //5 GAMEOBJECT_TYPE_GENERIC struct { @@ -207,6 +208,7 @@ struct GameObjectInfo uint32 eventID; //2 uint32 openTextID; //3 can be used to replace castBarCaption? } camera; + //14 GAMEOBJECT_TYPE_MAPOBJECT - empty //15 GAMEOBJECT_TYPE_MO_TRANSPORT struct { @@ -218,6 +220,7 @@ struct GameObjectInfo uint32 transportPhysics; //5 uint32 mapID; //6 } moTransport; + //16 GAMEOBJECT_TYPE_DUELFLAG - empty //17 GAMEOBJECT_TYPE_FISHINGNODE struct { @@ -236,6 +239,7 @@ struct GameObjectInfo uint32 castersGrouped; //6 uint32 ritualNoTargetCheck; //7 } summoningRitual; + //19 GAMEOBJECT_TYPE_MAILBOX - empty //20 GAMEOBJECT_TYPE_AUCTIONHOUSE struct { @@ -358,7 +362,8 @@ struct GameObjectInfo uint32 unk9; uint32 destroyedDisplayId; //10 } destructibleBuilding; - //34 GAMEOBJECT_TYPE_TRAPDOOR + //34 GAMEOBJECT_TYPE_GUILDBANK - empty + //35 GAMEOBJECT_TYPE_TRAPDOOR struct { uint32 whenToPause; // 0 @@ -367,7 +372,7 @@ struct GameObjectInfo } trapDoor; // not use for specific field access (only for output with loop by all filed), also this determinate max union size - struct // GAMEOBJECT_TYPE_SPELLCASTER + struct { uint32 data[24]; } raw; diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 42c4c66ef01..5191f4e9313 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -152,7 +152,7 @@ void PlayerMenu::SendGossipMenu( uint32 TitleTextId, uint64 npcGUID ) Quest const* pQuest = objmgr.GetQuestTemplate(questID); data << uint32(questID); - data << uint32( qItem.m_qIcon ); + data << uint32(qItem.m_qIcon); data << uint32(pSession->GetPlayer()->GetQuestLevel(pQuest)); std::string Title = pQuest->GetTitle(); diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 7eb5c326142..a1bee4df650 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -996,10 +996,10 @@ namespace Trinity return false; if(!u->CanAssistTo(i_obj,i_enemy)) return false; - + if(!i_obj->IsWithinDistInMap(u, i_range)) return false; - + if(!i_obj->IsWithinLOSInMap(u)) return false; diff --git a/src/game/Group.cpp b/src/game/Group.cpp index d2c17680e52..a9d06091619 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -107,7 +107,7 @@ bool Group::Create(const uint64 &guid, const char * name) CharacterDatabase.PExecute("DELETE FROM groups WHERE leaderGuid ='%u'", GUID_LOPART(m_leaderGuid)); CharacterDatabase.PExecute("DELETE FROM group_member WHERE leaderGuid ='%u'", GUID_LOPART(m_leaderGuid)); CharacterDatabase.PExecute("INSERT INTO groups(leaderGuid,mainTank,mainAssistant,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,isRaid,difficulty) " - "VALUES('%u','%u','%u','%u','%u','%u','" I64FMTD "','" I64FMTD "','" I64FMTD "','" I64FMTD "','" I64FMTD "','" I64FMTD "','" I64FMTD "','" I64FMTD "','%u','%u')", + "VALUES('%u','%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u','%u')", GUID_LOPART(m_leaderGuid), GUID_LOPART(m_mainTank), GUID_LOPART(m_mainAssistant), uint32(m_lootMethod), GUID_LOPART(m_looterGuid), uint32(m_lootThreshold), m_targetIcons[0], m_targetIcons[1], m_targetIcons[2], m_targetIcons[3], m_targetIcons[4], m_targetIcons[5], m_targetIcons[6], m_targetIcons[7], isRaidGroup(), m_difficulty); } diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index cd7004f5a07..1a156070815 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -276,7 +276,7 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY); } -void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) { CHECK_PACKET_SIZE(recv_data,1); @@ -290,7 +290,7 @@ void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data) // can't uninvite yourself if(GetPlayer()->GetName() == membername) { - sLog.outError("WorldSession::HandleGroupUninviteNameOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog.outError("WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } @@ -342,7 +342,7 @@ void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data ) group->ChangeLeader(guid); } -void WorldSession::HandleGroupLeaveOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleGroupDisbandOpcode( WorldPacket & /*recv_data*/ ) { if(!GetPlayer()->GetGroup()) return; @@ -409,6 +409,16 @@ void WorldSession::HandleLootRoll( WorldPacket &recv_data ) // everything's fine, do it group->CountRollVote(GetPlayer()->GetGUID(), Guid, NumberOfPlayers, Choise); + + switch (Choise) + { + case 1: + GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, 1); + break; + case 2: + GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, 1); + break; + } } void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) @@ -464,7 +474,7 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleRaidIconTargetOpcode( WorldPacket & recv_data ) +void WorldSession::HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,1); @@ -497,7 +507,7 @@ void WorldSession::HandleRaidIconTargetOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleRaidConvertOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleGroupRaidConvertOpcode( WorldPacket & /*recv_data*/ ) { Group *group = GetPlayer()->GetGroup(); if(!group) @@ -558,7 +568,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ) group->ChangeMembersGroup(movedPlayer, groupNr); } -void WorldSession::HandleGroupAssistantOpcode( WorldPacket & recv_data ) +void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+1); @@ -580,9 +590,10 @@ void WorldSession::HandleGroupAssistantOpcode( WorldPacket & recv_data ) group->SetAssistant(guid, (flag==0?false:true)); } -void WorldSession::HandleGroupPromoteOpcode( WorldPacket & recv_data ) +void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 1+1+8); + sLog.outDebug("MSG_PARTY_ASSIGNMENT"); Group *group = GetPlayer()->GetGroup(); if(!group) @@ -642,7 +653,7 @@ void WorldSession::HandleRaidReadyCheckOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleRaidReadyCheckFinishOpcode( WorldPacket & recv_data ) +void WorldSession::HandleRaidReadyCheckFinishedOpcode( WorldPacket & /*recv_data*/ ) { //Group* group = GetPlayer()->GetGroup(); //if(!group) @@ -919,11 +930,11 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ) sLog.outDebug( "WORLD: got CMSG_GROUP_CANCEL." ); }*/ -void WorldSession::HandleGroupPassOnLootOpcode( WorldPacket & recv_data ) +void WorldSession::HandleOptOutOfLootOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 4); - sLog.outDebug("WORLD: Received CMSG_GROUP_PASS_ON_LOOT"); + sLog.outDebug("WORLD: Received CMSG_OPT_OUT_OF_LOOT"); uint32 unkn; recv_data >> unkn; diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index fdc39d5d851..205277be2d0 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -84,7 +84,7 @@ bool Guild::create(Player* leader, std::string gname) CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", Id); CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid='%u'", Id); CharacterDatabase.PExecute("INSERT INTO guild (guildid,name,leaderguid,info,motd,createdate,EmblemStyle,EmblemColor,BorderStyle,BorderColor,BackgroundColor,BankMoney) " - "VALUES('%u','%s','%u', '%s', '%s', NOW(),'%u','%u','%u','%u','%u','" I64FMTD "')", + "VALUES('%u','%s','%u', '%s', '%s', NOW(),'%u','%u','%u','%u','%u','" UI64FMTD "')", Id, gname.c_str(), GUID_LOPART(leaderGuid), dbGINFO.c_str(), dbMOTD.c_str(), EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, guildbank_money); CharacterDatabase.CommitTransaction(); @@ -934,7 +934,7 @@ void Guild::LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid // Add entry to map m_GuildEventlog.push_back(NewEvent); // Add new eventlog entry into DB - CharacterDatabase.PExecute("INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','" I64FMTD "')", + CharacterDatabase.PExecute("INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','" UI64FMTD "')", Id, NewEvent->LogGuid, uint32(NewEvent->EventType), NewEvent->PlayerGuid1, NewEvent->PlayerGuid2, uint32(NewEvent->NewRank), NewEvent->TimeStamp); } @@ -1317,7 +1317,7 @@ void Guild::SetBankMoney(int64 money) money = 0; guildbank_money = money; - CharacterDatabase.PExecute("UPDATE guild SET BankMoney='" I64FMTD "' WHERE guildid='%u'", money, Id); + CharacterDatabase.PExecute("UPDATE guild SET BankMoney='" UI64FMTD "' WHERE guildid='%u'", money, Id); } // ************************************************* @@ -1683,7 +1683,7 @@ void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint } m_GuildBankEventLog_Item[TabId].push_back(NewEvent); } - CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" I64FMTD "')", + CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "')", Id, NewEvent->LogGuid, uint32(NewEvent->LogEntry), uint32(TabId), NewEvent->PlayerGuid, NewEvent->ItemOrMoney, uint32(NewEvent->ItemStackCount), uint32(NewEvent->DestTabId), NewEvent->TimeStamp); } diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 4055497c730..ffb6d26676f 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -740,7 +740,7 @@ void WorldSession::SendGuildCommandResult(uint32 typecmd, const std::string& str //sLog.outDebug("WORLD: Sent (SMSG_GUILD_COMMAND_RESULT)"); } -void WorldSession::HandleGuildChangeInfoOpcode(WorldPacket& recvPacket) +void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket, 1); @@ -766,7 +766,7 @@ void WorldSession::HandleGuildChangeInfoOpcode(WorldPacket& recvPacket) guild->SetGINFO(GINFO); } -void WorldSession::HandleGuildSaveEmblemOpcode(WorldPacket& recvPacket) +void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket, 8+4+4+4+4+4); @@ -787,7 +787,7 @@ void WorldSession::HandleGuildSaveEmblemOpcode(WorldPacket& recvPacket) { //"That's not an emblem vendor!" SendSaveGuildEmblem(ERR_GUILDEMBLEM_INVALIDVENDOR); - sLog.outDebug("WORLD: HandleGuildSaveEmblemOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(vendorGuid)); + sLog.outDebug("WORLD: HandleSaveGuildEmblemOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(vendorGuid)); return; } @@ -832,7 +832,7 @@ void WorldSession::HandleGuildSaveEmblemOpcode(WorldPacket& recvPacket) guild->Query(this); } -void WorldSession::HandleGuildEventLogOpcode(WorldPacket& /* recvPacket */) +void WorldSession::HandleGuildEventLogQueryOpcode(WorldPacket& /* recvPacket */) { // empty sLog.outDebug("WORLD: Received (MSG_GUILD_EVENT_LOG_QUERY)"); @@ -851,7 +851,7 @@ void WorldSession::HandleGuildEventLogOpcode(WorldPacket& /* recvPacket */) /****** GUILD BANK *******/ -void WorldSession::HandleGuildBankGetMoneyAmount( WorldPacket & /* recv_data */ ) +void WorldSession::HandleGuildBankMoneyWithdrawn( WorldPacket & /* recv_data */ ) { sLog.outDebug("WORLD: Received (MSG_GUILD_BANK_MONEY_WITHDRAWN)"); //recv_data.hexlike(); @@ -867,7 +867,7 @@ void WorldSession::HandleGuildBankGetMoneyAmount( WorldPacket & /* recv_data */ pGuild->SendMoneyInfo(this, GetPlayer()->GetGUIDLow()); } -void WorldSession::HandleGuildBankGetRights( WorldPacket& /* recv_data */ ) +void WorldSession::HandleGuildPermissions( WorldPacket& /* recv_data */ ) { sLog.outDebug("WORLD: Received (MSG_GUILD_PERMISSIONS)"); @@ -897,7 +897,7 @@ void WorldSession::HandleGuildBankGetRights( WorldPacket& /* recv_data */ ) } /* Called when clicking on Guild bank gameobject */ -void WorldSession::HandleGuildBankQuery( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankerActivate( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANKER_ACTIVATE)"); CHECK_PACKET_SIZE(recv_data,8+1); @@ -921,7 +921,7 @@ void WorldSession::HandleGuildBankQuery( WorldPacket & recv_data ) } /* Called when opening guild bank tab only (first one) */ -void WorldSession::HandleGuildBankTabColon( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB)"); CHECK_PACKET_SIZE(recv_data,8+1+1); @@ -947,7 +947,7 @@ void WorldSession::HandleGuildBankTabColon( WorldPacket & recv_data ) pGuild->DisplayGuildBankContent(this, TabId); } -void WorldSession::HandleGuildBankDeposit( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_DEPOSIT_MONEY)"); CHECK_PACKET_SIZE(recv_data,8+4); @@ -995,7 +995,7 @@ void WorldSession::HandleGuildBankDeposit( WorldPacket & recv_data ) pGuild->DisplayGuildBankMoneyUpdate(); } -void WorldSession::HandleGuildBankWithdraw( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_WITHDRAW_MONEY)"); CHECK_PACKET_SIZE(recv_data,8+4); @@ -1045,7 +1045,7 @@ void WorldSession::HandleGuildBankWithdraw( WorldPacket & recv_data ) pGuild->DisplayGuildBankMoneyUpdate(); } -void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_SWAP_ITEMS)"); //recv_data.hexlike(); @@ -1599,7 +1599,7 @@ void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data ) pGuild->DisplayGuildBankTabsInfo(this); } -void WorldSession::HandleGuildBankModifyTab( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_UPDATE_TAB)"); //recv_data.hexlike(); @@ -1636,7 +1636,7 @@ void WorldSession::HandleGuildBankModifyTab( WorldPacket & recv_data ) pGuild->DisplayGuildBankContent(this, TabId); } -void WorldSession::HandleGuildBankLog( WorldPacket & recv_data ) +void WorldSession::HandleGuildBankLogQuery( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (MSG_GUILD_BANK_LOG_QUERY)"); CHECK_PACKET_SIZE(recv_data, 1); @@ -1655,7 +1655,7 @@ void WorldSession::HandleGuildBankLog( WorldPacket & recv_data ) pGuild->DisplayGuildBankLogs(this, TabId); } -void WorldSession::HandleGuildBankTabText(WorldPacket &recv_data) +void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data) { sLog.outDebug("WORLD: Received MSG_QUERY_GUILD_BANK_TEXT"); CHECK_PACKET_SIZE(recv_data, 1); @@ -1674,7 +1674,7 @@ void WorldSession::HandleGuildBankTabText(WorldPacket &recv_data) pGuild->SendGuildBankTabText(this, TabId); } -void WorldSession::HandleGuildBankSetTabText(WorldPacket &recv_data) +void WorldSession::HandleSetGuildBankTabText(WorldPacket &recv_data) { sLog.outDebug("WORLD: Received CMSG_SET_GUILD_BANK_TEXT"); CHECK_PACKET_SIZE(recv_data, 1+1); diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index b12c001cf56..14d5951615d 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -135,7 +135,7 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId) { // save the resettime for normal instances only when they get unloaded if(time_t resettime = itr->second->GetResetTimeForDB()) - CharacterDatabase.PExecute("UPDATE instance SET resettime = '"I64FMTD"' WHERE id = '%u'", (uint64)resettime, InstanceId); + CharacterDatabase.PExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", (uint64)resettime, InstanceId); delete itr->second; m_instanceSaveById.erase(itr); } @@ -173,7 +173,7 @@ void InstanceSave::SaveToDB() } } - CharacterDatabase.PExecute("INSERT INTO instance VALUES ('%u', '%u', '"I64FMTD"', '%u', '%s')", m_instanceid, GetMapId(), (uint64)GetResetTimeForDB(), GetDifficulty(), data.c_str()); + CharacterDatabase.PExecute("INSERT INTO instance VALUES ('%u', '%u', '"UI64FMTD"', '%u', '%s')", m_instanceid, GetMapId(), (uint64)GetResetTimeForDB(), GetDifficulty(), data.c_str()); } time_t InstanceSave::GetResetTimeForDB() @@ -403,7 +403,7 @@ void InstanceSaveManager::LoadResetTimes() ResetTimeMapType::iterator itr = InstResetTime.find(instance); if(itr != InstResetTime.end() && itr->second.second != resettime) { - CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"I64FMTD"' WHERE id = '%u'", uint64(resettime), instance); + CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance); itr->second.second = resettime; } } @@ -438,7 +438,7 @@ void InstanceSaveManager::LoadResetTimes() uint64 oldresettime = fields[1].GetUInt64(); uint64 newresettime = (oldresettime / DAY) * DAY + diff; if(oldresettime != newresettime) - CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"I64FMTD"' WHERE mapid = '%u'", newresettime, mapid); + CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u'", newresettime, mapid); m_resetTimeByMapId[mapid] = newresettime; } while(result->NextRow()); @@ -447,7 +447,7 @@ void InstanceSaveManager::LoadResetTimes() // clean expired instances, references to them will be deleted in CleanupInstances // must be done before calculating new reset times - _DelHelper(CharacterDatabase, "id, map, difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map WHERE (instance.resettime < '"I64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"I64FMTD"')", (uint64)now, (uint64)now); + _DelHelper(CharacterDatabase, "id, map, difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)now, (uint64)now); // calculate new global reset times for expired instances and those that have never been reset yet // add the global reset times to the priority queue @@ -467,7 +467,7 @@ void InstanceSaveManager::LoadResetTimes() { // initialize the reset time t = today + period + diff; - CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','"I64FMTD"')", i, (uint64)t); + CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','"UI64FMTD"')", i, (uint64)t); } if(t < now) @@ -476,7 +476,7 @@ void InstanceSaveManager::LoadResetTimes() // calculate the next reset time t = (t / DAY) * DAY; t += ((today - t) / period + 1) * period + diff; - CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"I64FMTD"' WHERE mapid = '%u'", (uint64)t, i); + CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u'", (uint64)t, i); } m_resetTimeByMapId[temp->map] = t; @@ -619,7 +619,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe uint32 period = temp->reset_delay * DAY; uint64 next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff; // update it in the DB - CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"I64FMTD"' WHERE mapid = '%d'", next_reset, mapid); + CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d'", next_reset, mapid); } MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps(); diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 3be61c80ea2..ddb28e0288d 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -1009,7 +1009,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) return; } else - sLog.outDebug("WORLD: CMSG_ITEM_NAME_QUERY for item %u failed (unknown item)", itemid); + sLog.outErrorDb("WORLD: CMSG_ITEM_NAME_QUERY for item %u failed (unknown item)", itemid); } void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) @@ -1321,7 +1321,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) _player->ToggleMetaGemsActive(slot, true); //turn on all metagems (except for target item) } -void WorldSession::HandleCancelTempItemEnchantmentOpcode(WorldPacket& recv_data) +void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) { sLog.outDebug("WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT"); diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index 64c57d2c7fc..68e275ed963 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -123,6 +123,7 @@ enum ITEM_FLAGS enum BAG_FAMILY_MASK { + BAG_FAMILY_MASK_NONE = 0x00000000, BAG_FAMILY_MASK_ARROWS = 0x00000001, BAG_FAMILY_MASK_BULLETS = 0x00000002, BAG_FAMILY_MASK_SOUL_SHARDS = 0x00000004, @@ -564,7 +565,7 @@ struct ItemPrototype uint32 MaxDurability; uint32 Area; // id from AreaTable.dbc uint32 Map; // id from Map.dbc - uint32 BagFamily; // bit string (1 << id from ItemBagFamily.dbc) + uint32 BagFamily; // bit mask (1 << id from ItemBagFamily.dbc) uint32 TotemCategory; // id from TotemCategory.dbc _Socket Socket[MAX_ITEM_PROTO_SOCKETS]; uint32 socketBonus; // id from SpellItemEnchantment.dbc diff --git a/src/game/LFGHandler.cpp b/src/game/LFGHandler.cpp index 85c196a9346..6df5fc77532 100644 --- a/src/game/LFGHandler.cpp +++ b/src/game/LFGHandler.cpp @@ -142,9 +142,9 @@ static void AttemptAddMore(Player* _player) } } -void WorldSession::HandleLfgAutoJoinOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLfgSetAutoJoinOpcode( WorldPacket & /*recv_data*/ ) { - sLog.outDebug("CMSG_SET_LFG_AUTO_JOIN"); + sLog.outDebug("CMSG_LFG_SET_AUTOJOIN"); LookingForGroup_auto_join = true; if(!_player) // needed because STATUS_AUTHED @@ -153,15 +153,15 @@ void WorldSession::HandleLfgAutoJoinOpcode( WorldPacket & /*recv_data*/ ) AttemptJoin(_player); } -void WorldSession::HandleLfgCancelAutoJoinOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLfgClearAutoJoinOpcode( WorldPacket & /*recv_data*/ ) { - sLog.outDebug("CMSG_UNSET_LFG_AUTO_JOIN"); + sLog.outDebug("CMSG_LFG_CLEAR_AUTOJOIN"); LookingForGroup_auto_join = false; } -void WorldSession::HandleLfmAutoAddMembersOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLfmSetAutoFillOpcode( WorldPacket & /*recv_data*/ ) { - sLog.outDebug("CMSG_SET_LFM_AUTOADD"); + sLog.outDebug("CMSG_LFM_SET_AUTOFILL"); LookingForGroup_auto_add = true; if(!_player) // needed because STATUS_AUTHED @@ -170,15 +170,16 @@ void WorldSession::HandleLfmAutoAddMembersOpcode( WorldPacket & /*recv_data*/ ) AttemptAddMore(_player); } -void WorldSession::HandleLfmCancelAutoAddmembersOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLfmClearAutoFillOpcode( WorldPacket & /*recv_data*/ ) { - sLog.outDebug("CMSG_UNSET_LFM_AUTOADD"); + sLog.outDebug("CMSG_LFM_CLEAR_AUTOFILL"); LookingForGroup_auto_add = false; } void WorldSession::HandleLfgClearOpcode( WorldPacket & /*recv_data */ ) { - sLog.outDebug("CMSG_LOOKING_FOR_GROUP_CLEAR"); + // empty packet + sLog.outDebug("CMSG_CLEAR_LOOKING_FOR_GROUP"); for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) _player->m_lookingForGroup.slots[i].Clear(); @@ -187,14 +188,15 @@ void WorldSession::HandleLfgClearOpcode( WorldPacket & /*recv_data */ ) _player->LeaveLFGChannel(); } -void WorldSession::HandleLfmSetNoneOpcode( WorldPacket & /*recv_data */) +void WorldSession::HandleLfmClearOpcode( WorldPacket & /*recv_data */) { - sLog.outDebug("CMSG_SET_LOOKING_FOR_NONE"); + // empty packet + sLog.outDebug("CMSG_CLEAR_LOOKING_FOR_MORE"); _player->m_lookingForGroup.more.Clear(); } -void WorldSession::HandleLfmSetOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetLfmOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,4); @@ -216,11 +218,11 @@ void WorldSession::HandleLfmSetOpcode( WorldPacket & recv_data ) SendLfgResult(type, entry, 1); } -void WorldSession::HandleLfgSetCommentOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetLfgCommentOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1); + CHECK_PACKET_SIZE(recv_data, 1); - sLog.outDebug("CMSG_SET_COMMENTARY"); + sLog.outDebug("CMSG_SET_LFG_COMMENT"); //recv_data.hexlike(); std::string comment; @@ -232,7 +234,7 @@ void WorldSession::HandleLfgSetCommentOpcode( WorldPacket & recv_data ) void WorldSession::HandleLookingForGroup(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,4+4+4); + CHECK_PACKET_SIZE(recv_data, 4+4+4); sLog.outDebug("MSG_LOOKING_FOR_GROUP"); //recv_data.hexlike(); diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 054040fb708..0cde7dc5eb8 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1052,7 +1052,7 @@ bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args) uint64 titles = 0; - sscanf((char*)args, I64FMTD, &titles); + sscanf((char*)args, UI64FMTD, &titles); Player *chr = getSelectedPlayer(); if (!chr) @@ -1068,7 +1068,7 @@ bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args) uint64 titles2 = titles; - for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i) + for(int i = 1; i < sCharTitlesStore.GetNumRows(); ++i) if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) titles2 &= ~(uint64(1) << tEntry->bit_index); @@ -2418,7 +2418,7 @@ bool ChatHandler::HandleTeleNameCommand(const char * args) extractOptFirstArg((char*)args,&nameStr,&teleStr); if(!teleStr) return false; - + Player* target; uint64 target_guid; std::string target_name; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index e7eeda7966d..31834fce8ea 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -88,7 +88,7 @@ bool ChatHandler::HandleMuteCommand(const char* args) if (target) target->GetSession()->m_muteTime = mutetime; - LoginDatabase.PExecute("UPDATE account SET mutetime = " I64FMTD " WHERE id = '%u'",uint64(mutetime), account_id ); + LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'",uint64(mutetime), account_id ); if(target) ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime); @@ -3890,6 +3890,40 @@ bool ChatHandler::HandleCombatStopCommand(const char* args) return true; } +void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) +{ + uint32 classmask = player->getClassMask(); + + for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) + { + SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); + if (!skillLine) + continue; + + // wrong skill + if( skillLine->skillId != skill_id) + continue; + + // not high rank + if(skillLine->forward_spellid ) + continue; + + // skip racial skills + if (skillLine->racemask != 0) + continue; + + // skip wrong class skills + if( skillLine->classmask && (skillLine->classmask & classmask) == 0) + continue; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false)) + continue; + + player->learnSpell(skillLine->spellId,false); + } +} + bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/) { uint32 classmask = m_session->GetPlayer()->getClassMask(); @@ -3900,31 +3934,10 @@ bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/) if( !skillInfo ) continue; - if( skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY ) + if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && + skillInfo->canLink) // only prof. with recipes have { - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if( !skillLine ) - continue; - - // skip racial skills - if( skillLine->racemask != 0 ) - continue; - - // skip wrong class skills - if( skillLine->classmask && (skillLine->classmask & classmask) == 0) - continue; - - if( skillLine->skillId != i || skillLine->forward_spellid ) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - m_session->GetPlayer()->learnSpell(skillLine->spellId,false); - } + HandleLearnSkillRecipesHelper(m_session->GetPlayer(),skillInfo->id); } } @@ -3959,54 +3972,58 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args) uint32 classmask = m_session->GetPlayer()->getClassMask(); - for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) + std::string name; + + SkillLineEntry const *targetSkillInfo = NULL; + for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) { SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if( !skillInfo ) + if (!skillInfo) continue; - if( skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && - skillInfo->categoryId != SKILL_CATEGORY_SECONDARY ) + if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && + skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || + !skillInfo->canLink) // only prof with recipes have set continue; int loc = GetSessionDbcLocale(); - std::string name = skillInfo->name[loc]; + name = skillInfo->name[loc]; + if(name.empty()) + continue; - if(Utf8FitTo(name, wnamepart)) + if (!Utf8FitTo(name, wnamepart)) { - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) + loc = 0; + for(; loc < MAX_LOCALE; ++loc) { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if( !skillLine ) - continue; - - if( skillLine->skillId != i || skillLine->forward_spellid ) + if(loc==GetSessionDbcLocale()) continue; - // skip racial skills - if( skillLine->racemask != 0 ) + name = skillInfo->name[loc]; + if(name.empty()) continue; - // skip wrong class skills - if( skillLine->classmask && (skillLine->classmask & classmask) == 0) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - if( !target->HasSpell(spellInfo->Id) ) - m_session->GetPlayer()->learnSpell(skillLine->spellId,false); + if (Utf8FitTo(name, wnamepart)) + break; } + } - uint16 maxLevel = target->GetPureMaxSkillValue(skillInfo->id); - target->SetSkill(skillInfo->id, maxLevel, maxLevel); - PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); - return true; + if(loc < MAX_LOCALE) + { + targetSkillInfo = skillInfo; + break; } } - return false; + if(!targetSkillInfo) + return false; + + HandleLearnSkillRecipesHelper(target,targetSkillInfo->id); + + uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); + target->SetSkill(targetSkillInfo->id, maxLevel, maxLevel); + PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); + return true; } bool ChatHandler::HandleLookupPlayerIpCommand(const char* args) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 0b883b137de..d384efc1b07 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3779,7 +3779,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args) bool ChatHandler::HandleGuildCreateCommand(const char* args) { if(!*args) - return false; + return false; // if not guild name only (in "") then player name Player* target; @@ -3818,7 +3818,7 @@ bool ChatHandler::HandleGuildCreateCommand(const char* args) bool ChatHandler::HandleGuildInviteCommand(const char *args) { if(!*args) - return false; + return false; // if not guild name only (in "") then player name uint64 target_guid; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 337604f2a2a..0af4999092f 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -289,7 +289,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) } //called when mail is read -void WorldSession::HandleMarkAsRead(WorldPacket & recv_data ) +void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4); @@ -335,7 +335,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data ) pl->SendMailResult(mailId, MAIL_DELETED, MAIL_OK); } -void WorldSession::HandleReturnToSender(WorldPacket & recv_data ) +void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4); @@ -442,7 +442,7 @@ void WorldSession::SendReturnToSender(uint8 messageType, uint32 sender_acc, uint } //called when player takes item attached in mail -void WorldSession::HandleTakeItem(WorldPacket & recv_data ) +void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4+4); @@ -537,7 +537,7 @@ void WorldSession::HandleTakeItem(WorldPacket & recv_data ) pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg); } -void WorldSession::HandleTakeMoney(WorldPacket & recv_data ) +void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4); @@ -573,7 +573,7 @@ void WorldSession::HandleTakeMoney(WorldPacket & recv_data ) } //called when player lists his received mails -void WorldSession::HandleGetMail(WorldPacket & recv_data ) +void WorldSession::HandleGetMailList(WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8); @@ -761,7 +761,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) } //TODO Fix me! ... this void has probably bad condition, but good data are sent -void WorldSession::HandleMsgQueryNextMailtime(WorldPacket & /*recv_data*/ ) +void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ ) { WorldPacket data(MSG_QUERY_NEXT_MAIL_TIME, 8); @@ -891,7 +891,7 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station CharacterDatabase.BeginTransaction(); CharacterDatabase.escape_string(subject); CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%u', '%u', '" I64FMTD "','" I64FMTD "', '%u', '%u', '%d')", + "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%u', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%d')", mailId, messageType, stationery, mailTemplateId, sender_guidlow_or_entry, receiver_guidlow, subject.c_str(), itemTextId, (mi && !mi->empty() ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, money, COD, checked); if(mi) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 8efba9785c2..144dce1edf6 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -501,7 +501,7 @@ Map::Add(T *obj) if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { - sLog.outError("Map::Add: Object " I64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); + sLog.outError("Map::Add: Object " UI64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } @@ -2020,12 +2020,9 @@ void Map::SendInitSelf( Player * player ) UpdateData data; - bool hasTransport = false; - // attach to player data current transport data if(Transport* transport = player->GetTransport()) { - hasTransport = true; transport->BuildCreateUpdateBlockForPlayer(&data, player); } @@ -2039,14 +2036,13 @@ void Map::SendInitSelf( Player * player ) { if(player!=(*itr) && player->HaveAtClient(*itr)) { - hasTransport = true; (*itr)->BuildCreateUpdateBlockForPlayer(&data, player); } } } WorldPacket packet; - data.BuildPacket(&packet, hasTransport); + data.BuildPacket(&packet); player->GetSession()->SendPacket(&packet); } @@ -2063,20 +2059,17 @@ void Map::SendInitTransports( Player * player ) MapManager::TransportSet& tset = tmap[player->GetMapId()]; - bool hasTransport = false; - for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) { // send data for current transport in other place if((*i) != player->GetTransport() && (*i)->GetMapId()==i_id) { - hasTransport = true; (*i)->BuildCreateUpdateBlockForPlayer(&transData, player); } } WorldPacket packet; - transData.BuildPacket(&packet, hasTransport); + transData.BuildPacket(&packet); player->GetSession()->SendPacket(&packet); } diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 9ccae7798bd..c493d10de56 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -526,7 +526,7 @@ void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) _player->SetStandState(animstate); } -void WorldSession::HandleFriendListOpcode( WorldPacket & recv_data ) +void WorldSession::HandleContactListOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 4); sLog.outDebug( "WORLD: Received CMSG_CONTACT_LIST" ); @@ -715,9 +715,10 @@ void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); } -void WorldSession::HandleSetFriendNoteOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 8+1); + sLog.outDebug("CMSG_SET_CONTACT_NOTES"); uint64 guid; std::string note; recv_data >> guid >> note; @@ -753,7 +754,7 @@ void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) CharacterDatabase.PExecute ("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type.c_str( ), content.c_str( )); } -void WorldSession::HandleCorpseReclaimOpcode(WorldPacket &recv_data) +void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) { CHECK_PACKET_SIZE(recv_data,8); @@ -1071,7 +1072,7 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) } } -void WorldSession::HandleCompleteCinema( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleCompleteCinematic( WorldPacket & /*recv_data*/ ) { DEBUG_LOG( "WORLD: Player is watching cinema" ); } @@ -1131,8 +1132,8 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/) recv_data >> Orientation; // TODO for later may be we can use for anticheat - DEBUG_LOG("Guid " I64FMTD,guid); - DEBUG_LOG("unknown1 " I64FMTD,unknown1); + DEBUG_LOG("Guid " UI64FMTD,guid); + DEBUG_LOG("unknown1 " UI64FMTD,unknown1); DEBUG_LOG("unknown2 %u",unknown2); DEBUG_LOG("X %f",PositionX); DEBUG_LOG("Y %f",PositionY); @@ -1165,8 +1166,8 @@ void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/) recv_data >> Orientation; // for later may be we can use for anticheat - DEBUG_LOG("Guid " I64FMTD,guid); - DEBUG_LOG("unknown1 " I64FMTD,unknown1); + DEBUG_LOG("Guid " UI64FMTD,guid); + DEBUG_LOG("unknown1 " UI64FMTD,unknown1); DEBUG_LOG("unknown1 %u",unknown2); DEBUG_LOG("X %f",PositionX); DEBUG_LOG("Y %f",PositionY); @@ -1175,7 +1176,7 @@ void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/) */ } -void WorldSession::HandleSetActionBar(WorldPacket& recv_data) +void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data) { CHECK_PACKET_SIZE(recv_data,1); @@ -1186,7 +1187,7 @@ void WorldSession::HandleSetActionBar(WorldPacket& recv_data) if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED) { if(ActionBar!=0) - sLog.outError("WorldSession::HandleSetActionBar in not logged state with value: %u, ignored",uint32(ActionBar)); + sLog.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored",uint32(ActionBar)); return; } @@ -1221,7 +1222,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) uint64 guid; recv_data >> guid; - DEBUG_LOG("Inspected guid is " I64FMTD, guid); + DEBUG_LOG("Inspected guid is " UI64FMTD, guid); _player->SetSelection(guid); @@ -1426,10 +1427,10 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) sLog.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); } -void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data ) +void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 1+8); - sLog.outDebug("WORLD: CMSG_REPORT_SPAM"); + sLog.outDebug("WORLD: CMSG_COMPLAIN"); recv_data.hexlike(); uint8 spam_type; // 0 - mail, 1 - chat @@ -1470,7 +1471,7 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data ) sLog.outDebug("REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str()); } -void WorldSession::HandleRealmStateRequestOpcode( WorldPacket & recv_data ) +void WorldSession::HandleRealmSplitOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 4); @@ -1525,7 +1526,7 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) GetPlayer()->SetToNotify(); } -void WorldSession::HandleChooseTitleOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetTitleOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 4); @@ -1574,7 +1575,7 @@ void WorldSession::HandleResetInstancesOpcode( WorldPacket & /*recv_data*/ ) _player->ResetInstances(INSTANCE_RESET_ALL); } -void WorldSession::HandleDungeonDifficultyOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 4); @@ -1588,7 +1589,7 @@ void WorldSession::HandleDungeonDifficultyOpcode( WorldPacket & recv_data ) if(mode > DIFFICULTY_HEROIC) { - sLog.outError("WorldSession::HandleDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); + sLog.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); return; } @@ -1596,7 +1597,7 @@ void WorldSession::HandleDungeonDifficultyOpcode( WorldPacket & recv_data ) Map *map = _player->GetMap(); if(map && map->IsDungeon()) { - sLog.outError("WorldSession::HandleDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); + sLog.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); return; } @@ -1620,7 +1621,7 @@ void WorldSession::HandleDungeonDifficultyOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleDismountOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleCancelMountAuraOpcode( WorldPacket & /*recv_data*/ ) { sLog.outDebug("WORLD: CMSG_CANCEL_MOUNT_AURA"); //recv_data.hexlike(); @@ -1642,7 +1643,7 @@ void WorldSession::HandleDismountOpcode( WorldPacket & /*recv_data*/ ) _player->RemoveAurasByType(SPELL_AURA_MOUNTED); } -void WorldSession::HandleMoveFlyModeChangeAckOpcode( WorldPacket & recv_data ) +void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 8+4+4); @@ -1657,16 +1658,6 @@ void WorldSession::HandleMoveFlyModeChangeAckOpcode( WorldPacket & recv_data ) recv_data >> guid >> unk >> flags; _player->SetUnitMovementFlags(flags); - /* - on: - 25 00 00 00 00 00 00 00 | 00 00 00 00 00 00 80 00 - 85 4E A9 01 19 BA 7A C3 | 42 0D 70 44 44 B0 A8 42 - 78 15 94 40 39 03 00 00 | 00 00 80 3F - off: - 25 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 - 10 FD A9 01 19 BA 7A C3 | 42 0D 70 44 44 B0 A8 42 - 78 15 94 40 39 03 00 00 | 00 00 00 00 - */ } void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */) @@ -1687,7 +1678,7 @@ void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data ) sLog.outDebug("Client used \"/timetest %d\" command", mode); } -void WorldSession::HandleInspectAchievements( WorldPacket & recv_data ) +void WorldSession::HandleQueryInspectAchievements( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 1); uint64 guid; diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 53aa5923782..2fa6adf5a13 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -173,7 +173,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) recv_data >> guid; recv_data >> flags >> time; - DEBUG_LOG("Guid " I64FMTD,guid); + DEBUG_LOG("Guid " UI64FMTD,guid); DEBUG_LOG("Flags %u, time %u",flags, time/IN_MILISECONDS); Unit *mover = _player->m_mover; diff --git a/src/game/Object.cpp b/src/game/Object.cpp index a1f54398331..8dd558ca42c 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -62,7 +62,7 @@ uint32 GuidHigh2TypeId(uint32 guid_hi) case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT; case HIGHGUID_VEHICLE: return TYPEID_UNIT; } - return MAX_TYPEID; // unknown + return NUM_CLIENT_OBJECT_TYPES; // unknown } Object::Object( ) @@ -88,7 +88,7 @@ Object::~Object( ) if(IsInWorld()) { - sLog.outCrash("Object::~Object - guid="I64FMTD", typeid=%d deleted but still in world!!", GetGUID(), GetTypeId()); + sLog.outCrash("Object::~Object - guid="UI64FMTD", typeid=%d deleted but still in world!!", GetGUID(), GetTypeId()); assert(false); } @@ -120,7 +120,7 @@ void Object::_Create( uint32 guidlow, uint32 entry, HighGuid guidhigh ) { if(!m_uint32Values) _InitValues(); - uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh); // required more changes to make it working + uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh); SetUInt64Value( OBJECT_FIELD_GUID, guid ); SetUInt32Value( OBJECT_FIELD_TYPE, m_objectType ); m_PackGUID.clear(); @@ -129,10 +129,10 @@ void Object::_Create( uint32 guidlow, uint32 entry, HighGuid guidhigh ) void Object::BuildMovementUpdateBlock(UpdateData * data, uint32 flags ) const { - ByteBuffer buf(500); + ByteBuffer buf(50); buf << uint8( UPDATETYPE_MOVEMENT ); - buf << GetGUID(); + buf.append(GetPackGUID()); _BuildMovementUpdate(&buf, flags); @@ -142,15 +142,13 @@ void Object::BuildMovementUpdateBlock(UpdateData * data, uint32 flags ) const void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const { if(!target) - { return; - } uint8 updatetype = UPDATETYPE_CREATE_OBJECT; uint8 flags = m_updateFlag; /** lower flag1 **/ - if(target == this) // building packet for oneself + if(target == this) // building packet for yourself flags |= UPDATEFLAG_SELF; if(flags & UPDATEFLAG_HAS_POSITION) @@ -191,10 +189,9 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c //sLog.outDebug("BuildCreateUpdate: update-type: %u, object-type: %u got flags: %X, flags2: %X", updatetype, m_objectTypeId, flags, flags2); - ByteBuffer buf(500); + ByteBuffer buf(50); buf << (uint8)updatetype; - //buf.append(GetPackGUID()); //client crashes when using this - buf << (uint8)0xFF << GetGUID(); + buf.append(GetPackGUID()); buf << (uint8)m_objectTypeId; _BuildMovementUpdate(&buf, flags); @@ -202,7 +199,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c UpdateMask updateMask; updateMask.SetCount( m_valuesCount ); _SetCreateBits( &updateMask, target ); - _BuildValuesUpdate(updatetype, &buf, &updateMask, target ); + _BuildValuesUpdate(updatetype, &buf, &updateMask, target); data->AddUpdateBlock(buf); } @@ -224,24 +221,20 @@ void Object::SendUpdateToPlayer(Player* player) BuildCreateUpdateBlockForPlayer(&upd, player); upd.BuildPacket(&packet); player->GetSession()->SendPacket(&packet); - - // now object updated/(create updated) } void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const { - ByteBuffer buf(500); + ByteBuffer buf(50); buf << (uint8) UPDATETYPE_VALUES; - //buf.append(GetPackGUID()); //client crashes when using this. but not have crash in debug mode - buf << (uint8)0xFF; - buf << GetGUID(); + buf.append(GetPackGUID()); UpdateMask updateMask; updateMask.SetCount( m_valuesCount ); _SetUpdateBits( &updateMask, target ); - _BuildValuesUpdate(UPDATETYPE_VALUES, &buf, &updateMask, target ); + _BuildValuesUpdate(UPDATETYPE_VALUES, &buf, &updateMask, target); data->AddUpdateBlock(buf); } @@ -256,7 +249,7 @@ void Object::DestroyForPlayer(Player *target) const ASSERT(target); WorldPacket data(SMSG_DESTROY_OBJECT, 8); - data << GetGUID(); + data << uint64(GetGUID()); data << uint8(0); // WotLK (bool) target->GetSession()->SendPacket( &data ); } @@ -502,7 +495,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask updateMask->SetBit(GAMEOBJECT_BYTES_1); } } - else //case UPDATETYPE_VALUES + else // case UPDATETYPE_VALUES { if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport()) { @@ -659,7 +652,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *data << uint32(1); break; default: - *data << uint32(0); // unknown. not happen. + *data << uint32(0); // unknown, not happen. break; } } @@ -946,21 +939,21 @@ void Object::ApplyModUInt32Value(uint16 index, int32 val, bool apply) cur += (apply ? val : -val); if(cur < 0) cur = 0; - SetUInt32Value(index,cur); + SetUInt32Value(index, cur); } void Object::ApplyModInt32Value(uint16 index, int32 val, bool apply) { int32 cur = GetInt32Value(index); cur += (apply ? val : -val); - SetInt32Value(index,cur); + SetInt32Value(index, cur); } void Object::ApplyModSignedFloatValue(uint16 index, float val, bool apply) { float cur = GetFloatValue(index); cur += (apply ? val : -val); - SetFloatValue(index,cur); + SetFloatValue(index, cur); } void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply) @@ -969,7 +962,7 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply) cur += (apply ? val : -val); if(cur < 0) cur = 0; - SetFloatValue(index,cur); + SetFloatValue(index, cur); } void Object::SetFlag( uint16 index, uint32 newFlag ) @@ -1133,17 +1126,17 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint uint32 WorldObject::GetZoneId() const { - return MapManager::Instance().GetBaseMap(m_mapId)->GetZoneId(m_positionX,m_positionY,m_positionZ); + return MapManager::Instance().GetBaseMap(m_mapId)->GetZoneId(m_positionX, m_positionY, m_positionZ); } uint32 WorldObject::GetAreaId() const { - return MapManager::Instance().GetBaseMap(m_mapId)->GetAreaId(m_positionX,m_positionY,m_positionZ); + return MapManager::Instance().GetBaseMap(m_mapId)->GetAreaId(m_positionX, m_positionY, m_positionZ); } void WorldObject::GetZoneAndAreaId(uint32& zoneid, uint32& areaid) const { - MapManager::Instance().GetBaseMap(m_mapId)->GetZoneAndAreaId(zoneid,areaid,m_positionX,m_positionY,m_positionZ); + MapManager::Instance().GetBaseMap(m_mapId)->GetZoneAndAreaId(zoneid, areaid, m_positionX, m_positionY, m_positionZ); } InstanceData* WorldObject::GetInstanceData() @@ -1653,10 +1646,10 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const* *data << (uint8)msgtype; *data << (uint32)language; *data << (uint64)GetGUID(); - *data << (uint32)0; //2.1.0 + *data << (uint32)0; // 2.1.0 *data << (uint32)(strlen(name)+1); *data << name; - *data << (uint64)targetGuid; //Unit Target + *data << (uint64)targetGuid; // Unit Target if( targetGuid && !IS_PLAYER_GUID(targetGuid) ) { *data << (uint32)1; // target name length @@ -1679,7 +1672,7 @@ void WorldObject::BuildHeartBeatMsg(WorldPacket *data) const data->append(GetPackGUID()); *data << uint32(((Unit*)this)->GetUnitMovementFlags()); // movement flags *data << uint16(0); // 2.3.0 - *data << getMSTime(); // time + *data << uint32(getMSTime()); // time *data << m_positionX; *data << m_positionY; *data << m_positionZ; @@ -1699,7 +1692,7 @@ void WorldObject::BuildTeleportAckMsg(WorldPacket *data, float x, float y, float *data << uint32(0); // this value increments every time *data << uint32(((Unit*)this)->GetUnitMovementFlags()); // movement flags *data << uint16(0); // 2.3.0 - *data << getMSTime(); // time + *data << uint32(getMSTime()); // time *data << x; *data << y; *data << z; @@ -2277,7 +2270,7 @@ void WorldObject::PlayDistanceSound( uint32 sound_id, Player* target /*= NULL*/ { WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8); data << uint32(sound_id); - data << GetGUID(); + data << uint64(GetGUID()); if (target) target->SendDirectMessage( &data ); else diff --git a/src/game/Object.h b/src/game/Object.h index fa2a3a7eeb3..4970b4bab01 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -55,8 +55,6 @@ enum TypeMask TYPEMASK_GAMEOBJECT = 0x0020, TYPEMASK_DYNAMICOBJECT = 0x0040, TYPEMASK_CORPSE = 0x0080, - TYPEMASK_AIGROUP = 0x0100, - TYPEMASK_AREATRIGGER = 0x0200, TYPEMASK_SEER = TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT }; @@ -69,11 +67,10 @@ enum TypeID TYPEID_PLAYER = 4, TYPEID_GAMEOBJECT = 5, TYPEID_DYNAMICOBJECT = 6, - TYPEID_CORPSE = 7, - TYPEID_AIGROUP = 8, - TYPEID_AREATRIGGER = 9 + TYPEID_CORPSE = 7 }; -#define MAX_TYPEID 10 + +#define NUM_CLIENT_OBJECT_TYPES 8 uint32 GuidHigh2TypeId(uint32 guid_hi); diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 1e4074684f1..9736f9751eb 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -130,7 +130,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor, CellPair q = Trinity::ComputeCellPair(obj->GetPositionX(),obj->GetPositionY()); if(q.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || q.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { - sLog.outError("ObjectAccessor::GetObjecInWorld: object "I64FMTD" has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord); + sLog.outError("ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord); return NULL; } diff --git a/src/game/ObjectDefines.h b/src/game/ObjectDefines.h index ee58e8a5f34..028367a7bf8 100644 --- a/src/game/ObjectDefines.h +++ b/src/game/ObjectDefines.h @@ -25,8 +25,8 @@ // used for creating values for respawn for example #define MAKE_PAIR64(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) ) -#define PAIR64_HIPART(x) (uint32)((uint64(x) >> 32) & 0x00000000FFFFFFFFLL) -#define PAIR64_LOPART(x) (uint32)(uint64(x) & 0x00000000FFFFFFFFLL) +#define PAIR64_HIPART(x) (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000FFFFFFFF)) +#define PAIR64_LOPART(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF)) #define MAKE_PAIR32(l, h) uint32( uint16(l) | ( uint32(h) << 16 ) ) #define PAIR32_HIPART(x) (uint16)((uint32(x) >> 16) & 0x0000FFFF) @@ -72,9 +72,9 @@ enum HighGuid // We have different low and middle part size for different guid types #define _GUID_ENPART_2(x) 0 -#define _GUID_ENPART_3(x) (uint32)((uint64(x) >> 24) & 0x0000000000FFFFFFLL) -#define _GUID_LOPART_2(x) (uint32)(uint64(x) & 0x00000000FFFFFFFFLL) -#define _GUID_LOPART_3(x) (uint32)(uint64(x) & 0x0000000000FFFFFFLL) +#define _GUID_ENPART_3(x) (uint32)((uint64(x) >> 24) & UI64LIT(0x0000000000FFFFFF)) +#define _GUID_LOPART_2(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF)) +#define _GUID_LOPART_3(x) (uint32)(uint64(x) & UI64LIT(0x0000000000FFFFFF)) inline bool IsGuidHaveEnPart(uint64 const& guid) { diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 1b661bc41ba..27e1a175de2 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -802,6 +802,15 @@ void ObjectMgr::LoadCreatureAddons() if(!addon) continue; + if (addon->mount) + { + if (!sCreatureDisplayInfoStore.LookupEntry(addon->mount)) + sLog.outErrorDb("Creature (Entry %u) have invalid displayInfoId for mount (%u) defined in `creature_template_addon`.",addon->guidOrEntry, addon->mount); + } + + if (!sEmotesStore.LookupEntry(addon->emote)) + sLog.outErrorDb("Creature (Entry %u) have invalid emote (%u) defined in `creature_template_addon`.",addon->guidOrEntry, addon->emote); + ConvertCreatureAddonAuras(const_cast<CreatureDataAddon*>(addon), "creature_template_addon", "Entry"); if(!sCreatureStorage.LookupEntry<CreatureInfo>(addon->guidOrEntry)) @@ -820,6 +829,15 @@ void ObjectMgr::LoadCreatureAddons() if(!addon) continue; + if (addon->mount) + { + if (!sCreatureDisplayInfoStore.LookupEntry(addon->mount)) + sLog.outErrorDb("Creature (GUID %u) have invalid displayInfoId for mount (%u) defined in `creature_addon`.",addon->guidOrEntry, addon->mount); + } + + if (!sEmotesStore.LookupEntry(addon->emote)) + sLog.outErrorDb("Creature (GUID %u) have invalid emote (%u) defined in `creature_addon`.",addon->guidOrEntry, addon->emote); + ConvertCreatureAddonAuras(const_cast<CreatureDataAddon*>(addon), "creature_addon", "GUIDLow"); if(mCreatureDataMap.find(addon->guidOrEntry)==mCreatureDataMap.end()) @@ -4610,9 +4628,9 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) sLog.outDebug("Returning mails current time: hour: %d, minute: %d, second: %d ", localtime(&basetime)->tm_hour, localtime(&basetime)->tm_min, localtime(&basetime)->tm_sec); //delete all old mails without item and without body immediately, if starting server if (!serverUp) - CharacterDatabase.PExecute("DELETE FROM mail WHERE expire_time < '" I64FMTD "' AND has_items = '0' AND itemTextId = 0", (uint64)basetime); + CharacterDatabase.PExecute("DELETE FROM mail WHERE expire_time < '" UI64FMTD "' AND has_items = '0' AND itemTextId = 0", (uint64)basetime); // 0 1 2 3 4 5 6 7 8 9 - QueryResult* result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,itemTextId,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" I64FMTD "'", (uint64)basetime); + QueryResult* result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,itemTextId,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" UI64FMTD "'", (uint64)basetime); if ( !result ) { barGoLink bar(1); @@ -4687,7 +4705,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) else { //mail will be returned: - CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" I64FMTD "', deliver_time = '" I64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", m->receiver, m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); + CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" UI64FMTD "', deliver_time = '" UI64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", m->receiver, m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); delete m; continue; } @@ -6443,7 +6461,7 @@ void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t; WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance); if(t) - WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" I64FMTD "', '%u' )", loguid, uint64(t), instance); + WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance); } void ObjectMgr::DeleteCreatureData(uint32 guid) @@ -6461,7 +6479,7 @@ void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t) mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t; WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance); if(t) - WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ( '%u', '" I64FMTD "', '%u' )", loguid, uint64(t), instance); + WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance); } void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance) diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 536423345c6..8382b8ddbb4 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -118,7 +118,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x057*/ { "CMSG_ITEM_QUERY_MULTIPLE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x058*/ { "SMSG_ITEM_QUERY_SINGLE_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x059*/ { "SMSG_ITEM_QUERY_MULTIPLE_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x05A*/ { "CMSG_PAGE_TEXT_QUERY", STATUS_LOGGEDIN, &WorldSession::HandlePageQueryOpcode }, + /*0x05A*/ { "CMSG_PAGE_TEXT_QUERY", STATUS_LOGGEDIN, &WorldSession::HandlePageTextQueryOpcode }, /*0x05B*/ { "SMSG_PAGE_TEXT_QUERY_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x05C*/ { "CMSG_QUEST_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleQuestQueryOpcode }, /*0x05D*/ { "SMSG_QUEST_QUERY_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -130,28 +130,28 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x063*/ { "SMSG_WHO", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x064*/ { "CMSG_WHOIS", STATUS_LOGGEDIN, &WorldSession::HandleWhoisOpcode }, /*0x065*/ { "SMSG_WHOIS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x066*/ { "CMSG_CONTACT_LIST", STATUS_LOGGEDIN, &WorldSession::HandleFriendListOpcode }, + /*0x066*/ { "CMSG_CONTACT_LIST", STATUS_LOGGEDIN, &WorldSession::HandleContactListOpcode }, /*0x067*/ { "SMSG_CONTACT_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x068*/ { "SMSG_FRIEND_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x069*/ { "CMSG_ADD_FRIEND", STATUS_LOGGEDIN, &WorldSession::HandleAddFriendOpcode }, /*0x06A*/ { "CMSG_DEL_FRIEND", STATUS_LOGGEDIN, &WorldSession::HandleDelFriendOpcode }, - /*0x06B*/ { "CMSG_SET_CONTACT_NOTES", STATUS_LOGGEDIN, &WorldSession::HandleSetFriendNoteOpcode }, + /*0x06B*/ { "CMSG_SET_CONTACT_NOTES", STATUS_LOGGEDIN, &WorldSession::HandleSetContactNotesOpcode }, /*0x06C*/ { "CMSG_ADD_IGNORE", STATUS_LOGGEDIN, &WorldSession::HandleAddIgnoreOpcode }, /*0x06D*/ { "CMSG_DEL_IGNORE", STATUS_LOGGEDIN, &WorldSession::HandleDelIgnoreOpcode }, /*0x06E*/ { "CMSG_GROUP_INVITE", STATUS_LOGGEDIN, &WorldSession::HandleGroupInviteOpcode }, /*0x06F*/ { "SMSG_GROUP_INVITE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x070*/ { "CMSG_GROUP_CANCEL", STATUS_LOGGEDIN, &WorldSession::Handle_Deprecated }, + /*0x070*/ { "CMSG_GROUP_CANCEL", STATUS_LOGGEDIN, &WorldSession::Handle_NULL }, /*0x071*/ { "SMSG_GROUP_CANCEL", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x072*/ { "CMSG_GROUP_ACCEPT", STATUS_LOGGEDIN, &WorldSession::HandleGroupAcceptOpcode }, /*0x073*/ { "CMSG_GROUP_DECLINE", STATUS_LOGGEDIN, &WorldSession::HandleGroupDeclineOpcode }, /*0x074*/ { "SMSG_GROUP_DECLINE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x075*/ { "CMSG_GROUP_UNINVITE", STATUS_LOGGEDIN, &WorldSession::HandleGroupUninviteNameOpcode }, + /*0x075*/ { "CMSG_GROUP_UNINVITE", STATUS_LOGGEDIN, &WorldSession::HandleGroupUninviteOpcode }, /*0x076*/ { "CMSG_GROUP_UNINVITE_GUID", STATUS_LOGGEDIN, &WorldSession::HandleGroupUninviteGuidOpcode }, /*0x077*/ { "SMSG_GROUP_UNINVITE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x078*/ { "CMSG_GROUP_SET_LEADER", STATUS_LOGGEDIN, &WorldSession::HandleGroupSetLeaderOpcode }, /*0x079*/ { "SMSG_GROUP_SET_LEADER", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x07A*/ { "CMSG_LOOT_METHOD", STATUS_LOGGEDIN, &WorldSession::HandleLootMethodOpcode }, - /*0x07B*/ { "CMSG_GROUP_DISBAND", STATUS_LOGGEDIN, &WorldSession::HandleGroupLeaveOpcode }, + /*0x07B*/ { "CMSG_GROUP_DISBAND", STATUS_LOGGEDIN, &WorldSession::HandleGroupDisbandOpcode }, /*0x07C*/ { "SMSG_GROUP_DESTROYED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x07D*/ { "SMSG_GROUP_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x07E*/ { "SMSG_PARTY_MEMBER_STATS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -179,8 +179,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x094*/ { "UMSG_UPDATE_GUILD", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x095*/ { "CMSG_MESSAGECHAT", STATUS_LOGGEDIN, &WorldSession::HandleMessagechatOpcode }, /*0x096*/ { "SMSG_MESSAGECHAT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x097*/ { "CMSG_JOIN_CHANNEL", STATUS_LOGGEDIN, &WorldSession::HandleChannelJoin }, - /*0x098*/ { "CMSG_LEAVE_CHANNEL", STATUS_LOGGEDIN, &WorldSession::HandleChannelLeave }, + /*0x097*/ { "CMSG_JOIN_CHANNEL", STATUS_LOGGEDIN, &WorldSession::HandleJoinChannel }, + /*0x098*/ { "CMSG_LEAVE_CHANNEL", STATUS_LOGGEDIN, &WorldSession::HandleLeaveChannel }, /*0x099*/ { "SMSG_CHANNEL_NOTIFY", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x09A*/ { "CMSG_CHANNEL_LIST", STATUS_LOGGEDIN, &WorldSession::HandleChannelList }, /*0x09B*/ { "SMSG_CHANNEL_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -195,7 +195,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x0A4*/ { "CMSG_CHANNEL_KICK", STATUS_LOGGEDIN, &WorldSession::HandleChannelKick }, /*0x0A5*/ { "CMSG_CHANNEL_BAN", STATUS_LOGGEDIN, &WorldSession::HandleChannelBan }, /*0x0A6*/ { "CMSG_CHANNEL_UNBAN", STATUS_LOGGEDIN, &WorldSession::HandleChannelUnban }, - /*0x0A7*/ { "CMSG_CHANNEL_ANNOUNCEMENTS", STATUS_LOGGEDIN, &WorldSession::HandleChannelAnnounce }, + /*0x0A7*/ { "CMSG_CHANNEL_ANNOUNCEMENTS", STATUS_LOGGEDIN, &WorldSession::HandleChannelAnnouncements }, /*0x0A8*/ { "CMSG_CHANNEL_MODERATE", STATUS_LOGGEDIN, &WorldSession::HandleChannelModerate }, /*0x0A9*/ { "SMSG_UPDATE_OBJECT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x0AA*/ { "SMSG_DESTROY_OBJECT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -248,7 +248,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x0D9*/ { "MSG_MOVE_TOGGLE_COLLISION_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x0DA*/ { "MSG_MOVE_SET_FACING", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, /*0x0DB*/ { "MSG_MOVE_SET_PITCH", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, - /*0x0DC*/ { "MSG_MOVE_WORLDPORT_ACK", STATUS_TRANSFER_PENDING,&WorldSession::HandleMoveWorldportAckOpcode}, + /*0x0DC*/ { "MSG_MOVE_WORLDPORT_ACK", STATUS_TRANSFER, &WorldSession::HandleMoveWorldportAckOpcode }, /*0x0DD*/ { "SMSG_MONSTER_MOVE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x0DE*/ { "SMSG_MOVE_WATER_WALK", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x0DF*/ { "SMSG_MOVE_LAND_WALK", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -280,7 +280,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x0F9*/ { "CMSG_OPENING_CINEMATIC", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x0FA*/ { "SMSG_TRIGGER_CINEMATIC", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x0FB*/ { "CMSG_NEXT_CINEMATIC_CAMERA", STATUS_LOGGEDIN, &WorldSession::HandleNextCinematicCamera }, - /*0x0FC*/ { "CMSG_COMPLETE_CINEMATIC", STATUS_LOGGEDIN, &WorldSession::HandleCompleteCinema }, + /*0x0FC*/ { "CMSG_COMPLETE_CINEMATIC", STATUS_LOGGEDIN, &WorldSession::HandleCompleteCinematic }, /*0x0FD*/ { "SMSG_TUTORIAL_FLAGS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x0FE*/ { "CMSG_TUTORIAL_FLAG", STATUS_LOGGEDIN, &WorldSession::HandleTutorialFlag }, /*0x0FF*/ { "CMSG_TUTORIAL_CLEAR", STATUS_LOGGEDIN, &WorldSession::HandleTutorialClear }, @@ -418,11 +418,11 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x183*/ { "SMSG_QUESTGIVER_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x184*/ { "CMSG_QUESTGIVER_HELLO", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverHelloOpcode }, /*0x185*/ { "SMSG_QUESTGIVER_QUEST_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x186*/ { "CMSG_QUESTGIVER_QUERY_QUEST", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverQuestQueryOpcode}, - /*0x187*/ { "CMSG_QUESTGIVER_QUEST_AUTOLAUNCH", STATUS_LOGGEDIN, &WorldSession::HandleQuestAutoLaunch }, + /*0x186*/ { "CMSG_QUESTGIVER_QUERY_QUEST", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverQueryQuestOpcode}, + /*0x187*/ { "CMSG_QUESTGIVER_QUEST_AUTOLAUNCH", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverQuestAutoLaunch }, /*0x188*/ { "SMSG_QUESTGIVER_QUEST_DETAILS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x189*/ { "CMSG_QUESTGIVER_ACCEPT_QUEST", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverAcceptQuestOpcode}, - /*0x18A*/ { "CMSG_QUESTGIVER_COMPLETE_QUEST", STATUS_LOGGEDIN, &WorldSession::HandleQuestComplete }, + /*0x18A*/ { "CMSG_QUESTGIVER_COMPLETE_QUEST", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverCompleteQuest }, /*0x18B*/ { "SMSG_QUESTGIVER_REQUEST_ITEMS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x18C*/ { "CMSG_QUESTGIVER_REQUEST_REWARD", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverRequestRewardOpcode}, /*0x18D*/ { "SMSG_QUESTGIVER_OFFER_REWARD", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -441,7 +441,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x19A*/ { "SMSG_QUESTUPDATE_ADD_ITEM", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x19B*/ { "CMSG_QUEST_CONFIRM_ACCEPT", STATUS_LOGGEDIN, &WorldSession::HandleQuestConfirmAccept }, /*0x19C*/ { "SMSG_QUEST_CONFIRM_ACCEPT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x19D*/ { "CMSG_PUSHQUESTTOPARTY", STATUS_LOGGEDIN, &WorldSession::HandleQuestPushToParty }, + /*0x19D*/ { "CMSG_PUSHQUESTTOPARTY", STATUS_LOGGEDIN, &WorldSession::HandlePushQuestToParty }, /*0x19E*/ { "CMSG_LIST_INVENTORY", STATUS_LOGGEDIN, &WorldSession::HandleListInventoryOpcode }, /*0x19F*/ { "SMSG_LIST_INVENTORY", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x1A0*/ { "CMSG_SELL_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleSellItemOpcode }, @@ -494,7 +494,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x1CF*/ { "SMSG_QUERY_TIME_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x1D0*/ { "SMSG_LOG_XPGAIN", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x1D1*/ { "SMSG_AURACASTLOG", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x1D2*/ { "CMSG_RECLAIM_CORPSE", STATUS_LOGGEDIN, &WorldSession::HandleCorpseReclaimOpcode }, + /*0x1D2*/ { "CMSG_RECLAIM_CORPSE", STATUS_LOGGEDIN, &WorldSession::HandleReclaimCorpseOpcode }, /*0x1D3*/ { "CMSG_WRAP_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleWrapItemOpcode }, /*0x1D4*/ { "SMSG_LEVELUP_INFO", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x1D5*/ { "MSG_MINIMAP_PING", STATUS_LOGGEDIN, &WorldSession::HandleMinimapPingOpcode }, @@ -525,7 +525,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x1EE*/ { "SMSG_AUTH_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x1EF*/ { "MSG_GM_SHOWLABEL", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x1F0*/ { "CMSG_PET_CAST_SPELL", STATUS_LOGGEDIN, &WorldSession::HandlePetCastSpellOpcode }, - /*0x1F1*/ { "MSG_SAVE_GUILD_EMBLEM", STATUS_LOGGEDIN, &WorldSession::HandleGuildSaveEmblemOpcode }, + /*0x1F1*/ { "MSG_SAVE_GUILD_EMBLEM", STATUS_LOGGEDIN, &WorldSession::HandleSaveGuildEmblemOpcode }, /*0x1F2*/ { "MSG_TABARDVENDOR_ACTIVATE", STATUS_LOGGEDIN, &WorldSession::HandleTabardVendorActivateOpcode}, /*0x1F3*/ { "SMSG_PLAY_SPELL_VISUAL", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x1F4*/ { "CMSG_ZONEUPDATE", STATUS_LOGGEDIN, &WorldSession::HandleZoneUpdateOpcode }, @@ -598,9 +598,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x237*/ { "CMSG_CLEAR_EXPLORATION", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x238*/ { "CMSG_SEND_MAIL", STATUS_LOGGEDIN, &WorldSession::HandleSendMail }, /*0x239*/ { "SMSG_SEND_MAIL_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x23A*/ { "CMSG_GET_MAIL_LIST", STATUS_LOGGEDIN, &WorldSession::HandleGetMail }, + /*0x23A*/ { "CMSG_GET_MAIL_LIST", STATUS_LOGGEDIN, &WorldSession::HandleGetMailList }, /*0x23B*/ { "SMSG_MAIL_LIST_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x23C*/ { "CMSG_BATTLEFIELD_LIST", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundListOpcode }, + /*0x23C*/ { "CMSG_BATTLEFIELD_LIST", STATUS_LOGGEDIN, &WorldSession::HandleBattlefieldListOpcode }, /*0x23D*/ { "SMSG_BATTLEFIELD_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x23E*/ { "CMSG_BATTLEFIELD_JOIN", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x23F*/ { "SMSG_BATTLEFIELD_WIN_OBSOLETE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -609,10 +609,10 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x242*/ { "CMSG_TAXIENABLENODE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x243*/ { "CMSG_ITEM_TEXT_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleItemTextQuery }, /*0x244*/ { "SMSG_ITEM_TEXT_QUERY_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x245*/ { "CMSG_MAIL_TAKE_MONEY", STATUS_LOGGEDIN, &WorldSession::HandleTakeMoney }, - /*0x246*/ { "CMSG_MAIL_TAKE_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleTakeItem }, - /*0x247*/ { "CMSG_MAIL_MARK_AS_READ", STATUS_LOGGEDIN, &WorldSession::HandleMarkAsRead }, - /*0x248*/ { "CMSG_MAIL_RETURN_TO_SENDER", STATUS_LOGGEDIN, &WorldSession::HandleReturnToSender }, + /*0x245*/ { "CMSG_MAIL_TAKE_MONEY", STATUS_LOGGEDIN, &WorldSession::HandleMailTakeMoney }, + /*0x246*/ { "CMSG_MAIL_TAKE_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleMailTakeItem }, + /*0x247*/ { "CMSG_MAIL_MARK_AS_READ", STATUS_LOGGEDIN, &WorldSession::HandleMailMarkAsRead }, + /*0x248*/ { "CMSG_MAIL_RETURN_TO_SENDER", STATUS_LOGGEDIN, &WorldSession::HandleMailReturnToSender }, /*0x249*/ { "CMSG_MAIL_DELETE", STATUS_LOGGEDIN, &WorldSession::HandleMailDelete }, /*0x24A*/ { "CMSG_MAIL_CREATE_TEXT_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleMailCreateTextItem }, /*0x24B*/ { "SMSG_SPELLLOGMISS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -672,7 +672,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x281*/ { "CMSG_RESET_FACTION_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x282*/ { "CMSG_AUTOSTORE_BANK_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleAutoStoreBankItemOpcode }, /*0x283*/ { "CMSG_AUTOBANK_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleAutoBankItemOpcode }, - /*0x284*/ { "MSG_QUERY_NEXT_MAIL_TIME", STATUS_LOGGEDIN, &WorldSession::HandleMsgQueryNextMailtime }, + /*0x284*/ { "MSG_QUERY_NEXT_MAIL_TIME", STATUS_LOGGEDIN, &WorldSession::HandleQueryNextMailTime }, /*0x285*/ { "SMSG_RECEIVED_MAIL", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x286*/ { "SMSG_RAID_GROUP_ONLY", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x287*/ { "CMSG_SET_DURABILITY_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -682,8 +682,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x28B*/ { "CMSG_SET_PVP_TITLE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x28C*/ { "SMSG_PVP_CREDIT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x28D*/ { "SMSG_AUCTION_REMOVED_NOTIFICATION", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x28E*/ { "CMSG_GROUP_RAID_CONVERT", STATUS_LOGGEDIN, &WorldSession::HandleRaidConvertOpcode }, - /*0x28F*/ { "CMSG_GROUP_ASSISTANT_LEADER", STATUS_LOGGEDIN, &WorldSession::HandleGroupAssistantOpcode }, + /*0x28E*/ { "CMSG_GROUP_RAID_CONVERT", STATUS_LOGGEDIN, &WorldSession::HandleGroupRaidConvertOpcode }, + /*0x28F*/ { "CMSG_GROUP_ASSISTANT_LEADER", STATUS_LOGGEDIN, &WorldSession::HandleGroupAssistantLeaderOpcode}, /*0x290*/ { "CMSG_BUYBACK_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleBuybackItem }, /*0x291*/ { "SMSG_SERVER_MESSAGE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x292*/ { "CMSG_MEETINGSTONE_JOIN", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -710,7 +710,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2A7*/ { "SMSG_GAMEOBJECT_RESET_STATE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2A8*/ { "CMSG_REPAIR_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleRepairItemOpcode }, /*0x2A9*/ { "SMSG_CHAT_PLAYER_NOT_FOUND", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2AA*/ { "MSG_TALENT_WIPE_CONFIRM", STATUS_LOGGEDIN, &WorldSession::HandleTalentWipeOpcode }, + /*0x2AA*/ { "MSG_TALENT_WIPE_CONFIRM", STATUS_LOGGEDIN, &WorldSession::HandleTalentWipeConfirmOpcode }, /*0x2AB*/ { "SMSG_SUMMON_REQUEST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2AC*/ { "CMSG_SUMMON_RESPONSE", STATUS_LOGGEDIN, &WorldSession::HandleSummonResponseOpcode }, /*0x2AD*/ { "MSG_MOVE_TOGGLE_GRAVITY_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -725,13 +725,13 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2B6*/ { "SMSG_SCRIPT_MESSAGE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2B7*/ { "SMSG_DUEL_COUNTDOWN", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2B8*/ { "SMSG_AREA_TRIGGER_MESSAGE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2B9*/ { "CMSG_SHOWING_HELM", STATUS_LOGGEDIN, &WorldSession::HandleToggleHelmOpcode }, - /*0x2BA*/ { "CMSG_SHOWING_CLOAK", STATUS_LOGGEDIN, &WorldSession::HandleToggleCloakOpcode }, + /*0x2B9*/ { "CMSG_SHOWING_HELM", STATUS_LOGGEDIN, &WorldSession::HandleShowingHelmOpcode }, + /*0x2BA*/ { "CMSG_SHOWING_CLOAK", STATUS_LOGGEDIN, &WorldSession::HandleShowingCloakOpcode }, /*0x2BB*/ { "SMSG_MEETINGSTONE_JOINFAILED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2BC*/ { "SMSG_PLAYER_SKINNED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2BD*/ { "SMSG_DURABILITY_DAMAGE_DEATH", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2BE*/ { "CMSG_SET_EXPLORATION", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x2BF*/ { "CMSG_SET_ACTIONBAR_TOGGLES", STATUS_AUTHED, &WorldSession::HandleSetActionBar }, + /*0x2BF*/ { "CMSG_SET_ACTIONBAR_TOGGLES", STATUS_AUTHED, &WorldSession::HandleSetActionBarToggles }, /*0x2C0*/ { "UMSG_DELETE_GUILD_CHARTER", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x2C1*/ { "MSG_PETITION_RENAME", STATUS_LOGGEDIN, &WorldSession::HandlePetitionRenameOpcode }, /*0x2C2*/ { "SMSG_INIT_WORLD_STATES", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -739,9 +739,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2C4*/ { "CMSG_ITEM_NAME_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleItemNameQueryOpcode }, /*0x2C5*/ { "SMSG_ITEM_NAME_QUERY_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2C6*/ { "SMSG_PET_ACTION_FEEDBACK", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2C7*/ { "CMSG_CHAR_RENAME", STATUS_AUTHED, &WorldSession::HandleChangePlayerNameOpcode }, + /*0x2C7*/ { "CMSG_CHAR_RENAME", STATUS_AUTHED, &WorldSession::HandleCharRenameOpcode }, /*0x2C8*/ { "SMSG_CHAR_RENAME", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2C9*/ { "CMSG_MOVE_SPLINE_DONE", STATUS_LOGGEDIN, &WorldSession::HandleTaxiNextDestinationOpcode }, + /*0x2C9*/ { "CMSG_MOVE_SPLINE_DONE", STATUS_LOGGEDIN, &WorldSession::HandleMoveSplineDoneOpcode }, /*0x2CA*/ { "CMSG_MOVE_FALL_RESET", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, /*0x2CB*/ { "SMSG_INSTANCE_SAVE_CREATED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2CC*/ { "SMSG_RAID_INSTANCE_INFO", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -753,9 +753,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2D2*/ { "SMSG_PLAY_SOUND", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2D3*/ { "CMSG_BATTLEFIELD_STATUS", STATUS_LOGGEDIN, &WorldSession::HandleBattlefieldStatusOpcode }, /*0x2D4*/ { "SMSG_BATTLEFIELD_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2D5*/ { "CMSG_BATTLEFIELD_PORT", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundPlayerPortOpcode}, + /*0x2D5*/ { "CMSG_BATTLEFIELD_PORT", STATUS_LOGGEDIN, &WorldSession::HandleBattleFieldPortOpcode }, /*0x2D6*/ { "MSG_INSPECT_HONOR_STATS", STATUS_LOGGEDIN, &WorldSession::HandleInspectHonorStatsOpcode }, - /*0x2D7*/ { "CMSG_BATTLEMASTER_HELLO", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundHelloOpcode }, + /*0x2D7*/ { "CMSG_BATTLEMASTER_HELLO", STATUS_LOGGEDIN, &WorldSession::HandleBattlemasterHelloOpcode }, /*0x2D8*/ { "CMSG_MOVE_START_SWIM_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x2D9*/ { "CMSG_MOVE_STOP_SWIM_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x2DA*/ { "SMSG_FORCE_WALK_SPEED_CHANGE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -764,8 +764,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2DD*/ { "CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK", STATUS_LOGGEDIN, &WorldSession::HandleForceSpeedChangeAck }, /*0x2DE*/ { "SMSG_FORCE_TURN_RATE_CHANGE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2DF*/ { "CMSG_FORCE_TURN_RATE_CHANGE_ACK", STATUS_LOGGEDIN, &WorldSession::HandleForceSpeedChangeAck }, - /*0x2E0*/ { "MSG_PVP_LOG_DATA", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundPVPlogdataOpcode}, - /*0x2E1*/ { "CMSG_LEAVE_BATTLEFIELD", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundLeaveOpcode }, + /*0x2E0*/ { "MSG_PVP_LOG_DATA", STATUS_LOGGEDIN, &WorldSession::HandlePVPLogDataOpcode }, + /*0x2E1*/ { "CMSG_LEAVE_BATTLEFIELD", STATUS_LOGGEDIN, &WorldSession::HandleLeaveBattlefieldOpcode }, /*0x2E2*/ { "CMSG_AREA_SPIRIT_HEALER_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleAreaSpiritHealerQueryOpcode}, /*0x2E3*/ { "CMSG_AREA_SPIRIT_HEALER_QUEUE", STATUS_LOGGEDIN, &WorldSession::HandleAreaSpiritHealerQueueOpcode}, /*0x2E4*/ { "SMSG_AREA_SPIRIT_HEALER_TIME", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -778,7 +778,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2EB*/ { "SMSG_BINDER_CONFIRM", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2EC*/ { "SMSG_BATTLEGROUND_PLAYER_JOINED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2ED*/ { "SMSG_BATTLEGROUND_PLAYER_LEFT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2EE*/ { "CMSG_BATTLEMASTER_JOIN", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundJoinOpcode }, + /*0x2EE*/ { "CMSG_BATTLEMASTER_JOIN", STATUS_LOGGEDIN, &WorldSession::HandleBattlemasterJoinOpcode }, /*0x2EF*/ { "SMSG_ADDON_INFO", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2F0*/ { "CMSG_PET_UNLEARN", STATUS_LOGGEDIN, &WorldSession::HandlePetUnlearnOpcode }, /*0x2F1*/ { "SMSG_PET_UNLEARN_CONFIRM", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -792,7 +792,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2F9*/ { "SMSG_MINIGAME_MOVE_FAILED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2FA*/ { "SMSG_RAID_INSTANCE_MESSAGE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2FB*/ { "SMSG_COMPRESSED_MOVES", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x2FC*/ { "CMSG_GUILD_INFO_TEXT", STATUS_LOGGEDIN, &WorldSession::HandleGuildChangeInfoOpcode }, + /*0x2FC*/ { "CMSG_GUILD_INFO_TEXT", STATUS_LOGGEDIN, &WorldSession::HandleGuildChangeInfoTextOpcode }, /*0x2FD*/ { "SMSG_CHAT_RESTRICTED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2FE*/ { "SMSG_SPLINE_SET_RUN_SPEED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x2FF*/ { "SMSG_SPLINE_SET_RUN_BACK_SPEED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -814,13 +814,13 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x30F*/ { "CMSG_GM_NUKE_ACCOUNT", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x310*/ { "MSG_GM_DESTROY_CORPSE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x311*/ { "CMSG_GM_DESTROY_ONLINE_CORPSE", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x312*/ { "CMSG_ACTIVATETAXIEXPRESS", STATUS_LOGGEDIN, &WorldSession::HandleActivateTaxiFarOpcode }, + /*0x312*/ { "CMSG_ACTIVATETAXIEXPRESS", STATUS_LOGGEDIN, &WorldSession::HandleActivateTaxiExpressOpcode }, /*0x313*/ { "SMSG_SET_FACTION_ATWAR", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x314*/ { "SMSG_GAMETIMEBIAS_SET", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x315*/ { "CMSG_DEBUG_ACTIONS_START", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x316*/ { "CMSG_DEBUG_ACTIONS_STOP", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x317*/ { "CMSG_SET_FACTION_INACTIVE", STATUS_LOGGEDIN, &WorldSession::HandleSetWatchedFactionInactiveOpcode}, - /*0x318*/ { "CMSG_SET_WATCHED_FACTION", STATUS_LOGGEDIN, &WorldSession::HandleSetWatchedFactionIndexOpcode}, + /*0x317*/ { "CMSG_SET_FACTION_INACTIVE", STATUS_LOGGEDIN, &WorldSession::HandleSetFactionInactiveOpcode }, + /*0x318*/ { "CMSG_SET_WATCHED_FACTION", STATUS_LOGGEDIN, &WorldSession::HandleSetWatchedFactionOpcode }, /*0x319*/ { "MSG_MOVE_TIME_SKIPPED", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x31A*/ { "SMSG_SPLINE_MOVE_ROOT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x31B*/ { "CMSG_SET_EXPLORATION_ALL", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -829,7 +829,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x31E*/ { "SMSG_INSTANCE_RESET", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x31F*/ { "SMSG_INSTANCE_RESET_FAILED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x320*/ { "SMSG_UPDATE_LAST_INSTANCE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x321*/ { "MSG_RAID_TARGET_UPDATE", STATUS_LOGGEDIN, &WorldSession::HandleRaidIconTargetOpcode }, + /*0x321*/ { "MSG_RAID_TARGET_UPDATE", STATUS_LOGGEDIN, &WorldSession::HandleRaidTargetUpdateOpcode }, /*0x322*/ { "MSG_RAID_READY_CHECK", STATUS_LOGGEDIN, &WorldSession::HandleRaidReadyCheckOpcode }, /*0x323*/ { "CMSG_LUA_USAGE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x324*/ { "SMSG_PET_ACTION_SOUND", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -837,7 +837,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x326*/ { "SMSG_GHOSTEE_GONE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x327*/ { "CMSG_GM_UPDATE_TICKET_STATUS", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x328*/ { "SMSG_GM_TICKET_STATUS_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x329*/ { "MSG_SET_DUNGEON_DIFFICULTY", STATUS_LOGGEDIN, &WorldSession::HandleDungeonDifficultyOpcode }, + /*0x329*/ { "MSG_SET_DUNGEON_DIFFICULTY", STATUS_LOGGEDIN, &WorldSession::HandleSetDungeonDifficultyOpcode}, /*0x32A*/ { "CMSG_GMSURVEY_SUBMIT", STATUS_NEVER, &WorldSession::Handle_NULL },//LOGGEDIN, &WorldSession::HandleGMSurveySubmit }, /*0x32B*/ { "SMSG_UPDATE_INSTANCE_OWNERSHIP", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x32C*/ { "CMSG_IGNORE_KNOCKBACK_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -865,7 +865,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x342*/ { "MSG_MOVE_STOP_SWIM_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x343*/ { "SMSG_MOVE_SET_CAN_FLY", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x344*/ { "SMSG_MOVE_UNSET_CAN_FLY", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x345*/ { "CMSG_MOVE_SET_CAN_FLY_ACK", STATUS_LOGGEDIN, &WorldSession::HandleMoveFlyModeChangeAckOpcode}, + /*0x345*/ { "CMSG_MOVE_SET_CAN_FLY_ACK", STATUS_LOGGEDIN, &WorldSession::HandleMoveSetCanFlyAckOpcode }, /*0x346*/ { "CMSG_MOVE_SET_FLY", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, /*0x347*/ { "CMSG_SOCKET_GEMS", STATUS_LOGGEDIN, &WorldSession::HandleSocketOpcode }, /*0x348*/ { "CMSG_ARENA_TEAM_CREATE", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -875,30 +875,30 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x34C*/ { "SMSG_ARENA_TEAM_QUERY_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x34D*/ { "CMSG_ARENA_TEAM_ROSTER", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamRosterOpcode }, /*0x34E*/ { "SMSG_ARENA_TEAM_ROSTER", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x34F*/ { "CMSG_ARENA_TEAM_INVITE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamAddMemberOpcode }, + /*0x34F*/ { "CMSG_ARENA_TEAM_INVITE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamInviteOpcode }, /*0x350*/ { "SMSG_ARENA_TEAM_INVITE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x351*/ { "CMSG_ARENA_TEAM_ACCEPT", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamInviteAcceptOpcode}, - /*0x352*/ { "CMSG_ARENA_TEAM_DECLINE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamInviteDeclineOpcode}, + /*0x351*/ { "CMSG_ARENA_TEAM_ACCEPT", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamAcceptOpcode }, + /*0x352*/ { "CMSG_ARENA_TEAM_DECLINE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamDeclineOpcode }, /*0x353*/ { "CMSG_ARENA_TEAM_LEAVE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamLeaveOpcode }, - /*0x354*/ { "CMSG_ARENA_TEAM_REMOVE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamRemoveFromTeamOpcode}, + /*0x354*/ { "CMSG_ARENA_TEAM_REMOVE", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamRemoveOpcode }, /*0x355*/ { "CMSG_ARENA_TEAM_DISBAND", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamDisbandOpcode }, - /*0x356*/ { "CMSG_ARENA_TEAM_LEADER", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamPromoteToCaptainOpcode}, + /*0x356*/ { "CMSG_ARENA_TEAM_LEADER", STATUS_LOGGEDIN, &WorldSession::HandleArenaTeamLeaderOpcode }, /*0x357*/ { "SMSG_ARENA_TEAM_EVENT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x358*/ { "CMSG_BATTLEMASTER_JOIN_ARENA", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundArenaJoin }, + /*0x358*/ { "CMSG_BATTLEMASTER_JOIN_ARENA", STATUS_LOGGEDIN, &WorldSession::HandleBattlemasterJoinArena }, /*0x359*/ { "MSG_MOVE_START_ASCEND", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, /*0x35A*/ { "MSG_MOVE_STOP_ASCEND", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, /*0x35B*/ { "SMSG_ARENA_TEAM_STATS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x35C*/ { "CMSG_LFG_SET_AUTOJOIN", STATUS_AUTHED, &WorldSession::HandleLfgAutoJoinOpcode }, - /*0x35D*/ { "CMSG_LFG_CLEAR_AUTOJOIN", STATUS_LOGGEDIN, &WorldSession::HandleLfgCancelAutoJoinOpcode }, - /*0x35E*/ { "CMSG_LFM_SET_AUTOFILL", STATUS_AUTHED, &WorldSession::HandleLfmAutoAddMembersOpcode }, - /*0x35F*/ { "CMSG_LFM_CLEAR_AUTOFILL", STATUS_LOGGEDIN, &WorldSession::HandleLfmCancelAutoAddmembersOpcode}, + /*0x35C*/ { "CMSG_LFG_SET_AUTOJOIN", STATUS_AUTHED, &WorldSession::HandleLfgSetAutoJoinOpcode }, + /*0x35D*/ { "CMSG_LFG_CLEAR_AUTOJOIN", STATUS_LOGGEDIN, &WorldSession::HandleLfgClearAutoJoinOpcode }, + /*0x35E*/ { "CMSG_LFM_SET_AUTOFILL", STATUS_AUTHED, &WorldSession::HandleLfmSetAutoFillOpcode }, + /*0x35F*/ { "CMSG_LFM_CLEAR_AUTOFILL", STATUS_LOGGEDIN, &WorldSession::HandleLfmClearAutoFillOpcode }, /*0x360*/ { "CMSG_ACCEPT_LFG_MATCH", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x361*/ { "CMSG_DECLINE_LFG_MATCH", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x362*/ { "CMSG_CANCEL_PENDING_LFG", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x363*/ { "CMSG_CLEAR_LOOKING_FOR_GROUP", STATUS_LOGGEDIN, &WorldSession::HandleLfgClearOpcode }, - /*0x364*/ { "CMSG_CLEAR_LOOKING_FOR_MORE", STATUS_LOGGEDIN, &WorldSession::HandleLfmSetNoneOpcode }, - /*0x365*/ { "CMSG_SET_LOOKING_FOR_MORE", STATUS_LOGGEDIN, &WorldSession::HandleLfmSetOpcode }, - /*0x366*/ { "CMSG_SET_LFG_COMMENT", STATUS_LOGGEDIN, &WorldSession::HandleLfgSetCommentOpcode }, + /*0x364*/ { "CMSG_CLEAR_LOOKING_FOR_MORE", STATUS_LOGGEDIN, &WorldSession::HandleLfmClearOpcode }, + /*0x365*/ { "CMSG_SET_LOOKING_FOR_MORE", STATUS_LOGGEDIN, &WorldSession::HandleSetLfmOpcode }, + /*0x366*/ { "CMSG_SET_LFG_COMMENT", STATUS_LOGGEDIN, &WorldSession::HandleSetLfgCommentOpcode }, /*0x367*/ { "SMSG_LFG_TIMEDOUT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x368*/ { "SMSG_LFG_OTHER_TIMEDOUT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x369*/ { "SMSG_LFG_AUTOJOIN_FAILED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -912,12 +912,12 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x371*/ { "SMSG_LFG_PENDING_MATCH", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x372*/ { "SMSG_LFG_PENDING_MATCH_DONE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x373*/ { "SMSG_TITLE_EARNED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x374*/ { "CMSG_SET_TITLE", STATUS_LOGGEDIN, &WorldSession::HandleChooseTitleOpcode }, - /*0x375*/ { "CMSG_CANCEL_MOUNT_AURA", STATUS_LOGGEDIN, &WorldSession::HandleDismountOpcode }, + /*0x374*/ { "CMSG_SET_TITLE", STATUS_LOGGEDIN, &WorldSession::HandleSetTitleOpcode }, + /*0x375*/ { "CMSG_CANCEL_MOUNT_AURA", STATUS_LOGGEDIN, &WorldSession::HandleCancelMountAuraOpcode }, /*0x376*/ { "SMSG_ARENA_ERROR", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x377*/ { "MSG_INSPECT_ARENA_TEAMS", STATUS_LOGGEDIN, &WorldSession::HandleInspectArenaStatsOpcode }, + /*0x377*/ { "MSG_INSPECT_ARENA_TEAMS", STATUS_LOGGEDIN, &WorldSession::HandleInspectArenaTeamsOpcode }, /*0x378*/ { "SMSG_DEATH_RELEASE_LOC", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x379*/ { "CMSG_CANCEL_TEMP_ENCHANTMENT", STATUS_LOGGEDIN, &WorldSession::HandleCancelTempItemEnchantmentOpcode}, + /*0x379*/ { "CMSG_CANCEL_TEMP_ENCHANTMENT", STATUS_LOGGEDIN, &WorldSession::HandleCancelTempEnchantmentOpcode}, /*0x37A*/ { "SMSG_FORCED_DEATH_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x37B*/ { "CMSG_CHEAT_SET_HONOR_CURRENCY", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x37C*/ { "CMSG_CHEAT_SET_ARENA_CURRENCY", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -936,9 +936,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x389*/ { "CMSG_SET_TAXI_BENCHMARK_MODE", STATUS_AUTHED, &WorldSession::HandleSetTaxiBenchmarkOpcode }, /*0x38A*/ { "SMSG_JOINED_BATTLEGROUND_QUEUE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x38B*/ { "SMSG_REALM_SPLIT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x38C*/ { "CMSG_REALM_SPLIT", STATUS_AUTHED, &WorldSession::HandleRealmStateRequestOpcode }, + /*0x38C*/ { "CMSG_REALM_SPLIT", STATUS_AUTHED, &WorldSession::HandleRealmSplitOpcode }, /*0x38D*/ { "CMSG_MOVE_CHNG_TRANSPORT", STATUS_LOGGEDIN, &WorldSession::HandleMovementOpcodes }, - /*0x38E*/ { "MSG_PARTY_ASSIGNMENT", STATUS_LOGGEDIN, &WorldSession::HandleGroupPromoteOpcode }, + /*0x38E*/ { "MSG_PARTY_ASSIGNMENT", STATUS_LOGGEDIN, &WorldSession::HandlePartyAssignmentOpcode }, /*0x38F*/ { "SMSG_OFFER_PETITION_ERROR", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x390*/ { "SMSG_TIME_SYNC_REQ", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x391*/ { "CMSG_TIME_SYNC_RESP", STATUS_LOGGEDIN, &WorldSession::HandleTimeSyncResp }, @@ -971,7 +971,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3AC*/ { "SMSG_DISMOUNT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3AD*/ { "MSG_MOVE_UPDATE_CAN_FLY", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3AE*/ { "MSG_RAID_READY_CHECK_CONFIRM", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x3AF*/ { "CMSG_VOICE_SESSION_ENABLE", STATUS_AUTHED, &WorldSession::HandleVoiceSettingsOpcode }, + /*0x3AF*/ { "CMSG_VOICE_SESSION_ENABLE", STATUS_AUTHED, &WorldSession::HandleVoiceSessionEnableOpcode }, /*0x3B0*/ { "SMSG_VOICE_SESSION_ENABLE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3B1*/ { "SMSG_VOICE_PARENTAL_CONTROLS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3B2*/ { "CMSG_GM_WHISPER", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -994,8 +994,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3C3*/ { "CMSG_CHEAT_PLAYER_LOOKUP", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3C4*/ { "SMSG_CHEAT_PLAYER_LOOKUP", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3C5*/ { "SMSG_KICK_REASON", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x3C6*/ { "MSG_RAID_READY_CHECK_FINISHED", STATUS_LOGGEDIN, &WorldSession::HandleRaidReadyCheckFinishOpcode}, - /*0x3C7*/ { "CMSG_COMPLAIN", STATUS_LOGGEDIN, &WorldSession::HandleReportSpamOpcode }, + /*0x3C6*/ { "MSG_RAID_READY_CHECK_FINISHED", STATUS_LOGGEDIN, &WorldSession::HandleRaidReadyCheckFinishedOpcode}, + /*0x3C7*/ { "CMSG_COMPLAIN", STATUS_LOGGEDIN, &WorldSession::HandleComplainOpcode }, /*0x3C8*/ { "SMSG_COMPLAIN_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3C9*/ { "SMSG_FEATURE_SYSTEM_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3CA*/ { "CMSG_GM_SHOW_COMPLAINTS", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -1006,11 +1006,11 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3CF*/ { "CMSG_CHANNEL_UNSILENCE_ALL", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3D0*/ { "CMSG_TARGET_CAST", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3D1*/ { "CMSG_TARGET_SCRIPT_CAST", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x3D2*/ { "CMSG_CHANNEL_DISPLAY_LIST", STATUS_LOGGEDIN, &WorldSession::HandleChannelRosterQuery }, - /*0x3D3*/ { "CMSG_SET_ACTIVE_VOICE_CHANNEL", STATUS_AUTHED, &WorldSession::HandleChannelVoiceChatQuery }, - /*0x3D4*/ { "CMSG_GET_CHANNEL_MEMBER_COUNT", STATUS_LOGGEDIN, &WorldSession::HandleChannelInfoQuery }, + /*0x3D2*/ { "CMSG_CHANNEL_DISPLAY_LIST", STATUS_LOGGEDIN, &WorldSession::HandleChannelDisplayListQuery }, + /*0x3D3*/ { "CMSG_SET_ACTIVE_VOICE_CHANNEL", STATUS_AUTHED, &WorldSession::HandleSetActiveVoiceChannel }, + /*0x3D4*/ { "CMSG_GET_CHANNEL_MEMBER_COUNT", STATUS_LOGGEDIN, &WorldSession::HandleGetChannelMemberCount }, /*0x3D5*/ { "SMSG_CHANNEL_MEMBER_COUNT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x3D6*/ { "CMSG_CHANNEL_VOICE_ON", STATUS_LOGGEDIN, &WorldSession::HandleChannelEnableVoiceOpcode }, + /*0x3D6*/ { "CMSG_CHANNEL_VOICE_ON", STATUS_LOGGEDIN, &WorldSession::HandleChannelVoiceOnOpcode }, /*0x3D7*/ { "CMSG_CHANNEL_VOICE_OFF", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3D8*/ { "CMSG_DEBUG_LIST_TARGETS", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3D9*/ { "SMSG_DEBUG_LIST_TARGETS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -1024,18 +1024,18 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3E1*/ { "SMSG_COMSAT_DISCONNECT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3E2*/ { "SMSG_COMSAT_CONNECT_FAIL", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3E3*/ { "SMSG_VOICE_CHAT_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x3E4*/ { "CMSG_REPORT_PVP_AFK", STATUS_LOGGEDIN, &WorldSession::HandleBattleGroundReportAFK }, + /*0x3E4*/ { "CMSG_REPORT_PVP_AFK", STATUS_LOGGEDIN, &WorldSession::HandleReportPvPAFK }, /*0x3E5*/ { "CMSG_REPORT_PVP_AFK_RESULT", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x3E6*/ { "CMSG_GUILD_BANKER_ACTIVATE", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankQuery }, - /*0x3E7*/ { "CMSG_GUILD_BANK_QUERY_TAB", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankTabColon }, + /*0x3E6*/ { "CMSG_GUILD_BANKER_ACTIVATE", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankerActivate }, + /*0x3E7*/ { "CMSG_GUILD_BANK_QUERY_TAB", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankQueryTab }, /*0x3E8*/ { "SMSG_GUILD_BANK_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x3E9*/ { "CMSG_GUILD_BANK_SWAP_ITEMS", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankDepositItem }, + /*0x3E9*/ { "CMSG_GUILD_BANK_SWAP_ITEMS", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankSwapItems }, /*0x3EA*/ { "CMSG_GUILD_BANK_BUY_TAB", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankBuyTab }, - /*0x3EB*/ { "CMSG_GUILD_BANK_UPDATE_TAB", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankModifyTab }, - /*0x3EC*/ { "CMSG_GUILD_BANK_DEPOSIT_MONEY", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankDeposit }, - /*0x3ED*/ { "CMSG_GUILD_BANK_WITHDRAW_MONEY", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankWithdraw }, - /*0x3EE*/ { "MSG_GUILD_BANK_LOG_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankLog }, - /*0x3EF*/ { "CMSG_SET_CHANNEL_WATCH", STATUS_LOGGEDIN, &WorldSession::HandleChannelJoinNotify }, + /*0x3EB*/ { "CMSG_GUILD_BANK_UPDATE_TAB", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankUpdateTab }, + /*0x3EC*/ { "CMSG_GUILD_BANK_DEPOSIT_MONEY", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankDepositMoney }, + /*0x3ED*/ { "CMSG_GUILD_BANK_WITHDRAW_MONEY", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankWithdrawMoney }, + /*0x3EE*/ { "MSG_GUILD_BANK_LOG_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankLogQuery }, + /*0x3EF*/ { "CMSG_SET_CHANNEL_WATCH", STATUS_LOGGEDIN, &WorldSession::HandleSetChannelWatch }, /*0x3F0*/ { "SMSG_USERLIST_ADD", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3F1*/ { "SMSG_USERLIST_REMOVE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3F2*/ { "SMSG_USERLIST_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -1049,9 +1049,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3FA*/ { "CMSG_GM_CHARACTER_RESTORE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3FB*/ { "CMSG_GM_CHARACTER_SAVE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3FC*/ { "SMSG_VOICESESSION_FULL", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x3FD*/ { "MSG_GUILD_PERMISSIONS", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankGetRights }, - /*0x3FE*/ { "MSG_GUILD_BANK_MONEY_WITHDRAWN", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankGetMoneyAmount }, - /*0x3FF*/ { "MSG_GUILD_EVENT_LOG_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleGuildEventLogOpcode }, + /*0x3FD*/ { "MSG_GUILD_PERMISSIONS", STATUS_LOGGEDIN, &WorldSession::HandleGuildPermissions }, + /*0x3FE*/ { "MSG_GUILD_BANK_MONEY_WITHDRAWN", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankMoneyWithdrawn }, + /*0x3FF*/ { "MSG_GUILD_EVENT_LOG_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleGuildEventLogQueryOpcode }, /*0x400*/ { "CMSG_MAELSTROM_RENAME_GUILD", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x401*/ { "CMSG_GET_MIRRORIMAGE_DATA", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x402*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_NEVER, &WorldSession::Handle_ServerSide }, @@ -1061,9 +1061,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x406*/ { "SMSG_IGNORE_DIMINISHING_RETURNS_CHEAT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x407*/ { "CMSG_KEEP_ALIVE", STATUS_NEVER, &WorldSession::Handle_EarlyProccess }, /*0x408*/ { "SMSG_RAID_READY_CHECK_ERROR", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x409*/ { "CMSG_OPT_OUT_OF_LOOT", STATUS_AUTHED, &WorldSession::HandleGroupPassOnLootOpcode }, - /*0x40A*/ { "MSG_QUERY_GUILD_BANK_TEXT", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankTabText }, - /*0x40B*/ { "CMSG_SET_GUILD_BANK_TEXT", STATUS_LOGGEDIN, &WorldSession::HandleGuildBankSetTabText }, + /*0x409*/ { "CMSG_OPT_OUT_OF_LOOT", STATUS_AUTHED, &WorldSession::HandleOptOutOfLootOpcode }, + /*0x40A*/ { "MSG_QUERY_GUILD_BANK_TEXT", STATUS_LOGGEDIN, &WorldSession::HandleQueryGuildBankTabText }, + /*0x40B*/ { "CMSG_SET_GUILD_BANK_TEXT", STATUS_LOGGEDIN, &WorldSession::HandleSetGuildBankTabText }, /*0x40C*/ { "CMSG_SET_GRANTABLE_LEVELS", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x40D*/ { "CMSG_GRANT_LEVEL", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x40E*/ { "CMSG_REFER_A_FRIEND", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -1072,12 +1072,12 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x411*/ { "CMSG_GROUPACTION_THROTTLED", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x412*/ { "SMSG_OVERRIDE_LIGHT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x413*/ { "SMSG_TOTEM_CREATED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x414*/ { "CMSG_TOTEM_DESTROYED", STATUS_LOGGEDIN, &WorldSession::HandleTotemDestroy }, + /*0x414*/ { "CMSG_TOTEM_DESTROYED", STATUS_LOGGEDIN, &WorldSession::HandleTotemDestroyed }, /*0x415*/ { "CMSG_EXPIRE_RAID_INSTANCE", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x416*/ { "CMSG_NO_SPELL_VARIANCE", STATUS_NEVER, &WorldSession::Handle_NULL }, - /*0x417*/ { "CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverStatusQueryMultipleOpcode}, + /*0x417*/ { "CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY", STATUS_LOGGEDIN, &WorldSession::HandleQuestgiverStatusMultipleQuery}, /*0x418*/ { "SMSG_QUESTGIVER_STATUS_MULTIPLE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x419*/ { "CMSG_SET_PLAYER_DECLINED_NAMES", STATUS_AUTHED, &WorldSession::HandleDeclinedPlayerNameOpcode }, + /*0x419*/ { "CMSG_SET_PLAYER_DECLINED_NAMES", STATUS_AUTHED, &WorldSession::HandleSetPlayerDeclinedNames }, /*0x41A*/ { "SMSG_SET_PLAYER_DECLINED_NAMES_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x41B*/ { "CMSG_QUERY_SERVER_BUCK_DATA", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x41C*/ { "CMSG_CLEAR_SERVER_BUCK_DATA", STATUS_NEVER, &WorldSession::Handle_NULL }, @@ -1159,7 +1159,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x468*/ { "SMSG_ACHIEVEMENT_EARNED", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x469*/ { "SMSG_DYNAMIC_DROP_ROLL_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x46A*/ { "SMSG_CRITERIA_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide }, - /*0x46B*/ { "CMSG_QUERY_INSPECT_ACHIEVEMENTS", STATUS_LOGGEDIN, &WorldSession::HandleInspectAchievements }, + /*0x46B*/ { "CMSG_QUERY_INSPECT_ACHIEVEMENTS", STATUS_LOGGEDIN, &WorldSession::HandleQueryInspectAchievements }, /*0x46C*/ { "SMSG_RESPOND_INSPECT_ACHIEVEMENTS", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x46D*/ { "CMSG_DISMISS_CONTROLLED_VEHICLE", STATUS_LOGGEDIN, &WorldSession::HandleDismissControlledVehicle }, /*0x46E*/ { "CMSG_COMPLETE_ACHIEVEMENT_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL }, diff --git a/src/game/Opcodes.h b/src/game/Opcodes.h index d57cfd62852..fbf3e9a72a1 100644 --- a/src/game/Opcodes.h +++ b/src/game/Opcodes.h @@ -1241,7 +1241,7 @@ enum SessionStatus { STATUS_AUTHED = 0, ///< Player authenticated STATUS_LOGGEDIN, ///< Player in game - STATUS_TRANSFER_PENDING, ///< Player transferring to another map + STATUS_TRANSFER, ///< Player transferring to another map STATUS_NEVER ///< Opcode not accepted from client (deprecated or server side only) }; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 5f89d71ff53..d2bef6ddba7 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1035,7 +1035,7 @@ void Pet::_SaveSpellCooldowns() m_CreatureSpellCooldowns.erase(itr++); else { - CharacterDatabase.PExecute("INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES ('%u', '%u', '" I64FMTD "')", m_charmInfo->GetPetNumber(), itr->first, uint64(itr->second)); + CharacterDatabase.PExecute("INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES ('%u', '%u', '" UI64FMTD "')", m_charmInfo->GetPetNumber(), itr->first, uint64(itr->second)); ++itr; } } @@ -1186,7 +1186,7 @@ void Pet::_SaveAuras() } CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%u')", + "VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%u')", m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(), itr->second->GetId(), (uint32)itr->second->GetEffectMask(), (int32)itr->second->GetStackAmount(), amounts[0], amounts[1], amounts[2] ,itr->second->GetAuraMaxDuration(), itr->second->GetAuraDuration(), (uint32)itr->second->GetAuraCharges()); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index de558c5435a..d6ffb51f74d 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -83,7 +83,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid CharmInfo *charmInfo = pet->GetCharmInfo(); if(!charmInfo) { - sLog.outError("WorldSession::HandlePetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID()); + sLog.outError("WorldSession::HandlePetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); return; } @@ -380,7 +380,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) CharmInfo *charmInfo = pet->GetCharmInfo(); if(!charmInfo) { - sLog.outError("WorldSession::HandlePetSetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID()); + sLog.outError("WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); return; } @@ -550,7 +550,7 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) CharmInfo *charmInfo = pet->GetCharmInfo(); if(!charmInfo) { - sLog.outError("WorldSession::HandlePetUnlearnOpcode: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID()); + sLog.outError("WorldSession::HandlePetUnlearnOpcode: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); return; } pet->resetTalents(); @@ -588,7 +588,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) CharmInfo *charmInfo = pet->GetCharmInfo(); if(!charmInfo) { - sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID()); + sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); return; } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2e96a13dc61..ad7635d39de 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1536,7 +1536,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) const ItemPrototype * proto = objmgr.GetItemPrototype(item_id); SpellItemEnchantmentEntry const *enchant = NULL; - for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot<=TEMP_ENCHANTMENT_SLOT; enchantSlot++) + for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot) { uint32 enchantId = GetUInt32Value(visualbase+1+enchantSlot); if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId)) @@ -3071,7 +3071,7 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const switch(spellInfo->Id) { - // some spells not have stance data expacted cast at form change or present + // some spells not have stance data expected cast at form change or present case 5420: need_cast = (m_form == FORM_TREE); break; case 5419: need_cast = (m_form == FORM_TRAVEL); break; case 7376: need_cast = (m_form == FORM_DEFENSIVESTANCE); break; @@ -3318,7 +3318,7 @@ void Player::RemoveSpellCooldown( uint32 spell_id, bool update /* = false */ ) if(update) { - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(spell_id); data << uint64(GetGUID()); SendDirectMessage(&data); @@ -3349,7 +3349,7 @@ void Player::RemoveArenaSpellCooldowns() entry->CategoryRecoveryTime <= 15 * MINUTE * IN_MILISECONDS ) { // notify player - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(itr->first); data << uint64(GetGUID()); GetSession()->SendPacket(&data); @@ -3365,7 +3365,7 @@ void Player::RemoveAllSpellCooldown() { for(SpellCooldowns::const_iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); ++itr) { - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(itr->first); data << uint64(GetGUID()); GetSession()->SendPacket(&data); @@ -3426,7 +3426,7 @@ void Player::_SaveSpellCooldowns() m_spellCooldowns.erase(itr++); else if(itr->second.end <= infTime) // not save locked cooldowns, it will be reset or set at reload { - CharacterDatabase.PExecute("INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES ('%u', '%u', '%u', '" I64FMTD "')", GetGUIDLow(), itr->first, itr->second.itemid, uint64(itr->second.end)); + CharacterDatabase.PExecute("INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES ('%u', '%u', '%u', '" UI64FMTD "')", GetGUIDLow(), itr->first, itr->second.itemid, uint64(itr->second.end)); ++itr; } else @@ -8967,7 +8967,7 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV if(slot >= VANITYPET_SLOT_START && slot < VANITYPET_SLOT_END) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - // currencytoken case (disabled until proper implement) + // currencytoken case if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -9635,7 +9635,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } // check free space for all items - for (int k=0;k<count;k++) + for (int k = 0; k < count; ++k) { Item *pItem = pItems[k]; @@ -9666,7 +9666,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const { bool b_found = false; - for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; t++) + for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; ++t) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9678,7 +9678,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; t++) + for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_tokens[t-CURRENCYTOKEN_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9690,7 +9690,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) + for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_slot_items[t-INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9702,7 +9702,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag && ItemCanGoIntoBag(pItem->GetProto(), pBag->GetProto())) @@ -9757,7 +9757,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag ) @@ -9785,7 +9785,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const // search free slot bool b_found = false; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) + for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { if( inv_slot_items[t-INVENTORY_SLOT_ITEM_START] == 0 ) { @@ -9797,7 +9797,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; // search free slot in bags - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag ) @@ -10106,14 +10106,14 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p } else { - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); + if(res != EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); - if(res!=EQUIP_ERR_OK) + if(res != EQUIP_ERR_OK) return res; - if(count==0) + if(count == 0) return EQUIP_ERR_OK; } } @@ -10125,10 +10125,10 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p { // in slots res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if(res != EQUIP_ERR_OK) return res; - if(count==0) + if(count == 0) return EQUIP_ERR_OK; // in special bags @@ -10398,7 +10398,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (!pItem2) { if (clone) - pItem = pItem->CloneItem(count,this); + pItem = pItem->CloneItem(count, this); else pItem->SetCount(count); @@ -10413,7 +10413,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (bag == INVENTORY_SLOT_BAG_0) { m_items[slot] = pItem; - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); + SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); @@ -10422,7 +10422,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo // need update known currency if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) - UpdateKnownCurrencies(pItem->GetEntry(),true); + UpdateKnownCurrencies(pItem->GetEntry(), true); if (IsInWorld() && update) { @@ -10517,7 +10517,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) // item set bonuses applied only at equip and removed at unequip, and still active for broken items if(pProto && pProto->ItemSet) - AddItemsSetItem(this,pItem); + AddItemsSetItem(this, pItem); _ApplyItemMods(pItem, slot, true); @@ -10606,20 +10606,13 @@ void Player::QuickEquipItem( uint16 pos, Item *pItem) pItem->AddToWorld(); pItem->SendUpdateToPlayer( this ); } + + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); } } void Player::SetVisibleItemSlot(uint8 slot, Item *pItem) { - // PLAYER_VISIBLE_ITEM_i_CREATOR // Size: 2 - // PLAYER_VISIBLE_ITEM_i_0 // Size: 12 - // entry // Size: 1 - // inspected enchantments // Size: 6 - // ? // Size: 5 - // PLAYER_VISIBLE_ITEM_i_PROPERTIES // Size: 1 (property,suffix factor) - // PLAYER_VISIBLE_ITEM_i_PAD // Size: 1 - // // = 16 - if(pItem) { SetUInt64Value(PLAYER_VISIBLE_ITEM_1_CREATOR + (slot * MAX_VISIBLE_ITEM_OFFSET), pItem->GetUInt64Value(ITEM_FIELD_CREATOR)); @@ -10661,14 +10654,14 @@ void Player::VisualizeItem( uint8 slot, Item *pItem) sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); m_items[slot] = pItem; - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); + SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); pItem->SetSlot( slot ); pItem->SetContainer( NULL ); if( slot < EQUIPMENT_SLOT_END ) - SetVisibleItemSlot(slot,pItem); + SetVisibleItemSlot(slot, pItem); pItem->SetState(ITEM_CHANGED, this); } @@ -10696,7 +10689,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) // item set bonuses applied only at equip and removed at unequip, and still active for broken items if(pProto && pProto->ItemSet) - RemoveItemsSetItem(this,pProto); + RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); @@ -10727,13 +10720,13 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) } // need update known currency else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) - UpdateKnownCurrencies(pItem->GetEntry(),false); + UpdateKnownCurrencies(pItem->GetEntry(), false); m_items[slot] = NULL; - SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); + SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); if ( slot < EQUIPMENT_SLOT_END ) - SetVisibleItemSlot(slot,NULL); + SetVisibleItemSlot(slot, NULL); } else { @@ -10754,8 +10747,8 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) { if(Item* it = GetItemByPos(bag,slot)) { - ItemRemovedQuestCheck(it->GetEntry(),it->GetCount()); - RemoveItem( bag,slot,update); + ItemRemovedQuestCheck(it->GetEntry(), it->GetCount()); + RemoveItem(bag, slot, update); it->RemoveFromUpdateQueueOf(this); if(it->IsInWorld()) { @@ -10769,13 +10762,13 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB) { // update quest counters - ItemAddedQuestCheck(pItem->GetEntry(),pItem->GetCount()); + ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount()); // store item - Item* pLastItem = StoreItem( dest, pItem, update); + Item* pLastItem = StoreItem(dest, pItem, update); // only set if not merged to existed stack (pItem can be deleted already but we can compare pointers any way) - if(pLastItem==pItem) + if(pLastItem == pItem) { // update owner for last item (this can be original item with wrong owner if(pLastItem->GetOwnerGUID() != GetGUID()) @@ -10797,8 +10790,8 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) // start from destroy contained items (only equipped bag can have its) if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag==slot { - for (int i = 0; i < MAX_BAG_SIZE; i++) - DestroyItem(slot,i,update); + for (int i = 0; i < MAX_BAG_SIZE; ++i) + DestroyItem(slot, i, update); } if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) @@ -10811,7 +10804,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) if( bag == INVENTORY_SLOT_BAG_0 ) { - SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); + SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); // equipment and equipped bags can have applied bonuses if ( slot < INVENTORY_SLOT_BAG_END ) @@ -10820,7 +10813,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) // item set bonuses applied only at equip and removed at unequip, and still active for broken items if(pProto && pProto->ItemSet) - RemoveItemsSetItem(this,pProto); + RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); } @@ -10837,11 +10830,11 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) UpdateExpertise(OFF_ATTACK); // equipment visual show - SetVisibleItemSlot(slot,NULL); + SetVisibleItemSlot(slot, NULL); } // need update known currency else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) - UpdateKnownCurrencies(pItem->GetEntry(),false); + UpdateKnownCurrencies(pItem->GetEntry(), false); m_items[slot] = NULL; } @@ -10879,7 +10872,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq remcount += pItem->GetCount(); DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - if (remcount >=count) + if (remcount >= count) return; } else @@ -10907,7 +10900,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq remcount += pItem->GetCount(); DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - if (remcount >=count) + if (remcount >= count) return; } else @@ -10940,7 +10933,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq remcount += pItem->GetCount(); DestroyItem( i, j, update ); - if (remcount >=count) + if (remcount >= count) return; } else @@ -10967,12 +10960,12 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq { if (pItem->GetCount() + remcount <= count) { - if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i,false) == EQUIP_ERR_OK ) + if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false) == EQUIP_ERR_OK ) { remcount += pItem->GetCount(); DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - if (remcount >=count) + if (remcount >= count) return; } } @@ -10997,12 +10990,12 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) // in inventory for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem( INVENTORY_SLOT_BAG_0, i, update); for(int i = KEYRING_SLOT_START; i < QUESTBAG_SLOT_END; i++) if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem( INVENTORY_SLOT_BAG_0, i, update); // in inventory bags @@ -11010,13 +11003,13 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) for(uint32 j = 0; j < pBag->GetBagSize(); j++) if (Item* pItem = pBag->GetItemByPos(j)) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) - DestroyItem( i, j, update); + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) + DestroyItem(i, j, update); // in equipment and bag list for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem( INVENTORY_SLOT_BAG_0, i, update); } @@ -11056,7 +11049,7 @@ void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update ) if( pItem->GetCount() <= count ) { - count-= pItem->GetCount(); + count -= pItem->GetCount(); DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update); } @@ -11295,7 +11288,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) } RemoveItem(srcbag, srcslot, true); - EquipItem( dest, pSrcItem, true); + EquipItem(dest, pSrcItem, true); AutoUnequipOffhandIfNeed(); } @@ -11425,7 +11418,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) ItemPrototype const* bagItemProto = bagItem->GetProto(); if (!bagItemProto || !ItemCanGoIntoBag(bagItemProto, emotyProto)) { - // one from items not go to empry target bag + // one from items not go to empty target bag SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); return; } @@ -11443,7 +11436,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) // Items swap count = 0; // will pos in new bag - for(int i=0; i< fullBag->GetBagSize(); ++i) + for(int i = 0; i< fullBag->GetBagSize(); ++i) { Item *bagItem = fullBag->GetItemByPos(i); if (!bagItem) @@ -11522,7 +11515,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, pItem->GetGUID() ); + SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID() ); ItemPrototype const *pProto = pItem->GetProto(); if( pProto ) SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); @@ -11531,7 +11524,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime ); // move to next (for non filled list is move most optimized choice) - if(m_currentBuybackSlot < BUYBACK_SLOT_END-1) + if(m_currentBuybackSlot < BUYBACK_SLOT_END - 1) ++m_currentBuybackSlot; } } @@ -11559,7 +11552,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) m_items[slot] = NULL; uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, 0 ); + SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); @@ -11571,7 +11564,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ) { - sLog.outDebug( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)",msg); + sLog.outDebug( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg); WorldPacket data( SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18) ); data << uint8(msg); @@ -11654,9 +11647,9 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) if(m_itemDuration.empty()) return; - sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time,realtimeonly); + sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ) + for(ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ) { Item* item = *itr; ++itr; // current element can be erased in UpdateDuration @@ -11671,14 +11664,14 @@ void Player::UpdateEnchantTime(uint32 time) for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) { assert(itr->item); - next=itr; + next = itr; if(!itr->item->GetEnchantmentId(itr->slot)) { next = m_enchantDuration.erase(itr); } else if(itr->leftduration <= time) { - ApplyEnchantment(itr->item,itr->slot,false,false); + ApplyEnchantment(itr->item, itr->slot, false, false); itr->item->ClearEnchantment(itr->slot); next = m_enchantDuration.erase(itr); } @@ -11692,25 +11685,25 @@ void Player::UpdateEnchantTime(uint32 time) void Player::AddEnchantmentDurations(Item *item) { - for(int x=0;x<MAX_ENCHANTMENT_SLOT;++x) + for(int x = 0; x < MAX_ENCHANTMENT_SLOT; ++x) { if(!item->GetEnchantmentId(EnchantmentSlot(x))) continue; uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); if( duration > 0 ) - AddEnchantmentDuration(item,EnchantmentSlot(x),duration); + AddEnchantmentDuration(item, EnchantmentSlot(x), duration); } } void Player::RemoveEnchantmentDurations(Item *item) { - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();) + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) { if(itr->item == item) { // save duration in item - item->SetEnchantmentDuration(EnchantmentSlot(itr->slot),itr->leftduration); + item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration); itr = m_enchantDuration.erase(itr); } else @@ -11721,10 +11714,10 @@ void Player::RemoveEnchantmentDurations(Item *item) void Player::RemoveArenaEnchantments(EnchantmentSlot slot) { // remove enchantments from equipped items first to clean up the m_enchantDuration list - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) { next = itr; - if(itr->slot==slot) + if(itr->slot == slot) { if(itr->item && itr->item->GetEnchantmentId(slot)) { @@ -11735,7 +11728,7 @@ void Player::RemoveArenaEnchantments(EnchantmentSlot slot) continue; } // remove from stats - ApplyEnchantment(itr->item,slot,false,false); + ApplyEnchantment(itr->item, slot, false, false); // remove visual itr->item->ClearEnchantment(slot); } @@ -11781,19 +11774,19 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat if(slot >= MAX_ENCHANTMENT_SLOT) return; - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { if(itr->item == item && itr->slot == slot) { - itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); + itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration); m_enchantDuration.erase(itr); break; } } if(item && duration > 0 ) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(),slot,uint32(duration/1000)); - m_enchantDuration.push_back(EnchantDuration(item,slot,duration)); + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000)); + m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); } } @@ -11803,7 +11796,7 @@ void Player::ApplyEnchantment(Item *item,bool apply) ApplyEnchantment(item, EnchantmentSlot(slot), apply); } -void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur, bool ignore_condition) +void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { if(!item) return; @@ -11827,7 +11820,7 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a if (!item->IsBroken()) { - for (int s=0; s<3; s++) + for (int s = 0; s < 3; ++s) { uint32 enchant_display_type = pEnchant->type[s]; uint32 enchant_amount = pEnchant->amount[s]; @@ -11861,11 +11854,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a if (item_rand) { // Search enchant_amount - for (int k=0; k<3; k++) + for (int k = 0; k < 3; ++k) { if(item_rand->enchant_id[k] == enchant_id) { - basepoints = int32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + basepoints = int32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); break; } } @@ -11873,12 +11866,12 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a } // Cast custom spell vs all equal basepoints getted from enchant_amount if (basepoints) - CastCustomSpell(this,enchant_spell_id,&basepoints,&basepoints,&basepoints,true,item); + CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item); else - CastSpell(this,enchant_spell_id,true,item); + CastSpell(this, enchant_spell_id, true, item); } else - RemoveAurasDueToItemSpell(item,enchant_spell_id); + RemoveAurasDueToItemSpell(item, enchant_spell_id); } break; case ITEM_ENCHANTMENT_TYPE_RESISTANCE: @@ -11887,11 +11880,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if(item_rand) { - for (int k=0; k<3; k++) + for (int k = 0; k < 3; ++k) { if(item_rand->enchant_id[k] == enchant_id) { - enchant_amount = uint32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + enchant_amount = uint32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); break; } } @@ -11907,11 +11900,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if(item_rand_suffix) { - for (int k=0; k<3; k++) + for (int k = 0; k < 3; ++k) { if(item_rand_suffix->enchant_id[k] == enchant_id) { - enchant_amount = uint32((item_rand_suffix->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + enchant_amount = uint32((item_rand_suffix->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); break; } } @@ -12108,12 +12101,12 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a float addValue = 0.0f; if(item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); } else if(item->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); } } @@ -12146,27 +12139,27 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a // set duration uint32 duration = item->GetEnchantmentDuration(slot); if(duration > 0) - AddEnchantmentDuration(item,slot,duration); + AddEnchantmentDuration(item, slot, duration); } else { // duration == 0 will remove EnchantDuration - AddEnchantmentDuration(item,slot,0); + AddEnchantmentDuration(item, slot, 0); } } } void Player::SendEnchantmentDurations() { - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + for(EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(),itr->slot,uint32(itr->leftduration)/1000); + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(), itr->slot, uint32(itr->leftduration) / 1000); } } void Player::SendItemDurations() { - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end();++itr) + for(ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) { (*itr)->SendTimeUpdate(this); } @@ -12179,18 +12172,18 @@ void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, // last check 2.0.10 WorldPacket data( SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4) ); - data << GetGUID(); // player GUID + data << uint64(GetGUID()); // player GUID data << uint32(received); // 0=looted, 1=from npc data << uint32(created); // 0=received, 1=created data << uint32(1); // always 0x01 (probably meant to be count of listed items) - data << (uint8)item->GetBagSlot(); // bagslot + data << uint8(item->GetBagSlot()); // bagslot // item slot, but when added to stack: 0xFFFFFFFF - data << (uint32) ((item->GetCount()==count) ? item->GetSlot() : -1); + data << uint32((item->GetCount() == count) ? item->GetSlot() : -1); data << uint32(item->GetEntry()); // item id data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemRandomPropertyId()); // random item property id data << uint32(count); // count of items - data << GetItemCount(item->GetEntry()); // count of items in inventory + data << uint32(GetItemCount(item->GetEntry())); // count of items in inventory if (broadcast && GetGroup()) GetGroup()->BroadcastPacket(&data, true); @@ -12209,7 +12202,7 @@ void Player::PrepareQuestMenu( uint64 guid ) QuestRelations* pObjectQIR; // pets also can have quests - Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid); + Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid); if( pCreature ) { pObject = (Object*)pCreature; @@ -12275,10 +12268,11 @@ void Player::SendPreparedQuest( uint64 guid ) // Auto open -- maybe also should verify there is no greeting uint32 quest_id = qmi0.m_qId; Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); + if ( pQuest ) { if( status == DIALOG_STATUS_REWARD_REP && !GetQuestRewardStatus( quest_id ) ) - PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest,false), true ); + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest, false), true ); else if( status == DIALOG_STATUS_INCOMPLETE ) PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, false, true ); // Send completable on repeatable quest if player don't have quest @@ -14219,7 +14213,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(!LoadValues( fields[2].GetString())) { - sLog.outError("Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); + sLog.outError("Player #%d have broken data in `data` field. Can't be loaded.", GUID_LOPART(guid)); delete result; return false; } @@ -14230,8 +14224,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), 0 ); - SetVisibleItemSlot(slot,NULL); + SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0 ); + SetVisibleItemSlot(slot, NULL); if (m_items[slot]) { @@ -14645,7 +14639,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) { if(!HasTitle(curTitle)) - SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + SetUInt32Value(PLAYER_CHOSEN_TITLE, 0); } // Not finish taxi flight path @@ -15135,7 +15129,7 @@ void Player::_LoadMailedItems(Mail *mail) void Player::_LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery) { //set a count of unread mails - //QueryResult *resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" I64FMTD "'", GUID_LOPART(playerGuid),(uint64)cTime); + //QueryResult *resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(playerGuid),(uint64)cTime); if (resultUnread) { Field *fieldMail = resultUnread->Fetch(); @@ -15271,18 +15265,18 @@ void Player::_LoadQuestStatus(QueryResult *result) // add to quest log if( slot < MAX_QUEST_LOG_SIZE && - ( questStatusData.m_status==QUEST_STATUS_INCOMPLETE || - questStatusData.m_status==QUEST_STATUS_COMPLETE && + ( questStatusData.m_status == QUEST_STATUS_INCOMPLETE || + questStatusData.m_status == QUEST_STATUS_COMPLETE && (!questStatusData.m_rewarded || pQuest->IsDaily()) ) ) { - SetQuestSlot(slot,quest_id,quest_time); + SetQuestSlot(slot, quest_id, quest_time); if(questStatusData.m_status == QUEST_STATUS_COMPLETE) - SetQuestSlotState(slot,QUEST_STATE_COMPLETE); + SetQuestSlotState(slot, QUEST_STATE_COMPLETE); for(uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) if(questStatusData.m_creatureOrGOcount[idx]) - SetQuestSlotCounter(slot,idx,questStatusData.m_creatureOrGOcount[idx]); + SetQuestSlotCounter(slot, idx, questStatusData.m_creatureOrGOcount[idx]); ++slot; } @@ -15300,7 +15294,7 @@ void Player::_LoadQuestStatus(QueryResult *result) } if(pQuest->GetBonusTalents()) - m_questRewardTalentCount+=pQuest->GetBonusTalents(); + m_questRewardTalentCount += pQuest->GetBonusTalents(); } sLog.outDebug("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); @@ -15313,7 +15307,7 @@ void Player::_LoadQuestStatus(QueryResult *result) // clear quest log tail for ( uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i ) - SetQuestSlot(i,0); + SetQuestSlot(i, 0); } void Player::_LoadDailyQuestStatus(QueryResult *result) @@ -15548,7 +15542,7 @@ void Player::SendRaidInfo() } } } - data.put<uint32>(p_counter,counter); + data.put<uint32>(p_counter, counter); GetSession()->SendPacket(&data); } @@ -15995,7 +15989,7 @@ void Player::_SaveAuras() } CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", + "VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", GetGUIDLow(), itr->second->GetCasterGUID(),(uint32)itr->second->GetId(), (uint32)itr->second->GetEffectMask(), (int32)itr->second->GetStackAmount(), (int32)amounts[0], (int32)amounts[1], (int32)amounts[2] ,int(itr->second->GetAuraMaxDuration()),int(itr->second->GetAuraDuration()),int(itr->second->GetAuraCharges())); @@ -16089,7 +16083,7 @@ void Player::_SaveMail() Mail *m = (*itr); if (m->state == MAIL_STATE_CHANGED) { - CharacterDatabase.PExecute("UPDATE mail SET itemTextId = '%u',has_items = '%u',expire_time = '" I64FMTD "', deliver_time = '" I64FMTD "',money = '%u',cod = '%u',checked = '%u' WHERE id = '%u'", + CharacterDatabase.PExecute("UPDATE mail SET itemTextId = '%u',has_items = '%u',expire_time = '" UI64FMTD "', deliver_time = '" UI64FMTD "',money = '%u',cod = '%u',checked = '%u' WHERE id = '%u'", m->itemTextId, m->HasItems() ? 1 : 0, (uint64)m->expire_time, (uint64)m->deliver_time, m->money, m->COD, m->checked, m->messageID); if(m->removedItems.size()) { @@ -16137,11 +16131,11 @@ void Player::_SaveQuestStatus() { case QUEST_NEW : CharacterDatabase.PExecute("INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", + "VALUES ('%u', '%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", GetGUIDLow(), i->first, i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / IN_MILISECONDS+ sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3]); break; case QUEST_CHANGED : - CharacterDatabase.PExecute("UPDATE character_queststatus SET status = '%u',rewarded = '%u',explored = '%u',timer = '" I64FMTD "',mobcount1 = '%u',mobcount2 = '%u',mobcount3 = '%u',mobcount4 = '%u',itemcount1 = '%u',itemcount2 = '%u',itemcount3 = '%u',itemcount4 = '%u' WHERE guid = '%u' AND quest = '%u' ", + CharacterDatabase.PExecute("UPDATE character_queststatus SET status = '%u',rewarded = '%u',explored = '%u',timer = '" UI64FMTD "',mobcount1 = '%u',mobcount2 = '%u',mobcount3 = '%u',mobcount4 = '%u',itemcount1 = '%u',itemcount2 = '%u',itemcount3 = '%u',itemcount4 = '%u' WHERE guid = '%u' AND quest = '%u' ", i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / IN_MILISECONDS + sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3], GetGUIDLow(), i->first ); break; case QUEST_UNCHANGED: @@ -16164,7 +16158,7 @@ void Player::_SaveDailyQuestStatus() CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",GetGUIDLow()); for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) if(GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) - CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" I64FMTD "')", + CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" UI64FMTD "')", GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime)); } @@ -16791,7 +16785,7 @@ void Player::PetSpellInitialize() CharmInfo *charmInfo = pet->GetCharmInfo(); - WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+10*4); + WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+1); data << uint64(pet->GetGUID()); data << uint32(pet->GetCreatureInfo()->family); // creature family (required for pet talents) data << uint32(0); @@ -16862,26 +16856,20 @@ void Player::PossessSpellInitialize() if(!charmInfo) { - sLog.outError("Player::PossessSpellInitialize(): charm ("I64FMTD") has no charminfo!", charm->GetGUID()); + sLog.outError("Player::PossessSpellInitialize(): charm ("UI64FMTD") has no charminfo!", charm->GetGUID()); return; } - WorldPacket data(SMSG_PET_SPELLS, 20+40+1+1); - - //basic info 20 + WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+1); data << uint64(charm->GetGUID()); - data << uint32(0x00000000); + data << uint32(0); data << uint32(0); data << uint32(0); - //action bar 40 - charmInfo->BuildActionBar(&data); //40 - - //addlist 1 - data << uint8(0); + charmInfo->BuildActionBar(&data); - //cooldown 1 - data << uint8(0); + data << uint8(0); // spells count + data << uint8(0); // cooldowns count GetSession()->SendPacket(&data); } @@ -16934,7 +16922,7 @@ void Player::CharmSpellInitialize() CharmInfo *charmInfo = charm->GetCharmInfo(); if(!charmInfo) { - sLog.outError("Player::CharmSpellInitialize(): the player's charm ("I64FMTD") has no charminfo!", charm->GetGUID()); + sLog.outError("Player::CharmSpellInitialize(): the player's charm ("UI64FMTD") has no charminfo!", charm->GetGUID()); return; } @@ -16952,23 +16940,20 @@ void Player::CharmSpellInitialize() } } - WorldPacket data(SMSG_PET_SPELLS, 20+40+1+4*addlist+1);// first line + actionbar + spellcount + spells + last adds - - //basic info 20 + WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+4*addlist+1); data << uint64(charm->GetGUID()); data << uint32(0); data << uint32(0); + if(charm->GetTypeId() != TYPEID_PLAYER) data << uint8(((Creature*)charm)->GetReactState()) << uint8(charmInfo->GetCommandState()); else - data << uint8(0) << uint8(0); - data << uint16(0); + data << uint8(0) << uint8(0) << uint16(0); + + charmInfo->BuildActionBar(&data); - //action bar 40 - charmInfo->BuildActionBar(&data); //40 + data << uint8(addlist); - //add list - data << uint8(addlist); //1 if(addlist) { for(uint32 i = 0; i < MAX_SPELL_CHARM; ++i) @@ -16982,9 +16967,7 @@ void Player::CharmSpellInitialize() } } - //cooldown - uint8 count = 0; - data << uint8(count); // cooldowns count + data << uint8(0); // cooldowns count GetSession()->SendPacket(&data); } @@ -17436,8 +17419,8 @@ void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs ) if((idSchoolMask & GetSpellSchoolMask(spellInfo)) && GetSpellCooldownDelay(unSpellId) < unTimeMs ) { - data << unSpellId; - data << unTimeMs; // in m.secs + data << uint32(unSpellId); + data << uint32(unTimeMs); // in m.secs AddSpellCooldown(unSpellId, 0, curTime + unTimeMs/IN_MILISECONDS); } } @@ -18408,7 +18391,7 @@ void Player::SendInitialVisiblePackets(Unit* target) if(target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) target->SendMonsterMoveWithSpeedToCurrentDestination(this); if(target->hasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim()) - target->SendAttackStart(target->getVictim()); + target->SendMeleeAttackStart(target->getVictim()); } } @@ -19516,8 +19499,9 @@ uint32 Player::GetBaseWeaponSkillValue (WeaponAttackType attType) const void Player::ResurectUsingRequestData() { - /// Teleport before resurrecting, otherwise the player might get attacked from creatures near his corpse - TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); + /// Teleport before resurrecting by player, otherwise the player might get attacked from creatures near his corpse + if(IS_PLAYER_GUID(m_resurrectGUID)) + TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); ResurrectPlayer(0.0f,false); @@ -19982,16 +19966,16 @@ bool Player::HasTitle(uint32 bitIndex) if (bitIndex > 128) return false; - uint32 fieldIndexOffset = bitIndex/32; - uint32 flag = 1 << (bitIndex%32); - return HasFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag); + uint32 fieldIndexOffset = bitIndex / 32; + uint32 flag = 1 << (bitIndex % 32); + return HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } void Player::SetTitle(CharTitlesEntry const* title) { - uint32 fieldIndexOffset = title->bit_index/32; - uint32 flag = 1 << (title->bit_index%32); - SetFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag); + uint32 fieldIndexOffset = title->bit_index / 32; + uint32 flag = 1 << (title->bit_index % 32); + SetFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } /*-----------------------TRINITY--------------------------*/ diff --git a/src/game/Player.h b/src/game/Player.h index 33693842154..6cf949453d3 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -148,6 +148,7 @@ struct ActionButton enum ActionButtonType { ACTION_BUTTON_SPELL = 0, + ACTION_BUTTON_EQSET = 32, ACTION_BUTTON_MACRO = 64, ACTION_BUTTON_CMACRO= 65, ACTION_BUTTON_ITEM = 128 @@ -289,14 +290,32 @@ struct EnchantDuration typedef std::list<EnchantDuration> EnchantDurationList; typedef std::list<Item*> ItemDurationList; +enum LfgType +{ + LFG_TYPE_NONE = 0, + LFG_TYPE_DUNGEON = 1, + LFG_TYPE_RAID = 2, + LFG_TYPE_QUEST = 3, + LFG_TYPE_ZONE = 4, + LFG_TYPE_HEROIC_DUNGEON = 5 +}; + +enum LfgRoles +{ + LEADER = 1, + TANK = 2, + HEALER = 4, + DAMAGE = 8 +}; + struct LookingForGroupSlot { LookingForGroupSlot() : entry(0), type(0) {} bool Empty() const { return !entry && !type; } void Clear() { entry = 0; type = 0; } void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; } - bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; } - bool canAutoJoin() const { return entry && (type == 1 || type == 5); } + bool Is(uint32 _entry, uint32 _type) const { return entry == _entry && type == _type; } + bool canAutoJoin() const { return entry && (type == LFG_TYPE_DUNGEON || type == LFG_TYPE_HEROIC_DUNGEON); } uint32 entry; uint32 type; @@ -307,11 +326,11 @@ struct LookingForGroupSlot struct LookingForGroup { LookingForGroup() {} - bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); } + bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry, slot.type); } bool HaveInSlot(uint32 _entry, uint32 _type) const { for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) - if(slots[i].Is(_entry,_type)) + if(slots[i].Is(_entry, _type)) return true; return false; } @@ -384,48 +403,48 @@ enum PlayerFlags // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1) // can't use enum for uint64 values -#define PLAYER_TITLE_DISABLED 0x0000000000000000LL -#define PLAYER_TITLE_NONE 0x0000000000000001LL -#define PLAYER_TITLE_PRIVATE 0x0000000000000002LL // 1 -#define PLAYER_TITLE_CORPORAL 0x0000000000000004LL // 2 -#define PLAYER_TITLE_SERGEANT_A 0x0000000000000008LL // 3 -#define PLAYER_TITLE_MASTER_SERGEANT 0x0000000000000010LL // 4 -#define PLAYER_TITLE_SERGEANT_MAJOR 0x0000000000000020LL // 5 -#define PLAYER_TITLE_KNIGHT 0x0000000000000040LL // 6 -#define PLAYER_TITLE_KNIGHT_LIEUTENANT 0x0000000000000080LL // 7 -#define PLAYER_TITLE_KNIGHT_CAPTAIN 0x0000000000000100LL // 8 -#define PLAYER_TITLE_KNIGHT_CHAMPION 0x0000000000000200LL // 9 -#define PLAYER_TITLE_LIEUTENANT_COMMANDER 0x0000000000000400LL // 10 -#define PLAYER_TITLE_COMMANDER 0x0000000000000800LL // 11 -#define PLAYER_TITLE_MARSHAL 0x0000000000001000LL // 12 -#define PLAYER_TITLE_FIELD_MARSHAL 0x0000000000002000LL // 13 -#define PLAYER_TITLE_GRAND_MARSHAL 0x0000000000004000LL // 14 -#define PLAYER_TITLE_SCOUT 0x0000000000008000LL // 15 -#define PLAYER_TITLE_GRUNT 0x0000000000010000LL // 16 -#define PLAYER_TITLE_SERGEANT_H 0x0000000000020000LL // 17 -#define PLAYER_TITLE_SENIOR_SERGEANT 0x0000000000040000LL // 18 -#define PLAYER_TITLE_FIRST_SERGEANT 0x0000000000080000LL // 19 -#define PLAYER_TITLE_STONE_GUARD 0x0000000000100000LL // 20 -#define PLAYER_TITLE_BLOOD_GUARD 0x0000000000200000LL // 21 -#define PLAYER_TITLE_LEGIONNAIRE 0x0000000000400000LL // 22 -#define PLAYER_TITLE_CENTURION 0x0000000000800000LL // 23 -#define PLAYER_TITLE_CHAMPION 0x0000000001000000LL // 24 -#define PLAYER_TITLE_LIEUTENANT_GENERAL 0x0000000002000000LL // 25 -#define PLAYER_TITLE_GENERAL 0x0000000004000000LL // 26 -#define PLAYER_TITLE_WARLORD 0x0000000008000000LL // 27 -#define PLAYER_TITLE_HIGH_WARLORD 0x0000000010000000LL // 28 -#define PLAYER_TITLE_GLADIATOR 0x0000000020000000LL // 29 -#define PLAYER_TITLE_DUELIST 0x0000000040000000LL // 30 -#define PLAYER_TITLE_RIVAL 0x0000000080000000LL // 31 -#define PLAYER_TITLE_CHALLENGER 0x0000000100000000LL // 32 -#define PLAYER_TITLE_SCARAB_LORD 0x0000000200000000LL // 33 -#define PLAYER_TITLE_CONQUEROR 0x0000000400000000LL // 34 -#define PLAYER_TITLE_JUSTICAR 0x0000000800000000LL // 35 -#define PLAYER_TITLE_CHAMPION_OF_THE_NAARU 0x0000001000000000LL // 36 -#define PLAYER_TITLE_MERCILESS_GLADIATOR 0x0000002000000000LL // 37 -#define PLAYER_TITLE_OF_THE_SHATTERED_SUN 0x0000004000000000LL // 38 -#define PLAYER_TITLE_HAND_OF_ADAL 0x0000008000000000LL // 39 -#define PLAYER_TITLE_VENGEFUL_GLADIATOR 0x0000010000000000LL // 40 +#define PLAYER_TITLE_DISABLED UI64LIT(0x0000000000000000) +#define PLAYER_TITLE_NONE UI64LIT(0x0000000000000001) +#define PLAYER_TITLE_PRIVATE UI64LIT(0x0000000000000002) // 1 +#define PLAYER_TITLE_CORPORAL UI64LIT(0x0000000000000004) // 2 +#define PLAYER_TITLE_SERGEANT_A UI64LIT(0x0000000000000008) // 3 +#define PLAYER_TITLE_MASTER_SERGEANT UI64LIT(0x0000000000000010) // 4 +#define PLAYER_TITLE_SERGEANT_MAJOR UI64LIT(0x0000000000000020) // 5 +#define PLAYER_TITLE_KNIGHT UI64LIT(0x0000000000000040) // 6 +#define PLAYER_TITLE_KNIGHT_LIEUTENANT UI64LIT(0x0000000000000080) // 7 +#define PLAYER_TITLE_KNIGHT_CAPTAIN UI64LIT(0x0000000000000100) // 8 +#define PLAYER_TITLE_KNIGHT_CHAMPION UI64LIT(0x0000000000000200) // 9 +#define PLAYER_TITLE_LIEUTENANT_COMMANDER UI64LIT(0x0000000000000400) // 10 +#define PLAYER_TITLE_COMMANDER UI64LIT(0x0000000000000800) // 11 +#define PLAYER_TITLE_MARSHAL UI64LIT(0x0000000000001000) // 12 +#define PLAYER_TITLE_FIELD_MARSHAL UI64LIT(0x0000000000002000) // 13 +#define PLAYER_TITLE_GRAND_MARSHAL UI64LIT(0x0000000000004000) // 14 +#define PLAYER_TITLE_SCOUT UI64LIT(0x0000000000008000) // 15 +#define PLAYER_TITLE_GRUNT UI64LIT(0x0000000000010000) // 16 +#define PLAYER_TITLE_SERGEANT_H UI64LIT(0x0000000000020000) // 17 +#define PLAYER_TITLE_SENIOR_SERGEANT UI64LIT(0x0000000000040000) // 18 +#define PLAYER_TITLE_FIRST_SERGEANT UI64LIT(0x0000000000080000) // 19 +#define PLAYER_TITLE_STONE_GUARD UI64LIT(0x0000000000100000) // 20 +#define PLAYER_TITLE_BLOOD_GUARD UI64LIT(0x0000000000200000) // 21 +#define PLAYER_TITLE_LEGIONNAIRE UI64LIT(0x0000000000400000) // 22 +#define PLAYER_TITLE_CENTURION UI64LIT(0x0000000000800000) // 23 +#define PLAYER_TITLE_CHAMPION UI64LIT(0x0000000001000000) // 24 +#define PLAYER_TITLE_LIEUTENANT_GENERAL UI64LIT(0x0000000002000000) // 25 +#define PLAYER_TITLE_GENERAL UI64LIT(0x0000000004000000) // 26 +#define PLAYER_TITLE_WARLORD UI64LIT(0x0000000008000000) // 27 +#define PLAYER_TITLE_HIGH_WARLORD UI64LIT(0x0000000010000000) // 28 +#define PLAYER_TITLE_GLADIATOR UI64LIT(0x0000000020000000) // 29 +#define PLAYER_TITLE_DUELIST UI64LIT(0x0000000040000000) // 30 +#define PLAYER_TITLE_RIVAL UI64LIT(0x0000000080000000) // 31 +#define PLAYER_TITLE_CHALLENGER UI64LIT(0x0000000100000000) // 32 +#define PLAYER_TITLE_SCARAB_LORD UI64LIT(0x0000000200000000) // 33 +#define PLAYER_TITLE_CONQUEROR UI64LIT(0x0000000400000000) // 34 +#define PLAYER_TITLE_JUSTICAR UI64LIT(0x0000000800000000) // 35 +#define PLAYER_TITLE_CHAMPION_OF_THE_NAARU UI64LIT(0x0000001000000000) // 36 +#define PLAYER_TITLE_MERCILESS_GLADIATOR UI64LIT(0x0000002000000000) // 37 +#define PLAYER_TITLE_OF_THE_SHATTERED_SUN UI64LIT(0x0000004000000000) // 38 +#define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39 +#define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40 // used in PLAYER_FIELD_BYTES values enum PlayerFieldByteFlags @@ -1363,7 +1382,7 @@ class TRINITY_DLL_SPEC Player : public Unit uint32 GetGlyph(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot); } uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } - void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); } + void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); } void InitPrimaryProffesions(); PlayerSpellMap const& GetSpellMap() const { return m_spells; } diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index bdb02913f59..e5782fcb8df 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -181,10 +181,10 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty data << SubName; data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0 - data << uint32(ci->type_flags); // flags wdbFeild7=wad flags1 - data << uint32(ci->type); - data << uint32(ci->family); // family wdbFeild9 - data << uint32(ci->rank); // rank wdbFeild10 + data << uint32(ci->type_flags); // flags + data << uint32(ci->type); // CreatureType.dbc + data << uint32(ci->family); // CreatureFamily.dbc + data << uint32(ci->rank); // Creature Rank (elite, boss, etc) data << uint32(ci->PetSpellDataId); // Id from CreatureSpellData.dbc wdbField12 data << (uint32)ci->Modelid_A1; // Modelid_A1 data << (uint32)ci->Modelid_A2; // Modelid_A2 @@ -193,7 +193,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) data << float(ci->unk17); // unk data << uint8(ci->RacialLeader); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" ); } else { @@ -205,7 +205,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 ); data << uint32(entry | 0x80000000); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" ); } } @@ -220,7 +220,6 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) const GameObjectInfo *info = objmgr.GetGameObjectInfo(entryID); if(info) { - std::string Name; std::string IconName; std::string CastBarCaption; @@ -254,7 +253,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) data.append(info->raw.data, 24); data << float(info->size); // go size SendPacket( &data ); - sLog.outDebug( "WORLD: Sent CMSG_GAMEOBJECT_QUERY " ); + sLog.outDebug( "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE" ); } else { @@ -267,7 +266,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 4 ); data << uint32(entryID | 0x80000000); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent CMSG_GAMEOBJECT_QUERY " ); + sLog.outDebug( "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE" ); } } @@ -319,7 +318,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8); + CHECK_PACKET_SIZE(recv_data, 4 + 8); uint32 textID; uint64 guid; @@ -354,7 +353,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) else { std::string Text_0[8], Text_1[8]; - for (int i=0;i<8;++i) + for (int i = 0; i < 8; ++i) { Text_0[i]=pGossip->Options[i].Text_0; Text_1[i]=pGossip->Options[i].Text_1; @@ -366,7 +365,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textID); if (nl) { - for (int i=0;i<8;++i) + for (int i = 0; i < 8; ++i) { if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty()) Text_0[i]=nl->Text_0[i][loc_idx]; @@ -376,7 +375,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) } } - for (int i=0; i<8; ++i) + for (int i = 0; i < 8; ++i) { data << pGossip->Options[i].Probability; @@ -402,12 +401,12 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); + sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE" ); } -void WorldSession::HandlePageQueryOpcode( WorldPacket & recv_data ) +void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4); + CHECK_PACKET_SIZE(recv_data, 4); uint32 pageID; @@ -448,7 +447,7 @@ void WorldSession::HandlePageQueryOpcode( WorldPacket & recv_data ) } SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE" ); } } diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index bc3f2a8fb37..74839bac1c3 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -114,7 +114,7 @@ void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); + CHECK_PACKET_SIZE(recv_data, 8+4); uint64 guid; uint32 quest; @@ -123,7 +123,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) if(!GetPlayer()->isAlive()) return; - sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %u, quest = %u",uint32(GUID_LOPART(guid)),quest ); + sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %u, quest = %u", uint32(GUID_LOPART(guid)), quest ); Object* pObject = ObjectAccessor::GetObjectByTypeMask(*_player, guid,TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT|TYPEMASK_ITEM|TYPEMASK_PLAYER); @@ -208,14 +208,14 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) _player->PlayerTalkClass->CloseGossip(); } -void WorldSession::HandleQuestgiverQuestQueryOpcode( WorldPacket & recv_data ) +void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); + CHECK_PACKET_SIZE(recv_data, 8+4); uint64 guid; uint32 quest; recv_data >> guid >> quest; - sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u",uint32(GUID_LOPART(guid)),quest ); + sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u", uint32(GUID_LOPART(guid)), quest ); // Verify that the guid is valid and is a questgiver or involved in the requested quest Object* pObject = ObjectAccessor::GetObjectByTypeMask(*_player, guid,TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT|TYPEMASK_ITEM); @@ -389,7 +389,7 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) sLog.outDebug( "WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT quest = %u",quest ); } -void WorldSession::HandleQuestComplete(WorldPacket& recv_data) +void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) { CHECK_PACKET_SIZE(recv_data,8+4); @@ -423,12 +423,12 @@ void WorldSession::HandleQuestComplete(WorldPacket& recv_data) } } -void WorldSession::HandleQuestAutoLaunch(WorldPacket& /*recvPacket*/) +void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/) { - sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_QUEST_AUTOLAUNCH (Send your log to anakin if you see this message)" ); + sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_QUEST_AUTOLAUNCH" ); } -void WorldSession::HandleQuestPushToParty(WorldPacket& recvPacket) +void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket,4); @@ -604,7 +604,7 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32 return result; } -void WorldSession::HandleQuestgiverStatusQueryMultipleOpcode(WorldPacket& /*recvPacket*/) +void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/) { sLog.outDebug("WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index 2e1f09aaf5a..950fc985173 100644 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -38,7 +38,7 @@ void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data ) _player->LearnTalent(talent_id, requested_rank); } -void WorldSession::HandleTalentWipeOpcode( WorldPacket & recv_data ) +void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8); @@ -49,7 +49,7 @@ void WorldSession::HandleTalentWipeOpcode( WorldPacket & recv_data ) Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER); if (!unit) { - sLog.outDebug( "WORLD: HandleTalentWipeOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + sLog.outDebug( "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); return; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 299aac060ae..d04d4ab58fd 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -49,7 +49,7 @@ #include "Util.h" #include "TemporarySummon.h" -#define SPELL_CHANNEL_UPDATE_INTERVAL (1*IN_MILISECONDS) +#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILISECONDS) extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS]; @@ -212,11 +212,11 @@ void SpellCastTargets::Update(Unit* caster) { m_GOTarget = m_GOTargetGUID ? caster->GetMap()->GetGameObject(m_GOTargetGUID) : NULL; m_unitTarget = m_unitTargetGUID ? - ( m_unitTargetGUID==caster->GetGUID() ? caster : ObjectAccessor::GetUnit(*caster, m_unitTargetGUID) ) : + ( m_unitTargetGUID == caster->GetGUID() ? caster : ObjectAccessor::GetUnit(*caster, m_unitTargetGUID) ) : NULL; m_itemTarget = NULL; - if(caster->GetTypeId()==TYPEID_PLAYER) + if(caster->GetTypeId() == TYPEID_PLAYER) { if(m_targetMask & TARGET_FLAG_ITEM) m_itemTarget = ((Player*)caster)->GetItemByGuid(m_itemTargetGUID); @@ -234,7 +234,7 @@ void SpellCastTargets::Update(Unit* caster) bool SpellCastTargets::read ( WorldPacket * data, Unit *caster ) { - if(data->rpos()+4 > data->size()) + if(data->rpos() + 4 > data->size()) return false; //data->hexlike(); @@ -264,7 +264,7 @@ bool SpellCastTargets::read ( WorldPacket * data, Unit *caster ) if( m_targetMask & TARGET_FLAG_SOURCE_LOCATION ) { - if(data->rpos()+4+4+4 > data->size()) + if(data->rpos() + 4 + 4 + 4 > data->size()) return false; *data >> m_srcX >> m_srcY >> m_srcZ; @@ -274,7 +274,7 @@ bool SpellCastTargets::read ( WorldPacket * data, Unit *caster ) if( m_targetMask & TARGET_FLAG_DEST_LOCATION ) { - if(data->rpos()+1+4+4+4 > data->size()) + if(data->rpos() + 1 + 4 + 4 + 4 > data->size()) return false; if(!data->readPackGUID(m_unitTargetGUID)) @@ -287,7 +287,7 @@ bool SpellCastTargets::read ( WorldPacket * data, Unit *caster ) if( m_targetMask & TARGET_FLAG_STRING ) { - if(data->rpos()+1 > data->size()) + if(data->rpos() + 1 > data->size()) return false; *data >> m_strTarget; @@ -395,7 +395,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi if(m_attackType == RANGED_ATTACK) { // wand case - if((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId()==TYPEID_PLAYER) + if((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId() == TYPEID_PLAYER) { if(Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK)) m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetProto()->Damage[0].DamageType); @@ -409,11 +409,11 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi else m_originalCasterGUID = m_caster->GetGUID(); - if(m_originalCasterGUID==m_caster->GetGUID()) + if(m_originalCasterGUID == m_caster->GetGUID()) m_originalCaster = m_caster; else { - m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID); + m_originalCaster = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID); if(m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL; } @@ -453,12 +453,12 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(m_spellInfo->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED)) { - for(int j=0;j<3;j++) + for(int j = 0;j < 3; ++j) { - if (m_spellInfo->Effect[j]==0) + if (m_spellInfo->Effect[j] == 0) continue; - if(!IsPositiveTarget(m_spellInfo->EffectImplicitTargetA[j],m_spellInfo->EffectImplicitTargetB[j])) + if(!IsPositiveTarget(m_spellInfo->EffectImplicitTargetA[j], m_spellInfo->EffectImplicitTargetB[j])) m_canReflect = true; else m_canReflect = (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NEGATIVE) ? true : false; @@ -586,8 +586,8 @@ void Spell::FillTargetMap() else { // clear cooldown at fail - if(m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true); + if(m_caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id, true); SendCastResult(SPELL_FAILED_NO_EDIBLE_CORPSES); finish(false); } @@ -631,7 +631,7 @@ void Spell::FillTargetMap() AddUnitTarget(m_targets.getUnitTarget(), i); if(m_targets.getCorpseTargetGUID()) { - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); + Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.getCorpseTargetGUID()); if(corpse) { Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); @@ -813,7 +813,7 @@ void Spell::CleanupTargetList() void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) { - if( m_spellInfo->Effect[effIndex]==0 ) + if( m_spellInfo->Effect[effIndex] == 0 ) return; if(!CheckTarget(pVictim, effIndex)) @@ -825,12 +825,12 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) uint64 targetGUID = pVictim->GetGUID(); // Lookup target in already in list - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if (targetGUID == ihit->targetGUID) // Found in list { if (!immuned) - ihit->effectMask |= 1<<effIndex; // Add only effect mask if not immuned + ihit->effectMask |= 1 << effIndex; // Add only effect mask if not immuned return; } } @@ -840,7 +840,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) // Get spell hit result on target TargetInfo target; target.targetGUID = targetGUID; // Store target GUID - target.effectMask = immuned ? 0 : 1<<effIndex; // Store index of effect if not immuned + target.effectMask = immuned ? 0 : 1 << effIndex; // Store index of effect if not immuned target.processed = false; // Effects not apply on target target.alive = pVictim->isAlive(); target.damage = 0; @@ -866,14 +866,14 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) target.timeDelay = (uint64) floor(dist / m_spellInfo->speed * 1000.0f); // Calculate minimum incoming time - if (m_delayMoment==0 || m_delayMoment>target.timeDelay) + if (m_delayMoment == 0 || m_delayMoment>target.timeDelay) m_delayMoment = target.timeDelay; } else target.timeDelay = 0LL; // If target reflect spell back to caster - if (target.missCondition==SPELL_MISS_REFLECT) + if (target.missCondition == SPELL_MISS_REFLECT) { // Calculate reflected spell result on caster target.reflectResult = m_caster->SpellHitResult(m_caster, m_spellInfo, m_canReflect); @@ -882,7 +882,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) target.reflectResult = SPELL_MISS_PARRY; // Increase time interval for reflected spells by 1.5 - target.timeDelay+=target.timeDelay>>1; + target.timeDelay += target.timeDelay >> 1; } else target.reflectResult = SPELL_MISS_NONE; @@ -893,24 +893,24 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) void Spell::AddUnitTarget(uint64 unitGUID, uint32 effIndex) { - Unit* unit = m_caster->GetGUID()==unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID); + Unit* unit = m_caster->GetGUID() == unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID); if (unit) AddUnitTarget(unit, effIndex); } void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) { - if( m_spellInfo->Effect[effIndex]==0 ) + if( m_spellInfo->Effect[effIndex] == 0 ) return; uint64 targetGUID = pVictim->GetGUID(); // Lookup target in already in list - for(std::list<GOTargetInfo>::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) + for(std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit) { if (targetGUID == ihit->targetGUID) // Found in list { - ihit->effectMask |= 1<<effIndex; // Add only effect mask + ihit->effectMask |= 1 << effIndex; // Add only effect mask return; } } @@ -919,7 +919,7 @@ void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) GOTargetInfo target; target.targetGUID = targetGUID; - target.effectMask = 1<<effIndex; + target.effectMask = 1 << effIndex; target.processed = false; // Effects not apply on target // Spell have speed - need calculate incoming time @@ -948,11 +948,11 @@ void Spell::AddGOTarget(uint64 goGUID, uint32 effIndex) void Spell::AddItemTarget(Item* pitem, uint32 effIndex) { - if( m_spellInfo->Effect[effIndex]==0 ) + if( m_spellInfo->Effect[effIndex] == 0 ) return; // Lookup target in already in list - for(std::list<ItemTargetInfo>::iterator ihit= m_UniqueItemInfo.begin();ihit != m_UniqueItemInfo.end();++ihit) + for(std::list<ItemTargetInfo>::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit) { if (pitem == ihit->item) // Found in list { @@ -965,7 +965,7 @@ void Spell::AddItemTarget(Item* pitem, uint32 effIndex) ItemTargetInfo target; target.item = pitem; - target.effectMask = 1<<effIndex; + target.effectMask = 1 << effIndex; m_UniqueItemInfo.push_back(target); } @@ -1178,7 +1178,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if( !m_caster->IsFriendlyTo(unit) ) { // for delayed spells ignore not visible explicit target - if(m_spellInfo->speed > 0.0f && unit==m_targets.getUnitTarget() && !unit->isVisibleForOrDetect(m_caster,false)) + if(m_spellInfo->speed > 0.0f && unit == m_targets.getUnitTarget() && !unit->isVisibleForOrDetect(m_caster,false)) { return SPELL_MISS_EVADE; } @@ -1376,9 +1376,9 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target) if(!go) return; - for(uint32 effectNumber=0;effectNumber<3;effectNumber++) - if (effectMask & (1<<effectNumber)) - HandleEffects(NULL,NULL,go,effectNumber); + for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber) + if (effectMask & (1 << effectNumber)) + HandleEffects(NULL, NULL, go, effectNumber); // cast at creature (or GO) quest objectives update at successful cast finished (+channel finished) // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) @@ -1395,8 +1395,8 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo *target) if(!target->item || !effectMask) return; - for(uint32 effectNumber=0;effectNumber<3;effectNumber++) - if (effectMask & (1<<effectNumber)) + for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber) + if (effectMask & (1 << effectNumber)) HandleEffects(NULL, target->item, NULL, effectNumber); } @@ -1414,11 +1414,11 @@ bool Spell::UpdateChanneledTargetList() needAuraMask &= needAliveTargetMask; - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if( ihit->missCondition == SPELL_MISS_NONE && (needAliveTargetMask & ihit->effectMask) ) { - Unit *unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + Unit *unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if (unit && unit->isAlive()) { @@ -1446,7 +1446,7 @@ bool Spell::UpdateChanneledTargetList() } // is all effects from m_needAliveTargetMask have alive targets - return needAliveTargetMask==0; + return needAliveTargetMask == 0; } // Helper for Chain Healing @@ -2769,15 +2769,15 @@ void Spell::_handle_immediate_phase() HandleThreatSpells(m_spellInfo->Id); m_needSpellLog = IsNeedSendToClient(); - for(uint32 j = 0;j<3;j++) + for(uint32 j = 0; j < 3; ++j) { - if(m_spellInfo->Effect[j]==0) + if(m_spellInfo->Effect[j] == 0) continue; // apply Send Event effect to ground in case empty target lists if( m_spellInfo->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(j) ) { - HandleEffects(NULL,NULL,NULL, j); + HandleEffects(NULL, NULL, NULL, j); continue; } @@ -2927,20 +2927,20 @@ void Spell::update(uint32 difftime) { if ( Player* p = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself() ) { - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { TargetInfo* target = &*ihit; if(!IS_CREATURE_GUID(target->targetGUID)) continue; - Unit* unit = m_caster->GetGUID()==target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster,target->targetGUID); - if (unit==NULL) + Unit* unit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); + if (unit == NULL) continue; - p->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); + p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), m_spellInfo->Id); } - for(std::list<GOTargetInfo>::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) + for(std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit) { GOTargetInfo* target = &*ihit; @@ -2948,7 +2948,7 @@ void Spell::update(uint32 difftime) if(!go) continue; - p->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); + p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), m_spellInfo->Id); } } } @@ -3301,33 +3301,35 @@ void Spell::WriteSpellGoTargets( WorldPacket * data ) // m_needAliveTargetMask req for stop channelig if one target die uint32 hit = m_UniqueGOTargetInfo.size(); // Always hits on GO uint32 miss = 0; - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if ((*ihit).effectMask == 0) // No effect apply - all immuned add state { // possibly SPELL_MISS_IMMUNE2 for this?? ihit->missCondition = SPELL_MISS_IMMUNE2; - miss++; + ++miss; } else if ((*ihit).missCondition == SPELL_MISS_NONE) - hit++; + ++hit; else - miss++; + ++miss; } *data << (uint8)hit; - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) + { if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits { *data << uint64(ihit->targetGUID); m_needAliveTargetMask |=ihit->effectMask; } + } - for(std::list<GOTargetInfo>::iterator ighit= m_UniqueGOTargetInfo.begin();ighit != m_UniqueGOTargetInfo.end();++ighit) + for(std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit) *data << uint64(ighit->targetGUID); // Always hits *data << (uint8)miss; - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if( ihit->missCondition != SPELL_MISS_NONE ) // Add only miss { @@ -3472,8 +3474,8 @@ void Spell::SendChannelUpdate(uint32 time) { if(time == 0) { - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,0); - m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL,0); + m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0); + m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); } if (m_caster->GetTypeId() != TYPEID_PLAYER) @@ -3493,9 +3495,9 @@ void Spell::SendChannelStart(uint32 duration) // select first not resisted target from target list for _0_ effect if(!m_UniqueTargetInfo.empty()) { - for(std::list<TargetInfo>::iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) + for(std::list<TargetInfo>::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) { - if( (itr->effectMask & (1<<0)) && itr->reflectResult==SPELL_MISS_NONE && itr->targetGUID != m_caster->GetGUID()) + if( (itr->effectMask & (1 << 0)) && itr->reflectResult == SPELL_MISS_NONE && itr->targetGUID != m_caster->GetGUID()) { target = ObjectAccessor::GetUnit(*m_caster, itr->targetGUID); break; @@ -3504,9 +3506,9 @@ void Spell::SendChannelStart(uint32 duration) } else if(!m_UniqueGOTargetInfo.empty()) { - for(std::list<GOTargetInfo>::iterator itr= m_UniqueGOTargetInfo.begin();itr != m_UniqueGOTargetInfo.end();++itr) + for(std::list<GOTargetInfo>::const_iterator itr = m_UniqueGOTargetInfo.begin(); itr != m_UniqueGOTargetInfo.end(); ++itr) { - if(itr->effectMask & (1<<0) ) + if(itr->effectMask & (1 << 0) ) { target = m_caster->GetMap()->GetGameObject(itr->targetGUID); break; @@ -3535,16 +3537,16 @@ void Spell::SendResurrectRequest(Player* target) // Both players and NPCs can resurrect using spells - have a look at creature 28487 for example // However, the packet structure differs slightly - const char* sentName = m_caster->GetTypeId()==TYPEID_PLAYER ?"":m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()); + const char* sentName = m_caster->GetTypeId() == TYPEID_PLAYER ? "" : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()); WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+strlen(sentName)+1+1+1)); data << uint64(m_caster->GetGUID()); - data << uint32(strlen(sentName)+1); + data << uint32(strlen(sentName) + 1); data << sentName; data << uint8(0); - data << uint8(m_caster->GetTypeId()==TYPEID_PLAYER ?0:1); + data << uint8(m_caster->GetTypeId() == TYPEID_PLAYER ? 0 : 1); target->GetSession()->SendPacket(&data); } @@ -3553,7 +3555,7 @@ void Spell::SendPlaySpellVisual(uint32 SpellID) if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); + WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); data << uint64(m_caster->GetGUID()); data << uint32(SpellID); // spell visual id? ((Player*)m_caster)->GetSession()->SendPacket(&data); @@ -3826,7 +3828,7 @@ void Spell::TakeReagents() if (p_caster->CanNoReagentCast(m_spellInfo)) return; - for(uint32 x=0;x<8;x++) + for(uint32 x = 0; x < 8; ++x) { if(m_spellInfo->Reagent[x] <= 0) continue; @@ -3840,7 +3842,7 @@ void Spell::TakeReagents() ItemPrototype const *proto = m_CastItem->GetProto(); if( proto && proto->ItemId == itemid ) { - for(int s=0;s < MAX_ITEM_PROTO_SPELLS; ++s) + for(int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s) { // CastItem will be used up and does not count as reagent int32 charges = m_CastItem->GetSpellCharges(s); @@ -3856,7 +3858,7 @@ void Spell::TakeReagents() } // if getItemTarget is also spell reagent - if (m_targets.getItemTargetEntry()==itemid) + if (m_targets.getItemTargetEntry() == itemid) m_targets.setItemTarget(NULL); p_caster->DestroyItemCount(itemid, itemcount, true); @@ -4034,7 +4036,7 @@ SpellCastResult Spell::CheckCast(bool strict) if(target->getLevel() + 10 < m_spellInfo->spellLevel) return SPELL_FAILED_LOWLEVEL; } - else if (m_caster->GetTypeId()==TYPEID_PLAYER) // Target - is player caster + else if (m_caster->GetTypeId() == TYPEID_PLAYER) // Target - is player caster { // Additional check for some spells // If 0 spell effect empty - client not send target data (need use selection) @@ -4050,7 +4052,7 @@ SpellCastResult Spell::CheckCast(bool strict) } // check pet presents - for(int j=0;j<3;j++) + for(int j = 0; j < 3; ++j) { if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_UNIT_PET) { @@ -4072,7 +4074,7 @@ SpellCastResult Spell::CheckCast(bool strict) { if(!CheckTargetCreatureType(target)) { - if(target->GetTypeId()==TYPEID_PLAYER) + if(target->GetTypeId() == TYPEID_PLAYER) return SPELL_FAILED_TARGET_IS_PLAYER; else return SPELL_FAILED_BAD_TARGETS; @@ -4081,7 +4083,7 @@ SpellCastResult Spell::CheckCast(bool strict) // TODO: this check can be applied and for player to prevent cheating when IsPositiveSpell will return always correct result. // check target for pet/charmed casts (not self targeted), self targeted cast used for area effects and etc - if(m_caster != target && m_caster->GetTypeId()==TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID()) + if(m_caster != target && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID()) { // check correctness positive/negative cast target (pet cast real check and cheating check) if(IsPositiveSpell(m_spellInfo->Id)) @@ -4125,7 +4127,7 @@ SpellCastResult Spell::CheckCast(bool strict) } // Spell casted only on battleground - if((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId()==TYPEID_PLAYER) + if((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId() == TYPEID_PLAYER) if(!((Player*)m_caster)->InBattleGround()) return SPELL_FAILED_ONLY_BATTLEGROUNDS; @@ -4171,7 +4173,7 @@ SpellCastResult Spell::CheckCast(bool strict) /*//ImpliciteTargetA-B = 38, If fact there is 0 Spell with ImpliciteTargetB=38 if(m_UniqueTargetInfo.empty()) // skip second CheckCast apply (for delayed spells for example) { - for(uint8 j = 0; j < 3; j++) + for(uint8 j = 0; j < 3; ++j) { if( m_spellInfo->EffectImplicitTargetA[j] == TARGET_UNIT_NEARBY_ENTRY || m_spellInfo->EffectImplicitTargetB[j] == TARGET_UNIT_NEARBY_ENTRY && m_spellInfo->EffectImplicitTargetA[j] != TARGET_UNIT_CASTER || @@ -4218,7 +4220,7 @@ SpellCastResult Spell::CheckCast(bool strict) range = go_check.GetLastRange(); } } - else if( focusObject ) //Focus Object + else if( focusObject ) // Focus Object { float frange = m_caster->GetDistance(focusObject); if(range >= frange) @@ -4330,7 +4332,7 @@ SpellCastResult Spell::CheckCast(bool strict) if(m_caster->IsInWater()) return SPELL_FAILED_ONLY_ABOVEWATER; } - else if(m_spellInfo->SpellIconID==156) // Holy Shock + else if(m_spellInfo->SpellIconID == 156) // Holy Shock { // spell different for friends and enemies // hart version required facing @@ -4418,7 +4420,7 @@ SpellCastResult Spell::CheckCast(bool strict) // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects) if(m_caster->GetTypeId() == TYPEID_PLAYER) if(Unit* target = m_targets.getUnitTarget()) - if(target!=m_caster && target->getPowerType()!=m_spellInfo->EffectMiscValue[i]) + if(target != m_caster && target->getPowerType() != m_spellInfo->EffectMiscValue[i]) return SPELL_FAILED_BAD_TARGETS; break; } @@ -4447,14 +4449,14 @@ SpellCastResult Spell::CheckCast(bool strict) int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill); int32 TargetLevel = m_targets.getUnitTarget()->getLevel(); - int32 ReqValue = (skillValue < 100 ? (TargetLevel-10)*10 : TargetLevel*5); + int32 ReqValue = (skillValue < 100 ? (TargetLevel-10) * 10 : TargetLevel * 5); if (ReqValue > skillValue) return SPELL_FAILED_LOW_CASTLEVEL; // chance for fail at orange skinning attempt if( (m_selfContainer && (*m_selfContainer) == this) && skillValue < sWorld.GetConfigMaxSkillValue() && - (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue-25, skillValue+37) ) + (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue - 25, skillValue + 37) ) return SPELL_FAILED_TRY_AGAIN; break; @@ -4481,17 +4483,17 @@ SpellCastResult Spell::CheckCast(bool strict) // get the lock entry uint32 lockId = 0; - if (GameObject* go=m_targets.getGOTarget()) + if (GameObject* go = m_targets.getGOTarget()) lockId = go->GetLockId(); - else if(Item* itm=m_targets.getItemTarget()) + else if(Item* itm = m_targets.getItemTarget()) lockId = itm->GetProto()->LockID; - SkillType skillId =SKILL_NONE; + SkillType skillId = SKILL_NONE; int32 reqSkillValue = 0; int32 skillValue = 0; // check lock compatibility - SpellCastResult res = CanOpenLock(i,lockId,skillId,reqSkillValue,skillValue); + SpellCastResult res = CanOpenLock(i, lockId, skillId, reqSkillValue, skillValue); if(res != SPELL_CAST_OK) return res; @@ -4502,7 +4504,7 @@ SpellCastResult Spell::CheckCast(bool strict) bool canFailAtMax = skillId != SKILL_HERBALISM && skillId != SKILL_MINING; // chance for failure in orange gather / lockpick (gathering skill can't fail at maxskill) - if((canFailAtMax || skillValue < sWorld.GetConfigMaxSkillValue()) && reqSkillValue > irand(skillValue-25, skillValue+37)) + if((canFailAtMax || skillValue < sWorld.GetConfigMaxSkillValue()) && reqSkillValue > irand(skillValue - 25, skillValue + 37)) return SPELL_FAILED_TRY_AGAIN; } break; @@ -4568,13 +4570,13 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_SUMMON_PLAYER: { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if(m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_BAD_TARGETS; if(!((Player*)m_caster)->GetSelection()) return SPELL_FAILED_BAD_TARGETS; Player* target = objmgr.GetPlayer(((Player*)m_caster)->GetSelection()); - if( !target || ((Player*)m_caster)==target || !target->IsInSameRaidWith((Player*)m_caster) ) + if( !target || ((Player*)m_caster) == target || !target->IsInSameRaidWith((Player*)m_caster) ) return SPELL_FAILED_BAD_TARGETS; // check if our map is dungeon @@ -4600,7 +4602,7 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_STEAL_BENEFICIAL_BUFF: { - if (m_targets.getUnitTarget()==m_caster) + if (m_targets.getUnitTarget() == m_caster) return SPELL_FAILED_BAD_TARGETS; break; } @@ -4618,7 +4620,7 @@ SpellCastResult Spell::CheckCast(bool strict) switch(m_spellInfo->Id) { case 61336: - if(m_caster->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_caster)->IsInFeralForm()) + if(m_caster->GetTypeId() != TYPEID_PLAYER || !((Player*)m_caster)->IsInFeralForm()) return SPELL_FAILED_ONLY_SHAPESHIFT; break; case 1515: @@ -4674,11 +4676,11 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->IsInWater()) return SPELL_FAILED_ONLY_ABOVEWATER; - if (m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetTransport()) + if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->GetTransport()) return SPELL_FAILED_NO_MOUNTS_ALLOWED; // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells - if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaGroupId) + if (m_caster->GetTypeId() == TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaGroupId) return SPELL_FAILED_NO_MOUNTS_ALLOWED; ShapeshiftForm form = m_caster->m_form; @@ -4717,10 +4719,10 @@ SpellCastResult Spell::CheckCast(bool strict) if (!m_targets.getUnitTarget()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - if (m_caster->GetTypeId()!=TYPEID_PLAYER || m_CastItem) + if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem) break; - if(m_targets.getUnitTarget()->getPowerType()!=POWER_MANA) + if(m_targets.getUnitTarget()->getPowerType() != POWER_MANA) return SPELL_FAILED_BAD_TARGETS; break; @@ -4786,18 +4788,18 @@ SpellCastResult Spell::CheckCasterAuras() const // Flag drop spells totally immuned to caster auras // FIXME: find more nice check for all totally immuned spells // AttributesEx3 & 0x10000000? - if(m_spellInfo->Id==23336 || m_spellInfo->Id==23334 || m_spellInfo->Id==34991) + if(m_spellInfo->Id == 23336 || m_spellInfo->Id == 23334 || m_spellInfo->Id == 34991) return SPELL_CAST_OK; uint8 school_immune = 0; uint32 mechanic_immune = 0; uint32 dispel_immune = 0; - //Check if the spell grants school or mechanic immunity. - //We use bitmasks so the loop is done only once and not on every aura check below. + // Check if the spell grants school or mechanic immunity. + // We use bitmasks so the loop is done only once and not on every aura check below. if ( m_spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY ) { - for(int i = 0;i < 3; i ++) + for(int i = 0; i < 3; ++i) { if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); @@ -4811,7 +4813,7 @@ SpellCastResult Spell::CheckCasterAuras() const mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; } - //Check whether the cast should be prevented by any state you might have. + // Check whether the cast should be prevented by any state you might have. SpellCastResult prevented_reason = SPELL_CAST_OK; // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state @@ -4821,9 +4823,9 @@ SpellCastResult Spell::CheckCasterAuras() const prevented_reason = SPELL_FAILED_CONFUSED; else if(unitflag & UNIT_FLAG_FLEEING && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) prevented_reason = SPELL_FAILED_FLEEING; - else if(unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) + else if(unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) prevented_reason = SPELL_FAILED_SILENCED; - else if(unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) + else if(unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY) prevented_reason = SPELL_FAILED_PACIFIED; // Attr must make flag drop spell totally immune from all effects @@ -4878,7 +4880,7 @@ SpellCastResult Spell::CheckCasterAuras() const } } } - //You are prevented from casting and the spell casted does not grant immunity. Return a failed error. + // You are prevented from casting and the spell casted does not grant immunity. Return a failed error. else return prevented_reason; } @@ -4889,7 +4891,7 @@ bool Spell::CanAutoCast(Unit* target) { uint64 targetguid = target->GetGUID(); - for(uint32 j = 0;j<3;j++) + for(uint32 j = 0; j < 3; ++j) { if(m_spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA) { @@ -4975,9 +4977,9 @@ SpellCastResult Spell::CheckRange(bool strict) if(m_targets.m_targetMask == TARGET_FLAG_DEST_LOCATION && m_targets.m_destX != 0 && m_targets.m_destY != 0 && m_targets.m_destZ != 0) { - if(!m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ,max_range)) + if(!m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, max_range)) return SPELL_FAILED_OUT_OF_RANGE; - if(m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ,min_range)) + if(m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, min_range)) return SPELL_FAILED_TOO_CLOSE; } @@ -5099,16 +5101,16 @@ SpellCastResult Spell::CheckItems() else { uint32 itemid = m_CastItem->GetEntry(); - if( !p_caster->HasItemCount(itemid,1) ) + if( !p_caster->HasItemCount(itemid, 1) ) return SPELL_FAILED_ITEM_NOT_READY; ItemPrototype const *proto = m_CastItem->GetProto(); if(!proto) return SPELL_FAILED_ITEM_NOT_READY; - for (int i = 0; i<5; i++) + for (int i = 0; i < 5; ++i) if (proto->Spells[i].SpellCharges) - if(m_CastItem->GetSpellCharges(i)==0) + if(m_CastItem->GetSpellCharges(i) == 0) return SPELL_FAILED_NO_CHARGES_REMAIN; // consumable cast item checks @@ -5191,7 +5193,7 @@ SpellCastResult Spell::CheckItems() GameObject* ok = NULL; MaNGOS::GameObjectFocusCheck go_check(m_caster,m_spellInfo->RequiresSpellFocus); - MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck> checker(m_caster,ok,go_check); + MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck> checker(m_caster, ok, go_check); TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck>, GridTypeMapContainer > object_checker(checker); CellLock<GridReadGuard> cell_lock(cell, p); @@ -5241,7 +5243,7 @@ SpellCastResult Spell::CheckItems() // check totem-item requirements (items presence in inventory) uint32 totems = 2; - for(int i=0;i<2;++i) + for(int i = 0; i < 2 ; ++i) { if(m_spellInfo->Totem[i] != 0) { @@ -5258,7 +5260,7 @@ SpellCastResult Spell::CheckItems() // Check items for TotemCategory (items presence in inventory) uint32 TotemCategory = 2; - for(int i=0;i<2;++i) + for(int i= 0; i < 2; ++i) { if(m_spellInfo->TotemCategory[i] != 0) { @@ -5470,11 +5472,11 @@ SpellCastResult Spell::CheckItems() { case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: - if(ammoProto->SubClass!=ITEM_SUBCLASS_ARROW) + if(ammoProto->SubClass != ITEM_SUBCLASS_ARROW) return SPELL_FAILED_NO_AMMO; break; case ITEM_SUBCLASS_WEAPON_GUN: - if(ammoProto->SubClass!=ITEM_SUBCLASS_BULLET) + if(ammoProto->SubClass != ITEM_SUBCLASS_BULLET) return SPELL_FAILED_NO_AMMO; break; default: @@ -5485,6 +5487,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_NO_AMMO; }; break; case ITEM_SUBCLASS_WEAPON_WAND: + break; default: break; } @@ -5547,7 +5550,7 @@ void Spell::Delayed() // only called in DealDamage() //check pushback reduce int32 delaytime = 500; // spellcasting delay is normally 500ms int32 delayReduce = 100; // must be initialized to 100 for percent modifiers - ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id,SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); + ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if(delayReduce >= 100) return; @@ -5562,13 +5565,13 @@ void Spell::Delayed() // only called in DealDamage() else m_timer += delaytime; - sLog.outDetail("Spell %u partially interrupted for (%d) ms at damage",m_spellInfo->Id,delaytime); + sLog.outDetail("Spell %u partially interrupted for (%d) ms at damage", m_spellInfo->Id, delaytime); WorldPacket data(SMSG_SPELL_DELAYED, 8+4); data.append(m_caster->GetPackGUID()); data << uint32(delaytime); - m_caster->SendMessageToSet(&data,true); + m_caster->SendMessageToSet(&data, true); } void Spell::DelayedChannel() @@ -5582,7 +5585,7 @@ void Spell::DelayedChannel() //check pushback reduce int32 delaytime = GetSpellDuration(m_spellInfo) * 25 / 100; // channeling delay is normally 25% of its time per hit int32 delayReduce = 100; // must be initialized to 100 for percent modifiers - ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,delayReduce, this); + ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if(delayReduce >= 100) return; @@ -5599,11 +5602,11 @@ void Spell::DelayedChannel() sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer); - for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for(std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if ((*ihit).missCondition == SPELL_MISS_NONE) { - Unit* unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if (unit) { unit->DelayAura(m_spellInfo->Id, m_caster->GetGUID(), delaytime); @@ -5611,7 +5614,7 @@ void Spell::DelayedChannel() } } - for(int j = 0; j < 3; j++) + for(int j = 0; j < 3; ++j) { // partially interrupt persistent area auras DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j); @@ -5680,7 +5683,7 @@ CurrentSpellTypes Spell::GetCurrentContainer() bool Spell::CheckTarget(Unit* target, uint32 eff) { // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) - if(m_spellInfo->EffectImplicitTargetA[eff]!=TARGET_UNIT_CASTER) + if(m_spellInfo->EffectImplicitTargetA[eff] != TARGET_UNIT_CASTER) { if (!CheckTargetCreatureType(target)) return false; @@ -5709,9 +5712,9 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) } //Check player targets and remove if in GM mode or GM invisibility (for not self casting case) - if( target != m_caster && target->GetTypeId()==TYPEID_PLAYER) + if( target != m_caster && target->GetTypeId() == TYPEID_PLAYER) { - if(((Player*)target)->GetVisibility()==VISIBILITY_OFF) + if(((Player*)target)->GetVisibility() == VISIBILITY_OFF) return false; if(((Player*)target)->isGameMaster() && !IsPositiveSpell(m_spellInfo->Id)) @@ -5728,21 +5731,21 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) case SPELL_EFFECT_SUMMON_PLAYER: // from anywhere break; case SPELL_EFFECT_DUMMY: - if(m_spellInfo->Id!=20577) // Cannibalize + if(m_spellInfo->Id != 20577) // Cannibalize break; //fall through case SPELL_EFFECT_RESURRECT_NEW: // player far away, maybe his corpse near? - if(target!=m_caster && !target->IsWithinLOSInMap(m_caster)) + if(target != m_caster && !target->IsWithinLOSInMap(m_caster)) { if(!m_targets.getCorpseTargetGUID()) return false; - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); + Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.getCorpseTargetGUID()); if(!corpse) return false; - if(target->GetGUID()!=corpse->GetOwnerGUID()) + if(target->GetGUID() != corpse->GetOwnerGUID()) return false; if(!corpse->IsWithinLOSInMap(m_caster)) @@ -5758,7 +5761,7 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID); if (!caster) caster = m_caster; - if(target!=m_caster && !target->IsWithinLOSInMap(caster)) + if(target != m_caster && !target->IsWithinLOSInMap(caster)) return false; break; } @@ -5774,16 +5777,16 @@ bool Spell::IsNeedSendToClient() const bool Spell::HaveTargetsForEffect( uint8 effect ) const { - for(std::list<TargetInfo>::const_iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) - if(itr->effectMask & (1<<effect)) + for(std::list<TargetInfo>::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) + if(itr->effectMask & (1 << effect)) return true; - for(std::list<GOTargetInfo>::const_iterator itr= m_UniqueGOTargetInfo.begin();itr != m_UniqueGOTargetInfo.end();++itr) - if(itr->effectMask & (1<<effect)) + for(std::list<GOTargetInfo>::const_iterator itr = m_UniqueGOTargetInfo.begin(); itr != m_UniqueGOTargetInfo.end(); ++itr) + if(itr->effectMask & (1 << effect)) return true; - for(std::list<ItemTargetInfo>::const_iterator itr= m_UniqueItemInfo.begin();itr != m_UniqueItemInfo.end();++itr) - if(itr->effectMask & (1<<effect)) + for(std::list<ItemTargetInfo>::const_iterator itr = m_UniqueItemInfo.begin(); itr != m_UniqueItemInfo.end(); ++itr) + if(itr->effectMask & (1 << effect)) return true; return false; @@ -5806,7 +5809,7 @@ SpellEvent::~SpellEvent() else { sLog.outError("~SpellEvent: %s %u tried to delete non-deletable spell %u. Was not deleted, causes memory leak.", - (m_Spell->GetCaster()->GetTypeId()==TYPEID_PLAYER?"Player":"Creature"), m_Spell->GetCaster()->GetGUIDLow(),m_Spell->m_spellInfo->Id); + (m_Spell->GetCaster()->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUIDLow(), m_Spell->m_spellInfo->Id); } } @@ -5825,8 +5828,7 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time) if (m_Spell->IsDeletable()) { // check, if we do have unfinished triggered spells - - return(true); // spell is deletable, finish event + return true; // spell is deletable, finish event } // event will be re-added automatically at the end of routine) } break; @@ -5863,7 +5865,7 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time) { // re-add us to the queue m_Spell->GetCaster()->m_Events.AddEvent(this, m_Spell->GetDelayStart() + n_offset, false); - return(false); // event not complete + return false; // event not complete } // event complete // finish update event will be re-added automatically at the end of routine) @@ -5875,7 +5877,7 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time) m_Spell->SetDelayStart(e_time); // re-plan the event for the delay moment m_Spell->GetCaster()->m_Events.AddEvent(this, e_time + m_Spell->GetDelayMoment(), false); - return(false); // event not complete + return false; // event not complete } } break; @@ -5888,7 +5890,7 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time) // spell processing not complete, plan event on the next update interval m_Spell->GetCaster()->m_Events.AddEvent(this, e_time + 1, false); - return(false); // event not complete + return false; // event not complete } void SpellEvent::Abort(uint64 /*e_time*/) diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 494bdc68a88..8dd39552eb2 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -91,9 +91,9 @@ enum AuraType SPELL_AURA_PROC_TRIGGER_DAMAGE = 43, SPELL_AURA_TRACK_CREATURES = 44, SPELL_AURA_TRACK_RESOURCES = 45, - SPELL_AURA_46 = 46, // Ignore all Gear test spells + SPELL_AURA_46 = 46, // Ignore all Gear test spells SPELL_AURA_MOD_PARRY_PERCENT = 47, - SPELL_AURA_48 = 48, // One periodic spell + SPELL_AURA_48 = 48, // One periodic spell SPELL_AURA_MOD_DODGE_PERCENT = 49, SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT = 50, SPELL_AURA_MOD_BLOCK_PERCENT = 51, @@ -135,7 +135,7 @@ enum AuraType SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN = 87, SPELL_AURA_MOD_HEALTH_REGEN_PERCENT = 88, SPELL_AURA_PERIODIC_DAMAGE_PERCENT = 89, - SPELL_AURA_90 = 90, // old SPELL_AURA_MOD_RESIST_CHANCE + SPELL_AURA_90 = 90, // old SPELL_AURA_MOD_RESIST_CHANCE SPELL_AURA_MOD_DETECT_RANGE = 91, SPELL_AURA_PREVENTS_FLEEING = 92, SPELL_AURA_MOD_UNATTACKABLE = 93, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index bf760f6dea1..7ac2ae5f25e 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3734,7 +3734,7 @@ void AuraEffect::HandleAuraModPetTalentsPoints(bool Apply, bool Real, bool chang if(m_target->GetCharmInfo()) m_target->GetCharmInfo()->SetPetNumber(0, true); else - sLog.outError("AuraEffect::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId()); + sLog.outError("AuraEffect::HandleModCharm: target="UI64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId()); } } @@ -5892,18 +5892,8 @@ void AuraEffect::PeriodicTick() pCaster->DealDamageMods(m_target,pdamage,&absorb); - WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size - data.append(m_target->GetPackGUID()); - data.appendPackGUID(GetCasterGUID()); - data << uint32(GetId()); - data << uint32(1); - data << uint32(m_auraName); - data << (uint32)pdamage; - data << uint32(0); // overkill - data << (uint32)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x - data << (uint32)absorb; - data << (uint32)resist; - m_target->SendMessageToSet(&data,true); + SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, absorb, resist, 0.0f); + m_target->SendPeriodicAuraLog(&pInfo); Unit* target = m_target; // aura can be deleted in DealDamage SpellEntry const* spellProto = GetSpellProto(); @@ -6030,15 +6020,8 @@ void AuraEffect::PeriodicTick() int32 gain = m_target->ModifyHealth(pdamage); - WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size - data.append(m_target->GetPackGUID()); - data.appendPackGUID(GetCasterGUID()); - data << uint32(GetId()); - data << uint32(1); - data << uint32(m_auraName); - data << (uint32)pdamage; - data << uint32(pdamage - gain); // wotlk - m_target->SendMessageToSet(&data,true); + SpellPeriodicAuraLogInfo pInfo(this, pdamage, pdamage - gain, 0, 0, 0.0f); + m_target->SendPeriodicAuraLog(&pInfo); // add HoTs to amount healed in bgs if( pCaster->GetTypeId() == TYPEID_PLAYER ) @@ -6152,16 +6135,8 @@ void AuraEffect::PeriodicTick() modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier); } - WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size - data.append(m_target->GetPackGUID()); - data.appendPackGUID(GetCasterGUID()); - data << uint32(GetId()); - data << uint32(1); - data << uint32(m_auraName); - data << (uint32)power; // power type - data << (uint32)drain_amount; - data << (float)gain_multiplier; - m_target->SendMessageToSet(&data,true); + SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, 0, gain_multiplier); + m_target->SendPeriodicAuraLog(&pInfo); int32 gain_amount = int32(drain_amount*gain_multiplier); @@ -6215,15 +6190,8 @@ void AuraEffect::PeriodicTick() sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u", GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), amount, GetId()); - WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size - data.append(m_target->GetPackGUID()); - data.appendPackGUID(GetCasterGUID()); - data << uint32(GetId()); - data << uint32(1); - data << uint32(m_auraName); - data << uint32(power); // power type - data << (uint32)amount; - m_target->SendMessageToSet(&data,true); + SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f); + m_target->SendPeriodicAuraLog(&pInfo); int32 gain = m_target->ModifyPower(power,amount); @@ -6247,15 +6215,8 @@ void AuraEffect::PeriodicTick() uint32 amount = m_amount; - WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size - data.append(m_target->GetPackGUID()); - data.appendPackGUID(GetCasterGUID()); - data << uint32(GetId()); - data << uint32(1); - data << uint32(m_auraName); - data << (uint32)power; // power type - data << (uint32)amount; - m_target->SendMessageToSet(&data,true); + SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f); + m_target->SendPeriodicAuraLog(&pInfo); sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u", GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), amount, GetId()); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 59830551cf3..b99a6169161 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -276,14 +276,14 @@ void Spell::EffectInstaKill(uint32 /*i*/) case 1863: spellID=18791; break; //succubus case 17252: spellID=35701; break; //fellguard default: - sLog.outError("EffectInstaKill: Unhandled creature entry (%u) case.",entry); + sLog.outError("EffectInstaKill: Unhandled creature entry (%u) case.", entry); return; } - m_caster->CastSpell(m_caster,spellID,true); + m_caster->CastSpell(m_caster, spellID, true); } - if(m_caster==unitTarget) // prevent interrupt message + if(m_caster == unitTarget) // prevent interrupt message finish(); m_caster->DealDamage(unitTarget, unitTarget->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); @@ -299,11 +299,11 @@ void Spell::EffectEnvirinmentalDMG(uint32 i) // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc damage = m_spellInfo->CalculateSimpleValue(i); - m_caster->CalcAbsorbResist(m_caster,GetSpellSchoolMask(m_spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo); + m_caster->CalcAbsorbResist(m_caster, GetSpellSchoolMask(m_spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo); m_caster->SendSpellNonMeleeDamageLog(m_caster, m_spellInfo->Id, damage, GetSpellSchoolMask(m_spellInfo), absorb, resist, false, 0, false); if(m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->EnvironmentalDamage(DAMAGE_FIRE,damage); + ((Player*)m_caster)->EnvironmentalDamage(DAMAGE_FIRE, damage); } void Spell::EffectSchoolDMG(uint32 effect_idx) @@ -783,7 +783,7 @@ void Spell::EffectDummy(uint32 i) case 4: spell_id = 8067; break; // Party Time! case 5: spell_id = 8068; break; // Healthy Spirit } - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 8213: // Savory Deviate Delight @@ -805,7 +805,7 @@ void Spell::EffectDummy(uint32 i) case 8593: // Symbol of life (restore creature to life) case 31225: // Shimmering Vessel (restore creature to life) { - if(!unitTarget || unitTarget->GetTypeId()!=TYPEID_UNIT) + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) return; ((Creature*)unitTarget)->setDeathState(JUST_ALIVED); return; @@ -889,18 +889,18 @@ void Spell::EffectDummy(uint32 i) } case 16589: // Noggenfogger Elixir { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if(m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; - switch(urand(1,3)) + switch(urand(1, 3)) { case 1: spell_id = 16595; break; case 2: spell_id = 16593; break; default:spell_id = 16591; break; } - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 17251: // Spirit Healer Res @@ -911,7 +911,7 @@ void Spell::EffectDummy(uint32 i) if(m_originalCaster->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); - data << unitTarget->GetGUID(); + data << uint64(unitTarget->GetGUID()); ((Player*)m_originalCaster)->GetSession()->SendPacket( &data ); } return; @@ -923,12 +923,12 @@ void Spell::EffectDummy(uint32 i) uint32 spell_id = roll_chance_i(50) ? 17269 : 17270; - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 20577: // Cannibalize if (unitTarget) - m_caster->CastSpell(m_caster,20578,false,NULL); + m_caster->CastSpell(m_caster, 20578, false, NULL); return; case 23019: // Crystal Prison Dummy DND { @@ -948,49 +948,49 @@ void Spell::EffectDummy(uint32 i) WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); data << uint64(Crystal_Prison->GetGUID()); - m_caster->SendMessageToSet(&data,true); + m_caster->SendMessageToSet(&data, true); return; } case 23074: // Arcanite Dragonling if (!m_CastItem) return; - m_caster->CastSpell(m_caster,19804,true,m_CastItem); + m_caster->CastSpell(m_caster, 19804, true, m_CastItem); return; case 23075: // Mithril Mechanical Dragonling if (!m_CastItem) return; - m_caster->CastSpell(m_caster,12749,true,m_CastItem); + m_caster->CastSpell(m_caster, 12749, true, m_CastItem); return; case 23076: // Mechanical Dragonling if (!m_CastItem) return; - m_caster->CastSpell(m_caster,4073,true,m_CastItem); + m_caster->CastSpell(m_caster, 4073, true, m_CastItem); return; case 23133: // Gnomish Battle Chicken if (!m_CastItem) return; - m_caster->CastSpell(m_caster,13166,true,m_CastItem); + m_caster->CastSpell(m_caster, 13166, true, m_CastItem); return; case 23448: // Ultrasafe Transporter: Gadgetzan - backfires { int32 r = irand(0, 119); if ( r < 20 ) // 1/6 polymorph - m_caster->CastSpell(m_caster,23444,true); + m_caster->CastSpell(m_caster, 23444, true); else if ( r < 100 ) // 4/6 evil twin - m_caster->CastSpell(m_caster,23445,true); + m_caster->CastSpell(m_caster, 23445, true); else // 1/6 miss the target - m_caster->CastSpell(m_caster,36902,true); + m_caster->CastSpell(m_caster, 36902, true); return; } case 23453: // Ultrasafe Transporter: Gadgetzan if ( roll_chance_i(50) ) // success - m_caster->CastSpell(m_caster,23441,true); + m_caster->CastSpell(m_caster, 23441, true); else // failure - m_caster->CastSpell(m_caster,23446,true); + m_caster->CastSpell(m_caster, 23446, true); return; case 23645: // Hourglass Sand m_caster->RemoveAurasDueToSpell(23170); return; case 23725: // Gift of Life (warrior bwl trinket) - m_caster->CastSpell(m_caster,23782,true); - m_caster->CastSpell(m_caster,23783,true); + m_caster->CastSpell(m_caster, 23782, true); + m_caster->CastSpell(m_caster, 23783, true); return; case 25860: // Reindeer Transformation { @@ -1021,7 +1021,7 @@ void Spell::EffectDummy(uint32 i) case 28006: // Arcane Cloaking { if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER ) - m_caster->CastSpell(unitTarget,29294,true); + m_caster->CastSpell(unitTarget, 29294, true); return; } // Polarity Shift @@ -1086,7 +1086,7 @@ void Spell::EffectDummy(uint32 i) case 5: spell_id = 33064; break; } - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 35745: @@ -1099,7 +1099,7 @@ void Spell::EffectDummy(uint32 i) default: return; } - m_caster->CastSpell(m_caster,spell_id,true); + m_caster->CastSpell(m_caster, spell_id, true); return; } case 37674: // Chaos Blast @@ -1108,14 +1108,14 @@ void Spell::EffectDummy(uint32 i) return; int32 basepoints0 = 100; - m_caster->CastCustomSpell(unitTarget,37675,&basepoints0,NULL,NULL,true); + m_caster->CastCustomSpell(unitTarget, 37675, &basepoints0, NULL, NULL, true); return; } case 40802: // Mingo's Fortune Generator (Mingo's Fortune Giblets) { // selecting one from Bloodstained Fortune item uint32 newitemid; - switch(urand(1,20)) + switch(urand(1, 20)) { case 1: newitemid = 32688; break; case 2: newitemid = 32689; break; @@ -1141,7 +1141,7 @@ void Spell::EffectDummy(uint32 i) return; } - DoCreateItem(i,newitemid); + DoCreateItem(i, newitemid); return; } // Demon Broiled Surprise @@ -1167,7 +1167,7 @@ void Spell::EffectDummy(uint32 i) creatureTarget->SetHealth(0); // just for nice GM-mode view //cast spell Raptor Capture Credit - m_caster->CastSpell(m_caster,42337,true,NULL); + m_caster->CastSpell(m_caster, 42337, true, NULL); return; } case 34665: //Administer Antidote @@ -1195,7 +1195,7 @@ void Spell::EffectDummy(uint32 i) return; pCreature->SetHealth(health); - ((Player*)m_caster)->RewardPlayerAndGroupAtEvent(16992,pCreature); + ((Player*)m_caster)->RewardPlayerAndGroupAtEvent(16992, pCreature); if (pCreature->IsAIEnabled) pCreature->AI()->AttackStart(m_caster); @@ -1285,7 +1285,7 @@ void Spell::EffectDummy(uint32 i) case 53341: case 53343: { - m_caster->CastSpell(m_caster,54586,true); + m_caster->CastSpell(m_caster, 54586, true); return; } case 58418: // Portal to Orgrimmar @@ -1312,7 +1312,7 @@ void Spell::EffectDummy(uint32 i) // FIXME: custom spell required this aura state by some unknown reason, we not need remove it anyway m_caster->ModifyAuraState(AURA_STATE_BERSERKING,true); - m_caster->CastCustomSpell(m_caster,26635,&hasteModBasePoints0,&hasteModBasePoints1,&hasteModBasePoints2,true,NULL); + m_caster->CastCustomSpell(m_caster, 26635, &hasteModBasePoints0, &hasteModBasePoints1, &hasteModBasePoints2, true, NULL); return; } } @@ -1340,7 +1340,7 @@ void Spell::EffectDummy(uint32 i) (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) && spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 ) { - ((Player*)m_caster)->RemoveSpellCooldown(classspell,true); + ((Player*)m_caster)->RemoveSpellCooldown(classspell, true); } } return; @@ -1362,7 +1362,7 @@ void Spell::EffectDummy(uint32 i) if(m_spellInfo->SpellFamilyFlags & 0x1 && m_spellInfo->SpellVisual[0] == 867) { int32 chargeBasePoints0 = damage; - m_caster->CastCustomSpell(m_caster,34846,&chargeBasePoints0,NULL,NULL,true); + m_caster->CastCustomSpell(m_caster, 34846, &chargeBasePoints0, NULL, NULL, true); return; } //Slam @@ -1425,7 +1425,7 @@ void Spell::EffectDummy(uint32 i) { if(!unitTarget) return; - m_caster->CastSpell(unitTarget,21887,true); // spell mod + m_caster->CastSpell(unitTarget, 21887, true);// spell mod return; } // Last Stand @@ -1602,7 +1602,7 @@ void Spell::EffectDummy(uint32 i) } case 31231: // Cheat Death { - m_caster->CastSpell(m_caster,45182,true); + m_caster->CastSpell(m_caster, 45182, true); return; } } @@ -1707,7 +1707,7 @@ void Spell::EffectDummy(uint32 i) ((Player*)m_caster)->AddSpellMod(mod, false); } else - m_caster->CastSpell(unitTarget,spell_proto,true,NULL); + m_caster->CastSpell(unitTarget, spell_proto, true, NULL); return; } @@ -1761,7 +1761,7 @@ void Spell::EffectDummy(uint32 i) default: return; // ignore for not healing classes } - m_caster->CastSpell(m_caster,spell_id,true); + m_caster->CastSpell(m_caster, spell_id, true); return; } } @@ -1780,7 +1780,7 @@ void Spell::EffectDummy(uint32 i) case 8019: spell_id = 36755; break; // Rank 3 case 10399: spell_id = 36759; break; // Rank 4 default: - sLog.outError("Spell::EffectDummy: Spell %u not handled in RW",m_spellInfo->Id); + sLog.outError("Spell::EffectDummy: Spell %u not handled in RW", m_spellInfo->Id); return; } @@ -1847,7 +1847,7 @@ void Spell::EffectDummy(uint32 i) damage+=dummy->GetAmount(); // Regenerate 6% of Total Mana Every 3 secs int32 EffectBasePoints0 = unitTarget->GetMaxPower(POWER_MANA) * damage / 100; - m_caster->CastCustomSpell(unitTarget,39609,&EffectBasePoints0,NULL,NULL,true,NULL,NULL,m_originalCasterGUID); + m_caster->CastCustomSpell(unitTarget, 39609, &EffectBasePoints0, NULL, NULL, true, NULL, NULL, m_originalCasterGUID); return; } // Lava Lash @@ -1884,12 +1884,12 @@ void Spell::EffectDummy(uint32 i) return; int32 bp = damage * 1.5f; - m_caster->CastCustomSpell(unitTarget,47633,&bp,NULL,NULL,true); + m_caster->CastCustomSpell(unitTarget, 47633, &bp, NULL, NULL, true); } else { int32 bp = damage; - m_caster->CastCustomSpell(unitTarget,47632,&bp,NULL,NULL,true); + m_caster->CastCustomSpell(unitTarget, 47632, &bp, NULL, NULL, true); } return; } @@ -1993,7 +1993,7 @@ void Spell::EffectForceCast(uint32 i) return; } - unitTarget->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID); + unitTarget->CastSpell(unitTarget, spellInfo, true, NULL, NULL, m_originalCasterGUID); } void Spell::EffectTriggerSpell(uint32 i) @@ -2069,7 +2069,7 @@ void Spell::EffectTriggerSpell(uint32 i) return; for (int j=0; j < spell->StackAmount; ++j) - m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); + m_caster->CastSpell(unitTarget, spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); return; } // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) @@ -2080,13 +2080,13 @@ void Spell::EffectTriggerSpell(uint32 i) return; for (int j=0; j < spell->StackAmount; ++j) - m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); + m_caster->CastSpell(unitTarget, spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); return; } // Righteous Defense case 31980: { - m_caster->CastSpell(unitTarget, 31790, true,m_CastItem,NULL,m_originalCasterGUID); + m_caster->CastSpell(unitTarget, 31790, true, m_CastItem, NULL, m_originalCasterGUID); return; } // Cloak of Shadows @@ -2264,9 +2264,9 @@ void Spell::EffectTeleportUnits(uint32 i) if ( r >= 70 ) // 7/12 success { if ( r < 100 ) // 4/12 evil twin - m_caster->CastSpell(m_caster,23445,true); + m_caster->CastSpell(m_caster, 23445, true); else // 1/12 fire - m_caster->CastSpell(m_caster,23449,true); + m_caster->CastSpell(m_caster, 23449, true); } return; } @@ -2275,41 +2275,41 @@ void Spell::EffectTeleportUnits(uint32 i) { if ( roll_chance_i(50) ) // 50% success { - int32 rand_eff = urand(1,7); + int32 rand_eff = urand(1, 7); switch ( rand_eff ) { case 1: // soul split - evil - m_caster->CastSpell(m_caster,36900,true); + m_caster->CastSpell(m_caster, 36900, true); break; case 2: // soul split - good - m_caster->CastSpell(m_caster,36901,true); + m_caster->CastSpell(m_caster, 36901, true); break; case 3: // Increase the size - m_caster->CastSpell(m_caster,36895,true); + m_caster->CastSpell(m_caster, 36895, true); break; case 4: // Decrease the size - m_caster->CastSpell(m_caster,36893,true); + m_caster->CastSpell(m_caster, 36893, true); break; case 5: // Transform { if (((Player*)m_caster)->GetTeam() == ALLIANCE ) - m_caster->CastSpell(m_caster,36897,true); + m_caster->CastSpell(m_caster, 36897, true); else - m_caster->CastSpell(m_caster,36899,true); + m_caster->CastSpell(m_caster, 36899, true); break; } case 6: // chicken - m_caster->CastSpell(m_caster,36940,true); + m_caster->CastSpell(m_caster, 36940, true); break; case 7: // evil twin - m_caster->CastSpell(m_caster,23445,true); + m_caster->CastSpell(m_caster, 23445, true); break; } } @@ -2320,28 +2320,28 @@ void Spell::EffectTeleportUnits(uint32 i) { if ( roll_chance_i(50) ) // 50% success { - int32 rand_eff = urand(1,4); + int32 rand_eff = urand(1, 4); switch ( rand_eff ) { case 1: // soul split - evil - m_caster->CastSpell(m_caster,36900,true); + m_caster->CastSpell(m_caster, 36900, true); break; case 2: // soul split - good - m_caster->CastSpell(m_caster,36901,true); + m_caster->CastSpell(m_caster, 36901, true); break; case 3: // Increase the size - m_caster->CastSpell(m_caster,36895,true); + m_caster->CastSpell(m_caster, 36895, true); break; case 4: // Transform { if (((Player*)m_caster)->GetTeam() == ALLIANCE ) - m_caster->CastSpell(m_caster,36897,true); + m_caster->CastSpell(m_caster, 36897, true); else - m_caster->CastSpell(m_caster,36899,true); + m_caster->CastSpell(m_caster, 36899, true); break; } } @@ -2422,11 +2422,11 @@ void Spell::EffectPowerDrain(uint32 i) if(Player *modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, manaMultiplier); - int32 gain = int32(new_damage*manaMultiplier); + int32 gain = int32(new_damage * manaMultiplier); m_caster->ModifyPower(POWER_MANA,gain); //send log - m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA); + m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id, gain, POWER_MANA); } } @@ -2474,7 +2474,7 @@ void Spell::EffectPowerBurn(uint32 i) int32 new_damage = (curPower < power) ? curPower : power; - unitTarget->ModifyPower(powertype,-new_damage); + unitTarget->ModifyPower(powertype, -new_damage); float multiplier = m_spellInfo->EffectMultipleValue[i]; if(Player *modOwner = m_caster->GetSpellModOwner()) @@ -2537,7 +2537,7 @@ void Spell::SpellDamageHeal(uint32 /*i*/) if(!targetAura) { - sLog.outError("Target(GUID:" I64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID()); + sLog.outError("Target(GUID:" UI64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID()); return; } @@ -2745,7 +2745,7 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype) // set the "Crafted by ..." property of the item if( pItem->GetProto()->Class != ITEM_CLASS_CONSUMABLE && pItem->GetProto()->Class != ITEM_CLASS_QUEST) - pItem->SetUInt32Value(ITEM_FIELD_CREATOR,player->GetGUIDLow()); + pItem->SetUInt32Value(ITEM_FIELD_CREATOR, player->GetGUIDLow()); // send info to the client if(pItem) @@ -2769,23 +2769,23 @@ void Spell::EffectCreateItem2(uint32 i) uint32 item_id = m_spellInfo->EffectItemType[i]; if(item_id) - DoCreateItem(i,item_id); + DoCreateItem(i, item_id); // special case: fake item replaced by generate using spell_loot_template if(IsLootCraftingSpell(m_spellInfo)) { if(item_id) { - if(!player->HasItemCount(item_id,1)) + if(!player->HasItemCount(item_id, 1)) return; // remove reagent uint32 count = 1; - player->DestroyItemCount (item_id,count,true); + player->DestroyItemCount(item_id, count, true); } // create some random items - player->AutoStoreLoot(m_spellInfo->Id,LootTemplates_Spell); + player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); } } @@ -3079,7 +3079,7 @@ void Spell::EffectOpenLock(uint32 effIndex) int32 reqSkillValue = 0; int32 skillValue; - SpellCastResult res = CanOpenLock(effIndex,lockId,skillId,reqSkillValue,skillValue); + SpellCastResult res = CanOpenLock(effIndex, lockId, skillId, reqSkillValue, skillValue); if(res != SPELL_CAST_OK) { SendCastResult(res); @@ -3153,7 +3153,7 @@ void Spell::EffectSummonChangeItem(uint32 i) uint8 msg = player->CanStoreItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); if( msg == EQUIP_ERR_OK ) { - player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); + player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true); // prevent crash at access and unexpected charges counting with item update queue corrupt if(m_CastItem==m_targets.getItemTarget()) @@ -3171,7 +3171,7 @@ void Spell::EffectSummonChangeItem(uint32 i) uint8 msg = player->CanBankItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); if( msg == EQUIP_ERR_OK ) { - player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); + player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true); // prevent crash at access and unexpected charges counting with item update queue corrupt if(m_CastItem==m_targets.getItemTarget()) @@ -3189,7 +3189,7 @@ void Spell::EffectSummonChangeItem(uint32 i) uint8 msg = player->CanEquipItem( m_CastItem->GetSlot(), dest, pNewItem, true ); if( msg == EQUIP_ERR_OK ) { - player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); + player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true); // prevent crash at access and unexpected charges counting with item update queue corrupt if(m_CastItem==m_targets.getItemTarget()) @@ -3219,15 +3219,15 @@ void Spell::EffectProficiency(uint32 /*i*/) Player *p_target = (Player*)unitTarget; uint32 subClassMask = m_spellInfo->EquippedItemSubClassMask; - if(m_spellInfo->EquippedItemClass == 2 && !(p_target->GetWeaponProficiency() & subClassMask)) + if(m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && !(p_target->GetWeaponProficiency() & subClassMask)) { p_target->AddWeaponProficiency(subClassMask); - p_target->SendProficiency(uint8(0x02),p_target->GetWeaponProficiency()); + p_target->SendProficiency(ITEM_CLASS_WEAPON, p_target->GetWeaponProficiency()); } - if(m_spellInfo->EquippedItemClass == 4 && !(p_target->GetArmorProficiency() & subClassMask)) + if(m_spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && !(p_target->GetArmorProficiency() & subClassMask)) { p_target->AddArmorProficiency(subClassMask); - p_target->SendProficiency(uint8(0x04),p_target->GetArmorProficiency()); + p_target->SendProficiency(ITEM_CLASS_ARMOR, p_target->GetArmorProficiency()); } } @@ -3568,7 +3568,7 @@ void Spell::EffectDistract(uint32 /*i*/) // Set creature Distracted, Stop it, And turn it unitTarget->SetOrientation(angle); unitTarget->StopMoving(); - unitTarget->GetMotionMaster()->MoveDistract(damage*IN_MILISECONDS); + unitTarget->GetMotionMaster()->MoveDistract(damage * IN_MILISECONDS); } } @@ -3891,26 +3891,26 @@ void Spell::EffectEnchantItemTmp(uint32 i) uint32 duration; // rogue family enchantments exception by duration - if(m_spellInfo->Id==38615) + if(m_spellInfo->Id == 38615) duration = 1800; // 30 mins // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints) - else if(m_spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE) + else if(m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE) duration = 3600; // 1 hour // shaman family enchantments - else if(m_spellInfo->SpellFamilyName==SPELLFAMILY_SHAMAN) + else if(m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN) duration = 1800; // 30 mins // other cases with this SpellVisual already selected - else if(m_spellInfo->SpellVisual[0]==215) + else if(m_spellInfo->SpellVisual[0] == 215) duration = 1800; // 30 mins // some fishing pole bonuses - else if(m_spellInfo->SpellVisual[0]==563) + else if(m_spellInfo->SpellVisual[0] == 563) duration = 600; // 10 mins // shaman rockbiter enchantments - else if(m_spellInfo->SpellVisual[0]==0) + else if(m_spellInfo->SpellVisual[0] == 0) duration = 1800; // 30 mins - else if(m_spellInfo->Id==29702) + else if(m_spellInfo->Id == 29702) duration = 300; // 5 mins - else if(m_spellInfo->Id==37360) + else if(m_spellInfo->Id == 37360) duration = 300; // 5 mins // default case else @@ -3924,18 +3924,18 @@ void Spell::EffectEnchantItemTmp(uint32 i) if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), - item_owner->GetName(),item_owner->GetSession()->GetAccountId()); + p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + itemTarget->GetProto()->Name1, itemTarget->GetEntry(), + item_owner->GetName(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped - item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,false); + item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT, false); - itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration*1000, 0); + itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration * 1000, 0); // add new enchanting if equipped - item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,true); + item_owner->ApplyEnchantment(itemTarget, TEMP_ENCHANTMENT_SLOT, true); } void Spell::EffectTameCreature(uint32 /*i*/) @@ -4130,7 +4130,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) // multiple weapon dmg effect workaround // execute only the last weapon damage // and handle all effects at once - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; ++j) { switch(m_spellInfo->Effect[j]) { @@ -4279,7 +4279,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) // Stormstrike AP Buff if ( (*citr)->GetMiscValue() == 5634 ) { - m_caster->CastSpell(m_caster,38430,true,NULL,*citr); + m_caster->CastSpell(m_caster, 38430, true, NULL, *citr); break; } } @@ -4306,10 +4306,10 @@ void Spell::SpellDamageWeaponDmg(uint32 i) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - fixed_bonus += CalculateDamage(j,unitTarget); + fixed_bonus += CalculateDamage(j, unitTarget); break; case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - fixed_bonus += CalculateDamage(j,unitTarget); + fixed_bonus += CalculateDamage(j, unitTarget); normalized = true; break; case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: @@ -4437,7 +4437,7 @@ void Spell::EffectSummonObjectWild(uint32 i) if( !target ) target = m_caster; - float x,y,z; + float x, y, z; if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { x = m_targets.m_destX; @@ -4445,7 +4445,7 @@ void Spell::EffectSummonObjectWild(uint32 i) z = m_targets.m_destZ; } else - m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); + m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); Map *map = target->GetMap(); @@ -4549,7 +4549,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) return; uint32 spell_id = 0; - switch(urand(1,5)) + switch(urand(1, 5)) { case 1: spell_id = 8854; break; default: spell_id = 8855; break; @@ -4671,14 +4671,17 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 29830: { uint32 item = 0; - switch ( urand(1,6) ) + switch ( urand(1, 6) ) { - case 1:case 2:case 3: - item = 23584;break; // Loch Modan Lager - case 4:case 5: - item = 23585;break; // Stouthammer Lite + case 1: + case 2: + case 3: + item = 23584; break; // Loch Modan Lager + case 4: + case 5: + item = 23585; break; // Stouthammer Lite case 6: - item = 23586;break; // Aerie Peak Pale Ale + item = 23586; break; // Aerie Peak Pale Ale } if (item) DoCreateItem(effIndex,item); @@ -4823,7 +4826,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) return; uint32 spellId = 0; - switch(rand()%4) + switch(rand() % 4) { case 0: spellId = 46740; break; case 1: spellId = 46739; break; @@ -4963,12 +4966,12 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 61288: // Minor Inscription Research case 61756: // Northrend Inscription Research (FAST QA VERSION) { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) + if(m_caster->GetTypeId() != TYPEID_PLAYER) return; // learn random explicit discovery recipe (if any) if(uint32 discoveredSpell = GetExplicitDiscoverySpell(m_spellInfo->Id, (Player*)m_caster)) - ((Player*)m_caster)->learnSpell(discoveredSpell,false); + ((Player*)m_caster)->learnSpell(discoveredSpell, false); return; } } @@ -5006,14 +5009,14 @@ void Spell::EffectScriptEffect(uint32 effIndex) } static uint32 const itypes[8][3] = { - { 5512,19004,19005}, // Minor Healthstone - { 5511,19006,19007}, // Lesser Healthstone - { 5509,19008,19009}, // Healthstone - { 5510,19010,19011}, // Greater Healthstone - { 9421,19012,19013}, // Major Healthstone - {22103,22104,22105}, // Master Healthstone - {36889,36890,36891}, // Demonic Healthstone - {36892,36893,36894} // Fel Healthstone + { 5512, 19004, 19005}, // Minor Healthstone + { 5511, 19006, 19007}, // Lesser Healthstone + { 5509, 19008, 19009}, // Healthstone + { 5510, 19010, 19011}, // Greater Healthstone + { 9421, 19012, 19013}, // Major Healthstone + {22103, 22104, 22105}, // Master Healthstone + {36889, 36890, 36891}, // Demonic Healthstone + {36892, 36893, 36894} // Fel Healthstone }; switch(m_spellInfo->Id) @@ -5254,8 +5257,8 @@ void Spell::EffectScriptEffect(uint32 effIndex) const uint32 spellid = 28703; // don't overwrite an existing aura - for(uint8 i=0; i<5; i++) - if(unitTarget->HasAuraEffect(spellid+i, 0)) + for(uint8 i = 0; i < 5; ++i) + if(unitTarget->HasAuraEffect(spellid + i, 0)) return; unitTarget->CastSpell(unitTarget, spellid+urand(0, 4), true); break; @@ -5392,9 +5395,9 @@ void Spell::EffectDuel(uint32 i) //END // Send request - WorldPacket data(SMSG_DUEL_REQUESTED, 16); - data << pGameObj->GetGUID(); - data << caster->GetGUID(); + WorldPacket data(SMSG_DUEL_REQUESTED, 8 + 8); + data << uint64(pGameObj->GetGUID()); + data << uint64(caster->GetGUID()); caster->GetSession()->SendPacket(&data); target->GetSession()->SendPacket(&data); @@ -5413,8 +5416,8 @@ void Spell::EffectDuel(uint32 i) duel2->startTimer = 0; target->duel = duel2; - caster->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); - target->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); + caster->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); + target->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); } void Spell::EffectStuck(uint32 /*i*/) @@ -5440,7 +5443,7 @@ void Spell::EffectStuck(uint32 /*i*/) SpellEntry const *spellInfo = sSpellStore.LookupEntry(8690); if(!spellInfo) return; - Spell spell(pTarget,spellInfo,true,0); + Spell spell(pTarget, spellInfo, true, 0); spell.SendSpellCooldown(); } @@ -5453,8 +5456,8 @@ void Spell::EffectSummonPlayer(uint32 /*i*/) if(unitTarget->GetDummyAura(23445)) return; - float x,y,z; - m_caster->GetClosePoint(x,y,z,unitTarget->GetObjectSize()); + float x, y, z; + m_caster->GetClosePoint(x, y, z, unitTarget->GetObjectSize()); ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(),x,y,z); @@ -5559,7 +5562,7 @@ void Spell::EffectEnchantHeldItem(uint32 i) // Apply the temporary enchantment item->SetEnchantment(slot, enchant_id, duration*IN_MILISECONDS, 0); - item_owner->ApplyEnchantment(item,slot,true); + item_owner->ApplyEnchantment(item, slot, true); } } @@ -5591,7 +5594,7 @@ void Spell::EffectInebriate(uint32 /*i*/) currentDrunk = 0xFFFF; else currentDrunk += drunkMod; - player->SetDrunkValue(currentDrunk, m_CastItem?m_CastItem->GetEntry():0); + player->SetDrunkValue(currentDrunk, m_CastItem ? m_CastItem->GetEntry() : 0); } void Spell::EffectFeedPet(uint32 i) @@ -5620,7 +5623,7 @@ void Spell::EffectFeedPet(uint32 i) _player->DestroyItemCount(foodItem,count,true); // TODO: fix crash when a spell has two effects, both pointed at the same item target - m_caster->CastCustomSpell(pet,m_spellInfo->EffectTriggerSpell[i],&benefit,NULL,NULL,true); + m_caster->CastCustomSpell(pet, m_spellInfo->EffectTriggerSpell[i], &benefit, NULL, NULL, true); } void Spell::EffectDismissPet(uint32 /*i*/) @@ -5634,7 +5637,7 @@ void Spell::EffectDismissPet(uint32 /*i*/) if(!pet||!pet->isAlive()) return; - ((Player*)m_caster)->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); + ((Player*)m_caster)->RemovePet(pet, PET_SAVE_NOT_IN_SLOT); } void Spell::EffectSummonObject(uint32 i) @@ -5664,7 +5667,7 @@ void Spell::EffectSummonObject(uint32 i) GameObject* pGameObj = new GameObject; - float x,y,z; + float x, y, z; // If dest location if present if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { @@ -5674,7 +5677,7 @@ void Spell::EffectSummonObject(uint32 i) } // Summon in random point all other units if location present else - m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); + m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); Map *map = m_caster->GetMap(); if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map, @@ -5692,8 +5695,8 @@ void Spell::EffectSummonObject(uint32 i) map->Add(pGameObj); WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); - data << pGameObj->GetGUID(); - m_caster->SendMessageToSet(&data,true); + data << uint64(pGameObj->GetGUID()); + m_caster->SendMessageToSet(&data, true); m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); } @@ -5848,7 +5851,7 @@ void Spell::EffectReputation(uint32 i) if(!factionEntry) return; - _player->GetReputationMgr().ModifyReputation(factionEntry,rep_change); + _player->GetReputationMgr().ModifyReputation(factionEntry, rep_change); } void Spell::EffectQuestComplete(uint32 i) @@ -6001,7 +6004,7 @@ void Spell::EffectPlayerPull(uint32 i) float vsin = sin(unitTarget->GetAngle(m_caster)); float vcos = cos(unitTarget->GetAngle(m_caster)); - WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); + WorldPacket data(SMSG_MOVE_KNOCK_BACK, 8+4+4+4+4+4); data.append(unitTarget->GetPackGUID()); data << uint32(0); // Sequence data << float(vcos); // x direction @@ -6099,7 +6102,7 @@ void Spell::EffectDurabilityDamage(uint32 i) // Possibly its mean -1 all player equipped items and -2 all items if(slot < 0) { - ((Player*)unitTarget)->DurabilityPointsLossAll(damage,(slot < -1)); + ((Player*)unitTarget)->DurabilityPointsLossAll(damage, (slot < -1)); return; } @@ -6107,8 +6110,8 @@ void Spell::EffectDurabilityDamage(uint32 i) if(slot >= INVENTORY_SLOT_BAG_END) return; - if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0,slot)) - ((Player*)unitTarget)->DurabilityPointsLoss(item,damage); + if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + ((Player*)unitTarget)->DurabilityPointsLoss(item, damage); } void Spell::EffectDurabilityDamagePCT(uint32 i) @@ -6122,7 +6125,7 @@ void Spell::EffectDurabilityDamagePCT(uint32 i) // Possibly its mean -1 all player equipped items and -2 all items if(slot < 0) { - ((Player*)unitTarget)->DurabilityLossAll(double(damage)/100.0f,(slot < -1)); + ((Player*)unitTarget)->DurabilityLossAll(double(damage)/100.0f, (slot < -1)); return; } @@ -6133,8 +6136,8 @@ void Spell::EffectDurabilityDamagePCT(uint32 i) if(damage <= 0) return; - if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0,slot)) - ((Player*)unitTarget)->DurabilityLoss(item,double(damage)/100.0f); + if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + ((Player*)unitTarget)->DurabilityLoss(item, double(damage)/100.0f); } void Spell::EffectModifyThreatPercent(uint32 /*effIndex*/) @@ -6157,7 +6160,7 @@ void Spell::EffectTransmitted(uint32 effIndex) return; } - float fx,fy,fz; + float fx, fy, fz; if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { @@ -6169,7 +6172,7 @@ void Spell::EffectTransmitted(uint32 effIndex) else if(m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed==0) { float dis = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); - m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); + m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); } else { @@ -6178,14 +6181,14 @@ void Spell::EffectTransmitted(uint32 effIndex) float max_dis = GetSpellMaxRangeForFriend(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); float dis = rand_norm() * (max_dis - min_dis) + min_dis; - m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); + m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); } Map *cMap = m_caster->GetMap(); if(goinfo->type==GAMEOBJECT_TYPE_FISHINGNODE) { - if ( !cMap->IsInWater(fx,fy,fz-0.5f)) // Hack to prevent fishing bobber from failing to land on fishing hole + if ( !cMap->IsInWater(fx, fy, fz-0.5f)) // Hack to prevent fishing bobber from failing to land on fishing hole { // but this is not proper, we really need to ignore not materialized objects SendCastResult(SPELL_FAILED_NOT_HERE); SendChannelUpdate(0); @@ -6193,12 +6196,12 @@ void Spell::EffectTransmitted(uint32 effIndex) } // replace by water level in this case - fz = cMap->GetWaterLevel(fx,fy); + fz = cMap->GetWaterLevel(fx, fy); } // if gameobject is summoning object, it should be spawned right on caster's position else if(goinfo->type==GAMEOBJECT_TYPE_SUMMONING_RITUAL) { - m_caster->GetPosition(fx,fy,fz); + m_caster->GetPosition(fx, fy, fz); } GameObject* pGameObj = new GameObject; @@ -6235,7 +6238,7 @@ void Spell::EffectTransmitted(uint32 effIndex) } case GAMEOBJECT_TYPE_SUMMONING_RITUAL: { - if(m_caster->GetTypeId()==TYPEID_PLAYER) + if(m_caster->GetTypeId() == TYPEID_PLAYER) { pGameObj->AddUniqueUse((Player*)m_caster); m_caster->AddGameObject(pGameObj); // will removed at spell cancel diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index ca675dcd931..7e72fd4e749 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -445,7 +445,7 @@ void WorldSession::HandleCancelChanneling( WorldPacket & /*recv_data */) */ } -void WorldSession::HandleTotemDestroy( WorldPacket& recvPacket) +void WorldSession::HandleTotemDestroyed( WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket, 1); diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 5dd2010b83b..6fb3d8cfc55 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -620,11 +620,13 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) case SPELL_AURA_MOD_DAMAGE_DONE: // dependent from bas point sign (negative -> negative) case SPELL_AURA_MOD_HEALING_DONE: case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: - { if(spellproto->CalculateSimpleValue(effIndex) < 0) return false; break; - } + case SPELL_AURA_MOD_SPELL_CRIT_CHANCE: + if(spellproto->CalculateSimpleValue(effIndex) > 0) + return true; // some expected possitive spells have SPELL_ATTR_EX_NEGATIVE + break; case SPELL_AURA_ADD_TARGET_TRIGGER: return true; case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE: diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index fe1255e51a1..7d90bbd26ce 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -157,7 +157,7 @@ bool WorldSession::SendLearnNewTaxiNode( Creature* unit ) return false; } -void WorldSession::HandleActivateTaxiFarOpcode ( WorldPacket & recv_data ) +void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4+4); @@ -171,7 +171,7 @@ void WorldSession::HandleActivateTaxiFarOpcode ( WorldPacket & recv_data ) Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) { - sLog.outDebug( "WORLD: HandleActivateTaxiFarOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) ); + sLog.outDebug( "WORLD: HandleActivateTaxiExpressOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) ); return; } // recheck @@ -194,7 +194,7 @@ void WorldSession::HandleActivateTaxiFarOpcode ( WorldPacket & recv_data ) GetPlayer()->ActivateTaxiPathTo(nodes, npc); } -void WorldSession::HandleTaxiNextDestinationOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/) { sLog.outDebug( "WORLD: Received CMSG_MOVE_SPLINE_DONE" ); diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index c0006ba2d52..bd698932e6c 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -567,7 +567,7 @@ void Transport::UpdateForMap(Map const* targetMap) UpdateData transData; BuildCreateUpdateBlockForPlayer(&transData, itr->getSource()); WorldPacket packet; - transData.BuildPacket(&packet, true); + transData.BuildPacket(&packet); itr->getSource()->SendDirectMessage(&packet); } } @@ -577,7 +577,7 @@ void Transport::UpdateForMap(Map const* targetMap) UpdateData transData; BuildOutOfRangeUpdateBlock(&transData); WorldPacket out_packet; - transData.BuildPacket(&out_packet, true); + transData.BuildPacket(&out_packet); for(Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) if(this != itr->getSource()->GetTransport()) diff --git a/src/game/Transports.h b/src/game/Transports.h index 2df39f401e7..d72fa3b2124 100644 --- a/src/game/Transports.h +++ b/src/game/Transports.h @@ -72,6 +72,7 @@ class Transport : protected GameObject using GameObject::GetPositionZ; using GameObject::BuildCreateUpdateBlockForPlayer; using GameObject::BuildOutOfRangeUpdateBlock; + using GameObject::GetPackGUID; bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags); bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index cd199ee76d2..cff6e0ac853 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -376,6 +376,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M } data << uint32(MovementFlags); + data << uint32(Time); // Time in between points data << uint32(1); // 1 single waypoint data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B @@ -390,14 +391,14 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end) { uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32); - uint32 pathSize = end-start; + uint32 pathSize = end - start; WorldPacket data( SMSG_MONSTER_MOVE, (GetPackGUID().size()+4+4+4+4+1+4+4+4+pathSize*4*3) ); data.append(GetPackGUID()); data << GetPositionX(); data << GetPositionY(); data << GetPositionZ(); - data << getMSTime(); + data << uint32(getMSTime()); data << uint8( 0 ); data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight())? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK); data << uint32( traveltime ); @@ -1370,7 +1371,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) if(pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) { const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); - if(area && area->flags & 0x800) //sanctuary + if(area && area->flags & AREA_FLAG_SANCTUARY) // sanctuary return; } @@ -1606,11 +1607,11 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) if(pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) { const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); - if(area && area->flags & 0x800) //sanctuary + if(area && area->flags & AREA_FLAG_SANCTUARY) // sanctuary return; } - // Hmmmm dont like this emotes cloent must by self do all animations + // Hmmmm dont like this emotes client must by self do all animations if (damageInfo->HitInfo&HITINFO_CRITICALHIT) pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); if(damageInfo->blocked_amount && damageInfo->TargetState!=VICTIMSTATE_BLOCKS) @@ -1759,7 +1760,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) void Unit::HandleEmoteCommand(uint32 anim_id) { - WorldPacket data( SMSG_EMOTE, 12 ); + WorldPacket data( SMSG_EMOTE, 4 + 8 ); data << uint32(anim_id); data << uint64(GetGUID()); SendMessageToSet(&data, true); @@ -2640,9 +2641,9 @@ float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const return (100.0f - LvlPenalty) * LvlFactor / 100.0f; } -void Unit::SendAttackStart(Unit* pVictim) +void Unit::SendMeleeAttackStart(Unit* pVictim) { - WorldPacket data( SMSG_ATTACKSTART, 16 ); + WorldPacket data( SMSG_ATTACKSTART, 8 + 8 ); data << uint64(GetGUID()); data << uint64(pVictim->GetGUID()); @@ -2650,7 +2651,7 @@ void Unit::SendAttackStart(Unit* pVictim) DEBUG_LOG( "WORLD: Sent SMSG_ATTACKSTART" ); } -void Unit::SendAttackStop(Unit* victim) +void Unit::SendMeleeAttackStop(Unit* victim) { if(!victim) return; @@ -4507,7 +4508,7 @@ void Unit::RemoveAllGameObjects() void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log) { - WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+1+4+4+1+1+4+4+1)); // we guess size + WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+4+1+4+4+1+1+4+4+1)); // we guess size data.append(log->target->GetPackGUID()); data.append(log->attacker->GetPackGUID()); data << uint32(log->SpellID); @@ -4525,10 +4526,10 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log) SendMessageToSet( &data, true ); } -void Unit::SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit) +void Unit::SendSpellNonMeleeDamageLog(Unit *target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit) { - SpellNonMeleeDamage log(this,target,SpellID,damageSchoolMask); - log.damage = Damage-AbsorbedDamage-Resist-Blocked; + SpellNonMeleeDamage log(this, target, SpellID, damageSchoolMask); + log.damage = Damage - AbsorbedDamage - Resist - Blocked; log.absorb = AbsorbedDamage; log.resist = Resist; log.physicalLog = PhysicalDamage; @@ -4550,6 +4551,51 @@ void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVic pVictim->ProcDamageAndSpellFor(true,this,procVictim, procExtra, attType, procSpell, amount, procAura); } +void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo) +{ + AuraEffect *aura = pInfo->auraEff; + + WorldPacket data(SMSG_PERIODICAURALOG, 30); + data.append(GetPackGUID()); + data.appendPackGUID(aura->GetCasterGUID()); + data << uint32(aura->GetId()); // spellId + data << uint32(1); // count + data << uint32(aura->GetAuraName()); // auraId + switch(aura->GetAuraName()) + { + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: + data << uint32(pInfo->damage); // damage + data << uint32(pInfo->overDamage); // overkill? + data << uint32(GetSpellSchoolMask(aura->GetSpellProto())); + data << uint32(pInfo->absorb); // absorb + data << uint32(pInfo->resist); // resist + data << uint8(0); // new 3.1.2 + break; + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_OBS_MOD_HEALTH: + data << uint32(pInfo->damage); // damage + data << uint32(pInfo->overDamage); // overheal? + data << uint8(0); // new 3.1.2 + break; + case SPELL_AURA_OBS_MOD_ENERGY: + case SPELL_AURA_PERIODIC_ENERGIZE: + data << uint32(aura->GetMiscValue()); // power type + data << uint32(pInfo->damage); // damage + break; + case SPELL_AURA_PERIODIC_MANA_LEECH: + data << uint32(aura->GetMiscValue()); // power type + data << uint32(pInfo->damage); // amount + data << float(pInfo->multiplier); // gain multiplier + break; + default: + sLog.outError("Unit::SendPeriodicAuraLog: unknown aura %u", uint32(aura->GetAuraName())); + return; + } + + SendMessageToSet(&data, true); +} + void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo) { WorldPacket data(SMSG_SPELLLOGMISS, (4+8+1+4+8+1)); @@ -4566,41 +4612,43 @@ void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo) void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo) { + sLog.outDebug("WORLD: Sending SMSG_ATTACKERSTATEUPDATE"); + uint32 count = 1; - WorldPacket data(SMSG_ATTACKERSTATEUPDATE, (16+45)); // we guess size - data << (uint32)damageInfo->HitInfo; - data.append(GetPackGUID()); + WorldPacket data(SMSG_ATTACKERSTATEUPDATE, 16 + 45); // we guess size + data << uint32(damageInfo->HitInfo); + data.append(damageInfo->attacker->GetPackGUID()); data.append(damageInfo->target->GetPackGUID()); - data << (uint32)(damageInfo->damage); // Full damage - data << uint32(int32 (damageInfo->target->GetHealth()-damageInfo->damage ) >0 ? 0 : damageInfo->damage - damageInfo->target->GetHealth()); // Overkill - - data << (uint8)count; // Sub damage count + data << uint32(damageInfo->damage); // Full damage + int32 overkill = damageInfo->damage - damageInfo->target->GetHealth(); + data << uint32(overkill < 0 ? 0 : overkill); // Overkill + data << uint8(count); // Sub damage count for(int i = 0; i < count; ++i) { - data << (uint32)(damageInfo->damageSchoolMask); // School of sub damage - data << (float)damageInfo->damage; // sub damage - data << (uint32)damageInfo->damage; // Sub Damage + data << uint32(damageInfo->damageSchoolMask); // School of sub damage + data << float(damageInfo->damage); // sub damage + data << uint32(damageInfo->damage); // Sub Damage } if(damageInfo->HitInfo & (HITINFO_ABSORB | HITINFO_ABSORB2)) { for(int i = 0; i < count; ++i) - data << (uint32)damageInfo->absorb; // Absorb + data << uint32(damageInfo->absorb); // Absorb } if(damageInfo->HitInfo & (HITINFO_RESIST | HITINFO_RESIST2)) { for(int i = 0; i < count; ++i) - data << (uint32)damageInfo->resist; // Resist + data << uint32(damageInfo->resist); // Resist } - data << (uint8)damageInfo->TargetState; - data << (uint32)0; - data << (uint32)0; + data << uint8(damageInfo->TargetState); + data << uint32(0); + data << uint32(0); if(damageInfo->HitInfo & HITINFO_BLOCK) - data << (uint32)damageInfo->blocked_amount; + data << uint32(damageInfo->blocked_amount); if(damageInfo->HitInfo & HITINFO_UNK3) data << uint32(0); @@ -4629,72 +4677,17 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo) void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) { - sLog.outDebug("WORLD: Sending SMSG_ATTACKERSTATEUPDATE"); - - WorldPacket data(SMSG_ATTACKERSTATEUPDATE, (16+45)); // we guess size - data << uint32(HitInfo); // flags - data.append(GetPackGUID()); - data.append(target->GetPackGUID()); - int32 damageDone = Damage-AbsorbDamage-Resist-BlockedAmount; - data << uint32(damageDone);// damage - data << uint32(int32 (target->GetHealth()-damageDone ) >0 ? 0 : damageDone - target->GetHealth()); // Overkill - - data << (uint8)SwingType; // count? - - // for(i = 0; i < SwingType; ++i) - data << (uint32)damageSchoolMask; - data << (float)(damageDone); - data << (uint32)(damageDone); - // end loop - - if(HitInfo & (HITINFO_ABSORB | HITINFO_ABSORB2)) - { - // for(i = 0; i < SwingType; ++i) - data << uint32(AbsorbDamage); - // end loop - } - - if(HitInfo & (HITINFO_RESIST | HITINFO_RESIST2)) - { - // for(i = 0; i < SwingType; ++i) - data << uint32(Resist); - // end loop - } - - data << (uint8)TargetState; - data << (uint32)0; - data << (uint32)0; - - if(HitInfo & HITINFO_BLOCK) - { - data << uint32(BlockedAmount); - } - - if(HitInfo & HITINFO_UNK3) - { - data << uint32(0); - } - - if(HitInfo & HITINFO_UNK1) - { - data << uint32(0); - data << float(0); - data << float(0); - data << float(0); - data << float(0); - data << float(0); - data << float(0); - data << float(0); - data << float(0); - for(uint8 i = 0; i < 5; ++i) - { - data << float(0); - data << float(0); - } - data << uint32(0); - } - - SendMessageToSet( &data, true ); + CalcDamageInfo dmgInfo; + dmgInfo.HitInfo = HitInfo; + dmgInfo.attacker = this; + dmgInfo.target = target; + dmgInfo.damage = Damage - AbsorbDamage - Resist - BlockedAmount; + dmgInfo.damageSchoolMask = damageSchoolMask; + dmgInfo.absorb = AbsorbDamage; + dmgInfo.resist = Resist; + dmgInfo.TargetState = TargetState; + dmgInfo.blocked_amount = BlockedAmount; + SendAttackStateUpdate(&dmgInfo); } bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown) @@ -7370,7 +7363,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig if( m_extraAttacks && IsSpellHaveEffect(triggerEntry, SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) return false; - // Costum requirements (not listed in procEx) Warning! damage dealing after this + // Custom requirements (not listed in procEx) Warning! damage dealing after this // Custom triggered spells switch (auraSpellInfo->Id) { @@ -7404,7 +7397,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig // Greater Heal Refund (Avatar Raiment set) case 37594: { - // Not give if target alredy have full health + // Not give if target already have full health if (pVictim->GetHealth() == pVictim->GetMaxHealth()) return false; // If your Greater Heal brings the target to full health, you gain $37595s1 mana. @@ -7439,7 +7432,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig } } - // Costum basepoints/target for exist spell + // Custom basepoints/target for exist spell // dummy basepoints or other customs switch(trigger_spell_id) { @@ -7452,7 +7445,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig target = pVictim; break; } - // Combo points add triggers (need add combopoint only for main tatget, and after possible combopoints reset) + // Combo points add triggers (need add combopoint only for main target, and after possible combopoints reset) case 15250: // Rogue Setup { if(!pVictim || pVictim != getVictim()) // applied only for main target @@ -8032,7 +8025,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) ) { addUnitState(UNIT_STAT_MELEE_ATTACKING); - SendAttackStart(victim); + SendMeleeAttackStart(victim); return true; } return false; @@ -8081,7 +8074,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) resetAttackTimer(OFF_ATTACK); if(meleeAttack) - SendAttackStart(victim); + SendMeleeAttackStart(victim); return true; } @@ -8110,7 +8103,7 @@ bool Unit::AttackStop() ((Creature*)this)->SetNoSearchAssistance(false); } - SendAttackStop(victim); + SendMeleeAttackStop(victim); return true; } @@ -9285,7 +9278,6 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama break; } - if(pVictim) { uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); @@ -10625,7 +10617,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) void Unit::SetHover(bool on) { if(on) - CastSpell(this,11010,true); + CastSpell(this, 11010, true); else RemoveAurasDueToSpell(11010); } @@ -11832,7 +11824,7 @@ bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate) } } - // or use empty slot in other case + // or use empty slot in other case for(uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { if (!PetActionBar[i].SpellOrAction && PetActionBar[i].IsActionBarForSpell()) @@ -12344,7 +12336,7 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) if(!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - WorldPacket data(SMSG_PET_CAST_FAILED, (4+1)); + WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1); data << uint8(0); // cast count? data << uint32(spellid); data << uint8(msg); @@ -12370,7 +12362,7 @@ void Unit::SendPetTalk (uint32 pettalk) if(!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - WorldPacket data(SMSG_PET_ACTION_SOUND, 8+4); + WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); data << uint64(GetGUID()); data << uint32(pettalk); ((Player*)owner)->GetSession()->SendPacket(&data); @@ -12397,7 +12389,7 @@ void Unit::SendPetClearCooldown (uint32 spellid) if(!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(spellid); data << uint64(GetGUID()); ((Player*)owner)->GetSession()->SendPacket(&data); @@ -12409,8 +12401,9 @@ void Unit::SendPetAIReaction(uint64 guid) if(!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - WorldPacket data(SMSG_AI_REACTION, 12); - data << uint64(guid) << uint32(00000002); + WorldPacket data(SMSG_AI_REACTION, 8 + 4); + data << uint64(guid); + data << uint32(AI_REACTION_AGGRO); ((Player*)owner)->GetSession()->SendPacket(&data); } @@ -13385,7 +13378,8 @@ void Unit::SetStunned(bool apply) // Creature specific if(GetTypeId() != TYPEID_PLAYER) ((Creature*)this)->StopMoving(); - //else + else + SetStandState(UNIT_STAND_STATE_STAND); // SetUnitMovementFlags(0); //Clear movement flags WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8); @@ -13649,7 +13643,7 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer) if(GetCharmInfo()) GetCharmInfo()->SetPetNumber(0, true); else - sLog.outError("Aura::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", GetGUID(), GetTypeId()); + sLog.outError("Aura::HandleModCharm: target="UI64FMTD" with typeid=%d has a charm aura but no charm info!", GetGUID(), GetTypeId()); } } diff --git a/src/game/Unit.h b/src/game/Unit.h index 399d0667e3e..375e21e5f4d 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -638,8 +638,8 @@ enum MovementFlags MOVEMENTFLAG_RIGHT = 0x00000020, MOVEMENTFLAG_PITCH_UP = 0x00000040, MOVEMENTFLAG_PITCH_DOWN = 0x00000080, - MOVEMENTFLAG_WALK_MODE = 0x00000100, - MOVEMENTFLAG_ONTRANSPORT = 0x00000200, + MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking + MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures MOVEMENTFLAG_LEVITATING = 0x00000400, MOVEMENTFLAG_FLY_UNK1 = 0x00000800, MOVEMENTFLAG_JUMPING = 0x00001000, @@ -658,6 +658,42 @@ enum MovementFlags MOVEMENTFLAG_UNK3 = 0x40000000 }; +enum MonsterMovementFlags +{ + MONSTER_MOVE_NONE = 0x00000000, + MONSTER_MOVE_FORWARD = 0x00000001, + MONSTER_MOVE_BACKWARD = 0x00000002, + MONSTER_MOVE_STRAFE_LEFT = 0x00000004, + MONSTER_MOVE_STRAFE_RIGHT = 0x00000008, + MONSTER_MOVE_LEFT = 0x00000010, // turn + MONSTER_MOVE_RIGHT = 0x00000020, // turn + MONSTER_MOVE_PITCH_UP = 0x00000040, + MONSTER_MOVE_PITCH_DOWN = 0x00000080, + MONSTER_MOVE_TELEPORT = 0x00000100, + MONSTER_MOVE_TELEPORT2 = 0x00000200, + MONSTER_MOVE_LEVITATING = 0x00000400, + MONSTER_MOVE_UNK1 = 0x00000800, // float+uint32 + MONSTER_MOVE_WALK = 0x00001000, // run2? + MONSTER_MOVE_SPLINE = 0x00002000, // spline n*(float x,y,z) + // 0x4000, 0x8000, 0x10000, 0x20000 run + MONSTER_MOVE_SPLINE2 = 0x00040000, // spline n*(float x,y,z) + MONSTER_MOVE_UNK2 = 0x00080000, // used for flying mobs + MONSTER_MOVE_UNK3 = 0x00100000, // used for flying mobs + MONSTER_MOVE_UNK4 = 0x00200000, // uint8+uint32 + MONSTER_MOVE_UNK5 = 0x00400000, // run in place, then teleport to final point + MONSTER_MOVE_UNK6 = 0x00800000, // teleport + MONSTER_MOVE_UNK7 = 0x01000000, // run + MONSTER_MOVE_FLY = 0x02000000, // swimming/flying (depends on mob?) + MONSTER_MOVE_UNK9 = 0x04000000, // run + MONSTER_MOVE_UNK10 = 0x08000000, // run + MONSTER_MOVE_UNK11 = 0x10000000, // run + MONSTER_MOVE_UNK12 = 0x20000000, // run + MONSTER_MOVE_UNK13 = 0x40000000, // levitating + + // masks + MONSTER_MOVE_SPLINE_FLY = 0x00003000, // fly by points +}; + struct MovementInfo { // common @@ -743,7 +779,7 @@ struct CalcDamageInfo uint32 procAttacker; uint32 procVictim; uint32 procEx; - uint32 cleanDamage; // Used only fo rage calcultion + uint32 cleanDamage; // Used only for rage calculation MeleeHitOutcome hitOutCome; // TODO: remove this field (need use TargetState) }; @@ -770,6 +806,19 @@ struct SpellNonMeleeDamage{ uint32 cleanDamage; }; +struct SpellPeriodicAuraLogInfo +{ + SpellPeriodicAuraLogInfo(AuraEffect *_auraEff, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier) + : auraEff(_auraEff), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier) {} + + AuraEffect *auraEff; + uint32 damage; + uint32 absorb; + uint32 resist; + uint32 overDamage; // overkill/overheal + float multiplier; +}; + uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition); #define MAX_DECLINED_NAME_CASES 5 @@ -989,6 +1038,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void CombatStopWithPets(bool includingCast = false); Unit* SelectNearbyTarget(float dist = NOMINAL_MELEE_RANGE) const; bool hasNegativeAuraWithInterruptFlag(uint32 flag); + void SendMeleeAttackStop(Unit* victim); + void SendMeleeAttackStart(Unit* pVictim); void addUnitState(uint32 f) { m_state |= f; } bool hasUnitState(const uint32 f) const { return (m_state & f); } @@ -1212,11 +1263,11 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void DeMorph(); - void SendAttackStart(Unit* pVictim); void SendAttackStateUpdate(CalcDamageInfo *damageInfo); void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log); - void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo); void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo); void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); @@ -1743,9 +1794,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject ThreatManager m_ThreatManager; private: - void SendAttackStop(Unit* victim); // only from AttackStop(Unit*) - //void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*) - bool IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry const * procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const *& spellProcEvent ); bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); bool HandleObsModEnergyAuraProc( Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index b9c1ec04c63..34547040cda 100644 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -103,24 +103,20 @@ void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size) *dst_size = c_stream.total_out; } -bool UpdateData::BuildPacket(WorldPacket *packet, bool /*hasTransport*/) +bool UpdateData::BuildPacket(WorldPacket *packet) { - ByteBuffer buf(m_data.size() + 10 + m_outOfRangeGUIDs.size()*8); + ByteBuffer buf(m_data.size()); buf << (uint32) (!m_outOfRangeGUIDs.empty() ? m_blockCount + 1 : m_blockCount); - //buf << (uint8) (hasTransport ? 1 : 0); if(!m_outOfRangeGUIDs.empty()) { buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS; buf << (uint32) m_outOfRangeGUIDs.size(); - for(std::set<uint64>::const_iterator i = m_outOfRangeGUIDs.begin(); - i != m_outOfRangeGUIDs.end(); ++i) + for(std::set<uint64>::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i) { - //buf.appendPackGUID(*i); - buf << (uint8)0xFF; - buf << (uint64) *i; + buf.appendPackGUID(*i); } } @@ -128,24 +124,23 @@ bool UpdateData::BuildPacket(WorldPacket *packet, bool /*hasTransport*/) packet->clear(); - if (m_data.size() > 50 ) + size_t pSize = buf.size(); + + if (pSize > 100 ) // compress large packets { - uint32 destsize = buf.size() + buf.size()/10 + 16; - packet->resize( destsize ); + packet->resize(pSize); - packet->put(0, (uint32)buf.size()); + packet->put<uint32>(0, pSize); - Compress(const_cast<uint8*>(packet->contents()) + sizeof(uint32), - &destsize, - (void*)buf.contents(), - buf.size()); + uint32 destsize = pSize; + Compress(const_cast<uint8*>(packet->contents()) + sizeof(uint32), &destsize, (void*)buf.contents(), pSize); if (destsize == 0) return false; packet->resize( destsize + sizeof(uint32) ); packet->SetOpcode( SMSG_COMPRESSED_UPDATE_OBJECT ); } - else + else // send small packets without compression { packet->append( buf ); packet->SetOpcode( SMSG_UPDATE_OBJECT ); diff --git a/src/game/UpdateData.h b/src/game/UpdateData.h index 71a9258b90b..c563911ba74 100644 --- a/src/game/UpdateData.h +++ b/src/game/UpdateData.h @@ -35,15 +35,17 @@ enum OBJECT_UPDATE_TYPE enum OBJECT_UPDATE_FLAGS { - UPDATEFLAG_NONE = 0x00, - UPDATEFLAG_SELF = 0x01, - UPDATEFLAG_TRANSPORT = 0x02, - UPDATEFLAG_HAS_TARGET = 0x04, - UPDATEFLAG_LOWGUID = 0x08, - UPDATEFLAG_HIGHGUID = 0x10, - UPDATEFLAG_LIVING = 0x20, - UPDATEFLAG_HAS_POSITION = 0x40, - UPDATEFLAG_VEHICLE = 0x80 + UPDATEFLAG_NONE = 0x0000, + UPDATEFLAG_SELF = 0x0001, + UPDATEFLAG_TRANSPORT = 0x0002, + UPDATEFLAG_HAS_TARGET = 0x0004, + UPDATEFLAG_LOWGUID = 0x0008, + UPDATEFLAG_HIGHGUID = 0x0010, + UPDATEFLAG_LIVING = 0x0020, + UPDATEFLAG_HAS_POSITION = 0x0040, + UPDATEFLAG_VEHICLE = 0x0080, + UPDATEFLAG_POSITION = 0x0100, + UPDATEFLAG_ROTATION = 0x0200 }; class UpdateData @@ -54,7 +56,7 @@ class UpdateData void AddOutOfRangeGUID(std::set<uint64>& guids); void AddOutOfRangeGUID(const uint64 &guid); void AddUpdateBlock(const ByteBuffer &block); - bool BuildPacket(WorldPacket *packet, bool hasTransport = false); + bool BuildPacket(WorldPacket *packet); bool HasData() { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); } void Clear(); diff --git a/src/game/VoiceChatHandler.cpp b/src/game/VoiceChatHandler.cpp index 8e787549e33..0aef129a010 100644 --- a/src/game/VoiceChatHandler.cpp +++ b/src/game/VoiceChatHandler.cpp @@ -24,23 +24,23 @@ #include "Opcodes.h" #include "Log.h" -void WorldSession::HandleVoiceSettingsOpcode( WorldPacket & recv_data ) +void WorldSession::HandleVoiceSessionEnableOpcode( WorldPacket & recv_data ) { - sLog.outDebug("WORLD: CMSG_VOICE_SETTINGS"); + sLog.outDebug("WORLD: CMSG_VOICE_SESSION_ENABLE"); // uint8 isVoiceEnabled, uint8 isMicrophoneEnabled recv_data.hexlike(); } -void WorldSession::HandleChannelEnableVoiceOpcode( WorldPacket & recv_data ) +void WorldSession::HandleChannelVoiceOnOpcode( WorldPacket & recv_data ) { - sLog.outDebug("WORLD: CMSG_CHANNEL_ENABLE_VOICE"); + sLog.outDebug("WORLD: CMSG_CHANNEL_VOICE_ON"); // Enable Voice button in channel context menu recv_data.hexlike(); } -void WorldSession::HandleChannelVoiceChatQuery( WorldPacket & recv_data ) +void WorldSession::HandleSetActiveVoiceChannel( WorldPacket & recv_data ) { - sLog.outDebug("WORLD: CMSG_CHANNEL_VOICE_CHAT_QUERY"); + sLog.outDebug("WORLD: CMSG_SET_ACTIVE_VOICE_CHANNEL"); // uint32, string recv_data.hexlike(); } diff --git a/src/game/World.cpp b/src/game/World.cpp index 563ee500d5f..e180e38b4db 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1491,7 +1491,7 @@ void World::SetInitialWorldSettings() sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d", local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); - LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " I64FMTD ", '%s', 0)", + LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)", realmID, uint64(m_startTime), isoDate); m_timers[WUPDATE_OBJECTS].SetInterval(0); @@ -1730,7 +1730,7 @@ void World::Update(uint32 diff) uint32 maxClientsNum = GetMaxActiveSessionCount(); m_timers[WUPDATE_UPTIME].Reset(); - LoginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " I64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime)); + LoginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime)); } /// <li> Clean logs table @@ -1742,7 +1742,7 @@ void World::Update(uint32 diff) uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount(); m_timers[WUPDATE_CLEANDB].Reset(); - LoginDatabase.PExecute("DELETE FROM logs WHERE (time + %u) < "I64FMTD";", + LoginDatabase.PExecute("DELETE FROM logs WHERE (time + %u) < "UI64FMTD";", sWorld.getConfig(CONFIG_LOGDB_CLEARTIME), uint64(time(0))); } } diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 36342c8dee1..1721e3ff295 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -122,8 +122,8 @@ void WorldSession::SendPacket(WorldPacket const* packet) { uint64 minTime = uint64(cur_time - lastTime); uint64 fullTime = uint64(lastTime - firstTime); - sLog.outDetail("Send all time packets count: " I64FMTD " bytes: " I64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u",sendPacketCount,sendPacketBytes,float(sendPacketCount)/fullTime,float(sendPacketBytes)/fullTime,uint32(fullTime)); - sLog.outDetail("Send last min packets count: " I64FMTD " bytes: " I64FMTD " avr.count/sec: %f avr.bytes/sec: %f",sendLastPacketCount,sendLastPacketBytes,float(sendLastPacketCount)/minTime,float(sendLastPacketBytes)/minTime); + sLog.outDetail("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u",sendPacketCount,sendPacketBytes,float(sendPacketCount)/fullTime,float(sendPacketBytes)/fullTime,uint32(fullTime)); + sLog.outDetail("Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f",sendLastPacketCount,sendLastPacketBytes,float(sendLastPacketCount)/minTime,float(sendLastPacketBytes)/minTime); lastTime = cur_time; sendLastPacketCount = 1; @@ -188,7 +188,7 @@ bool WorldSession::Update(uint32 /*diff*/) (this->*opHandle.handler)(*packet); // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer break; - case STATUS_TRANSFER_PENDING: + case STATUS_TRANSFER: if(!_player) logUnexpectedOpcode(packet, "the player has not logged in yet"); else if(_player->IsInWorld()) @@ -350,12 +350,12 @@ void WorldSession::LogoutPlayer(bool Save) if(Save) { uint32 eslot; - for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++) + for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j) { eslot = j - BUYBACK_SLOT_START; - _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+eslot*2,0); - _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+eslot,0); - _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+eslot,0); + _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); + _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); + _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); } _player->SaveToDB(); } diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 346afd99edc..53f2a4b52f6 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -282,8 +282,8 @@ class TRINITY_DLL_SPEC WorldSession void HandleMountSpecialAnimOpcode(WorldPacket &recvdata); // character view - void HandleToggleHelmOpcode(WorldPacket& recv_data); - void HandleToggleCloakOpcode(WorldPacket& recv_data); + void HandleShowingHelmOpcode(WorldPacket& recv_data); + void HandleShowingCloakOpcode(WorldPacket& recv_data); // repair void HandleRepairItemOpcode(WorldPacket& recvPacket); @@ -308,11 +308,11 @@ class TRINITY_DLL_SPEC WorldSession void HandleLogoutCancelOpcode(WorldPacket& recvPacket); // GM Ticket opcodes - void HandleGMTicketCreateOpcode(WorldPacket& recvPacket); - void HandleGMTicketUpdateOpcode(WorldPacket& recvPacket); - void HandleGMTicketDeleteOpcode(WorldPacket& recvPacket); - void HandleGMTicketGetTicketOpcode(WorldPacket& recvPacket); - void HandleGMTicketSystemStatusOpcode(WorldPacket& recvPacket); + void HandleGMTicketCreateOpcode(WorldPacket& recvPacket); + void HandleGMTicketUpdateOpcode(WorldPacket& recvPacket); + void HandleGMTicketDeleteOpcode(WorldPacket& recvPacket); + void HandleGMTicketGetTicketOpcode(WorldPacket& recvPacket); + void HandleGMTicketSystemStatusOpcode(WorldPacket& recvPacket); //void HandleGMSurveySubmit(WorldPacket& recvPacket); @@ -323,14 +323,14 @@ class TRINITY_DLL_SPEC WorldSession void HandleSetSelectionOpcode(WorldPacket& recvPacket); void HandleStandStateChangeOpcode(WorldPacket& recvPacket); void HandleEmoteOpcode(WorldPacket& recvPacket); - void HandleFriendListOpcode(WorldPacket& recvPacket); + void HandleContactListOpcode(WorldPacket& recvPacket); void HandleAddFriendOpcode(WorldPacket& recvPacket); static void HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote); void HandleDelFriendOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcode(WorldPacket& recvPacket); static void HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId); void HandleDelIgnoreOpcode(WorldPacket& recvPacket); - void HandleSetFriendNoteOpcode(WorldPacket& recvPacket); + void HandleSetContactNotesOpcode(WorldPacket& recvPacket); void HandleBugOpcode(WorldPacket& recvPacket); void HandleSetAmmoOpcode(WorldPacket& recvPacket); void HandleItemNameQueryOpcode(WorldPacket& recvPacket); @@ -339,8 +339,8 @@ class TRINITY_DLL_SPEC WorldSession void HandleSetFactionAtWar( WorldPacket & recv_data ); void HandleSetFactionCheat( WorldPacket & recv_data ); - void HandleSetWatchedFactionIndexOpcode(WorldPacket & recv_data); - void HandleSetWatchedFactionInactiveOpcode(WorldPacket & recv_data); + void HandleSetWatchedFactionOpcode(WorldPacket & recv_data); + void HandleSetFactionInactiveOpcode(WorldPacket & recv_data); void HandleUpdateAccountData(WorldPacket& recvPacket); void HandleRequestAccountData(WorldPacket& recvPacket); @@ -378,21 +378,21 @@ class TRINITY_DLL_SPEC WorldSession //void HandleGroupCancelOpcode(WorldPacket& recvPacket); void HandleGroupAcceptOpcode(WorldPacket& recvPacket); void HandleGroupDeclineOpcode(WorldPacket& recvPacket); - void HandleGroupUninviteNameOpcode(WorldPacket& recvPacket); + void HandleGroupUninviteOpcode(WorldPacket& recvPacket); void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket); void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket); - void HandleGroupLeaveOpcode(WorldPacket& recvPacket); - void HandleGroupPassOnLootOpcode( WorldPacket &recv_data ); + void HandleGroupDisbandOpcode(WorldPacket& recvPacket); + void HandleOptOutOfLootOpcode( WorldPacket &recv_data ); void HandleLootMethodOpcode(WorldPacket& recvPacket); void HandleLootRoll( WorldPacket &recv_data ); void HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ); - void HandleRaidIconTargetOpcode( WorldPacket & recv_data ); + void HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ); void HandleRaidReadyCheckOpcode( WorldPacket & recv_data ); - void HandleRaidReadyCheckFinishOpcode( WorldPacket & recv_data ); - void HandleRaidConvertOpcode( WorldPacket & recv_data ); + void HandleRaidReadyCheckFinishedOpcode( WorldPacket & recv_data ); + void HandleGroupRaidConvertOpcode( WorldPacket & recv_data ); void HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ); - void HandleGroupAssistantOpcode( WorldPacket & recv_data ); - void HandleGroupPromoteOpcode( WorldPacket & recv_data ); + void HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ); + void HandlePartyAssignmentOpcode( WorldPacket & recv_data ); void HandlePetitionBuyOpcode(WorldPacket& recv_data); void HandlePetitionShowSignOpcode(WorldPacket& recv_data); @@ -410,7 +410,7 @@ class TRINITY_DLL_SPEC WorldSession void HandleGuildAcceptOpcode(WorldPacket& recvPacket); void HandleGuildDeclineOpcode(WorldPacket& recvPacket); void HandleGuildInfoOpcode(WorldPacket& recvPacket); - void HandleGuildEventLogOpcode(WorldPacket& recvPacket); + void HandleGuildEventLogQueryOpcode(WorldPacket& recvPacket); void HandleGuildRosterOpcode(WorldPacket& recvPacket); void HandleGuildPromoteOpcode(WorldPacket& recvPacket); void HandleGuildDemoteOpcode(WorldPacket& recvPacket); @@ -423,14 +423,14 @@ class TRINITY_DLL_SPEC WorldSession void HandleGuildRankOpcode(WorldPacket& recvPacket); void HandleGuildAddRankOpcode(WorldPacket& recvPacket); void HandleGuildDelRankOpcode(WorldPacket& recvPacket); - void HandleGuildChangeInfoOpcode(WorldPacket& recvPacket); - void HandleGuildSaveEmblemOpcode(WorldPacket& recvPacket); + void HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket); + void HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket); void HandleTaxiNodeStatusQueryOpcode(WorldPacket& recvPacket); void HandleTaxiQueryAvailableNodes(WorldPacket& recvPacket); void HandleActivateTaxiOpcode(WorldPacket& recvPacket); - void HandleActivateTaxiFarOpcode(WorldPacket& recvPacket); - void HandleTaxiNextDestinationOpcode(WorldPacket& recvPacket); + void HandleActivateTaxiExpressOpcode(WorldPacket& recvPacket); + void HandleMoveSplineDoneOpcode(WorldPacket& recvPacket); void HandleTabardVendorActivateOpcode(WorldPacket& recvPacket); void HandleBankerActivateOpcode(WorldPacket& recvPacket); @@ -473,16 +473,16 @@ class TRINITY_DLL_SPEC WorldSession void HandleAuctionPlaceBid( WorldPacket & recv_data ); void HandleAuctionListPendingSales( WorldPacket & recv_data ); - void HandleGetMail( WorldPacket & recv_data ); + void HandleGetMailList( WorldPacket & recv_data ); void HandleSendMail( WorldPacket & recv_data ); - void HandleTakeMoney( WorldPacket & recv_data ); - void HandleTakeItem( WorldPacket & recv_data ); - void HandleMarkAsRead( WorldPacket & recv_data ); - void HandleReturnToSender( WorldPacket & recv_data ); + void HandleMailTakeMoney( WorldPacket & recv_data ); + void HandleMailTakeItem( WorldPacket & recv_data ); + void HandleMailMarkAsRead( WorldPacket & recv_data ); + void HandleMailReturnToSender( WorldPacket & recv_data ); void HandleMailDelete( WorldPacket & recv_data ); void HandleItemTextQuery( WorldPacket & recv_data); void HandleMailCreateTextItem(WorldPacket & recv_data ); - void HandleMsgQueryNextMailtime(WorldPacket & recv_data ); + void HandleQueryNextMailTime(WorldPacket & recv_data ); void HandleCancelChanneling(WorldPacket & recv_data ); void SendItemPageInfo( ItemPrototype *itemProto ); @@ -517,14 +517,14 @@ class TRINITY_DLL_SPEC WorldSession void HandleCancelAutoRepeatSpellOpcode(WorldPacket& recvPacket); void HandleLearnTalentOpcode(WorldPacket& recvPacket); - void HandleTalentWipeOpcode(WorldPacket& recvPacket); + void HandleTalentWipeConfirmOpcode(WorldPacket& recvPacket); void HandleUnlearnSkillOpcode(WorldPacket& recvPacket); void HandleQuestgiverStatusQueryOpcode(WorldPacket& recvPacket); - void HandleQuestgiverStatusQueryMultipleOpcode(WorldPacket& recvPacket); + void HandleQuestgiverStatusMultipleQuery(WorldPacket& recvPacket); void HandleQuestgiverHelloOpcode(WorldPacket& recvPacket); void HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvPacket); - void HandleQuestgiverQuestQueryOpcode(WorldPacket& recvPacket); + void HandleQuestgiverQueryQuestOpcode(WorldPacket& recvPacket); void HandleQuestgiverChooseRewardOpcode(WorldPacket& recvPacket); void HandleQuestgiverRequestRewardOpcode(WorldPacket& recvPacket); void HandleQuestQueryOpcode(WorldPacket& recvPacket); @@ -532,22 +532,22 @@ class TRINITY_DLL_SPEC WorldSession void HandleQuestLogSwapQuest(WorldPacket& recv_data ); void HandleQuestLogRemoveQuest(WorldPacket& recv_data); void HandleQuestConfirmAccept(WorldPacket& recv_data); - void HandleQuestComplete(WorldPacket& recv_data); - void HandleQuestAutoLaunch(WorldPacket& recvPacket); - void HandleQuestPushToParty(WorldPacket& recvPacket); + void HandleQuestgiverCompleteQuest(WorldPacket& recv_data); + void HandleQuestgiverQuestAutoLaunch(WorldPacket& recvPacket); + void HandlePushQuestToParty(WorldPacket& recvPacket); void HandleQuestPushResult(WorldPacket& recvPacket); void HandleMessagechatOpcode(WorldPacket& recvPacket); void HandleTextEmoteOpcode(WorldPacket& recvPacket); void HandleChatIgnoredOpcode(WorldPacket& recvPacket); - void HandleCorpseReclaimOpcode( WorldPacket& recvPacket ); + void HandleReclaimCorpseOpcode( WorldPacket& recvPacket ); void HandleCorpseQueryOpcode( WorldPacket& recvPacket ); void HandleResurrectResponseOpcode(WorldPacket& recvPacket); void HandleSummonResponseOpcode(WorldPacket& recv_data); - void HandleChannelJoin(WorldPacket& recvPacket); - void HandleChannelLeave(WorldPacket& recvPacket); + void HandleJoinChannel(WorldPacket& recvPacket); + void HandleLeaveChannel(WorldPacket& recvPacket); void HandleChannelList(WorldPacket& recvPacket); void HandleChannelPassword(WorldPacket& recvPacket); void HandleChannelSetOwner(WorldPacket& recvPacket); @@ -560,18 +560,18 @@ class TRINITY_DLL_SPEC WorldSession void HandleChannelKick(WorldPacket& recvPacket); void HandleChannelBan(WorldPacket& recvPacket); void HandleChannelUnban(WorldPacket& recvPacket); - void HandleChannelAnnounce(WorldPacket& recvPacket); + void HandleChannelAnnouncements(WorldPacket& recvPacket); void HandleChannelModerate(WorldPacket& recvPacket); - void HandleChannelRosterQuery(WorldPacket& recvPacket); - void HandleChannelInfoQuery(WorldPacket& recvPacket); - void HandleChannelJoinNotify(WorldPacket& recvPacket); void HandleChannelDeclineInvite(WorldPacket& recvPacket); + void HandleChannelDisplayListQuery(WorldPacket& recvPacket); + void HandleGetChannelMemberCount(WorldPacket& recvPacket); + void HandleSetChannelWatch(WorldPacket& recvPacket); - void HandleCompleteCinema(WorldPacket& recvPacket); + void HandleCompleteCinematic(WorldPacket& recvPacket); void HandleNextCinematicCamera(WorldPacket& recvPacket); void HandlePageQuerySkippedOpcode(WorldPacket& recvPacket); - void HandlePageQueryOpcode(WorldPacket& recvPacket); + void HandlePageTextQueryOpcode(WorldPacket& recvPacket); void HandleTutorialFlag ( WorldPacket & recv_data ); void HandleTutorialClear( WorldPacket & recv_data ); @@ -590,24 +590,24 @@ class TRINITY_DLL_SPEC WorldSession void HandlePetCastSpellOpcode( WorldPacket& recvPacket ); void HandlePetLearnTalent( WorldPacket& recvPacket ); - void HandleSetActionBar(WorldPacket& recv_data); + void HandleSetActionBarToggles(WorldPacket& recv_data); - void HandleChangePlayerNameOpcode(WorldPacket& recv_data); + void HandleCharRenameOpcode(WorldPacket& recv_data); static void HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname); - void HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data); + void HandleSetPlayerDeclinedNames(WorldPacket& recv_data); - void HandleTotemDestroy(WorldPacket& recv_data); + void HandleTotemDestroyed(WorldPacket& recv_data); //BattleGround - void HandleBattleGroundHelloOpcode(WorldPacket &recv_data); - void HandleBattleGroundJoinOpcode(WorldPacket &recv_data); + void HandleBattlemasterHelloOpcode(WorldPacket &recv_data); + void HandleBattlemasterJoinOpcode(WorldPacket &recv_data); void HandleBattleGroundPlayerPositionsOpcode(WorldPacket& recv_data); - void HandleBattleGroundPVPlogdataOpcode( WorldPacket &recv_data ); - void HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ); - void HandleBattleGroundListOpcode( WorldPacket &recv_data ); - void HandleBattleGroundLeaveOpcode( WorldPacket &recv_data ); - void HandleBattleGroundArenaJoin( WorldPacket &recv_data ); - void HandleBattleGroundReportAFK( WorldPacket &recv_data ); + void HandlePVPLogDataOpcode( WorldPacket &recv_data ); + void HandleBattleFieldPortOpcode( WorldPacket &recv_data ); + void HandleBattlefieldListOpcode( WorldPacket &recv_data ); + void HandleLeaveBattlefieldOpcode( WorldPacket &recv_data ); + void HandleBattlemasterJoinArena( WorldPacket &recv_data ); + void HandleReportPvPAFK( WorldPacket &recv_data ); void HandleWardenDataOpcode(WorldPacket& recv_data); void HandleWorldTeleportOpcode(WorldPacket& recv_data); @@ -615,64 +615,64 @@ class TRINITY_DLL_SPEC WorldSession void HandleRandomRollOpcode(WorldPacket& recv_data); void HandleFarSightOpcode(WorldPacket& recv_data); void HandleSetLfgOpcode(WorldPacket& recv_data); - void HandleDungeonDifficultyOpcode(WorldPacket& recv_data); - void HandleMoveFlyModeChangeAckOpcode(WorldPacket& recv_data); - void HandleLfgAutoJoinOpcode(WorldPacket& recv_data); - void HandleLfgCancelAutoJoinOpcode(WorldPacket& recv_data); - void HandleLfmAutoAddMembersOpcode(WorldPacket& recv_data); - void HandleLfmCancelAutoAddmembersOpcode(WorldPacket& recv_data); + void HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data); + void HandleMoveSetCanFlyAckOpcode(WorldPacket& recv_data); + void HandleLfgSetAutoJoinOpcode(WorldPacket& recv_data); + void HandleLfgClearAutoJoinOpcode(WorldPacket& recv_data); + void HandleLfmSetAutoFillOpcode(WorldPacket& recv_data); + void HandleLfmClearAutoFillOpcode(WorldPacket& recv_data); void HandleLfgClearOpcode(WorldPacket& recv_data); - void HandleLfmSetNoneOpcode(WorldPacket& recv_data); - void HandleLfmSetOpcode(WorldPacket& recv_data); - void HandleLfgSetCommentOpcode(WorldPacket& recv_data); - void HandleChooseTitleOpcode(WorldPacket& recv_data); - void HandleRealmStateRequestOpcode(WorldPacket& recv_data); + void HandleLfmClearOpcode(WorldPacket& recv_data); + void HandleSetLfmOpcode(WorldPacket& recv_data); + void HandleSetLfgCommentOpcode(WorldPacket& recv_data); + void HandleSetTitleOpcode(WorldPacket& recv_data); + void HandleRealmSplitOpcode(WorldPacket& recv_data); void HandleTimeSyncResp(WorldPacket& recv_data); void HandleWhoisOpcode(WorldPacket& recv_data); void HandleResetInstancesOpcode(WorldPacket& recv_data); // Arena Team - void HandleInspectArenaStatsOpcode(WorldPacket& recv_data); + void HandleInspectArenaTeamsOpcode(WorldPacket& recv_data); void HandleArenaTeamQueryOpcode(WorldPacket& recv_data); void HandleArenaTeamRosterOpcode(WorldPacket& recv_data); - void HandleArenaTeamAddMemberOpcode(WorldPacket& recv_data); - void HandleArenaTeamInviteAcceptOpcode(WorldPacket& recv_data); - void HandleArenaTeamInviteDeclineOpcode(WorldPacket& recv_data); + void HandleArenaTeamInviteOpcode(WorldPacket& recv_data); + void HandleArenaTeamAcceptOpcode(WorldPacket& recv_data); + void HandleArenaTeamDeclineOpcode(WorldPacket& recv_data); void HandleArenaTeamLeaveOpcode(WorldPacket& recv_data); - void HandleArenaTeamRemoveFromTeamOpcode(WorldPacket& recv_data); + void HandleArenaTeamRemoveOpcode(WorldPacket& recv_data); void HandleArenaTeamDisbandOpcode(WorldPacket& recv_data); - void HandleArenaTeamPromoteToCaptainOpcode(WorldPacket& recv_data); + void HandleArenaTeamLeaderOpcode(WorldPacket& recv_data); void HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data); void HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data); - void HandleDismountOpcode(WorldPacket& recv_data); + void HandleCancelMountAuraOpcode(WorldPacket& recv_data); void HandleSelfResOpcode(WorldPacket& recv_data); - void HandleReportSpamOpcode(WorldPacket& recv_data); + void HandleComplainOpcode(WorldPacket& recv_data); void HandleRequestPetInfoOpcode(WorldPacket& recv_data); // Socket gem void HandleSocketOpcode(WorldPacket& recv_data); - void HandleCancelTempItemEnchantmentOpcode(WorldPacket& recv_data); + void HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data); - void HandleChannelEnableVoiceOpcode(WorldPacket & recv_data); - void HandleVoiceSettingsOpcode(WorldPacket& recv_data); - void HandleChannelVoiceChatQuery(WorldPacket& recv_data); + void HandleChannelVoiceOnOpcode(WorldPacket & recv_data); + void HandleVoiceSessionEnableOpcode(WorldPacket& recv_data); + void HandleSetActiveVoiceChannel(WorldPacket& recv_data); void HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data); // Guild Bank - void HandleGuildBankGetRights(WorldPacket& recv_data); - void HandleGuildBankGetMoneyAmount(WorldPacket& recv_data); - void HandleGuildBankQuery(WorldPacket& recv_data); - void HandleGuildBankTabColon(WorldPacket& recv_data); - void HandleGuildBankLog(WorldPacket& recv_data); - void HandleGuildBankDeposit(WorldPacket& recv_data); - void HandleGuildBankWithdraw(WorldPacket& recv_data); - void HandleGuildBankDepositItem(WorldPacket& recv_data); - void HandleGuildBankModifyTab(WorldPacket& recv_data); + void HandleGuildPermissions(WorldPacket& recv_data); + void HandleGuildBankMoneyWithdrawn(WorldPacket& recv_data); + void HandleGuildBankerActivate(WorldPacket& recv_data); + void HandleGuildBankQueryTab(WorldPacket& recv_data); + void HandleGuildBankLogQuery(WorldPacket& recv_data); + void HandleGuildBankDepositMoney(WorldPacket& recv_data); + void HandleGuildBankWithdrawMoney(WorldPacket& recv_data); + void HandleGuildBankSwapItems(WorldPacket& recv_data); + void HandleGuildBankUpdateTab(WorldPacket& recv_data); void HandleGuildBankBuyTab(WorldPacket& recv_data); - void HandleGuildBankTabText(WorldPacket& recv_data); - void HandleGuildBankSetTabText(WorldPacket& recv_data); + void HandleQueryGuildBankTabText(WorldPacket& recv_data); + void HandleSetGuildBankTabText(WorldPacket& recv_data); // Calendar void HandleCalendarGetCalendar(WorldPacket& recv_data); @@ -695,7 +695,7 @@ class TRINITY_DLL_SPEC WorldSession void HandleAlterAppearance(WorldPacket& recv_data); void HandleRemoveGlyph(WorldPacket& recv_data); void HandleCharCustomize(WorldPacket& recv_data); - void HandleInspectAchievements(WorldPacket& recv_data); + void HandleQueryInspectAchievements(WorldPacket& recv_data); private: // private trade methods void moveItems(Item* myItems[], Item* hisItems[]); diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 16988632871..7dc6b5483df 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -369,7 +369,7 @@ class ByteBuffer { if ((i == (j*8)) && ((i != (k*16)))) { - if (read<uint8>(i) < 0x0F) + if (read<uint8>(i) < 0x10) { sLog.outDebugInLine("| 0%X ", read<uint8>(i) ); } @@ -381,7 +381,7 @@ class ByteBuffer } else if (i == (k*16)) { - if (read<uint8>(i) < 0x0F) + if (read<uint8>(i) < 0x10) { sLog.outDebugInLine("\n"); @@ -399,7 +399,7 @@ class ByteBuffer } else { - if (read<uint8>(i) < 0x0F) + if (read<uint8>(i) < 0x10) { sLog.outDebugInLine("0%X ", read<uint8>(i) ); } diff --git a/src/shared/Common.h b/src/shared/Common.h index 37ced4c8e11..735c57eedbe 100644 --- a/src/shared/Common.h +++ b/src/shared/Common.h @@ -103,6 +103,7 @@ #include "LockedQueue.h" #include "Threading.h" +#include <ace/Basic_Types.h> #include <ace/Guard_T.h> #include <ace/RW_Thread_Mutex.h> #include <ace/Thread_Mutex.h> @@ -130,8 +131,6 @@ #include <float.h> #define I64FMT "%016I64X" -#define I64FMTD "%I64u" -#define SI64FMTD "%I64d" #define snprintf _snprintf #define atoll __atoi64 #define vsnprintf _vsnprintf @@ -143,10 +142,15 @@ #define stricmp strcasecmp #define strnicmp strncasecmp #define I64FMT "%016llX" -#define I64FMTD "%llu" -#define SI64FMTD "%lld" + #endif +#define UI64FMTD ACE_UINT64_FORMAT_SPECIFIER +#define UI64LIT(N) ACE_UINT64_LITERAL(N) + +#define SI64FMTD ACE_INT64_FORMAT_SPECIFIER +#define SI64LIT(N) ACE_INT64_LITERAL(N) + inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; } #define atol(a) strtoul( a, NULL, 10) diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index da6a865c6f2..f365a96df64 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -59,7 +59,7 @@ class Field if(mValue) { uint64 value; - sscanf(mValue,I64FMTD,&value); + sscanf(mValue,UI64FMTD,&value); return value; } else diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index f3fcae1faf7..d81594c9787 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -353,7 +353,7 @@ void Log::outDB( LogTypes type, const char * str ) LoginDatabase.escape_string(new_str); LoginDatabase.PExecute("INSERT INTO logs (time, realm, type, string) " - "VALUES ("I64FMTD", %u, %u, '%s');", uint64(time(0)), realm, (uint32)type, new_str.c_str()); + "VALUES (" UI64FMTD ", %u, %u, '%s');", uint64(time(0)), realm, (uint32)type, new_str.c_str()); } void Log::outString( const char * str, ... ) diff --git a/src/shared/vmap/CoordModelMapping.cpp b/src/shared/vmap/CoordModelMapping.cpp index c362101ffb4..5dd23f306aa 100644 --- a/src/shared/vmap/CoordModelMapping.cpp +++ b/src/shared/vmap/CoordModelMapping.cpp @@ -87,63 +87,65 @@ namespace VMAP bool CoordModelMapping::readCoordinateMapping(const std::string& pDirectoryFileName) { FILE *f = fopen(pDirectoryFileName.c_str(), "rb"); - bool result = false; + if(!f) + { + printf("ERROR: Can't open file: %s\n",pDirectoryFileName.c_str()); + return false; + } + char buffer[500+1]; - if(f) + CMappingEntry* cMappingEntry; + while(fgets(buffer, 500, f)) { - result = true; - CMappingEntry* cMappingEntry; - while(fgets(buffer, 500, f)) - { - //char namebuffer[500]; - char positionbuffer[500]; - int xpos, ypos, noVec; - float scale; - xpos = ypos = noVec = 0; + //char namebuffer[500]; + char positionbuffer[500]; + int xpos, ypos, noVec; + float scale; + xpos = ypos = noVec = 0; - //sscanf(buffer, "%d %d %s %s %f %d", &xpos, &ypos, namebuffer,positionbuffer, &scale, &noVec); + //sscanf(buffer, "%d %d %s %s %f %d", &xpos, &ypos, namebuffer,positionbuffer, &scale, &noVec); - // this is ugly, but the format has no read delimiter and a space could be in the first part of the name - int nameStart = findPosChar(buffer, ' ', 2);// find the 2. space - if(nameStart > -1 && (iFilterMethod == NULL || (*iFilterMethod)(buffer))) + // this is ugly, but the format has no read delimiter and a space could be in the first part of the name + int nameStart = findPosChar(buffer, ' ', 2);// find the 2. space + if(nameStart > -1 && (iFilterMethod == NULL || (*iFilterMethod)(buffer))) + { + ++nameStart; + // find the 1. / (now a space only can be found at the end of the name) + int nameEnd = nameStart + findPosChar(&buffer[nameStart], '/', 1); + // find the 1. space (after the name) + nameEnd += findPosChar(&buffer[nameEnd], ' ', 1); + buffer[nameEnd] = 0; // terminate the name + + sscanf(buffer, "%d %d", &xpos, &ypos); + sscanf(&buffer[nameEnd+1], "%s %f %d", positionbuffer, &scale, &noVec); + unsigned int mapId = getMapIdFromFilename(std::string(&buffer[nameStart])); + if(!iMapIds.contains(mapId)) { - ++nameStart; - // find the 1. / (now a space only can be found at the end of the name) - int nameEnd = nameStart + findPosChar(&buffer[nameStart], '/', 1); - // find the 1. space (after the name) - nameEnd += findPosChar(&buffer[nameEnd], ' ', 1); - buffer[nameEnd] = 0; // terminate the name - - sscanf(buffer, "%d %d", &xpos, &ypos); - sscanf(&buffer[nameEnd+1], "%s %f %d", positionbuffer, &scale, &noVec); - unsigned int mapId = getMapIdFromFilename(std::string(&buffer[nameStart])); - if(!iMapIds.contains(mapId)) - { - iMapIds.append(mapId); - } - if(!isWorldAreaMap(mapId)) - { - xpos = 0; // store all files under the groupKey - ypos = 0; - } - - std::string key = CMappingEntry::getKeyString(mapId, xpos, ypos); - cMappingEntry = getCMappingEntry(key); - if(cMappingEntry == 0) - { - cMappingEntry = new CMappingEntry(mapId, xpos, ypos); - addCMappingEntry(cMappingEntry); - } - char namebuffer2[500]; - sprintf(namebuffer2, "%d %s#%s_%f", noVec, &buffer[nameStart], positionbuffer, scale); - cMappingEntry->addFilename(namebuffer2); - //break; + iMapIds.append(mapId); + printf("Coords for map %u...\n",mapId); } + if(!isWorldAreaMap(mapId)) + { + xpos = 0; // store all files under the groupKey + ypos = 0; + } + + std::string key = CMappingEntry::getKeyString(mapId, xpos, ypos); + cMappingEntry = getCMappingEntry(key); + if(cMappingEntry == 0) + { + cMappingEntry = new CMappingEntry(mapId, xpos, ypos); + addCMappingEntry(cMappingEntry); + } + char namebuffer2[500]; + sprintf(namebuffer2, "%d %s#%s_%f", noVec, &buffer[nameStart], positionbuffer, scale); + cMappingEntry->addFilename(namebuffer2); + //break; } - fclose(f); } - return result; + fclose(f); + return true; } //============================================================ diff --git a/src/shared/vmap/TileAssembler.cpp b/src/shared/vmap/TileAssembler.cpp index 7ac4f683248..c2918a64fa4 100644 --- a/src/shared/vmap/TileAssembler.cpp +++ b/src/shared/vmap/TileAssembler.cpp @@ -150,447 +150,454 @@ namespace VMAP # endif #endif - bool result = true; std::string fname = iSrcDir; fname.append("/"); fname.append("dir"); iCoordModelMapping->setModelNameFilterMethod(iFilterMethod); - iCoordModelMapping->readCoordinateMapping(fname); + + printf("Read coordinate mapping...\n"); + if(!iCoordModelMapping->readCoordinateMapping(fname)) + return false; Array<unsigned int> mapIds = iCoordModelMapping->getMaps(); if(mapIds.size() == 0) { - result = false; + printf("Fatal error: empty map list!\n"); + return false; } - for(int i=0; i<mapIds.size() && result; ++i) + + for(int i=0; i<mapIds.size(); ++i) { unsigned int mapId = mapIds[i]; #ifdef _ASSEMBLER_DEBUG if(mapId == 0) // "Azeroth" just for debug { - for(int x=28; x<29 && result; ++x) //debug + for(int x=28; x<29; ++x) //debug { - for(int y=28; y<29 && result; ++y) + for(int y=28; y<29; ++y) { - #else - // ignore DeeprunTram (369) it is too large for short vector and not important - // ignore test (13), Test (29) , development (451) - if(mapId != 369 && mapId != 13 && mapId != 29 && mapId != 451) + #else + // ignore DeeprunTram (369) it is too large for short vector and not important + // ignore test (13), Test (29) , development (451) + if(mapId != 369 && mapId != 13 && mapId != 29 && mapId != 451) + { + for(int x=0; x<66; ++x) + { + for(int y=0; y<66; ++y) + { + #endif + Array<ModelContainer*> mc; + std::string dirname; + char buffer[100]; + if(iCoordModelMapping->isWorldAreaMap(mapId) && x<65 && y<65) { - for(int x=0; x<66 && result; ++x) - { - for(int y=0; y<66 && result; ++y) - { - #endif - Array<ModelContainer*> mc; - std::string dirname; - char buffer[100]; - if(iCoordModelMapping->isWorldAreaMap(mapId) && x<65 && y<65) - { - sprintf(buffer, "%03u_%d_%d",mapId,y,x); // Let's flip x and y here - dirname = std::string(buffer); - } - else - { - sprintf(buffer, "%03u",mapId); - dirname = std::string(buffer); - } - result = fillModelContainerArray(dirname, mapId, x, y, mc); - emptyArray(mc); - } - } + sprintf(buffer, "%03u_%d_%d",mapId,y,x); // Let's flip x and y here + dirname = std::string(buffer); + printf("%s...\n",dirname.c_str()); } - } - #ifdef _ASSEMBLER_DEBUG - if(::g_df) fclose(::g_df); - #endif - - return result; - } + else + { + sprintf(buffer, "%03u",mapId); + dirname = std::string(buffer); - //================================================================= + // prevent spam for small maps + if(x==0 && y==0) + printf("%s...\n",dirname.c_str()); + } - bool TileAssembler::fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, Array<ModelContainer*>& pMC) - { - bool result = true; - ModelContainer* modelContainer; + bool result = fillModelContainerArray(dirname, mapId, x, y, mc); + emptyArray(mc); - NameCollection nameCollection = iCoordModelMapping->getFilenamesForCoordinate(pMapId, pXPos, pYPos); - if(nameCollection.size() > 0) - { - result = false; - char dirfilename[500]; - sprintf(dirfilename,"%s/%s.vmdir",iDestDir.c_str(),pDirFileName.c_str()); - FILE *dirfile = fopen(dirfilename, "ab"); - if(dirfile) - { - result = true; - char destnamebuffer[500]; - char fullnamedestnamebuffer[500]; - if(nameCollection.iMainFiles.size() >0) - { - sprintf(destnamebuffer,"%03u_%i_%i.vmap",pMapId, pYPos, pXPos); // flip it here too - std::string checkDoubleStr = std::string(dirfilename); - checkDoubleStr.append("##"); - checkDoubleStr.append(std::string(destnamebuffer)); - // Check, if same file already is in the same dir file - if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr)) - { - iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr); - fprintf(dirfile, "%s\n",destnamebuffer); - sprintf(fullnamedestnamebuffer,"%s/%s",iDestDir.c_str(),destnamebuffer); - modelContainer = processNames(nameCollection.iMainFiles, fullnamedestnamebuffer); - if(modelContainer) - { - pMC.append(modelContainer); - } - else - { - result = false; - } - } - } - // process the large singe files - int pos = 0; - while(result && (pos < nameCollection.iSingeFiles.size())) - { - std::string destFileName = iDestDir; - destFileName.append("/"); - std::string dirEntryName = getDirEntryNameFromModName(pMapId,nameCollection.iSingeFiles[pos]); - std::string checkDoubleStr = std::string(dirfilename); - checkDoubleStr.append("##"); - checkDoubleStr.append(nameCollection.iSingeFiles[pos]); - // Check, if same file already is in the same dir file - if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr)) - { - iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr); - fprintf(dirfile, "%s\n",dirEntryName.c_str()); - destFileName.append(dirEntryName); - - Array<std::string> positionarray; - positionarray.append(nameCollection.iSingeFiles[pos]); - - if(!iCoordModelMapping->isAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos])) - { - modelContainer = processNames(positionarray, destFileName.c_str()); - iCoordModelMapping->addAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]); - if(modelContainer) - { - pMC.append(modelContainer); - } - else - { - result = false; - } - } - } - ++pos; - } - fclose(dirfile); - } + if(!result) + return false; } - return(result); } + } + } + #ifdef _ASSEMBLER_DEBUG + if(::g_df) fclose(::g_df); + #endif + + return true; + } + + //================================================================= + + bool TileAssembler::fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, Array<ModelContainer*>& pMC) + { + ModelContainer* modelContainer; + + NameCollection nameCollection = iCoordModelMapping->getFilenamesForCoordinate(pMapId, pXPos, pYPos); + if(nameCollection.size() == 0) + return true; // no data... + + char dirfilename[500]; + sprintf(dirfilename,"%s/%s.vmdir",iDestDir.c_str(),pDirFileName.c_str()); + FILE *dirfile = fopen(dirfilename, "ab"); + if(!dirfile) + { + printf("ERROR: Can't create file %s",dirfilename); + return false; + } + + char destnamebuffer[500]; + char fullnamedestnamebuffer[500]; + + if(nameCollection.iMainFiles.size() >0) + { + sprintf(destnamebuffer,"%03u_%i_%i.vmap",pMapId, pYPos, pXPos); // flip it here too + std::string checkDoubleStr = std::string(dirfilename); + checkDoubleStr.append("##"); + checkDoubleStr.append(std::string(destnamebuffer)); + // Check, if same file already is in the same dir file + if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr)) + { + iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr); + fprintf(dirfile, "%s\n",destnamebuffer); + sprintf(fullnamedestnamebuffer,"%s/%s",iDestDir.c_str(),destnamebuffer); + modelContainer = processNames(nameCollection.iMainFiles, fullnamedestnamebuffer); + if(modelContainer) + pMC.append(modelContainer); + else + printf("warning: (if) problems in processing data for %s\n",destnamebuffer); + } + } + // process the large singe files + int pos = 0; + while(pos < nameCollection.iSingeFiles.size()) + { + std::string destFileName = iDestDir; + destFileName.append("/"); + std::string dirEntryName = getDirEntryNameFromModName(pMapId,nameCollection.iSingeFiles[pos]); + std::string checkDoubleStr = std::string(dirfilename); + checkDoubleStr.append("##"); + checkDoubleStr.append(nameCollection.iSingeFiles[pos]); + // Check, if same file already is in the same dir file + if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr)) + { + iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr); + fprintf(dirfile, "%s\n",dirEntryName.c_str()); + destFileName.append(dirEntryName); - //================================================================= + Array<std::string> positionarray; + positionarray.append(nameCollection.iSingeFiles[pos]); - void removeEntriesFromTree(AABSPTree<SubModel *>* pTree) + if(!iCoordModelMapping->isAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos])) { - Array<SubModel *> submodelArray; - pTree->getMembers(submodelArray); - int no = submodelArray.size(); - while(no > 0) - { - --no; - delete submodelArray[no]; - } + modelContainer = processNames(positionarray, destFileName.c_str()); + iCoordModelMapping->addAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]); + if(modelContainer) + pMC.append(modelContainer); + else + printf("warning: (while) problems in processing data for %s\n",destFileName.c_str()); } + } + ++pos; + } - //================================================================= + fclose(dirfile); + return true; + } - ModelContainer* TileAssembler::processNames(const Array<std::string>& pPositions, const char* pDestFileName) - { - ModelContainer *modelContainer = 0; + //================================================================= - Vector3 basepos = Vector3(0,0,0); - AABSPTree<SubModel *>* mainTree = new AABSPTree<SubModel *>(); + void removeEntriesFromTree(AABSPTree<SubModel *>* pTree) + { + Array<SubModel *> submodelArray; + pTree->getMembers(submodelArray); + int no = submodelArray.size(); + while(no > 0) + { + --no; + delete submodelArray[no]; + } + } - int pos = 0; + //================================================================= - bool result = true; - while(result && (pos < pPositions.size())) - { - std::string modelPosString = pPositions[pos]; - std::string modelFileName = getModNameFromModPosName(modelPosString); + ModelContainer* TileAssembler::processNames(const Array<std::string>& pPositions, const char* pDestFileName) + { + ModelContainer *modelContainer = 0; - if(!fillModelIntoTree(mainTree, basepos, modelPosString, modelFileName)) - { - result = false; - break; - } - ++pos; - } - if(result && mainTree->size() > 0) - { - mainTree->balance(); - modelContainer = new ModelContainer(mainTree); - modelContainer->writeFile(pDestFileName); - } - removeEntriesFromTree(mainTree); + Vector3 basepos = Vector3(0,0,0); + AABSPTree<SubModel *>* mainTree = new AABSPTree<SubModel *>(); - delete mainTree; + int pos = 0; - return(modelContainer); - } + bool result = true; + while(result && (pos < pPositions.size())) + { + std::string modelPosString = pPositions[pos]; + std::string modelFileName = getModNameFromModPosName(modelPosString); - //================================================================= - bool TileAssembler::readRawFile(std::string& pModelFilename, ModelPosition& pModelPosition, AABSPTree<SubModel *> *pMainTree) - { - bool result = false; - - std::string filename = iSrcDir; - if(filename.length() >0) - filename.append("/"); - filename.append(pModelFilename); - FILE *rf = fopen(filename.c_str(), "rb"); - if(!rf) - { - // depending on the extractor version, the data could be located in the root dir - std::string baseModelFilename = pModelFilename.substr((pModelFilename.find_first_of("/")+1),pModelFilename.length()); - filename = iSrcDir; - if(filename.length() >0) - filename.append("/"); - filename.append(baseModelFilename); - rf = fopen(filename.c_str(), "rb"); - } - char ident[8]; - - int trianglecount =0; - - #ifdef _ASSEMBLER_DEBUG - int startgroup = 0; //2; - int endgroup = INT_MAX; //2; - fprintf(::g_df,"-------------------------------------------------\n"); - fprintf(::g_df,"%s\n", pModelFilename.c_str()); - fprintf(::g_df,"-------------------------------------------------\n"); - #else - int startgroup = 0; - int endgroup = INT_MAX; - #endif - - // temporary use defines to simplify read/check code (close file and return at fail) - #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { fclose(rf); return(false); } - #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { fclose(rf); return(false); } - - if(rf) - { - READ_OR_RETURN(&ident, 8); - if(strcmp(ident, "VMAP001") == 0) - { - // OK, do nothing - } - else if(strcmp(ident, "VMAP002") == 0) - { - // we have to read one int. This is needed during the export and we have to skip it here - int tempNVectors; - READ_OR_RETURN(&tempNVectors, sizeof(int)); + if(!fillModelIntoTree(mainTree, basepos, modelPosString, modelFileName)) + { + result = false; + break; + } + ++pos; + } + if(result && mainTree->size() > 0) + { + mainTree->balance(); + modelContainer = new ModelContainer(mainTree); + modelContainer->writeFile(pDestFileName); + } + removeEntriesFromTree(mainTree); - } - else - { - // wrong version - fclose(rf); - return(false); - } - G3D::uint32 groups; - char blockId[5]; - blockId[4] = 0; - int blocksize; + delete mainTree; - READ_OR_RETURN(&groups, sizeof(G3D::uint32)); + return(modelContainer); + } - for(int g=0;g<(int)groups;g++) - { - // group MUST NOT have more then 65536 indexes !! Array will have a problem with that !! (strange ...) - Array<int> tempIndexArray; - Array<Vector3> tempVertexArray; - - AABSPTree<Triangle> *gtree = new AABSPTree<Triangle>(); - - // add free gtree at fail - #undef READ_OR_RETURN - #undef CMP_OR_RETURN - #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { fclose(rf); delete gtree; return(false); } - #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { fclose(rf); delete gtree; return(false); } - - G3D::uint32 flags; - READ_OR_RETURN(&flags, sizeof(G3D::uint32)); - - G3D::uint32 branches; - READ_OR_RETURN(&blockId, 4); - CMP_OR_RETURN(blockId, "GRP "); - READ_OR_RETURN(&blocksize, sizeof(int)); - READ_OR_RETURN(&branches, sizeof(G3D::uint32)); - for(int b=0;b<(int)branches; b++) - { - G3D::uint32 indexes; - // indexes for each branch (not used jet) - READ_OR_RETURN(&indexes, sizeof(G3D::uint32)); - } - - // ---- indexes - READ_OR_RETURN(&blockId, 4); - CMP_OR_RETURN(blockId, "INDX"); - READ_OR_RETURN(&blocksize, sizeof(int)); - unsigned int nindexes; - READ_OR_RETURN(&nindexes, sizeof(G3D::uint32)); - if(nindexes >0) - { - unsigned short *indexarray = new unsigned short[nindexes*sizeof(unsigned short)]; - READ_OR_RETURN(indexarray, sizeof(unsigned short)); - for(int i=0;i<(int)nindexes; i++) - { - unsigned short val = indexarray[i]; - tempIndexArray.append(val); - } - delete[] indexarray; - } - - // ---- vectors - READ_OR_RETURN(&blockId, 4); - CMP_OR_RETURN(blockId, "VERT"); - READ_OR_RETURN(&blocksize, sizeof(int)); - unsigned int nvectors; - READ_OR_RETURN(&nvectors, sizeof(int)); - - float *vectorarray = 0; - - // add vectorarray free - #undef READ_OR_RETURN - #undef CMP_OR_RETURN - #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { fclose(rf); delete gtree; delete[] vectorarray; return(false); } - #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { fclose(rf); delete gtree; delete[] vectorarray; return(false); } - - if(nvectors >0) - { - vectorarray = new float[nvectors*sizeof(float)*3]; - READ_OR_RETURN(vectorarray, sizeof(float)*3); - } - // ----- liquit - if(flags & 1) - { - // we have liquit -> not handled yet ... skip - READ_OR_RETURN(&blockId, 4); - CMP_OR_RETURN(blockId, "LIQU"); - READ_OR_RETURN(&blocksize, sizeof(int)); - fseek(rf, blocksize, SEEK_CUR); - } - - - for(unsigned int i=0, indexNo=0; indexNo<nvectors; indexNo++) - { - Vector3 v = Vector3(vectorarray[i+2], vectorarray[i+1], vectorarray[i+0]); - i+=3; - v = pModelPosition.transform(v); - - float swapy = v.y; - v.y = v.x; - v.x = swapy; - - tempVertexArray.append(v); - } - - // ---- calculate triangles - int rest = nindexes%3; - if(rest != 0) - { - nindexes -= rest; - } - - for(unsigned int i=0;i<(nindexes);) - { - Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] ); - i+=3; - ++trianglecount; - if(g>= startgroup && g <= endgroup) - { - gtree->insert(t); - } - } - - // drop of temporary use defines - #undef READ_OR_RETURN - #undef CMP_OR_RETURN - - if(vectorarray != 0) - { - delete vectorarray; - } - - if(gtree->size() >0) - { - gtree->balance(); - SubModel *sm = new SubModel(gtree); - #ifdef _ASSEMBLER_DEBUG - if(::g_df) fprintf(::g_df,"group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size()); - if(sm->getNTriangles() != gtree->memberTable.size()) - { - if(::g_df) fprintf(::g_df,"ERROR !!!! group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size()); - } - #endif - sm->setBasePosition(pModelPosition.iPos); - pMainTree->insert(sm); - } - delete gtree; - } - fclose(rf); - result = true; - } - return(result); - } + //================================================================= + bool TileAssembler::readRawFile(std::string& pModelFilename, ModelPosition& pModelPosition, AABSPTree<SubModel *> *pMainTree) + { + std::string filename = iSrcDir; + if(filename.length() >0) + filename.append("/"); + filename.append(pModelFilename); + FILE *rf = fopen(filename.c_str(), "rb"); + if(!rf) + { + // depending on the extractor version, the data could be located in the root dir + std::string baseModelFilename = pModelFilename.substr((pModelFilename.find_first_of("/")+1),pModelFilename.length()); + filename = iSrcDir; + if(filename.length() >0) + filename.append("/"); + filename.append(baseModelFilename); + rf = fopen(filename.c_str(), "rb"); + } + + if(!rf) + { + printf("ERROR: Can't open model file in form: %s",pModelFilename.c_str()); + printf("... or form: %s",filename ); + return false; + } + + char ident[8]; + + int trianglecount =0; + + #ifdef _ASSEMBLER_DEBUG + int startgroup = 0; //2; + int endgroup = INT_MAX; //2; + fprintf(::g_df,"-------------------------------------------------\n"); + fprintf(::g_df,"%s\n", pModelFilename.c_str()); + fprintf(::g_df,"-------------------------------------------------\n"); + #else + int startgroup = 0; + int endgroup = INT_MAX; + #endif + + // temporary use defines to simplify read/check code (close file and return at fail) + #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \ + fclose(rf); return(false); } + #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \ + fclose(rf); return(false); } + + READ_OR_RETURN(&ident, 8); + if(strcmp(ident, "VMAP001") == 0) + { + // OK, do nothing + } + else if(strcmp(ident, "VMAP002") == 0) + { + // we have to read one int. This is needed during the export and we have to skip it here + int tempNVectors; + READ_OR_RETURN(&tempNVectors, sizeof(int)); + + } + else + { + // wrong version + fclose(rf); + return(false); + } + G3D::uint32 groups; + char blockId[5]; + blockId[4] = 0; + int blocksize; - //================================================================= + READ_OR_RETURN(&groups, sizeof(G3D::uint32)); - bool TileAssembler::fillModelIntoTree(AABSPTree<SubModel *> *pMainTree, const Vector3& pBasePos, std::string& pPos, std::string& pModelFilename) + for(int g=0;g<(int)groups;g++) + { + // group MUST NOT have more then 65536 indexes !! Array will have a problem with that !! (strange ...) + Array<int> tempIndexArray; + Array<Vector3> tempVertexArray; + + AABSPTree<Triangle> *gtree = new AABSPTree<Triangle>(); + + // add free gtree at fail + #undef READ_OR_RETURN + #undef CMP_OR_RETURN + #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \ + fclose(rf); delete gtree; return(false); } + #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \ + fclose(rf); delete gtree; return(false); } + + G3D::uint32 flags; + READ_OR_RETURN(&flags, sizeof(G3D::uint32)); + + G3D::uint32 branches; + READ_OR_RETURN(&blockId, 4); + CMP_OR_RETURN(blockId, "GRP "); + READ_OR_RETURN(&blocksize, sizeof(int)); + READ_OR_RETURN(&branches, sizeof(G3D::uint32)); + for(int b=0;b<(int)branches; b++) + { + G3D::uint32 indexes; + // indexes for each branch (not used jet) + READ_OR_RETURN(&indexes, sizeof(G3D::uint32)); + } + + // ---- indexes + READ_OR_RETURN(&blockId, 4); + CMP_OR_RETURN(blockId, "INDX"); + READ_OR_RETURN(&blocksize, sizeof(int)); + unsigned int nindexes; + READ_OR_RETURN(&nindexes, sizeof(G3D::uint32)); + if(nindexes >0) + { + unsigned short *indexarray = new unsigned short[nindexes*sizeof(unsigned short)]; + READ_OR_RETURN(indexarray, nindexes*sizeof(unsigned short)); + for(int i=0;i<(int)nindexes; i++) { - bool result = false; - ModelPosition modelPosition; - getModelPosition(pPos, modelPosition); - // all should be relative to object base position - modelPosition.moveToBasePos(pBasePos); + unsigned short val = indexarray[i]; + tempIndexArray.append(val); + } + delete[] indexarray; + } + + // ---- vectors + READ_OR_RETURN(&blockId, 4); + CMP_OR_RETURN(blockId, "VERT"); + READ_OR_RETURN(&blocksize, sizeof(int)); + unsigned int nvectors; + READ_OR_RETURN(&nvectors, sizeof(int)); + + float *vectorarray = 0; + + // add vectorarray free + #undef READ_OR_RETURN + #undef CMP_OR_RETURN + #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \ + fclose(rf); delete gtree; delete[] vectorarray; return(false); } + #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \ + fclose(rf); delete gtree; delete[] vectorarray; return(false); } + + if(nvectors >0) + { + vectorarray = new float[nvectors*sizeof(float)*3]; + READ_OR_RETURN(vectorarray, nvectors*sizeof(float)*3); + } + // ----- liquit + if(flags & 1) + { + // we have liquit -> not handled yet ... skip + READ_OR_RETURN(&blockId, 4); + CMP_OR_RETURN(blockId, "LIQU"); + READ_OR_RETURN(&blocksize, sizeof(int)); + fseek(rf, blocksize, SEEK_CUR); + } - modelPosition.init(); - if(readRawFile(pModelFilename, modelPosition, pMainTree)) - { - result = true; - } + for(unsigned int i=0, indexNo=0; indexNo<nvectors; indexNo++) + { + Vector3 v = Vector3(vectorarray[i+2], vectorarray[i+1], vectorarray[i+0]); + i+=3; + v = pModelPosition.transform(v); + + float swapy = v.y; + v.y = v.x; + v.x = swapy; + + tempVertexArray.append(v); + } + + // ---- calculate triangles + int rest = nindexes%3; + if(rest != 0) + { + nindexes -= rest; + } - return result; + for(unsigned int i=0;i<(nindexes);) + { + Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] ); + i+=3; + ++trianglecount; + if(g>= startgroup && g <= endgroup) + { + gtree->insert(t); } + } + + // drop of temporary use defines + #undef READ_OR_RETURN + #undef CMP_OR_RETURN - //================================================================= - void TileAssembler::getModelPosition(std::string& pPosString, ModelPosition& pModelPosition) + if(vectorarray != 0) + { + delete vectorarray; + } + + if(gtree->size() >0) + { + gtree->balance(); + SubModel *sm = new SubModel(gtree); + #ifdef _ASSEMBLER_DEBUG + if(::g_df) fprintf(::g_df,"group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size()); + if(sm->getNTriangles() != gtree->memberTable.size()) { - float vposarray[3]; - float vdirarray[3]; - float scale; + if(::g_df) fprintf(::g_df,"ERROR !!!! group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size()); + } + #endif + sm->setBasePosition(pModelPosition.iPos); + pMainTree->insert(sm); + } + delete gtree; + } + fclose(rf); + return true; + } + + //================================================================= - size_t spos = pPosString.find_first_of('#'); - std::string stripedPosString = pPosString.substr(spos+1,pPosString.length()); + bool TileAssembler::fillModelIntoTree(AABSPTree<SubModel *> *pMainTree, const Vector3& pBasePos, std::string& pPos, std::string& pModelFilename) + { + ModelPosition modelPosition; + getModelPosition(pPos, modelPosition); + // all should be relative to object base position + modelPosition.moveToBasePos(pBasePos); - sscanf(stripedPosString.c_str(), "%f,%f,%f_%f,%f,%f_%f", - &vposarray[0],&vposarray[1],&vposarray[2], - &vdirarray[0],&vdirarray[1],&vdirarray[2], - &scale); + modelPosition.init(); - pModelPosition.iPos = Vector3(vposarray[0], vposarray[1], vposarray[2]); - pModelPosition.iDir = Vector3(vdirarray[0], vdirarray[1], vdirarray[2]); - pModelPosition.iScale = scale; + return readRawFile(pModelFilename, modelPosition, pMainTree); + } - } - //========================================== + //================================================================= + void TileAssembler::getModelPosition(std::string& pPosString, ModelPosition& pModelPosition) + { + float vposarray[3]; + float vdirarray[3]; + float scale; + + size_t spos = pPosString.find_first_of('#'); + std::string stripedPosString = pPosString.substr(spos+1,pPosString.length()); - } // VMAP + sscanf(stripedPosString.c_str(), "%f,%f,%f_%f,%f,%f_%f", + &vposarray[0],&vposarray[1],&vposarray[2], + &vdirarray[0],&vdirarray[1],&vdirarray[2], + &scale); + pModelPosition.iPos = Vector3(vposarray[0], vposarray[1], vposarray[2]); + pModelPosition.iDir = Vector3(vdirarray[0], vdirarray[1], vdirarray[2]); + pModelPosition.iScale = scale; + + } + //========================================== +} // VMAP |