diff options
406 files changed, 9420 insertions, 4366 deletions
diff --git a/dep/PackageList.txt b/dep/PackageList.txt index e5003ec744a..21d6c596b51 100644 --- a/dep/PackageList.txt +++ b/dep/PackageList.txt @@ -6,15 +6,15 @@ ACE (ADAPTIVE Communication Environment) bzip2 (a freely available, patent free, high-quality data compressor) http://www.bzip.org/ - Version: 1.0.5 + Version: 1.0.6 G3D (a commercial-grade C++ 3D engine available as Open Source (BSD License) http://g3d.sourceforge.net/ - Version: 8.0-Release + Version: 8.01-Release jemalloc (a general-purpose scalable concurrent malloc-implementation) http://www.canonware.com/jemalloc/ - Version: 2.2.5 + Version: 2.1.0 libMPQ (a library for reading MPQ files) https://libmpq.org/ @@ -30,12 +30,12 @@ SFMT (SIMD-oriented Fast Mersenne Twister) utf8-cpp (UTF-8 with C++ in a Portable Way) http://utfcpp.sourceforge.net/ - Version: 2.3 + Version: 2.3.2 zlib (A Massively Spiffy Yet Delicately Unobtrusive Compression Library) http://www.zlib.net/ - Version: 1.2.5 + Version: 1.2.7 gSOAP (a portable development toolkit for C and C++ XML Web services and XML data bindings) http://gsoap2.sourceforge.net/ - Version: 2.8.2 + Version: 2.8.10 diff --git a/dep/bzip2/LICENSE b/dep/bzip2/LICENSE new file mode 100644 index 00000000000..cc614178cf7 --- /dev/null +++ b/dep/bzip2/LICENSE @@ -0,0 +1,42 @@ + +-------------------------------------------------------------------------- + +This program, "bzip2", the associated library "libbzip2", and all +documentation, are copyright (C) 1996-2010 Julian R Seward. All +rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +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 + 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 + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Julian Seward, jseward@bzip.org +bzip2/libbzip2 version 1.0.6 of 6 September 2010 + +-------------------------------------------------------------------------- diff --git a/dep/bzip2/README b/dep/bzip2/README new file mode 100644 index 00000000000..9fb0f636013 --- /dev/null +++ b/dep/bzip2/README @@ -0,0 +1,215 @@ + +This is the README for bzip2/libzip2. +This version is fully compatible with the previous public releases. + +------------------------------------------------------------------ +This file is part of bzip2/libbzip2, a program and library for +lossless, block-sorting data compression. + +bzip2/libbzip2 version 1.0.6 of 6 September 2010 +Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> + +Please read the WARNING, DISCLAIMER and PATENTS sections in this file. + +This program is released under the terms of the license contained +in the file LICENSE. +------------------------------------------------------------------ + +Complete documentation is available in Postscript form (manual.ps), +PDF (manual.pdf) or html (manual.html). A plain-text version of the +manual page is available as bzip2.txt. + + +HOW TO BUILD -- UNIX + +Type 'make'. This builds the library libbz2.a and then the programs +bzip2 and bzip2recover. Six self-tests are run. If the self-tests +complete ok, carry on to installation: + +To install in /usr/local/bin, /usr/local/lib, /usr/local/man and +/usr/local/include, type + + make install + +To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type + + make install PREFIX=/xxx/yyy + +If you are (justifiably) paranoid and want to see what 'make install' +is going to do, you can first do + + make -n install or + make -n install PREFIX=/xxx/yyy respectively. + +The -n instructs make to show the commands it would execute, but not +actually execute them. + + +HOW TO BUILD -- UNIX, shared library libbz2.so. + +Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for +Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims +that it works for any other platform, though I suspect it probably +will work for most platforms employing both ELF and gcc. + +bzip2-shared, a client of the shared library, is also built, but not +self-tested. So I suggest you also build using the normal Makefile, +since that conducts a self-test. A second reason to prefer the +version statically linked to the library is that, on x86 platforms, +building shared objects makes a valuable register (%ebx) unavailable +to gcc, resulting in a slowdown of 10%-20%, at least for bzip2. + +Important note for people upgrading .so's from 0.9.0/0.9.5 to version +1.0.X. All the functions in the library have been renamed, from (eg) +bzCompress to BZ2_bzCompress, to avoid namespace pollution. +Unfortunately this means that the libbz2.so created by +Makefile-libbz2_so will not work with any program which used an older +version of the library. I do encourage library clients to make the +effort to upgrade to use version 1.0, since it is both faster and more +robust than previous versions. + + +HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc. + +It's difficult for me to support compilation on all these platforms. +My approach is to collect binaries for these platforms, and put them +on the master web site (http://www.bzip.org). Look there. However +(FWIW), bzip2-1.0.X is very standard ANSI C and should compile +unmodified with MS Visual C. If you have difficulties building, you +might want to read README.COMPILATION.PROBLEMS. + +At least using MS Visual C++ 6, you can build from the unmodified +sources by issuing, in a command shell: + + nmake -f makefile.msc + +(you may need to first run the MSVC-provided script VCVARS32.BAT + so as to set up paths to the MSVC tools correctly). + + +VALIDATION + +Correct operation, in the sense that a compressed file can always be +decompressed to reproduce the original, is obviously of paramount +importance. To validate bzip2, I used a modified version of Mark +Nelson's churn program. Churn is an automated test driver which +recursively traverses a directory structure, using bzip2 to compress +and then decompress each file it encounters, and checking that the +decompressed data is the same as the original. + + + +Please read and be aware of the following: + +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* + lead to disastrous loss of data. + + +DISCLAIMER: + + I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE + USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED. + + Every compression of a file implies an assumption that the + compressed file can be decompressed to reproduce the original. + Great efforts in design, coding and testing have been made to + ensure that this program works correctly. However, the complexity + of the algorithms, and, in particular, the presence 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 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. + Indeed, I very much hope the opposite is true. bzip2/libbzip2 + 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 + to carry out a patent search. Therefore I cannot give any + guarantee of the above statement. + + + +WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? + + * Approx 10% faster compression, 30% faster decompression + * -t (test mode) is a lot quicker + * Can decompress concatenated compressed files + * Programming interface, so programs can directly read/write .bz2 files + * Less restrictive (BSD-style) licensing + * Flag handling more compatible with GNU gzip + * Much more documentation, i.e., a proper user manual + * Hopefully, improved portability (at least of the library) + +WHAT'S NEW IN 0.9.5 ? + + * Compression speed is much less sensitive to the input + data than in previous versions. Specifically, the very + slow performance caused by repetitive data is fixed. + * Many small improvements in file and flag handling. + * A Y2K statement. + +WHAT'S NEW IN 1.0.0 ? + + See the CHANGES file. + +WHAT'S NEW IN 1.0.2 ? + + See the CHANGES file. + +WHAT'S NEW IN 1.0.3 ? + + See the CHANGES file. + +WHAT'S NEW IN 1.0.4 ? + + See the CHANGES file. + +WHAT'S NEW IN 1.0.5 ? + + See the CHANGES file. + +WHAT'S NEW IN 1.0.6 ? + + See the CHANGES file. + + +I hope you find bzip2 useful. Feel free to contact me at + jseward@bzip.org +if you have any suggestions or queries. Many people mailed me with +comments, suggestions and patches after the releases of bzip-0.15, +bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, +1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this +feedback. I thank you for your comments. + +bzip2's "home" is http://www.bzip.org/ + +Julian Seward +jseward@bzip.org +Cambridge, UK. + +18 July 1996 (version 0.15) +25 August 1996 (version 0.21) + 7 August 1997 (bzip2, version 0.1) +29 August 1997 (bzip2, version 0.1pl2) +23 August 1998 (bzip2, version 0.9.0) + 8 June 1999 (bzip2, version 0.9.5) + 4 Sept 1999 (bzip2, version 0.9.5d) + 5 May 2000 (bzip2, version 1.0pre8) +30 December 2001 (bzip2, version 1.0.2pre1) +15 February 2005 (bzip2, version 1.0.3) +20 December 2006 (bzip2, version 1.0.4) +10 December 2007 (bzip2, version 1.0.5) + 6 Sept 2010 (bzip2, version 1.0.6) diff --git a/dep/bzip2/blocksort.c b/dep/bzip2/blocksort.c index bd2dec157fa..d0d662cd4e9 100644 --- a/dep/bzip2/blocksort.c +++ b/dep/bzip2/blocksort.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/bzip2.c b/dep/bzip2/bzip2.c new file mode 100644 index 00000000000..6de9d1d1488 --- /dev/null +++ b/dep/bzip2/bzip2.c @@ -0,0 +1,2034 @@ + +/*-----------------------------------------------------------*/ +/*--- A block-sorting, lossless compressor bzip2.c ---*/ +/*-----------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +/* Place a 1 beside your platform, and 0 elsewhere. + Generic 32-bit Unix. + Also works on 64-bit Unix boxes. + This is the default. +*/ +#define BZ_UNIX 1 + +/*-- + Win32, as seen by Jacob Navia's excellent + port of (Chris Fraser & David Hanson)'s excellent + lcc compiler. Or with MS Visual C. + This is selected automatically if compiled by a compiler which + defines _WIN32, not including the Cygwin GCC. +--*/ +#define BZ_LCCWIN32 0 + +#if defined(_WIN32) && !defined(__CYGWIN__) +#undef BZ_LCCWIN32 +#define BZ_LCCWIN32 1 +#undef BZ_UNIX +#define BZ_UNIX 0 +#endif + + +/*---------------------------------------------*/ +/*-- + Some stuff for all platforms. +--*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <math.h> +#include <errno.h> +#include <ctype.h> +#include "bzlib.h" + +#define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); } +#define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); } +#define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); } + + +/*---------------------------------------------*/ +/*-- + Platform-specific stuff. +--*/ + +#if BZ_UNIX +# include <fcntl.h> +# include <sys/types.h> +# include <utime.h> +# include <unistd.h> +# include <sys/stat.h> +# include <sys/times.h> + +# define PATH_SEP '/' +# define MY_LSTAT lstat +# define MY_STAT stat +# define MY_S_ISREG S_ISREG +# define MY_S_ISDIR S_ISDIR + +# define APPEND_FILESPEC(root, name) \ + root=snocString((root), (name)) + +# define APPEND_FLAG(root, name) \ + root=snocString((root), (name)) + +# define SET_BINARY_MODE(fd) /**/ + +# ifdef __GNUC__ +# define NORETURN __attribute__ ((noreturn)) +# else +# define NORETURN /**/ +# endif + +# ifdef __DJGPP__ +# include <io.h> +# include <fcntl.h> +# undef MY_LSTAT +# undef MY_STAT +# define MY_LSTAT stat +# define MY_STAT stat +# undef SET_BINARY_MODE +# define SET_BINARY_MODE(fd) \ + do { \ + int retVal = setmode ( fileno ( fd ), \ + O_BINARY ); \ + ERROR_IF_MINUS_ONE ( retVal ); \ + } while ( 0 ) +# endif + +# ifdef __CYGWIN__ +# include <io.h> +# include <fcntl.h> +# undef SET_BINARY_MODE +# define SET_BINARY_MODE(fd) \ + do { \ + int retVal = setmode ( fileno ( fd ), \ + O_BINARY ); \ + ERROR_IF_MINUS_ONE ( retVal ); \ + } while ( 0 ) +# endif +#endif /* BZ_UNIX */ + + + +#if BZ_LCCWIN32 +# include <io.h> +# include <fcntl.h> +# include <sys\stat.h> + +# define NORETURN /**/ +# define PATH_SEP '\\' +# define MY_LSTAT _stat +# define MY_STAT _stat +# define MY_S_ISREG(x) ((x) & _S_IFREG) +# define MY_S_ISDIR(x) ((x) & _S_IFDIR) + +# define APPEND_FLAG(root, name) \ + root=snocString((root), (name)) + +# define APPEND_FILESPEC(root, name) \ + root = snocString ((root), (name)) + +# define SET_BINARY_MODE(fd) \ + do { \ + int retVal = setmode ( fileno ( fd ), \ + O_BINARY ); \ + ERROR_IF_MINUS_ONE ( retVal ); \ + } while ( 0 ) + +#endif /* BZ_LCCWIN32 */ + + +/*---------------------------------------------*/ +/*-- + Some more stuff for all platforms :-) +--*/ + +typedef char Char; +typedef unsigned char Bool; +typedef unsigned char UChar; +typedef int Int32; +typedef unsigned int UInt32; +typedef short Int16; +typedef unsigned short UInt16; + +#define True ((Bool)1) +#define False ((Bool)0) + +/*-- + IntNative is your platform's `native' int size. + Only here to avoid probs with 64-bit platforms. +--*/ +typedef int IntNative; + + +/*---------------------------------------------------*/ +/*--- Misc (file handling) data decls ---*/ +/*---------------------------------------------------*/ + +Int32 verbosity; +Bool keepInputFiles, smallMode, deleteOutputOnInterrupt; +Bool forceOverwrite, testFailsExist, unzFailsExist, noisy; +Int32 numFileNames, numFilesProcessed, blockSize100k; +Int32 exitValue; + +/*-- source modes; F==file, I==stdin, O==stdout --*/ +#define SM_I2O 1 +#define SM_F2O 2 +#define SM_F2F 3 + +/*-- operation modes --*/ +#define OM_Z 1 +#define OM_UNZ 2 +#define OM_TEST 3 + +Int32 opMode; +Int32 srcMode; + +#define FILE_NAME_LEN 1034 + +Int32 longestFileName; +Char inName [FILE_NAME_LEN]; +Char outName[FILE_NAME_LEN]; +Char tmpName[FILE_NAME_LEN]; +Char *progName; +Char progNameReally[FILE_NAME_LEN]; +FILE *outputHandleJustInCase; +Int32 workFactor; + +static void panic ( const Char* ) NORETURN; +static void ioError ( void ) NORETURN; +static void outOfMemory ( void ) NORETURN; +static void configError ( void ) NORETURN; +static void crcError ( void ) NORETURN; +static void cleanUpAndFail ( Int32 ) NORETURN; +static void compressedStreamEOF ( void ) NORETURN; + +static void copyFileName ( Char*, Char* ); +static void* myMalloc ( Int32 ); +static void applySavedFileAttrToOutputFile ( IntNative fd ); + + + +/*---------------------------------------------------*/ +/*--- An implementation of 64-bit ints. Sigh. ---*/ +/*--- Roll on widespread deployment of ANSI C9X ! ---*/ +/*---------------------------------------------------*/ + +typedef + struct { UChar b[8]; } + UInt64; + + +static +void uInt64_from_UInt32s ( UInt64* n, UInt32 lo32, UInt32 hi32 ) +{ + n->b[7] = (UChar)((hi32 >> 24) & 0xFF); + n->b[6] = (UChar)((hi32 >> 16) & 0xFF); + n->b[5] = (UChar)((hi32 >> 8) & 0xFF); + n->b[4] = (UChar) (hi32 & 0xFF); + n->b[3] = (UChar)((lo32 >> 24) & 0xFF); + n->b[2] = (UChar)((lo32 >> 16) & 0xFF); + n->b[1] = (UChar)((lo32 >> 8) & 0xFF); + n->b[0] = (UChar) (lo32 & 0xFF); +} + + +static +double uInt64_to_double ( UInt64* n ) +{ + Int32 i; + double base = 1.0; + double sum = 0.0; + for (i = 0; i < 8; i++) { + sum += base * (double)(n->b[i]); + base *= 256.0; + } + return sum; +} + + +static +Bool uInt64_isZero ( UInt64* n ) +{ + Int32 i; + for (i = 0; i < 8; i++) + if (n->b[i] != 0) return 0; + return 1; +} + + +/* Divide *n by 10, and return the remainder. */ +static +Int32 uInt64_qrm10 ( UInt64* n ) +{ + UInt32 rem, tmp; + Int32 i; + rem = 0; + for (i = 7; i >= 0; i--) { + tmp = rem * 256 + n->b[i]; + n->b[i] = tmp / 10; + rem = tmp % 10; + } + return rem; +} + + +/* ... and the Whole Entire Point of all this UInt64 stuff is + so that we can supply the following function. +*/ +static +void uInt64_toAscii ( char* outbuf, UInt64* n ) +{ + Int32 i, q; + UChar buf[32]; + Int32 nBuf = 0; + UInt64 n_copy = *n; + do { + q = uInt64_qrm10 ( &n_copy ); + buf[nBuf] = q + '0'; + nBuf++; + } while (!uInt64_isZero(&n_copy)); + outbuf[nBuf] = 0; + for (i = 0; i < nBuf; i++) + outbuf[i] = buf[nBuf-i-1]; +} + + +/*---------------------------------------------------*/ +/*--- Processing of complete files and streams ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------*/ +static +Bool myfeof ( FILE* f ) +{ + Int32 c = fgetc ( f ); + if (c == EOF) return True; + ungetc ( c, f ); + return False; +} + + +/*---------------------------------------------*/ +static +void compressStream ( FILE *stream, FILE *zStream ) +{ + BZFILE* bzf = NULL; + UChar ibuf[5000]; + Int32 nIbuf; + UInt32 nbytes_in_lo32, nbytes_in_hi32; + UInt32 nbytes_out_lo32, nbytes_out_hi32; + Int32 bzerr, bzerr_dummy, ret; + + SET_BINARY_MODE(stream); + SET_BINARY_MODE(zStream); + + if (ferror(stream)) goto errhandler_io; + if (ferror(zStream)) goto errhandler_io; + + bzf = BZ2_bzWriteOpen ( &bzerr, zStream, + blockSize100k, verbosity, workFactor ); + if (bzerr != BZ_OK) goto errhandler; + + if (verbosity >= 2) fprintf ( stderr, "\n" ); + + while (True) { + + if (myfeof(stream)) break; + nIbuf = fread ( ibuf, sizeof(UChar), 5000, stream ); + if (ferror(stream)) goto errhandler_io; + if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf ); + if (bzerr != BZ_OK) goto errhandler; + + } + + BZ2_bzWriteClose64 ( &bzerr, bzf, 0, + &nbytes_in_lo32, &nbytes_in_hi32, + &nbytes_out_lo32, &nbytes_out_hi32 ); + if (bzerr != BZ_OK) goto errhandler; + + if (ferror(zStream)) goto errhandler_io; + ret = fflush ( zStream ); + if (ret == EOF) goto errhandler_io; + if (zStream != stdout) { + Int32 fd = fileno ( zStream ); + if (fd < 0) goto errhandler_io; + applySavedFileAttrToOutputFile ( fd ); + ret = fclose ( zStream ); + outputHandleJustInCase = NULL; + if (ret == EOF) goto errhandler_io; + } + outputHandleJustInCase = NULL; + if (ferror(stream)) goto errhandler_io; + ret = fclose ( stream ); + if (ret == EOF) goto errhandler_io; + + if (verbosity >= 1) { + if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) { + 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 + ); + } + } + + return; + + errhandler: + BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, + &nbytes_in_lo32, &nbytes_in_hi32, + &nbytes_out_lo32, &nbytes_out_hi32 ); + switch (bzerr) { + case BZ_CONFIG_ERROR: + configError(); break; + case BZ_MEM_ERROR: + outOfMemory (); break; + case BZ_IO_ERROR: + errhandler_io: + ioError(); break; + default: + panic ( "compress:unexpected error" ); + } + + panic ( "compress:end" ); + /*notreached*/ +} + + + +/*---------------------------------------------*/ +static +Bool uncompressStream ( FILE *zStream, FILE *stream ) +{ + BZFILE* bzf = NULL; + Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; + UChar obuf[5000]; + UChar unused[BZ_MAX_UNUSED]; + Int32 nUnused; + void* unusedTmpV; + UChar* unusedTmp; + + nUnused = 0; + streamNo = 0; + + SET_BINARY_MODE(stream); + SET_BINARY_MODE(zStream); + + if (ferror(stream)) goto errhandler_io; + if (ferror(zStream)) goto errhandler_io; + + while (True) { + + bzf = BZ2_bzReadOpen ( + &bzerr, zStream, verbosity, + (int)smallMode, unused, nUnused + ); + if (bzf == NULL || bzerr != BZ_OK) goto errhandler; + streamNo++; + + while (bzerr == BZ_OK) { + nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 ); + if (bzerr == BZ_DATA_ERROR_MAGIC) goto trycat; + if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0) + fwrite ( obuf, sizeof(UChar), nread, stream ); + if (ferror(stream)) goto errhandler_io; + } + if (bzerr != BZ_STREAM_END) goto errhandler; + + BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); + if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); + + unusedTmp = (UChar*)unusedTmpV; + for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; + + BZ2_bzReadClose ( &bzerr, bzf ); + if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); + + if (nUnused == 0 && myfeof(zStream)) break; + } + + closeok: + if (ferror(zStream)) goto errhandler_io; + if (stream != stdout) { + Int32 fd = fileno ( stream ); + if (fd < 0) goto errhandler_io; + applySavedFileAttrToOutputFile ( fd ); + } + ret = fclose ( zStream ); + if (ret == EOF) goto errhandler_io; + + if (ferror(stream)) goto errhandler_io; + ret = fflush ( stream ); + if (ret != 0) goto errhandler_io; + if (stream != stdout) { + ret = fclose ( stream ); + outputHandleJustInCase = NULL; + if (ret == EOF) goto errhandler_io; + } + outputHandleJustInCase = NULL; + if (verbosity >= 2) fprintf ( stderr, "\n " ); + return True; + + 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; + } + goto closeok; + } + + errhandler: + BZ2_bzReadClose ( &bzerr_dummy, bzf ); + switch (bzerr) { + case BZ_CONFIG_ERROR: + configError(); break; + case BZ_IO_ERROR: + errhandler_io: + ioError(); break; + case BZ_DATA_ERROR: + crcError(); + case BZ_MEM_ERROR: + outOfMemory(); + case BZ_UNEXPECTED_EOF: + compressedStreamEOF(); + case BZ_DATA_ERROR_MAGIC: + if (zStream != stdin) fclose(zStream); + if (stream != stdout) fclose(stream); + if (streamNo == 1) { + return False; + } else { + if (noisy) + fprintf ( stderr, + "\n%s: %s: trailing garbage after EOF ignored\n", + progName, inName ); + return True; + } + default: + panic ( "decompress:unexpected error" ); + } + + panic ( "decompress:end" ); + return True; /*notreached*/ +} + + +/*---------------------------------------------*/ +static +Bool testStream ( FILE *zStream ) +{ + BZFILE* bzf = NULL; + Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; + UChar obuf[5000]; + UChar unused[BZ_MAX_UNUSED]; + Int32 nUnused; + void* unusedTmpV; + UChar* unusedTmp; + + nUnused = 0; + streamNo = 0; + + SET_BINARY_MODE(zStream); + if (ferror(zStream)) goto errhandler_io; + + while (True) { + + bzf = BZ2_bzReadOpen ( + &bzerr, zStream, verbosity, + (int)smallMode, unused, nUnused + ); + if (bzf == NULL || bzerr != BZ_OK) goto errhandler; + streamNo++; + + while (bzerr == BZ_OK) { + nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 ); + if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler; + } + if (bzerr != BZ_STREAM_END) goto errhandler; + + BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); + if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); + + unusedTmp = (UChar*)unusedTmpV; + for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; + + BZ2_bzReadClose ( &bzerr, bzf ); + if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); + if (nUnused == 0 && myfeof(zStream)) break; + + } + + if (ferror(zStream)) goto errhandler_io; + ret = fclose ( zStream ); + if (ret == EOF) goto errhandler_io; + + if (verbosity >= 2) fprintf ( stderr, "\n " ); + return True; + + errhandler: + BZ2_bzReadClose ( &bzerr_dummy, bzf ); + if (verbosity == 0) + fprintf ( stderr, "%s: %s: ", progName, inName ); + switch (bzerr) { + case BZ_CONFIG_ERROR: + configError(); break; + case BZ_IO_ERROR: + errhandler_io: + ioError(); break; + case BZ_DATA_ERROR: + fprintf ( stderr, + "data integrity (CRC) error in data\n" ); + return False; + case BZ_MEM_ERROR: + outOfMemory(); + case BZ_UNEXPECTED_EOF: + fprintf ( stderr, + "file ends unexpectedly\n" ); + return False; + case BZ_DATA_ERROR_MAGIC: + if (zStream != stdin) fclose(zStream); + if (streamNo == 1) { + fprintf ( stderr, + "bad magic number (file not created by bzip2)\n" ); + return False; + } else { + if (noisy) + fprintf ( stderr, + "trailing garbage after EOF ignored\n" ); + return True; + } + default: + panic ( "test:unexpected error" ); + } + + panic ( "test:end" ); + return True; /*notreached*/ +} + + +/*---------------------------------------------------*/ +/*--- Error [non-] handling grunge ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------*/ +static +void setExit ( Int32 v ) +{ + if (v > exitValue) exitValue = v; +} + + +/*---------------------------------------------*/ +static +void cadvise ( void ) +{ + if (noisy) + fprintf ( + stderr, + "\nIt is possible that the compressed file(s) have become corrupted.\n" + "You can use the -tvv option to test integrity of such files.\n\n" + "You can use the `bzip2recover' program to attempt to recover\n" + "data from undamaged sections of corrupted files.\n\n" + ); +} + + +/*---------------------------------------------*/ +static +void showFileNames ( void ) +{ + if (noisy) + fprintf ( + stderr, + "\tInput file = %s, output file = %s\n", + inName, outName + ); +} + + +/*---------------------------------------------*/ +static +void cleanUpAndFail ( Int32 ec ) +{ + IntNative retVal; + struct MY_STAT statBuf; + + if ( srcMode == SM_F2F + && opMode != OM_TEST + && deleteOutputOnInterrupt ) { + + /* Check whether input file still exists. Delete output file + only if input exists to avoid loss of data. Joerg Prante, 5 + January 2002. (JRS 06-Jan-2002: other changes in 1.0.2 mean + this is less likely to happen. But to be ultra-paranoid, we + do the check anyway.) */ + retVal = MY_STAT ( inName, &statBuf ); + if (retVal == 0) { + if (noisy) + fprintf ( stderr, + "%s: Deleting output file %s, if it exists.\n", + progName, outName ); + if (outputHandleJustInCase != NULL) + fclose ( outputHandleJustInCase ); + retVal = remove ( outName ); + if (retVal != 0) + fprintf ( stderr, + "%s: WARNING: deletion of output file " + "(apparently) failed.\n", + progName ); + } else { + fprintf ( stderr, + "%s: WARNING: deletion of output file suppressed\n", + progName ); + fprintf ( stderr, + "%s: since input file no longer exists. Output file\n", + progName ); + fprintf ( stderr, + "%s: `%s' may be incomplete.\n", + progName, outName ); + fprintf ( stderr, + "%s: I suggest doing an integrity test (bzip2 -tv)" + " of it.\n", + progName ); + } + } + + if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) { + 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, + numFileNames, numFileNames - numFilesProcessed ); + } + setExit(ec); + exit(exitValue); +} + + +/*---------------------------------------------*/ +static +void panic ( const Char* s ) +{ + fprintf ( stderr, + "\n%s: PANIC -- internal consistency error:\n" + "\t%s\n" + "\tThis is a BUG. Please report it to me at:\n" + "\tjseward@bzip.org\n", + progName, s ); + showFileNames(); + cleanUpAndFail( 3 ); +} + + +/*---------------------------------------------*/ +static +void crcError ( void ) +{ + fprintf ( stderr, + "\n%s: Data integrity error when decompressing.\n", + progName ); + showFileNames(); + cadvise(); + cleanUpAndFail( 2 ); +} + + +/*---------------------------------------------*/ +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 ); + perror ( progName ); + showFileNames(); + cadvise(); + } + cleanUpAndFail( 2 ); +} + + +/*---------------------------------------------*/ +static +void ioError ( void ) +{ + fprintf ( stderr, + "\n%s: I/O or other error, bailing out. " + "Possible reason follows.\n", + progName ); + perror ( progName ); + showFileNames(); + cleanUpAndFail( 1 ); +} + + +/*---------------------------------------------*/ +static +void mySignalCatcher ( IntNative n ) +{ + fprintf ( stderr, + "\n%s: Control-C or similar caught, quitting.\n", + progName ); + cleanUpAndFail(1); +} + + +/*---------------------------------------------*/ +static +void mySIGSEGVorSIGBUScatcher ( IntNative n ) +{ + if (opMode == OM_Z) + fprintf ( + stderr, + "\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n" + "\n" + " Possible causes are (most likely first):\n" + " (1) This computer has unreliable memory or cache hardware\n" + " (a surprisingly common problem; try a different machine.)\n" + " (2) A bug in the compiler used to create this executable\n" + " (unlikely, if you didn't compile bzip2 yourself.)\n" + " (3) A real bug in bzip2 -- I hope this should never be the case.\n" + " The user's manual, Section 4.3, has more info on (1) and (2).\n" + " \n" + " If you suspect this is a bug in bzip2, or are unsure about (1)\n" + " or (2), feel free to report it to me at: jseward@bzip.org.\n" + " Section 4.3 of the user's manual describes the info a useful\n" + " bug report should have. If the manual is available on your\n" + " system, please try and read it before mailing me. If you don't\n" + " have the manual or can't be bothered to read it, mail me anyway.\n" + "\n", + progName ); + else + fprintf ( + stderr, + "\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n" + "\n" + " Possible causes are (most likely first):\n" + " (1) The compressed data is corrupted, and bzip2's usual checks\n" + " failed to detect this. Try bzip2 -tvv my_file.bz2.\n" + " (2) This computer has unreliable memory or cache hardware\n" + " (a surprisingly common problem; try a different machine.)\n" + " (3) A bug in the compiler used to create this executable\n" + " (unlikely, if you didn't compile bzip2 yourself.)\n" + " (4) A real bug in bzip2 -- I hope this should never be the case.\n" + " The user's manual, Section 4.3, has more info on (2) and (3).\n" + " \n" + " If you suspect this is a bug in bzip2, or are unsure about (2)\n" + " or (3), feel free to report it to me at: jseward@bzip.org.\n" + " Section 4.3 of the user's manual describes the info a useful\n" + " bug report should have. If the manual is available on your\n" + " system, please try and read it before mailing me. If you don't\n" + " have the manual or can't be bothered to read it, mail me anyway.\n" + "\n", + progName ); + + showFileNames(); + if (opMode == OM_Z) + cleanUpAndFail( 3 ); else + { cadvise(); cleanUpAndFail( 2 ); } +} + + +/*---------------------------------------------*/ +static +void outOfMemory ( void ) +{ + fprintf ( stderr, + "\n%s: couldn't allocate enough memory\n", + progName ); + showFileNames(); + cleanUpAndFail(1); +} + + +/*---------------------------------------------*/ +static +void configError ( void ) +{ + fprintf ( stderr, + "bzip2: I'm not configured correctly for this platform!\n" + "\tI require Int32, Int16 and Char to have sizes\n" + "\tof 4, 2 and 1 bytes to run properly, and they don't.\n" + "\tProbably you can fix this by defining them correctly,\n" + "\tand recompiling. Bye!\n" ); + setExit(3); + exit(exitValue); +} + + +/*---------------------------------------------------*/ +/*--- The main driver machinery ---*/ +/*---------------------------------------------------*/ + +/* All rather crufty. The main problem is that input files + are stat()d multiple times before use. This should be + cleaned up. +*/ + +/*---------------------------------------------*/ +static +void pad ( Char *s ) +{ + Int32 i; + if ( (Int32)strlen(s) >= longestFileName ) return; + for (i = 1; i <= longestFileName - (Int32)strlen(s); i++) + fprintf ( stderr, " " ); +} + + +/*---------------------------------------------*/ +static +void copyFileName ( Char* to, Char* from ) +{ + if ( strlen(from) > FILE_NAME_LEN-10 ) { + fprintf ( + stderr, + "bzip2: file name\n`%s'\n" + "is suspiciously (more than %d chars) long.\n" + "Try using a reasonable file name instead. Sorry! :-)\n", + from, FILE_NAME_LEN-10 + ); + setExit(1); + exit(exitValue); + } + + strncpy(to,from,FILE_NAME_LEN-10); + to[FILE_NAME_LEN-10]='\0'; +} + + +/*---------------------------------------------*/ +static +Bool fileExists ( Char* name ) +{ + FILE *tmp = fopen ( name, "rb" ); + Bool exists = (tmp != NULL); + if (tmp != NULL) fclose ( tmp ); + return exists; +} + + +/*---------------------------------------------*/ +/* Open an output file safely with O_EXCL and good permissions. + This avoids a race condition in versions < 1.0.2, in which + the file was first opened and then had its interim permissions + set safely. We instead use open() to create the file with + the interim permissions required. (--- --- rw-). + + For non-Unix platforms, if we are not worrying about + security issues, simple this simply behaves like fopen. +*/ +static +FILE* fopen_output_safely ( Char* name, const char* mode ) +{ +# if BZ_UNIX + FILE* fp; + IntNative fh; + fh = open(name, O_WRONLY|O_CREAT|O_EXCL, S_IWUSR|S_IRUSR); + if (fh == -1) return NULL; + fp = fdopen(fh, mode); + if (fp == NULL) close(fh); + return fp; +# else + return fopen(name, mode); +# endif +} + + +/*---------------------------------------------*/ +/*-- + if in doubt, return True +--*/ +static +Bool notAStandardFile ( Char* name ) +{ + IntNative i; + struct MY_STAT statBuf; + + i = MY_LSTAT ( name, &statBuf ); + if (i != 0) return True; + if (MY_S_ISREG(statBuf.st_mode)) return False; + return True; +} + + +/*---------------------------------------------*/ +/*-- + rac 11/21/98 see if file has hard links to it +--*/ +static +Int32 countHardLinks ( Char* name ) +{ + IntNative i; + struct MY_STAT statBuf; + + i = MY_LSTAT ( name, &statBuf ); + if (i != 0) return 0; + return (statBuf.st_nlink - 1); +} + + +/*---------------------------------------------*/ +/* Copy modification date, access date, permissions and owner from the + source to destination file. We have to copy this meta-info off + into fileMetaInfo before starting to compress / decompress it, + because doing it afterwards means we get the wrong access time. + + To complicate matters, in compress() and decompress() below, the + sequence of tests preceding the call to saveInputFileMetaInfo() + involves calling fileExists(), which in turn establishes its result + by attempting to fopen() the file, and if successful, immediately + fclose()ing it again. So we have to assume that the fopen() call + does not cause the access time field to be updated. + + Reading of the man page for stat() (man 2 stat) on RedHat 7.2 seems + to imply that merely doing open() will not affect the access time. + Therefore we merely need to hope that the C library only does + open() as a result of fopen(), and not any kind of read()-ahead + cleverness. + + 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 ... +*/ +#if BZ_UNIX +static +struct MY_STAT fileMetaInfo; +#endif + +static +void saveInputFileMetaInfo ( Char *srcName ) +{ +# if BZ_UNIX + IntNative retVal; + /* Note use of stat here, not lstat. */ + retVal = MY_STAT( srcName, &fileMetaInfo ); + ERROR_IF_NOT_ZERO ( retVal ); +# endif +} + + +static +void applySavedTimeInfoToOutputFile ( Char *dstName ) +{ +# if BZ_UNIX + IntNative retVal; + struct utimbuf uTimBuf; + + uTimBuf.actime = fileMetaInfo.st_atime; + uTimBuf.modtime = fileMetaInfo.st_mtime; + + retVal = utime ( dstName, &uTimBuf ); + ERROR_IF_NOT_ZERO ( retVal ); +# endif +} + +static +void applySavedFileAttrToOutputFile ( IntNative fd ) +{ +# if BZ_UNIX + IntNative retVal; + + retVal = fchmod ( fd, fileMetaInfo.st_mode ); + ERROR_IF_NOT_ZERO ( retVal ); + + (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid ); + /* chown() will in many cases return with EPERM, which can + be safely ignored. + */ +# endif +} + + +/*---------------------------------------------*/ +static +Bool containsDubiousChars ( Char* name ) +{ +# if BZ_UNIX + /* On unix, files can contain any characters and the file expansion + * is performed by the shell. + */ + return False; +# else /* ! BZ_UNIX */ + /* On non-unix (Win* platforms), wildcard characters are not allowed in + * filenames. + */ + for (; *name != '\0'; name++) + if (*name == '?' || *name == '*') return True; + return False; +# endif /* BZ_UNIX */ +} + + +/*---------------------------------------------*/ +#define BZ_N_SUFFIX_PAIRS 4 + +const Char* zSuffix[BZ_N_SUFFIX_PAIRS] + = { ".bz2", ".bz", ".tbz2", ".tbz" }; +const Char* unzSuffix[BZ_N_SUFFIX_PAIRS] + = { "", "", ".tar", ".tar" }; + +static +Bool hasSuffix ( Char* s, const Char* suffix ) +{ + Int32 ns = strlen(s); + Int32 nx = strlen(suffix); + if (ns < nx) return False; + if (strcmp(s + ns - nx, suffix) == 0) return True; + return False; +} + +static +Bool mapSuffix ( Char* name, + const Char* oldSuffix, + const Char* newSuffix ) +{ + if (!hasSuffix(name,oldSuffix)) return False; + name[strlen(name)-strlen(oldSuffix)] = 0; + strcat ( name, newSuffix ); + return True; +} + + +/*---------------------------------------------*/ +static +void compress ( Char *name ) +{ + FILE *inStr; + FILE *outStr; + Int32 n, i; + struct MY_STAT statBuf; + + deleteOutputOnInterrupt = False; + + if (name == NULL && srcMode != SM_I2O) + panic ( "compress: bad modes\n" ); + + switch (srcMode) { + case SM_I2O: + copyFileName ( inName, (Char*)"(stdin)" ); + copyFileName ( outName, (Char*)"(stdout)" ); + break; + case SM_F2F: + copyFileName ( inName, name ); + copyFileName ( outName, name ); + strcat ( outName, ".bz2" ); + break; + case SM_F2O: + copyFileName ( inName, name ); + copyFileName ( outName, (Char*)"(stdout)" ); + break; + } + + if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { + if (noisy) + fprintf ( stderr, "%s: There are no files matching `%s'.\n", + progName, inName ); + setExit(1); + return; + } + if ( srcMode != SM_I2O && !fileExists ( inName ) ) { + fprintf ( stderr, "%s: Can't open input file %s: %s.\n", + progName, inName, strerror(errno) ); + setExit(1); + return; + } + for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) { + if (hasSuffix(inName, zSuffix[i])) { + if (noisy) + fprintf ( stderr, + "%s: Input file %s already has %s suffix.\n", + progName, inName, zSuffix[i] ); + setExit(1); + return; + } + } + if ( srcMode == SM_F2F || srcMode == SM_F2O ) { + MY_STAT(inName, &statBuf); + if ( MY_S_ISDIR(statBuf.st_mode) ) { + fprintf( stderr, + "%s: Input file %s is a directory.\n", + progName,inName); + setExit(1); + return; + } + } + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { + if (noisy) + fprintf ( stderr, "%s: Input file %s is not a normal file.\n", + progName, inName ); + setExit(1); + return; + } + if ( srcMode == SM_F2F && fileExists ( outName ) ) { + if (forceOverwrite) { + remove(outName); + } else { + fprintf ( stderr, "%s: Output file %s already exists.\n", + progName, outName ); + setExit(1); + return; + } + } + if ( srcMode == SM_F2F && !forceOverwrite && + (n=countHardLinks ( inName )) > 0) { + fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", + progName, inName, n, n > 1 ? "s" : "" ); + setExit(1); + return; + } + + if ( srcMode == SM_F2F ) { + /* Save the file's meta-info before we open it. Doing it later + means we mess up the access times. */ + saveInputFileMetaInfo ( inName ); + } + + switch ( srcMode ) { + + case SM_I2O: + inStr = stdin; + outStr = stdout; + if ( isatty ( fileno ( stdout ) ) ) { + fprintf ( stderr, + "%s: I won't write compressed data to a terminal.\n", + progName ); + fprintf ( stderr, "%s: For help, type: `%s --help'.\n", + progName, progName ); + setExit(1); + return; + }; + break; + + case SM_F2O: + inStr = fopen ( inName, "rb" ); + outStr = stdout; + if ( isatty ( fileno ( stdout ) ) ) { + fprintf ( stderr, + "%s: I won't write compressed data to a terminal.\n", + progName ); + fprintf ( stderr, "%s: For help, type: `%s --help'.\n", + progName, progName ); + if ( inStr != NULL ) fclose ( inStr ); + setExit(1); + return; + }; + if ( inStr == NULL ) { + fprintf ( stderr, "%s: Can't open input file %s: %s.\n", + progName, inName, strerror(errno) ); + setExit(1); + return; + }; + break; + + case SM_F2F: + inStr = fopen ( inName, "rb" ); + outStr = fopen_output_safely ( outName, "wb" ); + if ( outStr == NULL) { + fprintf ( stderr, "%s: Can't create output file %s: %s.\n", + progName, outName, strerror(errno) ); + if ( inStr != NULL ) fclose ( inStr ); + setExit(1); + return; + } + if ( inStr == NULL ) { + fprintf ( stderr, "%s: Can't open input file %s: %s.\n", + progName, inName, strerror(errno) ); + if ( outStr != NULL ) fclose ( outStr ); + setExit(1); + return; + }; + break; + + default: + panic ( "compress: bad srcMode" ); + break; + } + + if (verbosity >= 1) { + fprintf ( stderr, " %s: ", inName ); + pad ( inName ); + fflush ( stderr ); + } + + /*--- Now the input and output handles are sane. Do the Biz. ---*/ + outputHandleJustInCase = outStr; + deleteOutputOnInterrupt = True; + compressStream ( inStr, outStr ); + outputHandleJustInCase = NULL; + + /*--- If there was an I/O error, we won't get here. ---*/ + if ( srcMode == SM_F2F ) { + applySavedTimeInfoToOutputFile ( outName ); + deleteOutputOnInterrupt = False; + if ( !keepInputFiles ) { + IntNative retVal = remove ( inName ); + ERROR_IF_NOT_ZERO ( retVal ); + } + } + + deleteOutputOnInterrupt = False; +} + + +/*---------------------------------------------*/ +static +void uncompress ( Char *name ) +{ + FILE *inStr; + FILE *outStr; + Int32 n, i; + Bool magicNumberOK; + Bool cantGuess; + struct MY_STAT statBuf; + + deleteOutputOnInterrupt = False; + + if (name == NULL && srcMode != SM_I2O) + panic ( "uncompress: bad modes\n" ); + + cantGuess = False; + switch (srcMode) { + case SM_I2O: + copyFileName ( inName, (Char*)"(stdin)" ); + copyFileName ( outName, (Char*)"(stdout)" ); + break; + 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; + cantGuess = True; + strcat ( outName, ".out" ); + break; + case SM_F2O: + copyFileName ( inName, name ); + copyFileName ( outName, (Char*)"(stdout)" ); + break; + } + + zzz: + if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { + if (noisy) + fprintf ( stderr, "%s: There are no files matching `%s'.\n", + progName, inName ); + setExit(1); + return; + } + if ( srcMode != SM_I2O && !fileExists ( inName ) ) { + fprintf ( stderr, "%s: Can't open input file %s: %s.\n", + progName, inName, strerror(errno) ); + setExit(1); + return; + } + if ( srcMode == SM_F2F || srcMode == SM_F2O ) { + MY_STAT(inName, &statBuf); + if ( MY_S_ISDIR(statBuf.st_mode) ) { + fprintf( stderr, + "%s: Input file %s is a directory.\n", + progName,inName); + setExit(1); + return; + } + } + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { + if (noisy) + fprintf ( stderr, "%s: Input file %s is not a normal file.\n", + progName, inName ); + setExit(1); + return; + } + if ( /* srcMode == SM_F2F implied && */ cantGuess ) { + if (noisy) + 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); + } else { + fprintf ( stderr, "%s: Output file %s already exists.\n", + progName, outName ); + setExit(1); + return; + } + } + if ( srcMode == SM_F2F && !forceOverwrite && + (n=countHardLinks ( inName ) ) > 0) { + fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", + progName, inName, n, n > 1 ? "s" : "" ); + setExit(1); + return; + } + + if ( srcMode == SM_F2F ) { + /* Save the file's meta-info before we open it. Doing it later + means we mess up the access times. */ + saveInputFileMetaInfo ( inName ); + } + + switch ( srcMode ) { + + case SM_I2O: + inStr = stdin; + outStr = stdout; + if ( isatty ( fileno ( stdin ) ) ) { + fprintf ( stderr, + "%s: I won't read compressed data from a terminal.\n", + progName ); + fprintf ( stderr, "%s: For help, type: `%s --help'.\n", + progName, progName ); + setExit(1); + return; + }; + break; + + case SM_F2O: + inStr = fopen ( inName, "rb" ); + outStr = stdout; + if ( inStr == NULL ) { + fprintf ( stderr, "%s: Can't open input file %s:%s.\n", + progName, inName, strerror(errno) ); + if ( inStr != NULL ) fclose ( inStr ); + setExit(1); + return; + }; + break; + + case SM_F2F: + inStr = fopen ( inName, "rb" ); + outStr = fopen_output_safely ( outName, "wb" ); + if ( outStr == NULL) { + fprintf ( stderr, "%s: Can't create output file %s: %s.\n", + progName, outName, strerror(errno) ); + if ( inStr != NULL ) fclose ( inStr ); + setExit(1); + return; + } + if ( inStr == NULL ) { + fprintf ( stderr, "%s: Can't open input file %s: %s.\n", + progName, inName, strerror(errno) ); + if ( outStr != NULL ) fclose ( outStr ); + setExit(1); + return; + }; + break; + + default: + panic ( "uncompress: bad srcMode" ); + break; + } + + if (verbosity >= 1) { + fprintf ( stderr, " %s: ", inName ); + pad ( inName ); + fflush ( stderr ); + } + + /*--- Now the input and output handles are sane. Do the Biz. ---*/ + outputHandleJustInCase = outStr; + deleteOutputOnInterrupt = True; + magicNumberOK = uncompressStream ( inStr, outStr ); + outputHandleJustInCase = NULL; + + /*--- If there was an I/O error, we won't get here. ---*/ + if ( magicNumberOK ) { + if ( srcMode == SM_F2F ) { + applySavedTimeInfoToOutputFile ( outName ); + deleteOutputOnInterrupt = False; + if ( !keepInputFiles ) { + IntNative retVal = remove ( inName ); + ERROR_IF_NOT_ZERO ( retVal ); + } + } + } else { + unzFailsExist = True; + deleteOutputOnInterrupt = False; + if ( srcMode == SM_F2F ) { + IntNative retVal = remove ( outName ); + ERROR_IF_NOT_ZERO ( retVal ); + } + } + deleteOutputOnInterrupt = False; + + if ( magicNumberOK ) { + if (verbosity >= 1) + fprintf ( stderr, "done\n" ); + } else { + setExit(2); + if (verbosity >= 1) + fprintf ( stderr, "not a bzip2 file.\n" ); else + fprintf ( stderr, + "%s: %s is not a bzip2 file.\n", + progName, inName ); + } + +} + + +/*---------------------------------------------*/ +static +void testf ( Char *name ) +{ + FILE *inStr; + Bool allOK; + struct MY_STAT statBuf; + + deleteOutputOnInterrupt = False; + + if (name == NULL && srcMode != SM_I2O) + panic ( "testf: bad modes\n" ); + + copyFileName ( outName, (Char*)"(none)" ); + switch (srcMode) { + case SM_I2O: copyFileName ( inName, (Char*)"(stdin)" ); break; + case SM_F2F: copyFileName ( inName, name ); break; + case SM_F2O: copyFileName ( inName, name ); break; + } + + if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { + if (noisy) + fprintf ( stderr, "%s: There are no files matching `%s'.\n", + progName, inName ); + setExit(1); + return; + } + if ( srcMode != SM_I2O && !fileExists ( inName ) ) { + fprintf ( stderr, "%s: Can't open input %s: %s.\n", + progName, inName, strerror(errno) ); + setExit(1); + return; + } + if ( srcMode != SM_I2O ) { + MY_STAT(inName, &statBuf); + if ( MY_S_ISDIR(statBuf.st_mode) ) { + fprintf( stderr, + "%s: Input file %s is a directory.\n", + progName,inName); + setExit(1); + return; + } + } + + switch ( srcMode ) { + + case SM_I2O: + if ( isatty ( fileno ( stdin ) ) ) { + fprintf ( stderr, + "%s: I won't read compressed data from a terminal.\n", + progName ); + fprintf ( stderr, "%s: For help, type: `%s --help'.\n", + progName, progName ); + setExit(1); + return; + }; + inStr = stdin; + break; + + case SM_F2O: case SM_F2F: + inStr = fopen ( inName, "rb" ); + if ( inStr == NULL ) { + fprintf ( stderr, "%s: Can't open input file %s:%s.\n", + progName, inName, strerror(errno) ); + setExit(1); + return; + }; + break; + + default: + panic ( "testf: bad srcMode" ); + break; + } + + if (verbosity >= 1) { + fprintf ( stderr, " %s: ", inName ); + pad ( inName ); + fflush ( stderr ); + } + + /*--- Now the input handle is sane. Do the Biz. ---*/ + outputHandleJustInCase = NULL; + allOK = testStream ( inStr ); + + if (allOK && verbosity >= 1) fprintf ( stderr, "ok\n" ); + if (!allOK) testFailsExist = True; +} + + +/*---------------------------------------------*/ +static +void license ( void ) +{ + fprintf ( stderr, + + "bzip2, a block-sorting file compressor. " + "Version %s.\n" + " \n" + " Copyright (C) 1996-2010 by Julian Seward.\n" + " \n" + " This program is free software; you can redistribute it and/or modify\n" + " it under the terms set out in the LICENSE file, which is included\n" + " in the bzip2-1.0.6 source distribution.\n" + " \n" + " This program is distributed in the hope that it will be useful,\n" + " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + " LICENSE file for more details.\n" + " \n", + BZ2_bzlibVersion() + ); +} + + +/*---------------------------------------------*/ +static +void usage ( Char *fullProgName ) +{ + fprintf ( + stderr, + "bzip2, a block-sorting file compressor. " + "Version %s.\n" + "\n usage: %s [flags and input files in any order]\n" + "\n" + " -h --help print this message\n" + " -d --decompress force decompression\n" + " -z --compress force compression\n" + " -k --keep keep (don't delete) input files\n" + " -f --force overwrite existing output files\n" + " -t --test test compressed file integrity\n" + " -c --stdout output to standard out\n" + " -q --quiet suppress noncritical error messages\n" + " -v --verbose be verbose (a 2nd -v gives more)\n" + " -L --license display software version & license\n" + " -V --version display software version & license\n" + " -s --small use less memory (at most 2500k)\n" + " -1 .. -9 set block size to 100k .. 900k\n" + " --fast alias for -1\n" + " --best alias for -9\n" + "\n" + " If invoked as `bzip2', default action is to compress.\n" + " as `bunzip2', default action is to decompress.\n" + " as `bzcat', default action is to decompress to stdout.\n" + "\n" + " If no file names are given, bzip2 compresses or decompresses\n" + " from standard input to standard output. You can combine\n" + " short flags, so `-v -4' means the same as -v4 or -4v, &c.\n" +# if BZ_UNIX + "\n" +# endif + , + + BZ2_bzlibVersion(), + fullProgName + ); +} + + +/*---------------------------------------------*/ +static +void redundant ( Char* flag ) +{ + fprintf ( + stderr, + "%s: %s is redundant in versions 0.9.5 and above\n", + progName, flag ); +} + + +/*---------------------------------------------*/ +/*-- + All the garbage from here to main() is purely to + 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 + filenames for OSs which don't know how to do it + themselves, like MSDOS, Windows 95 and NT. + + The actual Dirty Work is done by the platform- + specific macro APPEND_FILESPEC. +--*/ + +typedef + struct zzzz { + Char *name; + struct zzzz *link; + } + Cell; + + +/*---------------------------------------------*/ +static +void *myMalloc ( Int32 n ) +{ + void* p; + + p = malloc ( (size_t)n ); + if (p == NULL) outOfMemory (); + return p; +} + + +/*---------------------------------------------*/ +static +Cell *mkCell ( void ) +{ + Cell *c; + + c = (Cell*) myMalloc ( sizeof ( Cell ) ); + c->name = NULL; + c->link = NULL; + return c; +} + + +/*---------------------------------------------*/ +static +Cell *snocString ( Cell *root, Char *name ) +{ + if (root == NULL) { + Cell *tmp = mkCell(); + tmp->name = (Char*) myMalloc ( 5 + strlen(name) ); + strcpy ( tmp->name, name ); + return tmp; + } else { + Cell *tmp = root; + while (tmp->link != NULL) tmp = tmp->link; + tmp->link = snocString ( tmp->link, name ); + return root; + } +} + + +/*---------------------------------------------*/ +static +void addFlagsFromEnvVar ( Cell** argList, Char* varName ) +{ + Int32 i, j, k; + Char *envbase, *p; + + envbase = getenv(varName); + if (envbase != NULL) { + p = envbase; + i = 0; + while (True) { + if (p[i] == 0) break; + p += i; + i = 0; + while (isspace((Int32)(p[0]))) p++; + while (p[i] != 0 && !isspace((Int32)(p[i]))) i++; + if (i > 0) { + k = i; if (k > FILE_NAME_LEN-10) k = FILE_NAME_LEN-10; + for (j = 0; j < k; j++) tmpName[j] = p[j]; + tmpName[k] = 0; + APPEND_FLAG(*argList, tmpName); + } + } + } +} + + +/*---------------------------------------------*/ +#define ISFLAG(s) (strcmp(aa->name, (s))==0) + +IntNative main ( IntNative argc, Char *argv[] ) +{ + Int32 i, j; + Char *tmp; + Cell *argList; + Cell *aa; + Bool decode; + + /*-- Be really really really paranoid :-) --*/ + if (sizeof(Int32) != 4 || sizeof(UInt32) != 4 || + sizeof(Int16) != 2 || sizeof(UInt16) != 2 || + sizeof(Char) != 1 || sizeof(UChar) != 1) + configError(); + + /*-- Initialise --*/ + outputHandleJustInCase = NULL; + smallMode = False; + keepInputFiles = False; + forceOverwrite = False; + noisy = True; + verbosity = 0; + blockSize100k = 9; + testFailsExist = False; + unzFailsExist = False; + numFileNames = 0; + numFilesProcessed = 0; + workFactor = 30; + deleteOutputOnInterrupt = False; + exitValue = 0; + i = j = 0; /* avoid bogus warning from egcs-1.1.X */ + + /*-- Set up signal handlers for mem access errors --*/ + signal (SIGSEGV, mySIGSEGVorSIGBUScatcher); +# if BZ_UNIX +# ifndef __DJGPP__ + signal (SIGBUS, mySIGSEGVorSIGBUScatcher); +# endif +# endif + + copyFileName ( inName, (Char*)"(none)" ); + copyFileName ( outName, (Char*)"(none)" ); + + copyFileName ( progNameReally, argv[0] ); + progName = &progNameReally[0]; + for (tmp = &progNameReally[0]; *tmp != '\0'; tmp++) + if (*tmp == PATH_SEP) progName = tmp + 1; + + + /*-- Copy flags from env var BZIP2, and + expand filename wildcards in arg list. + --*/ + argList = NULL; + addFlagsFromEnvVar ( &argList, (Char*)"BZIP2" ); + addFlagsFromEnvVar ( &argList, (Char*)"BZIP" ); + for (i = 1; i <= argc-1; i++) + APPEND_FILESPEC(argList, argv[i]); + + + /*-- Find the length of the longest filename --*/ + longestFileName = 7; + numFileNames = 0; + decode = True; + for (aa = argList; aa != NULL; aa = aa->link) { + if (ISFLAG("--")) { decode = False; continue; } + if (aa->name[0] == '-' && decode) continue; + numFileNames++; + if (longestFileName < (Int32)strlen(aa->name) ) + longestFileName = (Int32)strlen(aa->name); + } + + + /*-- Determine source modes; flag handling may change this too. --*/ + if (numFileNames == 0) + srcMode = SM_I2O; else srcMode = SM_F2F; + + + /*-- Determine what to do (compress/uncompress/test/cat). --*/ + /*-- Note that subsequent flag handling may change this. --*/ + opMode = OM_Z; + + if ( (strstr ( progName, "unzip" ) != 0) || + (strstr ( progName, "UNZIP" ) != 0) ) + opMode = OM_UNZ; + + if ( (strstr ( progName, "z2cat" ) != 0) || + (strstr ( progName, "Z2CAT" ) != 0) || + (strstr ( progName, "zcat" ) != 0) || + (strstr ( progName, "ZCAT" ) != 0) ) { + opMode = OM_UNZ; + srcMode = (numFileNames == 0) ? SM_I2O : SM_F2O; + } + + + /*-- Look at the flags. --*/ + for (aa = argList; aa != NULL; aa = aa->link) { + if (ISFLAG("--")) break; + if (aa->name[0] == '-' && aa->name[1] != '-') { + for (j = 1; aa->name[j] != '\0'; j++) { + switch (aa->name[j]) { + case 'c': srcMode = SM_F2O; break; + case 'd': opMode = OM_UNZ; break; + case 'z': opMode = OM_Z; break; + case 'f': forceOverwrite = True; break; + case 't': opMode = OM_TEST; break; + case 'k': keepInputFiles = True; break; + case 's': smallMode = True; break; + case 'q': noisy = False; break; + case '1': blockSize100k = 1; break; + case '2': blockSize100k = 2; break; + case '3': blockSize100k = 3; break; + case '4': blockSize100k = 4; break; + case '5': blockSize100k = 5; break; + case '6': blockSize100k = 6; break; + case '7': blockSize100k = 7; break; + case '8': blockSize100k = 8; break; + case '9': blockSize100k = 9; break; + case 'V': + case 'L': license(); break; + case 'v': verbosity++; break; + case 'h': usage ( progName ); + exit ( 0 ); + break; + default: fprintf ( stderr, "%s: Bad flag `%s'\n", + progName, aa->name ); + usage ( progName ); + exit ( 1 ); + break; + } + } + } + } + + /*-- And again ... --*/ + for (aa = argList; aa != NULL; aa = aa->link) { + if (ISFLAG("--")) break; + if (ISFLAG("--stdout")) srcMode = SM_F2O; else + if (ISFLAG("--decompress")) opMode = OM_UNZ; else + if (ISFLAG("--compress")) opMode = OM_Z; else + if (ISFLAG("--force")) forceOverwrite = True; else + if (ISFLAG("--test")) opMode = OM_TEST; else + if (ISFLAG("--keep")) keepInputFiles = True; else + if (ISFLAG("--small")) smallMode = True; else + if (ISFLAG("--quiet")) noisy = False; else + if (ISFLAG("--version")) license(); else + if (ISFLAG("--license")) license(); 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 + if (ISFLAG("--best")) blockSize100k = 9; else + if (ISFLAG("--verbose")) verbosity++; else + if (ISFLAG("--help")) { usage ( progName ); exit ( 0 ); } + else + if (strncmp ( aa->name, "--", 2) == 0) { + fprintf ( stderr, "%s: Bad flag `%s'\n", progName, aa->name ); + usage ( progName ); + exit ( 1 ); + } + } + + if (verbosity > 4) verbosity = 4; + if (opMode == OM_Z && smallMode && blockSize100k > 2) + blockSize100k = 2; + + if (opMode == OM_TEST && srcMode == SM_F2O) { + fprintf ( stderr, "%s: -c and -t cannot be used together.\n", + progName ); + exit ( 1 ); + } + + if (srcMode == SM_F2O && numFileNames == 0) + srcMode = SM_I2O; + + if (opMode != OM_Z) blockSize100k = 0; + + if (srcMode == SM_F2F) { + signal (SIGINT, mySignalCatcher); + signal (SIGTERM, mySignalCatcher); +# if BZ_UNIX + signal (SIGHUP, mySignalCatcher); +# endif + } + + if (opMode == OM_Z) { + if (srcMode == SM_I2O) { + compress ( NULL ); + } else { + decode = True; + for (aa = argList; aa != NULL; aa = aa->link) { + if (ISFLAG("--")) { decode = False; continue; } + if (aa->name[0] == '-' && decode) continue; + numFilesProcessed++; + compress ( aa->name ); + } + } + } + else + + if (opMode == OM_UNZ) { + unzFailsExist = False; + if (srcMode == SM_I2O) { + uncompress ( NULL ); + } else { + decode = True; + for (aa = argList; aa != NULL; aa = aa->link) { + if (ISFLAG("--")) { decode = False; continue; } + if (aa->name[0] == '-' && decode) continue; + numFilesProcessed++; + uncompress ( aa->name ); + } + } + if (unzFailsExist) { + setExit(2); + exit(exitValue); + } + } + + else { + testFailsExist = False; + if (srcMode == SM_I2O) { + testf ( NULL ); + } else { + decode = True; + for (aa = argList; aa != NULL; aa = aa->link) { + if (ISFLAG("--")) { decode = False; continue; } + if (aa->name[0] == '-' && decode) continue; + numFilesProcessed++; + testf ( aa->name ); + } + } + if (testFailsExist && noisy) { + fprintf ( stderr, + "\n" + "You can use the `bzip2recover' program to attempt to recover\n" + "data from undamaged sections of corrupted files.\n\n" + ); + setExit(2); + exit(exitValue); + } + } + + /* Free the argument list memory to mollify leak detectors + (eg) Purify, Checker. Serves no other useful purpose. + */ + aa = argList; + while (aa != NULL) { + Cell* aa2 = aa->link; + if (aa->name != NULL) free(aa->name); + free(aa); + aa = aa2; + } + + return exitValue; +} + + +/*-----------------------------------------------------------*/ +/*--- end bzip2.c ---*/ +/*-----------------------------------------------------------*/ diff --git a/dep/bzip2/bzip2recover.c b/dep/bzip2/bzip2recover.c new file mode 100644 index 00000000000..f9de0496abf --- /dev/null +++ b/dep/bzip2/bzip2recover.c @@ -0,0 +1,514 @@ +/*-----------------------------------------------------------*/ +/*--- Block recoverer program for bzip2 ---*/ +/*--- bzip2recover.c ---*/ +/*-----------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + +/* This program is a complete hack and should be rewritten properly. + It isn't very complicated. */ + +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> + + +/* This program records bit locations in the file to be recovered. + That means that if 64-bit ints are not supported, we will not + be able to recover .bz2 files over 512MB (2^32 bits) long. + On GNU supported platforms, we take advantage of the 64-bit + int support to circumvent this problem. Ditto MSVC. + + This change occurred in version 1.0.2; all prior versions have + the 512MB limitation. +*/ +#ifdef __GNUC__ + typedef unsigned long long int MaybeUInt64; +# define MaybeUInt64_FMT "%Lu" +#else +#ifdef _MSC_VER + typedef unsigned __int64 MaybeUInt64; +# define MaybeUInt64_FMT "%I64u" +#else + typedef unsigned int MaybeUInt64; +# define MaybeUInt64_FMT "%u" +#endif +#endif + +typedef unsigned int UInt32; +typedef int Int32; +typedef unsigned char UChar; +typedef char Char; +typedef unsigned char Bool; +#define True ((Bool)1) +#define False ((Bool)0) + + +#define BZ_MAX_FILENAME 2000 + +Char inFileName[BZ_MAX_FILENAME]; +Char outFileName[BZ_MAX_FILENAME]; +Char progName[BZ_MAX_FILENAME]; + +MaybeUInt64 bytesOut = 0; +MaybeUInt64 bytesIn = 0; + + +/*---------------------------------------------------*/ +/*--- Header bytes ---*/ +/*---------------------------------------------------*/ + +#define BZ_HDR_B 0x42 /* 'B' */ +#define BZ_HDR_Z 0x5a /* 'Z' */ +#define BZ_HDR_h 0x68 /* 'h' */ +#define BZ_HDR_0 0x30 /* '0' */ + + +/*---------------------------------------------------*/ +/*--- I/O errors ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------*/ +static void readError ( void ) +{ + fprintf ( stderr, + "%s: I/O error reading `%s', possible reason follows.\n", + progName, inFileName ); + perror ( progName ); + fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", + progName ); + exit ( 1 ); +} + + +/*---------------------------------------------*/ +static void writeError ( void ) +{ + fprintf ( stderr, + "%s: I/O error reading `%s', possible reason follows.\n", + progName, inFileName ); + perror ( progName ); + fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", + progName ); + exit ( 1 ); +} + + +/*---------------------------------------------*/ +static void mallocFail ( Int32 n ) +{ + fprintf ( stderr, + "%s: malloc failed on request for %d bytes.\n", + progName, n ); + fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", + progName ); + exit ( 1 ); +} + + +/*---------------------------------------------*/ +static void tooManyBlocks ( Int32 max_handled_blocks ) +{ + fprintf ( stderr, + "%s: `%s' appears to contain more than %d blocks\n", + progName, inFileName, max_handled_blocks ); + fprintf ( stderr, + "%s: and cannot be handled. To fix, increase\n", + progName ); + fprintf ( stderr, + "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n", + progName ); + exit ( 1 ); +} + + + +/*---------------------------------------------------*/ +/*--- Bit stream I/O ---*/ +/*---------------------------------------------------*/ + +typedef + struct { + FILE* handle; + Int32 buffer; + Int32 buffLive; + Char mode; + } + BitStream; + + +/*---------------------------------------------*/ +static BitStream* bsOpenReadStream ( FILE* stream ) +{ + BitStream *bs = malloc ( sizeof(BitStream) ); + if (bs == NULL) mallocFail ( sizeof(BitStream) ); + bs->handle = stream; + bs->buffer = 0; + bs->buffLive = 0; + bs->mode = 'r'; + return bs; +} + + +/*---------------------------------------------*/ +static BitStream* bsOpenWriteStream ( FILE* stream ) +{ + BitStream *bs = malloc ( sizeof(BitStream) ); + if (bs == NULL) mallocFail ( sizeof(BitStream) ); + bs->handle = stream; + bs->buffer = 0; + bs->buffLive = 0; + bs->mode = 'w'; + return bs; +} + + +/*---------------------------------------------*/ +static void bsPutBit ( BitStream* bs, Int32 bit ) +{ + if (bs->buffLive == 8) { + Int32 retVal = putc ( (UChar) bs->buffer, bs->handle ); + if (retVal == EOF) writeError(); + bytesOut++; + bs->buffLive = 1; + bs->buffer = bit & 0x1; + } else { + bs->buffer = ( (bs->buffer << 1) | (bit & 0x1) ); + bs->buffLive++; + }; +} + + +/*---------------------------------------------*/ +/*-- + Returns 0 or 1, or 2 to indicate EOF. +--*/ +static Int32 bsGetBit ( BitStream* bs ) +{ + if (bs->buffLive > 0) { + bs->buffLive --; + return ( ((bs->buffer) >> (bs->buffLive)) & 0x1 ); + } else { + Int32 retVal = getc ( bs->handle ); + if ( retVal == EOF ) { + if (errno != 0) readError(); + return 2; + } + bs->buffLive = 7; + bs->buffer = retVal; + return ( ((bs->buffer) >> 7) & 0x1 ); + } +} + + +/*---------------------------------------------*/ +static void bsClose ( BitStream* bs ) +{ + Int32 retVal; + + if ( bs->mode == 'w' ) { + while ( bs->buffLive < 8 ) { + bs->buffLive++; + bs->buffer <<= 1; + }; + retVal = putc ( (UChar) (bs->buffer), bs->handle ); + if (retVal == EOF) writeError(); + bytesOut++; + retVal = fflush ( bs->handle ); + if (retVal == EOF) writeError(); + } + retVal = fclose ( bs->handle ); + if (retVal == EOF) { + if (bs->mode == 'w') writeError(); else readError(); + } + free ( bs ); +} + + +/*---------------------------------------------*/ +static void bsPutUChar ( BitStream* bs, UChar c ) +{ + Int32 i; + for (i = 7; i >= 0; i--) + bsPutBit ( bs, (((UInt32) c) >> i) & 0x1 ); +} + + +/*---------------------------------------------*/ +static void bsPutUInt32 ( BitStream* bs, UInt32 c ) +{ + Int32 i; + + for (i = 31; i >= 0; i--) + bsPutBit ( bs, (c >> i) & 0x1 ); +} + + +/*---------------------------------------------*/ +static Bool endsInBz2 ( Char* name ) +{ + Int32 n = strlen ( name ); + if (n <= 4) return False; + return + (name[n-4] == '.' && + name[n-3] == 'b' && + name[n-2] == 'z' && + name[n-1] == '2'); +} + + +/*---------------------------------------------------*/ +/*--- ---*/ +/*---------------------------------------------------*/ + +/* This logic isn't really right when it comes to Cygwin. */ +#ifdef _WIN32 +# define BZ_SPLIT_SYM '\\' /* path splitter on Windows platform */ +#else +# define BZ_SPLIT_SYM '/' /* path splitter on Unix platform */ +#endif + +#define BLOCK_HEADER_HI 0x00003141UL +#define BLOCK_HEADER_LO 0x59265359UL + +#define BLOCK_ENDMARK_HI 0x00001772UL +#define BLOCK_ENDMARK_LO 0x45385090UL + +/* Increase if necessary. However, a .bz2 file with > 50000 blocks + would have an uncompressed size of at least 40GB, so the chances + are low you'll need to up this. +*/ +#define BZ_MAX_HANDLED_BLOCKS 50000 + +MaybeUInt64 bStart [BZ_MAX_HANDLED_BLOCKS]; +MaybeUInt64 bEnd [BZ_MAX_HANDLED_BLOCKS]; +MaybeUInt64 rbStart[BZ_MAX_HANDLED_BLOCKS]; +MaybeUInt64 rbEnd [BZ_MAX_HANDLED_BLOCKS]; + +Int32 main ( Int32 argc, Char** argv ) +{ + FILE* inFile; + FILE* outFile; + BitStream* bsIn, *bsWr; + Int32 b, wrBlock, currBlock, rbCtr; + MaybeUInt64 bitsRead; + + UInt32 buffHi, buffLo, blockCRC; + Char* p; + + strcpy ( progName, argv[0] ); + inFileName[0] = outFileName[0] = 0; + + fprintf ( stderr, + "bzip2recover 1.0.6: extracts blocks from damaged .bz2 files.\n" ); + + if (argc != 2) { + fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n", + progName, progName ); + switch (sizeof(MaybeUInt64)) { + case 8: + fprintf(stderr, + "\trestrictions on size of recovered file: None\n"); + break; + case 4: + fprintf(stderr, + "\trestrictions on size of recovered file: 512 MB\n"); + fprintf(stderr, + "\tto circumvent, recompile with MaybeUInt64 as an\n" + "\tunsigned 64-bit int.\n"); + break; + default: + fprintf(stderr, + "\tsizeof(MaybeUInt64) is not 4 or 8 -- " + "configuration error.\n"); + break; + } + exit(1); + } + + if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) { + fprintf ( stderr, + "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n", + progName, (int)strlen(argv[1]) ); + exit(1); + } + + strcpy ( inFileName, argv[1] ); + + inFile = fopen ( inFileName, "rb" ); + if (inFile == NULL) { + fprintf ( stderr, "%s: can't read `%s'\n", progName, inFileName ); + exit(1); + } + + bsIn = bsOpenReadStream ( inFile ); + fprintf ( stderr, "%s: searching for block boundaries ...\n", progName ); + + bitsRead = 0; + buffHi = buffLo = 0; + currBlock = 0; + bStart[currBlock] = 0; + + rbCtr = 0; + + while (True) { + b = bsGetBit ( bsIn ); + bitsRead++; + if (b == 2) { + if (bitsRead >= bStart[currBlock] && + (bitsRead - bStart[currBlock]) >= 40) { + bEnd[currBlock] = bitsRead-1; + if (currBlock > 0) + fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT + " to " MaybeUInt64_FMT " (incomplete)\n", + currBlock, bStart[currBlock], bEnd[currBlock] ); + } else + currBlock--; + break; + } + buffHi = (buffHi << 1) | (buffLo >> 31); + buffLo = (buffLo << 1) | (b & 1); + if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI + && buffLo == BLOCK_HEADER_LO) + || + ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI + && buffLo == BLOCK_ENDMARK_LO) + ) { + if (bitsRead > 49) { + bEnd[currBlock] = bitsRead-49; + } else { + bEnd[currBlock] = 0; + } + if (currBlock > 0 && + (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]; + rbEnd[rbCtr] = bEnd[currBlock]; + rbCtr++; + } + if (currBlock >= BZ_MAX_HANDLED_BLOCKS) + tooManyBlocks(BZ_MAX_HANDLED_BLOCKS); + currBlock++; + + bStart[currBlock] = bitsRead; + } + } + + bsClose ( bsIn ); + + /*-- identified blocks run from 1 to rbCtr inclusive. --*/ + + if (rbCtr < 1) { + fprintf ( stderr, + "%s: sorry, I couldn't find any block boundaries.\n", + progName ); + exit(1); + }; + + fprintf ( stderr, "%s: splitting into blocks\n", progName ); + + inFile = fopen ( inFileName, "rb" ); + if (inFile == NULL) { + fprintf ( stderr, "%s: can't open `%s'\n", progName, inFileName ); + exit(1); + } + bsIn = bsOpenReadStream ( inFile ); + + /*-- placate gcc's dataflow analyser --*/ + blockCRC = 0; bsWr = 0; + + bitsRead = 0; + outFile = NULL; + wrBlock = 0; + while (True) { + b = bsGetBit(bsIn); + if (b == 2) break; + buffHi = (buffHi << 1) | (buffLo >> 31); + buffLo = (buffLo << 1) | (b & 1); + if (bitsRead == 47+rbStart[wrBlock]) + blockCRC = (buffHi << 16) | (buffLo >> 16); + + if (outFile != NULL && bitsRead >= rbStart[wrBlock] + && bitsRead <= rbEnd[wrBlock]) { + bsPutBit ( bsWr, b ); + } + + bitsRead++; + + if (bitsRead == rbEnd[wrBlock]+1) { + if (outFile != NULL) { + bsPutUChar ( bsWr, 0x17 ); bsPutUChar ( bsWr, 0x72 ); + bsPutUChar ( bsWr, 0x45 ); bsPutUChar ( bsWr, 0x38 ); + bsPutUChar ( bsWr, 0x50 ); bsPutUChar ( bsWr, 0x90 ); + bsPutUInt32 ( bsWr, blockCRC ); + bsClose ( bsWr ); + } + if (wrBlock >= rbCtr) break; + wrBlock++; + } else + if (bitsRead == rbStart[wrBlock]) { + /* 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++) + outFileName[k] = 0; + strcpy (outFileName, inFileName); + split = strrchr (outFileName, BZ_SPLIT_SYM); + if (split == NULL) { + split = outFileName; + } else { + ++split; + } + /* 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'; + strcat (outFileName, inFileName + ofs); + + if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" ); + + fprintf ( stderr, " writing block %d to `%s' ...\n", + wrBlock+1, outFileName ); + + outFile = fopen ( outFileName, "wb" ); + if (outFile == NULL) { + fprintf ( stderr, "%s: can't write `%s'\n", + progName, outFileName ); + exit(1); + } + bsWr = bsOpenWriteStream ( outFile ); + 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 ); + bsPutUChar ( bsWr, 0x53 ); bsPutUChar ( bsWr, 0x59 ); + } + } + + fprintf ( stderr, "%s: finished\n", progName ); + return 0; +} + + + +/*-----------------------------------------------------------*/ +/*--- end bzip2recover.c ---*/ +/*-----------------------------------------------------------*/ diff --git a/dep/bzip2/bzlib.c b/dep/bzip2/bzlib.c index ef86c91e695..bd358a793b8 100644 --- a/dep/bzip2/bzlib.c +++ b/dep/bzip2/bzlib.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/bzlib.h b/dep/bzip2/bzlib.h index c5b75d6d8ff..8277123da8c 100644 --- a/dep/bzip2/bzlib.h +++ b/dep/bzip2/bzlib.h @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/bzlib_private.h b/dep/bzip2/bzlib_private.h index 23427879b18..5d0217f4635 100644 --- a/dep/bzip2/bzlib_private.h +++ b/dep/bzip2/bzlib_private.h @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -36,7 +36,7 @@ /*-- General stuff. --*/ -#define BZ_VERSION "1.0.5, 10-Dec-2007" +#define BZ_VERSION "1.0.6, 6-Sept-2010" typedef char Char; typedef unsigned char Bool; diff --git a/dep/bzip2/compress.c b/dep/bzip2/compress.c index 8c80a079700..caf7696011b 100644 --- a/dep/bzip2/compress.c +++ b/dep/bzip2/compress.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/crctable.c b/dep/bzip2/crctable.c index 215687b2c05..1fea7e946c5 100644 --- a/dep/bzip2/crctable.c +++ b/dep/bzip2/crctable.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/decompress.c b/dep/bzip2/decompress.c index bba5e0fa36d..311f5668f9a 100644 --- a/dep/bzip2/decompress.c +++ b/dep/bzip2/decompress.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -381,6 +381,13 @@ Int32 BZ2_decompress ( DState* s ) es = -1; N = 1; do { + /* Check that N doesn't get too big, so that es doesn't + go negative. The maximum value that can be + RUNA/RUNB encoded is equal to the block size (post + the initial RLE), viz, 900k, so bounding N at 2 + million should guard against overflow without + rejecting any legitimate inputs. */ + if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR); if (nextSym == BZ_RUNA) es = es + (0+1) * N; else if (nextSym == BZ_RUNB) es = es + (1+1) * N; N = N * 2; @@ -485,15 +492,28 @@ Int32 BZ2_decompress ( DState* s ) RETURN(BZ_DATA_ERROR); /*-- Set up cftab to facilitate generation of T^(-1) --*/ + /* Check: unzftab entries in range. */ + for (i = 0; i <= 255; i++) { + if (s->unzftab[i] < 0 || s->unzftab[i] > nblock) + RETURN(BZ_DATA_ERROR); + } + /* Actually generate cftab. */ s->cftab[0] = 0; for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; + /* Check: cftab entries in range. */ for (i = 0; i <= 256; i++) { if (s->cftab[i] < 0 || s->cftab[i] > nblock) { /* s->cftab[i] can legitimately be == nblock */ RETURN(BZ_DATA_ERROR); } } + /* Check: cftab entries non-descending. */ + for (i = 1; i <= 256; i++) { + if (s->cftab[i-1] > s->cftab[i]) { + RETURN(BZ_DATA_ERROR); + } + } s->state_out_len = 0; s->state_out_ch = 0; diff --git a/dep/bzip2/huffman.c b/dep/bzip2/huffman.c index 87e79e38af0..2283fdbc5a1 100644 --- a/dep/bzip2/huffman.c +++ b/dep/bzip2/huffman.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/randtable.c b/dep/bzip2/randtable.c index 068b76367bc..6d624599061 100644 --- a/dep/bzip2/randtable.c +++ b/dep/bzip2/randtable.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/g3dlite/include/G3D/AABox.h b/dep/g3dlite/include/G3D/AABox.h index 2e8da1f6098..d57320d73eb 100644 --- a/dep/g3dlite/include/G3D/AABox.h +++ b/dep/g3dlite/include/G3D/AABox.h @@ -20,6 +20,7 @@ #include "G3D/debug.h" #include "G3D/Array.h" #include "G3D/Plane.h" +#include "G3D/Sphere.h" namespace G3D { @@ -259,6 +260,8 @@ public: void getBounds(AABox& out) const { out = *this; } + + void getBounds(Sphere& out) const; }; } diff --git a/dep/g3dlite/include/G3D/Any.h b/dep/g3dlite/include/G3D/Any.h index c267eedd22f..e2d0fbe7e62 100644 --- a/dep/g3dlite/include/G3D/Any.h +++ b/dep/g3dlite/include/G3D/Any.h @@ -17,7 +17,9 @@ #include "G3D/platform.h" #include "G3D/Table.h" #include "G3D/Array.h" +#include "G3D/Set.h" #include "G3D/AtomicInt32.h" +#include "G3D/stringutils.h" #include <string> // needed for Token @@ -448,7 +450,6 @@ public: */ std::string resolveStringAsFilename() const; - /** If this is named ARRAY or TABLE, returns the name. */ const std::string& name() const; @@ -518,7 +519,7 @@ public: // Needed to prevent the operator[](int) overload from catching // string literals - inline const Any& operator[](const char* key) const { + const Any& operator[](const char* key) const { return operator[](std::string(key)); } @@ -548,7 +549,7 @@ public: Any& operator[](const std::string& key); /** \copydoc Any::operator[](const std::string&) */ - inline Any& operator[](const char* key) { + Any& operator[](const char* key) { return operator[](std::string(key)); } @@ -636,6 +637,124 @@ private: }; // class Any + +/** + Convenient iteration over the keys of a Any::TABLE, usually + for implementing construction of an object from an Any. + + Getting an element using either iteration or explicit requests + consumes that element from the iterator (but not from the Any!) + It is an error to consume the same element more than once from + the same iterator. + + <pre> + AnyKeyIterator r(a); + r.getIfPresent("enabled", enabled); + r.getIfPresent("showSamples", showSamples); + r.getIfPresent("showTiles", showTiles); + + r.verifyDone(); + </pre> + + \beta +*/ +class AnyTableReader { +private: + Any m_any; + Set<std::string> m_alreadyRead; +public: + + /** Verifies that \a is a TABLE with the given \a name. */ + AnyTableReader(const std::string& name, const Any& a) : m_any(a) { + try { + m_any.verifyType(Any::TABLE); + m_any.verifyName(name); + } catch (const ParseError& e) { + // If an exception is thrown, the destructors will not be + // invoked automatically. + m_any.~Any(); + m_alreadyRead.~Set(); + throw e; + } + } + + /** Verifies that \a is a TABLE. */ + AnyTableReader(const Any& a) : m_any(a) { + try { + m_any.verifyType(Any::TABLE); + } catch (const ParseError& e) { + // If an exception is thrown, the destructors will not be + // invoked automatically. + m_any.~Any(); + m_alreadyRead.~Set(); + throw e; + } + } + + bool hasMore() const { + return m_any.size() > m_alreadyRead.size(); + } + + /** Verifies that all keys have been read. */ + void verifyDone() const { + if (hasMore()) { + // Generate all keys + // Remove the ones we've read + // Assert the rest + // any.verify(""); + } + } + +#if 0 + /** Returns the current key */ + const std::string& key() const; + + /** Returns the current value */ + const Any& value() const; + + AnyKeyIterator& operator++(); +#endif + + /** If key \s appears in the any, reads its value into \a v and + removes that key from the ones available to iterate over. + + If key \s does not appear in the any, throws a G3D::ParseError. + + Assumes that if key \s appears in the any it has not already been extracted + by this iterator. If it has been read before, an assertion will fail in debug mode. + + */ + template<class ValueType> + void get(const std::string& s, ValueType& v) { + v = m_any[s]; + m_alreadyRead.insert(toLower(s)); + } + + /** Get the value associated with a key only if the key is actually present. + + If key \s appears in the any, reads its value into \a v and + removes that key from the ones available to iterate over. + + If key \s does not appear in the any, does nothing. + + Assumes that if key \s appears in the any it has not already been extracted + by this iterator. If it has been read before, an assertion will fail in debug mode. + + \return True if the value was read. + */ + template<class ValueType> + bool getIfPresent(const std::string& s, ValueType& v) { + if (m_any.containsKey(s)) { + debugAssertM(! m_alreadyRead.contains(toLower(s)), "read twice"); + + get(s, v); + return true; + } else { + return false; + } + } +}; + } // namespace G3D #endif diff --git a/dep/g3dlite/include/G3D/PointHashGrid.h b/dep/g3dlite/include/G3D/PointHashGrid.h index 5b128d1b5d9..d0b60a88ae5 100644 --- a/dep/g3dlite/include/G3D/PointHashGrid.h +++ b/dep/g3dlite/include/G3D/PointHashGrid.h @@ -360,7 +360,7 @@ public: m_arrayIndex(0), m_epoch(0) {} Iterator(const ThisType* grid) : - m_isEnd(false), + m_isEnd(grid->size() == 0), m_grid(grid), m_tableIterator( grid->m_data.begin() ), m_arrayIndex(0), @@ -387,6 +387,10 @@ public: } } + bool hasMore() const { + return ! m_isEnd; + } + bool operator==(const Iterator& other) const { return !(*this != other); } diff --git a/dep/g3dlite/include/G3D/Quat.inl b/dep/g3dlite/include/G3D/Quat.inl deleted file mode 100644 index 9e4c861d93b..00000000000 --- a/dep/g3dlite/include/G3D/Quat.inl +++ /dev/null @@ -1,36 +0,0 @@ -/** - Quat.inl - - @cite Quaternion implementation based on Watt & Watt page 363. - Thanks to Max McGuire for slerp optimizations. - - @maintainer Morgan McGuire, matrix@graphics3d.com - - @created 2002-01-23 - @edited 2004-03-04 - */ - -namespace G3D { - -inline float& Quat::operator[] (int i) { - debugAssert(i >= 0); - debugAssert(i < 4); - return ((float*)this)[i]; -} - -inline const float& Quat::operator[] (int i) const { - debugAssert(i >= 0); - debugAssert(i < 4); - return ((float*)this)[i]; -} - -inline Quat Quat::operator-(const Quat& other) const { - return Quat(x - other.x, y - other.y, z - other.z, w - other.w); -} - -inline Quat Quat::operator+(const Quat& other) const { - return Quat(x + other.x, y + other.y, z + other.z, w + other.w); -} - -} - diff --git a/dep/g3dlite/include/G3D/Sphere.h b/dep/g3dlite/include/G3D/Sphere.h index 595b61c4bf1..d1448261d9f 100644 --- a/dep/g3dlite/include/G3D/Sphere.h +++ b/dep/g3dlite/include/G3D/Sphere.h @@ -15,7 +15,6 @@ #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/Array.h" -#include "G3D/Sphere.h" namespace G3D { diff --git a/dep/g3dlite/include/G3D/Table.h b/dep/g3dlite/include/G3D/Table.h index 896a5a2a08a..ab0b114b1c4 100644 --- a/dep/g3dlite/include/G3D/Table.h +++ b/dep/g3dlite/include/G3D/Table.h @@ -86,12 +86,11 @@ namespace G3D { <PRE> template<> struct HashTrait<MyEnum> { - static size_t equals(const MyEnum& key) const { return reinterpret_cast<size_t>( key ); } + static size_t hashCode(const MyEnum& key) const { return reinterpret_cast<size_t>( key ); } }; </PRE> - And rely on the default enum operator==. - + and rely on the default enum operator==. Periodically check that debugGetLoad() is low (> 0.1). When it gets near 1.0 your hash function is badly designed and maps too many inputs to diff --git a/dep/g3dlite/include/G3D/Vector2.inl b/dep/g3dlite/include/G3D/Vector2.inl deleted file mode 100644 index 4f7c55a39cf..00000000000 --- a/dep/g3dlite/include/G3D/Vector2.inl +++ /dev/null @@ -1,18 +0,0 @@ -/** - @file Vector2.inl - - @maintainer Morgan McGuire, matrix@graphics3d.com - @cite Portions by Laura Wollstadt, graphics3d.com - - @cite Portions based on Dave Eberly'x Magic Software Library - at http://www.magic-software.com - - @created 2001-06-02 - @edited 2006-01-14 - - Copyright 2000-2006, Morgan McGuire. - All rights reserved. - */ - -} - diff --git a/dep/g3dlite/include/G3D/Vector3.inl b/dep/g3dlite/include/G3D/Vector3.inl deleted file mode 100644 index 9211c2a70fd..00000000000 --- a/dep/g3dlite/include/G3D/Vector3.inl +++ /dev/null @@ -1,249 +0,0 @@ -/** - @file Vector3.inl - - @maintainer Morgan McGuire, matrix@graphics3d.com - - @cite Portions based on Dave Eberly's Magic Software Library at http://www.magic-software.com - - @created 2001-06-02 - @edited 2004-05-21 - Copyright 2000-2004, Morgan McGuire. - All rights reserved. - */ - -//---------------------------------------------------------------------------- -#ifdef SSE - // If you receive an error on this line, it is because you do not have the file - // xmmintrin.h needed for MMX & SSE extensions. Download and install - // - // http://download.microsoft.com/download/vstudio60ent/SP5/Wideband-Full/WIN98Me/EN-US/vs6sp5.exe - // and - // http://download.microsoft.com/download/vb60ent/Update/6/W9X2KXP/EN-US/vcpp5.exe - // - // to get this file. -# include <xmmintrin.h> -#endif - -inline unsigned int hashCode(const G3D::Vector3& v) { - return v.hashCode(); -} - -namespace G3D { - -//---------------------------------------------------------------------------- -inline Vector3::Vector3() : x(0.0f), y(0.0f), z(0.0f) { -} - -//---------------------------------------------------------------------------- - -inline Vector3::Vector3 (float fX, float fY, float fZ) : x(fX), y(fY), z(fZ) { -} - -//---------------------------------------------------------------------------- -inline Vector3::Vector3 (float V[3]) : x(V[0]), y(V[1]), z(V[2]){ -} -//---------------------------------------------------------------------------- -inline Vector3::Vector3 (double V[3]) : x((float)V[0]), y((float)V[1]), z((float)V[2]){ -} - -//---------------------------------------------------------------------------- -inline Vector3::Vector3 (const Vector3& V) : x(V.x), y(V.y), z(V.z) { -} - -//---------------------------------------------------------------------------- - -//inline Vector3::Vector3 (const __m128& m) { - // Cast from SSE packed floats -// *this = *(Vector3*)&m; -//} - -//---------------------------------------------------------------------------- -inline const float& Vector3::operator[] (int i) const { - return ((float*)this)[i]; -} - -inline float& Vector3::operator[] (int i) { - return ((float*)this)[i]; -} - -//---------------------------------------------------------------------------- -inline Vector3& Vector3::operator= (const Vector3& rkVector) { - x = rkVector.x; - y = rkVector.y; - z = rkVector.z; - return *this; -} - -//---------------------------------------------------------------------------- - -inline bool Vector3::fuzzyEq(const Vector3& other) const { - return G3D::fuzzyEq((*this - other).squaredMagnitude(), 0); -} - -//---------------------------------------------------------------------------- - -inline bool Vector3::fuzzyNe(const Vector3& other) const { - return G3D::fuzzyNe((*this - other).squaredMagnitude(), 0); -} - -//---------------------------------------------------------------------------- - -inline bool Vector3::isFinite() const { - return G3D::isFinite(x) && G3D::isFinite(y) && G3D::isFinite(z); -} - -//---------------------------------------------------------------------------- -inline bool Vector3::operator== (const Vector3& rkVector) const { - return ( x == rkVector.x && y == rkVector.y && z == rkVector.z ); -} - -//---------------------------------------------------------------------------- -inline bool Vector3::operator!= (const Vector3& rkVector) const { - return ( x != rkVector.x || y != rkVector.y || z != rkVector.z ); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::operator+ (const Vector3& rkVector) const { - return Vector3(x + rkVector.x, y + rkVector.y, z + rkVector.z); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::operator- (const Vector3& rkVector) const { - return Vector3(x - rkVector.x, y - rkVector.y, z - rkVector.z); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::operator* (const Vector3& rkVector) const { - return Vector3(x * rkVector.x, y * rkVector.y, z * rkVector.z); -} - -inline Vector3 Vector3::operator*(float f) const { - return Vector3(x * f, y * f, z * f); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::operator/ (const Vector3& rkVector) const { - return Vector3(x / rkVector.x, y / rkVector.y, z / rkVector.z); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::operator- () const { - return Vector3(-x, -y, -z); -} - -//---------------------------------------------------------------------------- -inline Vector3& Vector3::operator+= (const Vector3& rkVector) { - x += rkVector.x; - y += rkVector.y; - z += rkVector.z; - return *this; -} - -//---------------------------------------------------------------------------- -inline Vector3& Vector3::operator-= (const Vector3& rkVector) { - x -= rkVector.x; - y -= rkVector.y; - z -= rkVector.z; - return *this; -} - -//---------------------------------------------------------------------------- -inline Vector3& Vector3::operator*= (float fScalar) { - x *= fScalar; - y *= fScalar; - z *= fScalar; - return *this; -} - -//---------------------------------------------------------------------------- -inline Vector3& Vector3::operator*= (const Vector3& rkVector) { - x *= rkVector.x; - y *= rkVector.y; - z *= rkVector.z; - return *this; -} - -//---------------------------------------------------------------------------- -inline Vector3& Vector3::operator/= (const Vector3& rkVector) { - x /= rkVector.x; - y /= rkVector.y; - z /= rkVector.z; - return *this; -} - -//---------------------------------------------------------------------------- -inline float Vector3::squaredMagnitude () const { - return x*x + y*y + z*z; -} - -//---------------------------------------------------------------------------- -inline float Vector3::squaredLength () const { - return squaredMagnitude(); -} - -//---------------------------------------------------------------------------- -inline float Vector3::magnitude() const { - return sqrtf(x*x + y*y + z*z); -} - -//---------------------------------------------------------------------------- -inline float Vector3::length() const { - return magnitude(); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::direction () const { - float lenSquared = squaredMagnitude(); - float invSqrt = 1.0f / sqrtf(lenSquared); - return Vector3(x * invSqrt, y * invSqrt, z * invSqrt); -} - -//---------------------------------------------------------------------------- - -inline Vector3 Vector3::fastDirection () const { - float lenSquared = x * x + y * y + z * z; - float invSqrt = rsq(lenSquared); - return Vector3(x * invSqrt, y * invSqrt, z * invSqrt); -} - -//---------------------------------------------------------------------------- -inline float Vector3::dot (const Vector3& rkVector) const { - return x*rkVector.x + y*rkVector.y + z*rkVector.z; -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::cross (const Vector3& rkVector) const { - return Vector3(y*rkVector.z - z*rkVector.y, z*rkVector.x - x*rkVector.z, - x*rkVector.y - y*rkVector.x); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::unitCross (const Vector3& rkVector) const { - Vector3 kCross(y*rkVector.z - z*rkVector.y, z*rkVector.x - x*rkVector.z, - x*rkVector.y - y*rkVector.x); - kCross.unitize(); - return kCross; -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::min(const Vector3 &v) const { - return Vector3(G3D::min(v.x, x), G3D::min(v.y, y), G3D::min(v.z, z)); -} - -//---------------------------------------------------------------------------- -inline Vector3 Vector3::max(const Vector3 &v) const { - return Vector3(G3D::max(v.x, x), G3D::max(v.y, y), G3D::max(v.z, z)); -} - -//---------------------------------------------------------------------------- -inline bool Vector3::isZero() const { - return G3D::fuzzyEq(squaredMagnitude(), 0.0f); -} - -//---------------------------------------------------------------------------- - -inline bool Vector3::isUnit() const { - return G3D::fuzzyEq(squaredMagnitude(), 1.0f); -} - -} // namespace diff --git a/dep/g3dlite/include/G3D/Vector4.inl b/dep/g3dlite/include/G3D/Vector4.inl deleted file mode 100644 index 576cca83b56..00000000000 --- a/dep/g3dlite/include/G3D/Vector4.inl +++ /dev/null @@ -1,191 +0,0 @@ -/** - @file Vector4.inl - - @maintainer Morgan McGuire, matrix@graphics3d.com - - @created 2002-07-09 - @edited 2003-02-10 - */ - -//---------------------------------------------------------------------------- - -inline unsigned int hashCode(const G3D::Vector4& v) { - return v.hashCode(); -} - -namespace G3D { - -//---------------------------------------------------------------------------- -inline Vector4::Vector4() { - x = y = z = w = 0; -} - -//---------------------------------------------------------------------------- - -inline Vector4::Vector4 (float fX, float fY, float fZ, float fW) { - x = fX; - y = fY; - z = fZ; - w = fW; -} - -//---------------------------------------------------------------------------- -inline Vector4::Vector4 (float afCoordinate[4]) { - x = afCoordinate[0]; - y = afCoordinate[1]; - z = afCoordinate[2]; - w = afCoordinate[3]; -} - -//---------------------------------------------------------------------------- -inline Vector4::Vector4(const Vector4& rkVector) { - x = rkVector.x; - y = rkVector.y; - z = rkVector.z; - w = rkVector.w; -} -//---------------------------------------------------------------------------- -inline Vector4::Vector4(const Vector3& rkVector, float fW) { - x = rkVector.x; - y = rkVector.y; - z = rkVector.z; - w = fW; -} - -//---------------------------------------------------------------------------- -inline float& Vector4::operator[] (int i) { - return ((float*)this)[i]; -} - -//---------------------------------------------------------------------------- -inline const float& Vector4::operator[] (int i) const { - return ((float*)this)[i]; -} - -//---------------------------------------------------------------------------- -inline Vector4::operator float* () { - return (float*)this; -} - -inline Vector4::operator const float* () const { - return (float*)this; -} - -//---------------------------------------------------------------------------- -inline Vector4& Vector4::operator= (const Vector4& rkVector) { - x = rkVector.x; - y = rkVector.y; - z = rkVector.z; - w = rkVector.w; - return *this; -} - -//---------------------------------------------------------------------------- -inline bool Vector4::operator== (const Vector4& rkVector) const { - return ( (x == rkVector.x) && (y == rkVector.y) && (z == rkVector.z) && (w == rkVector.w)); -} - -//---------------------------------------------------------------------------- -inline bool Vector4::operator!= (const Vector4& rkVector) const { - return ( x != rkVector.x || y != rkVector.y || z != rkVector.z || w != rkVector.w); -} - -//---------------------------------------------------------------------------- -inline Vector4 Vector4::operator+ (const Vector4& rkVector) const { - return Vector4(x + rkVector.x, y + rkVector.y, z + rkVector.z, w + rkVector.w); -} - -//---------------------------------------------------------------------------- -inline Vector4 Vector4::operator- (const Vector4& rkVector) const { - return Vector4(x - rkVector.x, y - rkVector.y, z - rkVector.z, w - rkVector.w); -} - -//---------------------------------------------------------------------------- -inline Vector4 Vector4::operator* (float fScalar) const { - return Vector4(fScalar*x, fScalar*y, fScalar*z, fScalar*w); -} - -//---------------------------------------------------------------------------- -inline Vector4 Vector4::operator- () const { - return Vector4( -x, -y, -z, -w); -} - -//---------------------------------------------------------------------------- -inline Vector4& Vector4::operator+= (const Vector4& rkVector) { - x += rkVector.x; - y += rkVector.y; - z += rkVector.z; - w += rkVector.w; - return *this; -} - -//---------------------------------------------------------------------------- -inline Vector4& Vector4::operator-= (const Vector4& rkVector) { - x -= rkVector.x; - y -= rkVector.y; - z -= rkVector.z; - w -= rkVector.w; - return *this; -} - -//---------------------------------------------------------------------------- - -inline Vector4 Vector4::lerp(const Vector4& v, float alpha) const { - return (*this) + (v - *this) * alpha; -} - -//---------------------------------------------------------------------------- -inline Vector4& Vector4::operator*= (float fScalar) { - x *= fScalar; - y *= fScalar; - z *= fScalar; - w *= fScalar; - return *this; -} - -//---------------------------------------------------------------------------- -inline float Vector4::dot(const Vector4& rkVector) const { - return x*rkVector.x + y*rkVector.y + z*rkVector.z + w*rkVector.w; -} - -//---------------------------------------------------------------------------- -inline Vector4 Vector4::min(const Vector4 &v) const { - return Vector4(G3D::min(v.x, x), G3D::min(v.y, y), G3D::min(v.z, z), G3D::min(v.w, w)); -} - -//---------------------------------------------------------------------------- -inline Vector4 Vector4::max(const Vector4 &v) const { - return Vector4(G3D::max(v.x, x), G3D::max(v.y, y), G3D::max(v.z, z), G3D::max(v.w, w)); -} - -//---------------------------------------------------------------------------- -inline bool Vector4::isZero() const { - return (x == 0.0f) && (y == 0.0f) && (z == 0.0f) && (w == 0.0f); -} - -//---------------------------------------------------------------------------- - -inline bool Vector4::isFinite() const { - return G3D::isFinite(x) && G3D::isFinite(y) && G3D::isFinite(z) && G3D::isFinite(w); -} - -//---------------------------------------------------------------------------- - -inline bool Vector4::isUnit() const { - return squaredLength() == 1.0; -} - -//---------------------------------------------------------------------------- - -inline float Vector4::length() const { - return sqrtf(squaredLength()); -} - -//---------------------------------------------------------------------------- - -inline float Vector4::squaredLength() const { - return x * x + y * y + z * z + w * w; -} - -} - diff --git a/dep/g3dlite/include/G3D/g3dmath.inl b/dep/g3dlite/include/G3D/g3dmath.inl deleted file mode 100644 index 9bf661a7ebc..00000000000 --- a/dep/g3dlite/include/G3D/g3dmath.inl +++ /dev/null @@ -1,288 +0,0 @@ -/** - @file g3dmath.inl - - @maintainer Morgan McGuire, matrix@graphics3d.com - - @created 2001-06-02 - @edited 2006-01-14 - */ - -#include <stdlib.h> - -#ifdef _MSC_VER -// Disable conditional expression is constant, which occurs incorrectly on inlined functions -# pragma warning (push) -# pragma warning( disable : 4127 ) -#endif - -namespace G3D { - -inline bool isNaN(double x) { - bool b1 = (x < 0.0); - bool b2 = (x >= 0.0); - bool b3 = !(b1 || b2); - return b3; -} - -inline bool isFinite(double x) { - return ! isNaN(x) && (x < G3D::inf()) && (x > -G3D::inf()); -} - -//---------------------------------------------------------------------------- -inline int iAbs (int iValue) { - return ( iValue >= 0 ? iValue : -iValue ); -} - -//---------------------------------------------------------------------------- -inline int iCeil (double fValue) { - return int(::ceil(fValue)); -} - -//---------------------------------------------------------------------------- - -inline int iClamp(int val, int low, int hi) { - debugAssert(low <= hi); - if (val <= low) { - return low; - } else if (val >= hi) { - return hi; - } else { - return val; - } -} - -//---------------------------------------------------------------------------- - -inline double clamp(double val, double low, double hi) { - debugAssert(low <= hi); - if (val <= low) { - return low; - } else if (val >= hi) { - return hi; - } else { - return val; - } -} - -inline float clamp(float val, float low, float hi) { - debugAssert(low <= hi); - if (val <= low) { - return low; - } else if (val >= hi) { - return hi; - } else { - return val; - } -} -//---------------------------------------------------------------------------- - -inline int iWrap(int val, int hi) { - if (val < 0) { - return ((val % hi) + hi) % hi; - } else { - return val % hi; - } -} - -//---------------------------------------------------------------------------- -inline int iFloor (double fValue) { - return int(::floor(fValue)); -} - -//---------------------------------------------------------------------------- -inline int iSign (int iValue) { - return ( iValue > 0 ? + 1 : ( iValue < 0 ? -1 : 0 ) ); -} - -inline int iSign (double fValue) { - return ( fValue > 0.0 ? + 1 : ( fValue < 0.0 ? -1 : 0 ) ); -} - -//---------------------------------------------------------------------------- -inline double abs (double fValue) { - return double(::fabs(fValue)); -} - -//---------------------------------------------------------------------------- -inline double aCos (double fValue) { - if ( -1.0 < fValue ) { - if ( fValue < 1.0 ) - return double(::acos(fValue)); - else - return 0.0; - } else { - return G3D_PI; - } -} - -//---------------------------------------------------------------------------- -inline double aSin (double fValue) { - if ( -1.0 < fValue ) { - if ( fValue < 1.0 ) { - return double(::asin(fValue)); - } else { - return -G3D_HALF_PI; - } - } else { - return G3D_HALF_PI; - } -} - -//---------------------------------------------------------------------------- -inline double aTan (double fValue) { - return double(::atan(fValue)); -} - -//---------------------------------------------------------------------------- -inline double aTan2 (double fY, double fX) { - return double(::atan2(fY, fX)); -} - -//---------------------------------------------------------------------------- -inline double sign (double fValue) { - if (fValue > 0.0) { - return 1.0; - } - - if (fValue < 0.0) { - return -1.0; - } - - return 0.0; -} - -inline double G3D_DEPRECATED unitRandom () { - return double(::rand()) / double(RAND_MAX); -} - -inline float uniformRandom(float low, float hi) { - return (hi - low) * float(::rand()) / float(RAND_MAX) + low; -} - -//---------------------------------------------------------------------------- -inline double G3D_DEPRECATED symmetricRandom () { - return 2.0 * double(::rand()) / double(RAND_MAX) - 1.0; -} - -//---------------------------------------------------------------------------- -inline double square(double x) { - return x * x; -} - -//---------------------------------------------------------------------------- -inline double sumSquares(double x, double y) { - return x*x + y*y; -} - -//---------------------------------------------------------------------------- -inline double sumSquares(double x, double y, double z) { - return x*x + y*y + z*z; -} - -//---------------------------------------------------------------------------- -inline double distance(double x, double y) { - return sqrt(sumSquares(x, y)); -} - -//---------------------------------------------------------------------------- -inline double distance(double x, double y, double z) { - return sqrt(sumSquares(x, y, z)); -} - -//---------------------------------------------------------------------------- - -/** @deprecated use G3D::min */ -inline int iMin(int x, int y) { - return (x >= y) ? y : x; -} - -//---------------------------------------------------------------------------- -/** @deprecated use G3D::min */ -inline int iMax(int x, int y) { - return (x >= y) ? x : y; -} - -//---------------------------------------------------------------------------- -inline int ceilPow2(unsigned int in) { - in -= 1; - - in |= in >> 16; - in |= in >> 8; - in |= in >> 4; - in |= in >> 2; - in |= in >> 1; - - return in + 1; -} - -inline bool isPow2(int num) { - return ((num & -num) == num); -} - -inline bool isOdd(int num) { - return (num & 1) == 1; -} - -inline bool isEven(int num) { - return (num & 1) == 0; -} - -inline double toRadians(double deg) { - return deg * G3D_PI / 180.0; -} - -inline double toDegrees(double rad) { - return rad * 180.0 / G3D_PI; -} - -/** - Computes an appropriate epsilon for comparing a and b. - */ -inline double eps(double a, double b) { - // For a and b to be nearly equal, they must have nearly - // the same magnitude. This means that we can ignore b - // since it either has the same magnitude or the comparison - // will fail anyway. - (void)b; - const double aa = abs(a) + 1; - if (aa == inf()) { - return fuzzyEpsilon; - } else { - return fuzzyEpsilon * aa; - } -} - -inline bool fuzzyEq(double a, double b) { - return (a == b) || (abs(a - b) <= eps(a, b)); -} - -inline bool fuzzyNe(double a, double b) { - return ! fuzzyEq(a, b); -} - -inline bool fuzzyGt(double a, double b) { - return a > b + eps(a, b); -} - -inline bool fuzzyGe(double a, double b) { - return a > b - eps(a, b); -} - -inline bool fuzzyLt(double a, double b) { - return a < b - eps(a, b); -} - -inline bool fuzzyLe(double a, double b) { - return a < b + eps(a, b); -} - -inline int iMod3(int x) { - return x % 3; -} - -} // namespace G3D - -#ifdef _MSC_VER -// Disable conditional expression is constant, which occurs incorrectly on inlined functions -# pragma warning (pop) -#endif diff --git a/dep/g3dlite/include/G3D/platform.h b/dep/g3dlite/include/G3D/platform.h index d399135101b..c8d2f0b6534 100644 --- a/dep/g3dlite/include/G3D/platform.h +++ b/dep/g3dlite/include/G3D/platform.h @@ -6,7 +6,7 @@ @maintainer Morgan McGuire, http://graphics.cs.williams.edu @created 2003-06-09 - @edited 2010-01-11 + @edited 2010-08-11 */ #ifndef G3D_platform_h @@ -16,7 +16,7 @@ The version number of G3D in the form: MmmBB -> version M.mm [beta BB] */ -#define G3D_VER 80000 +#define G3D_VER 80100 // fatal error for unsupported architectures #if defined(__powerpc__) diff --git a/dep/g3dlite/source/AABox.cpp b/dep/g3dlite/source/AABox.cpp index 035497aa3c4..8e66456c013 100644 --- a/dep/g3dlite/source/AABox.cpp +++ b/dep/g3dlite/source/AABox.cpp @@ -282,6 +282,10 @@ bool AABox::culledBy( return false; } +void AABox::getBounds(Sphere& s) const { + s.center = center(); + s.radius = extent().length() / 2; +} bool AABox::intersects(const class Sphere& sphere) const { double d = 0; diff --git a/dep/g3dlite/source/Log.cpp b/dep/g3dlite/source/Log.cpp index d44d88d0242..f437351cfbd 100644 --- a/dep/g3dlite/source/Log.cpp +++ b/dep/g3dlite/source/Log.cpp @@ -23,23 +23,23 @@ namespace G3D { void logPrintf(const char* fmt, ...) { - va_list arg_list; - va_start(arg_list, fmt); + va_list arg_list; + va_start(arg_list, fmt); Log::common()->vprintf(fmt, arg_list); va_end(arg_list); } void logLazyPrintf(const char* fmt, ...) { - va_list arg_list; - va_start(arg_list, fmt); + va_list arg_list; + va_start(arg_list, fmt); Log::common()->lazyvprintf(fmt, arg_list); va_end(arg_list); } Log* Log::commonLog = NULL; -Log::Log(const std::string& filename, int stripFromStackBottom) : +Log::Log(const std::string& filename, int stripFromStackBottom) : stripFromStackBottom(stripFromStackBottom) { this->filename = filename; @@ -50,7 +50,7 @@ Log::Log(const std::string& filename, int stripFromStackBottom) : std::string drive, base, ext; Array<std::string> path; parseFilename(filename, drive, path, base, ext); - std::string logName = base + ((ext != "") ? ("." + ext) : ""); + std::string logName = base + ((ext != "") ? ("." + ext) : ""); // Write time is greater than 1ms. This may be a network drive.... try another file. #ifdef G3D_WIN32 @@ -80,7 +80,7 @@ Log::Log(const std::string& filename, int stripFromStackBottom) : Log::~Log() { section("Shutdown"); println("Closing log file"); - + // Make sure we don't leave a dangling pointer if (Log::commonLog == this) { Log::commonLog = NULL; diff --git a/dep/g3dlite/source/System.cpp b/dep/g3dlite/source/System.cpp index 5170ba44941..809f05c0ab4 100644 --- a/dep/g3dlite/source/System.cpp +++ b/dep/g3dlite/source/System.cpp @@ -920,9 +920,12 @@ RealTime System::time() { //////////////////////////////////////////////////////////////// -#define REALPTR_TO_USERPTR(x) ((uint8*)(x) + sizeof (void *)) -#define USERPTR_TO_REALPTR(x) ((uint8*)(x) - sizeof (void *)) -#define REALBLOCK_SIZE(x) ((x) + sizeof (void *)) + +#define REALPTR_TO_USERPTR(x) ((uint8*)(x) + sizeof(uint32)) +#define USERPTR_TO_REALPTR(x) ((uint8*)(x) - sizeof(uint32)) +#define USERSIZE_TO_REALSIZE(x) ((x) + sizeof(uint32)) +#define REALSIZE_FROM_USERPTR(u) (*(uint32*)USERPTR_TO_REALPTR(ptr) + sizeof(uint32)) +#define USERSIZE_FROM_USERPTR(u) (*(uint32*)USERPTR_TO_REALPTR(ptr)) class BufferPool { public: @@ -947,13 +950,19 @@ public: private: + /** Pointer given to the program. Unless in the tiny heap, the user size of the block is stored right in front of the pointer as a uint32.*/ + typedef void* UserPtr; + + /** Actual block allocated on the heap */ + typedef void* RealPtr; + class MemBlock { public: - void* ptr; - size_t bytes; + UserPtr ptr; + size_t bytes; inline MemBlock() : ptr(NULL), bytes(0) {} - inline MemBlock(void* p, size_t b) : ptr(p), bytes(b) {} + inline MemBlock(UserPtr p, size_t b) : ptr(p), bytes(b) {} }; MemBlock smallPool[maxSmallBuffers]; @@ -1010,13 +1019,13 @@ private: /** Malloc out of the tiny heap. Returns NULL if allocation failed. */ - inline void* tinyMalloc(size_t bytes) { + inline UserPtr tinyMalloc(size_t bytes) { // Note that we ignore the actual byte size // and create a constant size block. (void)bytes; assert(tinyBufferSize >= bytes); - void* ptr = NULL; + UserPtr ptr = NULL; if (tinyPoolSize > 0) { --tinyPoolSize; @@ -1040,20 +1049,20 @@ private: } /** Returns true if this is a pointer into the tiny heap. */ - bool inTinyHeap(void* ptr) { + bool inTinyHeap(UserPtr ptr) { return (ptr >= tinyHeap) && (ptr < (uint8*)tinyHeap + maxTinyBuffers * tinyBufferSize); } - void tinyFree(void* ptr) { + void tinyFree(UserPtr ptr) { assert(ptr); assert(tinyPoolSize < maxTinyBuffers); // "Tried to free a tiny pool buffer when the tiny pool freelist is full."); # ifdef G3D_DEBUG if (tinyPoolSize > 0) { - void* prevOnHeap = tinyPool[tinyPoolSize - 1]; + UserPtr prevOnHeap = tinyPool[tinyPoolSize - 1]; assert(prevOnHeap != ptr); // "System::malloc heap corruption detected: " // "the last two pointers on the freelist are identical (during tinyFree)."); @@ -1070,7 +1079,8 @@ private: void flushPool(MemBlock* pool, int& poolSize) { for (int i = 0; i < poolSize; ++i) { - ::free(pool[i].ptr); + bytesAllocated -= USERSIZE_TO_REALSIZE(pool[i].bytes); + ::free(USERPTR_TO_REALPTR(pool[i].ptr)); pool[i].ptr = NULL; pool[i].bytes = 0; } @@ -1078,24 +1088,23 @@ private: } - /** Allocate out of a specific pool-> Return NULL if no suitable - memory was found. - - */ - void* malloc(MemBlock* pool, int& poolSize, size_t bytes) { + /** Allocate out of a specific pool. Return NULL if no suitable + memory was found. */ + UserPtr malloc(MemBlock* pool, int& poolSize, size_t bytes) { // OPT: find the smallest block that satisfies the request. - // See if there's something we can use in the buffer pool-> + // See if there's something we can use in the buffer pool. // Search backwards since usually we'll re-use the last one. for (int i = (int)poolSize - 1; i >= 0; --i) { if (pool[i].bytes >= bytes) { - // We found a suitable entry in the pool-> + // We found a suitable entry in the pool. // No need to offset the pointer; it is already offset - void* ptr = pool[i].ptr; + UserPtr ptr = pool[i].ptr; - // Remove this element from the pool + // Remove this element from the pool, replacing it with + // the one from the end (same as Array::fastRemove) --poolSize; pool[i] = pool[poolSize]; @@ -1159,6 +1168,8 @@ public: ~BufferPool() { ::free(tinyHeap); + flushPool(smallPool, smallPoolSize); + flushPool(medPool, medPoolSize); #if 0 //-------------------------------- old mutex # ifdef G3D_WIN32 DeleteCriticalSection(&mutex); @@ -1169,7 +1180,7 @@ public: } - void* realloc(void* ptr, size_t bytes) { + UserPtr realloc(UserPtr ptr, size_t bytes) { if (ptr == NULL) { return malloc(bytes); } @@ -1181,7 +1192,7 @@ public: } else { // Free the old pointer and malloc - void* newPtr = malloc(bytes); + UserPtr newPtr = malloc(bytes); System::memcpy(newPtr, ptr, tinyBufferSize); tinyFree(ptr); return newPtr; @@ -1191,28 +1202,28 @@ public: // In one of our heaps. // See how big the block really was - size_t realSize = *(uint32*)USERPTR_TO_REALPTR(ptr); - if (bytes <= realSize) { + size_t userSize = USERSIZE_FROM_USERPTR(ptr); + if (bytes <= userSize) { // The old block was big enough. return ptr; } - // Need to reallocate - void* newPtr = malloc(bytes); - System::memcpy(newPtr, ptr, realSize); + // Need to reallocate and move + UserPtr newPtr = malloc(bytes); + System::memcpy(newPtr, ptr, userSize); free(ptr); return newPtr; } } - void* malloc(size_t bytes) { + UserPtr malloc(size_t bytes) { lock(); ++totalMallocs; if (bytes <= tinyBufferSize) { - void* ptr = tinyMalloc(bytes); + UserPtr ptr = tinyMalloc(bytes); if (ptr) { ++mallocsFromTinyPool; @@ -1226,7 +1237,7 @@ public: // through to a small buffer if (bytes <= smallBufferSize) { - void* ptr = malloc(smallPool, smallPoolSize, bytes); + UserPtr ptr = malloc(smallPool, smallPoolSize, bytes); if (ptr) { ++mallocsFromSmallPool; @@ -1239,7 +1250,7 @@ public: // through into a medium allocation because that would // waste the medium buffer's resources. - void* ptr = malloc(medPool, medPoolSize, bytes); + UserPtr ptr = malloc(medPool, medPoolSize, bytes); if (ptr) { ++mallocsFromMedPool; @@ -1249,37 +1260,37 @@ public: } } - bytesAllocated += REALBLOCK_SIZE(bytes); + bytesAllocated += USERSIZE_TO_REALSIZE(bytes); unlock(); // Heap allocate // Allocate 4 extra bytes for our size header (unfortunate, // since malloc already added its own header). - void* ptr = ::malloc(REALBLOCK_SIZE(bytes)); + RealPtr ptr = ::malloc(USERSIZE_TO_REALSIZE(bytes)); if (ptr == NULL) { // Flush memory pools to try and recover space flushPool(smallPool, smallPoolSize); flushPool(medPool, medPoolSize); - ptr = ::malloc(REALBLOCK_SIZE(bytes)); + ptr = ::malloc(USERSIZE_TO_REALSIZE(bytes)); } if (ptr == NULL) { if ((System::outOfMemoryCallback() != NULL) && - (System::outOfMemoryCallback()(REALBLOCK_SIZE(bytes), true) == true)) { + (System::outOfMemoryCallback()(USERSIZE_TO_REALSIZE(bytes), true) == true)) { // Re-attempt the malloc - ptr = ::malloc(REALBLOCK_SIZE(bytes)); + ptr = ::malloc(USERSIZE_TO_REALSIZE(bytes)); } } if (ptr == NULL) { if (System::outOfMemoryCallback() != NULL) { // Notify the application - System::outOfMemoryCallback()(REALBLOCK_SIZE(bytes), false); + System::outOfMemoryCallback()(USERSIZE_TO_REALSIZE(bytes), false); } # ifdef G3D_DEBUG - debugPrintf("::malloc(%d) returned NULL\n", (int)REALBLOCK_SIZE(bytes)); + debugPrintf("::malloc(%d) returned NULL\n", (int)USERSIZE_TO_REALSIZE(bytes)); # endif debugAssertM(ptr != NULL, "::malloc returned NULL. Either the " @@ -1294,7 +1305,7 @@ public: } - void free(void* ptr) { + void free(UserPtr ptr) { if (ptr == NULL) { // Free does nothing on null pointers return; @@ -1309,7 +1320,7 @@ public: return; } - uint32 bytes = *(uint32*)USERPTR_TO_REALPTR(ptr); + uint32 bytes = USERSIZE_FROM_USERPTR(ptr); lock(); if (bytes <= smallBufferSize) { @@ -1327,7 +1338,7 @@ public: return; } } - bytesAllocated -= REALBLOCK_SIZE(bytes); + bytesAllocated -= USERSIZE_TO_REALSIZE(bytes); unlock(); // Free; the buffer pools are full or this is too big to store. diff --git a/dep/g3dlite/source/TextInput.cpp b/dep/g3dlite/source/TextInput.cpp index 09abacc7391..354d0de13c0 100644 --- a/dep/g3dlite/source/TextInput.cpp +++ b/dep/g3dlite/source/TextInput.cpp @@ -128,32 +128,34 @@ Token TextInput::read() { } -std::string TextInput::readUntilNewlineAsString() { - // Go to the front of the next token - Token t = read(); - // Reset the position to the start of this token +std::string TextInput::readUntilNewlineAsString() { +/* + // Reset the read position back to the start of that token currentCharOffset = t.bytePosition(); + lineNumber = t.line(); + charNumber = t.character(); stack.clear(); if (currentCharOffset == buffer.size()) { // End of file return ""; } - + */ std::string s; // Read until newline or eof char c = '\0'; do { - c = buffer[currentCharOffset]; - if (c == '\r' || c == '\n') { - // Done - break; - } else { - s += c; - ++currentCharOffset; - } + c = buffer[currentCharOffset]; + if (c == '\r' || c == '\n') { + // Done + break; + } else { + s += c; + ++currentCharOffset; + ++charNumber; + } } while (currentCharOffset < buffer.size()); return s; diff --git a/dep/gsoap/gsoap.stub b/dep/gsoap/gsoap.stub new file mode 100644 index 00000000000..be215b46655 --- /dev/null +++ b/dep/gsoap/gsoap.stub @@ -0,0 +1 @@ +int ns1__executeCommand(char* command, char** result); diff --git a/dep/gsoap/soapC.cpp b/dep/gsoap/soapC.cpp index 7fefc27f5d1..2c675cc339d 100644 --- a/dep/gsoap/soapC.cpp +++ b/dep/gsoap/soapC.cpp @@ -1,8 +1,11 @@ /* soapC.cpp - Generated by gSOAP 2.8.2 from stub.h - Copyright(C) 2000-2011, Robert van Engelen, Genivia Inc. All Rights Reserved. - The generated code is released under one of the following licenses: - GPL OR Genivia's license for commercial use. + Generated by gSOAP 2.8.10 from gsoap.stub + +Copyright(C) 2000-2012, Robert van Engelen, Genivia Inc. All Rights Reserved. +The generated code is released under one of the following licenses: +1) GPL or 2) Genivia's license for commercial use. +This program is released under the GPL with the additional exemption that +compiling, linking, and/or using OpenSSL is allowed. */ #if defined(__BORLANDC__) @@ -12,15 +15,17 @@ #include "soapH.h" -SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.8.2 2011-04-26 21:49:07 GMT") +SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.8.10 2012-09-02 20:48:00 GMT") #ifndef WITH_NOGLOBAL -SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap) +SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap) { - if (soap->header) - soap_serialize_SOAP_ENV__Header(soap, soap->header); + soap->part = SOAP_IN_HEADER; + soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", soap->header, NULL); + soap->part = SOAP_END_HEADER; + return soap->header == NULL; } SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap) @@ -34,12 +39,10 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap) return SOAP_OK; } -SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap) +SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap) { - soap->part = SOAP_IN_HEADER; - soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", NULL, NULL); - soap->part = SOAP_END_HEADER; - return soap->header == NULL; + if (soap->header) + soap_serialize_SOAP_ENV__Header(soap, soap->header); } SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap) @@ -90,7 +93,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap) SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap) { soap_fault(soap); - if (soap->version == 2) + if (soap->version == 2 && soap->fault->SOAP_ENV__Code) return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value; return (const char**)&soap->fault->faultcode; } @@ -108,6 +111,17 @@ SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap) return (const char**)&soap->fault->faultcode; } +SOAP_FMAC3 const char * SOAP_FMAC4 soap_check_faultsubcode(struct soap *soap) +{ + soap_fault(soap); + if (soap->version == 2) + { if (soap->fault->SOAP_ENV__Code && soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode && soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode) + return soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value; + return NULL; + } + return soap->fault->faultcode; +} + SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap) { soap_fault(soap); @@ -133,6 +147,16 @@ SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap) return (const char**)&soap->fault->SOAP_ENV__Detail->__any; } +SOAP_FMAC3 const char * SOAP_FMAC4 soap_check_faultdetail(struct soap *soap) +{ + soap_fault(soap); + if (soap->version == 2 && soap->fault->SOAP_ENV__Detail) + return soap->fault->SOAP_ENV__Detail->__any; + if (soap->fault->detail) + return soap->fault->detail->__any; + return NULL; +} + #endif #ifndef WITH_NOIDREF @@ -158,7 +182,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap) extern "C" { #endif SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type) -{ +{ (void)type; if (soap_peek_element(soap)) return NULL; if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id))) @@ -280,7 +304,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap) extern "C" { #endif SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, const char *tag, int id, int type) -{ +{ (void)tag; switch (type) { case SOAP_TYPE_byte: @@ -340,7 +364,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, #endif SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n) -{ +{ (void)type; switch (t) { case SOAP_TYPE_ns1__executeCommandResponse: @@ -446,7 +470,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a) } SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type) -{ +{ (void)soap; (void)type; (void)tag; (void)id; return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_byte); } @@ -483,7 +507,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a) } SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type) -{ +{ (void)soap; (void)type; (void)tag; (void)id; return soap_outint(soap, tag, id, a, type, SOAP_TYPE_int); } @@ -542,13 +566,14 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, con SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type) { const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode); + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Fault), type)) return soap->error; if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, "")) return soap->error; - if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "xsd:string")) + if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "")) return soap->error; - if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "xsd:string")) + if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "")) return soap->error; if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, "")) return soap->error; @@ -692,7 +717,7 @@ SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault( SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p)); *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q; } @@ -715,6 +740,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, co SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type) { + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Reason), type)) return soap->error; if (soap->lang) @@ -803,7 +829,7 @@ SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reaso SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p)); *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q; } @@ -828,6 +854,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, co SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type) { + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Detail), type)) return soap->error; soap_outliteral(soap, "-any", &a->__any, NULL); @@ -921,7 +948,7 @@ SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detai SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p)); *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q; } @@ -947,6 +974,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, cons SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type) { const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value); + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Code), type)) return soap->error; if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, "")) @@ -1041,7 +1069,7 @@ SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(st SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p)); *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q; } @@ -1062,6 +1090,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, co SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type) { + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type)) return soap->error; return soap_element_end_out(soap, tag); @@ -1140,7 +1169,7 @@ SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Heade SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p)); *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q; } @@ -1161,9 +1190,10 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommand(struct soap *soap, SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommand(struct soap *soap, const char *tag, int id, const struct ns1__executeCommand *a, const char *type) { + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_ns1__executeCommand), type)) return soap->error; - if (soap_out_string(soap, "command", -1, &a->command, "xsd:string")) + if (soap_out_string(soap, "command", -1, &a->command, "")) return soap->error; return soap_element_end_out(soap, tag); } @@ -1247,7 +1277,7 @@ SOAP_FMAC1 struct ns1__executeCommand * SOAP_FMAC2 soap_instantiate_ns1__execute SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommand(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct ns1__executeCommand %p -> %p\n", q, p)); *(struct ns1__executeCommand*)p = *(struct ns1__executeCommand*)q; } @@ -1266,9 +1296,10 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommandResponse(struct soa SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommandResponse(struct soap *soap, const char *tag, int id, const struct ns1__executeCommandResponse *a, const char *type) { + (void)soap; (void)tag; (void)id; (void)type; if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_ns1__executeCommandResponse), type)) return soap->error; - if (soap_out_PointerTostring(soap, "result", -1, &a->result, "xsd:string")) + if (soap_out_PointerTostring(soap, "result", -1, &a->result, "")) return soap->error; return soap_element_end_out(soap, tag); } @@ -1352,7 +1383,7 @@ SOAP_FMAC1 struct ns1__executeCommandResponse * SOAP_FMAC2 soap_instantiate_ns1_ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommandResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { - (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ + (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct ns1__executeCommandResponse %p -> %p\n", q, p)); *(struct ns1__executeCommandResponse*)p = *(struct ns1__executeCommandResponse*)q; } @@ -1383,6 +1414,8 @@ SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reas *a = NULL; if (!soap->null && *soap->href != '#') { soap_revert(soap); + *a = (struct SOAP_ENV__Reason *)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason)); + soap_default_SOAP_ENV__Reason(soap, *a); if (!(*a = soap_in_SOAP_ENV__Reason(soap, tag, *a, type))) return NULL; } @@ -1438,6 +1471,8 @@ SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Deta *a = NULL; if (!soap->null && *soap->href != '#') { soap_revert(soap); + *a = (struct SOAP_ENV__Detail *)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail)); + soap_default_SOAP_ENV__Detail(soap, *a); if (!(*a = soap_in_SOAP_ENV__Detail(soap, tag, *a, type))) return NULL; } @@ -1493,6 +1528,8 @@ SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(s *a = NULL; if (!soap->null && *soap->href != '#') { soap_revert(soap); + *a = (struct SOAP_ENV__Code *)soap_malloc(soap, sizeof(struct SOAP_ENV__Code)); + soap_default_SOAP_ENV__Code(soap, *a); if (!(*a = soap_in_SOAP_ENV__Code(soap, tag, *a, type))) return NULL; } diff --git a/dep/gsoap/soapH.h b/dep/gsoap/soapH.h index e51d3defaaf..06e9ec21239 100644 --- a/dep/gsoap/soapH.h +++ b/dep/gsoap/soapH.h @@ -1,8 +1,11 @@ /* soapH.h - Generated by gSOAP 2.8.2 from stub.h - Copyright(C) 2000-2011, Robert van Engelen, Genivia Inc. All Rights Reserved. - The generated code is released under one of the following licenses: - GPL OR Genivia's license for commercial use. + Generated by gSOAP 2.8.10 from gsoap.stub + +Copyright(C) 2000-2012, Robert van Engelen, Genivia Inc. All Rights Reserved. +The generated code is released under one of the following licenses: +1) GPL or 2) Genivia's license for commercial use. +This program is released under the GPL with the additional exemption that +compiling, linking, and/or using OpenSSL is allowed. */ #ifndef soapH_H diff --git a/dep/gsoap/soapServer.cpp b/dep/gsoap/soapServer.cpp index 8c8206fb3ef..b6304a3e525 100644 --- a/dep/gsoap/soapServer.cpp +++ b/dep/gsoap/soapServer.cpp @@ -1,8 +1,11 @@ /* soapServer.cpp - Generated by gSOAP 2.8.2 from stub.h - Copyright(C) 2000-2011, Robert van Engelen, Genivia Inc. All Rights Reserved. - The generated code is released under one of the following licenses: - GPL OR Genivia's license for commercial use. + Generated by gSOAP 2.8.10 from gsoap.stub + +Copyright(C) 2000-2012, Robert van Engelen, Genivia Inc. All Rights Reserved. +The generated code is released under one of the following licenses: +1) GPL or 2) Genivia's license for commercial use. +This program is released under the GPL with the additional exemption that +compiling, linking, and/or using OpenSSL is allowed. */ #if defined(__BORLANDC__) @@ -11,7 +14,7 @@ #endif #include "soapH.h" -SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.8.2 2011-04-26 21:49:07 GMT") +SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.8.10 2012-09-02 20:48:00 GMT") SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap) @@ -67,6 +70,7 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve_ns1__executeCommand(struct soap *soap) soap_tmp_string = NULL; soap_tmp_ns1__executeCommandResponse.result = &soap_tmp_string; soap_default_ns1__executeCommand(soap, &soap_tmp_ns1__executeCommand); + soap->encodingStyle = NULL; if (!soap_get_ns1__executeCommand(soap, &soap_tmp_ns1__executeCommand, "ns1:executeCommand", NULL)) return soap->error; if (soap_body_end_in(soap) diff --git a/dep/gsoap/soapStub.h b/dep/gsoap/soapStub.h index 85f3119b9ff..fbdd170e0f4 100644 --- a/dep/gsoap/soapStub.h +++ b/dep/gsoap/soapStub.h @@ -1,13 +1,20 @@ /* soapStub.h - Generated by gSOAP 2.8.2 from stub.h - Copyright(C) 2000-2011, Robert van Engelen, Genivia Inc. All Rights Reserved. - The generated code is released under one of the following licenses: - GPL OR Genivia's license for commercial use. + Generated by gSOAP 2.8.10 from gsoap.stub + +Copyright(C) 2000-2012, Robert van Engelen, Genivia Inc. All Rights Reserved. +The generated code is released under one of the following licenses: +1) GPL or 2) Genivia's license for commercial use. +This program is released under the GPL with the additional exemption that +compiling, linking, and/or using OpenSSL is allowed. */ #ifndef soapStub_H #define soapStub_H #include "stdsoap2.h" +#if GSOAP_VERSION != 20810 +# error "GSOAP VERSION MISMATCH IN GENERATED CODE: PLEASE REINSTALL PACKAGE" +#endif + /******************************************************************************\ * * diff --git a/dep/gsoap/stdsoap2.cpp b/dep/gsoap/stdsoap2.cpp index ed0922d86f2..36a8901dcab 100644 --- a/dep/gsoap/stdsoap2.cpp +++ b/dep/gsoap/stdsoap2.cpp @@ -1,17 +1,17 @@ /* - stdsoap2.c[pp] 2.8.2 + stdsoap2.c[pp] 2.8.10 gSOAP runtime engine gSOAP XML Web services tools -Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2012, Robert van Engelen, Genivia Inc., All Rights Reserved. This part of the software is released under ONE of the following licenses: GPL, or the gSOAP public license, or Genivia's license for commercial use. -------------------------------------------------------------------------------- Contributors: Wind River Systems Inc., for the following additions under gSOAP public license: - - vxWorks compatible + - vxWorks compatible options -------------------------------------------------------------------------------- gSOAP public license. @@ -24,7 +24,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2012, Robert van Engelen, Genivia Inc., All Rights Reserved. -------------------------------------------------------------------------------- GPL license. @@ -49,25 +49,18 @@ compiling, linking, and/or using OpenSSL is allowed. -------------------------------------------------------------------------------- A commercial use license is available from Genivia, Inc., contact@genivia.com -------------------------------------------------------------------------------- - -Installation note: - -Win32 build needs "ws2_32.lib" -To do this in Visual C++ 6.0, go to "Project", "settings", select the "Link" -tab (the project file needs to be selected in the file view) and add -"ws2_32.lib" to the "Object/library modules" entry - -On Mac OS X with gcc (GCC) 3.1 20020420 (prerelease) you MUST compile with --fstack_check when using -O2 because gcc 3.1 has a bug that smashes the stack -when locally allocated data exceeds 64K. - */ +#define GSOAP_LIB_VERSION 20810 + #ifdef AS400 # pragma convert(819) /* EBCDIC to ASCII */ #endif #include "stdsoap2.h" +#if GSOAP_VERSION != GSOAP_LIB_VERSION +# error "GSOAP VERSION MISMATCH IN LIBRARY: PLEASE REINSTALL PACKAGE" +#endif #ifdef __BORLANDC__ # pragma warn -8060 @@ -83,10 +76,10 @@ when locally allocated data exceeds 64K. #endif #ifdef __cplusplus -SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.8.2 2011-04-17 00:00:00 GMT") +SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.8.10 2012-08-16 00:00:00 GMT") extern "C" { #else -SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.8.2 2011-04-17 00:00:00 GMT") +SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.8.10 2012-08-16 00:00:00 GMT") #endif /* 8bit character representing unknown/nonrepresentable character data (e.g. not supported by current locale with multibyte support enabled) */ @@ -101,7 +94,7 @@ SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.8.2 2011-04-17 00:00:00 GMT") #define SOAP_QT (soap_wchar)(-5) /* XML-specific '"' */ #define SOAP_AP (soap_wchar)(-6) /* XML-specific ''' */ -#define soap_blank(c) ((c) >= 0 && (c) <= 32) +#define soap_blank(c) ((c)+1 > 0 && (c) <= 32) #define soap_notblank(c) ((c) > 32) #if defined(WIN32) && !defined(UNDER_CE) @@ -138,8 +131,10 @@ static int soap_isxdigit(int); static void *fplugin(struct soap*, const char*); static size_t soap_count_attachments(struct soap *soap); static int soap_try_connect_command(struct soap*, int http_command, const char *endpoint, const char *action); +#ifdef WITH_NTLM +static int soap_ntlm_handshake(struct soap *soap, int command, const char *endpoint, const char *host, int port); +#endif #ifndef WITH_NOIDREF -static void soap_update_ptrs(struct soap*, char*, char*, char*, char*); static int soap_has_copies(struct soap*, const char*, const char*); static void soap_init_iht(struct soap*); static void soap_free_iht(struct soap*); @@ -152,7 +147,7 @@ static void soap_free_pht(struct soap*); static const char *soap_set_validation_fault(struct soap*, const char*, const char*); static int soap_isnumeric(struct soap*, const char*); static struct soap_nlist *soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized); -static void soap_utilize_ns(struct soap *soap, const char *tag, size_t n); +static void soap_utilize_ns(struct soap *soap, const char *tag); #endif #ifndef WITH_LEANER @@ -208,9 +203,9 @@ static const char *soap_decode(char*, size_t, const char*, const char*); #ifndef PALM_1 static soap_wchar soap_getchunkchar(struct soap*); static const char *http_error(struct soap*, int); -static int http_put(struct soap*); static int http_get(struct soap*); static int http_405(struct soap*); +static int http_200(struct soap*); static int http_post(struct soap*, const char*, const char*, int, const char*, const char*, size_t); static int http_send_header(struct soap*, const char*); static int http_post_header(struct soap*, const char*, const char*); @@ -538,6 +533,7 @@ extern int h_errno; static int fsend(struct soap *soap, const char *s, size_t n) { register int nwritten, err; + SOAP_SOCKET sk; #if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) if (soap->os) { soap->os->write(s, (std::streamsize)n); @@ -547,23 +543,26 @@ fsend(struct soap *soap, const char *s, size_t n) return SOAP_EOF; } #endif + sk = soap->sendsk; + if (!soap_valid_socket(sk)) + sk = soap->socket; while (n) - { if (soap_valid_socket(soap->socket)) + { if (soap_valid_socket(sk)) { if (soap->send_timeout) { for (;;) { register int r; #ifdef WITH_OPENSSL if (soap->ssl) - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ALL, soap->send_timeout); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_ALL, soap->send_timeout); else #endif #ifdef WITH_GNUTLS if (soap->session) - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ALL, soap->send_timeout); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_ALL, soap->send_timeout); else #endif - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout); if (r > 0) break; if (!r) @@ -590,25 +589,25 @@ fsend(struct soap *soap, const char *s, size_t n) #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) { if (soap->peerlen) - nwritten = sendto(soap->socket, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen); + nwritten = sendto(sk, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen); else - nwritten = send(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags); + nwritten = send(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags); /* retry and back-off algorithm */ /* TODO: this is not very clear from specs so verify and limit conditions under which we should loop (e.g. ENOBUFS) */ if (nwritten < 0) { int udp_repeat; int udp_delay; if ((soap->connect_flags & SO_BROADCAST)) - udp_repeat = 3; /* SOAP-over-UDP MULTICAST_UDP_REPEAT - 1 */ + udp_repeat = 2; /* SOAP-over-UDP MULTICAST_UDP_REPEAT - 1 */ else udp_repeat = 1; /* SOAP-over-UDP UNICAST_UDP_REPEAT - 1 */ udp_delay = ((unsigned int)soap_random % 201) + 50; /* UDP_MIN_DELAY .. UDP_MAX_DELAY */ do - { tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ERR, -1000 * udp_delay); + { tcp_select(soap, sk, SOAP_TCP_SELECT_ERR, -1000 * udp_delay); if (soap->peerlen) - nwritten = sendto(soap->socket, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen); + nwritten = sendto(sk, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen); else - nwritten = send(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags); + nwritten = send(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags); udp_delay <<= 1; if (udp_delay > 500) /* UDP_UPPER_DELAY */ udp_delay = 500; @@ -619,14 +618,14 @@ fsend(struct soap *soap, const char *s, size_t n) else #endif #if !defined(PALM) && !defined(AS400) - nwritten = send(soap->socket, s, (int)n, soap->socket_flags); + nwritten = send(sk, s, (int)n, soap->socket_flags); #else - nwritten = send(soap->socket, (void*)s, n, soap->socket_flags); + nwritten = send(sk, (void*)s, n, soap->socket_flags); #endif if (nwritten <= 0) { register int r = 0; - err = soap_socket_errno(soap->socket); + err = soap_socket_errno(sk); #ifdef WITH_OPENSSL if (soap->ssl && (r = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && r != SSL_ERROR_WANT_READ && r != SSL_ERROR_WANT_WRITE) { soap->errnum = err; @@ -645,14 +644,14 @@ fsend(struct soap *soap, const char *s, size_t n) { #if defined(WITH_OPENSSL) if (soap->ssl && r == SSL_ERROR_WANT_READ) - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000); else #elif defined(WITH_GNUTLS) if (soap->session && !gnutls_record_get_direction(soap->session)) - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000); else #endif - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000); if (!r && soap->send_timeout) return SOAP_EOF; if (r < 0 && soap->errnum != SOAP_EINTR) @@ -775,7 +774,7 @@ soap_flush(struct soap *soap) do { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating %u bytes\n", soap->d_stream->avail_in)); if (deflate(soap->d_stream, Z_NO_FLUSH) != Z_OK) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS)); return soap->error = SOAP_ZLIB_ERROR; } if (!soap->d_stream->avail_out) @@ -870,6 +869,7 @@ static size_t frecv(struct soap *soap, char *s, size_t n) { register int r; register int retries = 100; /* max 100 retries with non-blocking sockets */ + SOAP_SOCKET sk; soap->errnum = 0; #if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) if (soap->is) @@ -878,7 +878,10 @@ frecv(struct soap *soap, char *s, size_t n) return 0; } #endif - if (soap_valid_socket(soap->socket)) + sk = soap->recvsk; + if (!soap_valid_socket(sk)) + sk = soap->socket; + if (soap_valid_socket(sk)) { for (;;) { #ifdef WITH_OPENSSL @@ -890,7 +893,7 @@ frecv(struct soap *soap, char *s, size_t n) if (soap->recv_timeout) #endif { for (;;) - { r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout); + { r = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout); if (r > 0) break; if (!r) @@ -930,7 +933,7 @@ frecv(struct soap *soap, char *s, size_t n) if ((soap->omode & SOAP_IO_UDP)) { SOAP_SOCKLEN_T k = (SOAP_SOCKLEN_T)sizeof(soap->peer); memset((void*)&soap->peer, 0, sizeof(soap->peer)); - r = recvfrom(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, &k); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ + r = recvfrom(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, &k); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ soap->peerlen = (size_t)k; #ifndef WITH_IPV6 soap->ip = ntohl(soap->peer.sin_addr.s_addr); @@ -938,13 +941,13 @@ frecv(struct soap *soap, char *s, size_t n) } else #endif - r = recv(soap->socket, s, (int)n, soap->socket_flags); + r = recv(sk, s, (int)n, soap->socket_flags); #ifdef PALM /* CycleSyncDisplay(curStatusMsg); */ #endif if (r >= 0) return (size_t)r; - r = soap_socket_errno(soap->socket); + r = soap_socket_errno(sk); if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK) { soap->errnum = r; return 0; @@ -952,14 +955,14 @@ frecv(struct soap *soap, char *s, size_t n) } #if defined(WITH_OPENSSL) if (soap->ssl && err == SSL_ERROR_WANT_WRITE) - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); else #elif defined(WITH_GNUTLS) if (soap->session && gnutls_record_get_direction(soap->session)) - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); else #endif - r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); if (!r && soap->recv_timeout) return 0; if (r < 0) @@ -970,7 +973,7 @@ frecv(struct soap *soap, char *s, size_t n) if (retries-- <= 0) return 0; #ifdef PALM - r = soap_socket_errno(soap->socket); + r = soap_socket_errno(sk); if (r != SOAP_EINTR && retries-- <= 0) { soap->errnum = r; return 0; @@ -1076,10 +1079,9 @@ soap_recv_raw(struct soap *soap) } } else if (r != Z_BUF_ERROR) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS)); soap->d_stream->next_out = Z_NULL; - soap->error = SOAP_ZLIB_ERROR; - return EOF; + return soap->error = SOAP_ZLIB_ERROR; } } zlib_again: @@ -1110,7 +1112,9 @@ zlib_again: DBGMSG(RECV, soap->buf, ret); soap->bufidx = 0; if (!ret) - return soap->ahead = EOF; + { soap->ahead = EOF; + return EOF; + } } else soap->bufidx = soap->buflen; @@ -1118,7 +1122,9 @@ zlib_again: DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (idx=%u len=%u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen)); while (!soap_isxdigit((int)(c = soap_getchunkchar(soap)))) { if ((int)c == EOF) - return soap->ahead = EOF; + { soap->ahead = EOF; + return EOF; + } } do *t++ = (char)c; @@ -1126,7 +1132,9 @@ zlib_again: while ((int)c != EOF && c != '\n') c = soap_getchunkchar(soap); if ((int)c == EOF) - return soap->ahead = EOF; + { soap->ahead = EOF; + return EOF; + } *t = '\0'; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunk size = %s (hex)\n", tmp)); soap->chunksize = (size_t)soap_strtoul(tmp, &t, 16); @@ -1194,10 +1202,9 @@ zlib_again: #endif } else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS)); soap->d_stream->next_out = Z_NULL; - soap->error = SOAP_ZLIB_ERROR; - return EOF; + return soap->error = SOAP_ZLIB_ERROR; } } #endif @@ -1283,19 +1290,22 @@ soap_recv(struct soap *soap) } } while (soap->ffilterrecv) - { int err = soap->filterstop; - if (err) + { int err, last = soap->filterstop; + if (last) soap->bufidx = soap->buflen = 0; - else - err = soap_recv_raw(soap); /* do not call again after EOF */ - if ((soap->error = soap->ffilterrecv(soap, soap->buf, &soap->buflen, sizeof(soap->buf)))) - return soap->error; + if ((err = soap->ffilterrecv(soap, soap->buf, &soap->buflen, sizeof(soap->buf)))) + return soap->error = err; if (soap->buflen) - { soap->filterstop = err; + { soap->bufidx = 0; + soap->filterstop = last; return SOAP_OK; } - if (err) - return err; + if (last) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Returning postponed error %d\n", last)); + soap->filterstop = SOAP_OK; + return last; + } + soap->filterstop = soap_recv_raw(soap); /* do not call again after EOF */ } #endif return soap_recv_raw(soap); @@ -1505,7 +1515,7 @@ soap_get(struct soap *soap) { c = soap_get0(soap); if (c == '>') { soap->cdata = 0; - soap_get1(soap); + c = soap_get1(soap); c = soap_get1(soap); } else @@ -1702,12 +1712,11 @@ SOAP_FMAC2 soap_getutf8(struct soap *soap) { register soap_wchar c, c1, c2, c3, c4; c = soap->ahead; - if (c > 0x7F) - { soap->ahead = 0; - return c; - } - c = soap_get(soap); - if (c < 0x80 || (soap->mode & SOAP_ENC_LATIN)) + if (c) + soap->ahead = 0; + else + c = soap_get(soap); + if (c < 0x80 || c > 0xFF || (soap->mode & SOAP_ENC_LATIN)) return c; c1 = soap_get1(soap); if (c1 < 0x80) @@ -1896,7 +1905,7 @@ SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_getbase64(struct soap *soap, int *n, int malloc_flag) -{ +{ (void)malloc_flag; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) { soap->dom->data = soap_string_in(soap, 0, -1, -1); @@ -1921,6 +1930,8 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) register int j = 0; do { register soap_wchar c = soap_get(soap); + if (c < SOAP_AP) + c &= 0x7FFFFFFF; if (c == '=' || c < 0) { unsigned char *p; switch (j) @@ -2037,14 +2048,13 @@ SOAP_FMAC2 soap_xop_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options) { /* Check MTOM xop:Include element (within hex/base64Binary) */ /* TODO: this code to be obsoleted with new import/xop.h conventions */ - int body = soap->body; /* should save type too? */ + short body = soap->body; /* should save type too? */ if (!soap_peek_element(soap)) { if (!soap_element_begin_in(soap, "xop:Include", 0, NULL)) - { if (soap_dime_forward(soap, ptr, size, id, type, options)) + { if (soap_dime_forward(soap, ptr, size, id, type, options) + || (soap->body && soap_element_end_in(soap, "xop:Include"))) return soap->error; } - if (soap->body && soap_element_end_in(soap, NULL)) - return soap->error; } soap->body = body; return SOAP_OK; @@ -2176,11 +2186,14 @@ soap_pop_block(struct soap *soap, struct soap_blist *b) #endif /******************************************************************************/ -#ifndef WITH_NOIDREF #ifndef PALM_1 -static void -soap_update_ptrs(struct soap *soap, char *start, char *end, char *p1, char *p2) -{ int i; +SOAP_FMAC1 +void +SOAP_FMAC2 +soap_update_pointers(struct soap *soap, char *start, char *end, char *p1, char *p2) +{ +#ifndef WITH_NOIDREF + int i; register struct soap_ilist *ip = NULL; register struct soap_flist *fp = NULL; #ifndef WITH_LEANER @@ -2218,7 +2231,7 @@ soap_update_ptrs(struct soap *soap, char *start, char *end, char *p1, char *p2) #ifndef WITH_LEANER for (xp = soap->xlist; xp; xp = xp->next) { if (xp->ptr && (char*)xp->ptr >= start && (char*)xp->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", xp->id?xp->id:SOAP_STR_EOS, xp->ptr, (char*)xp->ptr + (p1-p2))); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", xp->id ? xp->id : SOAP_STR_EOS, xp->ptr, (char*)xp->ptr + (p1-p2))); xp->ptr = (unsigned char**)((char*)xp->ptr + (p1-p2)); xp->size = (int*)((char*)xp->size + (p1-p2)); xp->type = (char**)((char*)xp->type + (p1-p2)); @@ -2226,8 +2239,10 @@ soap_update_ptrs(struct soap *soap, char *start, char *end, char *p1, char *p2) } } #endif -} +#else + (void)soap; (void)start; (void)end; (void)p1; (void)p2; #endif +} #endif /******************************************************************************/ @@ -2469,11 +2484,11 @@ soap_save_block(struct soap *soap, struct soap_blist *b, char *p, int flag) if (p) { for (s = p, q = soap_first_block(soap, b); q; q = soap_next_block(soap, b)) { n = soap_block_size(soap, b); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); #ifndef WITH_NOIDREF if (flag) - soap_update_ptrs(soap, q, q + n, s, q); + soap_update_pointers(soap, q, q + n, s, q); #endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); memcpy(s, q, n); s += n; } @@ -2701,12 +2716,7 @@ soap_push_namespace(struct soap *soap, const char *id, const char *ns) if (p) { for (i = 0; p->id; p++, i++) { if (p->ns && !strcmp(ns, p->ns)) - { if (p->out) - { SOAP_FREE(soap, p->out); - p->out = NULL; - } break; - } if (p->out) { if (!strcmp(ns, p->out)) break; @@ -2733,10 +2743,10 @@ soap_push_namespace(struct soap *soap, const char *id, const char *ns) soap->nlist = np; np->level = soap->level; np->index = i; - strcpy(np->id, id); + strcpy((char*)np->id, id); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); if (i < 0) - { np->ns = strcpy(np->id + n + 1, ns); + { np->ns = strcpy((char*)np->id + n + 1, ns); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); } else @@ -3067,6 +3077,7 @@ soap_ssl_init() #ifdef WITH_OPENSSL SSL_library_init(); OpenSSL_add_all_algorithms(); /* 2.8.1 change (wsseapi.c) */ + OpenSSL_add_all_digests(); #ifndef WITH_LEAN SSL_load_error_strings(); #endif @@ -3122,7 +3133,11 @@ soap_ssl_error(struct soap *soap, int ret) strcpy(soap->msgbuf, "EOF was observed that violates the protocol. The client probably provided invalid authentication information."); break; case -1: +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Error observed by underlying BIO: %s", strerror(errno)); +#else sprintf(soap->msgbuf, "Error observed by underlying BIO: %s", strerror(errno)); +#endif break; } } @@ -3333,12 +3348,22 @@ ssl_verify_callback(int ok, X509_STORE_CTX *store) #ifdef SOAP_DEBUG if (!ok) { char buf[1024]; + int err = X509_STORE_CTX_get_error(store); X509 *cert = X509_STORE_CTX_get_current_cert(store); - fprintf(stderr, "SSL verify error or warning with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(X509_STORE_CTX_get_error(store))); + fprintf(stderr, "SSL verify error or warning with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(err)); X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)); fprintf(stderr, "certificate issuer %s\n", buf); X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)); fprintf(stderr, "certificate subject %s\n", buf); + /* accept self signed certificates and certificates out of date */ + switch (err) + { case X509_V_ERR_CERT_NOT_YET_VALID: + case X509_V_ERR_CERT_HAS_EXPIRED: + case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: + case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: + X509_STORE_CTX_set_error(store, X509_V_OK); + ok = 1; + } } #endif /* Note: return 1 to continue, but unsafe progress will be terminated by OpenSSL */ @@ -3353,13 +3378,16 @@ ssl_verify_callback(int ok, X509_STORE_CTX *store) static int ssl_verify_callback_allow_expired_certificate(int ok, X509_STORE_CTX *store) { ok = ssl_verify_callback(ok, store); - if (ok == 0 && X509_STORE_CTX_get_error(store) == X509_V_ERR_CERT_HAS_EXPIRED) - { -#ifdef SOAP_DEBUG - fprintf(stderr, "ignoring certificate expiration\n"); -#endif - X509_STORE_CTX_set_error(store, X509_V_OK); - ok = 1; + if (!ok) + { /* accept self signed certificates and certificates out of date */ + switch (X509_STORE_CTX_get_error(store)) + { case X509_V_ERR_CERT_NOT_YET_VALID: + case X509_V_ERR_CERT_HAS_EXPIRED: + case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: + case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: + X509_STORE_CTX_set_error(store, X509_V_OK); + ok = 1; + } } /* Note: return 1 to continue, but unsafe progress will be terminated by SSL */ return ok; @@ -3414,11 +3442,11 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_accept(struct soap *soap) -{ SOAP_SOCKET fd = soap->socket; +{ SOAP_SOCKET sk = soap->socket; #ifdef WITH_OPENSSL BIO *bio; int retries, r, s; - if (!soap_valid_socket(fd)) + if (!soap_valid_socket(sk)) return soap_set_receiver_error(soap, "SSL/TLS error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); soap->ssl_flags &= ~SOAP_SSL_CLIENT; if (!soap->ctx && (soap->error = soap->fsslauth(soap))) @@ -3430,12 +3458,12 @@ soap_ssl_accept(struct soap *soap) } else SSL_clear(soap->ssl); - bio = BIO_new_socket((int)fd, BIO_NOCLOSE); + bio = BIO_new_socket((int)sk, BIO_NOCLOSE); SSL_set_bio(soap->ssl, bio, bio); /* Set SSL sockets to non-blocking */ retries = 0; if (soap->accept_timeout) - { SOAP_SOCKNONBLOCK(fd) + { SOAP_SOCKNONBLOCK(sk) retries = 10*soap->accept_timeout; } if (retries <= 0) @@ -3447,14 +3475,14 @@ soap_ssl_accept(struct soap *soap) err = SSL_get_error(soap->ssl, r); if (err == SSL_ERROR_WANT_ACCEPT || err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) { if (err == SSL_ERROR_WANT_READ) - s = tcp_select(soap, fd, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); else - s = tcp_select(soap, fd, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); if (s < 0 && soap->errnum != SOAP_EINTR) break; } else - { soap->errnum = soap_socket_errno(fd); + { soap->errnum = soap_socket_errno(sk); break; } } @@ -3480,17 +3508,17 @@ soap_ssl_accept(struct soap *soap) #endif #ifdef WITH_GNUTLS int retries = 0, r; - if (!soap_valid_socket(fd)) + if (!soap_valid_socket(sk)) return soap_set_receiver_error(soap, "SSL/TLS error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); soap->ssl_flags &= ~SOAP_SSL_CLIENT; if (!soap->session && (soap->error = soap->fsslauth(soap))) { soap_closesock(soap); return soap->error; } - gnutls_transport_set_ptr(soap->session, (gnutls_transport_ptr_t)(long)fd); + gnutls_transport_set_ptr(soap->session, (gnutls_transport_ptr_t)(long)sk); /* Set SSL sockets to non-blocking */ if (soap->accept_timeout) - { SOAP_SOCKNONBLOCK(fd) + { SOAP_SOCKNONBLOCK(sk) retries = 10*soap->accept_timeout; } if (retries <= 0) @@ -3502,14 +3530,14 @@ soap_ssl_accept(struct soap *soap) break; if (r == GNUTLS_E_AGAIN || r == GNUTLS_E_INTERRUPTED) { if (!gnutls_record_get_direction(soap->session)) - s = tcp_select(soap, fd, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); else - s = tcp_select(soap, fd, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); if (s < 0 && soap->errnum != SOAP_EINTR) break; } else - { soap->errnum = soap_socket_errno(fd); + { soap->errnum = soap_socket_errno(sk); break; } } @@ -3526,9 +3554,9 @@ soap_ssl_accept(struct soap *soap) } #endif if (soap->recv_timeout || soap->send_timeout) - SOAP_SOCKNONBLOCK(fd) + SOAP_SOCKNONBLOCK(sk) else - SOAP_SOCKBLOCK(fd) + SOAP_SOCKBLOCK(sk) soap->imode |= SOAP_ENC_SSL; soap->omode |= SOAP_ENC_SSL; return SOAP_OK; @@ -3672,7 +3700,7 @@ tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) #ifdef WITH_IPV6 struct addrinfo hints, *res, *ressave; #endif - SOAP_SOCKET fd; + SOAP_SOCKET sk; int err = 0; #ifndef WITH_LEAN #ifndef WIN32 @@ -3714,7 +3742,7 @@ tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) } ressave = res; again: - fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + sk = socket(res->ai_family, res->ai_socktype, res->ai_protocol); soap->errmode = 0; #else #ifndef WITH_LEAN @@ -3722,12 +3750,12 @@ again: #endif #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) - fd = socket(AF_INET, SOCK_DGRAM, 0); + sk = socket(AF_INET, SOCK_DGRAM, 0); else #endif - fd = socket(AF_INET, SOCK_STREAM, 0); + sk = socket(AF_INET, SOCK_STREAM, 0); #endif - if (!soap_valid_socket(fd)) + if (!soap_valid_socket(sk)) { #ifdef WITH_IPV6 if (res->ai_next) @@ -3735,7 +3763,7 @@ again: goto again; } #endif - soap->errnum = soap_socket_errno(fd); + soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "socket failed in tcp_connect()", SOAP_TCP_ERROR); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -3745,10 +3773,10 @@ again: #ifdef SOCKET_CLOSE_ON_EXEC #ifdef WIN32 #ifndef UNDER_CE - SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0); + SetHandleInformation((HANDLE)sk, HANDLE_FLAG_INHERIT, 0); #endif #else - fcntl(fd, F_SETFD, 1); + fcntl(sk, F_SETFD, 1); #endif #endif #ifndef WITH_LEAN @@ -3757,57 +3785,57 @@ again: memset((void*)&linger, 0, sizeof(linger)); linger.l_onoff = 1; linger.l_linger = soap->linger_time; - if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno(fd); + if (setsockopt(sk, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } } - else if (soap->connect_flags && setsockopt(fd, SOL_SOCKET, soap->connect_flags, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + else if (soap->connect_flags && setsockopt(sk, SOL_SOCKET, soap->connect_flags, (char*)&set, sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } - if ((soap->keep_alive || soap->tcp_keep_alive) && setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if ((soap->keep_alive || soap->tcp_keep_alive) && setsockopt(sk, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } - if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if (setsockopt(sk, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } - if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if (setsockopt(sk, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } #ifdef TCP_KEEPIDLE - if (soap->tcp_keep_idle && setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_KEEPIDLE, (char*)&(soap->tcp_keep_idle), sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if (soap->tcp_keep_idle && setsockopt((SOAP_SOCKET)sk, IPPROTO_TCP, TCP_KEEPIDLE, (char*)&(soap->tcp_keep_idle), sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPIDLE failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); + soap->fclosesocket(soap, (SOAP_SOCKET)sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3815,10 +3843,10 @@ again: } #endif #ifdef TCP_KEEPINTVL - if (soap->tcp_keep_intvl && setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_KEEPINTVL, (char*)&(soap->tcp_keep_intvl), sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if (soap->tcp_keep_intvl && setsockopt((SOAP_SOCKET)sk, IPPROTO_TCP, TCP_KEEPINTVL, (char*)&(soap->tcp_keep_intvl), sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPINTVL failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); + soap->fclosesocket(soap, (SOAP_SOCKET)sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3826,10 +3854,10 @@ again: } #endif #ifdef TCP_KEEPCNT - if (soap->tcp_keep_cnt && setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_KEEPCNT, (char*)&(soap->tcp_keep_cnt), sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if (soap->tcp_keep_cnt && setsockopt((SOAP_SOCKET)sk, IPPROTO_TCP, TCP_KEEPCNT, (char*)&(soap->tcp_keep_cnt), sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPCNT failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); + soap->fclosesocket(soap, (SOAP_SOCKET)sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3837,10 +3865,10 @@ again: } #endif #ifdef TCP_NODELAY - if (!(soap->omode & SOAP_IO_UDP) && setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno(fd); + if (!(soap->omode & SOAP_IO_UDP) && setsockopt(sk, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3857,29 +3885,29 @@ again: if ((soap->omode & SOAP_IO_UDP)) { if (soap->ipv4_multicast_ttl) { unsigned char ttl = soap->ipv4_multicast_ttl; - if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ttl, sizeof(ttl))) - { soap->errnum = soap_socket_errno(fd); + if (setsockopt(sk, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ttl, sizeof(ttl))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_TTL failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } } if ((soap->omode & SOAP_IO_UDP) && soap->ipv4_multicast_if && !soap->ipv6_multicast_if) - { if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr))) + { if (setsockopt(sk, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr))) #ifndef WINDOWS - { soap->errnum = soap_socket_errno(fd); + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } #else #ifndef IP_MULTICAST_IF #define IP_MULTICAST_IF 2 #endif - if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr))) - { soap->errnum = soap_socket_errno(fd); + if (setsockopt(sk, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr))) + { soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } #endif @@ -3887,7 +3915,7 @@ again: } #endif #endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Opening socket %d to host='%s' port=%d\n", fd, host, port)); + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Opening socket %d to host='%s' port=%d\n", sk, host, port)); #ifndef WITH_IPV6 soap->peerlen = sizeof(soap->peer); memset((void*)&soap->peer, 0, sizeof(soap->peer)); @@ -3896,7 +3924,7 @@ again: if (soap->proxy_host) { if (soap->fresolve(soap, soap->proxy_host, &soap->peer.sin_addr)) { soap_set_sender_error(soap, tcp_error(soap), "get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } soap->peer.sin_port = htons((short)soap->proxy_port); @@ -3904,7 +3932,7 @@ again: else { if (soap->fresolve(soap, host, &soap->peer.sin_addr)) { soap_set_sender_error(soap, tcp_error(soap), "get host by name failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } soap->peer.sin_port = htons((short)port); @@ -3912,34 +3940,34 @@ again: soap->errmode = 0; #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) - return fd; + return sk; #endif #else if ((soap->omode & SOAP_IO_UDP)) { memcpy(&soap->peer, res->ai_addr, res->ai_addrlen); soap->peerlen = res->ai_addrlen; freeaddrinfo(ressave); - return fd; + return sk; } #endif #ifndef WITH_LEAN if (soap->connect_timeout) - SOAP_SOCKNONBLOCK(fd) + SOAP_SOCKNONBLOCK(sk) else - SOAP_SOCKBLOCK(fd) + SOAP_SOCKBLOCK(sk) retries = 10; #endif for (;;) { #ifdef WITH_IPV6 - if (connect(fd, res->ai_addr, (int)res->ai_addrlen)) + if (connect(sk, res->ai_addr, (int)res->ai_addrlen)) #else - if (connect(fd, (struct sockaddr*)&soap->peer, sizeof(soap->peer))) + if (connect(sk, (struct sockaddr*)&soap->peer, sizeof(soap->peer))) #endif - { err = soap_socket_errno(fd); + { err = soap_socket_errno(sk); #ifndef WITH_LEAN if (err == SOAP_EADDRINUSE) - { soap->fclosesocket(soap, fd); + { soap->fclosesocket(soap, sk); if (retries-- > 0) goto again; } @@ -3948,13 +3976,13 @@ again: SOAP_SOCKLEN_T k; for (;;) { register int r; - r = tcp_select(soap, fd, SOAP_TCP_SELECT_SND, soap->connect_timeout); + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND, soap->connect_timeout); if (r > 0) break; if (!r) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); soap_set_sender_error(soap, "Timeout", "connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3964,7 +3992,7 @@ again: if (r != SOAP_EINTR) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3972,13 +4000,13 @@ again: } } k = (SOAP_SOCKLEN_T)sizeof(soap->errnum); - if (!getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &k) && !soap->errnum) /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ + if (!getsockopt(sk, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &k) && !soap->errnum) /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ break; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); if (!soap->errnum) - soap->errnum = soap_socket_errno(fd); + soap->errnum = soap_socket_errno(sk); soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -3988,7 +4016,7 @@ again: #ifdef WITH_IPV6 if (res->ai_next) { res = res->ai_next; - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); goto again; } #endif @@ -3996,7 +4024,7 @@ again: { soap->errnum = err; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif @@ -4010,7 +4038,7 @@ again: soap->peerlen = 0; /* IPv6: already connected so use send() */ freeaddrinfo(ressave); #endif - soap->socket = fd; + soap->socket = sk; soap->imode &= ~SOAP_ENC_SSL; soap->omode &= ~SOAP_ENC_SSL; if (!soap_tag_cmp(endpoint, "https:*")) @@ -4025,46 +4053,45 @@ again: soap_mode om = soap->omode; /* make sure we only parse HTTP */ size_t n = soap->count; /* save the content length */ const char *userid, *passwd; + int status = soap->status; /* save the current status/command */ + short keep_alive = soap->keep_alive; /* save the KA status */ soap->omode &= ~SOAP_ENC; /* mask IO and ENC */ soap->omode |= SOAP_IO_BUFFER; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connecting to %s proxy server\n", soap->proxy_http_version)); - sprintf(soap->tmpbuf, "CONNECT %s:%d HTTP/%s", host, port, soap->proxy_http_version); - if (soap_begin_send(soap) - || (soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - { soap->fclosesocket(soap, fd); - return SOAP_INVALID_SOCKET; - } -#ifndef WITH_LEAN - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - { soap->fclosesocket(soap, fd); +#ifdef WITH_NTLM + if (soap->ntlm_challenge) + { if (soap_ntlm_handshake(soap, SOAP_CONNECT, endpoint, host, port)) return soap->error; - } } #endif - if ((soap->error = soap->fposthdr(soap, NULL, NULL)) - || soap_flush(soap)) - { soap->fclosesocket(soap, fd); + if (soap_begin_send(soap)) + { soap->fclosesocket(soap, sk); + return SOAP_INVALID_SOCKET; + } + soap->status = SOAP_CONNECT; + soap->keep_alive = 1; + if ((soap->error = soap->fpost(soap, endpoint, host, port, NULL, NULL, 0)) + || soap_end_send(soap)) + { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } + soap->keep_alive = keep_alive; soap->omode = om; om = soap->imode; soap->imode &= ~SOAP_ENC; /* mask IO and ENC */ userid = soap->userid; /* preserve */ passwd = soap->passwd; /* preserve */ if ((soap->error = soap->fparse(soap))) - { soap->fclosesocket(soap, fd); + { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } + soap->status = status; /* restore */ soap->userid = userid; /* restore */ soap->passwd = passwd; /* restore */ soap->imode = om; /* restore */ soap->count = n; /* restore */ if (soap_begin_send(soap)) - { soap->fclosesocket(soap, fd); + { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } if (endpoint) @@ -4074,13 +4101,15 @@ again: #ifdef WITH_OPENSSL soap->ssl_flags |= SOAP_SSL_CLIENT; if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - { soap->fclosesocket(soap, fd); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL required, but no ctx set\n")); + soap->fclosesocket(soap, sk); + soap->error = SOAP_SSL_ERROR; return SOAP_INVALID_SOCKET; } if (!soap->ssl) { soap->ssl = SSL_new(soap->ctx); if (!soap->ssl) - { soap->fclosesocket(soap, fd); + { soap->fclosesocket(soap, sk); soap->error = SOAP_SSL_ERROR; return SOAP_INVALID_SOCKET; } @@ -4095,16 +4124,16 @@ again: } soap->imode |= SOAP_ENC_SSL; soap->omode |= SOAP_ENC_SSL; - bio = BIO_new_socket((int)fd, BIO_NOCLOSE); + bio = BIO_new_socket((int)sk, BIO_NOCLOSE); SSL_set_bio(soap->ssl, bio, bio); /* Connect timeout: set SSL sockets to non-blocking */ retries = 0; if (soap->connect_timeout) - { SOAP_SOCKNONBLOCK(fd) + { SOAP_SOCKNONBLOCK(sk) retries = 10*soap->connect_timeout; } else - SOAP_SOCKBLOCK(fd) + SOAP_SOCKBLOCK(sk) if (retries <= 0) retries = 100; /* timeout: 10 sec retries, 100 times 0.1 sec */ /* Try connecting until success or timeout (when nonblocking) */ @@ -4114,37 +4143,37 @@ again: if (err == SSL_ERROR_WANT_CONNECT || err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) { register int s; if (err == SSL_ERROR_WANT_READ) - s = tcp_select(soap, fd, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); else - s = tcp_select(soap, fd, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); if (s < 0 && soap->errnum != SOAP_EINTR) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL_connect/select error in tcp_connect\n")); soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } if (s == 0 && retries-- <= 0) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL/TLS connect timeout\n")); soap_set_sender_error(soap, "Timeout", "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } } else { soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL_connect error in tcp_connect()", SOAP_SSL_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } } } while (!SSL_is_init_finished(soap->ssl)); /* Set SSL sockets to nonblocking */ - SOAP_SOCKNONBLOCK(fd) + SOAP_SOCKNONBLOCK(sk) /* Check server credentials when required */ if ((soap->ssl_flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION)) { int err; if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK) { soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL/TLS certificate presented by peer cannot be verified in tcp_connect()", SOAP_SSL_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } if (!(soap->ssl_flags & SOAP_SSL_SKIP_HOST_CHECK)) @@ -4155,7 +4184,7 @@ again: peer = SSL_get_peer_certificate(soap->ssl); if (!peer) { soap_set_sender_error(soap, "SSL/TLS error", "No SSL/TLS certificate was presented by the peer in tcp_connect()", SOAP_SSL_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } ext_count = X509_get_ext_count(peer); @@ -4249,7 +4278,7 @@ again: X509_free(peer); if (!ok) { soap_set_sender_error(soap, "SSL/TLS error", "SSL/TLS certificate host name mismatch in tcp_connect()", SOAP_SSL_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } } @@ -4258,17 +4287,17 @@ again: #ifdef WITH_GNUTLS soap->ssl_flags |= SOAP_SSL_CLIENT; if (!soap->session && (soap->error = soap->fsslauth(soap))) - { soap->fclosesocket(soap, fd); + { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } - gnutls_transport_set_ptr(soap->session, (gnutls_transport_ptr_t)(long)fd); + gnutls_transport_set_ptr(soap->session, (gnutls_transport_ptr_t)(long)sk); /* Set SSL sockets to non-blocking */ if (soap->connect_timeout) - { SOAP_SOCKNONBLOCK(fd) + { SOAP_SOCKNONBLOCK(sk) retries = 10*soap->connect_timeout; } else - SOAP_SOCKBLOCK(fd) + SOAP_SOCKBLOCK(sk) if (retries <= 0) retries = 100; /* timeout: 10 sec retries, 100 times 0.1 sec */ while ((r = gnutls_handshake(soap->session))) @@ -4278,42 +4307,42 @@ again: break; if (r == GNUTLS_E_AGAIN || r == GNUTLS_E_INTERRUPTED) { if (!gnutls_record_get_direction(soap->session)) - s = tcp_select(soap, fd, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); else - s = tcp_select(soap, fd, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); + s = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); if (s < 0 && soap->errnum != SOAP_EINTR) break; } else - { soap->errnum = soap_socket_errno(fd); + { soap->errnum = soap_socket_errno(sk); break; } } if (r) { soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL/TLS handshake failed", SOAP_SSL_ERROR); - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } if ((soap->ssl_flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION)) { const char *err = ssl_verify(soap, host); if (err) - { soap->fclosesocket(soap, fd); + { soap->fclosesocket(soap, sk); soap->error = soap_set_sender_error(soap, "SSL/TLS error", err, SOAP_SSL_ERROR); return SOAP_INVALID_SOCKET; } } #endif #else - soap->fclosesocket(soap, fd); + soap->fclosesocket(soap, sk); soap->error = SOAP_SSL_ERROR; return SOAP_INVALID_SOCKET; #endif } if (soap->recv_timeout || soap->send_timeout) - SOAP_SOCKNONBLOCK(fd) + SOAP_SOCKNONBLOCK(sk) else - SOAP_SOCKBLOCK(fd) - return fd; + SOAP_SOCKBLOCK(sk) + return sk; } #endif #endif @@ -4322,7 +4351,7 @@ again: #ifndef WITH_NOIO #ifndef PALM_1 static int -tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout) +tcp_select(struct soap *soap, SOAP_SOCKET sk, int flags, int timeout) { register int r; struct timeval tv; fd_set fd[3], *rfd, *sfd, *efd; @@ -4333,12 +4362,12 @@ tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout) if (1) #else /* if fd max set size exceeded, use poll() */ - if ((int)s >= (int)FD_SETSIZE) + if ((int)sk >= (int)FD_SETSIZE) #endif #ifdef HAVE_POLL { struct pollfd pollfd; int retries = 0; - pollfd.fd = (int)s; + pollfd.fd = (int)sk; pollfd.events = 0; if (flags & SOAP_TCP_SELECT_RCV) pollfd.events |= POLLIN; @@ -4379,17 +4408,17 @@ tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout) if (flags & SOAP_TCP_SELECT_RCV) { rfd = &fd[0]; FD_ZERO(rfd); - FD_SET(s, rfd); + FD_SET(sk, rfd); } if (flags & SOAP_TCP_SELECT_SND) { sfd = &fd[1]; FD_ZERO(sfd); - FD_SET(s, sfd); + FD_SET(sk, sfd); } if (flags & SOAP_TCP_SELECT_ERR) { efd = &fd[2]; FD_ZERO(efd); - FD_SET(s, efd); + FD_SET(sk, efd); } if (timeout >= 0) { tv.tv_sec = timeout; @@ -4399,14 +4428,14 @@ tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout) { tv.tv_sec = -timeout / 1000000; tv.tv_usec = -timeout % 1000000; } - r = select((int)s + 1, rfd, sfd, efd, &tv); + r = select((int)sk + 1, rfd, sfd, efd, &tv); if (r > 0) { r = 0; - if ((flags & SOAP_TCP_SELECT_RCV) && FD_ISSET(s, rfd)) + if ((flags & SOAP_TCP_SELECT_RCV) && FD_ISSET(sk, rfd)) r |= SOAP_TCP_SELECT_RCV; - if ((flags & SOAP_TCP_SELECT_SND) && FD_ISSET(s, sfd)) + if ((flags & SOAP_TCP_SELECT_SND) && FD_ISSET(sk, sfd)) r |= SOAP_TCP_SELECT_SND; - if ((flags & SOAP_TCP_SELECT_ERR) && FD_ISSET(s, efd)) + if ((flags & SOAP_TCP_SELECT_ERR) && FD_ISSET(sk, efd)) r |= SOAP_TCP_SELECT_ERR; } else if (r < 0) @@ -4421,18 +4450,19 @@ tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout) #ifndef PALM_1 static SOAP_SOCKET tcp_accept(struct soap *soap, SOAP_SOCKET s, struct sockaddr *a, int *n) -{ SOAP_SOCKET fd; - fd = accept(s, a, (SOAP_SOCKLEN_T*)n); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ +{ SOAP_SOCKET sk; + (void)soap; + sk = accept(s, a, (SOAP_SOCKLEN_T*)n); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ #ifdef SOCKET_CLOSE_ON_EXEC #ifdef WIN32 #ifndef UNDER_CE - SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0); + SetHandleInformation((HANDLE)sk, HANDLE_FLAG_INHERIT, 0); #endif #else - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(sk, F_SETFD, FD_CLOEXEC); #endif #endif - return fd; + return sk; } #endif #endif @@ -4533,9 +4563,10 @@ tcp_disconnect(struct soap *soap) #ifndef WITH_NOIO #ifndef PALM_1 static int -tcp_closesocket(struct soap *soap, SOAP_SOCKET fd) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Close socket %d\n", (int)fd)); - return soap_closesocket(fd); +tcp_closesocket(struct soap *soap, SOAP_SOCKET sk) +{ (void)soap; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Close socket %d\n", (int)sk)); + return soap_closesocket(sk); } #endif #endif @@ -4544,9 +4575,10 @@ tcp_closesocket(struct soap *soap, SOAP_SOCKET fd) #ifndef WITH_NOIO #ifndef PALM_1 static int -tcp_shutdownsocket(struct soap *soap, SOAP_SOCKET fd, int how) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Shutdown socket %d how=%d\n", (int)fd, how)); - return shutdown(fd, how); +tcp_shutdownsocket(struct soap *soap, SOAP_SOCKET sk, int how) +{ (void)soap; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Shutdown socket %d how=%d\n", (int)sk, how)); + return shutdown(sk, how); } #endif #endif @@ -4569,7 +4601,7 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) #endif #endif #ifndef WITH_LEAN -#ifndef WITH_WIN32 +#ifndef WIN32 int len = SOAP_BUFLEN; #else int len = SOAP_BUFLEN + 1; /* speeds up windows xfer */ @@ -4623,6 +4655,7 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) soap_set_receiver_error(soap, tcp_error(soap), "socket failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } + soap->port = port; #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) soap->socket = soap->master; @@ -4642,7 +4675,7 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } - if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) + if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && (!((soap->imode | soap->omode) & SOAP_IO_UDP)) && setsockopt(soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; @@ -4669,14 +4702,14 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) #ifdef WITH_IPV6_V6ONLY if (setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt set IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } #endif #ifdef WITH_NO_IPV6_V6ONLY if (setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&unset, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt unset IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } #endif @@ -4784,8 +4817,9 @@ SOAP_SOCKET SOAP_FMAC2 soap_accept(struct soap *soap) { int n = (int)sizeof(soap->peer); + register int err; #ifndef WITH_LEAN -#ifndef WITH_WIN32 +#ifndef WIN32 int len = SOAP_BUFLEN; #else int len = SOAP_BUFLEN + 1; /* speeds up windows xfer */ @@ -4793,124 +4827,123 @@ soap_accept(struct soap *soap) int set = 1; #endif soap->error = SOAP_OK; -#ifndef WITH_LEAN - if ((soap->omode & SOAP_IO_UDP)) - return soap->socket = soap->master; -#endif memset((void*)&soap->peer, 0, sizeof(soap->peer)); soap->socket = SOAP_INVALID_SOCKET; soap->errmode = 0; soap->keep_alive = 0; - if (soap_valid_socket(soap->master)) - { register int err; - for (;;) - { if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout) - { for (;;) - { register int r; - r = tcp_select(soap, soap->master, SOAP_TCP_SELECT_ALL, soap->accept_timeout ? soap->accept_timeout : 60); - if (r > 0) - break; - if (!r && soap->accept_timeout) - { soap_set_receiver_error(soap, "Timeout", "accept failed in soap_accept()", SOAP_TCP_ERROR); + if (!soap_valid_socket(soap->master)) + { soap->errnum = 0; + soap_set_receiver_error(soap, tcp_error(soap), "no master socket in soap_accept()", SOAP_TCP_ERROR); + return SOAP_INVALID_SOCKET; + } +#ifndef WITH_LEAN + if ((soap->omode & SOAP_IO_UDP)) + return soap->socket = soap->master; +#endif + for (;;) + { if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout) + { for (;;) + { register int r; + r = tcp_select(soap, soap->master, SOAP_TCP_SELECT_ALL, soap->accept_timeout ? soap->accept_timeout : 60); + if (r > 0) + break; + if (!r && soap->accept_timeout) + { soap_set_receiver_error(soap, "Timeout", "accept failed in soap_accept()", SOAP_TCP_ERROR); + return SOAP_INVALID_SOCKET; + } + if (r < 0) + { r = soap->errnum; + if (r != SOAP_EINTR) + { soap_closesock(soap); + soap_set_sender_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } - if (r < 0) - { r = soap->errnum; - if (r != SOAP_EINTR) - { soap_closesock(soap); - soap_set_sender_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); - return SOAP_INVALID_SOCKET; - } - } } } - if (soap->accept_timeout) - SOAP_SOCKNONBLOCK(soap->master) - else - SOAP_SOCKBLOCK(soap->master) - soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&soap->peer, &n); - soap->peerlen = (size_t)n; - if (soap_valid_socket(soap->socket)) - { + } + if (soap->accept_timeout) + SOAP_SOCKNONBLOCK(soap->master) + else + SOAP_SOCKBLOCK(soap->master) + soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&soap->peer, &n); + soap->peerlen = (size_t)n; + if (soap_valid_socket(soap->socket)) + { #ifdef WITH_IPV6 -/* Use soap->host to store the numeric form of the remote host */ - getnameinfo((struct sockaddr*)&soap->peer, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d from %s\n", soap->socket, soap->host)); - soap->ip = 0; /* info stored in soap->peer and soap->host */ - soap->port = 0; /* info stored in soap->peer and soap->host */ + unsigned int ip1, ip2, ip3, ip4; + char port[16]; + getnameinfo((struct sockaddr*)&soap->peer, n, soap->host, sizeof(soap->host), port, 16, NI_NUMERICHOST | NI_NUMERICSERV); + sscanf(soap->host, "%u.%u.%u.%u", &ip1, &ip2, &ip3, &ip4); + soap->ip = (unsigned long)ip1 << 24 | (unsigned long)ip2 << 16 | (unsigned long)ip3 << 8 | (unsigned long)ip4; + soap->port = soap_strtol(port, NULL, 10); #else - soap->ip = ntohl(soap->peer.sin_addr.s_addr); - soap->port = (int)ntohs(soap->peer.sin_port); /* does not return port number on some systems */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d at port %d from IP %d.%d.%d.%d\n", soap->socket, soap->port, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF)); + soap->ip = ntohl(soap->peer.sin_addr.s_addr); + sprintf(soap->host, "%u.%u.%u.%u", (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); + soap->port = (int)ntohs(soap->peer.sin_port); /* does not return port number on some systems */ #endif + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d at port %d from IP %s\n", soap->socket, soap->port, soap->host)); #ifndef WITH_LEAN - if (soap->accept_flags == SO_LINGER) - { struct linger linger; - memset((void*)&linger, 0, sizeof(linger)); - linger.l_onoff = 1; - linger.l_linger = soap->linger_time; - if (setsockopt(soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno(soap->socket); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR); - soap_closesock(soap); - return SOAP_INVALID_SOCKET; - } - } - else if (soap->accept_flags && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags, (char*)&set, sizeof(int))) + if (soap->accept_flags == SO_LINGER) + { struct linger linger; + memset((void*)&linger, 0, sizeof(linger)); + linger.l_onoff = 1; + linger.l_linger = soap->linger_time; + if (setsockopt(soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) { soap->errnum = soap_socket_errno(soap->socket); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_accept()", SOAP_TCP_ERROR); - soap_closesock(soap); - return SOAP_INVALID_SOCKET; - } - if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno(soap->socket); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); - soap_closesock(soap); - return SOAP_INVALID_SOCKET; - } - if (setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno(soap->socket); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); - soap_closesock(soap); - return SOAP_INVALID_SOCKET; - } - if (setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno(soap->socket); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); return SOAP_INVALID_SOCKET; } + } + else if (soap->accept_flags && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags, (char*)&set, sizeof(int))) + { soap->errnum = soap_socket_errno(soap->socket); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_accept()", SOAP_TCP_ERROR); + soap_closesock(soap); + return SOAP_INVALID_SOCKET; + } + if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) + { soap->errnum = soap_socket_errno(soap->socket); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); + soap_closesock(soap); + return SOAP_INVALID_SOCKET; + } + if (setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) + { soap->errnum = soap_socket_errno(soap->socket); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); + soap_closesock(soap); + return SOAP_INVALID_SOCKET; + } + if (setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) + { soap->errnum = soap_socket_errno(soap->socket); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); + soap_closesock(soap); + return SOAP_INVALID_SOCKET; + } #ifdef TCP_NODELAY - if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno(soap->socket); - soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR); - soap_closesock(soap); - return SOAP_INVALID_SOCKET; - } -#endif -#endif - soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); - if (soap->send_timeout || soap->recv_timeout) - SOAP_SOCKNONBLOCK(soap->socket) - else - SOAP_SOCKBLOCK(soap->socket) - return soap->socket; - } - err = soap_socket_errno(soap->socket); - if (err != 0 && err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host)); - soap->errnum = err; - soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); + if (setsockopt(soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) + { soap->errnum = soap_socket_errno(soap->socket); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); return SOAP_INVALID_SOCKET; } +#endif +#endif + soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); + if (soap->send_timeout || soap->recv_timeout) + SOAP_SOCKNONBLOCK(soap->socket) + else + SOAP_SOCKBLOCK(soap->socket) + return soap->socket; + } + err = soap_socket_errno(soap->socket); + if (err != 0 && err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK) + { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host)); + soap->errnum = err; + soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); + soap_closesock(soap); + return SOAP_INVALID_SOCKET; } } - else - { soap->errnum = 0; - soap_set_receiver_error(soap, tcp_error(soap), "no master socket in soap_accept()", SOAP_TCP_ERROR); - return SOAP_INVALID_SOCKET; - } } #endif #endif @@ -4949,6 +4982,19 @@ soap_closesock(struct soap *soap) #endif /******************************************************************************/ +#ifndef PALM_1 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_force_closesock(struct soap *soap) +{ soap->keep_alive = 0; + if (soap_valid_socket(soap->socket)) + return soap_closesocket(soap->socket); + return SOAP_OK; +} +#endif + +/******************************************************************************/ #ifndef WITH_NOIO #ifndef PALM_2 SOAP_FMAC1 @@ -5004,11 +5050,11 @@ soap_done(struct soap *soap) soap->fmalloc = NULL; #ifndef WITH_NOHTTP soap->fpost = http_post; - soap->fput = http_put; soap->fget = http_get; + soap->fput = http_405; soap->fdel = http_405; - soap->fopt = http_405; - soap->fhead = http_405; + soap->fopt = http_200; + soap->fhead = http_200; soap->fform = NULL; soap->fposthdr = http_post_header; soap->fresponse = http_response; @@ -5106,7 +5152,11 @@ soap_done(struct soap *soap) } #endif #ifdef WITH_C_LOCALE +# ifdef WIN32 + _free_locale(soap->c_locale); +# else freelocale(soap->c_locale); +# endif #endif #ifdef WITH_ZLIB if (soap->d_stream) @@ -5147,16 +5197,24 @@ soap_done(struct soap *soap) int http_parse(struct soap *soap) { char header[SOAP_HDRLEN], *s; - unsigned short httpcmd = 0, status = 0; + unsigned short httpcmd = 0; + int status = 0; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for HTTP request/response...\n")); *soap->endpoint = '\0'; soap->length = 0; - soap->userid = NULL; - soap->passwd = NULL; - soap->action = NULL; - soap->authrealm = NULL; +#ifdef WITH_NTLM + if (!soap->ntlm_challenge) +#endif + { soap->userid = NULL; + soap->passwd = NULL; + soap->authrealm = NULL; + } +#ifdef WITH_NTLM + soap->ntlm_challenge = NULL; +#endif soap->proxy_from = NULL; soap->http_content = NULL; + soap->action = NULL; soap->status = 0; do { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) @@ -5245,6 +5303,8 @@ http_parse(struct soap *soap) n = sizeof(soap->endpoint) - 1; strncpy(soap->path, soap->msgbuf + l, n - m); soap->path[n - m] = '\0'; + if (*soap->path && *soap->path != '/') + *soap->endpoint = '\0'; strcat(soap->endpoint, soap->path); DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint)); if (httpcmd > 1) @@ -5277,7 +5337,7 @@ http_parse(struct soap *soap) may not have a body. When content length, content type, or chunking is used assume there is a message to parse, either XML or HTTP. */ - if (soap->length > 0 || (soap->http_content && soap->recv_timeout) || (soap->imode & SOAP_IO) == SOAP_IO_CHUNK) + if (soap->length > 0 || (soap->http_content && (!soap->keep_alive || soap->recv_timeout)) || (soap->imode & SOAP_IO) == SOAP_IO_CHUNK) { if ((soap->status > 200 && soap->status <= 299) || soap->status == 400 || soap->status == 500) @@ -5392,8 +5452,14 @@ http_parse_header(struct soap *soap, const char *key, const char *val) } } } - else if (!soap_tag_cmp(key, "WWW-Authenticate")) - { soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val + 6, "realm")); + else if (!soap_tag_cmp(key, "WWW-Authenticate") || !soap_tag_cmp(key, "Proxy-Authenticate")) + { +#ifdef WITH_NTLM + if (!soap_tag_cmp(val, "NTLM*")) + soap->ntlm_challenge = soap_strdup(soap, val + 4); + else +#endif + soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val + 6, "realm")); } else if (!soap_tag_cmp(key, "Expect")) { if (!soap_tag_cmp(val, "100-continue")) @@ -5522,6 +5588,7 @@ soap_decode(char *buf, size_t len, const char *val, const char *sep) static const char* http_error(struct soap *soap, int status) { register const char *msg = SOAP_STR_EOS; + (void)soap; #ifndef WITH_LEAN msg = soap_code_str(h_http_error_codes, status); if (!msg) @@ -5533,21 +5600,25 @@ http_error(struct soap *soap, int status) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int -http_put(struct soap *soap) -{ return http_parse(soap); +http_get(struct soap *soap) +{ (void)soap; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP GET request\n")); + return SOAP_GET_METHOD; } #endif #endif -/******************************************************************************/ +/******************************************************************************/ #ifndef WITH_NOHTTP #ifndef PALM_1 static int -http_get(struct soap *soap) -{ return SOAP_GET_METHOD; +http_405(struct soap *soap) +{ return 405; + (void)soap; } #endif #endif @@ -5556,8 +5627,8 @@ http_get(struct soap *soap) #ifndef WITH_NOHTTP #ifndef PALM_1 static int -http_405(struct soap *soap) -{ return 405; +http_200(struct soap *soap) +{ return soap_send_empty_response(soap, 200); } #endif #endif @@ -5569,10 +5640,23 @@ static int http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count) { register const char *s; register int err; - if (soap->status == SOAP_GET) - s = "GET"; - else - s = "POST"; + switch (soap->status) + { case SOAP_GET: + s = "GET"; + break; + case SOAP_PUT: + s = "PUT"; + break; + case SOAP_DEL: + s = "DELETE"; + break; + case SOAP_CONNECT: + s = "CONNECT"; + break; + default: + s = "POST"; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP %s to %s\n", s, endpoint ? endpoint : "(null)")); #ifdef PALM if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) #else @@ -5580,24 +5664,30 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c #endif return SOAP_OK; if (strlen(endpoint) + strlen(soap->http_version) > sizeof(soap->tmpbuf) - 80) - return soap->error = SOAP_EOM; - if (soap->proxy_host && soap_tag_cmp(endpoint, "https:*")) + return soap->error = SOAP_EOM; /* prevent overrun */ + if (soap->status == SOAP_CONNECT) + sprintf(soap->tmpbuf, "%s %s:%d HTTP/%s", s, soap->host, soap->port, soap->http_version); + else if (soap->proxy_host && endpoint) sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version); else sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, (*path == '/' ? path + 1 : path), soap->http_version); if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) return err; #ifdef WITH_OPENSSL - if ((soap->ssl && soap->port != 443) || (!soap->ssl && soap->port != 80)) - sprintf(soap->tmpbuf, "%s:%d", host, port); - else - strcpy(soap->tmpbuf, host); + if ((soap->ssl && port != 443) || (!soap->ssl && port != 80)) #else if (port != 80) - sprintf(soap->tmpbuf, "%s:%d", host, port); +#endif + { +#ifdef WITH_IPV6 + if (*host != '[' && strchr(host, ':')) + sprintf(soap->tmpbuf, "[%s]:%d", host, port); /* RFC 2732 */ + else +#endif + sprintf(soap->tmpbuf, "%s:%d", host, port); + } else strcpy(soap->tmpbuf, host); -#endif if ((err = soap->fposthdr(soap, "Host", soap->tmpbuf))) return err; if ((err = soap->fposthdr(soap, "User-Agent", "gSOAP/2.8"))) @@ -5614,16 +5704,30 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c #endif #ifndef WITH_LEAN if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); + { +#ifdef WITH_NTLM + if (soap->ntlm_challenge && strlen(soap->ntlm_challenge) + 6 < sizeof(soap->tmpbuf)) + sprintf(soap->tmpbuf, "NTLM %s", soap->ntlm_challenge); + else +#endif + { strcpy(soap->tmpbuf, "Basic "); + sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); + soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); + } if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) return err; } if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); + { +#ifdef WITH_NTLM + if (soap->ntlm_challenge && strlen(soap->ntlm_challenge) + 6 < sizeof(soap->tmpbuf)) + sprintf(soap->tmpbuf, "NTLM %s", soap->ntlm_challenge); + else +#endif + { strcpy(soap->tmpbuf, "Basic "); + sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); + soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); + } if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) return err; } @@ -5637,7 +5741,7 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c return soap->error; #endif #endif - if (soap->status != SOAP_GET && soap->version == 1) + if (action && soap->status != SOAP_GET && soap->status != SOAP_DEL) { sprintf(soap->tmpbuf, "\"%s\"", action && strlen(action) < sizeof(soap->tmpbuf) - 3 ? action : SOAP_STR_EOS); if ((err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf))) return err; @@ -5699,7 +5803,7 @@ http_response(struct soap *soap, int status, size_t count) if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK)) s = "200 OK"; else - s = "202 ACCEPTED"; + s = "202 Accepted"; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Status = %s\n", s)); #ifdef WMW_RPM_IO if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ @@ -5842,9 +5946,9 @@ soap_cookie(struct soap *soap, const char *name, const char *domain, const char path = SOAP_STR_EOS; else if (*path == '/') path++; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Search cookie %s domain=%s path=%s\n", name, domain?domain:"(null)", path?path:"(null)")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Search cookie %s domain=%s path=%s\n", name, domain ? domain : "(null)", path ? path : "(null)")); for (p = soap->cookies; p; p = p->next) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie in database: %s=%s domain=%s path=%s env=%hd\n", p->name, p->value?p->value:"(null)", p->domain?p->domain:"(null)", p->path?p->path:"(null)", p->env)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie in database: %s=%s domain=%s path=%s env=%hd\n", p->name, p->value ? p->value : "(null)", p->domain ? p->domain : "(null)", p->path ? p->path : "(null)", p->env)); if (!strcmp(p->name, name) && p->domain && p->path @@ -5871,7 +5975,7 @@ soap_set_cookie(struct soap *soap, const char *name, const char *value, const ch else if (*path == '/') path++; q = soap_cookie(soap, name, domain, path); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set %scookie: %s=%s domain=%s path=%s\n", q ? SOAP_STR_EOS : "new ", name, value?value:"(null)", domain?domain:"(null)", path?path:"(null)")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set %scookie: %s=%s domain=%s path=%s\n", q ? SOAP_STR_EOS : "new ", name, value ? value : "(null)", domain ? domain : "(null)", path ? path : "(null)")); if (!q) { if ((q = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie)))) { if ((q->name = (char*)SOAP_MALLOC(soap, strlen(name)+1))) @@ -5940,13 +6044,13 @@ soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const c if (!domain) domain = soap->cookie_domain; if (!domain) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error in clear cookie %s: cookie domain not set\n", name?name:"(null)")); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error in clear cookie %s: cookie domain not set\n", name ? name : "(null)")); return; } if (!path) path = soap->cookie_path; if (!path) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error in clear cookie %s: cookie path not set\n", name?name:"(null)")); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error in clear cookie %s: cookie path not set\n", name ? name : "(null)")); return; } if (*path == '/') @@ -6006,7 +6110,7 @@ int SOAP_FMAC2 soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path) { struct soap_cookie *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie expiration max-age %ld: %s domain=%s path=%s\n", expire, name, domain?domain:"(null)", path?path:"(null)")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie expiration max-age %ld: %s domain=%s path=%s\n", expire, name, domain ? domain : "(null)", path ? path : "(null)")); if ((p = soap_cookie(soap, name, domain, path))) { p->maxage = expire; p->modified = 1; @@ -6123,6 +6227,9 @@ soap_putcookies(struct soap *soap, const char *domain, const char *path, int sec unsigned int version = 0; time_t now = time(NULL); char *s, tmp[4096]; + if (!domain || !path) + return SOAP_OK; + s = tmp; p = &soap->cookies; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending cookies for domain=%s path=%s\n", domain, path)); if (*path == '/') @@ -6169,30 +6276,53 @@ soap_putcookies(struct soap *soap, const char *domain, const char *path, int sec if (flag && (!q->path || !strncmp(q->path, path, strlen(q->path))) && (!q->secure || secure)) - { s = tmp; + { size_t n = 12; + if (q->name) + n += 3*strlen(q->name); + if (q->value && *q->value) + n += 3*strlen(q->value) + 1; + if (q->path && *q->path) + n += strlen(q->path) + 9; + if (q->domain) + n += strlen(q->domain) + 11; + if (tmp - s + n > sizeof(tmp)) + { if (s == tmp) + return SOAP_OK; /* HTTP header size overflow */ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); + if ((soap->error = soap->fposthdr(soap, "Cookie", tmp))) + return soap->error; + s = tmp; + } + else if (s != tmp) + { strcat(s, " "); + s++; + } if (q->version != version) { sprintf(s, "$Version=%u;", q->version); version = q->version; + s += strlen(s); } if (q->name) - s += soap_encode_cookie(q->name, s, tmp-s+4080); + s += soap_encode_cookie(q->name, s, tmp+sizeof(tmp)-s-16); if (q->value && *q->value) { *s++ = '='; - s += soap_encode_cookie(q->value, s, tmp-s+4080); + s += soap_encode_cookie(q->value, s, tmp+sizeof(tmp)-s-16); } - if (q->path && *q->path && (int)strlen(q->path) < tmp-s+4080) + if (q->path) { sprintf(s, ";$Path=\"/%s\"", (*q->path == '/' ? q->path + 1 : q->path)); s += strlen(s); } - if (q->domain && (int)strlen(q->domain) < tmp-s+4080) - sprintf(s, ";$Domain=\"%s\"", q->domain); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); - if ((soap->error = soap->fposthdr(soap, "Cookie", tmp))) - return soap->error; + if (q->domain) + { sprintf(s, ";$Domain=\"%s\"", q->domain); + s += strlen(s); + } } p = &q->next; } } + if (s != tmp) + if ((soap->error = soap->fposthdr(soap, "Cookie", tmp))) + return soap->error; return SOAP_OK; } @@ -6322,7 +6452,7 @@ soap_getcookies(struct soap *soap, const char *val) p->secure = 1; else { if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"(null)", p->domain?p->domain:"(null)", p->path?p->path:"(null)", p->expire, p->secure)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value ? p->value : "(null)", p->domain ? p->domain : "(null)", p->path ? p->path : "(null)", p->expire, p->secure)); if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) { q->version = p->version; q->expire = p->expire; @@ -6374,7 +6504,7 @@ soap_getcookies(struct soap *soap, const char *val) } } if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"(null)", p->domain?p->domain:"(null)", p->path?p->path:"(null)", p->expire, p->secure)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value ? p->value : "(null)", p->domain ? p->domain : "(null)", p->path ? p->path : "(null)", p->expire, p->secure)); if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) { q->version = p->version; q->expire = p->expire; @@ -6506,30 +6636,10 @@ soap_init_pht(struct soap *soap) SOAP_FMAC1 struct soap* SOAP_FMAC2 -soap_new1(soap_mode mode) -{ return soap_new2(mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new() -{ return soap_new2(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new2(soap_mode imode, soap_mode omode) +soap_versioning(soap_new)(soap_mode imode, soap_mode omode) { struct soap *soap = (struct soap*)malloc(sizeof(struct soap)); if (soap) - soap_init2(soap, imode, omode); + soap_versioning(soap_init)(soap, imode, omode); return soap; } #endif @@ -6597,6 +6707,7 @@ soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, soap_set_embedded(soap, pp); } return i; + (void)soap; } #endif #endif @@ -6649,7 +6760,7 @@ soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, h = soap_hash_ptr(a->__ptr); else h = soap_hash_ptr(p); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%d dim=%d type=%d id=%d\n", p, a?a->__ptr:NULL, a?a->__size:0, n, type, soap->idnum+1)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%d dim=%d type=%d id=%d\n", p, a ? a->__ptr : NULL, a ? a->__size : 0, n, type, soap->idnum+1)); pp->next = soap->pht[h]; pp->type = type; pp->mark1 = 0; @@ -6659,6 +6770,7 @@ soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, soap->pht[h] = pp; pp->id = ++soap->idnum; return pp->id; + (void)n; } #endif #endif @@ -6747,6 +6859,7 @@ soap_begin_count(struct soap *soap) soap->encoding = 0; soap->part = SOAP_BEGIN; soap->event = 0; + soap->evlev = 0; soap->idnum = 0; soap_clr_attr(soap); soap_set_local_namespaces(soap); @@ -6829,7 +6942,7 @@ soap_begin_send(struct soap *soap) #ifdef WIN32 #ifndef UNDER_CE #ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ + if (!soap_valid_socket(soap->socket) && !soap->os) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ #ifdef __BORLANDC__ setmode(soap->sendfd, _O_BINARY); #else @@ -7084,7 +7197,7 @@ soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const int i; if (!p || !a->__ptr || (!aid && !atype)) return soap_element_id(soap, tag, id, p, a, n, type, t); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid?aid:SOAP_STR_EOS, id, atype?atype:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid ? aid : SOAP_STR_EOS, id, atype ? atype : SOAP_STR_EOS)); i = soap_array_pointer_lookup(soap, p, a, n, t, &pp); if (!i) { i = soap_pointer_enter(soap, p, a, n, t, &pp); @@ -7213,7 +7326,7 @@ soap_enter(struct soap *soap, const char *id) ip = (struct soap_ilist*)SOAP_MALLOC(soap, sizeof(struct soap_ilist) + strlen(id)); if (ip) { h = soap_hash(id); - strcpy(ip->id, id); + strcpy((char*)ip->id, id); ip->next = soap->iht[h]; soap->iht[h] = ip; } @@ -7400,13 +7513,16 @@ soap_dealloc(struct soap *soap, void *p) SOAP_FREE(soap, q); } /* we must assume these were deallocated: */ + soap->http_content = NULL; soap->action = NULL; soap->fault = NULL; soap->header = NULL; soap->userid = NULL; soap->passwd = NULL; soap->authrealm = NULL; - soap->http_content = NULL; +#ifdef WITH_NTLM + soap->ntlm_challenge = NULL; +#endif #ifndef WITH_LEANER soap_clr_mime(soap); #endif @@ -7537,32 +7653,33 @@ soap_link(struct soap *soap, void *p, int t, int n, int (*fdelete)(struct soap_c /******************************************************************************/ #ifndef PALM_2 SOAP_FMAC1 -void +int SOAP_FMAC2 soap_unlink(struct soap *soap, const void *p) { register char **q; register struct soap_clist **cp; - if (!soap || !p) - return; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); + if (soap && p) + { for (q = (char**)&soap->alist; *q; q = *(char***)q) + { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) + { *q = **(char***)q; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); #ifdef SOAP_MEM_DEBUG - soap_track_unlink(soap, p); + soap_track_unlink(soap, p); #endif - return; + return SOAP_OK; /* found and removed from dealloc chain */ + } } - } - for (cp = &soap->clist; *cp; cp = &(*cp)->next) - { if (p == (*cp)->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p)); - q = (char**)*cp; - *cp = (*cp)->next; - SOAP_FREE(soap, q); - return; + for (cp = &soap->clist; *cp; cp = &(*cp)->next) + { if (p == (*cp)->ptr) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p)); + q = (char**)*cp; + *cp = (*cp)->next; + SOAP_FREE(soap, q); + return SOAP_OK; /* found and removed from dealloc chain */ + } } } + return SOAP_ERR; } #endif @@ -7802,6 +7919,7 @@ SOAP_FMAC2 soap_fcopy(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Copying data type=%d (target type=%d) %p -> %p (%lu bytes)\n", st, tt, q, p, (unsigned long)n)); memcpy(p, q, n); + (void)soap; (void)st; (void)tt; (void)len; } #endif @@ -7867,7 +7985,7 @@ soap_end_send(struct soap *soap) soap->mode &= ~SOAP_ENC_ZLIB; soap->zlib_state = SOAP_ZLIB_NONE; if (deflateEnd(soap->d_stream) != Z_OK || r != Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS)); return soap->error = SOAP_ZLIB_ERROR; } #ifdef WITH_GZIP @@ -8004,7 +8122,7 @@ soap_end_recv(struct soap *soap) for (i = 0; i < 8; i++) { if ((int)(c = soap_get1(soap)) == EOF) { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: unable to read crc value\n")); - return soap->error = SOAP_EOF; + return soap->error = SOAP_ZLIB_ERROR; } soap->z_buf[i] = (char)c; } @@ -8232,6 +8350,7 @@ soap_copy_context(struct soap *copy, const struct soap *soap) return NULL; if (copy) { register struct soap_plugin *p = NULL; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying context\n")); #ifdef __cplusplus *copy = *soap; #else @@ -8241,6 +8360,9 @@ soap_copy_context(struct soap *copy, const struct soap *soap) copy->error = SOAP_OK; copy->userid = NULL; copy->passwd = NULL; +#ifdef WITH_NTLM + copy->ntlm_challenge = NULL; +#endif copy->nlist = NULL; copy->blist = NULL; copy->clist = NULL; @@ -8260,8 +8382,18 @@ soap_copy_context(struct soap *copy, const struct soap *soap) soap_set_sent_logfile(copy, soap->logfile[SOAP_INDEX_SENT]); soap_set_recv_logfile(copy, soap->logfile[SOAP_INDEX_RECV]); #endif + copy->namespaces = NULL; + copy->local_namespaces = NULL; + if (soap->local_namespaces) + soap_set_namespaces(copy, soap->local_namespaces); + else + soap_set_namespaces(copy, soap->namespaces); #ifdef WITH_C_LOCALE +# ifdef WIN32 + copy->c_locale = _create_locale(LC_ALL, "C"); +# else copy->c_locale = duplocale(soap->c_locale); +# endif #else copy->c_locale = NULL; #endif @@ -8326,7 +8458,10 @@ soap_copy_stream(struct soap *copy, struct soap *soap) copy->mode = soap->mode; copy->imode = soap->imode; copy->omode = soap->omode; + copy->master = soap->master; copy->socket = soap->socket; + copy->sendsk = soap->sendsk; + copy->recvsk = soap->recvsk; copy->recv_timeout = soap->recv_timeout; copy->send_timeout = soap->send_timeout; #if defined(__cplusplus) && !defined(WITH_LEAN) @@ -8350,23 +8485,27 @@ soap_copy_stream(struct soap *copy, struct soap *soap) #ifndef WITH_NOIO copy->peer = soap->peer; copy->peerlen = soap->peerlen; + copy->ip = soap->ip; + copy->port = soap->port; + memcpy(copy->host, soap->host, sizeof(soap->host)); + memcpy(copy->endpoint, soap->endpoint, sizeof(soap->endpoint)); #endif #ifdef WITH_OPENSSL - copy->bio = NULL; - copy->ctx = NULL; - copy->ssl = NULL; - if (soap->ssl) - copy->ssl = SSL_dup(soap->ssl); + copy->bio = soap->bio; + copy->ctx = soap->ctx; + copy->ssl = soap->ssl; #endif #ifdef WITH_GNUTLS - copy->session = soap->session; /* TODO: Oops, GNUTLS provides a dup? */ + copy->session = soap->session; #endif #ifdef WITH_ZLIB copy->zlib_state = soap->zlib_state; copy->zlib_in = soap->zlib_in; copy->zlib_out = soap->zlib_out; - copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream)); - memcpy(copy->d_stream, soap->d_stream, sizeof(z_stream)); + if (!copy->d_stream) + copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream)); + if (copy->d_stream) + memcpy(copy->d_stream, soap->d_stream, sizeof(z_stream)); copy->z_crc = soap->z_crc; copy->z_ratio_in = soap->z_ratio_in; copy->z_ratio_out = soap->z_ratio_out; @@ -8375,7 +8514,8 @@ soap_copy_stream(struct soap *copy, struct soap *soap) copy->z_level = soap->z_level; if (soap->z_buf && soap->zlib_state != SOAP_ZLIB_NONE) { copy->z_buf = (char*)SOAP_MALLOC(copy, SOAP_BUFLEN); - memcpy(copy->z_buf, soap->z_buf, sizeof(soap->z_buf)); + if (copy->z_buf) + memcpy(copy->z_buf, soap->z_buf, SOAP_BUFLEN); } copy->z_dict = soap->z_dict; copy->z_dict_len = soap->z_dict_len; @@ -8411,10 +8551,18 @@ soap_copy_stream(struct soap *copy, struct soap *soap) SOAP_FREE(copy, nq); } } - copy->level = soap->level; + memcpy(copy->tag, soap->tag, sizeof(copy->tag)); + memcpy(copy->id, soap->id, sizeof(copy->id)); + memcpy(copy->href, soap->href, sizeof(copy->href)); + memcpy(copy->type, soap->type, sizeof(copy->type)); + copy->other = soap->other; + copy->root = soap->root; + copy->null = soap->null; copy->body = soap->body; + copy->part = soap->part; + copy->mustUnderstand = soap->mustUnderstand; + copy->level = soap->level; copy->peeked = soap->peeked; - memcpy(copy->tag, soap->tag, sizeof(copy->tag)); /* copy attributes */ for (tq = soap->attributes; tq; tq = tq->next) { struct soap_attribute *tr = tp; @@ -8440,24 +8588,22 @@ void SOAP_FMAC2 soap_free_stream(struct soap *soap) { soap->socket = SOAP_INVALID_SOCKET; + soap->sendsk = SOAP_INVALID_SOCKET; + soap->recvsk = SOAP_INVALID_SOCKET; #ifdef WITH_OPENSSL soap->bio = NULL; - if (soap->ssl) - SSL_free(soap->ssl); + soap->ctx = NULL; soap->ssl = NULL; #endif #ifdef WITH_GNUTLS soap->xcred = NULL; soap->acred = NULL; soap->cache = NULL; - soap->session = NULL; /* TODO: GNUTLS free here when dupped */ + soap->session = NULL; soap->dh_params = NULL; soap->rsa_params = NULL; #endif #ifdef WITH_ZLIB - if (soap->d_stream) - SOAP_FREE(soap, soap->d_stream); - soap->d_stream = NULL; if (soap->z_buf) SOAP_FREE(soap, soap->z_buf); soap->z_buf = NULL; @@ -8470,7 +8616,7 @@ soap_free_stream(struct soap *soap) SOAP_FMAC1 void SOAP_FMAC2 -soap_init(struct soap *soap) +soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) { size_t i; soap->state = SOAP_INIT; #ifdef SOAP_MEM_DEBUG @@ -8480,7 +8626,7 @@ soap_init(struct soap *soap) soap_init_logs(soap); #endif #ifdef SOAP_DEBUG -#ifdef TANDEM +#ifdef TANDEM_NONSTOP soap_set_test_logfile(soap, "TESTLOG"); soap_set_sent_logfile(soap, "SENTLOG"); soap_set_recv_logfile(soap, "RECVLOG"); @@ -8491,21 +8637,26 @@ soap_init(struct soap *soap) #endif #endif soap->version = 0; - soap_imode(soap, SOAP_IO_DEFAULT); - soap_omode(soap, SOAP_IO_DEFAULT); + soap_mode(soap, imode); + soap_imode(soap, imode); + soap_omode(soap, omode); soap->plugins = NULL; soap->user = NULL; for (i = 0; i < sizeof(soap->data)/sizeof(*soap->data); i++) soap->data[i] = NULL; soap->userid = NULL; soap->passwd = NULL; + soap->authrealm = NULL; +#ifdef WITH_NTLM + soap->ntlm_challenge = NULL; +#endif #ifndef WITH_NOHTTP soap->fpost = http_post; - soap->fput = http_put; soap->fget = http_get; + soap->fput = http_405; soap->fdel = http_405; - soap->fopt = http_405; - soap->fhead = http_405; + soap->fopt = http_200; + soap->fhead = http_200; soap->fform = NULL; soap->fposthdr = http_post_header; soap->fresponse = http_response; @@ -8611,6 +8762,8 @@ soap_init(struct soap *soap) soap->fault = NULL; soap->master = SOAP_INVALID_SOCKET; soap->socket = SOAP_INVALID_SOCKET; + soap->sendsk = SOAP_INVALID_SOCKET; + soap->recvsk = SOAP_INVALID_SOCKET; soap->os = NULL; soap->is = NULL; #ifndef WITH_LEANER @@ -8639,7 +8792,6 @@ soap_init(struct soap *soap) soap->proxy_port = 8080; soap->proxy_userid = NULL; soap->proxy_passwd = NULL; - soap->authrealm = NULL; soap->prolog = NULL; #ifdef WITH_ZLIB soap->zlib_state = SOAP_ZLIB_NONE; @@ -8709,7 +8861,11 @@ soap_init(struct soap *soap) soap->rsa_params = NULL; #endif #ifdef WITH_C_LOCALE +# ifdef WIN32 + soap->c_locale = _create_locale(LC_ALL, "C"); +# else soap->c_locale = newlocale(LC_ALL_MASK, "C", NULL); +# endif #else soap->c_locale = NULL; #endif @@ -8726,6 +8882,7 @@ soap_init(struct soap *soap) soap->ns = 0; soap->part = SOAP_END; soap->event = 0; + soap->evlev = 0; soap->alloced = 0; soap->count = 0; soap->length = 0; @@ -8740,28 +8897,6 @@ soap_init(struct soap *soap) #endif /******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init1(struct soap *soap, soap_mode mode) -{ soap_init2(soap, mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init2(struct soap *soap, soap_mode imode, soap_mode omode) -{ soap_init(soap); - soap_imode(soap, imode); - soap_omode(soap, omode); -} -#endif - -/******************************************************************************/ #ifndef PALM_2 SOAP_FMAC1 void @@ -8772,7 +8907,6 @@ soap_begin(struct soap *soap) { soap->buflen = 0; soap->bufidx = 0; } - soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); soap->null = 0; soap->position = 0; soap->encoding = 0; @@ -8781,6 +8915,7 @@ soap_begin(struct soap *soap) soap->ns = 0; soap->part = SOAP_END; soap->event = 0; + soap->evlev = 0; soap->alloced = 0; soap->count = 0; soap->length = 0; @@ -8903,6 +9038,8 @@ soap_set_local_namespaces(struct soap *soap) soap->version = 2; } soap->local_namespaces = ns2; + for (; ns2->id; ns2++) + ns2->out = NULL; } } } @@ -8976,7 +9113,7 @@ soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized) return NULL; } } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Adding namespace binding (level=%u) '%s' '%s' utilized=%d\n", soap->level, id, ns?ns:"(null)", utilized)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Adding namespace binding (level=%u) '%s' '%s' utilized=%d\n", soap->level, id, ns ? ns : "(null)", utilized)); n = strlen(id); if (ns) k = strlen(ns); @@ -8989,9 +9126,9 @@ soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized) } np->next = soap->nlist; soap->nlist = np; - strcpy(np->id, id); + strcpy((char*)np->id, id); if (ns) - np->ns = strcpy(np->id + n + 1, ns); + np->ns = strcpy((char*)np->id + n + 1, ns); else np->ns = NULL; np->level = soap->level; @@ -9003,8 +9140,13 @@ soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized) /******************************************************************************/ #ifndef WITH_LEAN static void -soap_utilize_ns(struct soap *soap, const char *tag, size_t n) -{ register struct soap_nlist *np = soap_lookup_ns(soap, tag, n); +soap_utilize_ns(struct soap *soap, const char *tag) +{ register struct soap_nlist *np; + size_t n = 0; + const char *t = strchr(tag, ':'); + if (t) + n = t - tag; + np = soap_lookup_ns(soap, tag, n); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Utilizing namespace of '%s'\n", tag)); if (np) { if (np->index == 0) @@ -9028,7 +9170,8 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) #ifndef WITH_LEAN register const char *s; #endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' id='%d' type='%s'\n", tag, id, type?type:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' level='%u' id='%d' type='%s'\n", tag, soap->level, id, type ? type : SOAP_STR_EOS)); + soap->level++; #ifdef WITH_DOM #ifndef WITH_LEAN if (soap->wsuid && soap_tagsearch(soap->wsuid, tag)) @@ -9039,12 +9182,20 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) if (soap_set_attr(soap, "wsu:Id", soap->tag, 1)) return soap->error; } - if (soap->event == SOAP_SEC_BEGIN && (soap->mode & SOAP_XML_CANONICAL) && !(soap->mode & SOAP_DOM_ASIS)) - { register struct soap_nlist *np; - /* wsu:Id found: clear xmlns renderings, so re-emit them for exc-c14n */ - for (np = soap->nlist; np; np = np->next) - { if (np->index == 2) - np->index = 0; + if ((soap->mode & SOAP_XML_CANONICAL) && !(soap->mode & SOAP_DOM_ASIS)) + { if (soap->evlev >= soap->level) + soap->evlev = 0; + if (soap->event == SOAP_SEC_BEGIN && !soap->evlev) + { register struct soap_nlist *np; + /* non-nested wsu:Id found: clear xmlns, re-emit them for exc-c14n */ + for (np = soap->nlist; np; np = np->next) + { if (np->index == 2) + { struct soap_nlist *np1 = soap_push_ns(soap, np->id, np->ns, 1); + if (np1) + np1->index = 0; + } + } + soap->evlev = soap->level; } } #endif @@ -9080,7 +9231,6 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) else { #endif - soap->level++; #ifndef WITH_LEAN if (!soap->ns) { if (!(soap->mode & SOAP_XML_CANONICAL) @@ -9135,26 +9285,30 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) soap->ns = 1; /* namespace table control: ns = 0 or 2 to start, then 1 to stop dumping the table */ #ifndef WITH_LEAN if (soap->mode & SOAP_XML_CANONICAL) - { const char *t = strchr(tag, ':'); - if (t) - soap_utilize_ns(soap, tag, t - tag); - } + soap_utilize_ns(soap, tag); #endif if (id > 0) { sprintf(soap->tmpbuf, "_%d", id); if (soap_attribute(soap, "id", soap->tmpbuf)) return soap->error; } - if (type && *type && soap->part != SOAP_IN_HEADER) /* TODO: filter Header? */ - { if (soap_attribute(soap, "xsi:type", type)) - return soap->error; + if (type && *type && !(soap->mode & SOAP_XML_NOTYPE) && soap->part != SOAP_IN_HEADER) + { const char *t = type; #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { const char *t = strchr(type, ':'); + if (soap->mode & SOAP_XML_DEFAULTNS) + { t = strchr(type, ':'); if (t) - soap_utilize_ns(soap, type, t - type); + t++; + else + t = type; } #endif + if (soap->attributes ? soap_set_attr(soap, "xsi:type", t, 1) : soap_attribute(soap, "xsi:type", t)) + return soap->error; +#ifndef WITH_LEAN + if (soap->mode & SOAP_XML_CANONICAL) + soap_utilize_ns(soap, type); +#endif } if (soap->null && soap->position > 0) { register int i; @@ -9189,8 +9343,8 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) } soap->null = 0; soap->position = 0; - if (soap->event == SOAP_SEC_BEGIN && (soap->mode & SOAP_XML_CANONICAL)) - soap->event = SOAP_SEC_SIGN; + if (soap->event == SOAP_SEC_BEGIN) + soap->event = 0; return SOAP_OK; } #endif @@ -9358,10 +9512,7 @@ soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *typ } #ifndef WITH_LEAN if ((soap->mode & SOAP_XML_CANONICAL)) - { const char *s = strchr(type, ':'); - if (s) - soap_utilize_ns(soap, type, s - type); - } + soap_utilize_ns(soap, type); #endif return soap_element_start_end_out(soap, NULL); } @@ -9379,14 +9530,11 @@ soap_element_start_end_out(struct soap *soap, const char *tag) { struct soap_nlist *np; for (tp = soap->attributes; tp; tp = tp->next) { if (tp->visible && tp->name) - { const char *s = strchr(tp->name, ':'); - if (s) - soap_utilize_ns(soap, tp->name, s - tp->name); - } + soap_utilize_ns(soap, tp->name); } for (np = soap->nlist; np; np = np->next) { if (np->index == 1 && np->ns) - { sprintf(soap->tmpbuf, "xmlns:%s", np->id); + { sprintf(soap->tmpbuf, *(np->id) ? "xmlns:%s" : "xmlns", np->id); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enabling utilized binding (level=%u) %s='%s'\n", np->level, soap->tmpbuf, np->ns)); soap_set_attr(soap, soap->tmpbuf, np->ns, 1); np->index = 2; @@ -9636,6 +9784,7 @@ soap_check_result(struct soap *soap, const char *tag) { soap_instring(soap, ":result", NULL, NULL, 0, 2, -1, -1); /* just ignore content for compliance reasons, but should compare tag to element's QName value? */ } + (void)tag; } #endif @@ -9664,16 +9813,9 @@ soap_attribute(struct soap *soap, const char *name, const char *value) #endif #ifndef WITH_LEAN if (soap->mode & SOAP_XML_CANONICAL) - { /* TODO: consider using this code to handle default namespace bindings + { /* push namespace */ if (!strncmp(name, "xmlns", 5) && (name[5] == ':' || name[5] == '\0')) - { if (name[5] == ':') - soap_push_ns(soap, name + 6, value, 0); - else - soap_push_ns(soap, "", value, 0); - } - */ - if (!strncmp(name, "xmlns:", 6)) - soap_push_ns(soap, name + 6, value, 0); + soap_push_ns(soap, name + 5 + (name[5] == ':'), value, 0); else if (soap_set_attr(soap, name, value, 1)) return soap->error; } @@ -9710,7 +9852,8 @@ soap_element_begin_in(struct soap *soap, const char *tag, int nillable, const ch return soap->error = SOAP_NULL; if (soap->body) soap->level++; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:SOAP_STR_EOS )); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag ? tag : SOAP_STR_EOS )); + soap->error = SOAP_OK; } } else if (soap->error == SOAP_NO_TAG && tag && *tag == '-') @@ -9749,7 +9892,7 @@ soap_element_end_in(struct soap *soap, const char *tag) do { while (((c = soap_get(soap)) != SOAP_TT)) { if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; if (c == SOAP_LT) n++; else if (c == '/') @@ -9769,7 +9912,7 @@ soap_element_end_in(struct soap *soap, const char *tag) } *s = '\0'; if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; while (soap_blank(c)) c = soap_get(soap); if (c != SOAP_GT) @@ -9784,12 +9927,12 @@ soap_element_end_in(struct soap *soap, const char *tag) if (tag && (soap->mode & SOAP_XML_STRICT)) { soap_pop_namespace(soap); if (soap_match_tag(soap, soap->tag, tag)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element tag '%s' does not match '%s'\n", soap->tag, tag?tag:SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element tag '%s' does not match '%s'\n", soap->tag, tag ? tag : SOAP_STR_EOS)); return soap->error = SOAP_SYNTAX_ERROR; } } #endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag ? tag : SOAP_STR_EOS)); soap->level--; return SOAP_OK; } @@ -9831,7 +9974,7 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) { register struct soap_attribute *tp; if (*name == '-') return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value?value:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value ? value : SOAP_STR_EOS)); for (tp = soap->attributes; tp; tp = tp->next) { if (!strcmp(tp->name, name)) break; @@ -9883,7 +10026,7 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) { tp->next = soap->attributes; soap->attributes = tp; } - strcpy(tp->name, name); + strcpy((char*)tp->name, name); tp->value = NULL; } else if (tp->visible) @@ -9906,9 +10049,9 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) if (!strncmp(tp->name, "xmlns:", 6)) tp->ns = tp->value; tp->visible = 2; - tp->flag = flag; + tp->flag = (short)flag; #ifndef WITH_LEAN - if (soap->event != SOAP_SEC_SIGN && !strcmp(name, "wsu:Id")) + if (!strcmp(name, "wsu:Id")) { soap->event = SOAP_SEC_BEGIN; strncpy(soap->id, value, sizeof(soap->id)); soap->id[sizeof(soap->id)-1] = '\0'; @@ -9996,7 +10139,7 @@ soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) } default: if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; *s++ = (char)c; } } @@ -10085,8 +10228,19 @@ soap_peek_element(struct soap *soap) soap->position = 0; soap->null = 0; soap->mustUnderstand = 0; - /* skip BOM */ - if ((c = soap_getchar(soap)) != 0xEF || (c = soap_get1(soap)) != 0xBB || (c = soap_get1(soap)) != 0xBF) + /* UTF-8 BOM? */ + c = soap_getchar(soap); + if (c == 0xEF && soap_get0(soap) == 0xBB) + { c = soap_get1(soap); + if ((c = soap_get1(soap)) == 0xBF) + soap->mode &= ~SOAP_ENC_LATIN; + else + soap_unget(soap, (0x0F << 12) | (0xBB << 6) | (c & 0x3F)); /* UTF-8 */ + } + else if ((c == 0xFE && soap_get0(soap) == 0xFF) /* UTF-16 BE */ + || (c == 0xFF && soap_get0(soap) == 0xFE)) /* UTF-16 LE */ + return soap->error = SOAP_UTF_ERROR; + else soap_unget(soap, c); c = soap_get(soap); #ifdef WITH_DOM @@ -10116,7 +10270,7 @@ soap_peek_element(struct soap *soap) if (c != SOAP_LT) { *soap->tag = '\0'; if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; soap_unget(soap, c > 0 ? c | 0x80000000 : c); #ifdef WITH_DOM /* whitespace leading to end tag is significant for DOM */ @@ -10221,7 +10375,7 @@ soap_peek_element(struct soap *soap) { tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + strlen(soap->tmpbuf)); if (!tp) return soap->error = SOAP_EOM; - strcpy(tp->name, soap->tmpbuf); + strcpy((char*)tp->name, soap->tmpbuf); tp->value = NULL; tp->size = 0; tp->ns = NULL; @@ -10254,6 +10408,7 @@ soap_peek_element(struct soap *soap) return soap->error; if (tp->value) SOAP_FREE(soap, tp->value); + tp->value = NULL; for (;;) { if (soap_getattrval(soap, soap->labbuf + soap->labidx, soap->lablen - soap->labidx, c)) { if (soap->error != SOAP_EOM) @@ -10333,7 +10488,7 @@ soap_peek_element(struct soap *soap) } #endif if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; if (!(soap->body = (c != '/'))) do c = soap_get1(soap); while (soap_blank(c)); @@ -10342,8 +10497,6 @@ soap_peek_element(struct soap *soap) { if (!soap->body && soap->dom->prnt) soap->dom = soap->dom->prnt; } - if (soap->feltbegin) - return soap->error = soap->feltbegin(soap, soap->tag); #endif for (tp = soap->attributes; tp; tp = tp->next) { if (tp->visible && tp->value) @@ -10436,6 +10589,10 @@ soap_peek_element(struct soap *soap) } } } +#ifdef WITH_DOM + if (soap->feltbegin) + return soap->error = soap->feltbegin(soap, soap->tag); +#endif return soap->error = SOAP_OK; } #endif @@ -10536,7 +10693,7 @@ soap_string_out(struct soap *soap, const char *s, int flag) if (soap->mode & SOAP_C_MBSTRING) { wchar_t wc; register int m = mbtowc(&wc, t - 1, MB_CUR_MAX); - if (m > 0 && (soap_wchar)wc != c) + if (m > 0 && !((soap_wchar)wc == c && m == 1 && c < 0x80)) { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, wc)) return soap->error; s = t += m - 1; @@ -10649,11 +10806,11 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) if ((int)c == EOF) goto end; if ((c >= 0x80 || c < SOAP_AP) && state != 1 && !(soap->mode & SOAP_ENC_LATIN)) - { if (c >= 0x80) + { if ((c & 0x7FFFFFFF) >= 0x80) { soap_unget(soap, c); c = soap_getutf8(soap); } - if (soap->mode & SOAP_C_UTFSTRING) + if ((c & 0x7FFFFFFF) >= 0x80 && (soap->mode & SOAP_C_UTFSTRING)) { c &= 0x7FFFFFFF; t = buf; if (c < 0x0800) @@ -10688,17 +10845,17 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) { case 1: if (c == ']') state = 4; - *s++ = c; + *s++ = (char)c; continue; case 2: if (c == '-') state = 6; - *s++ = c; + *s++ = (char)c; continue; case 3: if (c == '?') state = 8; - *s++ = c; + *s++ = (char)c; continue; /* CDATA */ case 4: @@ -10706,14 +10863,14 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) state = 5; else state = 1; - *s++ = c; + *s++ = (char)c; continue; case 5: if (c == '>') state = 0; else state = 1; - *s++ = c; + *s++ = (char)c; continue; /* comment */ case 6: @@ -10721,14 +10878,14 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) state = 7; else state = 2; - *s++ = c; + *s++ = (char)c; continue; case 7: if (c == '>') state = 0; else state = 2; - *s++ = c; + *s++ = (char)c; continue; /* PI */ case 8: @@ -10736,7 +10893,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) state = 0; else state = 3; - *s++ = c; + *s++ = (char)c; continue; } switch (c) @@ -10830,7 +10987,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) #ifndef WITH_LEANER #ifdef HAVE_WCTOMB if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); + { m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF)); if (m >= 1 && m <= (int)MB_CUR_MAX) { t = buf; *s++ = *t++; @@ -11001,7 +11158,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) #ifndef WITH_LEANER #ifdef HAVE_WCTOMB if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); + { m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF)); if (m >= 1 && m <= (int)MB_CUR_MAX) { t = buf; *s++ = *t++; @@ -11266,7 +11423,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) if ((int)c == EOF) goto end; if (sizeof(wchar_t) < 4 && c > 0xFFFF) - { wchar_t c1, c2; + { soap_wchar c1, c2; /* http://unicode.org/faq/utf_bom.html#utf16-2 */ c1 = 0xD800 - (0x10000 >> 10) + (c >> 10); c2 = 0xDC00 + (c & 0x3FF); @@ -11511,7 +11668,7 @@ soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) soap_reset_errno; #endif #endif - *p = strtoll(s, &r, 10); + *p = soap_strtoll(s, &r, 10); if (s == r || *r #ifndef WITH_NOIO #ifndef WITH_LEAN @@ -11726,7 +11883,11 @@ soap_float2s(struct soap *soap, float n) return "-INF"; s = soap->tmpbuf; #if defined(HAVE_SPRINTF_L) +# ifdef WIN32 + _sprintf_s_l(s, _countof(soap->tmpbuf), soap->float_format, soap->c_locale, n); +# else sprintf_l(s, soap->c_locale, soap->float_format, n); +# endif #else sprintf(s, soap->float_format, n); s = strchr(s, ','); /* convert decimal comma to DP */ @@ -11772,7 +11933,11 @@ soap_s2float(struct soap *soap, const char *s, float *p) /* On some systems strtof requires -std=c99 or does not even link: so we try to use strtod first */ #if defined(HAVE_STRTOD_L) char *r; +# ifdef WIN32 + *p = (float)_strtod_l(s, &r, soap->c_locale); +# else *p = (float)strtod_l(s, &r, soap->c_locale); +# endif if (*r) #elif defined(HAVE_STRTOD) char *r; @@ -11872,7 +12037,11 @@ soap_double2s(struct soap *soap, double n) return "-INF"; s = soap->tmpbuf; #if defined(HAVE_SPRINTF_L) +# ifdef WIN32 + _sprintf_s_l(s, _countof(soap->tmpbuf), soap->double_format, soap->c_locale, n); +# else sprintf_l(s, soap->c_locale, soap->double_format, n); +# endif #else sprintf(s, soap->double_format, n); s = strchr(s, ','); /* convert decimal comma to DP */ @@ -11917,7 +12086,11 @@ soap_s2double(struct soap *soap, const char *s, double *p) { #if defined(HAVE_STRTOD_L) char *r; +# ifdef WIN32 + *p = _strtod_l(s, &r, soap->c_locale); +# else *p = strtod_l(s, &r, soap->c_locale); +# endif if (*r) #elif defined(HAVE_STRTOD) char *r; @@ -12313,7 +12486,7 @@ soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p) soap_reset_errno; #endif #endif - *p = strtoull(s, &r, 10); + *p = soap_strtoull(s, &r, 10); if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r #ifndef WITH_NOIO #ifndef WITH_LEAN @@ -12414,7 +12587,7 @@ soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxle break; /* find next QName */ n = 1; - while (s[n] && !soap_blank(s[n])) + while (s[n] && !soap_blank((soap_wchar)s[n])) n++; np = soap->nlist; /* if there is no namespace stack, or prefix is "xml" then copy string */ @@ -12455,7 +12628,7 @@ soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxle soap_append_lab(soap, "\"", 1); } else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\nNamespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns?np->ns:SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\nNamespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns ? np->ns : SOAP_STR_EOS)); return soap->error = SOAP_NAMESPACE; } } @@ -12506,10 +12679,7 @@ soap_QName2s(struct soap *soap, const char *s) { soap_append_lab(soap, s, n); #ifndef WITH_LEAN if ((soap->mode & SOAP_XML_CANONICAL)) - { const char *r = strchr(s, ':'); - if (r) - soap_utilize_ns(soap, s, r - s); - } + soap_utilize_ns(soap, s); #endif } else /* URL-based string prefix */ @@ -12688,7 +12858,8 @@ SOAP_FMAC1 char ** SOAP_FMAC2 soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen) -{ if (soap_element_begin_in(soap, tag, 1, NULL)) +{ (void)type; + if (soap_element_begin_in(soap, tag, 1, NULL)) { if (!tag || *tag != '-' || soap->error != SOAP_NO_TAG) return NULL; soap->error = SOAP_OK; @@ -12754,7 +12925,8 @@ SOAP_FMAC1 wchar_t ** SOAP_FMAC2 soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen) -{ if (soap_element_begin_in(soap, tag, 1, NULL)) +{ (void)type; + if (soap_element_begin_in(soap, tag, 1, NULL)) { if (!tag || *tag != '-' || soap->error != SOAP_NO_TAG) return NULL; soap->error = SOAP_OK; @@ -13217,7 +13389,7 @@ soap_getline(struct soap *soap, char *s, int len) if (c == '\r' || c == '\n') break; if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; *s++ = (char)c; } if (c != '\n') @@ -13231,7 +13403,7 @@ soap_getline(struct soap *soap, char *s, int len) break; } else if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; if (i < 0) return soap->error = SOAP_HDR; } @@ -13346,7 +13518,7 @@ SOAP_FMAC2 soap_putdimehdr(struct soap *soap) { unsigned char tmp[12]; size_t optlen = 0, idlen = 0, typelen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime.id?soap->dime.id:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime.id ? soap->dime.id : SOAP_STR_EOS)); if (soap->dime.options) optlen = (((unsigned char)soap->dime.options[2] << 8) | ((unsigned char)soap->dime.options[3])) + 4; if (soap->dime.id) @@ -13442,7 +13614,7 @@ soap_putdime(struct soap *soap) bufsize = sizeof(soap->tmpbuf); if (!(bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize))) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)content->size)); - soap->error = SOAP_EOF; + soap->error = SOAP_CHK_EOF; break; } if (soap_send_raw(soap, soap->tmpbuf, bufsize)) @@ -13484,7 +13656,7 @@ soap_getdimefield(struct soap *soap, size_t n) { s = p; for (i = n; i > 0; i--) { if ((int)(c = soap_get1(soap)) == EOF) - { soap->error = SOAP_EOF; + { soap->error = SOAP_CHK_EOF; return NULL; } *s++ = (char)c; @@ -13518,7 +13690,7 @@ soap_getdimehdr(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME header\n")); if (soap->dime.buflen || soap->dime.chunksize) { if (soap_move(soap, (long)(soap->dime.size - soap_tell(soap)))) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; soap_unget(soap, soap_getchar(soap)); /* skip padding and get hdr */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... From chunked\n")); return SOAP_OK; @@ -13526,7 +13698,7 @@ soap_getdimehdr(struct soap *soap) s = (char*)tmp; for (i = 12; i > 0; i--) { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; *s++ = (char)c; } if ((tmp[0] & 0xF8) != SOAP_DIME_VERSION) @@ -13543,7 +13715,7 @@ soap_getdimehdr(struct soap *soap) return soap->error; if (!(soap->dime.type = soap_getdimefield(soap, typelen)) && soap->error) return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime.id?soap->dime.id:SOAP_STR_EOS, soap->dime.type?soap->dime.type:"", soap->dime.options?soap->dime.options+4:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime.id ? soap->dime.id : SOAP_STR_EOS, soap->dime.type ? soap->dime.type : "", soap->dime.options ? soap->dime.options+4 : SOAP_STR_EOS)); if (soap->dime.flags & SOAP_DIME_ME) soap->mode &= ~SOAP_ENC_DIME; return SOAP_OK; @@ -13795,7 +13967,7 @@ soap_get_mime_attachment(struct soap *soap, void *handle) return NULL; } } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Parsing MIME content id=%s type=%s\n", content->id?content->id:SOAP_STR_EOS, content->type?content->type:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Parsing MIME content id=%s type=%s\n", content->id ? content->id : SOAP_STR_EOS, content->type ? content->type : SOAP_STR_EOS)); if (!content->ptr && soap_new_block(soap) == NULL) { soap->error = SOAP_EOM; return NULL; @@ -13816,7 +13988,7 @@ soap_get_mime_attachment(struct soap *soap, void *handle) { if (!flag) { c = soap_get1(soap); if ((int)c == EOF) - { soap->error = SOAP_EOF; + { soap->error = SOAP_CHK_EOF; return NULL; } } @@ -13829,7 +14001,7 @@ soap_get_mime_attachment(struct soap *soap, void *handle) do c = soap_getchar(soap); while (c == *t++); if ((int)c == EOF) - { soap->error = SOAP_EOF; + { soap->error = SOAP_CHK_EOF; return NULL; } if (!*--t) @@ -13954,7 +14126,7 @@ int SOAP_FMAC2 soap_putmimehdr(struct soap *soap, struct soap_multipart *content) { const char *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MIME attachment type=%s\n", content->type?content->type:SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MIME attachment type=%s\n", content->type ? content->type : SOAP_STR_EOS)); if (soap_send3(soap, "\r\n--", soap->mime.boundary, "\r\n")) return soap->error; if (content->type && soap_send3(soap, "Content-Type: ", content->type, "\r\n")) @@ -14245,7 +14417,7 @@ soap_getgziphdr(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n")); for (i = 0; i < 9; i++) { if ((int)(c = soap_get1(soap) == EOF)) - return soap->error = SOAP_EOF; + return soap->error = SOAP_ZLIB_ERROR; if (i == 1 && c == 8) soap->z_dict = 0; if (i == 2) @@ -14254,7 +14426,7 @@ soap_getgziphdr(struct soap *soap) if (f & 0x04) /* FEXTRA */ { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--) { if ((int)soap_get1(soap) == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_ZLIB_ERROR; } } if (f & 0x08) /* skip FNAME */ @@ -14272,7 +14444,7 @@ soap_getgziphdr(struct soap *soap) c = soap_get1(soap); } if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_ZLIB_ERROR; return SOAP_OK; } #endif @@ -14292,7 +14464,10 @@ soap_begin_serve(struct soap *soap) } #endif soap_begin(soap); - if (soap_begin_recv(soap)) + if (soap_begin_recv(soap) + || soap_envelope_begin_in(soap) + || soap_recv_header(soap) + || soap_body_begin_in(soap)) { if (soap->error < SOAP_STOP) { #ifdef WITH_FASTCGI @@ -14303,10 +14478,6 @@ soap_begin_serve(struct soap *soap) } return soap_closesock(soap); } - if (soap_envelope_begin_in(soap) - || soap_recv_header(soap) - || soap_body_begin_in(soap)) - return soap->error; return SOAP_OK; } #endif @@ -14317,7 +14488,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_begin_recv(struct soap *soap) -{ soap_wchar c; +{ register soap_wchar c; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for input\n")); soap->error = SOAP_OK; soap->filterstop = SOAP_OK; @@ -14350,6 +14521,7 @@ soap_begin_recv(struct soap *soap) soap->header = NULL; soap->fault = NULL; soap->status = 0; + soap->fform = NULL; #ifndef WITH_LEANER soap->dom = NULL; soap->dime.chunksize = 0; @@ -14366,7 +14538,7 @@ soap_begin_recv(struct soap *soap) #ifdef WIN32 #ifndef UNDER_CE #ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) + if (!soap_valid_socket(soap->socket) && !soap->is) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ #ifdef __BORLANDC__ setmode(soap->recvfd, _O_BINARY); #else @@ -14433,14 +14605,24 @@ soap_begin_recv(struct soap *soap) else #endif { /* skip BOM */ - if (c == 0xEF && (c = soap_getchar(soap)) == 0xBB && (c = soap_getchar(soap)) == 0xBF) - c = soap_getchar(soap); + if (c == 0xEF && soap_get0(soap) == 0xBB) + { c = soap_get1(soap); + if ((c = soap_get1(soap)) == 0xBF) + { soap->mode &= ~SOAP_ENC_LATIN; + c = soap_getchar(soap); + } + else + c = (0x0F << 12) | (0xBB << 6) | (c & 0x3F); /* UTF-8 */ + } + else if ((c == 0xFE && soap_get0(soap) == 0xFF) /* UTF-16 BE */ + || (c == 0xFF && soap_get0(soap) == 0xFE)) /* UTF-16 LE */ + return soap->error = SOAP_UTF_ERROR; /* skip space */ while (soap_blank(c)) c = soap_getchar(soap); } if ((int)c == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; soap_unget(soap, c); #ifndef WITH_NOHTTP /* if not XML or MIME/DIME/ZLIB, assume HTTP header */ @@ -14453,7 +14635,13 @@ soap_begin_recv(struct soap *soap) return soap->error; } if (soap->error == SOAP_STOP) + { if (soap->fform) + { soap->error = soap->fform(soap); + if (soap->error == SOAP_OK) + soap->error = SOAP_STOP; /* prevents further processing */ + } return soap->error; + } soap->mode = soap->imode; /* if imode is changed, effectuate */ soap->imode = m; /* restore imode */ #ifdef WITH_ZLIB @@ -14532,7 +14720,7 @@ soap_begin_recv(struct soap *soap) if (soap->mode & SOAP_ENC_MIME) { do /* skip preamble */ { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; + return soap->error = SOAP_CHK_EOF; } while (c != '-' || soap_get0(soap) != '-'); soap_unget(soap, c); if (soap_getmimehdr(soap)) @@ -14614,7 +14802,8 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope") || soap_send_raw(soap, "\r\n", 2)) /* 2.8: always emit \r\n after SOAP Envelope */ +{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope") + || soap_send_raw(soap, "\r\n", 2)) /* 2.8: always emit \r\n */ return soap->error; #ifndef WITH_LEANER if ((soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM)) @@ -14959,23 +15148,32 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi } else #endif + soap->action = soap_strdup(soap, action); if (soap->fopen && *soap->host) { if (!soap->keep_alive || !soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port || !soap->fpoll || soap->fpoll(soap)) { soap->error = SOAP_OK; - soap->keep_alive = 0; /* to force close */ - soap->omode &= ~SOAP_IO_UDP; /* to force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect/reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); #ifndef WITH_LEAN if (!strncmp(endpoint, "soap.udp:", 9)) soap->omode |= SOAP_IO_UDP; + else #endif - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0); + { soap->keep_alive = 0; /* to force close */ + soap->omode &= ~SOAP_IO_UDP; /* to force close */ + } + soap_closesock(soap); + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect/reconnect to '%s' host='%s' path='%s' port=%d\n", endpoint?endpoint:"(null)", soap->host, soap->path, soap->port)); + if (!soap->keep_alive || !soap_valid_socket(soap->socket)) + { soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); + if (soap->error) + return soap->error; + soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0); + } } } +#ifdef WITH_NTLM + if (soap_ntlm_handshake(soap, SOAP_GET, endpoint, soap->host, soap->port)) + return soap->error; +#endif count = soap_count_attachments(soap); if (soap_begin_send(soap)) return soap->error; @@ -14984,7 +15182,6 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi soap->mode |= SOAP_IO_BUFFER; } #ifndef WITH_NOHTTP - soap->action = soap_strdup(soap, action); if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint) { unsigned int k = soap->mode; soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); @@ -15000,7 +15197,7 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi #endif soap->mode = k; } - if (http_command == SOAP_GET) + if (http_command == SOAP_GET || http_command == SOAP_DEL) return soap_end_send(soap); #endif return SOAP_OK; @@ -15008,6 +15205,80 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi #endif /******************************************************************************/ +#ifdef WITH_NTLM +#ifndef PALM_1 +static int +soap_ntlm_handshake(struct soap *soap, int command, const char *endpoint, const char *host, int port) +{ /* requires libntlm from http://www.nongnu.org/libntlm/ */ + const char *userid = (soap->proxy_userid ? soap->proxy_userid : soap->userid); + const char *passwd = (soap->proxy_passwd ? soap->proxy_passwd : soap->passwd); + struct SOAP_ENV__Header *oldheader; + if (soap->ntlm_challenge && userid && passwd && soap->authrealm) + { tSmbNtlmAuthRequest req; + tSmbNtlmAuthResponse res; + tSmbNtlmAuthChallenge ch; + short k = soap->keep_alive; + size_t l = soap->length; + size_t c = soap->count; + soap_mode m = soap->mode, o = soap->omode; + int s = soap->status; + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM '%s'\n", soap->ntlm_challenge)); + if (!*soap->ntlm_challenge) + { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM S->C Type 1: received NTLM authentication challenge from server\n")); + /* S -> C 401 Unauthorized + WWW-Authenticate: NTLM + */ + buildSmbNtlmAuthRequest(&req, userid, soap->authrealm); + soap->ntlm_challenge = soap_s2base64(soap, (unsigned char*)&req, NULL, SmbLength(&req)); + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM C->S Type 2: sending NTLM authorization to server\nAuthorization: NTLM %s\n", soap->ntlm_challenge)); + /* C -> S GET ... + Authorization: NTLM TlRMTVNTUAABAAAAA7IAAAoACgApAAAACQAJACAAAABMSUdIVENJVFlVUlNBLU1JTk9S + */ + soap->omode = SOAP_IO_BUFFER; + if (soap_begin_send(soap)) + return soap->error; + soap->keep_alive = 1; + soap->status = command; + if (soap->fpost(soap, endpoint, host, port, soap->path, soap->action, 0) + || soap_end_send(soap)) + return soap->error; + soap->mode = m; + soap->keep_alive = k; + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM S->C Type 2: waiting on server NTLM response\n")); + oldheader = soap->header; + if (soap_begin_recv(soap)) + if (soap->error == SOAP_EOF) + return soap->error; + soap_end_recv(soap); + soap->header = oldheader; + soap->length = l; + if (soap->status != 401 && soap->status != 407) + return soap->error = SOAP_NTLM_ERROR; + soap->error = SOAP_OK; + } + /* S -> C 401 Unauthorized + WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAAAAACgAAAABggAAU3J2Tm9uY2UAAAAAAAAAAA== + */ + soap_base642s(soap, soap->ntlm_challenge, (char*)&ch, sizeof(tSmbNtlmAuthChallenge), NULL); + buildSmbNtlmAuthResponse(&ch, &res, userid, passwd); + soap->ntlm_challenge = soap_s2base64(soap, (unsigned char*)&res, NULL, SmbLength(&res)); + DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM C->S Type 3: sending NTLM authorization to server\nAuthorization: NTLM %s\n", soap->ntlm_challenge)); + /* C -> S GET ... + Authorization: NTLM TlRMTVNTUAADAAAAGAAYAHIAAAAYABgAigAAABQAFABAAAAADAAMAFQAAAASABIAYAAAAAAAAACiAAAAAYIAAFUAUgBTAEEALQBNAEkATgBPAFIAWgBhAHAAaABvAGQATABJAEcASABUAEMASQBUAFkArYfKbe/jRoW5xDxHeoxC1gBmfWiS5+iX4OAN4xBKG/IFPwfH3agtPEia6YnhsADT + */ + soap->keep_alive = k; + soap->length = l; + soap->count = c; + soap->mode = m; + soap->omode = o; + soap->status = s; + } + return SOAP_OK; +} +#endif +#endif + +/******************************************************************************/ #ifndef WITH_LEAN SOAP_FMAC1 char* @@ -15055,7 +15326,8 @@ SOAP_FMAC1 const char* SOAP_FMAC2 soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) -{ register int i, j, c; +{ register size_t i, j; + register soap_wchar c; register unsigned long m; register const char *p; if (!s || !*s) @@ -15066,7 +15338,7 @@ soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) return SOAP_NON_NULL; } if (!t) - { l = (strlen(s) + 3) / 4 * 3; + { l = (strlen(s) + 3) / 4 * 3 + 1; /* make sure enough space for \0 */ t = (char*)soap_malloc(soap, l); } if (!t) @@ -15093,7 +15365,9 @@ soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) i += 2; } if (n) - *n += i; + *n += (int)i; + if (l >= j) + *t = '\0'; return p; } c -= '+'; @@ -15111,14 +15385,15 @@ soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) return NULL; } } - *t++ = (char)((m >> 16) & 0xFF); - *t++ = (char)((m >> 8) & 0xFF); - *t++ = (char)(m & 0xFF); if (l < 3) { if (n) - *n += i; + *n += (int)i; + *t = '\0'; return p; } + *t++ = (char)((m >> 16) & 0xFF); + *t++ = (char)((m >> 8) & 0xFF); + *t++ = (char)(m & 0xFF); l -= 3; } if (n) @@ -15168,7 +15443,7 @@ soap_hex2s(struct soap *soap, const char *s, char *t, size_t l, int *n) return SOAP_NON_NULL; } if (!t) - { l = strlen(s) / 2; + { l = strlen(s) / 2 + 1; /* make sure enough space for \0 */ t = (char*)soap_malloc(soap, l); } if (!t) @@ -15182,11 +15457,13 @@ soap_hex2s(struct soap *soap, const char *s, char *t, size_t l, int *n) d2 = *s++; if (!d2) break; - *t++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); + *t++ = (char)(((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0')); l--; } if (n) *n = (int)(t - p); + if (l) + *t = '\0'; return p; } #endif @@ -15198,13 +15475,13 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_puthttphdr(struct soap *soap, int status, size_t count) -{ if (soap->status != SOAP_GET) +{ if (soap->status != SOAP_GET && soap->status != SOAP_DEL && soap->status != SOAP_CONNECT) { register const char *s = "text/xml; charset=utf-8"; register int err = SOAP_OK; #ifndef WITH_LEANER register const char *r = NULL; #endif - if ((status == SOAP_FILE || soap->status == SOAP_POST_FILE) && soap->http_content) + if ((status == SOAP_FILE || soap->status == SOAP_PUT || soap->status == SOAP_POST_FILE) && soap->http_content) s = soap->http_content; else if (status == SOAP_HTML) s = "text/html; charset=utf-8"; @@ -15245,12 +15522,12 @@ soap_puthttphdr(struct soap *soap, int status, size_t count) } s = soap->tmpbuf; } - if (status == SOAP_OK && soap->version == 2 && soap->action && strlen(soap->action) < sizeof(soap->tmpbuf) - 80) - { sprintf(soap->tmpbuf, "%s; action=\"%s\"", s, soap->action); - s = soap->tmpbuf; - } + else + s = strcpy(soap->tmpbuf, s); + if (status == SOAP_OK && soap->version == 2 && soap->action && strlen(soap->action) + strlen(s) < sizeof(soap->tmpbuf) - 80) + sprintf(soap->tmpbuf + strlen(s), "; action=\"%s\"", soap->action); #endif - if (s && (err = soap->fposthdr(soap, "Content-Type", s))) + if ((err = soap->fposthdr(soap, "Content-Type", s))) return err; #ifdef WITH_ZLIB if ((soap->omode & SOAP_ENC_ZLIB)) @@ -15286,9 +15563,17 @@ soap_puthttphdr(struct soap *soap, int status, size_t count) static const char* soap_set_validation_fault(struct soap *soap, const char *s, const char *t) { if (*soap->tag) - sprintf(soap->msgbuf, "Validation constraint violation: %s%s in element '%s'", s, t?t:SOAP_STR_EOS, soap->tag); +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Validation constraint violation: %s%s in element '%s'", s, t ? t : SOAP_STR_EOS, soap->tag); +#else + sprintf(soap->msgbuf, "Validation constraint violation: %s%s in element '%s'", s, t ? t : SOAP_STR_EOS, soap->tag); +#endif else - sprintf(soap->msgbuf, "Validation constraint violation: %s%s", s, t?t:SOAP_STR_EOS); +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Validation constraint violation: %s%s", s, t ? t : SOAP_STR_EOS); +#else + sprintf(soap->msgbuf, "Validation constraint violation: %s%s", s, t ? t : SOAP_STR_EOS); +#endif return soap->msgbuf; } #endif @@ -15330,11 +15615,15 @@ soap_set_fault(struct soap *soap) *s = "Well-formedness violation"; break; case SOAP_NO_TAG: - *s = "No XML root element"; + *s = "No tag: no XML root element or missing SOAP message body element"; break; case SOAP_MUSTUNDERSTAND: *c = "SOAP-ENV:MustUnderstand"; +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "The data in element '%s' must be understood but cannot be handled", soap->tag); +#else sprintf(soap->msgbuf, "The data in element '%s' must be understood but cannot be handled", soap->tag); +#endif *s = soap->msgbuf; break; case SOAP_VERSIONMISMATCH: @@ -15355,7 +15644,11 @@ soap_set_fault(struct soap *soap) *s = "Fatal error"; break; case SOAP_NO_METHOD: +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Method '%s' not implemented: method name or namespace not recognized", soap->tag); +#else sprintf(soap->msgbuf, "Method '%s' not implemented: method name or namespace not recognized", soap->tag); +#endif *s = soap->msgbuf; break; case SOAP_NO_DATA: @@ -15386,7 +15679,7 @@ soap_set_fault(struct soap *soap) *s = soap_set_validation_fault(soap, "nil not allowed", NULL); break; case SOAP_DUPLICATE_ID: - *s = soap_set_validation_fault(soap, "multiple definitions of id ", soap->id); + *s = soap_set_validation_fault(soap, "multiple definitions (use the SOAP_XML_TREE flag) of the same id ", soap->id); if (soap->version == 2) *soap_faultsubcode(soap) = "SOAP-ENC:DuplicateID"; break; @@ -15411,6 +15704,9 @@ soap_set_fault(struct soap *soap) case SOAP_HTTP_ERROR: *s = "An HTTP processing error occurred"; break; + case SOAP_NTLM_ERROR: + *s = "An HTTP NTLM authentication error occurred"; + break; case SOAP_SSL_ERROR: #ifdef WITH_OPENSSL *s = "SSL/TLS error"; @@ -15444,7 +15740,11 @@ soap_set_fault(struct soap *soap) break; case SOAP_ZLIB_ERROR: #ifdef WITH_ZLIB - sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS); +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Zlib/gzip error: '%s'", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS); +#else + sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS); +#endif *s = soap->msgbuf; #else *s = "Zlib/gzip not installed for (de)compression: recompile with -DWITH_GZIP"; @@ -15465,8 +15765,11 @@ soap_set_fault(struct soap *soap) case SOAP_FD_EXCEEDED: *s = "Maximum number of open connections was reached (no define HAVE_POLL): increase FD_SETSIZE"; break; + case SOAP_UTF_ERROR: + *s = "UTF content encoding error"; + break; case SOAP_STOP: - *s = "Stopped: no response to be sent or received (informative)"; + *s = "Stopped: no response sent or received (informative)"; break; #endif case SOAP_EOF: @@ -15488,7 +15791,12 @@ soap_set_fault(struct soap *soap) #ifndef WITH_NOHTTP #ifndef WITH_LEAN if (soap->error > 200 && soap->error < 600) - { sprintf(soap->msgbuf, "HTTP Error: %d %s", soap->error, http_error(soap, soap->error)); + { +#ifdef HAVE_SNPRINTF + soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "HTTP Error: %d %s", soap->error, http_error(soap, soap->error)); +#else + sprintf(soap->msgbuf, "HTTP Error: %d %s", soap->error, http_error(soap, soap->error)); +#endif *s = soap->msgbuf; } else @@ -15617,12 +15925,14 @@ int SOAP_FMAC2 soap_send_empty_response(struct soap *soap, int httpstatuscode) { register soap_mode m = soap->omode; - soap->count = 0; - if ((m & SOAP_IO) == SOAP_IO_CHUNK) - soap->omode = (m & ~SOAP_IO) | SOAP_IO_BUFFER; - if (!soap_response(soap, httpstatuscode) && !soap_end_send(soap)) - soap->error = SOAP_STOP; /* stops the server's response */ - soap->omode = m; + if (!(m & SOAP_IO_UDP)) + { soap->count = 0; + if ((m & SOAP_IO) == SOAP_IO_CHUNK) + soap->omode = (m & ~SOAP_IO) | SOAP_IO_BUFFER; + if (!soap_response(soap, httpstatuscode) && !soap_end_send(soap)) + soap->error = SOAP_STOP; /* stops the server's processing of request */ + soap->omode = m; + } return soap_closesock(soap); } #endif @@ -15635,10 +15945,12 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_recv_empty_response(struct soap *soap) -{ if (!soap_begin_recv(soap)) - soap_end_recv(soap); - else if (soap->error == SOAP_NO_DATA || soap->error == 202) - soap->error = SOAP_OK; +{ if (!(soap->omode & SOAP_IO_UDP)) + { if (!soap_begin_recv(soap)) + soap_end_recv(soap); + else if (soap->error == SOAP_NO_DATA || soap->error == 202) + soap->error = SOAP_OK; + } return soap_closesock(soap); } #endif @@ -15805,16 +16117,15 @@ soap_print_fault(struct soap *soap, FILE *fd) { if (soap_check_state(soap)) fprintf(fd, "Error: soap struct state not initialized\n"); else if (soap->error) - { const char *c, *v = NULL, *s, **d; - d = soap_faultcode(soap); - if (!*d) + { const char **c, *v = NULL, *s, *d; + c = soap_faultcode(soap); + if (!*c) soap_set_fault(soap); - c = *d; if (soap->version == 2) - v = *soap_faultsubcode(soap); + v = soap_check_faultsubcode(soap); s = *soap_faultstring(soap); - d = soap_faultdetail(soap); - fprintf(fd, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]"); + d = soap_check_faultdetail(soap); + fprintf(fd, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); } } #endif @@ -15824,6 +16135,7 @@ soap_print_fault(struct soap *soap, FILE *fd) #ifdef __cplusplus #ifndef WITH_LEAN #ifndef WITH_NOSTDLIB +#ifndef WITH_COMPAT SOAP_FMAC1 void SOAP_FMAC2 @@ -15831,29 +16143,29 @@ soap_stream_fault(struct soap *soap, std::ostream& os) { if (soap_check_state(soap)) os << "Error: soap struct state not initialized\n"; else if (soap->error) - { const char *c, *v = NULL, *s, **d; - d = soap_faultcode(soap); - if (!*d) + { const char **c, *v = NULL, *s, *d; + c = soap_faultcode(soap); + if (!*c) soap_set_fault(soap); - c = *d; if (soap->version == 2) - v = *soap_faultsubcode(soap); + v = soap_check_faultsubcode(soap); s = *soap_faultstring(soap); - d = soap_faultdetail(soap); + d = soap_check_faultdetail(soap); os << (soap->version ? "SOAP 1." : "Error ") << (soap->version ? (int)soap->version : soap->error) - << " fault: " << c + << " fault: " << *c << "[" << (v ? v : "no subcode") << "]" << std::endl << "\"" << (s ? s : "[no reason]") << "\"" << std::endl - << "Detail: " << (d && *d ? *d : "[no detail]") + << "Detail: " << (d ? d : "[no detail]") << std::endl; } } #endif #endif #endif +#endif /******************************************************************************/ #ifndef WITH_LEAN @@ -15865,27 +16177,21 @@ soap_sprint_fault(struct soap *soap, char *buf, size_t len) { if (soap_check_state(soap)) strncpy(buf, "Error: soap struct not initialized", len); else if (soap->error) - { const char *c, *v = NULL, *s, **d; - d = soap_faultcode(soap); - if (!*d) + { const char **c, *v = NULL, *s, *d; + c = soap_faultcode(soap); + if (!*c) soap_set_fault(soap); - c = *d; if (soap->version == 2) v = *soap_faultsubcode(soap); s = *soap_faultstring(soap); - d = soap_faultdetail(soap); + d = soap_check_faultdetail(soap); #ifdef HAVE_SNPRINTF -# ifdef WIN32 - _snprintf -# else - snprintf -# endif - (buf, len, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]"); + soap_snprintf(buf, len, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); #else - if (len > 40 + (v ? strlen(v) : 0) + (s ? strlen(s) : 0) + (d && *d ? strlen(*d) : 0)) - sprintf(buf, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]"); + if (len > 40 + (v ? strlen(v) : 0) + (s ? strlen(s) : 0) + (d ? strlen(d) : 0)) + sprintf(buf, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); else if (len > 40) - sprintf(buf, "%s%d fault: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c); + sprintf(buf, "%s%d fault: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c); else buf[0] = '\0'; #endif @@ -15920,8 +16226,8 @@ soap_print_fault_location(struct soap *soap, FILE *fd) fprintf(fd, "%s%c\n<!-- ** HERE ** -->\n", soap->buf, c1); if (soap->bufidx < soap->buflen) fprintf(fd, "%s\n", soap->buf + soap->bufidx); - soap->buf[i] = c1; - soap->buf[j] = c2; + soap->buf[i] = (char)c1; + soap->buf[j] = (char)c2; } #endif } @@ -15949,7 +16255,7 @@ soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Registered '%s' plugin\n", p->id)); return SOAP_OK; } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id?p->id:"?", r)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id ? p->id : "?", r)); SOAP_FREE(soap, p); return r; } diff --git a/dep/gsoap/stdsoap2.h b/dep/gsoap/stdsoap2.h index 238b7f175ac..87185924135 100644 --- a/dep/gsoap/stdsoap2.h +++ b/dep/gsoap/stdsoap2.h @@ -1,10 +1,10 @@ /* - stdsoap2.h 2.8.2 + stdsoap2.h 2.8.10 gSOAP runtime engine gSOAP XML Web services tools -Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2012, Robert van Engelen, Genivia Inc., All Rights Reserved. This part of the software is released under ONE of the following licenses: GPL, or the gSOAP public license, or Genivia's license for commercial use. -------------------------------------------------------------------------------- @@ -24,7 +24,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2012, Robert van Engelen, Genivia Inc., All Rights Reserved. -------------------------------------------------------------------------------- GPL license. @@ -51,6 +51,8 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com -------------------------------------------------------------------------------- */ +#define GSOAP_VERSION 20810 + #ifdef WITH_SOAPDEFS_H # include "soapdefs.h" /* include user-defined stuff */ #endif @@ -129,6 +131,13 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif +/* for legacy purposes we use WIN32 macro even though 64 bit is supported */ +#ifdef _WIN64 +# ifndef WIN32 +# define WIN32 +# endif +#endif + #ifdef _WIN32_WCE # ifndef UNDER_CE # define UNDER_CE _WIN32_WCE @@ -211,8 +220,14 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_STRRCHR # define HAVE_STRTOD # define HAVE_SSCANF +# define HAVE_STRTOD_L +# define HAVE_SPRINTF_L # define HAVE_STRTOL # define HAVE_STRTOUL +# if _MSC_VER >= 1300 +# define HAVE_STRTOLL // use _strtoi64 +# define HAVE_STRTOULL // use _strtoui64 +# endif # define HAVE_SYS_TIMEB_H # define HAVE_FTIME # define HAVE_GMTIME @@ -293,7 +308,6 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_WCTOMB # define HAVE_MBTOWC # define HAVE_ISNAN -# define HAVE_ISINF # elif defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) # define HAVE_POLL # define HAVE_SNPRINTF @@ -472,6 +486,19 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define ULONG64 unsigned LONG64 # define SOAP_LONG_FORMAT "%ld" # define SOAP_ULONG_FORMAT "%lu" +# elif defined(SUN_OS) +# define HAVE_SNPRINTF +# define HAVE_STRRCHR +# define HAVE_STRTOD +# define HAVE_SSCANF +# define HAVE_STRTOL +# define HAVE_STRTOUL +# define HAVE_SYS_TIMEB_H +# define HAVE_FTIME +# define HAVE_RAND_R +# define HAVE_GETHOSTBYNAME_R +# define HAVE_GMTIME_R +# define HAVE_LOCALTIME_R # else /* Default assumptions for supported functions */ # define HAVE_SNPRINTF @@ -515,11 +542,17 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif -/* native Win and HP-UX compilers don't like empty structs */ +/* native Win, HP-UX, and AIX compilers don't like empty structs */ #if defined(WIN32) || defined(HP_UX) || defined(_AIX41) || defined(_AIX43) || defined(VXWORKS) # define WITH_NOEMPTYSTRUCT #endif +#ifdef WITH_PURE_VIRTUAL +# define SOAP_PURE_VIRTUAL = 0 +#else +# define SOAP_PURE_VIRTUAL +#endif + #ifdef HP_UX # undef HAVE_STRTOLL # undef HAVE_STRTOULL @@ -534,8 +567,11 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com /* if we have xlocale.h we use it to avoid decimal point conversion issues */ #ifdef WITH_C_LOCALE -# include <locale.h> -# include <xlocale.h> +# ifdef WIN32 +# include <locale.h> +# else +# include <xlocale.h> +# endif #else # undef HAVE_STRTOF_L # undef HAVE_STRTOD_L @@ -543,7 +579,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # undef HAVE_SPRINTF_L #endif -#ifdef TANDEM +#ifdef TANDEM_NONSTOP # define SOAP_BUFLEN (32767) /*# define WITH_NOSTDLIB */ /* uncommment to remove stdlib dependences */ # define WITH_NOIO /* no IO dependences, e.g. remove TCP/IP */ @@ -586,6 +622,10 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # include <limits.h> #endif +#ifdef WITH_NTLM +# include <ntlm.h> +#endif + #ifdef HAVE_POLL # include <poll.h> #endif @@ -672,14 +712,6 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define SOAP_WINSOCKINT size_t #endif -#ifdef WITH_IPV6 -# ifdef IPV6_V6ONLY -# if !defined(WITH_NO_IPV6_V6ONLY) && !defined(WITH_IPV6_V6ONLY) -# define WITH_NO_IPV6_V6ONLY /* turn on IPv6-IPv4 switching */ -# endif -# endif -#endif - #if defined(WITH_IPV6_V6ONLY) || defined(WITH_NO_IPV6_V6ONLY) # ifndef WITH_IPV6 # define WITH_IPV6 @@ -691,9 +723,17 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # include <io.h> # include <fcntl.h> # endif -# include <winsock2.h> /* Visual Studio 2005 users: you must install the Platform SDK (R2) */ -# include <ws2tcpip.h> -# include <wspiapi.h> +// When you get macro redefinition errors when compiling the code below: +// try arrange your include list that <windows.h> is included after "stdsoap2.h" +// or define _WINSOCKAPI_ first: +// #define _WINSOCKAPI_ // stops windows.h including winsock.h +// #include <windows.h> +// #include "stdsoap2.h" +# include <winsock2.h> /* Visual Studio 2005 users: install Platform SDK (R2) */ +# include <ws2tcpip.h> +// # define _WSPIAPI_COUNTOF /* DEV NOTE: enble to fix problems with VC6 */ +// # include <wspiapi.h> +# include <ws2spi.h> /* DEV NOTE: replaces older wspiapi.h above */ # ifdef WITH_IPV6 # define SOAP_GAI_STRERROR gai_strerrorA # endif @@ -790,9 +830,9 @@ extern "C" { # endif #elif defined(SOCKLEN_T) # define SOAP_SOCKLEN_T SOCKLEN_T -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) || defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__) || defined(QNX) || defined(OS390) || defined(HP_UX) +#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) || defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__) || defined(QNX) || defined(OS390) # define SOAP_SOCKLEN_T socklen_t -#elif defined(IRIX) || defined(WIN32) || defined(__APPLE__) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) +#elif defined(IRIX) || defined(WIN32) || defined(__APPLE__) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) || defined(HP_UX) # define SOAP_SOCKLEN_T int #else # define SOAP_SOCKLEN_T size_t @@ -822,6 +862,12 @@ extern "C" { # define FD_SETSIZE (1024) #endif +#ifdef WITH_LEAN +# define SOAP_CHK_EOF SOAP_EOF +#else +# define SOAP_CHK_EOF (soap->error ? soap->error : SOAP_EOF) +#endif + #if defined(SYMBIAN) # define LONG64 long # define ULONG64 unsigned LONG64 @@ -874,7 +920,6 @@ extern "C" { #elif defined(PALM) # define soap_int32 Int32 #elif defined(_AIX) -# define SOAP_NEW(type) new type /* AIX compilers don't like new (t) */ # if defined(_AIX43) # define soap_int32 int32_t # else @@ -1133,6 +1178,14 @@ extern const char soap_base64o[], soap_base64i[]; #define soap_isninfd(n) ((n) < 0 && soap_isinf(n)) #define soap_isninff(n) ((n) < 0 && soap_isinf(n)) +#ifdef HAVE_SNPRINTF +# ifdef WIN32 +# define soap_snprintf _snprintf +# else +# define soap_snprintf snprintf +# endif +#endif + /* gSOAP error codes */ #define SOAP_EOF EOF @@ -1184,6 +1237,8 @@ extern const char soap_base64o[], soap_base64i[]; #define SOAP_OCCURS 44 #define SOAP_LENGTH 45 #define SOAP_FD_EXCEEDED 46 +#define SOAP_UTF_ERROR 47 +#define SOAP_NTLM_ERROR 48 #define soap_xml_error_check(e) ((e) == SOAP_TAG_MISMATCH || (e) == SOAP_NO_TAG || (e) == SOAP_SYNTAX_ERROR || (e) == SOAP_NAMESPACE || (e) == SOAP_DUPLICATE_ID || (e) == SOAP_MISSING_ID || (e) == SOAP_REQUIRED || (e) == SOAP_PROHIBITED || (e) == SOAP_OCCURS || (e) == SOAP_LENGTH || (e) == SOAP_NULL || (e) == SOAP_HREF) #define soap_soap_error_check(e) ((e) == SOAP_CLI_FAULT || (e) == SOAP_SVR_FAULT || (e) == SOAP_VERSIONMISMATCH || (e) == SOAP_MUSTUNDERSTAND || (e) == SOAP_FAULT || (e) == SOAP_NO_METHOD) @@ -1199,7 +1254,7 @@ extern const char soap_base64o[], soap_base64i[]; /* Exceptional gSOAP HTTP server response status codes >= 1000 */ #define SOAP_STOP 1000 /* No HTTP response */ -#define SOAP_FORM 1001 /* Form request/response */ +#define SOAP_FORM 1001 /* Request (form) data is present, no HTTP response */ #define SOAP_HTML 1002 /* Custom HTML response */ #define SOAP_FILE 1003 /* Custom file-based response */ @@ -1208,6 +1263,9 @@ extern const char soap_base64o[], soap_base64i[]; #define SOAP_POST 2000 /* POST request */ #define SOAP_POST_FILE 2001 /* Custom file-based POST request */ #define SOAP_GET 2002 /* GET request */ +#define SOAP_PUT 2003 /* PUT request */ +#define SOAP_DEL 2004 /* DELETE request */ +#define SOAP_CONNECT 2005 /* CONNECT request */ /* gSOAP DIME */ @@ -1254,21 +1312,22 @@ typedef soap_int32 soap_mode; #define SOAP_XML_DEFAULTNS 0x00008000 /* out: emit xmlns="..." */ #define SOAP_XML_CANONICAL 0x00010000 /* out: excC14N canonical XML */ #define SOAP_XML_TREE 0x00020000 /* out: XML tree (no id/ref) */ -#define SOAP_XML_GRAPH 0x00040000 /* see DOM manual */ -#define SOAP_XML_NIL 0x00080000 /* out: NULLs as xsi:nil */ +#define SOAP_XML_NIL 0x00040000 /* out: NULLs as xsi:nil */ +#define SOAP_XML_NOTYPE 0x00080000 /* out: NULLs as xsi:nil */ -#define SOAP_C_NOIOB 0x00100000 /* don't fault on array index out of bounds (just ignore) */ -#define SOAP_C_UTFSTRING 0x00200000 /* (de)serialize strings with UTF8 content */ -#define SOAP_C_MBSTRING 0x00400000 /* (de)serialize strings with multi-byte content */ -#define SOAP_C_NILSTRING 0x00800000 /* serialize empty strings as nil (omitted) */ +#define SOAP_DOM_TREE 0x00100000 /* see DOM manual */ +#define SOAP_DOM_NODE 0x00200000 +#define SOAP_DOM_ASIS 0x00400000 -#define SOAP_XML_DOM 0x01000000 +#define SOAP_C_NOIOB 0x01000000 /* don't fault on array index out of bounds (just ignore) */ +#define SOAP_C_UTFSTRING 0x02000000 /* (de)serialize strings with UTF8 content */ +#define SOAP_C_MBSTRING 0x04000000 /* (de)serialize strings with multi-byte content */ +#define SOAP_C_NILSTRING 0x08000000 /* serialize empty strings as nil (omitted) */ -#define SOAP_DOM_TREE 0x02000000 -#define SOAP_DOM_NODE 0x04000000 -#define SOAP_DOM_ASIS 0x08000000 +#define SOAP_XML_DOM 0x10000000 /* enable internal DOM */ +#define SOAP_XML_GRAPH 0x20000000 /* id-ref graph in DOM */ -#define SOAP_MIME_POSTCHECK 0x10000000 /* MIME flag (internal) */ +#define SOAP_MIME_POSTCHECK 0x40000000 /* MIME flag (internal) */ #define SOAP_SEC_WSUID 0x80000000 /* Add Body wsu:Id */ @@ -1303,7 +1362,7 @@ typedef soap_int32 soap_mode; #define soap_check_state(soap) (!(soap) || ((soap)->state != SOAP_INIT && (soap)->state != SOAP_COPY)) -/* parts, states, and events */ +/* parts */ #define SOAP_BEGIN 0 #define SOAP_IN_ENVELOPE 2 @@ -1315,8 +1374,11 @@ typedef soap_int32 soap_mode; #define SOAP_END_ENVELOPE 8 #define SOAP_END 9 -#define SOAP_SEC_BEGIN 10 -#define SOAP_SEC_SIGN 11 +/* events */ + +#define SOAP_SEC_BEGIN 1 +#define SOAP_SEC_SIGN 2 +#define SOAP_SEC_DECRYPT 3 /* DEBUG macros */ @@ -1349,13 +1411,17 @@ typedef soap_int32 soap_mode; #endif #ifndef SOAP_NEW /* use C++ new operator */ -# if (__GNUC__ <= 2) && !defined(__BORLANDC__) /* Borland uses GNU C? */ +# if (defined(__GNUC__) && (__GNUC__ <= 2) && !defined(__BORLANDC__)) || defined(__clang__) || defined(_AIX) # define SOAP_NEW(type) new type /* old form w/o parenthesis */ # else # define SOAP_NEW(type) new (type) /* prefer with parenthesis */ # endif #endif +#ifndef SOAP_PLACEMENT_NEW +# define SOAP_PLACEMENT_NEW(buf, type) new (buf) type +#endif + #ifndef SOAP_NEW_COPY /* use C++ new operator for ::copy() */ # define SOAP_NEW_COPY(clas) new clas /* prefer w/o parenthesis */ #endif @@ -1792,9 +1858,15 @@ struct SOAP_STD_API soap struct soap_plugin *plugins; /* linked list of plug-in data */ const char *userid; /* HTTP Basic authorization userid */ const char *passwd; /* HTTP Basic authorization passwd */ + const char *authrealm; /* HTTP authentication realm (NTLM domain) */ +#if !defined(WITH_LEAN) || defined(WITH_NTLM) + const char *ntlm_challenge; /* HTTP NTLM challenge key string */ + short ntlm_auth; /* HTTP NTLM authentication type */ + short ntlm_stage; /* HTTP NTLM stage 0..3 */ +#endif int (*fpost)(struct soap*, const char*, const char*, int, const char*, const char*, size_t); int (*fget)(struct soap*); /* HTTP GET hook (not set by default) */ - int (*fput)(struct soap*); /* HTTP PUT hook (handled as POST) */ + int (*fput)(struct soap*); /* HTTP PUT hook (handled as POST by default) */ int (*fdel)(struct soap*); /* HTTP DELETE hook (not set by default) */ int (*fopt)(struct soap*); /* HTTP OPTIONS hook (not set by default) */ int (*fhead)(struct soap*); /* HTTP HEAD hook (not set by default) */ @@ -1847,11 +1919,13 @@ struct SOAP_STD_API soap size_t (*fmimeread)(struct soap*, void*, char*, size_t); int (*fmimewrite)(struct soap*, void*, const char*, size_t); #endif - SOAP_SOCKET master; - SOAP_SOCKET socket; + SOAP_SOCKET master; /* socket bound to TCP/IP port */ + SOAP_SOCKET socket; /* socket to send and receive */ + SOAP_SOCKET sendsk; /* socket to send (overrides ::socket) */ + SOAP_SOCKET recvsk; /* socket to receive (overrides ::socket) */ #if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) - std::ostream *os; - std::istream *is; + std::ostream *os; /* stream to send */ + std::istream *is; /* stream to receive */ #else void *os; /* preserve struct size */ void *is; /* preserve struct size */ @@ -1860,8 +1934,8 @@ struct SOAP_STD_API soap int sendfd; /* WinCE FD to send */ int recvfd; /* WinCE FD to receive */ #else - FILE *sendfd; - FILE *recvfd; + FILE *sendfd; /* FD to send */ + FILE *recvfd; /* FD to receive */ #endif size_t bufidx; /* index in soap.buf[] */ size_t buflen; /* length of soap.buf[] content */ @@ -1885,9 +1959,9 @@ struct SOAP_STD_API soap char arraySize[SOAP_TAGLEN]; char arrayOffset[SOAP_TAGLEN]; short other; - short position; - int positions[SOAP_MAXDIMS]; short root; + int position; + int positions[SOAP_MAXDIMS]; struct soap_attribute *attributes; /* attribute list */ short encoding; /* when set, output encodingStyle */ short mustUnderstand; /* a mustUnderstand element was parsed or is output */ @@ -1895,6 +1969,7 @@ struct SOAP_STD_API soap short ns; /* when not set, output full xmlns bindings */ short part; /* SOAP part state (header or body) */ short event; /* engine events and states for use by plugins */ + unsigned int evlev; /* event level */ short alloced; short peeked; size_t chunksize; @@ -1903,7 +1978,6 @@ struct SOAP_STD_API soap char path[SOAP_TAGLEN]; char host[SOAP_TAGLEN]; char *action; - char *authrealm; /* HTTP authentication realm */ char *prolog; /* XML declaration prolog */ unsigned long ip; /* IP number */ int port; /* port number */ @@ -1990,7 +2064,11 @@ struct SOAP_STD_API soap char session_host[SOAP_TAGLEN]; int session_port; #ifdef WITH_C_LOCALE +# ifdef WIN32 + _locale_t c_locale; /* set to C locale by default */ +# else locale_t c_locale; /* set to C locale by default */ +# endif #else void *c_locale; #endif @@ -2073,13 +2151,26 @@ soap_wchar soap_get0(struct soap*); soap_wchar soap_get1(struct soap*); #endif +#define soap_versioning_paste(name, ext) name##_LIBRARY_VERSION_REQUIRED_##ext +#define soap_versioning_ext(name, ext) soap_versioning_paste(name, ext) +#define soap_versioning(name) soap_versioning_ext(name, GSOAP_VERSION) + +#define soap_init(soap) soap_init1(soap, SOAP_IO_DEFAULT) +#define soap_init1(soap, mode) soap_init2(soap, mode, mode) +#define soap_init2(soap, imode, omode) soap_versioning(soap_init)(soap, imode, omode) + +#define soap_new() soap_new1(SOAP_IO_DEFAULT) +#define soap_new1(mode) soap_new2(mode, mode) +#define soap_new2(imode, omode) soap_versioning(soap_new)(imode, omode) + #define soap_revget1(soap) ((soap)->bufidx--) #define soap_unget(soap, c) ((soap)->ahead = c) #define soap_register_plugin(soap, plugin) soap_register_plugin_arg(soap, plugin, NULL) -#define soap_imode(soap, n) ((soap)->mode = (soap)->imode = (n)) +#define soap_mode(soap, n) ((soap)->mode = (soap)->imode = (soap)->omode = (n)) +#define soap_imode(soap, n) ((soap)->imode = (n)) +#define soap_omode(soap, n) ((soap)->omode = (n)) #define soap_set_imode(soap, n) ((soap)->imode |= (n)) #define soap_clr_imode(soap, n) ((soap)->imode &= ~(n)) -#define soap_omode(soap, n) ((soap)->mode = (soap)->omode = (n)) #define soap_set_omode(soap, n) ((soap)->omode |= (n)) #define soap_clr_omode(soap, n) ((soap)->omode &= ~(n)) #define soap_set_mode(soap, n) ((soap)->imode |= (n), (soap)->omode |= (n)) @@ -2104,6 +2195,18 @@ soap_wchar soap_get1(struct soap*); SOAP_FMAC1 unsigned long SOAP_FMAC2 soap_strtoul(const char *s, char **t, int b); #endif +#ifdef WIN32 +# define soap_strtoll _strtoi64 +#else +# define soap_strtoll strtoll +#endif + +#ifdef WIN32 +# define soap_strtoull _strtoui64 +#else +# define soap_strtoull strtoull +#endif + #if defined(WITH_OPENSSL) # define soap_random soap_rand() SOAP_FMAC1 int SOAP_FMAC2 soap_rand(void); @@ -2131,18 +2234,29 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_rand(void); # define soap_markelement(s, p, n) (0) #endif -SOAP_FMAC1 void SOAP_FMAC2 soap_header(struct soap*); -SOAP_FMAC1 void SOAP_FMAC2 soap_fault(struct soap*); -SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultcode(struct soap*); -SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultsubcode(struct soap*); -SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultstring(struct soap*); -SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultdetail(struct soap*); +/* soap_traverse() traversal/walker routines take walker function arguments */ +typedef void soap_walker(struct soap*, void*, int, const char*, const char*); + +SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap); +SOAP_FMAC5 int SOAP_FMAC6 soap_serve_request(struct soap *soap); + +#ifndef WITH_NOGLOBAL +SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap*); +SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap*); +SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultcode(struct soap*); +SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultsubcode(struct soap*); +SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultstring(struct soap*); +SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultdetail(struct soap*); +SOAP_FMAC3 const char* SOAP_FMAC4 soap_check_faultsubcode(struct soap*); +SOAP_FMAC3 const char* SOAP_FMAC4 soap_check_faultdetail(struct soap*); +SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap*); +#endif + SOAP_FMAC1 void SOAP_FMAC2 soap_serializeheader(struct soap*); -SOAP_FMAC1 int SOAP_FMAC2 soap_putheader(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_getheader(struct soap*); -SOAP_FMAC1 void SOAP_FMAC2 soap_serializefault(struct soap*); -SOAP_FMAC1 int SOAP_FMAC2 soap_putfault(struct soap*); +SOAP_FMAC1 int SOAP_FMAC2 soap_putheader(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_getfault(struct soap*); +SOAP_FMAC1 int SOAP_FMAC2 soap_putfault(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_ssl_init(void); SOAP_FMAC1 int SOAP_FMAC2 soap_poll(struct soap*); @@ -2234,7 +2348,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_end_recv(struct soap*); SOAP_FMAC1 void* SOAP_FMAC2 soap_malloc(struct soap*, size_t); SOAP_FMAC1 void SOAP_FMAC2 soap_dealloc(struct soap*, void*); SOAP_FMAC1 struct soap_clist * SOAP_FMAC2 soap_link(struct soap*, void*, int, int, int (*fdelete)(struct soap_clist*)); -SOAP_FMAC1 void SOAP_FMAC2 soap_unlink(struct soap*, const void*); +SOAP_FMAC1 int SOAP_FMAC2 soap_unlink(struct soap*, const void*); SOAP_FMAC1 void SOAP_FMAC2 soap_free_temp(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_del(struct soap*); @@ -2262,18 +2376,15 @@ SOAP_FMAC1 char* SOAP_FMAC2 soap_putoffset(struct soap*, int); SOAP_FMAC1 char* SOAP_FMAC2 soap_putoffsets(struct soap*, const int *, int); SOAP_FMAC1 int SOAP_FMAC2 soap_closesock(struct soap*); +SOAP_FMAC1 int SOAP_FMAC2 soap_force_closesock(struct soap*); -SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_new(void); -SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_new1(soap_mode); -SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_new2(soap_mode, soap_mode); +SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_versioning(soap_new)(soap_mode, soap_mode); SOAP_FMAC1 void SOAP_FMAC2 soap_free(struct soap*); SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_copy(const struct soap*); SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_copy_context(struct soap*, const struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_copy_stream(struct soap*, struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_free_stream(struct soap*); -SOAP_FMAC1 void SOAP_FMAC2 soap_init(struct soap*); -SOAP_FMAC1 void SOAP_FMAC2 soap_init1(struct soap*, soap_mode); -SOAP_FMAC1 void SOAP_FMAC2 soap_init2(struct soap*, soap_mode, soap_mode); +SOAP_FMAC1 void SOAP_FMAC2 soap_versioning(soap_init)(struct soap*, soap_mode, soap_mode); SOAP_FMAC1 void SOAP_FMAC2 soap_done(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_cleanup(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_begin(struct soap*); @@ -2353,6 +2464,7 @@ SOAP_FMAC1 char* SOAP_FMAC2 soap_next_block(struct soap*, struct soap_blist*); SOAP_FMAC1 size_t SOAP_FMAC2 soap_block_size(struct soap*, struct soap_blist*); SOAP_FMAC1 char* SOAP_FMAC2 soap_save_block(struct soap*, struct soap_blist*, char*, int); SOAP_FMAC1 void SOAP_FMAC2 soap_end_block(struct soap*, struct soap_blist*); +SOAP_FMAC1 void SOAP_FMAC2 soap_update_pointers(struct soap *soap, char *start, char *end, char *p1, char *p2); SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_begin_out(struct soap*); SOAP_FMAC1 int soap_envelope_end_out(struct soap*); @@ -2382,8 +2494,10 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_recv_fault(struct soap*, int check); SOAP_FMAC1 void SOAP_FMAC2 soap_print_fault(struct soap*, FILE*); SOAP_FMAC1 void SOAP_FMAC2 soap_print_fault_location(struct soap*, FILE*); # ifndef WITH_LEAN -# ifdef __cplusplus +# ifndef WITH_COMPAT +# ifdef __cplusplus SOAP_FMAC1 void SOAP_FMAC2 soap_stream_fault(struct soap*, std::ostream&); +# endif # endif SOAP_FMAC1 char* SOAP_FMAC2 soap_sprint_fault(struct soap*, char*, size_t); # endif diff --git a/dep/gsoap/tc_upgrades.txt b/dep/gsoap/tc_upgrades.txt new file mode 100644 index 00000000000..04298b2ae82 --- /dev/null +++ b/dep/gsoap/tc_upgrades.txt @@ -0,0 +1,12 @@ +* Generate new headers based on TrinityCore soap-services stub: +gsoap/bin/linux386/soapcpp2 -1 -S -L -w -x -y soap.stub + +* Copy the following files from the gsoap package: +gsoap/stdsoap2.h +gsoap/stdsoap2.cpp + +* Remove the following files after generation: +ns1.nsmap +soapObject.h + +* Test compile and see if SOAP works... diff --git a/dep/utf8cpp/utf8/checked.h b/dep/utf8cpp/utf8/checked.h index a1d2035364d..3b00644444c 100644 --- a/dep/utf8cpp/utf8/checked.h +++ b/dep/utf8cpp/utf8/checked.h @@ -34,7 +34,7 @@ DEALINGS IN THE SOFTWARE. namespace utf8 { // Base for the exceptions that may be thrown from the library - class exception : public std::exception { + class exception : public ::std::exception { }; // Exceptions that may be thrown from the library functions. @@ -69,12 +69,38 @@ namespace utf8 /// The library API - functions intended to be called by the users + template <typename octet_iterator> + octet_iterator append(uint32_t cp, octet_iterator result) + { + if (!utf8::internal::is_code_point_valid(cp)) + throw invalid_code_point(cp); + + if (cp < 0x80) // one octet + *(result++) = static_cast<uint8_t>(cp); + else if (cp < 0x800) { // two octets + *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0); + *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); + } + else if (cp < 0x10000) { // three octets + *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0); + *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); + *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); + } + else { // four octets + *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0); + *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80); + *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); + *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); + } + return result; + } + template <typename octet_iterator, typename output_iterator> output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement) { while (start != end) { octet_iterator sequence_start = start; - internal::utf_error err_code = internal::validate_next(start, end); + internal::utf_error err_code = utf8::internal::validate_next(start, end); switch (err_code) { case internal::UTF8_OK : for (octet_iterator it = sequence_start; it != start; ++it) @@ -83,16 +109,16 @@ namespace utf8 case internal::NOT_ENOUGH_ROOM: throw not_enough_room(); case internal::INVALID_LEAD: - append (replacement, out); + utf8::append (replacement, out); ++start; break; case internal::INCOMPLETE_SEQUENCE: case internal::OVERLONG_SEQUENCE: case internal::INVALID_CODE_POINT: - append (replacement, out); + utf8::append (replacement, out); ++start; // just one replacement mark for the sequence - while (internal::is_trail(*start) && start != end) + while (start != end && utf8::internal::is_trail(*start)) ++start; break; } @@ -103,41 +129,15 @@ namespace utf8 template <typename octet_iterator, typename output_iterator> inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out) { - static const uint32_t replacement_marker = internal::mask16(0xfffd); - return replace_invalid(start, end, out, replacement_marker); - } - - template <typename octet_iterator> - octet_iterator append(uint32_t cp, octet_iterator result) - { - if (!internal::is_code_point_valid(cp)) - throw invalid_code_point(cp); - - if (cp < 0x80) // one octet - *(result++) = static_cast<uint8_t>(cp); - else if (cp < 0x800) { // two octets - *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - else if (cp < 0x10000) { // three octets - *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0); - *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - else { // four octets - *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0); - *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - return result; + static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd); + return utf8::replace_invalid(start, end, out, replacement_marker); } template <typename octet_iterator> uint32_t next(octet_iterator& it, octet_iterator end) { uint32_t cp = 0; - internal::utf_error err_code = internal::validate_next(it, end, &cp); + internal::utf_error err_code = utf8::internal::validate_next(it, end, cp); switch (err_code) { case internal::UTF8_OK : break; @@ -156,18 +156,22 @@ namespace utf8 template <typename octet_iterator> uint32_t peek_next(octet_iterator it, octet_iterator end) { - return next(it, end); + return utf8::next(it, end); } template <typename octet_iterator> uint32_t prior(octet_iterator& it, octet_iterator start) { + // can't do much if it == start + if (it == start) + throw not_enough_room(); + octet_iterator end = it; - while (internal::is_trail(*(--it))) - if (it < start) + // Go back until we hit either a lead octet or start + while (utf8::internal::is_trail(*(--it))) + if (it == start) throw invalid_utf8(*it); // error - no lead byte in the sequence - octet_iterator temp = it; - return next(temp, end); + return utf8::peek_next(it, end); } /// Deprecated in versions that include "prior" @@ -175,18 +179,18 @@ namespace utf8 uint32_t previous(octet_iterator& it, octet_iterator pass_start) { octet_iterator end = it; - while (internal::is_trail(*(--it))) + while (utf8::internal::is_trail(*(--it))) if (it == pass_start) throw invalid_utf8(*it); // error - no lead byte in the sequence octet_iterator temp = it; - return next(temp, end); + return utf8::next(temp, end); } template <typename octet_iterator, typename distance_type> void advance (octet_iterator& it, distance_type n, octet_iterator end) { for (distance_type i = 0; i < n; ++i) - next(it, end); + utf8::next(it, end); } template <typename octet_iterator> @@ -195,7 +199,7 @@ namespace utf8 { typename std::iterator_traits<octet_iterator>::difference_type dist; for (dist = 0; first < last; ++dist) - next(first, last); + utf8::next(first, last); return dist; } @@ -203,12 +207,12 @@ namespace utf8 octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result) { while (start != end) { - uint32_t cp = internal::mask16(*start++); + uint32_t cp = utf8::internal::mask16(*start++); // Take care of surrogate pairs first - if (internal::is_lead_surrogate(cp)) { + if (utf8::internal::is_lead_surrogate(cp)) { if (start != end) { - uint32_t trail_surrogate = internal::mask16(*start++); - if (internal::is_trail_surrogate(trail_surrogate)) + uint32_t trail_surrogate = utf8::internal::mask16(*start++); + if (utf8::internal::is_trail_surrogate(trail_surrogate)) cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET; else throw invalid_utf16(static_cast<uint16_t>(trail_surrogate)); @@ -218,10 +222,10 @@ namespace utf8 } // Lone trail surrogate - else if (internal::is_trail_surrogate(cp)) + else if (utf8::internal::is_trail_surrogate(cp)) throw invalid_utf16(static_cast<uint16_t>(cp)); - result = append(cp, result); + result = utf8::append(cp, result); } return result; } @@ -230,7 +234,7 @@ namespace utf8 u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result) { while (start != end) { - uint32_t cp = next(start, end); + uint32_t cp = utf8::next(start, end); if (cp > 0xffff) { //make a surrogate pair *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET); *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN); @@ -245,7 +249,7 @@ namespace utf8 octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result) { while (start != end) - result = append(*(start++), result); + result = utf8::append(*(start++), result); return result; } @@ -254,7 +258,7 @@ namespace utf8 u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result) { while (start != end) - (*result++) = next(start, end); + (*result++) = utf8::next(start, end); return result; } @@ -280,7 +284,7 @@ namespace utf8 uint32_t operator * () const { octet_iterator temp = it; - return next(temp, range_end); + return utf8::next(temp, range_end); } bool operator == (const iterator& rhs) const { @@ -294,24 +298,24 @@ namespace utf8 } iterator& operator ++ () { - next(it, range_end); + utf8::next(it, range_end); return *this; } iterator operator ++ (int) { iterator temp = *this; - next(it, range_end); + utf8::next(it, range_end); return temp; } iterator& operator -- () { - prior(it, range_start); + utf8::prior(it, range_start); return *this; } iterator operator -- (int) { iterator temp = *this; - prior(it, range_start); + utf8::prior(it, range_start); return temp; } }; // class iterator diff --git a/dep/utf8cpp/utf8/core.h b/dep/utf8cpp/utf8/core.h index ec709f12006..693d388c078 100644 --- a/dep/utf8cpp/utf8/core.h +++ b/dep/utf8cpp/utf8/core.h @@ -68,7 +68,7 @@ namespace internal template<typename octet_type> inline bool is_trail(octet_type oc) { - return ((mask8(oc) >> 6) == 0x2); + return ((utf8::internal::mask8(oc) >> 6) == 0x2); } template <typename u16> @@ -92,14 +92,14 @@ namespace internal template <typename u32> inline bool is_code_point_valid(u32 cp) { - return (cp <= CODE_POINT_MAX && !is_surrogate(cp) && cp != 0xfffe && cp != 0xffff); + return (cp <= CODE_POINT_MAX && !utf8::internal::is_surrogate(cp)); } template <typename octet_iterator> inline typename std::iterator_traits<octet_iterator>::difference_type sequence_length(octet_iterator lead_it) { - uint8_t lead = mask8(*lead_it); + uint8_t lead = utf8::internal::mask8(*lead_it); if (lead < 0x80) return 1; else if ((lead >> 5) == 0x6) @@ -133,123 +133,94 @@ namespace internal enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT}; - /// get_sequence_x functions decode utf-8 sequences of the length x + /// Helper for get_sequence_x + template <typename octet_iterator> + utf_error increase_safely(octet_iterator& it, octet_iterator end) + { + if (++it == end) + return NOT_ENOUGH_ROOM; + + if (!utf8::internal::is_trail(*it)) + return INCOMPLETE_SEQUENCE; + + return UTF8_OK; + } + #define UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(IT, END) {utf_error ret = increase_safely(IT, END); if (ret != UTF8_OK) return ret;} + + /// get_sequence_x functions decode utf-8 sequences of the length x template <typename octet_iterator> - utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t* code_point) + utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t& code_point) { - if (it != end) { - if (code_point) - *code_point = mask8(*it); - return UTF8_OK; - } - return NOT_ENOUGH_ROOM; + if (it == end) + return NOT_ENOUGH_ROOM; + + code_point = utf8::internal::mask8(*it); + + return UTF8_OK; } template <typename octet_iterator> - utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t* code_point) + utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t& code_point) { - utf_error ret_code = NOT_ENOUGH_ROOM; + if (it == end) + return NOT_ENOUGH_ROOM; + + code_point = utf8::internal::mask8(*it); - if (it != end) { - uint32_t cp = mask8(*it); - if (++it != end) { - if (is_trail(*it)) { - cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f); + UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) - if (code_point) - *code_point = cp; - ret_code = UTF8_OK; - } - else - ret_code = INCOMPLETE_SEQUENCE; - } - else - ret_code = NOT_ENOUGH_ROOM; - } + code_point = ((code_point << 6) & 0x7ff) + ((*it) & 0x3f); - return ret_code; + return UTF8_OK; } template <typename octet_iterator> - utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t* code_point) + utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t& code_point) { - utf_error ret_code = NOT_ENOUGH_ROOM; - - if (it != end) { - uint32_t cp = mask8(*it); - if (++it != end) { - if (is_trail(*it)) { - cp = ((cp << 12) & 0xffff) + ((mask8(*it) << 6) & 0xfff); - if (++it != end) { - if (is_trail(*it)) { - cp += (*it) & 0x3f; - - if (code_point) - *code_point = cp; - ret_code = UTF8_OK; - } - else - ret_code = INCOMPLETE_SEQUENCE; - } - else - ret_code = NOT_ENOUGH_ROOM; - } - else - ret_code = INCOMPLETE_SEQUENCE; - } - else - ret_code = NOT_ENOUGH_ROOM; - } + if (it == end) + return NOT_ENOUGH_ROOM; + + code_point = utf8::internal::mask8(*it); + + UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) + + code_point = ((code_point << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff); + + UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) - return ret_code; + code_point += (*it) & 0x3f; + + return UTF8_OK; } template <typename octet_iterator> - utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t* code_point) + utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t& code_point) { - utf_error ret_code = NOT_ENOUGH_ROOM; - - if (it != end) { - uint32_t cp = mask8(*it); - if (++it != end) { - if (is_trail(*it)) { - cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff); - if (++it != end) { - if (is_trail(*it)) { - cp += (mask8(*it) << 6) & 0xfff; - if (++it != end) { - if (is_trail(*it)) { - cp += (*it) & 0x3f; - - if (code_point) - *code_point = cp; - ret_code = UTF8_OK; - } - else - ret_code = INCOMPLETE_SEQUENCE; - } - else - ret_code = NOT_ENOUGH_ROOM; - } - else - ret_code = INCOMPLETE_SEQUENCE; - } - else - ret_code = NOT_ENOUGH_ROOM; - } - else - ret_code = INCOMPLETE_SEQUENCE; - } - else - ret_code = NOT_ENOUGH_ROOM; - } + if (it == end) + return NOT_ENOUGH_ROOM; - return ret_code; + code_point = utf8::internal::mask8(*it); + + UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) + + code_point = ((code_point << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff); + + UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) + + code_point += (utf8::internal::mask8(*it) << 6) & 0xfff; + + UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) + + code_point += (*it) & 0x3f; + + return UTF8_OK; } + #undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR + template <typename octet_iterator> - utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t* code_point) + utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point) { // Save the original value of it so we can go back in case of failure // Of course, it does not make much sense with i.e. stream iterators @@ -258,34 +229,33 @@ namespace internal uint32_t cp = 0; // Determine the sequence length based on the lead octet typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type; - octet_difference_type length = sequence_length(it); - if (length == 0) - return INVALID_LEAD; + const octet_difference_type length = utf8::internal::sequence_length(it); - // Now that we have a valid sequence length, get trail octets and calculate the code point + // Get trail octets and calculate the code point utf_error err = UTF8_OK; switch (length) { + case 0: + return INVALID_LEAD; case 1: - err = get_sequence_1(it, end, &cp); + err = utf8::internal::get_sequence_1(it, end, cp); break; case 2: - err = get_sequence_2(it, end, &cp); + err = utf8::internal::get_sequence_2(it, end, cp); break; case 3: - err = get_sequence_3(it, end, &cp); + err = utf8::internal::get_sequence_3(it, end, cp); break; case 4: - err = get_sequence_4(it, end, &cp); + err = utf8::internal::get_sequence_4(it, end, cp); break; } if (err == UTF8_OK) { // Decoding succeeded. Now, security checks... - if (is_code_point_valid(cp)) { - if (!is_overlong_sequence(cp, length)){ + if (utf8::internal::is_code_point_valid(cp)) { + if (!utf8::internal::is_overlong_sequence(cp, length)){ // Passed! Return here. - if (code_point) - *code_point = cp; + code_point = cp; ++it; return UTF8_OK; } @@ -303,7 +273,8 @@ namespace internal template <typename octet_iterator> inline utf_error validate_next(octet_iterator& it, octet_iterator end) { - return validate_next(it, end, 0); + uint32_t ignored; + return utf8::internal::validate_next(it, end, ignored); } } // namespace internal @@ -318,7 +289,7 @@ namespace internal { octet_iterator result = start; while (result != end) { - internal::utf_error err_code = internal::validate_next(result, end); + utf8::internal::utf_error err_code = utf8::internal::validate_next(result, end); if (err_code != internal::UTF8_OK) return result; } @@ -328,27 +299,27 @@ namespace internal template <typename octet_iterator> inline bool is_valid(octet_iterator start, octet_iterator end) { - return (find_invalid(start, end) == end); + return (utf8::find_invalid(start, end) == end); } template <typename octet_iterator> inline bool starts_with_bom (octet_iterator it, octet_iterator end) { return ( - ((it != end) && (internal::mask8(*it++)) == bom[0]) && - ((it != end) && (internal::mask8(*it++)) == bom[1]) && - ((it != end) && (internal::mask8(*it)) == bom[2]) + ((it != end) && (utf8::internal::mask8(*it++)) == bom[0]) && + ((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) && + ((it != end) && (utf8::internal::mask8(*it)) == bom[2]) ); } - //Deprecated in release 2.3 + //Deprecated in release 2.3 template <typename octet_iterator> inline bool is_bom (octet_iterator it) { return ( - (internal::mask8(*it++)) == bom[0] && - (internal::mask8(*it++)) == bom[1] && - (internal::mask8(*it)) == bom[2] + (utf8::internal::mask8(*it++)) == bom[0] && + (utf8::internal::mask8(*it++)) == bom[1] && + (utf8::internal::mask8(*it)) == bom[2] ); } } // namespace utf8 diff --git a/dep/utf8cpp/utf8/unchecked.h b/dep/utf8cpp/utf8/unchecked.h index 2f3eb4d1d02..b4547fad945 100644 --- a/dep/utf8cpp/utf8/unchecked.h +++ b/dep/utf8cpp/utf8/unchecked.h @@ -60,7 +60,7 @@ namespace utf8 template <typename octet_iterator> uint32_t next(octet_iterator& it) { - uint32_t cp = internal::mask8(*it); + uint32_t cp = utf8::internal::mask8(*it); typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it); switch (length) { case 1: @@ -71,15 +71,15 @@ namespace utf8 break; case 3: ++it; - cp = ((cp << 12) & 0xffff) + ((internal::mask8(*it) << 6) & 0xfff); + cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff); ++it; cp += (*it) & 0x3f; break; case 4: ++it; - cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff); + cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff); ++it; - cp += (internal::mask8(*it) << 6) & 0xfff; + cp += (utf8::internal::mask8(*it) << 6) & 0xfff; ++it; cp += (*it) & 0x3f; break; @@ -91,29 +91,29 @@ namespace utf8 template <typename octet_iterator> uint32_t peek_next(octet_iterator it) { - return next(it); + return utf8::unchecked::next(it); } template <typename octet_iterator> uint32_t prior(octet_iterator& it) { - while (internal::is_trail(*(--it))) ; + while (utf8::internal::is_trail(*(--it))) ; octet_iterator temp = it; - return next(temp); + return utf8::unchecked::next(temp); } // Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous) template <typename octet_iterator> inline uint32_t previous(octet_iterator& it) { - return prior(it); + return utf8::unchecked::prior(it); } template <typename octet_iterator, typename distance_type> void advance (octet_iterator& it, distance_type n) { for (distance_type i = 0; i < n; ++i) - next(it); + utf8::unchecked::next(it); } template <typename octet_iterator> @@ -122,7 +122,7 @@ namespace utf8 { typename std::iterator_traits<octet_iterator>::difference_type dist; for (dist = 0; first < last; ++dist) - next(first); + utf8::unchecked::next(first); return dist; } @@ -130,13 +130,13 @@ namespace utf8 octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result) { while (start != end) { - uint32_t cp = internal::mask16(*start++); + uint32_t cp = utf8::internal::mask16(*start++); // Take care of surrogate pairs first - if (internal::is_lead_surrogate(cp)) { - uint32_t trail_surrogate = internal::mask16(*start++); + if (utf8::internal::is_lead_surrogate(cp)) { + uint32_t trail_surrogate = utf8::internal::mask16(*start++); cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET; } - result = append(cp, result); + result = utf8::unchecked::append(cp, result); } return result; } @@ -145,7 +145,7 @@ namespace utf8 u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result) { while (start < end) { - uint32_t cp = next(start); + uint32_t cp = utf8::unchecked::next(start); if (cp > 0xffff) { //make a surrogate pair *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET); *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN); @@ -160,7 +160,7 @@ namespace utf8 octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result) { while (start != end) - result = append(*(start++), result); + result = utf8::unchecked::append(*(start++), result); return result; } @@ -169,7 +169,7 @@ namespace utf8 u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result) { while (start < end) - (*result++) = next(start); + (*result++) = utf8::unchecked::next(start); return result; } @@ -186,7 +186,7 @@ namespace utf8 uint32_t operator * () const { octet_iterator temp = it; - return next(temp); + return utf8::unchecked::next(temp); } bool operator == (const iterator& rhs) const { @@ -198,24 +198,24 @@ namespace utf8 } iterator& operator ++ () { - std::advance(it, internal::sequence_length(it)); + ::std::advance(it, utf8::internal::sequence_length(it)); return *this; } iterator operator ++ (int) { iterator temp = *this; - std::advance(it, internal::sequence_length(it)); + ::std::advance(it, utf8::internal::sequence_length(it)); return temp; } iterator& operator -- () { - prior(it); + utf8::unchecked::prior(it); return *this; } iterator operator -- (int) { iterator temp = *this; - prior(it); + utf8::unchecked::prior(it); return temp; } }; // class iterator diff --git a/dep/zlib/adler32.c b/dep/zlib/adler32.c index 65ad6a5adc4..a868f073d8a 100644 --- a/dep/zlib/adler32.c +++ b/dep/zlib/adler32.c @@ -1,5 +1,5 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2007 Mark Adler + * Copyright (C) 1995-2011 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,9 +9,9 @@ #define local static -local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); +local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); -#define BASE 65521UL /* largest prime smaller than 65536 */ +#define BASE 65521 /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); -/* use NO_DIVIDE if your processor does not do division in hardware */ +/* use NO_DIVIDE if your processor does not do division in hardware -- + try it both ways to see which is faster */ #ifdef NO_DIVIDE -# define MOD(a) \ +/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 + (thank you to John Reiser for pointing this out) */ +# define CHOP(a) \ + do { \ + unsigned long tmp = a >> 16; \ + a &= 0xffffUL; \ + a += (tmp << 4) - tmp; \ + } while (0) +# define MOD28(a) \ do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ + CHOP(a); \ if (a >= BASE) a -= BASE; \ } while (0) -# define MOD4(a) \ +# define MOD(a) \ do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ + CHOP(a); \ + MOD28(a); \ + } while (0) +# define MOD63(a) \ + do { /* this assumes a is not negative */ \ + z_off64_t tmp = a >> 32; \ + a &= 0xffffffffL; \ + a += (tmp << 8) - (tmp << 5) + tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE -# define MOD4(a) a %= BASE +# define MOD28(a) a %= BASE +# define MOD63(a) a %= BASE #endif /* ========================================================================= */ @@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len) } if (adler >= BASE) adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ + MOD28(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } @@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adler2, len2) unsigned long sum2; unsigned rem; + /* for negative len, return invalid adler32 as a clue for debugging */ + if (len2 < 0) + return 0xffffffffUL; + /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); + MOD63(len2); /* assumes len2 >= 0 */ + rem = (unsigned)len2; sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); diff --git a/dep/zlib/crc32.c b/dep/zlib/crc32.c index 91be372d224..979a7190a3c 100644 --- a/dep/zlib/crc32.c +++ b/dep/zlib/crc32.c @@ -1,5 +1,5 @@ /* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010 Mark Adler + * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster @@ -17,6 +17,8 @@ of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). + + DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. */ #ifdef MAKECRCH @@ -30,31 +32,11 @@ #define local static -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include <limits.h> -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - /* Definitions for doing the crc four data bytes at a time. */ +#if !defined(NOBYFOUR) && defined(Z_U4) +# define BYFOUR +#endif #ifdef BYFOUR -# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, @@ -68,16 +50,16 @@ local unsigned long gf2_matrix_times OF((unsigned long *mat, unsigned long vec)); local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); +local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); #ifdef DYNAMIC_CRC_TABLE local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; +local z_crc_t FAR crc_table[TBLS][256]; local void make_crc_table OF((void)); #ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); + local void write_table OF((FILE *, const z_crc_t FAR *)); #endif /* MAKECRCH */ /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: @@ -107,9 +89,9 @@ local void make_crc_table OF((void)); */ local void make_crc_table() { - unsigned long c; + z_crc_t c; int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ + z_crc_t poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ static volatile int first = 1; /* flag to limit concurrent making */ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; @@ -121,13 +103,13 @@ local void make_crc_table() first = 0; /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); + poly = 0; + for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) + poly |= (z_crc_t)1 << (31 - p[n]); /* generate a crc for every 8-bit value */ for (n = 0; n < 256; n++) { - c = (unsigned long)n; + c = (z_crc_t)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[0][n] = c; @@ -138,11 +120,11 @@ local void make_crc_table() and then the byte reversal of those as well as the first table */ for (n = 0; n < 256; n++) { c = crc_table[0][n]; - crc_table[4][n] = REV(c); + crc_table[4][n] = ZSWAP32(c); for (k = 1; k < 4; k++) { c = crc_table[0][c & 0xff] ^ (c >> 8); crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); + crc_table[k + 4][n] = ZSWAP32(c); } } #endif /* BYFOUR */ @@ -164,7 +146,7 @@ local void make_crc_table() if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); + fprintf(out, "local const z_crc_t FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); # ifdef BYFOUR @@ -184,12 +166,13 @@ local void make_crc_table() #ifdef MAKECRCH local void write_table(out, table) FILE *out; - const unsigned long FAR *table; + const z_crc_t FAR *table; { int n; for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", + (unsigned long)(table[n]), n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); } #endif /* MAKECRCH */ @@ -204,13 +187,13 @@ local void write_table(out, table) /* ========================================================================= * This function can be used by asm versions of crc32() */ -const unsigned long FAR * ZEXPORT get_crc_table() +const z_crc_t FAR * ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; + return (const z_crc_t FAR *)crc_table; } /* ========================================================================= */ @@ -232,7 +215,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) #ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; + z_crc_t endian; endian = 1; if (*((unsigned char *)(&endian))) @@ -266,17 +249,17 @@ local unsigned long crc32_little(crc, buf, len) const unsigned char FAR *buf; unsigned len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = (u4)crc; + c = (z_crc_t)crc; c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; while (len >= 32) { DOLIT32; len -= 32; @@ -306,17 +289,17 @@ local unsigned long crc32_big(crc, buf, len) const unsigned char FAR *buf; unsigned len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = REV((u4)crc); + c = ZSWAP32((z_crc_t)crc); c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; buf4--; while (len >= 32) { DOBIG32; @@ -333,7 +316,7 @@ local unsigned long crc32_big(crc, buf, len) c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); } while (--len); c = ~c; - return (unsigned long)(REV(c)); + return (unsigned long)(ZSWAP32(c)); } #endif /* BYFOUR */ diff --git a/dep/zlib/crc32.h b/dep/zlib/crc32.h index 8053b6117c0..9e0c7781025 100644 --- a/dep/zlib/crc32.h +++ b/dep/zlib/crc32.h @@ -2,7 +2,7 @@ * Generated automatically by crc32.c */ -local const unsigned long FAR crc_table[TBLS][256] = +local const z_crc_t FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, diff --git a/dep/zlib/deflate.c b/dep/zlib/deflate.c index 5c4022f3d47..9e4c2cbc8af 100644 --- a/dep/zlib/deflate.c +++ b/dep/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -37,7 +37,7 @@ * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt + * Available in http://tools.ietf.org/html/rfc1951 * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -155,6 +155,9 @@ local const config configuration_table[10] = { struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif +/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ +#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) + /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive @@ -235,10 +238,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; +#endif } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif #ifdef FASTEST if (level != 0) level = 1; @@ -314,43 +326,70 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) uInt dictLength; { deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; + uInt str, n; + int wrap; + unsigned avail; + unsigned char *next; - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - if (s->wrap) - strm->adler = adler32(strm->adler, dictionary, dictLength); + wrap = s->wrap; + if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) + return Z_STREAM_ERROR; - if (length < MIN_MATCH) return Z_OK; - if (length > s->w_size) { - length = s->w_size; - dictionary += dictLength - length; /* use the tail of the dictionary */ + /* when using zlib wrappers, compute Adler-32 for provided dictionary */ + if (wrap == 1) + strm->adler = adler32(strm->adler, dictionary, dictLength); + s->wrap = 0; /* avoid computing Adler-32 in read_buf */ + + /* if dictionary would fill window, just replace the history */ + if (dictLength >= s->w_size) { + if (wrap == 0) { /* already empty otherwise */ + CLEAR_HASH(s); + s->strstart = 0; + s->block_start = 0L; + s->insert = 0; + } + dictionary += dictLength - s->w_size; /* use the tail */ + dictLength = s->w_size; } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - 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 dictionary into window and hash */ + avail = strm->avail_in; + next = strm->next_in; + strm->avail_in = dictLength; + strm->next_in = (Bytef *)dictionary; + fill_window(s); + while (s->lookahead >= MIN_MATCH) { + str = s->strstart; + n = s->lookahead - (MIN_MATCH-1); + do { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + } while (--n); + s->strstart = str; + s->lookahead = MIN_MATCH-1; + fill_window(s); } - if (hash_head) hash_head = 0; /* to make compiler happy */ + s->strstart += s->lookahead; + s->block_start = (long)s->strstart; + s->insert = s->lookahead; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + strm->next_in = next; + strm->avail_in = avail; + s->wrap = wrap; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateReset (strm) +int ZEXPORT deflateResetKeep (strm) z_streamp strm; { deflate_state *s; @@ -380,12 +419,23 @@ int ZEXPORT deflateReset (strm) s->last_flush = Z_NO_FLUSH; _tr_init(s); - lm_init(s); return Z_OK; } /* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + int ret; + + ret = deflateResetKeep(strm); + if (ret == Z_OK) + lm_init(strm->state); + return ret; +} + +/* ========================================================================= */ int ZEXPORT deflateSetHeader (strm, head) z_streamp strm; gz_headerp head; @@ -397,14 +447,42 @@ int ZEXPORT deflateSetHeader (strm, head) } /* ========================================================================= */ +int ZEXPORT deflatePending (strm, pending, bits) + unsigned *pending; + int *bits; + z_streamp strm; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (pending != Z_NULL) + *pending = strm->state->pending; + if (bits != Z_NULL) + *bits = strm->state->bi_valid; + return Z_OK; +} + +/* ========================================================================= */ int ZEXPORT deflatePrime (strm, bits, value) z_streamp strm; int bits; int value; { + deflate_state *s; + int put; + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - strm->state->bi_valid = bits; - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); + s = strm->state; + if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; + do { + put = Buf_size - s->bi_valid; + if (put > bits) + put = bits; + s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); + s->bi_valid += put; + _tr_flush_bits(s); + value >>= put; + bits -= put; + } while (bits); return Z_OK; } @@ -562,19 +640,22 @@ local void putShortMSB (s, b) local void flush_pending(strm) z_streamp strm; { - unsigned len = strm->state->pending; + unsigned len; + deflate_state *s = strm->state; + _tr_flush_bits(s); + len = s->pending; if (len > strm->avail_out) len = strm->avail_out; if (len == 0) return; - zmemcpy(strm->next_out, strm->state->pending_out, len); + zmemcpy(strm->next_out, s->pending_out, len); strm->next_out += len; - strm->state->pending_out += len; + s->pending_out += len; strm->total_out += len; strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; + s->pending -= len; + if (s->pending == 0) { + s->pending_out = s->pending_buf; } } @@ -801,7 +882,7 @@ int ZEXPORT deflate (strm, flush) * flushes. For repeated and useless calls with Z_FINISH, we keep * returning Z_STREAM_END instead of Z_BUF_ERROR. */ - } else if (strm->avail_in == 0 && flush <= old_flush && + } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && flush != Z_FINISH) { ERR_RETURN(strm, Z_BUF_ERROR); } @@ -850,6 +931,7 @@ int ZEXPORT deflate (strm, flush) if (s->lookahead == 0) { s->strstart = 0; s->block_start = 0L; + s->insert = 0; } } } @@ -945,12 +1027,12 @@ int ZEXPORT deflateCopy (dest, source) ss = source->state; - zmemcpy(dest, source, sizeof(z_stream)); + zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); if (ds == Z_NULL) return Z_MEM_ERROR; dest->state = (struct internal_state FAR *) ds; - zmemcpy(ds, ss, sizeof(deflate_state)); + zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); ds->strm = dest; ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); @@ -966,8 +1048,8 @@ int ZEXPORT deflateCopy (dest, source) } /* following zmemcpy do not work for 16-bit MSDOS */ zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); @@ -1001,15 +1083,15 @@ local int read_buf(strm, buf, size) strm->avail_in -= len; + zmemcpy(buf, strm->next_in, len); if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, strm->next_in, len); + strm->adler = adler32(strm->adler, buf, len); } #ifdef GZIP else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, strm->next_in, len); + strm->adler = crc32(strm->adler, buf, len); } #endif - zmemcpy(buf, strm->next_in, len); strm->next_in += len; strm->total_in += len; @@ -1036,6 +1118,7 @@ local void lm_init (s) s->strstart = 0; s->block_start = 0L; s->lookahead = 0; + s->insert = 0; s->match_length = s->prev_length = MIN_MATCH-1; s->match_available = 0; s->ins_h = 0; @@ -1310,6 +1393,8 @@ local void fill_window(s) unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + do { more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); @@ -1362,7 +1447,7 @@ local void fill_window(s) #endif more += wsize; } - if (s->strm->avail_in == 0) return; + if (s->strm->avail_in == 0) break; /* If there was no sliding: * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && @@ -1381,12 +1466,24 @@ local void fill_window(s) s->lookahead += n; /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); + if (s->lookahead + s->insert >= MIN_MATCH) { + uInt str = s->strstart - s->insert; + s->ins_h = s->window[str]; + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); #if MIN_MATCH != 3 Call UPDATE_HASH() MIN_MATCH-3 more times #endif + while (s->insert) { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } } /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, * but this is not important since only literal bytes will be emitted. @@ -1427,6 +1524,9 @@ local void fill_window(s) s->high_water += init; } } + + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "not enough room for search"); } /* =========================================================================== @@ -1506,8 +1606,14 @@ local block_state deflate_stored(s, flush) FLUSH_BLOCK(s, 0); } } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; + s->insert = 0; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if ((long)s->strstart > s->block_start) + FLUSH_BLOCK(s, 0); + return block_done; } /* =========================================================================== @@ -1603,8 +1709,14 @@ local block_state deflate_fast(s, flush) } if (bflush) FLUSH_BLOCK(s, 0); } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; + s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; } #ifndef FASTEST @@ -1728,8 +1840,14 @@ local block_state deflate_slow(s, flush) _tr_tally_lit(s, s->window[s->strstart-1], bflush); s->match_available = 0; } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; + s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; } #endif /* FASTEST */ @@ -1749,11 +1867,11 @@ local block_state deflate_rle(s, flush) for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes - * for the longest encodable run. + * for the longest run, plus one for the unrolled loop. */ - if (s->lookahead < MAX_MATCH) { + if (s->lookahead <= MAX_MATCH) { fill_window(s); - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { + if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ @@ -1776,6 +1894,7 @@ local block_state deflate_rle(s, flush) if (s->match_length > s->lookahead) s->match_length = s->lookahead; } + Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); } /* Emit match if have run of MIN_MATCH or longer, else emit literal */ @@ -1796,8 +1915,14 @@ local block_state deflate_rle(s, flush) } if (bflush) FLUSH_BLOCK(s, 0); } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; + s->insert = 0; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; } /* =========================================================================== @@ -1829,6 +1954,12 @@ local block_state deflate_huff(s, flush) s->strstart++; if (bflush) FLUSH_BLOCK(s, 0); } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; + s->insert = 0; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; } diff --git a/dep/zlib/deflate.h b/dep/zlib/deflate.h index cbf0d1ea5d9..fbac44d908e 100644 --- a/dep/zlib/deflate.h +++ b/dep/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2010 Jean-loup Gailly + * Copyright (C) 1995-2012 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -48,6 +48,9 @@ #define MAX_BITS 15 /* All codes must not exceed MAX_BITS bits */ +#define Buf_size 16 +/* size of bit buffer in bi_buf */ + #define INIT_STATE 42 #define EXTRA_STATE 69 #define NAME_STATE 73 @@ -188,7 +191,7 @@ typedef struct internal_state { int nice_match; /* Stop searching when current match exceeds this */ /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ + /* Didn't use ct_data typedef below to suppress compiler warning */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ @@ -244,7 +247,7 @@ typedef struct internal_state { ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ + uInt insert; /* bytes at end of window left to insert */ #ifdef DEBUG ulg compressed_len; /* total bit length of compressed file mod 2^32 */ @@ -294,6 +297,7 @@ void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, int last)); diff --git a/dep/zlib/gzguts.h b/dep/zlib/gzguts.h index 0f8fb79f87d..ee3f281aa57 100644 --- a/dep/zlib/gzguts.h +++ b/dep/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -12,7 +12,7 @@ # endif #endif -#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) +#ifdef HAVE_HIDDEN # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL @@ -27,13 +27,65 @@ #endif #include <fcntl.h> +#ifdef _WIN32 +# include <stddef.h> +#endif + +#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) +# include <io.h> +#endif + #ifdef NO_DEFLATE /* for compatibility with old definition */ # define NO_GZCOMPRESS #endif -#ifdef _MSC_VER -# include <io.h> -# define vsnprintf _vsnprintf +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS +/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 +/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +# ifdef VMS +# define NO_vsnprintf +# endif +# ifdef __OS400__ +# define NO_vsnprintf +# endif +# ifdef __MVS__ +# define NO_vsnprintf +# endif #endif #ifndef local @@ -52,7 +104,7 @@ # include <windows.h> # define zstrerror() gz_strwinerror((DWORD)GetLastError()) #else -# ifdef STDC +# ifndef NO_STRERROR # include <errno.h> # define zstrerror() strerror(errno) # else @@ -68,6 +120,13 @@ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); #endif +/* default memLevel */ +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif + /* default i/o buffer size -- double this for output when reading */ #define GZBUFSIZE 8192 @@ -84,23 +143,25 @@ /* internal gzip file state data structure */ typedef struct { + /* exposed contents for gzgetc() macro */ + struct gzFile_s x; /* "x" for exposed */ + /* x.have: number of bytes available at x.next */ + /* x.next: next output data to deliver or write */ + /* x.pos: current position in uncompressed data */ /* used for both reading and writing */ int mode; /* see gzip modes above */ int fd; /* file descriptor */ char *path; /* path or fd for error messages */ - z_off64_t pos; /* current position in uncompressed data */ unsigned size; /* buffer size, zero if not allocated yet */ unsigned want; /* requested buffer size, default is GZBUFSIZE */ unsigned char *in; /* input buffer */ unsigned char *out; /* output buffer (double-sized when reading) */ - unsigned char *next; /* next output data to deliver or write */ + int direct; /* 0 if processing gzip, 1 if transparent */ /* just for reading */ - unsigned have; /* amount of output data unused at next */ - int eof; /* true if end of input file reached */ - z_off64_t start; /* where the gzip data started, for rewinding */ - z_off64_t raw; /* where the raw data started, for seeking */ int how; /* 0: get header, 1: copy, 2: decompress */ - int direct; /* true if last read direct, false if gzip */ + z_off64_t start; /* where the gzip data started, for rewinding */ + int eof; /* true if end of input file reached */ + int past; /* true if read requested past end */ /* just for writing */ int level; /* compression level */ int strategy; /* compression strategy */ diff --git a/dep/zlib/gzlib.c b/dep/zlib/gzlib.c index 603e60ed544..ca55c6ea926 100644 --- a/dep/zlib/gzlib.c +++ b/dep/zlib/gzlib.c @@ -1,19 +1,23 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004, 2010 Mark Adler + * Copyright (C) 2004, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" +#if defined(_WIN32) && !defined(__BORLANDC__) +# define LSEEK _lseeki64 +#else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define LSEEK lseek64 #else # define LSEEK lseek #endif +#endif /* Local functions */ local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const char *, int, const char *)); +local gzFile gz_open OF((const void *, int, const char *)); #if defined UNDER_CE @@ -71,25 +75,37 @@ char ZLIB_INTERNAL *gz_strwinerror (error) local void gz_reset(state) gz_statep state; { + state->x.have = 0; /* no output data available */ if (state->mode == GZ_READ) { /* for reading ... */ - state->have = 0; /* no output data available */ state->eof = 0; /* not at end of file */ + state->past = 0; /* have not read past end yet */ state->how = LOOK; /* look for gzip header */ - state->direct = 1; /* default for empty file */ } state->seek = 0; /* no seek request pending */ gz_error(state, Z_OK, NULL); /* clear error */ - state->pos = 0; /* no uncompressed data yet */ + state->x.pos = 0; /* no uncompressed data yet */ state->strm.avail_in = 0; /* no input data yet */ } /* Open a gzip file either by name or file descriptor. */ local gzFile gz_open(path, fd, mode) - const char *path; + const void *path; int fd; const char *mode; { gz_statep state; + size_t len; + int oflag; +#ifdef O_CLOEXEC + int cloexec = 0; +#endif +#ifdef O_EXCL + int exclusive = 0; +#endif + + /* check input */ + if (path == NULL) + return NULL; /* allocate gzFile structure to return */ state = malloc(sizeof(gz_state)); @@ -103,6 +119,7 @@ local gzFile gz_open(path, fd, mode) state->mode = GZ_NONE; state->level = Z_DEFAULT_COMPRESSION; state->strategy = Z_DEFAULT_STRATEGY; + state->direct = 0; while (*mode) { if (*mode >= '0' && *mode <= '9') state->level = *mode - '0'; @@ -124,6 +141,16 @@ local gzFile gz_open(path, fd, mode) return NULL; case 'b': /* ignore -- will request binary anyway */ break; +#ifdef O_CLOEXEC + case 'e': + cloexec = 1; + break; +#endif +#ifdef O_EXCL + case 'x': + exclusive = 1; + break; +#endif case 'f': state->strategy = Z_FILTERED; break; @@ -135,6 +162,8 @@ local gzFile gz_open(path, fd, mode) break; case 'F': state->strategy = Z_FIXED; + case 'T': + state->direct = 1; default: /* could consider as an error, but just ignore */ ; } @@ -147,30 +176,67 @@ local gzFile gz_open(path, fd, mode) return NULL; } + /* can't force transparent read */ + if (state->mode == GZ_READ) { + if (state->direct) { + free(state); + return NULL; + } + state->direct = 1; /* for empty file */ + } + /* save the path name for error messages */ - state->path = malloc(strlen(path) + 1); +#ifdef _WIN32 + if (fd == -2) { + len = wcstombs(NULL, path, 0); + if (len == (size_t)-1) + len = 0; + } + else +#endif + len = strlen(path); + state->path = malloc(len + 1); if (state->path == NULL) { free(state); return NULL; } - strcpy(state->path, path); +#ifdef _WIN32 + if (fd == -2) + if (len) + wcstombs(state->path, path, len + 1); + else + *(state->path) = 0; + else +#endif + strcpy(state->path, path); - /* open the file with the appropriate mode (or just use fd) */ - state->fd = fd != -1 ? fd : - open(path, + /* compute the flags for open() */ + oflag = #ifdef O_LARGEFILE - O_LARGEFILE | + O_LARGEFILE | #endif #ifdef O_BINARY - O_BINARY | + O_BINARY | +#endif +#ifdef O_CLOEXEC + (cloexec ? O_CLOEXEC : 0) | #endif - (state->mode == GZ_READ ? - O_RDONLY : - (O_WRONLY | O_CREAT | ( - state->mode == GZ_WRITE ? - O_TRUNC : - O_APPEND))), - 0666); + (state->mode == GZ_READ ? + O_RDONLY : + (O_WRONLY | O_CREAT | +#ifdef O_EXCL + (exclusive ? O_EXCL : 0) | +#endif + (state->mode == GZ_WRITE ? + O_TRUNC : + O_APPEND))); + + /* open the file with the appropriate flags (or just use fd) */ + state->fd = fd > -1 ? fd : ( +#ifdef _WIN32 + fd == -2 ? _wopen(path, oflag, 0666) : +#endif + open(path, oflag, 0666)); if (state->fd == -1) { free(state->path); free(state); @@ -225,6 +291,16 @@ gzFile ZEXPORT gzdopen(fd, mode) } /* -- see zlib.h -- */ +#ifdef _WIN32 +gzFile ZEXPORT gzopen_w(path, mode) + const wchar_t *path; + const char *mode; +{ + return gz_open(path, -2, mode); +} +#endif + +/* -- see zlib.h -- */ int ZEXPORT gzbuffer(file, size) gzFile file; unsigned size; @@ -243,8 +319,8 @@ int ZEXPORT gzbuffer(file, size) return -1; /* check and set requested size */ - if (size == 0) - return -1; + if (size < 2) + size = 2; /* need two bytes to check magic header */ state->want = size; return 0; } @@ -261,7 +337,8 @@ int ZEXPORT gzrewind(file) state = (gz_statep)file; /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || state->err != Z_OK) + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* back up and start over */ @@ -289,7 +366,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) return -1; /* check that there's no error */ - if (state->err != Z_OK) + if (state->err != Z_OK && state->err != Z_BUF_ERROR) return -1; /* can only seek from start or relative to current position */ @@ -298,31 +375,32 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) /* normalize offset to a SEEK_CUR specification */ if (whence == SEEK_SET) - offset -= state->pos; + offset -= state->x.pos; else if (state->seek) offset += state->skip; state->seek = 0; /* if within raw area while reading, just go there */ if (state->mode == GZ_READ && state->how == COPY && - state->pos + offset >= state->raw) { - ret = LSEEK(state->fd, offset - state->have, SEEK_CUR); + state->x.pos + offset >= 0) { + ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); if (ret == -1) return -1; - state->have = 0; + state->x.have = 0; state->eof = 0; + state->past = 0; state->seek = 0; gz_error(state, Z_OK, NULL); state->strm.avail_in = 0; - state->pos += offset; - return state->pos; + state->x.pos += offset; + return state->x.pos; } /* calculate skip amount, rewinding if needed for back seek when reading */ if (offset < 0) { if (state->mode != GZ_READ) /* writing -- can't go backwards */ return -1; - offset += state->pos; + offset += state->x.pos; if (offset < 0) /* before start of file! */ return -1; if (gzrewind(file) == -1) /* rewind, then skip to offset */ @@ -331,11 +409,11 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) /* if reading, skip what's in output buffer (one less gzgetc() check) */ if (state->mode == GZ_READ) { - n = GT_OFF(state->have) || (z_off64_t)state->have > offset ? - (unsigned)offset : state->have; - state->have -= n; - state->next += n; - state->pos += n; + n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? + (unsigned)offset : state->x.have; + state->x.have -= n; + state->x.next += n; + state->x.pos += n; offset -= n; } @@ -344,7 +422,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) state->seek = 1; state->skip = offset; } - return state->pos + offset; + return state->x.pos + offset; } /* -- see zlib.h -- */ @@ -373,7 +451,7 @@ z_off64_t ZEXPORT gztell64(file) return -1; /* return position */ - return state->pos + (state->seek ? state->skip : 0); + return state->x.pos + (state->seek ? state->skip : 0); } /* -- see zlib.h -- */ @@ -433,8 +511,7 @@ int ZEXPORT gzeof(file) return 0; /* return end-of-file state */ - return state->mode == GZ_READ ? - (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0; + return state->mode == GZ_READ ? state->past : 0; } /* -- see zlib.h -- */ @@ -471,8 +548,10 @@ void ZEXPORT gzclearerr(file) return; /* clear error and end-of-file */ - if (state->mode == GZ_READ) + if (state->mode == GZ_READ) { state->eof = 0; + state->past = 0; + } gz_error(state, Z_OK, NULL); } @@ -494,6 +573,10 @@ void ZLIB_INTERNAL gz_error(state, err, msg) state->msg = NULL; } + /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */ + if (err != Z_OK && err != Z_BUF_ERROR) + state->x.have = 0; + /* set error code, and if no message, then done */ state->err = err; if (msg == NULL) diff --git a/dep/zlib/gzread.c b/dep/zlib/gzread.c index 548201ab009..3493d34d4ea 100644 --- a/dep/zlib/gzread.c +++ b/dep/zlib/gzread.c @@ -1,5 +1,5 @@ /* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004, 2005, 2010 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -8,10 +8,9 @@ /* Local functions */ local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); local int gz_avail OF((gz_statep)); -local int gz_next4 OF((gz_statep, unsigned long *)); -local int gz_head OF((gz_statep)); +local int gz_look OF((gz_statep)); local int gz_decomp OF((gz_statep)); -local int gz_make OF((gz_statep)); +local int gz_fetch OF((gz_statep)); local int gz_skip OF((gz_statep, z_off64_t)); /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from @@ -46,67 +45,47 @@ local int gz_load(state, buf, len, have) error, 0 otherwise. Note that the eof flag is set when the end of the input file is reached, even though there may be unused data in the buffer. Once that data has been used, no more attempts will be made to read the file. - gz_avail() assumes that strm->avail_in == 0. */ + If strm->avail_in != 0, then the current data is moved to the beginning of + the input buffer, and then the remainder of the buffer is loaded with the + available data from the input file. */ local int gz_avail(state) gz_statep state; { + unsigned got; z_streamp strm = &(state->strm); - if (state->err != Z_OK) + if (state->err != Z_OK && state->err != Z_BUF_ERROR) return -1; if (state->eof == 0) { - if (gz_load(state, state->in, state->size, - (unsigned *)&(strm->avail_in)) == -1) + if (strm->avail_in) { /* copy what's there to the start */ + unsigned char *p = state->in, *q = strm->next_in; + unsigned n = strm->avail_in; + do { + *p++ = *q++; + } while (--n); + } + if (gz_load(state, state->in + strm->avail_in, + state->size - strm->avail_in, &got) == -1) return -1; + strm->avail_in += got; strm->next_in = state->in; } return 0; } -/* Get next byte from input, or -1 if end or error. */ -#define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \ - (strm->avail_in == 0 ? -1 : \ - (strm->avail_in--, *(strm->next_in)++))) - -/* Get a four-byte little-endian integer and return 0 on success and the value - in *ret. Otherwise -1 is returned and *ret is not modified. */ -local int gz_next4(state, ret) - gz_statep state; - unsigned long *ret; -{ - int ch; - unsigned long val; - z_streamp strm = &(state->strm); - - val = NEXT(); - val += (unsigned)NEXT() << 8; - val += (unsigned long)NEXT() << 16; - ch = NEXT(); - if (ch == -1) - return -1; - val += (unsigned long)ch << 24; - *ret = val; - return 0; -} - -/* Look for gzip header, set up for inflate or copy. state->have must be zero. +/* Look for gzip header, set up for inflate or copy. state->x.have must be 0. If this is the first time in, allocate required memory. state->how will be left unchanged if there is no more input data available, will be set to COPY if there is no gzip header and direct copying will be performed, or it will - be set to GZIP for decompression, and the gzip header will be skipped so - that the next available input data is the raw deflate stream. If direct - copying, then leftover input data from the input buffer will be copied to - the output buffer. In that case, all further file reads will be directly to - either the output buffer or a user buffer. If decompressing, the inflate - state and the check value will be initialized. gz_head() will return 0 on - success or -1 on failure. Failures may include read errors or gzip header - errors. */ -local int gz_head(state) + be set to GZIP for decompression. If direct copying, then leftover input + data from the input buffer will be copied to the output buffer. In that + case, all further file reads will be directly to either the output buffer or + a user buffer. If decompressing, the inflate state will be initialized. + gz_look() will return 0 on success or -1 on failure. */ +local int gz_look(state) gz_statep state; { z_streamp strm = &(state->strm); - int flags; - unsigned len; /* allocate read buffers and inflate memory */ if (state->size == 0) { @@ -129,7 +108,7 @@ local int gz_head(state) state->strm.opaque = Z_NULL; state->strm.avail_in = 0; state->strm.next_in = Z_NULL; - if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */ + if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ free(state->out); free(state->in); state->size = 0; @@ -138,83 +117,45 @@ local int gz_head(state) } } - /* get some data in the input buffer */ - if (strm->avail_in == 0) { + /* get at least the magic bytes in the input buffer */ + if (strm->avail_in < 2) { if (gz_avail(state) == -1) return -1; if (strm->avail_in == 0) return 0; } - /* look for the gzip magic header bytes 31 and 139 */ - if (strm->next_in[0] == 31) { - strm->avail_in--; - strm->next_in++; - if (strm->avail_in == 0 && gz_avail(state) == -1) - return -1; - if (strm->avail_in && strm->next_in[0] == 139) { - /* we have a gzip header, woo hoo! */ - strm->avail_in--; - strm->next_in++; - - /* skip rest of header */ - if (NEXT() != 8) { /* compression method */ - gz_error(state, Z_DATA_ERROR, "unknown compression method"); - return -1; - } - flags = NEXT(); - if (flags & 0xe0) { /* reserved flag bits */ - gz_error(state, Z_DATA_ERROR, "unknown header flags set"); - return -1; - } - NEXT(); /* modification time */ - NEXT(); - NEXT(); - NEXT(); - NEXT(); /* extra flags */ - NEXT(); /* operating system */ - if (flags & 4) { /* extra field */ - len = (unsigned)NEXT(); - len += (unsigned)NEXT() << 8; - while (len--) - if (NEXT() < 0) - break; - } - if (flags & 8) /* file name */ - while (NEXT() > 0) - ; - if (flags & 16) /* comment */ - while (NEXT() > 0) - ; - if (flags & 2) { /* header crc */ - NEXT(); - NEXT(); - } - /* an unexpected end of file is not checked for here -- it will be - noticed on the first request for uncompressed data */ - - /* set up for decompression */ - inflateReset(strm); - strm->adler = crc32(0L, Z_NULL, 0); - state->how = GZIP; - state->direct = 0; - return 0; - } - else { - /* not a gzip file -- save first byte (31) and fall to raw i/o */ - state->out[0] = 31; - state->have = 1; - } + /* look for gzip magic bytes -- if there, do gzip decoding (note: there is + a logical dilemma here when considering the case of a partially written + gzip file, to wit, if a single 31 byte is written, then we cannot tell + whether this is a single-byte file, or just a partially written gzip + file -- for here we assume that if a gzip file is being written, then + the header will be written in a single operation, so that reading a + single byte is sufficient indication that it is not a gzip file) */ + if (strm->avail_in > 1 && + strm->next_in[0] == 31 && strm->next_in[1] == 139) { + inflateReset(strm); + state->how = GZIP; + state->direct = 0; + return 0; + } + + /* no gzip header -- if we were decoding gzip before, then this is trailing + garbage. Ignore the trailing garbage and finish. */ + if (state->direct == 0) { + strm->avail_in = 0; + state->eof = 1; + state->x.have = 0; + return 0; } - /* doing raw i/o, save start of raw data for seeking, copy any leftover - input to output -- this assumes that the output buffer is larger than - the input buffer, which also assures space for gzungetc() */ - state->raw = state->pos; - state->next = state->out; + /* doing raw i/o, copy any leftover input to output -- this assumes that + the output buffer is larger than the input buffer, which also assures + space for gzungetc() */ + state->x.next = state->out; if (strm->avail_in) { - memcpy(state->next + state->have, strm->next_in, strm->avail_in); - state->have += strm->avail_in; + memcpy(state->x.next, strm->next_in, strm->avail_in); + state->x.have = strm->avail_in; strm->avail_in = 0; } state->how = COPY; @@ -223,19 +164,15 @@ local int gz_head(state) } /* Decompress from input to the provided next_out and avail_out in the state. - If the end of the compressed data is reached, then verify the gzip trailer - check value and length (modulo 2^32). state->have and state->next are set - to point to the just decompressed data, and the crc is updated. If the - trailer is verified, state->how is reset to LOOK to look for the next gzip - stream or raw data, once state->have is depleted. Returns 0 on success, -1 - on failure. Failures may include invalid compressed data or a failed gzip - trailer verification. */ + On return, state->x.have and state->x.next point to the just decompressed + data. If the gzip stream completes, state->how is reset to LOOK to look for + the next gzip stream or raw data, once state->x.have is depleted. Returns 0 + on success, -1 on failure. */ local int gz_decomp(state) gz_statep state; { - int ret; + int ret = Z_OK; unsigned had; - unsigned long crc, len; z_streamp strm = &(state->strm); /* fill output buffer up to end of deflate stream */ @@ -245,15 +182,15 @@ local int gz_decomp(state) if (strm->avail_in == 0 && gz_avail(state) == -1) return -1; if (strm->avail_in == 0) { - gz_error(state, Z_DATA_ERROR, "unexpected end of file"); - return -1; + gz_error(state, Z_BUF_ERROR, "unexpected end of file"); + break; } /* decompress and handle errors */ ret = inflate(strm, Z_NO_FLUSH); if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { gz_error(state, Z_STREAM_ERROR, - "internal error: inflate stream corrupt"); + "internal error: inflate stream corrupt"); return -1; } if (ret == Z_MEM_ERROR) { @@ -262,67 +199,55 @@ local int gz_decomp(state) } if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ gz_error(state, Z_DATA_ERROR, - strm->msg == NULL ? "compressed data error" : strm->msg); + strm->msg == NULL ? "compressed data error" : strm->msg); return -1; } } while (strm->avail_out && ret != Z_STREAM_END); - /* update available output and crc check value */ - state->have = had - strm->avail_out; - state->next = strm->next_out - state->have; - strm->adler = crc32(strm->adler, state->next, state->have); + /* update available output */ + state->x.have = had - strm->avail_out; + state->x.next = strm->next_out - state->x.have; - /* check gzip trailer if at end of deflate stream */ - if (ret == Z_STREAM_END) { - if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) { - gz_error(state, Z_DATA_ERROR, "unexpected end of file"); - return -1; - } - if (crc != strm->adler) { - gz_error(state, Z_DATA_ERROR, "incorrect data check"); - return -1; - } - if (len != (strm->total_out & 0xffffffffL)) { - gz_error(state, Z_DATA_ERROR, "incorrect length check"); - return -1; - } - state->how = LOOK; /* ready for next stream, once have is 0 (leave - state->direct unchanged to remember how) */ - } + /* if the gzip stream completed successfully, look for another */ + if (ret == Z_STREAM_END) + state->how = LOOK; /* good decompression */ return 0; } -/* Make data and put in the output buffer. Assumes that state->have == 0. +/* Fetch data and put it in the output buffer. Assumes state->x.have is 0. Data is either copied from the input file or decompressed from the input file depending on state->how. If state->how is LOOK, then a gzip header is - looked for (and skipped if found) to determine wither to copy or decompress. - Returns -1 on error, otherwise 0. gz_make() will leave state->have as COPY - or GZIP unless the end of the input file has been reached and all data has - been processed. */ -local int gz_make(state) + looked for to determine whether to copy or decompress. Returns -1 on error, + otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the + end of the input file has been reached and all data has been processed. */ +local int gz_fetch(state) gz_statep state; { z_streamp strm = &(state->strm); - if (state->how == LOOK) { /* look for gzip header */ - if (gz_head(state) == -1) - return -1; - if (state->have) /* got some data from gz_head() */ + do { + switch(state->how) { + case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ + if (gz_look(state) == -1) + return -1; + if (state->how == LOOK) + return 0; + break; + case COPY: /* -> COPY */ + if (gz_load(state, state->out, state->size << 1, &(state->x.have)) + == -1) + return -1; + state->x.next = state->out; return 0; - } - if (state->how == COPY) { /* straight copy */ - if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1) - return -1; - state->next = state->out; - } - else if (state->how == GZIP) { /* decompress */ - strm->avail_out = state->size << 1; - strm->next_out = state->out; - if (gz_decomp(state) == -1) - return -1; - } + case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ + strm->avail_out = state->size << 1; + strm->next_out = state->out; + if (gz_decomp(state) == -1) + return -1; + } + } while (state->x.have == 0 && (!state->eof || strm->avail_in)); return 0; } @@ -336,12 +261,12 @@ local int gz_skip(state, len) /* skip over len bytes or reach end-of-file, whichever comes first */ while (len) /* skip over whatever is in output buffer */ - if (state->have) { - n = GT_OFF(state->have) || (z_off64_t)state->have > len ? - (unsigned)len : state->have; - state->have -= n; - state->next += n; - state->pos += n; + if (state->x.have) { + n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? + (unsigned)len : state->x.have; + state->x.have -= n; + state->x.next += n; + state->x.pos += n; len -= n; } @@ -352,7 +277,7 @@ local int gz_skip(state, len) /* need more data to skip -- load up output buffer */ else { /* get more output, looking for header if required */ - if (gz_make(state) == -1) + if (gz_fetch(state) == -1) return -1; } return 0; @@ -374,14 +299,15 @@ int ZEXPORT gzread(file, buf, len) state = (gz_statep)file; strm = &(state->strm); - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || state->err != Z_OK) + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* since an int is returned, make sure len fits in one, otherwise return with an error (this avoids the flaw in the interface) */ if ((int)len < 0) { - gz_error(state, Z_BUF_ERROR, "requested length does not fit in int"); + gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); return -1; } @@ -400,24 +326,26 @@ int ZEXPORT gzread(file, buf, len) got = 0; do { /* first just try copying data from the output buffer */ - if (state->have) { - n = state->have > len ? len : state->have; - memcpy(buf, state->next, n); - state->next += n; - state->have -= n; + if (state->x.have) { + n = state->x.have > len ? len : state->x.have; + memcpy(buf, state->x.next, n); + state->x.next += n; + state->x.have -= n; } /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && strm->avail_in == 0) + else if (state->eof && strm->avail_in == 0) { + state->past = 1; /* tried to read past end */ break; + } /* need output data -- for small len or new stream load up our output buffer */ else if (state->how == LOOK || len < (state->size << 1)) { /* get more output, looking for header if required */ - if (gz_make(state) == -1) + if (gz_fetch(state) == -1) return -1; - continue; /* no progress yet -- go back to memcpy() above */ + continue; /* no progress yet -- go back to copy above */ /* the copy above assures that we will leave with space in the output buffer, allowing at least one gzungetc() to succeed */ } @@ -434,15 +362,15 @@ int ZEXPORT gzread(file, buf, len) strm->next_out = buf; if (gz_decomp(state) == -1) return -1; - n = state->have; - state->have = 0; + n = state->x.have; + state->x.have = 0; } /* update progress */ len -= n; buf = (char *)buf + n; got += n; - state->pos += n; + state->x.pos += n; } while (len); /* return number of bytes read into user buffer (will fit in int) */ @@ -450,6 +378,7 @@ int ZEXPORT gzread(file, buf, len) } /* -- see zlib.h -- */ +#undef gzgetc int ZEXPORT gzgetc(file) gzFile file; { @@ -462,15 +391,16 @@ int ZEXPORT gzgetc(file) return -1; state = (gz_statep)file; - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || state->err != Z_OK) + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* try output buffer (no need to check for skip request) */ - if (state->have) { - state->have--; - state->pos++; - return *(state->next)++; + if (state->x.have) { + state->x.have--; + state->x.pos++; + return *(state->x.next)++; } /* nothing there -- try gzread() */ @@ -478,6 +408,12 @@ int ZEXPORT gzgetc(file) return ret < 1 ? -1 : buf[0]; } +int ZEXPORT gzgetc_(file) +gzFile file; +{ + return gzgetc(file); +} + /* -- see zlib.h -- */ int ZEXPORT gzungetc(c, file) int c; @@ -490,8 +426,9 @@ int ZEXPORT gzungetc(c, file) return -1; state = (gz_statep)file; - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || state->err != Z_OK) + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* process a skip request */ @@ -506,32 +443,34 @@ int ZEXPORT gzungetc(c, file) return -1; /* if output buffer empty, put byte at end (allows more pushing) */ - if (state->have == 0) { - state->have = 1; - state->next = state->out + (state->size << 1) - 1; - state->next[0] = c; - state->pos--; + if (state->x.have == 0) { + state->x.have = 1; + state->x.next = state->out + (state->size << 1) - 1; + state->x.next[0] = c; + state->x.pos--; + state->past = 0; return c; } /* if no room, give up (must have already done a gzungetc()) */ - if (state->have == (state->size << 1)) { - gz_error(state, Z_BUF_ERROR, "out of room to push characters"); + if (state->x.have == (state->size << 1)) { + gz_error(state, Z_DATA_ERROR, "out of room to push characters"); return -1; } /* slide output data if needed and insert byte before existing data */ - if (state->next == state->out) { - unsigned char *src = state->out + state->have; + if (state->x.next == state->out) { + unsigned char *src = state->out + state->x.have; unsigned char *dest = state->out + (state->size << 1); while (src > state->out) *--dest = *--src; - state->next = dest; + state->x.next = dest; } - state->have++; - state->next--; - state->next[0] = c; - state->pos--; + state->x.have++; + state->x.next--; + state->x.next[0] = c; + state->x.pos--; + state->past = 0; return c; } @@ -551,8 +490,9 @@ char * ZEXPORT gzgets(file, buf, len) return NULL; state = (gz_statep)file; - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || state->err != Z_OK) + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) return NULL; /* process a skip request */ @@ -569,32 +509,31 @@ char * ZEXPORT gzgets(file, buf, len) left = (unsigned)len - 1; if (left) do { /* assure that something is in the output buffer */ - if (state->have == 0) { - if (gz_make(state) == -1) - return NULL; /* error */ - if (state->have == 0) { /* end of file */ - if (buf == str) /* got bupkus */ - return NULL; - break; /* got something -- return it */ - } + if (state->x.have == 0 && gz_fetch(state) == -1) + return NULL; /* error */ + if (state->x.have == 0) { /* end of file */ + state->past = 1; /* read past end */ + break; /* return what we have */ } /* look for end-of-line in current output buffer */ - n = state->have > left ? left : state->have; - eol = memchr(state->next, '\n', n); + n = state->x.have > left ? left : state->x.have; + eol = memchr(state->x.next, '\n', n); if (eol != NULL) - n = (unsigned)(eol - state->next) + 1; + n = (unsigned)(eol - state->x.next) + 1; /* copy through end-of-line, or remainder if not found */ - memcpy(buf, state->next, n); - state->have -= n; - state->next += n; - state->pos += n; + memcpy(buf, state->x.next, n); + state->x.have -= n; + state->x.next += n; + state->x.pos += n; left -= n; buf += n; } while (left && eol == NULL); - /* found end-of-line or out of space -- terminate string and return it */ + /* return terminated string, or if nothing, end of file */ + if (buf == str) + return NULL; buf[0] = 0; return str; } @@ -610,16 +549,12 @@ int ZEXPORT gzdirect(file) return 0; state = (gz_statep)file; - /* check that we're reading */ - if (state->mode != GZ_READ) - return 0; - /* if the state is not known, but we can find out, then do so (this is mainly for right after a gzopen() or gzdopen()) */ - if (state->how == LOOK && state->have == 0) - (void)gz_head(state); + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) + (void)gz_look(state); - /* return 1 if reading direct, 0 if decompressing a gzip stream */ + /* return 1 if transparent, 0 if processing a gzip stream */ return state->direct; } @@ -627,7 +562,7 @@ int ZEXPORT gzdirect(file) int ZEXPORT gzclose_r(file) gzFile file; { - int ret; + int ret, err; gz_statep state; /* get internal structure */ @@ -645,9 +580,10 @@ int ZEXPORT gzclose_r(file) free(state->out); free(state->in); } + err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; gz_error(state, Z_OK, NULL); free(state->path); ret = close(state->fd); free(state); - return ret ? Z_ERRNO : Z_OK; + return ret ? Z_ERRNO : err; } diff --git a/dep/zlib/gzwrite.c b/dep/zlib/gzwrite.c index e8defc6887a..27cb3428e32 100644 --- a/dep/zlib/gzwrite.c +++ b/dep/zlib/gzwrite.c @@ -1,5 +1,5 @@ /* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004, 2005, 2010 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -18,44 +18,55 @@ local int gz_init(state) int ret; z_streamp strm = &(state->strm); - /* allocate input and output buffers */ + /* allocate input buffer */ state->in = malloc(state->want); - state->out = malloc(state->want); - if (state->in == NULL || state->out == NULL) { - if (state->out != NULL) - free(state->out); - if (state->in != NULL) - free(state->in); + if (state->in == NULL) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } - /* allocate deflate memory, set up for gzip compression */ - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; - ret = deflateInit2(strm, state->level, Z_DEFLATED, - 15 + 16, 8, state->strategy); - if (ret != Z_OK) { - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; + /* only need output buffer and deflate state if compressing */ + if (!state->direct) { + /* allocate output buffer */ + state->out = malloc(state->want); + if (state->out == NULL) { + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + + /* allocate deflate memory, set up for gzip compression */ + strm->zalloc = Z_NULL; + strm->zfree = Z_NULL; + strm->opaque = Z_NULL; + ret = deflateInit2(strm, state->level, Z_DEFLATED, + MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); + if (ret != Z_OK) { + free(state->out); + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } } /* mark state as initialized */ state->size = state->want; - /* initialize write buffer */ - strm->avail_out = state->size; - strm->next_out = state->out; - state->next = strm->next_out; + /* initialize write buffer if compressing */ + if (!state->direct) { + strm->avail_out = state->size; + strm->next_out = state->out; + state->x.next = strm->next_out; + } return 0; } /* Compress whatever is at avail_in and next_in and write to the output file. Return -1 if there is an error writing to the output file, otherwise 0. flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH, - then the deflate() state is reset to start a new gzip stream. */ + then the deflate() state is reset to start a new gzip stream. If gz->direct + is true, then simply write to the output file without compressing, and + ignore flush. */ local int gz_comp(state, flush) gz_statep state; int flush; @@ -68,6 +79,17 @@ local int gz_comp(state, flush) if (state->size == 0 && gz_init(state) == -1) return -1; + /* write directly if requested */ + if (state->direct) { + got = write(state->fd, strm->next_in, strm->avail_in); + if (got < 0 || (unsigned)got != strm->avail_in) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + strm->avail_in = 0; + return 0; + } + /* run deflate() on provided input until it produces no more output */ ret = Z_OK; do { @@ -75,8 +97,8 @@ local int gz_comp(state, flush) doing Z_FINISH then don't write until we get to Z_STREAM_END */ if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && (flush != Z_FINISH || ret == Z_STREAM_END))) { - have = (unsigned)(strm->next_out - state->next); - if (have && ((got = write(state->fd, state->next, have)) < 0 || + have = (unsigned)(strm->next_out - state->x.next); + if (have && ((got = write(state->fd, state->x.next, have)) < 0 || (unsigned)got != have)) { gz_error(state, Z_ERRNO, zstrerror()); return -1; @@ -85,7 +107,7 @@ local int gz_comp(state, flush) strm->avail_out = state->size; strm->next_out = state->out; } - state->next = strm->next_out; + state->x.next = strm->next_out; } /* compress */ @@ -131,7 +153,7 @@ local int gz_zero(state, len) } strm->avail_in = n; strm->next_in = state->in; - state->pos += n; + state->x.pos += n; if (gz_comp(state, Z_NO_FLUSH) == -1) return -1; len -= n; @@ -163,7 +185,7 @@ int ZEXPORT gzwrite(file, buf, len) /* since an int is returned, make sure len fits in one, otherwise return with an error (this avoids the flaw in the interface) */ if ((int)len < 0) { - gz_error(state, Z_BUF_ERROR, "requested length does not fit in int"); + gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); return 0; } @@ -193,7 +215,7 @@ int ZEXPORT gzwrite(file, buf, len) n = len; memcpy(strm->next_in + strm->avail_in, buf, n); strm->avail_in += n; - state->pos += n; + state->x.pos += n; buf = (char *)buf + n; len -= n; if (len && gz_comp(state, Z_NO_FLUSH) == -1) @@ -208,7 +230,7 @@ int ZEXPORT gzwrite(file, buf, len) /* directly compress user buffer to file */ strm->avail_in = len; strm->next_in = (voidp)buf; - state->pos += len; + state->x.pos += len; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0; } @@ -249,15 +271,15 @@ int ZEXPORT gzputc(file, c) if (strm->avail_in == 0) strm->next_in = state->in; strm->next_in[strm->avail_in++] = c; - state->pos++; - return c; + state->x.pos++; + return c & 0xff; } /* no room in buffer or not initialized, use gz_write() */ buf[0] = c; if (gzwrite(file, buf, 1) != 1) return -1; - return c; + return c & 0xff; } /* -- see zlib.h -- */ @@ -274,7 +296,7 @@ int ZEXPORT gzputs(file, str) return ret == 0 && len != 0 ? -1 : ret; } -#ifdef STDC +#if defined(STDC) || defined(Z_HAVE_STDARG_H) #include <stdarg.h> /* -- see zlib.h -- */ @@ -316,19 +338,19 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) va_start(va, format); #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void - (void)vsprintf(state->in, format, va); + (void)vsprintf((char *)(state->in), format, va); va_end(va); for (len = 0; len < size; len++) if (state->in[len] == 0) break; # else - len = vsprintf(state->in, format, va); + len = vsprintf((char *)(state->in), format, va); va_end(va); # endif #else # ifdef HAS_vsnprintf_void - (void)vsnprintf(state->in, size, format, va); + (void)vsnprintf((char *)(state->in), size, format, va); va_end(va); - len = strlen(state->in); + len = strlen((char *)(state->in)); # else len = vsnprintf((char *)(state->in), size, format, va); va_end(va); @@ -342,11 +364,11 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) /* update buffer and position, defer compression until needed */ strm->avail_in = (unsigned)len; strm->next_in = state->in; - state->pos += len; + state->x.pos += len; return len; } -#else /* !STDC */ +#else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, @@ -366,6 +388,10 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, state = (gz_statep)file; strm = &(state->strm); + /* check that can really pass pointer in ints */ + if (sizeof(int) != sizeof(void *)) + return 0; + /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return 0; @@ -390,22 +416,23 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, state->in[size - 1] = 0; #ifdef NO_snprintf # ifdef HAS_sprintf_void - sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, + sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); for (len = 0; len < size; len++) if (state->in[len] == 0) break; # else - len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #else # ifdef HAS_snprintf_void - snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, + snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(state->in); + len = strlen((char *)(state->in)); # else - len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, + a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, + a19, a20); # endif #endif @@ -416,7 +443,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, /* update buffer and position, defer compression until needed */ strm->avail_in = (unsigned)len; strm->next_in = state->in; - state->pos += len; + state->x.pos += len; return len; } @@ -500,7 +527,7 @@ int ZEXPORT gzsetparams(file, level, strategy) int ZEXPORT gzclose_w(file) gzFile file; { - int ret = 0; + int ret = Z_OK; gz_statep state; /* get internal structure */ @@ -515,17 +542,24 @@ int ZEXPORT gzclose_w(file) /* check for seek request */ if (state->seek) { state->seek = 0; - ret += gz_zero(state, state->skip); + if (gz_zero(state, state->skip) == -1) + ret = state->err; } /* flush, free memory, and close file */ - ret += gz_comp(state, Z_FINISH); - (void)deflateEnd(&(state->strm)); - free(state->out); - free(state->in); + if (state->size) { + if (gz_comp(state, Z_FINISH) == -1) + ret = state->err; + if (!state->direct) { + (void)deflateEnd(&(state->strm)); + free(state->out); + } + free(state->in); + } gz_error(state, Z_OK, NULL); free(state->path); - ret += close(state->fd); + if (close(state->fd) == -1) + ret = Z_ERRNO; free(state); - return ret ? Z_ERRNO : Z_OK; + return ret; } diff --git a/dep/zlib/infback.c b/dep/zlib/infback.c index af3a8c965d5..981aff17c2d 100644 --- a/dep/zlib/infback.c +++ b/dep/zlib/infback.c @@ -1,5 +1,5 @@ /* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2009 Mark Adler + * Copyright (C) 1995-2011 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -42,10 +42,19 @@ int stream_size; return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; +#endif } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif state = (struct inflate_state FAR *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; @@ -394,7 +403,6 @@ void FAR *out_desc; PULLBYTE(); } if (here.val < 16) { - NEEDBITS(here.bits); DROPBITS(here.bits); state->lens[state->have++] = here.val; } diff --git a/dep/zlib/inffixed.h b/dep/zlib/inffixed.h index 75ed4b5978d..d6283277694 100644 --- a/dep/zlib/inffixed.h +++ b/dep/zlib/inffixed.h @@ -2,9 +2,9 @@ * Generated automatically by makefixed(). */ - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. + /* WARNING: this file should *not* be used by applications. + It is part of the implementation of this library and is + subject to change. Applications should only use zlib.h. */ static const code lenfix[512] = { diff --git a/dep/zlib/inflate.c b/dep/zlib/inflate.c index a8431abeacf..47418a1e1e1 100644 --- a/dep/zlib/inflate.c +++ b/dep/zlib/inflate.c @@ -1,5 +1,5 @@ /* inflate.c -- zlib decompression - * Copyright (C) 1995-2010 Mark Adler + * Copyright (C) 1995-2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -100,7 +100,7 @@ local int updatewindow OF((z_streamp strm, unsigned out)); local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, unsigned len)); -int ZEXPORT inflateReset(strm) +int ZEXPORT inflateResetKeep(strm) z_streamp strm; { struct inflate_state FAR *state; @@ -109,15 +109,13 @@ z_streamp strm; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; - strm->adler = 1; /* to support ill-conceived Java test suite */ + if (state->wrap) /* to support ill-conceived Java test suite */ + strm->adler = state->wrap & 1; state->mode = HEAD; state->last = 0; state->havedict = 0; state->dmax = 32768U; state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->wnext = 0; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; @@ -127,6 +125,19 @@ z_streamp strm; return Z_OK; } +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + state->wsize = 0; + state->whave = 0; + state->wnext = 0; + return inflateResetKeep(strm); +} + int ZEXPORT inflateReset2(strm, windowBits) z_streamp strm; int windowBits; @@ -180,10 +191,19 @@ int stream_size; if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; +#endif } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif state = (struct inflate_state FAR *) ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; @@ -321,8 +341,8 @@ void makefixed() low = 0; for (;;) { if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, - state.lencode[low].val); + printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, + state.lencode[low].bits, state.lencode[low].val); if (++low == size) break; putchar(','); } @@ -499,11 +519,6 @@ unsigned out; bits -= bits & 7; \ } while (0) -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - /* inflate() uses a state machine to process as much input data and generate as much output data as possible before returning. The state machine is @@ -797,7 +812,7 @@ int flush; #endif case DICTID: NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); + strm->adler = state->check = ZSWAP32(hold); INITBITS(); state->mode = DICT; case DICT: @@ -925,7 +940,6 @@ int flush; PULLBYTE(); } if (here.val < 16) { - NEEDBITS(here.bits); DROPBITS(here.bits); state->lens[state->have++] = here.val; } @@ -1170,7 +1184,7 @@ int flush; #ifdef GUNZIP state->flags ? hold : #endif - REVERSE(hold)) != state->check) { + ZSWAP32(hold)) != state->check) { strm->msg = (char *)"incorrect data check"; state->mode = BAD; break; @@ -1214,7 +1228,8 @@ int flush; */ inf_leave: RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) + if (state->wsize || (out != strm->avail_out && state->mode < BAD && + (state->mode < CHECK || flush != Z_FINISH))) if (updatewindow(strm, out)) { state->mode = MEM; return Z_MEM_ERROR; @@ -1255,7 +1270,10 @@ const Bytef *dictionary; uInt dictLength; { struct inflate_state FAR *state; - unsigned long id; + unsigned long dictid; + unsigned char *next; + unsigned avail; + int ret; /* check state */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; @@ -1263,29 +1281,27 @@ uInt dictLength; if (state->wrap != 0 && state->mode != DICT) return Z_STREAM_ERROR; - /* check for correct dictionary id */ + /* check for correct dictionary identifier */ if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) + dictid = adler32(0L, Z_NULL, 0); + dictid = adler32(dictid, dictionary, dictLength); + if (dictid != state->check) return Z_DATA_ERROR; } - /* copy dictionary to window */ - if (updatewindow(strm, strm->avail_out)) { + /* copy dictionary to window using updatewindow(), which will amend the + existing dictionary if appropriate */ + next = strm->next_out; + avail = strm->avail_out; + strm->next_out = (Bytef *)dictionary + dictLength; + strm->avail_out = 0; + ret = updatewindow(strm, dictLength); + strm->avail_out = avail; + strm->next_out = next; + if (ret) { state->mode = MEM; return Z_MEM_ERROR; } - if (dictLength > state->wsize) { - zmemcpy(state->window, dictionary + dictLength - state->wsize, - state->wsize); - state->whave = state->wsize; - } - else { - zmemcpy(state->window + state->wsize - dictLength, dictionary, - dictLength); - state->whave = dictLength; - } state->havedict = 1; Tracev((stderr, "inflate: dictionary set\n")); return Z_OK; @@ -1433,8 +1449,8 @@ z_streamp source; } /* copy state */ - zmemcpy(dest, source, sizeof(z_stream)); - zmemcpy(copy, state, sizeof(struct inflate_state)); + zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); + zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); diff --git a/dep/zlib/inftrees.c b/dep/zlib/inftrees.c index 11e9c52accb..abcd7c45ed3 100644 --- a/dep/zlib/inftrees.c +++ b/dep/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2010 Mark Adler + * Copyright (C) 1995-2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.5 Copyright 1995-2010 Mark Adler "; + " inflate 1.2.7 Copyright 1995-2012 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -62,7 +62,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, @@ -289,38 +289,14 @@ unsigned short FAR *work; } } - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)(len - drop); - here.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - here.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = here; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; + /* fill in remaining table entry if code is incomplete (guaranteed to have + at most one remaining entry, since if the code is incomplete, the + maximum code length that was allowed to get this far is one bit) */ + if (huff != 0) { + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)(len - drop); + here.val = (unsigned short)0; + next[huff] = here; } /* set return parameters */ diff --git a/dep/zlib/trees.c b/dep/zlib/trees.c index 56e9bb1c115..8c32b214b1d 100644 --- a/dep/zlib/trees.c +++ b/dep/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2010 Jean-loup Gailly + * Copyright (C) 1995-2012 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -74,11 +74,6 @@ local const uch bl_order[BL_CODES] * probability, to avoid transmitting the lengths for unused bit length codes. */ -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - /* =========================================================================== * Local data. These are initialized only once. */ @@ -399,7 +394,6 @@ void ZLIB_INTERNAL _tr_init(s) s->bi_buf = 0; s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ #ifdef DEBUG s->compressed_len = 0L; s->bits_sent = 0L; @@ -883,15 +877,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) } /* =========================================================================== + * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) + */ +void ZLIB_INTERNAL _tr_flush_bits(s) + deflate_state *s; +{ + bi_flush(s); +} + +/* =========================================================================== * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. */ void ZLIB_INTERNAL _tr_align(s) deflate_state *s; @@ -902,20 +898,6 @@ void ZLIB_INTERNAL _tr_align(s) s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ #endif bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; } /* =========================================================================== @@ -1118,7 +1100,6 @@ local void compress_block(s, ltree, dtree) } while (lx < s->last_lit); send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; } /* =========================================================================== @@ -1226,7 +1207,6 @@ local void copy_block(s, buf, len, header) int header; /* true if block header must be written */ { bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ if (header) { put_short(s, (ush)len); diff --git a/dep/zlib/zconf.h b/dep/zlib/zconf.h index 02ce56c4313..8a46a58b30c 100644 --- a/dep/zlib/zconf.h +++ b/dep/zlib/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2010 Jean-loup Gailly. + * Copyright (C) 1995-2012 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,6 +15,7 @@ * this permanently in zconf.h using "./configure --zprefix". */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET /* all linked symbols */ # define _dist_code z__dist_code @@ -27,9 +28,11 @@ # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 @@ -40,44 +43,52 @@ # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams +# define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzgetc z_gzgetc -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzwrite z_gzwrite +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# endif # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd @@ -95,13 +106,18 @@ # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table -# define uncompress z_uncompress +# ifndef Z_SOLO +# define uncompress z_uncompress +# endif # define zError z_zError -# define zcalloc z_zcalloc -# define zcfree z_zcfree +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif # define zlibCompileFlags z_zlibCompileFlags # define zlibVersion z_zlibVersion @@ -111,7 +127,9 @@ # define alloc_func z_alloc_func # define charf z_charf # define free_func z_free_func -# define gzFile z_gzFile +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif # define gz_header z_gz_header # define gz_headerp z_gz_headerp # define in_func z_in_func @@ -197,6 +215,12 @@ # endif #endif +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) # define NO_DUMMY_DECL @@ -243,6 +267,14 @@ # endif #endif +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have @@ -356,12 +388,45 @@ typedef uLong FAR uLongf; typedef Byte *voidp; #endif +/* ./configure may #define Z_U4 here */ + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include <limits.h> +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# else +# if (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# else +# if (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +# endif +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + #ifdef STDC -# include <sys/types.h> /* for off_t */ +# ifndef Z_SOLO +# include <sys/types.h> /* for off_t */ +# endif +#endif + +#ifdef _WIN32 +# include <stddef.h> /* for wchar_t */ #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and @@ -370,21 +435,38 @@ typedef uLong FAR uLongf; * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * equivalently requesting no 64-bit operations */ -#if -_LARGEFILE64_SOURCE - -1 == 1 +#if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif -#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include <unistd.h> /* for SEEK_* and off_t */ -# ifdef VMS -# include <unixio.h> /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE) +# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include <unixio.h> /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif # endif #endif -#ifndef SEEK_SET +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ @@ -394,18 +476,14 @@ typedef uLong FAR uLongf; # define z_off_t long #endif -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +#if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else -# define z_off64_t z_off_t -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif #endif /* MVS linker does not support external names larger than 8 bytes */ diff --git a/dep/zlib/zlib.h b/dep/zlib/zlib.h index bfbba83e8ee..3edf3acdb57 100644 --- a/dep/zlib/zlib.h +++ b/dep/zlib/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.5, April 19th, 2010 + version 1.2.7, May 2nd, 2012 - Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -24,8 +24,8 @@ The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). */ #ifndef ZLIB_H @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.5" -#define ZLIB_VERNUM 0x1250 +#define ZLIB_VERSION "1.2.7" +#define ZLIB_VERNUM 0x1270 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_REVISION 7 #define ZLIB_VER_SUBREVISION 0 /* @@ -83,15 +83,15 @@ typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ + z_const Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ + uLong total_in; /* total number of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ + uLong total_out; /* total number of bytes output so far */ - char *msg; /* last error message, NULL if no error */ + z_const char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ @@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); 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 the - value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. + value returned by deflateBound (see below). Then deflate is guaranteed to + return Z_STREAM_END. If not enough output space is provided, deflate will + not return Z_STREAM_END, and it must be called again as described above. deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). @@ -451,23 +452,29 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all the uncompressed data. (The size - of the uncompressed data may have been saved by the compressor for this - purpose.) The next operation on this stream must be inflateEnd to deallocate - the decompression state. The use of Z_FINISH is never required, but can be - used to inform inflate that a faster approach may be used for the single - inflate() call. + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK or Z_TREES is used. + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH is used. If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary + below), inflate sets strm->adler to the Adler-32 checksum of the 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, + strm->adler to the Adler-32 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() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END @@ -478,7 +485,9 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); initializing with inflateInit2(). Any information contained in the gzip header is not retained, so applications that need that information should instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. + perform their own processing of the gzip header and trailer. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + producted so far. The CRC-32 is checked against the gzip trailer. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has @@ -580,10 +589,15 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, uInt dictLength)); /* Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any call - of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The + compressor and decompressor must use exactly the same dictionary (see + inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly @@ -610,8 +624,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, @@ -688,8 +702,28 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, deflation of sourceLen bytes. It must be called after deflateInit() or deflateInit2(), and after deflateSetHeader(), if used. This would be used to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). -*/ + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, + unsigned *pending, + int *bits)); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, @@ -703,8 +737,9 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, than or equal to 16, and that many of the least significant bits of value will be inserted in the output. - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, @@ -790,10 +825,11 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the adler32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. The application must insure that the dictionary + that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is @@ -805,17 +841,21 @@ 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 + Skips invalid compressed data until a possible full flush point (see above + for the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been - found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the - success case, the application may save the current current value of total_in - which indicates where valid compressed data was found. In the error case, - the application may repeatedly call inflateSync, providing more input each - time, until success or end of the input data. + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible full flush point has been found, + Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point + has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. + In the success case, the application may save the current current value of + total_in which indicates where valid compressed data was found. In the + error case, the application may repeatedly call inflateSync, providing more + input each time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, @@ -962,7 +1002,7 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + the parameters are invalid, Z_MEM_ERROR if the internal state could not be allocated, or Z_VERSION_ERROR if the version of the library does not match the version of the header file. */ @@ -1088,6 +1128,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 27-31: 0 (reserved) */ +#ifndef Z_SOLO /* utility functions */ @@ -1149,10 +1190,11 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. */ - /* gzip file access functions */ /* @@ -1162,7 +1204,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, wrapper, documented in RFC 1952, wrapped around a deflate stream. */ -typedef voidp gzFile; /* opaque gzip file descriptor */ +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); @@ -1172,13 +1214,28 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) Also "a" - can be used instead of "w" to request that the gzip stream that will be - written be appended to the file. "+" will result in an error, since reading - and writing to the same gzip file is not supported. + deflateInit2 for more information about the strategy parameter.) 'T' will + request transparent writing or appending with no compression and not using + the gzip format. + + "a" can be used instead of "w" to request that the gzip stream that will + be written be appended to the file. "+" will result in an error, since + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. gzopen returns NULL if the file could not be opened, if there was insufficient memory to allocate the gzFile state, or if an invalid mode was @@ -1197,7 +1254,11 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. + gzdopen does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. gzdopen returns NULL if there was insufficient memory to allocate the gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not @@ -1235,14 +1296,26 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); /* Reads the given number of uncompressed bytes from the compressed file. If - the input file was not in gzip format, gzread copies the given number of - bytes into the buffer. + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream, or failing that, reading the rest - of the input file directly without decompression. The entire input file - will be read if gzread is called until it returns less than the requested - len. + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. gzread returns the number of uncompressed bytes actually read, less than len for end of file, or -1 for error. @@ -1256,7 +1329,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, error. */ -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); /* Converts, formats, and writes the arguments to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of @@ -1301,7 +1374,10 @@ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. */ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); @@ -1397,9 +1473,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); /* Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. This state can change from - false to true while reading the input file if the end of a gzip stream is - reached, but is followed by data that is not another gzip stream. + (0) if file is a gzip stream being decompressed. If the input file is empty, gzdirect() will return true, since the input does not contain a gzip stream. @@ -1408,6 +1482,13 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); cause buffers to be allocated to allow reading the file to determine if it is a gzip file. Therefore if gzbuffer() is used, it should be called before gzdirect(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) */ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); @@ -1419,7 +1500,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); must not be called more than once on the same allocation. gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, or Z_OK on success. + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. */ ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); @@ -1457,6 +1539,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); file that is being written concurrently. */ +#endif /* !Z_SOLO */ /* checksum functions */ @@ -1492,16 +1575,17 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. */ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the for the crc. Pre- and post-conditioning (one's - complement) is performed within this function so it shouldn't be done by the - application. + initial value for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. Usage example: @@ -1544,17 +1628,42 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); #define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) #define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) + ZLIB_VERSION, (int)sizeof(z_stream)) + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#endif /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if @@ -1562,7 +1671,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, * functions are changed to 64 bits) -- in case these are set on systems * without large file support, _LFS64_LARGEFILE must also be true */ -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +#ifdef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); @@ -1571,14 +1680,23 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); #endif -#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# ifdef _LARGEFILE64_SOURCE +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# endif +# ifndef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); @@ -1595,6 +1713,13 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); #endif +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + +#endif /* !Z_SOLO */ + /* hack for buggy compilers */ #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; @@ -1603,8 +1728,14 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, /* undocumented functions */ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); +ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, + const char *mode)); +#endif #ifdef __cplusplus } diff --git a/dep/zlib/zutil.c b/dep/zlib/zutil.c index 898ed345b0e..65e0d3b72b0 100644 --- a/dep/zlib/zutil.c +++ b/dep/zlib/zutil.c @@ -1,11 +1,14 @@ /* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005, 2010 Jean-loup Gailly. + * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" +#ifndef Z_SOLO +# include "gzguts.h" +#endif #ifndef NO_DUMMY_DECL struct internal_state {int dummy;}; /* for buggy compilers */ @@ -85,27 +88,27 @@ uLong ZEXPORT zlibCompileFlags() #ifdef FASTEST flags += 1L << 21; #endif -#ifdef STDC +#if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifdef NO_vsnprintf - flags += 1L << 25; + flags += 1L << 25; # ifdef HAS_vsprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # endif #else - flags += 1L << 24; + flags += 1L << 24; # ifdef NO_snprintf - flags += 1L << 25; + flags += 1L << 25; # ifdef HAS_sprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # endif #endif @@ -181,6 +184,7 @@ void ZLIB_INTERNAL zmemzero(dest, len) } #endif +#ifndef Z_SOLO #ifdef SYS16BIT @@ -316,3 +320,5 @@ void ZLIB_INTERNAL zcfree (opaque, ptr) } #endif /* MY_ZCALLOC */ + +#endif /* !Z_SOLO */ diff --git a/dep/zlib/zutil.h b/dep/zlib/zutil.h index 258fa88799a..4e3dcc6ae9f 100644 --- a/dep/zlib/zutil.h +++ b/dep/zlib/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2010 Jean-loup Gailly. + * Copyright (C) 1995-2012 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -13,7 +13,7 @@ #ifndef ZUTIL_H #define ZUTIL_H -#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) +#ifdef HAVE_HIDDEN # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL @@ -21,7 +21,7 @@ #include "zlib.h" -#ifdef STDC +#if defined(STDC) && !defined(Z_SOLO) # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) # include <stddef.h> # endif @@ -29,6 +29,10 @@ # include <stdlib.h> #endif +#ifdef Z_SOLO + typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ +#endif + #ifndef local # define local static #endif @@ -78,16 +82,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) # define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include <alloc.h> +# ifndef Z_SOLO +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include <alloc.h> +# endif +# else /* MSC or DJGPP */ +# include <malloc.h> # endif -# else /* MSC or DJGPP */ -# include <malloc.h> # endif #endif @@ -107,18 +113,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #ifdef OS2 # define OS_CODE 0x06 -# ifdef M_I86 +# if defined(M_I86) && !defined(Z_SOLO) # include <malloc.h> # endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include <unix.h> /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef Z_SOLO +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include <unix.h> /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif # endif # endif #endif @@ -153,14 +161,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#if defined(__BORLANDC__) +#if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 #pragma warn -8066 #endif /* provide prototypes for these when building zlib without LFS */ -#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 +#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); #endif @@ -177,42 +185,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* functions */ -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) +#if defined(pyr) || defined(Z_SOLO) # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) @@ -261,14 +234,19 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define Tracecv(c,x) #endif - -voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); -void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); +#ifndef Z_SOLO + voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, + unsigned size)); + void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); +#endif #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} +/* Reverse the bytes in a 32-bit value */ +#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + #endif /* ZUTIL_H */ diff --git a/doc/gpl-2.0.txt b/doc/GPL-2.0.txt index d159169d105..d159169d105 100644 --- a/doc/gpl-2.0.txt +++ b/doc/GPL-2.0.txt diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index bbd5a70e933..d2ec0a94a2b 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -1129,7 +1129,7 @@ DROP TABLE IF EXISTS `characters`; CREATE TABLE `characters` ( `guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier', `account` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Account Identifier', - `name` varchar(12) NOT NULL DEFAULT '', + `name` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `race` tinyint(3) unsigned NOT NULL DEFAULT '0', `class` tinyint(3) unsigned NOT NULL DEFAULT '0', `gender` tinyint(3) unsigned NOT NULL DEFAULT '0', @@ -2276,4 +2276,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2012-03-25 21:14:19 +-- Dump completed on 2012-09-08 15:27:29 diff --git a/sql/updates/characters/2012_06_13_00_characters_character_equipmentsets.sql b/sql/old/3.3.5a/2012_06_13_00_characters_character_equipmentsets.sql index ebf12062be3..ebf12062be3 100644 --- a/sql/updates/characters/2012_06_13_00_characters_character_equipmentsets.sql +++ b/sql/old/3.3.5a/2012_06_13_00_characters_character_equipmentsets.sql diff --git a/sql/updates/world/2012_07_12_00_world_version.sql b/sql/old/3.3.5a/2012_07_12_00_world_version.sql index ce24fa54614..ce24fa54614 100644 --- a/sql/updates/world/2012_07_12_00_world_version.sql +++ b/sql/old/3.3.5a/2012_07_12_00_world_version.sql diff --git a/sql/updates/world/2012_07_13_00_world_spell_proc_event.sql b/sql/old/3.3.5a/2012_07_13_00_world_spell_proc_event.sql index 952a4502b30..952a4502b30 100644 --- a/sql/updates/world/2012_07_13_00_world_spell_proc_event.sql +++ b/sql/old/3.3.5a/2012_07_13_00_world_spell_proc_event.sql diff --git a/sql/updates/world/2012_07_13_00_world_spell_script_names.sql b/sql/old/3.3.5a/2012_07_13_00_world_spell_script_names.sql index 64500418871..64500418871 100644 --- a/sql/updates/world/2012_07_13_00_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_07_13_00_world_spell_script_names.sql diff --git a/sql/updates/world/2012_07_14_00_world_creature_loot_template.sql b/sql/old/3.3.5a/2012_07_14_00_world_creature_loot_template.sql index f76e5519594..f76e5519594 100644 --- a/sql/updates/world/2012_07_14_00_world_creature_loot_template.sql +++ b/sql/old/3.3.5a/2012_07_14_00_world_creature_loot_template.sql diff --git a/sql/updates/world/2012_07_14_01_world_creature_loot_template.sql b/sql/old/3.3.5a/2012_07_14_01_world_creature_loot_template.sql index 1b9c4f4448c..1b9c4f4448c 100644 --- a/sql/updates/world/2012_07_14_01_world_creature_loot_template.sql +++ b/sql/old/3.3.5a/2012_07_14_01_world_creature_loot_template.sql diff --git a/sql/updates/world/2012_07_16_00_world_creature_template.sql b/sql/old/3.3.5a/2012_07_16_00_world_creature_template.sql index 7ce7c546592..7ce7c546592 100644 --- a/sql/updates/world/2012_07_16_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_07_16_00_world_creature_template.sql diff --git a/sql/updates/world/2012_07_16_01_world_reference_loot_template.sql b/sql/old/3.3.5a/2012_07_16_01_world_reference_loot_template.sql index e56dff3b0ea..e56dff3b0ea 100644 --- a/sql/updates/world/2012_07_16_01_world_reference_loot_template.sql +++ b/sql/old/3.3.5a/2012_07_16_01_world_reference_loot_template.sql diff --git a/sql/updates/world/2012_07_22_00_world_spelldifficulty_dbc.sql b/sql/old/3.3.5a/2012_07_22_00_world_spelldifficulty_dbc.sql index c90c42692b9..c90c42692b9 100644 --- a/sql/updates/world/2012_07_22_00_world_spelldifficulty_dbc.sql +++ b/sql/old/3.3.5a/2012_07_22_00_world_spelldifficulty_dbc.sql diff --git a/sql/updates/world/2012_07_22_01_world_conditions.sql b/sql/old/3.3.5a/2012_07_22_01_world_conditions.sql index 333ae7f997f..333ae7f997f 100644 --- a/sql/updates/world/2012_07_22_01_world_conditions.sql +++ b/sql/old/3.3.5a/2012_07_22_01_world_conditions.sql diff --git a/sql/updates/world/2012_07_22_02_world_creature_loot_template.sql b/sql/old/3.3.5a/2012_07_22_02_world_creature_loot_template.sql index e4bc61b6fa4..e4bc61b6fa4 100644 --- a/sql/updates/world/2012_07_22_02_world_creature_loot_template.sql +++ b/sql/old/3.3.5a/2012_07_22_02_world_creature_loot_template.sql diff --git a/sql/updates/world/2012_07_22_03_world_gossip.sql b/sql/old/3.3.5a/2012_07_22_03_world_gossip.sql index d1aa7e50747..d1aa7e50747 100644 --- a/sql/updates/world/2012_07_22_03_world_gossip.sql +++ b/sql/old/3.3.5a/2012_07_22_03_world_gossip.sql diff --git a/sql/updates/world/2012_07_22_04_world_gossip.sql b/sql/old/3.3.5a/2012_07_22_04_world_gossip.sql index 0fbf2e7508f..0fbf2e7508f 100644 --- a/sql/updates/world/2012_07_22_04_world_gossip.sql +++ b/sql/old/3.3.5a/2012_07_22_04_world_gossip.sql diff --git a/sql/updates/world/2012_07_22_05_world_script_texts.sql b/sql/old/3.3.5a/2012_07_22_05_world_script_texts.sql index 2ecb1b8f130..2ecb1b8f130 100644 --- a/sql/updates/world/2012_07_22_05_world_script_texts.sql +++ b/sql/old/3.3.5a/2012_07_22_05_world_script_texts.sql diff --git a/sql/updates/world/2012_07_22_06_world_gossip.sql b/sql/old/3.3.5a/2012_07_22_06_world_gossip.sql index 0cb41937d3c..0cb41937d3c 100644 --- a/sql/updates/world/2012_07_22_06_world_gossip.sql +++ b/sql/old/3.3.5a/2012_07_22_06_world_gossip.sql diff --git a/sql/updates/world/2012_07_22_07_world_sai.sql b/sql/old/3.3.5a/2012_07_22_07_world_sai.sql index f8f42ef07da..f8f42ef07da 100644 --- a/sql/updates/world/2012_07_22_07_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_22_07_world_sai.sql diff --git a/sql/updates/world/2012_07_22_08_world_sai.sql b/sql/old/3.3.5a/2012_07_22_08_world_sai.sql index 62b5a95f532..62b5a95f532 100644 --- a/sql/updates/world/2012_07_22_08_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_22_08_world_sai.sql diff --git a/sql/updates/world/2012_07_22_09_world_creature_template.sql b/sql/old/3.3.5a/2012_07_22_09_world_creature_template.sql index 909b4cc238b..909b4cc238b 100644 --- a/sql/updates/world/2012_07_22_09_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_07_22_09_world_creature_template.sql diff --git a/sql/updates/world/2012_07_22_10_world_creature_onkill_rep.sql b/sql/old/3.3.5a/2012_07_22_10_world_creature_onkill_rep.sql index 22d81bca548..22d81bca548 100644 --- a/sql/updates/world/2012_07_22_10_world_creature_onkill_rep.sql +++ b/sql/old/3.3.5a/2012_07_22_10_world_creature_onkill_rep.sql diff --git a/sql/updates/world/2012_07_22_11_world_conditions.sql b/sql/old/3.3.5a/2012_07_22_11_world_conditions.sql index 9ecb28307ba..9ecb28307ba 100644 --- a/sql/updates/world/2012_07_22_11_world_conditions.sql +++ b/sql/old/3.3.5a/2012_07_22_11_world_conditions.sql diff --git a/sql/updates/world/2012_07_22_12_world_creature_template.sql b/sql/old/3.3.5a/2012_07_22_12_world_creature_template.sql index 51e2b36d15d..51e2b36d15d 100644 --- a/sql/updates/world/2012_07_22_12_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_07_22_12_world_creature_template.sql diff --git a/sql/updates/world/2012_07_22_13_world_conditions.sql b/sql/old/3.3.5a/2012_07_22_13_world_conditions.sql index 896257d3f92..896257d3f92 100644 --- a/sql/updates/world/2012_07_22_13_world_conditions.sql +++ b/sql/old/3.3.5a/2012_07_22_13_world_conditions.sql diff --git a/sql/updates/world/2012_07_22_14_world_gameobject.sql b/sql/old/3.3.5a/2012_07_22_14_world_gameobject.sql index bf77d1a625f..bf77d1a625f 100644 --- a/sql/updates/world/2012_07_22_14_world_gameobject.sql +++ b/sql/old/3.3.5a/2012_07_22_14_world_gameobject.sql diff --git a/sql/updates/world/2012_07_22_15_world_sai.sql b/sql/old/3.3.5a/2012_07_22_15_world_sai.sql index 218eb9a3399..218eb9a3399 100644 --- a/sql/updates/world/2012_07_22_15_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_22_15_world_sai.sql diff --git a/sql/updates/world/2012_07_29_00_world_factionchange.sql b/sql/old/3.3.5a/2012_07_29_00_world_factionchange.sql index ca6c36630bc..ca6c36630bc 100644 --- a/sql/updates/world/2012_07_29_00_world_factionchange.sql +++ b/sql/old/3.3.5a/2012_07_29_00_world_factionchange.sql diff --git a/sql/updates/world/2012_07_29_01_world_pool_quest.sql b/sql/old/3.3.5a/2012_07_29_01_world_pool_quest.sql index 0e0f192c8d7..0e0f192c8d7 100644 --- a/sql/updates/world/2012_07_29_01_world_pool_quest.sql +++ b/sql/old/3.3.5a/2012_07_29_01_world_pool_quest.sql diff --git a/sql/updates/world/2012_07_29_02_world_sai.sql b/sql/old/3.3.5a/2012_07_29_02_world_sai.sql index 1a452576139..1a452576139 100644 --- a/sql/updates/world/2012_07_29_02_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_02_world_sai.sql diff --git a/sql/updates/world/2012_07_29_03_world_sai.sql b/sql/old/3.3.5a/2012_07_29_03_world_sai.sql index d8ca1b12390..d8ca1b12390 100644 --- a/sql/updates/world/2012_07_29_03_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_03_world_sai.sql diff --git a/sql/updates/world/2012_07_29_04_world_sai.sql b/sql/old/3.3.5a/2012_07_29_04_world_sai.sql index ef46c72f42c..ef46c72f42c 100644 --- a/sql/updates/world/2012_07_29_04_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_04_world_sai.sql diff --git a/sql/updates/world/2012_07_29_05_world_sai.sql b/sql/old/3.3.5a/2012_07_29_05_world_sai.sql index e1fd032eaca..e1fd032eaca 100644 --- a/sql/updates/world/2012_07_29_05_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_05_world_sai.sql diff --git a/sql/updates/world/2012_07_29_06_world_sai.sql b/sql/old/3.3.5a/2012_07_29_06_world_sai.sql index 03ebdfc6d0a..03ebdfc6d0a 100644 --- a/sql/updates/world/2012_07_29_06_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_06_world_sai.sql diff --git a/sql/updates/world/2012_07_29_07_world_sai.sql b/sql/old/3.3.5a/2012_07_29_07_world_sai.sql index 18de6d15c0a..18de6d15c0a 100644 --- a/sql/updates/world/2012_07_29_07_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_07_world_sai.sql diff --git a/sql/updates/world/2012_07_29_08_world_sai.sql b/sql/old/3.3.5a/2012_07_29_08_world_sai.sql index 796578d3f00..796578d3f00 100644 --- a/sql/updates/world/2012_07_29_08_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_08_world_sai.sql diff --git a/sql/updates/world/2012_07_29_09_world_gossip_menu_option.sql b/sql/old/3.3.5a/2012_07_29_09_world_gossip_menu_option.sql index 66474bdb5e4..66474bdb5e4 100644 --- a/sql/updates/world/2012_07_29_09_world_gossip_menu_option.sql +++ b/sql/old/3.3.5a/2012_07_29_09_world_gossip_menu_option.sql diff --git a/sql/updates/world/2012_07_29_10_world_sai.sql b/sql/old/3.3.5a/2012_07_29_10_world_sai.sql index c5513bf2f25..c5513bf2f25 100644 --- a/sql/updates/world/2012_07_29_10_world_sai.sql +++ b/sql/old/3.3.5a/2012_07_29_10_world_sai.sql diff --git a/sql/updates/world/2012_08_01_00_world_sai.sql b/sql/old/3.3.5a/2012_08_01_00_world_sai.sql index bf214cbfa9c..bf214cbfa9c 100644 --- a/sql/updates/world/2012_08_01_00_world_sai.sql +++ b/sql/old/3.3.5a/2012_08_01_00_world_sai.sql diff --git a/sql/updates/world/2012_08_01_01_world_creature.sql b/sql/old/3.3.5a/2012_08_01_01_world_creature.sql index 875a956fbd1..875a956fbd1 100644 --- a/sql/updates/world/2012_08_01_01_world_creature.sql +++ b/sql/old/3.3.5a/2012_08_01_01_world_creature.sql diff --git a/sql/updates/world/2012_08_01_02_world_loot.sql b/sql/old/3.3.5a/2012_08_01_02_world_loot.sql index a27bd274acf..a27bd274acf 100644 --- a/sql/updates/world/2012_08_01_02_world_loot.sql +++ b/sql/old/3.3.5a/2012_08_01_02_world_loot.sql diff --git a/sql/updates/world/2012_08_02_00_world_spell_script_names.sql b/sql/old/3.3.5a/2012_08_02_00_world_spell_script_names.sql index f14e44e35ff..f14e44e35ff 100644 --- a/sql/updates/world/2012_08_02_00_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_02_00_world_spell_script_names.sql diff --git a/sql/updates/world/2012_08_04_00_world_disables.sql b/sql/old/3.3.5a/2012_08_04_00_world_disables.sql index f3f197ba23a..f3f197ba23a 100644 --- a/sql/updates/world/2012_08_04_00_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_00_world_disables.sql diff --git a/sql/updates/world/2012_08_04_01_world_disables.sql b/sql/old/3.3.5a/2012_08_04_01_world_disables.sql index ca9f62564d5..ca9f62564d5 100644 --- a/sql/updates/world/2012_08_04_01_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_01_world_disables.sql diff --git a/sql/updates/world/2012_08_04_02_world_disables.sql b/sql/old/3.3.5a/2012_08_04_02_world_disables.sql index cccc7141d68..cccc7141d68 100644 --- a/sql/updates/world/2012_08_04_02_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_02_world_disables.sql diff --git a/sql/updates/world/2012_08_04_03_world_disables.sql b/sql/old/3.3.5a/2012_08_04_03_world_disables.sql index 21b55a3e930..e2d1ca1ff6b 100644 --- a/sql/updates/world/2012_08_04_03_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_03_world_disables.sql @@ -1,4 +1,4 @@ -DELETE FROM `disables` WHERE `sourceType`=1 AND `entry` IN (9754,9755,10215,11522,12445,12731,12923,13541); +DELETE FROM `disables` WHERE `sourceType`=1 AND `entry` IN (9754,9755,10215,11522,12445,12731,12923,13541,7797,7869,7870,7906,9378,9611,9880,9881,9908,9909,9949,9950,10088,10181,10214,10454,11197,11226,11577,11874,11937,12485,12600,13123,13210,13317,13990); INSERT INTO `disables` (`sourceType`,`entry`,`flags`,`params_0`,`params_1`,`comment`) VALUES (1,9754,0,'','','Deprecated quest: '), (1,9755,0,'','','Deprecated quest: '), diff --git a/sql/updates/world/2012_08_04_04_world_disables.sql b/sql/old/3.3.5a/2012_08_04_04_world_disables.sql index 14a0d6f94aa..14a0d6f94aa 100644 --- a/sql/updates/world/2012_08_04_04_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_04_world_disables.sql diff --git a/sql/updates/world/2012_08_04_05_world_disables.sql b/sql/old/3.3.5a/2012_08_04_05_world_disables.sql index ce123e4e5be..ce123e4e5be 100644 --- a/sql/updates/world/2012_08_04_05_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_05_world_disables.sql diff --git a/sql/updates/world/2012_08_04_06_world_quest_template.sql b/sql/old/3.3.5a/2012_08_04_06_world_quest_template.sql index fe48c887ae0..fe48c887ae0 100644 --- a/sql/updates/world/2012_08_04_06_world_quest_template.sql +++ b/sql/old/3.3.5a/2012_08_04_06_world_quest_template.sql diff --git a/sql/updates/world/2012_08_04_07_world_game_event_creature_quest.sql b/sql/old/3.3.5a/2012_08_04_07_world_game_event_creature_quest.sql index b72f8edd46d..b72f8edd46d 100644 --- a/sql/updates/world/2012_08_04_07_world_game_event_creature_quest.sql +++ b/sql/old/3.3.5a/2012_08_04_07_world_game_event_creature_quest.sql diff --git a/sql/updates/world/2012_08_04_08_world_disables.sql b/sql/old/3.3.5a/2012_08_04_08_world_disables.sql index 6944c45f1f4..6944c45f1f4 100644 --- a/sql/updates/world/2012_08_04_08_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_08_world_disables.sql diff --git a/sql/updates/world/2012_08_04_09_world_disables.sql b/sql/old/3.3.5a/2012_08_04_09_world_disables.sql index 3023625410e..3023625410e 100644 --- a/sql/updates/world/2012_08_04_09_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_09_world_disables.sql diff --git a/sql/updates/world/2012_08_04_10_world_disables.sql b/sql/old/3.3.5a/2012_08_04_10_world_disables.sql index 1d991eafef5..1d991eafef5 100644 --- a/sql/updates/world/2012_08_04_10_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_04_10_world_disables.sql diff --git a/sql/updates/world/2012_08_04_11_world_game_event_creature_quest.sql b/sql/old/3.3.5a/2012_08_04_11_world_game_event_creature_quest.sql index 224749c7e10..224749c7e10 100644 --- a/sql/updates/world/2012_08_04_11_world_game_event_creature_quest.sql +++ b/sql/old/3.3.5a/2012_08_04_11_world_game_event_creature_quest.sql diff --git a/sql/updates/world/2012_08_05_00_world_trinity_string.sql b/sql/old/3.3.5a/2012_08_05_00_world_trinity_string.sql index e432f598c02..e432f598c02 100644 --- a/sql/updates/world/2012_08_05_00_world_trinity_string.sql +++ b/sql/old/3.3.5a/2012_08_05_00_world_trinity_string.sql diff --git a/sql/updates/world/2012_08_05_01_world_command.sql b/sql/old/3.3.5a/2012_08_05_01_world_command.sql index f19bfe1c0d0..f19bfe1c0d0 100644 --- a/sql/updates/world/2012_08_05_01_world_command.sql +++ b/sql/old/3.3.5a/2012_08_05_01_world_command.sql diff --git a/sql/updates/auth/2012_08_06_00_auth_logs.sql b/sql/old/3.3.5a/2012_08_06_00_auth_logs.sql index 04e90e7d208..04e90e7d208 100644 --- a/sql/updates/auth/2012_08_06_00_auth_logs.sql +++ b/sql/old/3.3.5a/2012_08_06_00_auth_logs.sql diff --git a/sql/updates/world/2012_08_06_00_world_command.sql b/sql/old/3.3.5a/2012_08_06_00_world_command.sql index 50628aaa589..50628aaa589 100644 --- a/sql/updates/world/2012_08_06_00_world_command.sql +++ b/sql/old/3.3.5a/2012_08_06_00_world_command.sql diff --git a/sql/updates/characters/2012_08_07_00_characters_characters.sql b/sql/old/3.3.5a/2012_08_07_00_characters_characters.sql index e9bea82ad4b..e9bea82ad4b 100644 --- a/sql/updates/characters/2012_08_07_00_characters_characters.sql +++ b/sql/old/3.3.5a/2012_08_07_00_characters_characters.sql diff --git a/sql/updates/world/2012_08_09_00_world_creature_template.sql b/sql/old/3.3.5a/2012_08_09_00_world_creature_template.sql index 8d04c13dc87..8d04c13dc87 100644 --- a/sql/updates/world/2012_08_09_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_09_00_world_creature_template.sql diff --git a/sql/updates/world/2012_08_09_01_world_sai.sql b/sql/old/3.3.5a/2012_08_09_01_world_sai.sql index 94dce1bcc2c..94dce1bcc2c 100644 --- a/sql/updates/world/2012_08_09_01_world_sai.sql +++ b/sql/old/3.3.5a/2012_08_09_01_world_sai.sql diff --git a/sql/updates/world/2012_08_10_00_world_conditions.sql b/sql/old/3.3.5a/2012_08_10_00_world_conditions.sql index 14c5c570b6e..14c5c570b6e 100644 --- a/sql/updates/world/2012_08_10_00_world_conditions.sql +++ b/sql/old/3.3.5a/2012_08_10_00_world_conditions.sql diff --git a/sql/updates/world/2012_08_10_01_world_loot_template.sql b/sql/old/3.3.5a/2012_08_10_01_world_loot_template.sql index 07d400dc0d7..07d400dc0d7 100644 --- a/sql/updates/world/2012_08_10_01_world_loot_template.sql +++ b/sql/old/3.3.5a/2012_08_10_01_world_loot_template.sql diff --git a/sql/updates/world/2012_08_10_02_world_script_texts.sql b/sql/old/3.3.5a/2012_08_10_02_world_script_texts.sql index 0b97df592e1..0b97df592e1 100644 --- a/sql/updates/world/2012_08_10_02_world_script_texts.sql +++ b/sql/old/3.3.5a/2012_08_10_02_world_script_texts.sql diff --git a/sql/updates/world/2012_08_10_03_world_quest_template.sql b/sql/old/3.3.5a/2012_08_10_03_world_quest_template.sql index c4aebf5ba16..c4aebf5ba16 100644 --- a/sql/updates/world/2012_08_10_03_world_quest_template.sql +++ b/sql/old/3.3.5a/2012_08_10_03_world_quest_template.sql diff --git a/sql/updates/world/2012_08_10_04_world_gossip.sql b/sql/old/3.3.5a/2012_08_10_04_world_gossip.sql index a2082447dfc..a2082447dfc 100644 --- a/sql/updates/world/2012_08_10_04_world_gossip.sql +++ b/sql/old/3.3.5a/2012_08_10_04_world_gossip.sql diff --git a/sql/updates/world/2012_08_10_05_world_quest_template.sql b/sql/old/3.3.5a/2012_08_10_05_world_quest_template.sql index a65e7e76a44..a65e7e76a44 100644 --- a/sql/updates/world/2012_08_10_05_world_quest_template.sql +++ b/sql/old/3.3.5a/2012_08_10_05_world_quest_template.sql diff --git a/sql/updates/world/2012_08_10_06_world_creature.sql b/sql/old/3.3.5a/2012_08_10_06_world_creature.sql index 3d59f06db78..3d59f06db78 100644 --- a/sql/updates/world/2012_08_10_06_world_creature.sql +++ b/sql/old/3.3.5a/2012_08_10_06_world_creature.sql diff --git a/sql/updates/world/2012_08_11_00_world_creature_template.sql b/sql/old/3.3.5a/2012_08_11_00_world_creature_template.sql index 972b125d247..972b125d247 100644 --- a/sql/updates/world/2012_08_11_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_11_00_world_creature_template.sql diff --git a/sql/updates/world/2012_08_11_01_world_quest_poi.sql b/sql/old/3.3.5a/2012_08_11_01_world_quest_poi.sql index 6672df2bc98..6672df2bc98 100644 --- a/sql/updates/world/2012_08_11_01_world_quest_poi.sql +++ b/sql/old/3.3.5a/2012_08_11_01_world_quest_poi.sql diff --git a/sql/updates/world/2012_08_12_00_world_conditions.sql b/sql/old/3.3.5a/2012_08_12_00_world_conditions.sql index 6e1fd0ac1db..6e1fd0ac1db 100644 --- a/sql/updates/world/2012_08_12_00_world_conditions.sql +++ b/sql/old/3.3.5a/2012_08_12_00_world_conditions.sql diff --git a/sql/updates/world/2012_08_12_01_world_spell_script_names.sql b/sql/old/3.3.5a/2012_08_12_01_world_spell_script_names.sql index 980aceff519..980aceff519 100644 --- a/sql/updates/world/2012_08_12_01_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_12_01_world_spell_script_names.sql diff --git a/sql/updates/world/2012_08_12_02_world_spell_script_names.sql b/sql/old/3.3.5a/2012_08_12_02_world_spell_script_names.sql index 15ca9c43cc5..15ca9c43cc5 100644 --- a/sql/updates/world/2012_08_12_02_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_12_02_world_spell_script_names.sql diff --git a/sql/updates/world/2012_08_13_00_world_creature_text.sql b/sql/old/3.3.5a/2012_08_13_00_world_creature_text.sql index aeb24dbfe90..aeb24dbfe90 100644 --- a/sql/updates/world/2012_08_13_00_world_creature_text.sql +++ b/sql/old/3.3.5a/2012_08_13_00_world_creature_text.sql diff --git a/sql/updates/world/2012_08_13_01_world_creature.sql b/sql/old/3.3.5a/2012_08_13_01_world_creature.sql index 4d8544206dd..4d8544206dd 100644 --- a/sql/updates/world/2012_08_13_01_world_creature.sql +++ b/sql/old/3.3.5a/2012_08_13_01_world_creature.sql diff --git a/sql/updates/world/2012_08_14_00_world_creature_text.sql b/sql/old/3.3.5a/2012_08_14_00_world_creature_text.sql index bd0f3531937..bd0f3531937 100644 --- a/sql/updates/world/2012_08_14_00_world_creature_text.sql +++ b/sql/old/3.3.5a/2012_08_14_00_world_creature_text.sql diff --git a/sql/updates/world/2012_08_14_01_world_creature_text.sql b/sql/old/3.3.5a/2012_08_14_01_world_creature_text.sql index 0f182ae098e..0f182ae098e 100644 --- a/sql/updates/world/2012_08_14_01_world_creature_text.sql +++ b/sql/old/3.3.5a/2012_08_14_01_world_creature_text.sql diff --git a/sql/updates/world/2012_08_14_02_world_creature.sql b/sql/old/3.3.5a/2012_08_14_02_world_creature.sql index 5096c7d6b49..5096c7d6b49 100644 --- a/sql/updates/world/2012_08_14_02_world_creature.sql +++ b/sql/old/3.3.5a/2012_08_14_02_world_creature.sql diff --git a/sql/updates/world/2012_08_16_00_world_creature_template.sql b/sql/old/3.3.5a/2012_08_16_00_world_creature_template.sql index 732f647d7b7..732f647d7b7 100644 --- a/sql/updates/world/2012_08_16_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_16_00_world_creature_template.sql diff --git a/sql/updates/world/2012_08_16_00_world_spell_dbc.sql b/sql/old/3.3.5a/2012_08_16_00_world_spell_dbc.sql index 248674d17a5..248674d17a5 100644 --- a/sql/updates/world/2012_08_16_00_world_spell_dbc.sql +++ b/sql/old/3.3.5a/2012_08_16_00_world_spell_dbc.sql diff --git a/sql/updates/world/2012_08_17_00_world_spell_dbc.sql b/sql/old/3.3.5a/2012_08_17_00_world_spell_dbc.sql index ee6d2d2f3b6..ee6d2d2f3b6 100644 --- a/sql/updates/world/2012_08_17_00_world_spell_dbc.sql +++ b/sql/old/3.3.5a/2012_08_17_00_world_spell_dbc.sql diff --git a/sql/updates/world/2012_08_19_00_world_pickpocketing_loot_template.sql b/sql/old/3.3.5a/2012_08_19_00_world_pickpocketing_loot_template.sql index 773ad9b6ebc..773ad9b6ebc 100644 --- a/sql/updates/world/2012_08_19_00_world_pickpocketing_loot_template.sql +++ b/sql/old/3.3.5a/2012_08_19_00_world_pickpocketing_loot_template.sql diff --git a/sql/updates/world/2012_08_19_01_world_spell_dbc.sql b/sql/old/3.3.5a/2012_08_19_01_world_spell_dbc.sql index 69a9c2a8336..69a9c2a8336 100644 --- a/sql/updates/world/2012_08_19_01_world_spell_dbc.sql +++ b/sql/old/3.3.5a/2012_08_19_01_world_spell_dbc.sql diff --git a/sql/updates/world/2012_08_20_00_world_spell_script_names.sql b/sql/old/3.3.5a/2012_08_20_00_world_spell_script_names.sql index d0aa185ea3a..d0aa185ea3a 100644 --- a/sql/updates/world/2012_08_20_00_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_20_00_world_spell_script_names.sql diff --git a/sql/updates/world/2012_08_20_01_world_wintergrasp_conditions.sql b/sql/old/3.3.5a/2012_08_20_01_world_wintergrasp_conditions.sql index c97c753afa8..c97c753afa8 100644 --- a/sql/updates/world/2012_08_20_01_world_wintergrasp_conditions.sql +++ b/sql/old/3.3.5a/2012_08_20_01_world_wintergrasp_conditions.sql diff --git a/sql/updates/world/2012_08_20_02_world_wintergrasp_creatures.sql b/sql/old/3.3.5a/2012_08_20_02_world_wintergrasp_creatures.sql index 1e75f37d32f..1e75f37d32f 100644 --- a/sql/updates/world/2012_08_20_02_world_wintergrasp_creatures.sql +++ b/sql/old/3.3.5a/2012_08_20_02_world_wintergrasp_creatures.sql diff --git a/sql/updates/world/2012_08_20_03_world_wintergrasp_gameobjects.sql b/sql/old/3.3.5a/2012_08_20_03_world_wintergrasp_gameobjects.sql index c309bf1d9dd..c309bf1d9dd 100644 --- a/sql/updates/world/2012_08_20_03_world_wintergrasp_gameobjects.sql +++ b/sql/old/3.3.5a/2012_08_20_03_world_wintergrasp_gameobjects.sql diff --git a/sql/updates/world/2012_08_20_04_world_wintergrasp_gossips.sql b/sql/old/3.3.5a/2012_08_20_04_world_wintergrasp_gossips.sql index 87b96b765a6..87b96b765a6 100644 --- a/sql/updates/world/2012_08_20_04_world_wintergrasp_gossips.sql +++ b/sql/old/3.3.5a/2012_08_20_04_world_wintergrasp_gossips.sql diff --git a/sql/updates/world/2012_08_20_05_world_wintergrasp_quests.sql b/sql/old/3.3.5a/2012_08_20_05_world_wintergrasp_quests.sql index d456f5d5e71..d456f5d5e71 100644 --- a/sql/updates/world/2012_08_20_05_world_wintergrasp_quests.sql +++ b/sql/old/3.3.5a/2012_08_20_05_world_wintergrasp_quests.sql diff --git a/sql/updates/world/2012_08_20_06_world_wintergrasp_spells.sql b/sql/old/3.3.5a/2012_08_20_06_world_wintergrasp_spells.sql index cb2bd219e40..cb2bd219e40 100644 --- a/sql/updates/world/2012_08_20_06_world_wintergrasp_spells.sql +++ b/sql/old/3.3.5a/2012_08_20_06_world_wintergrasp_spells.sql diff --git a/sql/updates/world/2012_08_20_07_world_wintergrasp_texts.sql b/sql/old/3.3.5a/2012_08_20_07_world_wintergrasp_texts.sql index 090c5350c74..090c5350c74 100644 --- a/sql/updates/world/2012_08_20_07_world_wintergrasp_texts.sql +++ b/sql/old/3.3.5a/2012_08_20_07_world_wintergrasp_texts.sql diff --git a/sql/updates/world/2012_08_20_08_world_achievement_criteria_data.sql b/sql/old/3.3.5a/2012_08_20_08_world_achievement_criteria_data.sql index fa995e7804f..fa995e7804f 100644 --- a/sql/updates/world/2012_08_20_08_world_achievement_criteria_data.sql +++ b/sql/old/3.3.5a/2012_08_20_08_world_achievement_criteria_data.sql diff --git a/sql/updates/world/2012_08_20_09_world_disables.sql b/sql/old/3.3.5a/2012_08_20_09_world_disables.sql index fa5010b669f..fa5010b669f 100644 --- a/sql/updates/world/2012_08_20_09_world_disables.sql +++ b/sql/old/3.3.5a/2012_08_20_09_world_disables.sql diff --git a/sql/updates/world/2012_08_21_00_world_spell_proc_event.sql b/sql/old/3.3.5a/2012_08_21_00_world_spell_proc_event.sql index e1a8b59acae..e1a8b59acae 100644 --- a/sql/updates/world/2012_08_21_00_world_spell_proc_event.sql +++ b/sql/old/3.3.5a/2012_08_21_00_world_spell_proc_event.sql diff --git a/sql/updates/world/2012_08_21_01_world_command.sql b/sql/old/3.3.5a/2012_08_21_01_world_command.sql index df833d2d246..df833d2d246 100644 --- a/sql/updates/world/2012_08_21_01_world_command.sql +++ b/sql/old/3.3.5a/2012_08_21_01_world_command.sql diff --git a/sql/updates/world/2012_08_21_02_world_wintergrasp_conditions.sql b/sql/old/3.3.5a/2012_08_21_02_world_wintergrasp_conditions.sql index caf8a0cc1e4..caf8a0cc1e4 100644 --- a/sql/updates/world/2012_08_21_02_world_wintergrasp_conditions.sql +++ b/sql/old/3.3.5a/2012_08_21_02_world_wintergrasp_conditions.sql diff --git a/sql/updates/world/2012_08_23_00_world_wintergrasp_spell_script_names.sql b/sql/old/3.3.5a/2012_08_23_00_world_wintergrasp_spell_script_names.sql index a3dbf81d425..a3dbf81d425 100644 --- a/sql/updates/world/2012_08_23_00_world_wintergrasp_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_23_00_world_wintergrasp_spell_script_names.sql diff --git a/sql/updates/world/2012_08_23_01_world_wintergrasp_gameobject.sql b/sql/old/3.3.5a/2012_08_23_01_world_wintergrasp_gameobject.sql index 27f7b4027f1..27f7b4027f1 100644 --- a/sql/updates/world/2012_08_23_01_world_wintergrasp_gameobject.sql +++ b/sql/old/3.3.5a/2012_08_23_01_world_wintergrasp_gameobject.sql diff --git a/sql/updates/world/2012_08_25_00_world_creature_template.sql b/sql/old/3.3.5a/2012_08_25_00_world_creature_template.sql index f7ec4c87fb9..f7ec4c87fb9 100644 --- a/sql/updates/world/2012_08_25_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_25_00_world_creature_template.sql diff --git a/sql/updates/world/2012_08_25_01_world_creature_template.sql b/sql/old/3.3.5a/2012_08_25_01_world_creature_template.sql index ef8e5bdd8fc..ef8e5bdd8fc 100644 --- a/sql/updates/world/2012_08_25_01_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_25_01_world_creature_template.sql diff --git a/sql/updates/world/2012_08_26_00_world_conditions.sql b/sql/old/3.3.5a/2012_08_26_00_world_conditions.sql index c33d9bfc878..c33d9bfc878 100644 --- a/sql/updates/world/2012_08_26_00_world_conditions.sql +++ b/sql/old/3.3.5a/2012_08_26_00_world_conditions.sql diff --git a/sql/updates/world/2012_08_26_01_world_creature.sql b/sql/old/3.3.5a/2012_08_26_01_world_creature.sql index af14886850d..af14886850d 100644 --- a/sql/updates/world/2012_08_26_01_world_creature.sql +++ b/sql/old/3.3.5a/2012_08_26_01_world_creature.sql diff --git a/sql/updates/world/2012_08_26_02_world_spell_area.sql b/sql/old/3.3.5a/2012_08_26_02_world_spell_area.sql index c4eae68e3c4..c4eae68e3c4 100644 --- a/sql/updates/world/2012_08_26_02_world_spell_area.sql +++ b/sql/old/3.3.5a/2012_08_26_02_world_spell_area.sql diff --git a/sql/updates/world/2012_08_26_03_world_spell_area.sql b/sql/old/3.3.5a/2012_08_26_03_world_spell_area.sql index 65072d2b4a7..65072d2b4a7 100644 --- a/sql/updates/world/2012_08_26_03_world_spell_area.sql +++ b/sql/old/3.3.5a/2012_08_26_03_world_spell_area.sql diff --git a/sql/updates/world/2012_08_27_00_world_creature_template.sql b/sql/old/3.3.5a/2012_08_27_00_world_creature_template.sql index 804d7b5c61d..804d7b5c61d 100644 --- a/sql/updates/world/2012_08_27_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_27_00_world_creature_template.sql diff --git a/sql/updates/world/2012_08_27_00_world_spell_script_name.sql b/sql/old/3.3.5a/2012_08_27_00_world_spell_script_name.sql index 1d036df0a65..1d036df0a65 100644 --- a/sql/updates/world/2012_08_27_00_world_spell_script_name.sql +++ b/sql/old/3.3.5a/2012_08_27_00_world_spell_script_name.sql diff --git a/sql/updates/world/2012_08_27_01_world_sai.sql b/sql/old/3.3.5a/2012_08_27_01_world_sai.sql index 302c3ac1942..302c3ac1942 100644 --- a/sql/updates/world/2012_08_27_01_world_sai.sql +++ b/sql/old/3.3.5a/2012_08_27_01_world_sai.sql diff --git a/sql/updates/world/2012_08_27_02_world_creature.sql b/sql/old/3.3.5a/2012_08_27_02_world_creature.sql index 3595ea7b576..3595ea7b576 100644 --- a/sql/updates/world/2012_08_27_02_world_creature.sql +++ b/sql/old/3.3.5a/2012_08_27_02_world_creature.sql diff --git a/sql/updates/world/2012_08_27_02_world_playercreateinfo_spell.sql b/sql/old/3.3.5a/2012_08_27_02_world_playercreateinfo_spell.sql index 9c664142bba..9c664142bba 100644 --- a/sql/updates/world/2012_08_27_02_world_playercreateinfo_spell.sql +++ b/sql/old/3.3.5a/2012_08_27_02_world_playercreateinfo_spell.sql diff --git a/sql/updates/world/2012_08_27_03_world_gameobject.sql b/sql/old/3.3.5a/2012_08_27_03_world_gameobject.sql index 1bf836c96e0..1bf836c96e0 100644 --- a/sql/updates/world/2012_08_27_03_world_gameobject.sql +++ b/sql/old/3.3.5a/2012_08_27_03_world_gameobject.sql diff --git a/sql/updates/world/2012_08_27_04_world_quest_template.sql b/sql/old/3.3.5a/2012_08_27_04_world_quest_template.sql index 9169a6e5862..9169a6e5862 100644 --- a/sql/updates/world/2012_08_27_04_world_quest_template.sql +++ b/sql/old/3.3.5a/2012_08_27_04_world_quest_template.sql diff --git a/sql/updates/world/2012_08_27_05_world_sai.sql b/sql/old/3.3.5a/2012_08_27_05_world_sai.sql index 3da0143e6e6..3da0143e6e6 100644 --- a/sql/updates/world/2012_08_27_05_world_sai.sql +++ b/sql/old/3.3.5a/2012_08_27_05_world_sai.sql diff --git a/sql/updates/world/2012_08_27_06_world_sai.sql b/sql/old/3.3.5a/2012_08_27_06_world_sai.sql index 8b1aafd1558..8b1aafd1558 100644 --- a/sql/updates/world/2012_08_27_06_world_sai.sql +++ b/sql/old/3.3.5a/2012_08_27_06_world_sai.sql diff --git a/sql/updates/world/2012_08_27_07_world_spell_area.sql b/sql/old/3.3.5a/2012_08_27_07_world_spell_area.sql index 18be6ff0dbe..18be6ff0dbe 100644 --- a/sql/updates/world/2012_08_27_07_world_spell_area.sql +++ b/sql/old/3.3.5a/2012_08_27_07_world_spell_area.sql diff --git a/sql/updates/world/2012_08_27_08_world_misc.sql b/sql/old/3.3.5a/2012_08_27_08_world_misc.sql index 62a57cd42de..62a57cd42de 100644 --- a/sql/updates/world/2012_08_27_08_world_misc.sql +++ b/sql/old/3.3.5a/2012_08_27_08_world_misc.sql diff --git a/sql/updates/world/2012_08_27_09_world_conditions.sql b/sql/old/3.3.5a/2012_08_27_09_world_conditions.sql index 6d536859060..6d536859060 100644 --- a/sql/updates/world/2012_08_27_09_world_conditions.sql +++ b/sql/old/3.3.5a/2012_08_27_09_world_conditions.sql diff --git a/sql/updates/world/2012_08_27_10_world_spell_script_names.sql b/sql/old/3.3.5a/2012_08_27_10_world_spell_script_names.sql index 9ffb153f498..9ffb153f498 100644 --- a/sql/updates/world/2012_08_27_10_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_27_10_world_spell_script_names.sql diff --git a/sql/updates/world/2012_08_28_00_world_spell_script_name.sql b/sql/old/3.3.5a/2012_08_28_00_world_spell_script_name.sql index 01cfeb35f1f..01cfeb35f1f 100644 --- a/sql/updates/world/2012_08_28_00_world_spell_script_name.sql +++ b/sql/old/3.3.5a/2012_08_28_00_world_spell_script_name.sql diff --git a/sql/updates/world/2012_08_28_01_world_achievement_criteria_data.sql b/sql/old/3.3.5a/2012_08_28_01_world_achievement_criteria_data.sql index bf247399553..bf247399553 100644 --- a/sql/updates/world/2012_08_28_01_world_achievement_criteria_data.sql +++ b/sql/old/3.3.5a/2012_08_28_01_world_achievement_criteria_data.sql diff --git a/sql/updates/world/2012_08_29_00_world_blood_furnace.sql b/sql/old/3.3.5a/2012_08_29_00_world_blood_furnace.sql index 85b493da202..85b493da202 100644 --- a/sql/updates/world/2012_08_29_00_world_blood_furnace.sql +++ b/sql/old/3.3.5a/2012_08_29_00_world_blood_furnace.sql diff --git a/sql/updates/world/2012_08_30_00_world_creature_template.sql b/sql/old/3.3.5a/2012_08_30_00_world_creature_template.sql index 27c1c1dedd4..27c1c1dedd4 100644 --- a/sql/updates/world/2012_08_30_00_world_creature_template.sql +++ b/sql/old/3.3.5a/2012_08_30_00_world_creature_template.sql diff --git a/sql/updates/world/2012_08_30_00_world_spell_script_names.sql b/sql/old/3.3.5a/2012_08_30_00_world_spell_script_names.sql index d7602dd8c79..d7602dd8c79 100644 --- a/sql/updates/world/2012_08_30_00_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_08_30_00_world_spell_script_names.sql diff --git a/sql/updates/world/2012_08_31_00_world_command.sql b/sql/old/3.3.5a/2012_08_31_00_world_command.sql index c0686d6d907..c0686d6d907 100644 --- a/sql/updates/world/2012_08_31_00_world_command.sql +++ b/sql/old/3.3.5a/2012_08_31_00_world_command.sql diff --git a/sql/updates/world/2012_08_31_00_world_sai.sql b/sql/old/3.3.5a/2012_08_31_00_world_sai.sql index fd7e0d7810f..fd7e0d7810f 100644 --- a/sql/updates/world/2012_08_31_00_world_sai.sql +++ b/sql/old/3.3.5a/2012_08_31_00_world_sai.sql diff --git a/sql/updates/world/2012_09_01_00_world_spell_script_names.sql b/sql/old/3.3.5a/2012_09_01_00_world_spell_script_names.sql index 888cc15e276..add7621b74c 100644 --- a/sql/updates/world/2012_09_01_00_world_spell_script_names.sql +++ b/sql/old/3.3.5a/2012_09_01_00_world_spell_script_names.sql @@ -1,4 +1,4 @@ --- Unlocking zuluhed chains +-- Unlocking zuluhed chains DELETE FROM `spell_script_names` WHERE `spell_id`=38790; INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (38790, 'spell_unlocking_zuluheds_chains'); diff --git a/sql/old/3.3.5a/2012_09_02_00_world_quest_template.sql b/sql/old/3.3.5a/2012_09_02_00_world_quest_template.sql new file mode 100644 index 00000000000..d7e3948ef4f --- /dev/null +++ b/sql/old/3.3.5a/2012_09_02_00_world_quest_template.sql @@ -0,0 +1,49 @@ +-- Kandrostrasz <Brood of Alexstrasza> (15503) quests RequiredClasses fix by nelegalno +UPDATE `quest_template` SET `RequiredClasses` = 1 WHERE `Id` IN (8559,8560); -- Warrior +UPDATE `quest_template` SET `RequiredClasses` = 2 WHERE `Id` IN (8629,8655); -- Paladin +UPDATE `quest_template` SET `RequiredClasses` = 4 WHERE `Id` IN (8626,8658); -- Hunter +UPDATE `quest_template` SET `RequiredClasses` = 8 WHERE `Id` IN (8637,8640); -- Rogue +UPDATE `quest_template` SET `RequiredClasses` = 16 WHERE `Id` IN (8593,8596); -- Priest +UPDATE `quest_template` SET `RequiredClasses` = 64 WHERE `Id` IN (8621,8624); -- Shaman +UPDATE `quest_template` SET `RequiredClasses` = 128 WHERE `Id` IN (8631,8634); -- Mage +UPDATE `quest_template` SET `RequiredClasses` = 256 WHERE `Id` IN (8660,8663); -- Warlock +UPDATE `quest_template` SET `RequiredClasses` = 1024 WHERE `Id` IN (8665,8668); -- Druid + +-- Andorgos <Brood of Malygos> (15502) quests RequiredClasses fix by nelegalno +UPDATE `quest_template` SET `RequiredClasses` = 1 WHERE `Id` IN (8544,8561); -- Warrior +UPDATE `quest_template` SET `RequiredClasses` = 2 WHERE `Id` IN (8628,8630); -- Paladin +UPDATE `quest_template` SET `RequiredClasses` = 4 WHERE `Id` IN (8657,8659); -- Hunter +UPDATE `quest_template` SET `RequiredClasses` = 8 WHERE `Id` IN (8639,8641); -- Rogue +UPDATE `quest_template` SET `RequiredClasses` = 16 WHERE `Id` IN (8592,8594); -- Priest +UPDATE `quest_template` SET `RequiredClasses` = 64 WHERE `Id` IN (8602,8623); -- Shaman +UPDATE `quest_template` SET `RequiredClasses` = 128 WHERE `Id` IN (8625,8632); -- Mage +UPDATE `quest_template` SET `RequiredClasses` = 256 WHERE `Id` IN (8662,8664); -- Warlock +UPDATE `quest_template` SET `RequiredClasses` = 1024 WHERE `Id` IN (8667,8669); -- Druid + +-- Craftsman Wilhelm <Brotherhood of the Light> (16376) NPCs quests +UPDATE `quest_template` SET `RequiredClasses` = 3 WHERE `Id` IN (9234,9235,9236); -- Warrior, Paladin +UPDATE `quest_template` SET `RequiredClasses` = 68 WHERE `Id` IN (9244,9245,9246); -- Hunter, Shaman +UPDATE `quest_template` SET `RequiredClasses` = 400 WHERE `Id` IN (9238,9239,9240); -- Priest, Mage, Warlock +UPDATE `quest_template` SET `RequiredClasses` = 1032 WHERE `Id` IN (9241,9242,9243); -- Rogue, Druid + +-- Zanza the Restless (15042) NPCs quests +UPDATE `quest_template` SET `RequiredClasses` = 1 WHERE `Id` = 8184; -- Warrior +UPDATE `quest_template` SET `RequiredClasses` = 2 WHERE `Id` = 8185; -- Paladin +UPDATE `quest_template` SET `RequiredClasses` = 4 WHERE `Id` = 8187; -- Hunter +UPDATE `quest_template` SET `RequiredClasses` = 8 WHERE `Id` = 8186; -- Rogue +UPDATE `quest_template` SET `RequiredClasses` = 16 WHERE `Id` = 8191; -- Priest +UPDATE `quest_template` SET `RequiredClasses` = 64 WHERE `Id` = 8188; -- Shaman +UPDATE `quest_template` SET `RequiredClasses` = 128 WHERE `Id` = 8189; -- Mage +UPDATE `quest_template` SET `RequiredClasses` = 256 WHERE `Id` = 8190; -- Warlock +UPDATE `quest_template` SET `RequiredClasses` = 1024 WHERE `Id` = 8192; -- Druid + +-- Vethsera <Brood of Ysera> (15504) quests RequiredClasses fix by nelegalno +UPDATE `quest_template` SET `RequiredClasses` = 1 WHERE `Id` = 8562; -- Warrior +UPDATE `quest_template` SET `RequiredClasses` = 2 WHERE `Id` = 8627; -- Paladin +UPDATE `quest_template` SET `RequiredClasses` = 4 WHERE `Id` = 8656; -- Hunter +UPDATE `quest_template` SET `RequiredClasses` = 8 WHERE `Id` = 8638; -- Rogue +UPDATE `quest_template` SET `RequiredClasses` = 16 WHERE `Id` = 8603; -- Priest +UPDATE `quest_template` SET `RequiredClasses` = 64 WHERE `Id` = 8622; -- Shaman +UPDATE `quest_template` SET `RequiredClasses` = 128 WHERE `Id` = 8633; -- Mage +UPDATE `quest_template` SET `RequiredClasses` = 256 WHERE `Id` = 8661; -- Warlock +UPDATE `quest_template` SET `RequiredClasses` = 1024 WHERE `Id` = 8666; -- Druid diff --git a/sql/old/3.3.5a/2012_09_02_01_world_sai.sql b/sql/old/3.3.5a/2012_09_02_01_world_sai.sql new file mode 100644 index 00000000000..971c50d9c05 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_02_01_world_sai.sql @@ -0,0 +1,36 @@ +-- Lok'lira the Crone +SET @ENTRY := 29975; +UPDATE `creature_template` SET `AIName`='SmartAI', `ScriptName`='' WHERE `entry`=@ENTRY; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@ENTRY,0,0,1,62,0,100,0,9910,0,0,0,33,30467,0,0,0,0,0,7,0,0,0,0,0,0,0,'Loklira - gossip select 4 - The Hyldsmeet Kill credit'), +(@ENTRY,0,1,0,61,0,100,0,0,0,0,0,72,0,0,0,0,0,0,7,0,0,0,0,0,0,0,'Loklira - gossip select 4 - Close gossip'); + +UPDATE `gossip_menu_option` SET `action_menu_id`=9908 WHERE `menu_id`=9907; +UPDATE `gossip_menu_option` SET `action_menu_id`=9909 WHERE `menu_id`=9908; +UPDATE `gossip_menu_option` SET `action_menu_id`=9910 WHERE `menu_id`=9909; + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=9907; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(15,9907,0,0,9,12970,0,0,0,'','Loklira - Show gossip if quest accepted'); + +-- Thorim +SET @THORIM :=29445; +UPDATE `creature` SET `modelid`=0 WHERE `id`=@THORIM; +UPDATE `creature_template` SET `AIName`='SmartAI', `ScriptName`='' WHERE `entry`=@THORIM; +DELETE FROM `creature_addon` WHERE `guid`=97128; +DELETE FROM `creature_template_addon` WHERE `entry`=@THORIM; +INSERT INTO `creature_template_addon` (`entry`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES +(@THORIM,0,0,1,0,0,''); + +DELETE FROM `smart_scripts` WHERE `entryorguid`=@THORIM AND `source_type`=0; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@THORIM,0,0,0,62,0,100,0,9926,0,0,0,33,30514,0,0,0,0,0,7,0,0,0,0,0,0,0,'Thorim - gossip select - give quest credit'); + +UPDATE `gossip_menu_option` SET `action_menu_id`=9927 WHERE `menu_id`=9924; +UPDATE `gossip_menu_option` SET `action_menu_id`=9926 WHERE `menu_id`=9927; +UPDATE `gossip_menu_option` SET `action_menu_id`=9925 WHERE `menu_id`=9926; + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=9924; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(15,9924,0,0,9,13064,0,0,0,'','Thorim - Show gossip if quest accepted'); diff --git a/sql/old/3.3.5a/2012_09_03_00_world_misc.sql b/sql/old/3.3.5a/2012_09_03_00_world_misc.sql new file mode 100644 index 00000000000..e8910c78b40 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_03_00_world_misc.sql @@ -0,0 +1,36 @@ +-- Cold Hearted (12856) + +SET @NPC_CAPTIVE_DRAKE := 29708; -- Captive Proto-Drake +SET @NPC_FREED_DRAKE := 29709; -- Freed Proto-Drake +SET @NPC_PRISONER := 29639; -- Brunnhildar Prisoner +SET @NPC_LIBERATED := 29734; -- Liberated Brunnhildar + +SET @SPELL_SUM_FREE_DRAKE := 55028; -- Summon Freed Proto-Drake +SET @SPELL_ICE_SHARD := 55046; -- Ice Shard (Rank 3) +SET @SPELL_FREE_PRISONER := 55048; -- Free Brunnhildar Prisoner +SET @AURA_IMPRISONMENT := 54894; -- Icy Imprisonment + + +UPDATE `creature_template` SET `speed_walk`=1,`speed_run`=1.14286,`spell1`=@SPELL_ICE_SHARD,`HoverHeight`=4,`unit_flags`=0x1000008,`InhabitType`=4,`ScriptName`='npc_freed_protodrake' WHERE `entry`=@NPC_FREED_DRAKE; +UPDATE `creature_template` SET `unit_flags`=33554432,`AIName`='SmartAI' WHERE `entry`=@NPC_LIBERATED; + +DELETE FROM `npc_spellclick_spells` WHERE `npc_entry`=@NPC_CAPTIVE_DRAKE; +INSERT INTO `npc_spellclick_spells` (`npc_entry`,`spell_id`,`cast_flags`,`user_type`) VALUES +(@NPC_CAPTIVE_DRAKE,@SPELL_SUM_FREE_DRAKE,1,0); + +DELETE FROM `creature_template_addon` WHERE `entry`=@NPC_FREED_DRAKE; +INSERT INTO `creature_template_addon` (`entry`,`mount`,`bytes1`,`bytes2`,`auras`) VALUES +(@NPC_FREED_DRAKE,0,0x3000000,0x1,'55034 61183'); + +DELETE FROM `creature_text` WHERE `entry`=@NPC_FREED_DRAKE; +INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`comment`) VALUES +(@NPC_FREED_DRAKE,0,0,'Return to Brunnhildar Village!',42,0,100,0,0,0,'Freed Proto-Drake'), +(@NPC_FREED_DRAKE,0,1,'The proto-drake smells freedom and flies homeward!',41,0,100,0,0,0,'Freed Proto-Drake'); + +DELETE FROM `spell_scripts` WHERE `id`=@SPELL_FREE_PRISONER; +INSERT INTO `spell_scripts` (`id`,`effIndex`,`delay`,`command`,`datalong`,`datalong2`,`dataint`,`x`,`y`,`z`,`o`) VALUES +(@SPELL_FREE_PRISONER,0,0,14,@AURA_IMPRISONMENT,0,0,0,0,0,0); + +DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid`=@NPC_LIBERATED; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@NPC_LIBERATED,0,0,0,54,0,100,0,0,0,0,0,41,30000,0,0,0,0,0,1,0,0,0,0,0,0,0,'Liberated Brunnhildar - On Spawn - Despawn in 30 seconds'); diff --git a/sql/old/3.3.5a/2012_09_03_01_world_gameobject_template.sql b/sql/old/3.3.5a/2012_09_03_01_world_gameobject_template.sql new file mode 100644 index 00000000000..ff0907eee6e --- /dev/null +++ b/sql/old/3.3.5a/2012_09_03_01_world_gameobject_template.sql @@ -0,0 +1 @@ +UPDATE `gameobject_template` SET `flags`=40 WHERE `entry`=186371; -- Zeppelin diff --git a/sql/old/3.3.5a/2012_09_03_02_world_quest_template.sql b/sql/old/3.3.5a/2012_09_03_02_world_quest_template.sql new file mode 100644 index 00000000000..0c0a7ce4e40 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_03_02_world_quest_template.sql @@ -0,0 +1,2 @@ +-- Stalk the Stalker (9719) quest requirements fix +UPDATE `quest_template` SET `RequiredRaces` = 0 WHERE `Id` = 9719; diff --git a/sql/old/3.3.5a/2012_09_07_00_characters_characters.sql b/sql/old/3.3.5a/2012_09_07_00_characters_characters.sql new file mode 100644 index 00000000000..26ad904b4a0 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_07_00_characters_characters.sql @@ -0,0 +1,2 @@ +ALTER TABLE `characters` MODIFY `name` + VARCHAR(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL; diff --git a/sql/old/3.3.5a/2012_09_07_00_world_spell_bonus_data.sql b/sql/old/3.3.5a/2012_09_07_00_world_spell_bonus_data.sql new file mode 100644 index 00000000000..3d39c06051a --- /dev/null +++ b/sql/old/3.3.5a/2012_09_07_00_world_spell_bonus_data.sql @@ -0,0 +1,4 @@ +SET @Spell := 28715; -- Flamecap Fire +DELETE FROM `spell_bonus_data` WHERE `entry`=@Spell; +INSERT INTO `spell_bonus_data` (`entry`,`direct_bonus`,`dot_bonus`,`ap_bonus`,`ap_dot_bonus`,`comments`) VALUES +(@Spell,0,0,0,0, 'Flamecap Fire'); diff --git a/sql/old/3.3.5a/2012_09_07_01_world_creature_template.sql b/sql/old/3.3.5a/2012_09_07_01_world_creature_template.sql new file mode 100644 index 00000000000..16e4f670fd2 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_07_01_world_creature_template.sql @@ -0,0 +1 @@ +UPDATE `creature_template` SET `unit_flags2`=`unit_flags2`|0x800; -- UNIT_FLAG2_REGENERATE_POWER diff --git a/sql/old/3.3.5a/2012_09_07_02_world_spell_script_names.sql b/sql/old/3.3.5a/2012_09_07_02_world_spell_script_names.sql new file mode 100644 index 00000000000..652d45543e3 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_07_02_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM spell_script_names WHERE spell_id = -755; +INSERT IGNORE INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(-755, 'spell_warl_health_funnel'); diff --git a/sql/old/3.3.5a/2012_09_08_00_world_achievement_criteria_data.sql b/sql/old/3.3.5a/2012_09_08_00_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..cce5745dee9 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_08_00_world_achievement_criteria_data.sql @@ -0,0 +1,6 @@ +DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (10304,10313); +INSERT INTO `achievement_criteria_data` (`criteria_id`,`type`,`value1`,`value2`,`ScriptName`) VALUES +(10304,5,62320,0,''), +(10304,12,0,0,''), +(10313,5,62320,0,''), +(10313,12,1,0,''); diff --git a/sql/old/3.3.5a/2012_09_08_01_world_creature_template.sql b/sql/old/3.3.5a/2012_09_08_01_world_creature_template.sql new file mode 100644 index 00000000000..fb34f345f2d --- /dev/null +++ b/sql/old/3.3.5a/2012_09_08_01_world_creature_template.sql @@ -0,0 +1 @@ +UPDATE `creature_template` SET `InhabitType`=4 WHERE `entry` IN (32930,33909); -- Kologarn diff --git a/sql/old/3.3.5a/2012_09_08_02_world_achievement_criteria_data.sql b/sql/old/3.3.5a/2012_09_08_02_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..2f25f6f20fa --- /dev/null +++ b/sql/old/3.3.5a/2012_09_08_02_world_achievement_criteria_data.sql @@ -0,0 +1,10 @@ +-- Criteria data for achievement 'Wrecking Ball' +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry` IN (3368, 3369, 3370, 12578, 7623, 3371); +DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (3368, 3369, 3370, 12578, 7623, 3371); +INSERT INTO `achievement_criteria_data`(`criteria_id`,`type`,`value1`,`value2`,`ScriptName`) VALUES +(3368,2,0,0,''), +(3369,2,0,0,''), +(3370,2,0,0,''), +(12578,2,0,0,''), +(7623,2,0,0,''), +(3371,2,0,0,''); diff --git a/sql/old/3.3.5a/2012_09_09_00_world_command.sql b/sql/old/3.3.5a/2012_09_09_00_world_command.sql new file mode 100644 index 00000000000..1fb3247bfbb --- /dev/null +++ b/sql/old/3.3.5a/2012_09_09_00_world_command.sql @@ -0,0 +1,4 @@ +DELETE FROM `command` WHERE `name` = 'start'; +DELETE FROM `command` WHERE `name` = 'unstuck'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('unstuck', 0, 'Syntax: .unstuck $playername [inn/graveyard/startzone]\n\nTeleports specified player to specified location. Default location is player\'s current hearth location.'); diff --git a/sql/old/3.3.5a/2012_09_09_01_world_trinity_string.sql b/sql/old/3.3.5a/2012_09_09_01_world_trinity_string.sql new file mode 100644 index 00000000000..2f3c0aa1938 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_09_01_world_trinity_string.sql @@ -0,0 +1,3 @@ +DELETE FROM `trinity_string` WHERE `entry`=63; -- Existing entry 63 is not present in Language.h. It's safe to remove it. +INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES +(63, 'You can''t do that right now.'); diff --git a/sql/old/3.3.5a/2012_09_09_02_world_spell_script_names.sql b/sql/old/3.3.5a/2012_09_09_02_world_spell_script_names.sql new file mode 100644 index 00000000000..36e5b08c36d --- /dev/null +++ b/sql/old/3.3.5a/2012_09_09_02_world_spell_script_names.sql @@ -0,0 +1,10 @@ +-- Gift of the Naaru +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_gift_of_naaru'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(28880,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_WARRIOR +(59542,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_PALADIN +(59543,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_HUNTER +(59544,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_PRIEST +(59545,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_DEATHKNIGHT +(59547,'spell_gen_gift_of_naaru'), -- SPELLFAMILY_SHAMAN +(59548,'spell_gen_gift_of_naaru'); -- SPELLFAMILY_MAGE diff --git a/sql/old/3.3.5a/2012_09_09_03_world_spell_bonus_data.sql b/sql/old/3.3.5a/2012_09_09_03_world_spell_bonus_data.sql new file mode 100644 index 00000000000..a08c494da1b --- /dev/null +++ b/sql/old/3.3.5a/2012_09_09_03_world_spell_bonus_data.sql @@ -0,0 +1,9 @@ +DELETE FROM `spell_bonus_data` WHERE `entry` IN (28880,59542,59543,59544,59545,59547,59548); +INSERT INTO `spell_bonus_data` (`entry`,`direct_bonus`,`dot_bonus`,`ap_bonus`,`ap_dot_bonus`,`comments`) VALUES +(28880,0,0,0,0,'Warrior - Gift of the Naaru'), +(59542,0,0,0,0,'Paladin - Gift of the Naaru'), +(59543,0,0,0,0,'Hunter - Gift of the Naaru'), +(59544,0,0,0,0,'Priest - Gift of the Naaru'), +(59545,0,0,0,0,'Deathknight - Gift of the Naaru'), +(59547,0,0,0,0,'Shaman - Gift of the Naaru'), +(59548,0,0,0,0,'Mage - Gift of the Naaru'); diff --git a/sql/old/3.3.5a/2012_09_09_04_world_quest_template.sql b/sql/old/3.3.5a/2012_09_09_04_world_quest_template.sql new file mode 100644 index 00000000000..418c5badb36 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_09_04_world_quest_template.sql @@ -0,0 +1 @@ +UPDATE `quest_template` SET `OfferRewardText`='Excellent, $N. You''ve saved me a lot of work!$b$bBut don''t think that I''m not grateful!' WHERE `Id`=6571; diff --git a/sql/old/3.3.5a/2012_09_10_00_world_game_event.sql b/sql/old/3.3.5a/2012_09_10_00_world_game_event.sql new file mode 100644 index 00000000000..edd6413379c --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_00_world_game_event.sql @@ -0,0 +1,3 @@ +UPDATE `game_event` SET `start_time`='2012-11-04 00:01:00' WHERE `eventEntry`=3; -- Darkmoon Faire - Terrokkar +UPDATE `game_event` SET `start_time`='2012-12-02 00:01:00' WHERE `eventEntry`=4; -- Darkmoon Faire - Elwynn +UPDATE `game_event` SET `start_time`='2012-10-07 00:01:00' WHERE `eventEntry`=5; -- Darkmoon Faire - Mulgore diff --git a/sql/old/3.3.5a/2012_09_10_01_world_quest_template.sql b/sql/old/3.3.5a/2012_09_10_01_world_quest_template.sql new file mode 100644 index 00000000000..2db8883d92c --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_01_world_quest_template.sql @@ -0,0 +1 @@ +UPDATE `quest_template` SET `OfferRewardText`="What!? If I knew that Pao'ka Swiftmountain was going to snoop around Highperch, I would have chained him to a totem! His father was reluctant allowing him to come with me to Thousand Needles. We came here to study the different creatures that inhabit these beautiful lands.$b$bI appreciate the help you have shown Pao'ka. I hope this covers any misfortunes this deed has cost you." WHERE `Id`=4770; diff --git a/sql/old/3.3.5a/2012_09_10_02_world_creature_text.sql b/sql/old/3.3.5a/2012_09_10_02_world_creature_text.sql new file mode 100644 index 00000000000..7a3b1a2d86f --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_02_world_creature_text.sql @@ -0,0 +1 @@ +UPDATE `creature_text` SET `text`='Good news, everyone! I think I''ve perfected a plague that will destroy all life on Azeroth!' WHERE `entry`=36678 AND `groupid`=4 AND `id`=0; diff --git a/sql/old/3.3.5a/2012_09_10_03_world_quest_template.sql b/sql/old/3.3.5a/2012_09_10_03_world_quest_template.sql new file mode 100644 index 00000000000..aae769ced71 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_03_world_quest_template.sql @@ -0,0 +1,3 @@ +-- Grark Lorkrub should be available only when Kill On Sight: High Ranking Dark Iron Officials is complete +UPDATE `quest_template` SET `NextQuestId`=4122 WHERE `Id`=4082; +UPDATE `quest_template` SET `PrevQuestId`=4082 WHERE `Id`=4122; diff --git a/sql/old/3.3.5a/2012_09_10_04_world_quest_template.sql b/sql/old/3.3.5a/2012_09_10_04_world_quest_template.sql new file mode 100644 index 00000000000..5805debd094 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_04_world_quest_template.sql @@ -0,0 +1,2 @@ +-- Fix some quest requirements +UPDATE `quest_template` SET `PrevQuestId`=3906 WHERE `Id` IN (3907,7201); -- Disharmony of Fire and The Last Element are available only, if Disharmony of Flame is completed diff --git a/sql/old/3.3.5a/2012_09_10_06_world_creature_template.sql b/sql/old/3.3.5a/2012_09_10_06_world_creature_template.sql new file mode 100644 index 00000000000..24a60b107ec --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_06_world_creature_template.sql @@ -0,0 +1 @@ +UPDATE `creature_template` SET `flags_extra`=`flags_extra`|256 WHERE `entry` IN (36897, 38138); -- Little Ooze diff --git a/sql/old/3.3.5a/2012_09_10_07_world_go_loot_template.sql b/sql/old/3.3.5a/2012_09_10_07_world_go_loot_template.sql new file mode 100644 index 00000000000..a5e30edfe2c --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_07_world_go_loot_template.sql @@ -0,0 +1,2 @@ +-- Vic's Keys drop chance ( http://old.wowhead.com/object=190778 ) by nelegalno +UPDATE `gameobject_loot_template` SET `ChanceOrQuestChance` = -100 WHERE `entry`=24861 AND `item`=39264; diff --git a/sql/old/3.3.5a/2012_09_10_08_world_spell_area.sql b/sql/old/3.3.5a/2012_09_10_08_world_spell_area.sql new file mode 100644 index 00000000000..4e4e36051c9 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_08_world_spell_area.sql @@ -0,0 +1,5 @@ +-- Cast Armistice in front of the pavillions as well +DELETE FROM `spell_area` WHERE `spell`=64373 AND `area` IN (4676, 4677); +INSERT INTO `spell_area` (`spell`,`area`,`quest_start`,`quest_start_active`,`quest_end`,`aura_spell`,`racemask`,`gender`,`autocast`) VALUES +(64373,4676,0,0,0,0,0,2,1), -- Sunreaver Pavillion +(64373,4677,0,0,0,0,0,2,1); -- SIlver Covenant Pavillion diff --git a/sql/old/3.3.5a/2012_09_10_09_world_creature_involvedrelation.sql b/sql/old/3.3.5a/2012_09_10_09_world_creature_involvedrelation.sql new file mode 100644 index 00000000000..e30e1559c54 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_09_world_creature_involvedrelation.sql @@ -0,0 +1,4 @@ +DELETE FROM creature_involvedrelation WHERE quest IN (25500, 25286); +INSERT INTO creature_involvedrelation (id, quest) VALUES +(39675, 25500), +(39675, 25286); diff --git a/sql/old/3.3.5a/2012_09_10_10_world_gossips.sql b/sql/old/3.3.5a/2012_09_10_10_world_gossips.sql new file mode 100644 index 00000000000..042b05dc83a --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_10_world_gossips.sql @@ -0,0 +1,111 @@ +-- gossip assignation from sniff +UPDATE `creature_template` SET `gossip_menu_id`=4534 WHERE `entry`=3047; -- Archmage Shymm <Mage Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=4536 WHERE `entry`=3048; -- Ursyn Ghull <Mage Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=12670 WHERE `entry`=6328; -- Dannie Fizzwizzle <Demon Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=12670 WHERE `entry`=6373; -- Dane Winslow <Demon Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=12670 WHERE `entry`=6374; -- Cylina Darkheart <Demon Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=1622 WHERE `entry`=8965; -- Shawn +UPDATE `creature_template` SET `gossip_menu_id`=4119 WHERE `entry`=11047; -- Kray <Apprentice Alchemist> +UPDATE `creature_template` SET `gossip_menu_id`=4266 WHERE `entry`=11051; -- Vhan <Apprentice Tailor> +UPDATE `creature_template` SET `gossip_menu_id`=4154 WHERE `entry`=11065; -- Thonys Pillarstone <Apprentice Enchanter> +UPDATE `creature_template` SET `gossip_menu_id`=4158 WHERE `entry`=11071; -- Mot Dawnstrider <Apprentice Enchanter> +UPDATE `creature_template` SET `gossip_menu_id`=4204 WHERE `entry`=11081; -- Faldron <Apprentice Leatherworker> +UPDATE `creature_template` SET `gossip_menu_id`=4181 WHERE `entry`=11083; -- Darianna <Apprentice Leatherworker> +UPDATE `creature_template` SET `gossip_menu_id`=4207 WHERE `entry`=11084; -- Tarn <Apprentice Leatherworker> +UPDATE `creature_template` SET `gossip_menu_id`=5142 WHERE `entry`=13442; -- Arch Druid Renferal +UPDATE `creature_template` SET `gossip_menu_id`=5141 WHERE `entry`=13443; -- Druid of the Grove +UPDATE `creature_template` SET `gossip_menu_id`=5081 WHERE `entry`=13447; -- Corporal Noreg Stormpike +UPDATE `creature_template` SET `gossip_menu_id`=5281 WHERE `entry`=13577; -- Stormpike Ram Rider Commander +UPDATE `creature_template` SET `gossip_menu_id`=7993 WHERE `entry`=15991; -- Lady Dena Kennedy +UPDATE `creature_template` SET `gossip_menu_id`=7471 WHERE `entry`=17421; -- Clopper Wizbang <Explorers' League> +UPDATE `creature_template` SET `gossip_menu_id`=7455 WHERE `entry`=17424; -- Anchorite Paetheus <First Aid Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=7459 WHERE `entry`=17434; -- Morae <Herbalism Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=7461 WHERE `entry`=17599; -- Aonar +UPDATE `creature_template` SET `gossip_menu_id`=7462 WHERE `entry`=17649; -- Kessel <Elekk Lord> +UPDATE `creature_template` SET `gossip_menu_id`=9821 WHERE `entry`=17666; -- Astur <Stable Master> +UPDATE `creature_template` SET `gossip_menu_id`=7463 WHERE `entry`=17676; -- Achelus +UPDATE `creature_template` SET `gossip_menu_id`=7464 WHERE `entry`=17703; -- Messenger Hermesius +UPDATE `creature_template` SET `gossip_menu_id`=8298 WHERE `entry`=17712; -- Captain Edward Hanes +UPDATE `creature_template` SET `gossip_menu_id`=7835 WHERE `entry`=17927; -- Scout Jorli +UPDATE `creature_template` SET `gossip_menu_id`=7738 WHERE `entry`=18252; -- Andarl +UPDATE `creature_template` SET `gossip_menu_id`=7753 WHERE `entry`=18387; -- Bertelm +UPDATE `creature_template` SET `gossip_menu_id`=7743 WHERE `entry`=18389; -- Thander +UPDATE `creature_template` SET `gossip_menu_id`=7752 WHERE `entry`=18390; -- Ros'eleth +UPDATE `creature_template` SET `gossip_menu_id`=7695 WHERE `entry`=18416; -- Huntress Kima +UPDATE `creature_template` SET `gossip_menu_id`=7698 WHERE `entry`=18459; -- Jenai Starwhisper +UPDATE `creature_template` SET `gossip_menu_id`=7745 WHERE `entry`=18704; -- Taela Everstride +UPDATE `creature_template` SET `gossip_menu_id`=7773 WHERE `entry`=18713; -- Lieutenant Gravelhammer +UPDATE `creature_template` SET `gossip_menu_id`=7814 WHERE `entry`=18745; -- Captain Auric Sunchaser +UPDATE `creature_template` SET `gossip_menu_id`=7833 WHERE `entry`=18804; -- Prospector Nachlan <Explorers' League> +UPDATE `creature_template` SET `gossip_menu_id`=7940 WHERE `entry`=19137; -- "Shotgun" Jones <Nesingwary Safari> +UPDATE `creature_template` SET `gossip_menu_id`=8433 WHERE `entry`=19340; -- Mi'irku Farstep <Portal Trainer> +UPDATE `creature_template` SET `gossip_menu_id`=7973 WHERE `entry`=19375; -- Eli Thunderstrike <Sky'ree's Keeper> +UPDATE `creature_template` SET `gossip_menu_id`=8251 WHERE `entry`=21151; -- Borgrim Stouthammer <Explorers' League> +UPDATE `creature_template` SET `gossip_menu_id`=8247 WHERE `entry`=21158; -- Commander Skyshadow +UPDATE `creature_template` SET `gossip_menu_id`=8252 WHERE `entry`=21197; -- Bronwyn Stouthammer <Explorers' League> +UPDATE `creature_template` SET `gossip_menu_id`=8566 WHERE `entry`=22832; -- Morthis Whisperwing <Druid of the Talon> + +-- gossip from sniff +DELETE FROM `gossip_menu` WHERE (`entry`=1621 AND `text_id`=2273) OR (`entry`=1622 AND `text_id`=2276) OR (`entry`=4119 AND `text_id`=5040) OR (`entry`=4154 AND `text_id`=5184) OR (`entry`=4158 AND `text_id`=5196) OR (`entry`=4181 AND `text_id`=5273) OR (`entry`=4204 AND `text_id`=5325) OR (`entry`=4207 AND `text_id`=5340) OR (`entry`=4266 AND `text_id`=5428) OR (`entry`=4534 AND `text_id`=563) OR (`entry`=4536 AND `text_id`=563) OR (`entry`=5081 AND `text_id`=6288) OR (`entry`=5141 AND `text_id`=6173) OR (`entry`=5142 AND `text_id`=6174) OR (`entry`=5281 AND `text_id`=6313) OR (`entry`=7455 AND `text_id`=9029) OR (`entry`=7459 AND `text_id`=9034) OR (`entry`=7461 AND `text_id`=9037) OR (`entry`=7462 AND `text_id`=9041) OR (`entry`=7463 AND `text_id`=9042) OR (`entry`=7464 AND `text_id`=9043) OR (`entry`=7471 AND `text_id`=9054) OR (`entry`=7695 AND `text_id`=9389) OR (`entry`=7698 AND `text_id`=9393) OR (`entry`=7738 AND `text_id`=9471) OR (`entry`=7743 AND `text_id`=9481) OR (`entry`=7745 AND `text_id`=9484) OR (`entry`=7752 AND `text_id`=9492) OR (`entry`=7753 AND `text_id`=9493) OR (`entry`=7773 AND `text_id`=9521) OR (`entry`=7814 AND `text_id`=9566) OR (`entry`=7833 AND `text_id`=9586) OR (`entry`=7835 AND `text_id`=9591) OR (`entry`=7940 AND `text_id`=9733) OR (`entry`=7973 AND `text_id`=9805) OR (`entry`=7993 AND `text_id`=9845) OR (`entry`=8247 AND `text_id`=10264) OR (`entry`=8251 AND `text_id`=10270) OR (`entry`=8252 AND `text_id`=10271) OR (`entry`=8298 AND `text_id`=10352) OR (`entry`=8432 AND `text_id`=10538) OR (`entry`=8433 AND `text_id`=10291) OR (`entry`=8433 AND `text_id`=10292) OR (`entry`=8566 AND `text_id`=10735); +INSERT INTO `gossip_menu` (`entry`, `text_id`) VALUES +(1621, 2273), -- 8962 +(1622, 2276), -- 8965 +(4119, 5040), -- 11047 +(4154, 5184), -- 11065 +(4158, 5196), -- 11071 +(4181, 5273), -- 11083 +(4204, 5325), -- 11081 +(4207, 5340), -- 11084 +(4266, 5428), -- 11051 +(4534, 563), -- 3047 +(4536, 563), -- 3048 +(5081, 6288), -- 13447 +(5141, 6173), -- 13443 +(5142, 6174), -- 13442 +(5281, 6313), -- 13577 +(7455, 9029), -- 17424 +(7459, 9034), -- 17434 +(7461, 9037), -- 17599 +(7462, 9041), -- 17649 +(7463, 9042), -- 17676 +(7464, 9043), -- 17703 +(7471, 9054), -- 17421 +(7695, 9389), -- 18416 +(7698, 9393), -- 18459 +(7738, 9471), -- 18252 +(7743, 9481), -- 18389 +(7745, 9484), -- 18704 +(7752, 9492), -- 18390 +(7753, 9493), -- 18387 +(7773, 9521), -- 18713 +(7814, 9566), -- 18745 +(7833, 9586), -- 18804 +(7835, 9591), -- 17927 +(7940, 9733), -- 19137 +(7973, 9805), -- 19375 +(7993, 9845), -- 15991 +(8247, 10264), -- 21158 +(8251, 10270), -- 21151 +(8252, 10271), -- 21197 +(8298, 10352), -- 17712 +(8432, 10538), -- 21983 +(8433, 10291), -- 19340 +(8433, 10292), -- 19340 +(8566, 10735); -- 22832 + +-- correct npc_flags for npc from sniff +UPDATE `creature_template` SET `npcflag`=0 WHERE `entry`=3210; -- Brave Proudsnout +UPDATE `creature_template` SET `npcflag`=0 WHERE `entry`=3211; -- Brave Lightninghorn +UPDATE `creature_template` SET `npcflag`=0 WHERE `entry`=3213; -- Brave Running Wolf +UPDATE `creature_template` SET `npcflag`=0 WHERE `entry`=3214; -- Brave Greathoof +UPDATE `creature_template` SET `npcflag`=0 WHERE `entry`=3502; -- Ratchet Bruiser +UPDATE `creature_template` SET `npcflag`=3 WHERE `entry`=21151; -- Borgrim Stouthammer <Explorers' League> +UPDATE `creature_template` SET `npcflag`=3 WHERE `entry`=21197; -- Bronwyn Stouthammer <Explorers' League> +UPDATE `creature_template` SET `npcflag`=2 WHERE `entry`=21469; -- Daranelle + +-- Add condition +DELETE FROM `conditions` WHERE (`SourceTypeOrReferenceId`=14 AND `SourceGroup`=8433 AND `SourceEntry`=10291) OR (`SourceTypeOrReferenceId`=14 AND `SourceGroup`=8433 AND `SourceEntry`=10292) OR (`SourceTypeOrReferenceId`=14 AND `SourceGroup`=12670 AND `SourceEntry`=12549); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(14,8433,10291,0,0,15,0,128,0,0,1,0,'','Show gossip text if player is not a mage'), +(14,8433,10292,0,0,15,0,128,0,0,0,0,'','Show gossip text if player is a mage'), +(14,12670,12549,0,0,15,0,256,0,0,1,0,'','Show gossip text if player is not a Warlock'); diff --git a/sql/old/3.3.5a/2012_09_10_11_world_event_scripts.sql b/sql/old/3.3.5a/2012_09_10_11_world_event_scripts.sql new file mode 100644 index 00000000000..e0b122ede05 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_11_world_event_scripts.sql @@ -0,0 +1,7 @@ +-- Finding the Keymaster by nelegalno + +UPDATE `quest_template` SET `SpecialFlags` = 0, `RequiredSpellCast1` = 0 WHERE `ID` = 10256; +DELETE FROM `event_scripts` WHERE id=12857; +INSERT INTO `event_scripts` (`id`,`delay`,`command`,`datalong`,`datalong2`,`dataint`,`x`,`y`,`z`,`o`) VALUES +(12857,0,10,19938,3000000,0,2248.43,2227.97,138.56,2.48121), +(12857,1,8,19938,1,0,0,0,0,0); diff --git a/sql/old/3.3.5a/2012_09_10_12_world_sai.sql b/sql/old/3.3.5a/2012_09_10_12_world_sai.sql new file mode 100644 index 00000000000..99111fb5961 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_12_world_sai.sql @@ -0,0 +1,4 @@ +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry`=20243; +DELETE FROM `smart_scripts` WHERE `entryorguid`=20243 AND `id`=0 AND `source_type`=0; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(20243,0,0,0,8,0,100,0,256,0,0,0,19,0,0,0,0,0,0,1,0,0,0,0.0,0.0,0.0,0.0,"Scrapped Fel Reaver - On Spellhit - Remove - OOC Not attackable - flags"); diff --git a/sql/old/3.3.5a/2012_09_10_13_world_creature_model_info.sql b/sql/old/3.3.5a/2012_09_10_13_world_creature_model_info.sql new file mode 100644 index 00000000000..339072d0502 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_10_13_world_creature_model_info.sql @@ -0,0 +1,4 @@ +UPDATE `creature_model_info` SET `modelid_other_gender`=4264 WHERE `modelid`=4261; -- Female orc grunt +UPDATE `creature_model_info` SET `modelid_other_gender`=4263 WHERE `modelid`=4262; -- Female tauren +UPDATE `creature_model_info` SET `modelid_other_gender`=4262 WHERE `modelid`=4263; -- Male tauren +UPDATE `creature_model_info` SET `modelid_other_gender`=4261 WHERE `modelid`=4264; -- Male orc grunt diff --git a/sql/old/3.3.5a/2012_09_11_00_world_misc.sql b/sql/old/3.3.5a/2012_09_11_00_world_misc.sql new file mode 100644 index 00000000000..0f47f1bf2e9 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_11_00_world_misc.sql @@ -0,0 +1,11 @@ +-- ToCr orbs + +SET @NPC_ORB1 := 34606; -- Frost Sphere +SET @NPC_ORB2 := 34649; -- Frost Sphere + +UPDATE `creature_template` SET `speed_walk`=1.2,`speed_run`=1.42,`InhabitType`=7 WHERE `entry` IN (@NPC_ORB1,@NPC_ORB2); + +DELETE FROM `creature_template_addon` WHERE `entry` IN (@NPC_ORB1,@NPC_ORB2); +INSERT INTO `creature_template_addon` (`entry`,`mount`,`bytes1`,`bytes2`,`auras`) VALUES +(@NPC_ORB1,0,0x3000000,0x1,''), +(@NPC_ORB2,0,0x3000000,0x1,''); diff --git a/sql/old/3.3.5a/2012_09_12_00_world_misc.sql b/sql/old/3.3.5a/2012_09_12_00_world_misc.sql new file mode 100644 index 00000000000..50896ce414c --- /dev/null +++ b/sql/old/3.3.5a/2012_09_12_00_world_misc.sql @@ -0,0 +1,9 @@ +-- East Porticullis(195648): close and corrections +UPDATE `gameobject` SET `phaseMask`=1,`rotation2`=0.7071065,`rotation3`=0.707107,`spawntimesecs`=7200,`animprogress`=255,`state`=0 WHERE `guid`=151176; + +-- North Portcullis(195650): delete extra spawn and corrections +DELETE FROM `gameobject` WHERE `guid`=150080; +UPDATE `gameobject` SET `phaseMask`=1,`rotation2`=0.7071065,`rotation3`=0.707107,`spawntimesecs`=7200,`animprogress`=255,`state`=1 WHERE `guid`=151178; + +-- Web Door(195485): corrections +UPDATE `gameobject` SET `spawnMask`=15,`rotation2`=0.7071067,`rotation3`=0.7071068,`spawntimesecs`=7200,`animprogress`=255 WHERE `guid`=151192; diff --git a/sql/old/3.3.5a/2012_09_12_01_world_creature.sql b/sql/old/3.3.5a/2012_09_12_01_world_creature.sql new file mode 100644 index 00000000000..1b7fa2d78ef --- /dev/null +++ b/sql/old/3.3.5a/2012_09_12_01_world_creature.sql @@ -0,0 +1 @@ +DELETE FROM `creature` WHERE `id`=36095; diff --git a/sql/old/3.3.5a/2012_09_13_00_world_item_template.sql b/sql/old/3.3.5a/2012_09_13_00_world_item_template.sql new file mode 100644 index 00000000000..48b9d3a107f --- /dev/null +++ b/sql/old/3.3.5a/2012_09_13_00_world_item_template.sql @@ -0,0 +1 @@ +ALTER TABLE `item_template` CHANGE unk0 SoundOverrideSubclass tinyint(3) NOT NULL DEFAULT '-1'; diff --git a/sql/old/3.3.5a/2012_09_13_01_world_fires_over_skettis.sql b/sql/old/3.3.5a/2012_09_13_01_world_fires_over_skettis.sql new file mode 100644 index 00000000000..de9ba5a78fe --- /dev/null +++ b/sql/old/3.3.5a/2012_09_13_01_world_fires_over_skettis.sql @@ -0,0 +1,91 @@ +-- Add support for quest ID: 11008 - "Fires Over Skettis" based on Warpten fix and Nelegalno/shlomi1515 updates +-- Also add support for achievement - http://www.wowhead.com/achievement=1275/bombs-away +SET @TRIGGER := 22991; +SET @EGG := 185549; +SET @SKYBLAST := 39844; +SET @SUMMEGG := 39843; +-- Adds SAI support for Monstrous Kaliri Egg Trigger and the GO +UPDATE `creature_template` SET `AIName`= 'SmartAI' WHERE `entry`=@TRIGGER; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@TRIGGER AND `source_type`=0; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@TRIGGER*100 AND `source_type`=9; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@TRIGGER,0,0,0,25,0,100,0,0,0,0,0,11,@SUMMEGG,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - On spawn/reset - Summon Monstrous Kaliri Egg (object wild)'), +(@TRIGGER,0,1,2,8,0,100,0,@SKYBLAST,0,0,0,33,@TRIGGER,0,0,0,0,0,16,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - On Skyguard Blasting Charge hit - Give kill credit to invoker party'), +(@TRIGGER,0,2,3,61,0,100,0,0,0,0,0,45,0,1,0,0,0,0,20,@EGG,1,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - Linked with previous event - Despawn'), +(@TRIGGER,0,3,0,61,0,100,0,0,0,0,0,80,@TRIGGER*100,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - Linked with previous event - Start script 0'), +(@TRIGGER*100,9,0,0,0,0,100,0,44000,44000,0,0,11,@SUMMEGG,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger /On actionlist/ - Action 0 - Cast Summon Monstrous Kaliri Egg'); +-- Add SAI for Cannonball Stack +UPDATE `gameobject_template` SET `AIName`='SmartGameObjectAI' WHERE `entry`=@EGG; +DELETE FROM `smart_scripts` WHERE `source_type`=1 AND `entryorguid`=@EGG; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@EGG,1,0,0,38,0,100,0,0,1,0,0,70,45,0,0,0,0,0,1,0,0,0,0,0,0,0,' Monstrous Kaliri Egg - On data set 0 1 - Respawn object /make it reappear after 45 secs/'); +-- Remove achievement from disabled +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=3922; +-- Insert GO spawns taken directly from already spawned triggers coordinates = no need to sniff them +SET @guid := 74685; +DELETE FROM `gameobject` WHERE `id`=@EGG; +INSERT INTO `gameobject` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`) VALUES +(@guid+0,@EGG,530,1,1,-3857.69,3426.25,363.733,-0.087267,180), +(@guid+1,@EGG,530,1,1,-3845.16,3332.2,338.59,2.9147,180), +(@guid+2,@EGG,530,1,1,-3965.16,3232.7,347.552,-0.122173,180), +(@guid+3,@EGG,530,1,1,-3955.86,3222.16,347.503,0.244346,180), +(@guid+4,@EGG,530,1,1,-3953.3,3227.94,347.564,-0.244346,180), +(@guid+5,@EGG,530,1,1,-4044.66,3287.29,348.362,0.349066,180), +(@guid+6,@EGG,530,1,1,-4041.39,3271,346.642,-2.09439,180), +(@guid+7,@EGG,530,1,1,-4049.31,3285.9,348.335,1.43117,180), +(@guid+8,@EGG,530,1,1,-4076.99,3415.22,334.008,-2.33874,180), +(@guid+9,@EGG,530,1,1,-4076.79,3412.91,334.617,-1.0821,180), +(@guid+10,@EGG,530,1,1,-4077.92,3412.57,334.768,-0.733038,180), +(@guid+11,@EGG,530,1,1,-4107.93,3121.5,357.427,1.01229,180), +(@guid+12,@EGG,530,1,1,-4108.31,3123.66,357.633,-0.680679,180), +(@guid+13,@EGG,530,1,1,-4110.19,3122.64,358.083,-0.034907,180), +(@guid+14,@EGG,530,1,1,-3996.89,3142.12,372.729,3.05433,180), +(@guid+15,@EGG,530,1,1,-4109.06,3019.1,352.24,0.261799,180), +(@guid+16,@EGG,530,1,1,-4018.35,3076.7,375.29,-0.733038,180), +(@guid+17,@EGG,530,1,1,-4184.98,3044.71,352.394,1.81514,180), +(@guid+18,@EGG,530,1,1,-4187.52,3040.39,352.071,-0.017453,180), +(@guid+19,@EGG,530,1,1,-4189.67,3039.9,352.247,-0.785398,180), +(@guid+20,@EGG,530,1,1,-4192.61,3045.1,352.096,3.14159,180), +(@guid+21,@EGG,530,1,1,-4192.02,3046.91,352.297,2.46091,180), +(@guid+22,@EGG,530,1,1,-4186.47,3047.19,352.316,2.60054,180), +(@guid+23,@EGG,530,1,1,-3915.67,2983.4,396.957,-1.91986,180), +(@guid+24,@EGG,530,1,1,-3883.21,3004.11,399.738,-1.64061,180), +(@guid+25,@EGG,530,1,1,-3883.26,3001.55,399.431,-2.3911,180), +(@guid+26,@EGG,530,1,1,-3884.29,3003.3,400.063,-1.88496,180), +(@guid+27,@EGG,530,1,1,-3903.02,3095.85,383.783,-2.28638,180), +(@guid+28,@EGG,530,1,1,-3898.45,3093.06,383.667,2.53073,180), +(@guid+29,@EGG,530,1,1,-3900.75,3100.75,383.795,-0.436333,180), +(@guid+30,@EGG,530,1,1,-4107.81,3023.42,352.142,1.06465,180), +(@guid+31,@EGG,530,1,1,-4113.58,3022.4,352.157,-0.645772,180), +(@guid+32,@EGG,530,1,1,-3893.09,3677.17,374.516,-1.23918,180), +(@guid+33,@EGG,530,1,1,-3892.47,3674,374.478,-2.14675,180), +(@guid+34,@EGG,530,1,1,-4198.53,3168.91,355.847,-0.383972,180), +(@guid+35,@EGG,530,1,1,-4197.01,3170.04,356.117,-1.15192,180), +(@guid+36,@EGG,530,1,1,-4196.54,3167.69,356.348,-0.541052,180), +(@guid+37,@EGG,530,1,1,-4020.07,3077.84,374.391,1.53589,180), +(@guid+38,@EGG,530,1,1,-4019.32,3079.74,375.109,-1.25664,180), +(@guid+39,@EGG,530,1,1,-3917.21,2981.62,396.483,0.733038,180), +(@guid+40,@EGG,530,1,1,-3918.45,2982.44,397.24,-1.72788,180), +(@guid+41,@EGG,530,1,1,-3839.35,3344.85,337.834,2.75762,180), +(@guid+42,@EGG,530,1,1,-3835.3,3344.77,338.155,-0.767945,180), +(@guid+43,@EGG,530,1,1,-3846.43,3430.29,363.729,0.488692,180), +(@guid+44,@EGG,530,1,1,-3864.13,3439.06,363.679,-0.05236,180), +(@guid+45,@EGG,530,1,1,-3863.24,3440.42,363.655,0.349066,180), +(@guid+46,@EGG,530,1,1,-3846.35,3439.34,363.628,-0.122173,180), +(@guid+47,@EGG,530,1,1,-3847.32,3441.39,363.648,0.453786,180), +(@guid+48,@EGG,530,1,1,-3686.21,3301,320.513,0.837758,180), +(@guid+49,@EGG,530,1,1,-3687.77,3299.85,320.307,2.75762,180), +(@guid+50,@EGG,530,1,1,-3692.64,3302.07,320.396,-0.226893,180), +(@guid+51,@EGG,530,1,1,-3661.91,3379.15,320.377,0.890118,180), +(@guid+52,@EGG,530,1,1,-3660.65,3381.9,320.182,1.18682,180), +(@guid+53,@EGG,530,1,1,-3665.48,3380.11,320.365,-0.471239,180), +(@guid+54,@EGG,530,1,1,-3685.07,3305.97,320.198,-2.87979,180), +(@guid+55,@EGG,530,1,1,-3688.3,3308.93,320.337,1.65806,180), +(@guid+56,@EGG,530,1,1,-3690.65,3306.77,320.43,-2.79253,180), +(@guid+57,@EGG,530,1,1,-3879.37,3665.22,374.393,-2.30383,180), +(@guid+58,@EGG,530,1,1,-3990.42,3139.13,372.878,-2.61799,180), +(@guid+59,@EGG,530,1,1,-3991.59,3134.33,372.703,-0.017453,180), +(@guid+60,@EGG,530,1,1,-3884.89,3684.98,374.492,-2.53073,180), +(@guid+61,@EGG,530,1,1,-3800.8,3789.62,314,6.0912,180), +(@guid+62,@EGG,530,1,1,-3799.02,3788.06,314.158,3.19395,180), +(@guid+63,@EGG,530,1,1,-3798.91,3790.61,313.852,3.63029,180); diff --git a/sql/old/3.3.5a/2012_09_13_01_world_ogrila.sql b/sql/old/3.3.5a/2012_09_13_01_world_ogrila.sql new file mode 100644 index 00000000000..4ccb02e02e5 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_13_01_world_ogrila.sql @@ -0,0 +1,158 @@ +-- Quest support for http://www.wowhead.com/quest=11010 "Bombing Run", http://www.wowhead.com/quest=11102 "Bombing Run" /druid/ and http://www.wowhead.com/quest=11023 "Bomb Them Again!" +-- Achievement support for http://www.wowhead.com/achievement=1282 and http://www.wowhead.com/achievement=1276, +-- Based on Warpten Script +SET @SKYGUARD_BOMB := 32456; +SET @Run_Dummy := 23118; +SET @Explosion_Bunny := 23119; +SET @Flak_Cannon := 23076; +SET @Flak_Cannon2 := 23082; +SET @Fel_Cannon_Dummy := 23077; +SET @RUN_MARK := 40196; +SET @THROW_BOMB := 40160; +SET @EXPLOSION_VISUAL := 40162; +SET @See_Invisibility := 40195; +SET @Invisibility := 40194; +SET @CANNONBALL_STACK := 185861; +-- Add class requirements for druid version of "Bombing Run" +UPDATE `quest_template` SET `RequiredClasses`=1024 WHERE `Id`=11102; +-- Add SAI support for Bombing Run Target Dummy +UPDATE `creature_template` SET `AIName`='SmartAI',`flags_extra`=`flags_extra`|128 WHERE `entry`=@Run_Dummy; +DELETE FROM `creature_ai_scripts` WHERE `creature_id`=@Run_Dummy; +DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid`=@Run_Dummy; +DELETE FROM `smart_scripts` WHERE `source_type`=9 AND `entryorguid`=@Run_Dummy*100; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@Run_Dummy,0,0,1,8,0,100,0,@THROW_BOMB,0,1000,1000,33,@Run_Dummy,0,0,0,0,0,16,0,0,0,0,0,0,0, 'Run Target Dummy - On spell Throw Bomb hit - Give kill credit to invoker party'), +(@Run_Dummy,0,1,2,61,0,100,0,0,0,0,0,28,@RUN_MARK,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Run Target Dummy - Linked with previous event - Remove auras from hunter mark'), +(@Run_Dummy,0,2,3,61,0,100,0,0,0,0,0,45,0,1,0,0,0,0,20,@CANNONBALL_STACK,3,0,0,0,0,0, 'Run Target Dummy - Linked with previous event - Data set 0 1 on Cannonball Stack'), +(@Run_Dummy,0,3,4,61,0,100,0,0,0,0,0,45,0,1,0,0,0,0,19,@Explosion_Bunny,3,0,0,0,0,0, 'Run Target Dummy - Linked with previous event - Data set 0 1 on Explosion Bunny'), +(@Run_Dummy,0,4,0,61,0,100,0,0,0,0,0,80,@Run_Dummy*100,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Run Target Dummy - Linked with previous event - Start script 0'), +(@Run_Dummy*100,9,0,0,0,0,100,0,29000,29000,0,0,11,@RUN_MARK,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Run Target Dummy - Action 0 - Cast run mark on self'); +-- Add SAI for Cannonball Stack +UPDATE `gameobject_template` SET `AIName`='SmartGameObjectAI' WHERE `entry`=@CANNONBALL_STACK; +DELETE FROM `smart_scripts` WHERE `source_type`=1 AND `entryorguid`=@CANNONBALL_STACK; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@CANNONBALL_STACK,1,0,0,38,0,100,0,0,1,0,0,70,30,0,0,0,0,0,1,0,0,0,0,0,0,0,' Cannonball Stack - On data set 0 1 - Respawn object /make it reappear after 30 secs/'); +-- Add SAI support for Bombing Run Fel Cannon Dummy +UPDATE `creature_template` SET `AIName`='SmartAI',`unit_flags`=4,`flags_extra`=`flags_extra`|128 WHERE `entry`=@Fel_Cannon_Dummy; +DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid`=@Fel_Cannon_Dummy; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@Fel_Cannon_Dummy,0,0,0,8,0,100,0,40110,0,4350,5000,11,40119,0,0,0,0,0,19,@Flak_Cannon,5,0,0,0,0,0, 'Fel Cannon Dummy - On spell hit by Cannon trigger - Cast Aggro Burst on Flak Cannon'); +-- Add SAI support for Bombing Run Flak Cannon +UPDATE `creature_template` SET `AIName`='SmartAI',`unit_flags`=`unit_flags`|4|256|131072,`flags_extra`=`flags_extra`|2 WHERE `entry`=@Flak_Cannon; +DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid`=@Flak_Cannon; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@Flak_Cannon,0,0,0,25,0,100,0,0,0,0,0,11,40111,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Flak Cannon - On reset - Cast The Aggro Bunnies'), +(@Flak_Cannon,0,1,2,8,0,100,0,41598,0,0,0,66,0,0,0,0,0,0,7,0,0,0,0,0,0,0, 'Flak Cannon - On hit by Bolt Pair - Set orientation to invoker'), +(@Flak_Cannon,0,2,0,61,0,100,0,0,0,0,0,11,40109,0,0,0,0,0,7,0,0,0,0,0,0,0, 'Flak Cannon - Linked with previous event - Cast spell The Bolt'); +-- Add SAI support for Bombing Run Flak Cannon 2 /target bunny/ +UPDATE `creature_template` SET `AIName`='SmartAI',`flags_extra`=`flags_extra`|128,`InhabitType`=4 WHERE `entry`=@Flak_Cannon2; +DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid`=@Flak_Cannon2; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@Flak_Cannon2,0,0,0,54,0,100,0,0,0,0,0,11,41598,0,0,0,0,0,7,0,0,0,0,0,0,0, 'Flak Cannon 2 - On just summoned - Cast The Bolt Pair on invoker'), +(@Flak_Cannon2,0,1,2,8,0,100,0,40109,0,0,0,11,40075,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Flak Cannon 2 - On spell hit Cannon Bolt - Cast on self Fel Flak Fire'), +(@Flak_Cannon2,0,2,0,61,0,100,0,0,0,0,0,41,5000,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Flak Cannon 2 - Linked with previous event - Despawn in 5 sec'); +-- Add SAI support for Explosion Bunny +UPDATE `creature_template` SET `AIName`='SmartAI',`flags_extra`=`flags_extra`|128,`unit_flags`=0 WHERE `entry`=@Explosion_Bunny; +DELETE FROM `smart_scripts` WHERE `source_type`=0 AND `entryorguid`=@Explosion_Bunny; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@Explosion_Bunny,0,0,0,38,0,100,0,0,1,0,0,11,@EXPLOSION_VISUAL,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Explosion Bunny - On data set 0 1 - Cast Explosion Visual on self'); +-- Add conditions +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry` IN (@THROW_BOMB,40110,40112,40075); +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry` IN (@THROW_BOMB,40200,41598,40111); +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=22 AND `SourceEntry`=@Fel_Cannon_Dummy; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`Comment`) VALUES +(17,0,@THROW_BOMB,0,29,0,@Run_Dummy,35,0,0,0,'Throw Bomb requires Run Target Dummy within 35y'), +(13,1,@THROW_BOMB,0,31,0,3,@Run_Dummy,0,0,0,'Throw Bomb implicit effect 0 can hit only Run Target Dummy'), +(13,1,@THROW_BOMB,0,1,0,@RUN_MARK,0,0,0,0,'Throw Bomb can hit only targets under the aura of 40196'), +(17,0,40200,0,9,0,11010,0,0,1,0,'To cast remove see invisibility player must not be on quest 11010'), +(17,0,40200,0,9,0,11102,0,0,1,0,'To cast remove see invisibility player must not be on quest 11102'), +(17,0,40200,0,9,0,11023,0,0,1,0,'To cast remove see invisibility player must not be on quest 11023'), +(13,1,40110,0,31,0,3,23077,0,0,0,'Cannon Trigger implicit targets can be only Fel Cannon Dummies'), +(13,1,40110,0,35,0,1,65,2,0,0,'Cannon Trigger implicit hit can happen only on targets under 65 yards range'), +(17,0,40111,0,29,0,@Fel_Cannon_Dummy,10,0,1,0,'The Aggro Bunnies caster should not be around Fel Cannon Dummies to cast'), +(13,1,40112,0,31,0,4,0,0,0,0,'Bombing Run Dummy aggro check can hit players'), +(13,3,40075,0,31,0,4,0,0,0,0,'Fel Flak Fire effect 2 can hit only players'), +(22,1,@Fel_Cannon_Dummy,0,1,1,40119,0,0,1,0,'Fel Cannon Dummy event 0 will happen only if target is missing aura from aggro burst'); +-- Insert addon data +DELETE FROM `creature_template_addon` WHERE `entry` IN (@Run_Dummy,@Explosion_Bunny,@Fel_Cannon_Dummy); +INSERT INTO `creature_template_addon` (`entry`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES +(@Run_Dummy,0,0,0,0,'40196 40194 40195'), -- Mark, See Invisibility, Invisibility +(@Explosion_Bunny,0,0,0,0,'40194 40195'), -- See Invisibility, Invisibility +(@Fel_Cannon_Dummy,0,0,0,0,'40113'); -- The Aggro Check Aura +-- Remove achievement from disabled +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=3923; +-- Add missing spell from dbc +DELETE FROM `spell_dbc` WHERE `Id`=40200; +INSERT INTO `spell_dbc` (`Id`,`Dispel`,`Mechanic`,`Attributes`,`AttributesEx`,`AttributesEx2`,`AttributesEx3`,`AttributesEx4`,`AttributesEx5`,`AttributesEx6`,`AttributesEx7`,`Stances`,`StancesNot`,`Targets`,`CastingTimeIndex`,`AuraInterruptFlags`,`ProcFlags`,`ProcChance`,`ProcCharges`,`MaxLevel`,`BaseLevel`,`SpellLevel`,`DurationIndex`,`RangeIndex`,`StackAmount`,`EquippedItemClass`,`EquippedItemSubClassMask`,`EquippedItemInventoryTypeMask`,`Effect1`,`Effect2`,`Effect3`,`EffectDieSides1`,`EffectDieSides2`,`EffectDieSides3`,`EffectRealPointsPerLevel1`,`EffectRealPointsPerLevel2`,`EffectRealPointsPerLevel3`,`EffectBasePoints1`,`EffectBasePoints2`,`EffectBasePoints3`,`EffectMechanic1`,`EffectMechanic2`,`EffectMechanic3`,`EffectImplicitTargetA1`,`EffectImplicitTargetA2`,`EffectImplicitTargetA3`,`EffectImplicitTargetB1`,`EffectImplicitTargetB2`,`EffectImplicitTargetB3`,`EffectRadiusIndex1`,`EffectRadiusIndex2`,`EffectRadiusIndex3`,`EffectApplyAuraName1`,`EffectApplyAuraName2`,`EffectApplyAuraName3`,`EffectAmplitude1`,`EffectAmplitude2`,`EffectAmplitude3`,`EffectMultipleValue1`,`EffectMultipleValue2`,`EffectMultipleValue3`,`EffectMiscValue1`,`EffectMiscValue2`,`EffectMiscValue3`,`EffectMiscValueB1`,`EffectMiscValueB2`,`EffectMiscValueB3`,`EffectTriggerSpell1`,`EffectTriggerSpell2`,`EffectTriggerSpell3`,`EffectSpellClassMaskA1`,`EffectSpellClassMaskA2`,`EffectSpellClassMaskA3`,`EffectSpellClassMaskB1`,`EffectSpellClassMaskB2`,`EffectSpellClassMaskB3`,`EffectSpellClassMaskC1`,`EffectSpellClassMaskC2`,`EffectSpellClassMaskC3`,`MaxTargetLevel`,`SpellFamilyName`,`SpellFamilyFlags1`,`SpellFamilyFlags2`,`SpellFamilyFlags3`,`MaxAffectedTargets`,`DmgClass`,`PreventionType`,`DmgMultiplier1`,`DmgMultiplier2`,`DmgMultiplier3`,`AreaGroupId`,`SchoolMask`,`Comment`) VALUES +(40200,0,0,256,0,0,0,0,0,0,0,0,0,0,1,0,0,101,0,0,0,0,26,1,0,-1,0,0,164,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40195,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,'Bombing Run: See Invisibility Aura Remover'); +-- Spell area - Check to cast remove aura /against see invisibility aura/, if having it and not on quest +DELETE FROM `spell_area` WHERE `spell`=40200; +INSERT INTO `spell_area` (`spell`,`area`,`quest_start`,`quest_start_active`,`quest_end`,`aura_spell`,`racemask`,`gender`,`autocast`) VALUES +(40200,3522,0,0,0,@See_Invisibility,0,2,1); +-- Insert cannonballs spawns /based on sniffs/ +SET @guid := 14811; +DELETE FROM `gameobject` WHERE `guid` BETWEEN @guid+0 AND @guid+13; +INSERT INTO `gameobject` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`rotation0`,`rotation1`,`rotation2`,`rotation3`,`spawntimesecs`,`animprogress`,`state`) VALUES +(@guid+0,@CANNONBALL_STACK,530,1,1,2825.11,7024.05,369.982,5.69617,0,0,0.289313,-0.957235,300,0,1), +(@guid+1,@CANNONBALL_STACK,530,1,1,2938.26,7094.72,369.413,2.78314,0,0,0.983982,0.178267,300,0,1), +(@guid+2,@CANNONBALL_STACK,530,1,1,2924.84,7031.46,367.857,4.26205,0,0,0.847134,-0.53138,300,0,1), +(@guid+3,@CANNONBALL_STACK,530,1,1,2938.02,7015.59,365.75,3.65778,0,0,0.966879,-0.255237,300,0,1), +(@guid+4,@CANNONBALL_STACK,530,1,1,2998.57,7043.55,368.539,5.91266,0,0,0.184206,-0.982888,300,0,1), +(@guid+5,@CANNONBALL_STACK,530,1,1,2982,7054.94,368.32,4.99766,0,0,0.599411,-0.800442,300,0,1), +(@guid+6,@CANNONBALL_STACK,530,1,1,2978.73,6889.19,369.701,0.689745,0,0,0.338077,0.941119,300,0,1), +(@guid+7,@CANNONBALL_STACK,530,1,1,2941.56,6827.17,367.3,4.08109,0,0,0.891683,-0.452661,300,0,1), +(@guid+8,@CANNONBALL_STACK,530,1,1,2953.55,6859.3,369.954,6.14433,0,0,0.0693712,-0.997591,300,0,1), +(@guid+9,@CANNONBALL_STACK,530,1,1,3023.13,6799.74,374.46,1.58666,0,0,0.712695,0.701474,300,0,1), +(@guid+10,@CANNONBALL_STACK,530,1,1,3028.3,6824.84,373.591,5.0275,0,0,0.587401,-0.809296,300,0,1), +(@guid+11,@CANNONBALL_STACK,530,1,1,3022.15,6859.05,369.546,3.44885,0,0,0.988222,-0.153025,300,0,1), +(@guid+12,@CANNONBALL_STACK,530,1,1,3016.28,6876.11,370.188,3.47791,0,0,0.985895,-0.167365,300,0,1), +(@guid+13,@CANNONBALL_STACK,530,1,1,2940.6,7106.65,370.123,0.88561,0,0,0.428475,0.903553,300,0,1); +-- Insert spawns for Fel Flak Cannons, Run Target Dummies and Explosion Bunnies /based on sniffs/ +SET @guid := 85656; +DELETE FROM `creature` WHERE `guid` BETWEEN @guid+0 AND @guid+44; +INSERT INTO `creature` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`modelid`,`equipment_id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`currentwaypoint`,`curhealth`,`curmana`,`MovementType`,`npcflag`,`unit_flags`,`dynamicflags`) VALUES +(@guid+0,23118,530,1,1,0,0,2764.71,7024.45,370.203,0,300,0,0,42,0,0,0,33554432,0), +(@guid+1,23119,530,1,1,0,0,2764.71,7024.45,370.203,0,300,0,0,6986,0,0,0,33554432,0), +(@guid+2,23118,530,1,1,0,0,2786.61,7036.28,370.686,0,300,0,0,42,0,0,0,33554432,0), +(@guid+3,23119,530,1,1,0,0,2786.61,7036.28,370.686,0,300,0,0,6986,0,0,0,33554432,0), +(@guid+4,23118,530,1,1,0,0,2824.71,7044.79,369.877,0,300,0,0,42,0,0,0,33554432,0), +(@guid+5,23119,530,1,1,0,0,2824.71,7044.79,369.877,0,300,0,0,6986,0,0,0,33554432,0), +(@guid+6,23076,530,1,1,0,0,2775.81,7030.75,370.337,1.85606,300,0,0,22140,0,0,0,0,0), +(@guid+7,23076,530,1,1,0,0,2933.28,7103.93,369.209,2.58129,300,0,0,21543,0,0,0,0,0), +(@guid+8,23119,530,1,1,0,0,2940.82,7107.17,370.115,4.65944,300,0,0,6986,0,0,0,33554432,0), +(@guid+9,23118,530,1,1,0,0,2940.82,7107.17,370.115,4.65944,300,0,0,42,0,0,0,33554432,0), +(@guid+10,23118,530,1,1,0,0,2825.11,7024.05,369.982,5.69617,300,0,0,42,0,0,0,33554432,0), +(@guid+11,23119,530,1,1,0,0,2825.11,7024.05,369.982,5.69617,300,0,0,6986,0,0,0,33554432,0), +(@guid+12,23076,530,1,1,0,0,2834.14,7018.43,368.459,5.42992,300,0,0,21543,0,0,0,0,0), +(@guid+13,23119,530,1,1,0,0,2938.84,7094.48,371.493,0.242375,300,0,0,6986,0,0,0,33554432,0), +(@guid+14,23118,530,1,1,0,0,2938.84,7094.48,371.493,0.242375,300,0,0,42,0,0,0,33554432,0), +(@guid+15,23076,530,1,1,0,0,2925.49,7021.72,367.007,3.59446,300,0,0,22140,0,0,0,0,0), +(@guid+16,23119,530,1,1,0,0,2924.84,7031.46,367.857,4.26205,300,0,0,6986,0,0,0,33554432,0), +(@guid+17,23118,530,1,1,0,0,2924.84,7031.46,367.857,4.26205,300,0,0,42,0,0,0,33554432,0), +(@guid+18,23119,530,1,1,0,0,2938.02,7015.59,366.54,3.65778,300,0,0,6986,0,0,0,33554432,0), +(@guid+19,23118,530,1,1,0,0,2938.02,7015.59,366.54,3.65778,300,0,0,42,0,0,0,33554432,0), +(@guid+20,23076,530,1,1,0,0,2994.48,7039.91,369.42,5.26077,300,0,0,22140,0,0,0,0,0), +(@guid+21,23119,530,1,1,0,0,2998.57,7043.55,368.539,5.91266,300,0,0,6986,0,0,0,33554432,0), +(@guid+22,23118,530,1,1,0,0,2998.57,7043.55,368.539,5.91266,300,0,0,42,0,0,0,33554432,0), +(@guid+23,23119,530,1,1,0,0,2982,7054.94,368.82,4.99766,300,0,0,6986,0,0,0,33554432,0), +(@guid+24,23118,530,1,1,0,0,2982,7054.94,368.82,4.99766,300,0,0,42,0,0,0,33554432,0), +(@guid+25,23076,530,1,1,0,0,2982.59,6886.5,370.082,0.831123,300,0,0,22140,0,0,0,0,0), +(@guid+26,23118,530,1,1,0,0,2978.74,6889.12,371.288,0.897875,300,0,0,42,0,0,0,33554432,0), +(@guid+27,23119,530,1,1,0,0,2978.74,6889.12,371.288,0.897875,300,0,0,6986,0,0,0,33554432,0), +(@guid+28,23118,530,1,1,0,0,2941.56,6827.17,367.3,4.54054,300,0,0,42,0,0,0,33554432,0), +(@guid+29,23119,530,1,1,0,0,2941.56,6827.17,367.3,4.54054,300,0,0,6986,0,0,0,33554432,0), +(@guid+30,23076,530,1,1,0,0,2938.19,6818.01,366.959,3.31926,300,0,0,21543,0,0,0,0,0), +(@guid+31,23076,530,1,1,0,0,2946.3,6875.71,370.04,3.2148,300,0,0,22140,0,0,0,0,0), +(@guid+32,23118,530,1,1,0,0,2953.55,6859.3,369.954,6.14433,300,0,0,42,0,0,0,33554432,0), +(@guid+33,23119,530,1,1,0,0,2953.55,6859.3,369.954,6.14433,300,0,0,6986,0,0,0,33554432,0), +(@guid+34,23119,530,1,1,0,0,3023.13,6799.74,374.46,1.58666,300,0,0,6986,0,0,0,33554432,0), +(@guid+35,23118,530,1,1,0,0,3023.13,6799.74,374.46,1.58666,300,0,0,42,0,0,0,33554432,0), +(@guid+36,23076,530,1,1,0,0,3028.22,6807.09,374.075,5.94641,300,0,0,22140,0,0,0,0,0), +(@guid+37,23118,530,1,1,0,0,3028.3,6824.84,373.591,5.0275,300,0,0,42,0,0,0,33554432,0), +(@guid+38,23119,530,1,1,0,0,3028.3,6824.84,373.591,5.0275,300,0,0,6986,0,0,0,33554432,0), +(@guid+39,23119,530,1,1,0,0,3022.15,6859.05,369.546,3.44885,300,0,0,6986,0,0,0,33554432,0), +(@guid+40,23118,530,1,1,0,0,3022.15,6859.05,369.546,3.44885,300,0,0,42,0,0,0,33554432,0), +(@guid+41,23076,530,1,1,0,0,3022.21,6864.61,369.93,0.100696,300,0,0,22140,0,0,0,0,0), +(@guid+42,23118,530,1,1,0,0,3016.28,6876.11,370.188,3.47791,300,0,0,42,0,0,0,33554432,0), +(@guid+43,23119,530,1,1,0,0,3016.28,6876.11,370.188,3.47791,300,0,0,6986,0,0,0,33554432,0), +(@guid+44,23076,530,1,1,0,0,2816.74,7057.61,369.779,1.4555,300,0,0,21543,0,0,0,0,0); diff --git a/sql/old/3.3.5a/2012_09_13_01_world_spell_script_name.sql b/sql/old/3.3.5a/2012_09_13_01_world_spell_script_name.sql new file mode 100644 index 00000000000..61e4067c544 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_13_01_world_spell_script_name.sql @@ -0,0 +1,14 @@ +-- Add spell script name for Fires Over Skettis and Bombing Run quests +DELETE FROM `spell_script_names` WHERE `spell_id`=40113; +DELETE FROM `spell_script_names` WHERE `spell_id`=40160; +DELETE FROM `spell_script_names` WHERE `spell_id`=39844; +DELETE FROM `spell_script_names` WHERE `spell_id`=40056; +DELETE FROM `spell_script_names` WHERE `spell_id`=40112; +DELETE FROM `spell_script_names` WHERE `spell_id`=40119; +INSERT INTO `spell_script_names` VALUES +(39844,'spell_q11010_q11102_q11023_q11008_check_fly_mount'), +(40160,'spell_q11010_q11102_q11023_q11008_check_fly_mount'), +(40113,'spell_q11010_q11102_q11023_aggro_check_aura'), +(40056,'spell_q11010_q11102_q11023_choose_loc'), +(40112,'spell_q11010_q11102_q11023_aggro_check'), +(40119,'spell_q11010_q11102_q11023_aggro_burst'); diff --git a/sql/old/3.3.5a/2012_09_13_01_world_spell_target_position.sql b/sql/old/3.3.5a/2012_09_13_01_world_spell_target_position.sql new file mode 100644 index 00000000000..0879dbbbda0 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_13_01_world_spell_target_position.sql @@ -0,0 +1,15 @@ +DELETE FROM `spell_target_position` WHERE `id` IN (60323,60324,60325,60326,60327,60328,60329,60330,60331,60332,60333,60334,60335); +INSERT INTO `spell_target_position` (`id`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`) VALUES +(60323,0,-5506.339,-704.348,392.686,0.595), -- Steelgrills Depot +(60324,0,-9470.760,3.909,49.794,4.802), -- Lions Pride Inn, Goldshire +(60325,1,-3721.306,-4411.906,25.247,0.831), -- Theramore isle, Dustwallow Marsh +(60326,0,286.314,-2184.086,122.612,2.271), -- Aerie Peak, The Hinterlands +(60327,1,6395.708,433.256,33.260,0.566), -- Auberdine, Darkshore +(60328,0,-14412.923,692.017,22.248,1.231), -- Boote Bay +(60329,1,-7135.717,-3787.769,8.799,5.992), -- Tanaris, Gadgetzan +(60330,0,-10336.138,-2934.057,116.723,4.523), -- Swamp of Sorrows, Z coord is intended +(60331,0,-10446.900,-3261.909,20.179,5.875), -- Stonard, Swamp of Sorrows +(60332,0,-103.988,-902.795,55.534,5.924), -- Tarren Mill, Hillsbrad Foothils +(60333,0,1804.836,196.322,70.399,1.572), -- Undercity +(60334,1,-1060.266,23.137,141.455,5.967), -- Thunder Bluff +(60335,1,-506.224,-2590.084,113.150,2.445); -- Barrens, The Crossroads diff --git a/sql/old/3.3.5a/2012_09_13_02_world_trinity_string.sql b/sql/old/3.3.5a/2012_09_13_02_world_trinity_string.sql new file mode 100644 index 00000000000..f7214ad127b --- /dev/null +++ b/sql/old/3.3.5a/2012_09_13_02_world_trinity_string.sql @@ -0,0 +1,12 @@ +DELETE FROM `command` WHERE `name` = 'cheat status'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('cheat status', 2, 'Syntax: .cheat status \n\nShows the cheats you currently have enabled.'); + +DELETE FROM `trinity_string` WHERE `entry` BETWEEN 357 AND 362; +INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES +(357, 'Cheat Command Status:'), +(358, 'Godmode: %s.'), +(359, 'Casttime: %s.'), +(360, 'Cooldown: %s.'), +(361, 'Power: %s.'), +(362, 'Waterwalk: %s.'); diff --git a/sql/old/3.3.5a/2012_09_14_00_world_creature_template.sql b/sql/old/3.3.5a/2012_09_14_00_world_creature_template.sql new file mode 100644 index 00000000000..335b92e9af7 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_14_00_world_creature_template.sql @@ -0,0 +1,287 @@ +UPDATE `creature_template` SET `lootid`=18604 WHERE `entry`=17400; +UPDATE `creature_template` SET `lootid`=18605 WHERE `entry`=17401; +UPDATE `creature_template` SET `lootid`=19884 WHERE `entry`=17816; +UPDATE `creature_template` SET `lootid`=19885 WHERE `entry`=17957; +UPDATE `creature_template` SET `lootid`=19886 WHERE `entry`=17958; +UPDATE `creature_template` SET `lootid`=19887 WHERE `entry`=17961; +UPDATE `creature_template` SET `lootid`=19888 WHERE `entry`=17938; +UPDATE `creature_template` SET `lootid`=19889 WHERE `entry`=17959; +UPDATE `creature_template` SET `lootid`=19890 WHERE `entry`=17960; +UPDATE `creature_template` SET `lootid`=19891 WHERE `entry`=17940; +UPDATE `creature_template` SET `lootid`=19892 WHERE `entry`=17817; +UPDATE `creature_template` SET `lootid`=19902 WHERE `entry`=17963; +UPDATE `creature_template` SET `lootid`=19903 WHERE `entry`=17962; +UPDATE `creature_template` SET `lootid`=19904 WHERE `entry`=17964; +UPDATE `creature_template` SET `lootid`=20164 WHERE `entry`=17723; +UPDATE `creature_template` SET `lootid`=20173 WHERE `entry`=17731; +UPDATE `creature_template` SET `lootid`=20174 WHERE `entry`=19632; +UPDATE `creature_template` SET `lootid`=20175 WHERE `entry`=17732; +UPDATE `creature_template` SET `lootid`=20177 WHERE `entry`=17730; +UPDATE `creature_template` SET `lootid`=20179 WHERE `entry`=17771; +UPDATE `creature_template` SET `lootid`=20180 WHERE `entry`=17729; +UPDATE `creature_template` SET `lootid`=20181 WHERE `entry`=17728; +UPDATE `creature_template` SET `lootid`=20185 WHERE `entry`=17724; +UPDATE `creature_template` SET `lootid`=20187 WHERE `entry`=17734; +UPDATE `creature_template` SET `lootid`=20188 WHERE `entry`=17725; +UPDATE `creature_template` SET `lootid`=20190 WHERE `entry`=17871; +UPDATE `creature_template` SET `lootid`=20191 WHERE `entry`=17726; +UPDATE `creature_template` SET `lootid`=20192 WHERE `entry`=17727; +UPDATE `creature_template` SET `lootid`=20193 WHERE `entry`=17735; +UPDATE `creature_template` SET `lootid`=20255 WHERE `entry`=18311; +UPDATE `creature_template` SET `lootid`=20256 WHERE `entry`=18331; +UPDATE `creature_template` SET `lootid`=20257 WHERE `entry`=18317; +UPDATE `creature_template` SET `lootid`=20258 WHERE `entry`=18309; +UPDATE `creature_template` SET `lootid`=20259 WHERE `entry`=18313; +UPDATE `creature_template` SET `lootid`=20260 WHERE `entry`=18312; +UPDATE `creature_template` SET `lootid`=20261 WHERE `entry`=18315; +UPDATE `creature_template` SET `lootid`=20263 WHERE `entry`=19306; +UPDATE `creature_template` SET `lootid`=20264 WHERE `entry`=18314; +UPDATE `creature_template` SET `lootid`=20265 WHERE `entry`=19307; +UPDATE `creature_template` SET `lootid`=20298 WHERE `entry`=18524; +UPDATE `creature_template` SET `lootid`=20299 WHERE `entry`=18497; +UPDATE `creature_template` SET `lootid`=20300 WHERE `entry`=18702; +UPDATE `creature_template` SET `lootid`=20301 WHERE `entry`=18493; +UPDATE `creature_template` SET `lootid`=20302 WHERE `entry`=18495; +UPDATE `creature_template` SET `lootid`=20309 WHERE `entry`=18503; +UPDATE `creature_template` SET `lootid`=20310 WHERE `entry`=18557; +UPDATE `creature_template` SET `lootid`=20311 WHERE `entry`=18556; +UPDATE `creature_template` SET `lootid`=20312 WHERE `entry`=18558; +UPDATE `creature_template` SET `lootid`=20313 WHERE `entry`=18559; +UPDATE `creature_template` SET `lootid`=20315 WHERE `entry`=18521; +UPDATE `creature_template` SET `lootid`=20320 WHERE `entry`=18500; +UPDATE `creature_template` SET `lootid`=20321 WHERE `entry`=18498; +UPDATE `creature_template` SET `lootid`=20322 WHERE `entry`=18499; +UPDATE `creature_template` SET `lootid`=20323 WHERE `entry`=18501; +UPDATE `creature_template` SET `lootid`=20525 WHERE `entry`=18934; +UPDATE `creature_template` SET `lootid`=20526 WHERE `entry`=17820; +UPDATE `creature_template` SET `lootid`=20527 WHERE `entry`=17819; +UPDATE `creature_template` SET `lootid`=20528 WHERE `entry`=17840; +UPDATE `creature_template` SET `lootid`=20529 WHERE `entry`=17860; +UPDATE `creature_template` SET `lootid`=20530 WHERE `entry`=17833; +UPDATE `creature_template` SET `lootid`=20532 WHERE `entry`=18171; +UPDATE `creature_template` SET `lootid`=20533 WHERE `entry`=18172; +UPDATE `creature_template` SET `lootid`=20534 WHERE `entry`=18170; +UPDATE `creature_template` SET `lootid`=20537 WHERE `entry`=17815; +UPDATE `creature_template` SET `lootid`=20538 WHERE `entry`=17814; +UPDATE `creature_template` SET `lootid`=20543 WHERE `entry`=17846; +UPDATE `creature_template` SET `lootid`=20545 WHERE `entry`=18092; +UPDATE `creature_template` SET `lootid`=20546 WHERE `entry`=18094; +UPDATE `creature_template` SET `lootid`=20547 WHERE `entry`=18093; +UPDATE `creature_template` SET `lootid`=20620 WHERE `entry`=17721; +UPDATE `creature_template` SET `lootid`=20621 WHERE `entry`=17800; +UPDATE `creature_template` SET `lootid`=20622 WHERE `entry`=17803; +UPDATE `creature_template` SET `lootid`=20623 WHERE `entry`=17801; +UPDATE `creature_template` SET `lootid`=20624 WHERE `entry`=17805; +UPDATE `creature_template` SET `lootid`=20625 WHERE `entry`=17722; +UPDATE `creature_template` SET `lootid`=20626 WHERE `entry`=17802; +UPDATE `creature_template` SET `lootid`=20627 WHERE `entry`=17917; +UPDATE `creature_template` SET `lootid`=20628 WHERE `entry`=17799; +UPDATE `creature_template` SET `lootid`=20638 WHERE `entry`=18633; +UPDATE `creature_template` SET `lootid`=20639 WHERE `entry`=18636; +UPDATE `creature_template` SET `lootid`=20640 WHERE `entry`=18631; +UPDATE `creature_template` SET `lootid`=20641 WHERE `entry`=18635; +UPDATE `creature_template` SET `lootid`=20642 WHERE `entry`=18632; +UPDATE `creature_template` SET `lootid`=20643 WHERE `entry`=18641; +UPDATE `creature_template` SET `lootid`=20644 WHERE `entry`=18830; +UPDATE `creature_template` SET `lootid`=20645 WHERE `entry`=18794; +UPDATE `creature_template` SET `lootid`=20646 WHERE `entry`=18637; +UPDATE `creature_template` SET `lootid`=20647 WHERE `entry`=18639; +UPDATE `creature_template` SET `lootid`=20648 WHERE `entry`=18634; +UPDATE `creature_template` SET `lootid`=20649 WHERE `entry`=18640; +UPDATE `creature_template` SET `lootid`=20650 WHERE `entry`=18638; +UPDATE `creature_template` SET `lootid`=20651 WHERE `entry`=18642; +UPDATE `creature_template` SET `lootid`=20652 WHERE `entry`=18796; +UPDATE `creature_template` SET `lootid`=20655 WHERE `entry`=18663; +UPDATE `creature_template` SET `lootid`=20656 WHERE `entry`=18848; +UPDATE `creature_template` SET `lootid`=20660 WHERE `entry`=19208; +UPDATE `creature_template` SET `lootid`=20661 WHERE `entry`=19209; +UPDATE `creature_template` SET `lootid`=20686 WHERE `entry`=19429; +UPDATE `creature_template` SET `lootid`=20688 WHERE `entry`=19428; +UPDATE `creature_template` SET `lootid`=20691 WHERE `entry`=18327; +UPDATE `creature_template` SET `lootid`=20692 WHERE `entry`=18323; +UPDATE `creature_template` SET `lootid`=20693 WHERE `entry`=18318; +UPDATE `creature_template` SET `lootid`=20694 WHERE `entry`=18328; +UPDATE `creature_template` SET `lootid`=20695 WHERE `entry`=18325; +UPDATE `creature_template` SET `lootid`=20696 WHERE `entry`=18322; +UPDATE `creature_template` SET `lootid`=20697 WHERE `entry`=18319; +UPDATE `creature_template` SET `lootid`=20698 WHERE `entry`=18320; +UPDATE `creature_template` SET `lootid`=20699 WHERE `entry`=18326; +UPDATE `creature_template` SET `lootid`=20701 WHERE `entry`=18321; +UPDATE `creature_template` SET `lootid`=20993 WHERE `entry`=20923; +UPDATE `creature_template` SET `lootid`=21522 WHERE `entry`=19510; +UPDATE `creature_template` SET `lootid`=21523 WHERE `entry`=20990; +UPDATE `creature_template` SET `lootid`=21524 WHERE `entry`=19167; +UPDATE `creature_template` SET `lootid`=21527 WHERE `entry`=19231; +UPDATE `creature_template` SET `lootid`=21528 WHERE `entry`=19712; +UPDATE `creature_template` SET `lootid`=21531 WHERE `entry`=19716; +UPDATE `creature_template` SET `lootid`=21532 WHERE `entry`=19713; +UPDATE `creature_template` SET `lootid`=21539 WHERE `entry`=19168; +UPDATE `creature_template` SET `lootid`=21540 WHERE `entry`=20988; +UPDATE `creature_template` SET `lootid`=21541 WHERE `entry`=20059; +UPDATE `creature_template` SET `lootid`=21542 WHERE `entry`=19735; +UPDATE `creature_template` SET `lootid`=21543 WHERE `entry`=19166; +UPDATE `creature_template` SET `lootid`=21585 WHERE `entry`=20857; +UPDATE `creature_template` SET `lootid`=21586 WHERE `entry`=20869; +UPDATE `creature_template` SET `lootid`=21587 WHERE `entry`=20859; +UPDATE `creature_template` SET `lootid`=21588 WHERE `entry`=20911; +UPDATE `creature_template` SET `lootid`=21589 WHERE `entry`=20905; +UPDATE `creature_template` SET `lootid`=21591 WHERE `entry`=20867; +UPDATE `creature_template` SET `lootid`=21593 WHERE `entry`=20868; +UPDATE `creature_template` SET `lootid`=21594 WHERE `entry`=20880; +UPDATE `creature_template` SET `lootid`=21595 WHERE `entry`=20879; +UPDATE `creature_template` SET `lootid`=21596 WHERE `entry`=20896; +UPDATE `creature_template` SET `lootid`=21597 WHERE `entry`=20897; +UPDATE `creature_template` SET `lootid`=21598 WHERE `entry`=20898; +UPDATE `creature_template` SET `lootid`=21601 WHERE `entry`=20912; +UPDATE `creature_template` SET `lootid`=21604 WHERE `entry`=20875; +UPDATE `creature_template` SET `lootid`=21605 WHERE `entry`=20873; +UPDATE `creature_template` SET `lootid`=21606 WHERE `entry`=20906; +UPDATE `creature_template` SET `lootid`=21607 WHERE `entry`=20865; +UPDATE `creature_template` SET `lootid`=21608 WHERE `entry`=20864; +UPDATE `creature_template` SET `lootid`=21610 WHERE `entry`=20901; +UPDATE `creature_template` SET `lootid`=21611 WHERE `entry`=20902; +UPDATE `creature_template` SET `lootid`=21613 WHERE `entry`=20882; +UPDATE `creature_template` SET `lootid`=21614 WHERE `entry`=20866; +UPDATE `creature_template` SET `lootid`=21615 WHERE `entry`=20883; +UPDATE `creature_template` SET `lootid`=21616 WHERE `entry`=20909; +UPDATE `creature_template` SET `lootid`=21617 WHERE `entry`=20908; +UPDATE `creature_template` SET `lootid`=21618 WHERE `entry`=20910; +UPDATE `creature_template` SET `lootid`=21619 WHERE `entry`=20881; +UPDATE `creature_template` SET `lootid`=21621 WHERE `entry`=20900; +UPDATE `creature_template` SET `lootid`=21842 WHERE `entry`=21126; +UPDATE `creature_template` SET `lootid`=21843 WHERE `entry`=21127; +UPDATE `creature_template` SET `lootid`=21914 WHERE `entry`=21694; +UPDATE `creature_template` SET `lootid`=21916 WHERE `entry`=21696; +UPDATE `creature_template` SET `lootid`=21917 WHERE `entry`=21695; +UPDATE `creature_template` SET `lootid`=21989 WHERE `entry`=21891; +UPDATE `creature_template` SET `lootid`=21990 WHERE `entry`=21904; +UPDATE `creature_template` SET `lootid`=22129 WHERE `entry`=22128; +UPDATE `creature_template` SET `lootid`=22162 WHERE `entry`=18983; +UPDATE `creature_template` SET `lootid`=22163 WHERE `entry`=17952; +UPDATE `creature_template` SET `lootid`=22173 WHERE `entry`=18982; +UPDATE `creature_template` SET `lootid`=22346 WHERE `entry`=21702; +UPDATE `creature_template` SET `lootid`=22530 WHERE `entry`=13536; +UPDATE `creature_template` SET `lootid`=22532 WHERE `entry`=13539; +UPDATE `creature_template` SET `lootid`=22533 WHERE `entry`=13424; +UPDATE `creature_template` SET `lootid`=22534 WHERE `entry`=13542; +UPDATE `creature_template` SET `lootid`=22535 WHERE `entry`=13554; +UPDATE `creature_template` SET `lootid`=22536 WHERE `entry`=13545; +UPDATE `creature_template` SET `lootid`=22537 WHERE `entry`=13557; +UPDATE `creature_template` SET `lootid`=22538 WHERE `entry`=13425; +UPDATE `creature_template` SET `lootid`=22539 WHERE `entry`=13155; +UPDATE `creature_template` SET `lootid`=22543 WHERE `entry`=14770; +UPDATE `creature_template` SET `lootid`=22547 WHERE `entry`=14768; +UPDATE `creature_template` SET `lootid`=22550 WHERE `entry`=13378; +UPDATE `creature_template` SET `lootid`=22555 WHERE `entry`=603; +UPDATE `creature_template` SET `lootid`=22565 WHERE `entry`=13377; +UPDATE `creature_template` SET `lootid`=22576 WHERE `entry`=13416; +UPDATE `creature_template` SET `lootid`=22578 WHERE `entry`=13151; +UPDATE `creature_template` SET `lootid`=22579 WHERE `entry`=14767; +UPDATE `creature_template` SET `lootid`=22587 WHERE `entry`=13526; +UPDATE `creature_template` SET `lootid`=22592 WHERE `entry`=13530; +UPDATE `creature_template` SET `lootid`=22595 WHERE `entry`=14769; +UPDATE `creature_template` SET `lootid`=22607 WHERE `entry`=13527; +UPDATE `creature_template` SET `lootid`=22612 WHERE `entry`=13531; +UPDATE `creature_template` SET `lootid`=22613 WHERE `entry`=13140; +UPDATE `creature_template` SET `lootid`=22614 WHERE `entry`=13319; +UPDATE `creature_template` SET `lootid`=22615 WHERE `entry`=13320; +UPDATE `creature_template` SET `lootid`=22616 WHERE `entry`=13154; +UPDATE `creature_template` SET `lootid`=22617 WHERE `entry`=13152; +UPDATE `creature_template` SET `lootid`=22618 WHERE `entry`=13318; +UPDATE `creature_template` SET `lootid`=22619 WHERE `entry`=13153; +UPDATE `creature_template` SET `lootid`=22620 WHERE `entry`=13139; +UPDATE `creature_template` SET `lootid`=22621 WHERE `entry`=13446; +UPDATE `creature_template` SET `lootid`=22623 WHERE `entry`=13597; +UPDATE `creature_template` SET `lootid`=22624 WHERE `entry`=13357; +UPDATE `creature_template` SET `lootid`=22628 WHERE `entry`=13841; +UPDATE `creature_template` SET `lootid`=22634 WHERE `entry`=13598; +UPDATE `creature_template` SET `lootid`=22635 WHERE `entry`=13356; +UPDATE `creature_template` SET `lootid`=22639 WHERE `entry`=13449; +UPDATE `creature_template` SET `lootid`=22640 WHERE `entry`=13840; +UPDATE `creature_template` SET `lootid`=22645 WHERE `entry`=12048; +UPDATE `creature_template` SET `lootid`=22649 WHERE `entry`=12052; +UPDATE `creature_template` SET `lootid`=22657 WHERE `entry`=12047; +UPDATE `creature_template` SET `lootid`=22662 WHERE `entry`=13325; +UPDATE `creature_template` SET `lootid`=22663 WHERE `entry`=13327; +UPDATE `creature_template` SET `lootid`=22664 WHERE `entry`=13330; +UPDATE `creature_template` SET `lootid`=22667 WHERE `entry`=13335; +UPDATE `creature_template` SET `lootid`=22668 WHERE `entry`=13336; +UPDATE `creature_template` SET `lootid`=22669 WHERE `entry`=13337; +UPDATE `creature_template` SET `lootid`=22671 WHERE `entry`=13426; +UPDATE `creature_template` SET `lootid`=22672 WHERE `entry`=13427; +UPDATE `creature_template` SET `lootid`=22673 WHERE `entry`=13428; +UPDATE `creature_template` SET `lootid`=22676 WHERE `entry`=13528; +UPDATE `creature_template` SET `lootid`=22679 WHERE `entry`=13440; +UPDATE `creature_template` SET `lootid`=22687 WHERE `entry`=13324; +UPDATE `creature_template` SET `lootid`=22688 WHERE `entry`=13329; +UPDATE `creature_template` SET `lootid`=22689 WHERE `entry`=13524; +UPDATE `creature_template` SET `lootid`=22691 WHERE `entry`=13576; +UPDATE `creature_template` SET `lootid`=22700 WHERE `entry`=13298; +UPDATE `creature_template` SET `lootid`=22701 WHERE `entry`=13145; +UPDATE `creature_template` SET `lootid`=22702 WHERE `entry`=13296; +UPDATE `creature_template` SET `lootid`=22703 WHERE `entry`=13147; +UPDATE `creature_template` SET `lootid`=22704 WHERE `entry`=13299; +UPDATE `creature_template` SET `lootid`=22705 WHERE `entry`=13300; +UPDATE `creature_template` SET `lootid`=22706 WHERE `entry`=13146; +UPDATE `creature_template` SET `lootid`=22707 WHERE `entry`=13137; +UPDATE `creature_template` SET `lootid`=22708 WHERE `entry`=13138; +UPDATE `creature_template` SET `lootid`=22709 WHERE `entry`=13297; +UPDATE `creature_template` SET `lootid`=22710 WHERE `entry`=13143; +UPDATE `creature_template` SET `lootid`=22711 WHERE `entry`=13144; +UPDATE `creature_template` SET `lootid`=22713 WHERE `entry`=13525; +UPDATE `creature_template` SET `lootid`=22718 WHERE `entry`=13529; +UPDATE `creature_template` SET `lootid`=22719 WHERE `entry`=13333; +UPDATE `creature_template` SET `lootid`=22725 WHERE `entry`=10984; +UPDATE `creature_template` SET `lootid`=22736 WHERE `entry`=13776; +UPDATE `creature_template` SET `lootid`=22754 WHERE `entry`=13537; +UPDATE `creature_template` SET `lootid`=22759 WHERE `entry`=13777; +UPDATE `creature_template` SET `lootid`=22764 WHERE `entry`=13676; +UPDATE `creature_template` SET `lootid`=22765 WHERE `entry`=13618; +UPDATE `creature_template` SET `lootid`=22768 WHERE `entry`=13150; +UPDATE `creature_template` SET `lootid`=22769 WHERE `entry`=13149; +UPDATE `creature_template` SET `lootid`=22774 WHERE `entry`=13541; +UPDATE `creature_template` SET `lootid`=22776 WHERE `entry`=13544; +UPDATE `creature_template` SET `lootid`=22788 WHERE `entry`=12156; +UPDATE `creature_template` SET `lootid`=22789 WHERE `entry`=12158; +UPDATE `creature_template` SET `lootid`=22790 WHERE `entry`=13956; +UPDATE `creature_template` SET `lootid`=22791 WHERE `entry`=13958; +UPDATE `creature_template` SET `lootid`=22792 WHERE `entry`=12157; +UPDATE `creature_template` SET `lootid`=22794 WHERE `entry`=10983; +UPDATE `creature_template` SET `lootid`=22795 WHERE `entry`=13957; +UPDATE `creature_template` SET `lootid`=22796 WHERE `entry`=11679; +UPDATE `creature_template` SET `lootid`=25548 WHERE `entry`=24976; +UPDATE `creature_template` SET `lootid`=25551 WHERE `entry`=24698; +UPDATE `creature_template` SET `lootid`=29274 WHERE `entry`=16506; +UPDATE `creature_template` SET `lootid`=29833 WHERE `entry`=16156; +UPDATE `creature_template` SET `lootid`=30759 WHERE `entry`=22262; +UPDATE `creature_template` SET `lootid`=30760 WHERE `entry`=22261; +UPDATE `creature_template` SET `lootid`=30761 WHERE `entry`=22263; +UPDATE `creature_template` SET `lootid`=30763 WHERE `entry`=23174; +UPDATE `creature_template` SET `lootid`=30773 WHERE `entry`=23386; +UPDATE `creature_template` SET `lootid`=30822 WHERE `entry`=26690; +UPDATE `creature_template` SET `lootid`=30823 WHERE `entry`=26691; +UPDATE `creature_template` SET `lootid`=31178 WHERE `entry`=27729; +UPDATE `creature_template` SET `lootid`=31179 WHERE `entry`=28249; +UPDATE `creature_template` SET `lootid`=31180 WHERE `entry`=27732; +UPDATE `creature_template` SET `lootid`=31184 WHERE `entry`=28200; +UPDATE `creature_template` SET `lootid`=31187 WHERE `entry`=27734; +UPDATE `creature_template` SET `lootid`=31188 WHERE `entry`=28199; +UPDATE `creature_template` SET `lootid`=31199 WHERE `entry`=27736; +UPDATE `creature_template` SET `lootid`=31200 WHERE `entry`=28201; +UPDATE `creature_template` SET `lootid`=31201 WHERE `entry`=27731; +UPDATE `creature_template` SET `lootid`=31202 WHERE `entry`=27742; +UPDATE `creature_template` SET `lootid`=31203 WHERE `entry`=27744; +UPDATE `creature_template` SET `lootid`=31206 WHERE `entry`=27743; +UPDATE `creature_template` SET `lootid`=33391 WHERE `entry`=32915; +UPDATE `creature_template` SET `lootid`=33773 WHERE `entry`=33772; +UPDATE `creature_template` SET `lootid`=34106 WHERE `entry`=33432; +UPDATE `creature_template` SET `lootid`=34108 WHERE `entry`=33651; +UPDATE `creature_template` SET `lootid`=35306 WHERE `entry`=35305; +UPDATE `creature_template` SET `lootid`=35308 WHERE `entry`=35307; +UPDATE `creature_template` SET `lootid`=35310 WHERE `entry`=35309; +UPDATE `creature_template` SET `lootid`=35359 WHERE `entry`=35143; +UPDATE `creature_template` SET `lootid`=38151 WHERE `entry`=37532; +UPDATE `creature_template` SET `lootid`=39805 WHERE `entry`=39946; +UPDATE `creature_template` SET `lootid`=39823 WHERE `entry`=39948; +UPDATE `creature_template` SET `lootid`=39920 WHERE `entry`=39947; +UPDATE `creature_template` SET `lootid`=40420 WHERE `entry`=40419; diff --git a/sql/old/3.3.5a/2012_09_14_00_world_sai.sql b/sql/old/3.3.5a/2012_09_14_00_world_sai.sql new file mode 100644 index 00000000000..13f11b7a795 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_14_00_world_sai.sql @@ -0,0 +1 @@ +UPDATE `smart_scripts` SET `event_param1` = 35282, `action_param1` = 256, `comment` = 'Scrapped Fel Reaver - On Spellhit - Remove - OOC Not attackable - flags' WHERE `entryorguid` = 20243; diff --git a/sql/old/3.3.5a/2012_09_14_01_world_creature_loot_template.sql b/sql/old/3.3.5a/2012_09_14_01_world_creature_loot_template.sql new file mode 100644 index 00000000000..77ab9e89b04 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_14_01_world_creature_loot_template.sql @@ -0,0 +1,5 @@ +DELETE FROM `creature_loot_template` WHERE `entry` = 37126; +INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES +(37126, 49426, 100, 1, 0, 1, 1), +(37126, 1, 100, 1, 0, -100002, 1); +UPDATE `creature_template` SET `lootid` = 37126 WHERE `entry` IN (37126,38258); diff --git a/sql/old/3.3.5a/2012_09_15_00_world_achievement_criteria_data.sql b/sql/old/3.3.5a/2012_09_15_00_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..a30eff7024e --- /dev/null +++ b/sql/old/3.3.5a/2012_09_15_00_world_achievement_criteria_data.sql @@ -0,0 +1,6 @@ +-- Insert achievement instance criteria data scripts +DELETE FROM `achievement_criteria_data` WHERE `type`=11 and `criteria_id` IN (7323,7324,7325); +INSERT INTO `achievement_criteria_data` (`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES +(7323,11,0,0,'achievement_ruby_void'), +(7324,11,0,0,'achievement_emerald_void'), +(7325,11,0,0,'achievement_amber_void'); diff --git a/sql/old/3.3.5a/2012_09_15_00_world_creature_template.sql b/sql/old/3.3.5a/2012_09_15_00_world_creature_template.sql new file mode 100644 index 00000000000..3db5a598c1d --- /dev/null +++ b/sql/old/3.3.5a/2012_09_15_00_world_creature_template.sql @@ -0,0 +1,288 @@ +UPDATE `creature_template` SET `lootid`=`entry` WHERE `entry` IN (17400,17401,17816,17957,17958,17961,17938,17959,17960,17940,17817,17963,17962,17964,17723,17731,19632,17732,17730,17771,17729,17728,17724,17734,17725,17871,17726,17727,17735,18311,18331,18317,18309,18313,18312,18315,19306,18314,19307,18524,18497,18702,18493,18495,18503,18557,18556,18558,18559,18521,18500,18498,18499,18501,18934,17820,17819,17840,17860,17833,18171,18172,18170,17815,17814,17846,18092,18094,18093,17721,17800,17803,17801,17805,17722,17802,17917,17799,18633,18636,18631,18635,18632,18641,18830,18794,18637,18639,18634,18640,18638,18642,18796,18663,18848,19208,19209,19429,19428,18327,18323,18318,18328,18325,18322,18319,18320,18326,18321,20923,19510,20990,19167,19231,19712,19716,19713,19168,20988,20059,19735,19166,20857,20869,20859,20911,20905,20867,20868,20880,20879,20896,20897,20898,20912,20875,20873,20906,20865,20864,20901,20902,20882,20866,20883,20909,20908,20910,20881,20900,21126,21127,21694,21696,21695,21891,21904,22128,18983,17952,18982,21702,13536,13539,13424,13542,13554,13545,13557,13425,13155,14770,14768,13378,603,13377,13416,13151,14767,13526,13530,14769,13527,13531,13140,13319,13320,13154,13152,13318,13153,13139,13446,13597,13357,13841,13598,13356,13449,13840,12048,12052,12047,13325,13327,13330,13335,13336,13337,13426,13427,13428,13528,13440,13324,13329,13524,13576,13298,13145,13296,13147,13299,13300,13146,13137,13138,13297,13143,13144,13525,13529,13333,10984,13776,13537,13777,13676,13618,13150,13149,13541,13544,12156,12158,13956,13958,12157,10983,13957,11679,24976,24698,16506,16156,22262,22261,22263,23174,23386,26690,26691,27729,28249,27732,28200,27734,28199,27736,28201,27731,27742,27744,27743,32915,33772,33432,33651,35305,35307,35309,35143,37532,39946,39948,39947,40419); +UPDATE `creature_template` SET `lootid`=17400 WHERE `entry`=18604; +UPDATE `creature_template` SET `lootid`=17401 WHERE `entry`=18605; +UPDATE `creature_template` SET `lootid`=17816 WHERE `entry`=19884; +UPDATE `creature_template` SET `lootid`=17957 WHERE `entry`=19885; +UPDATE `creature_template` SET `lootid`=17958 WHERE `entry`=19886; +UPDATE `creature_template` SET `lootid`=17961 WHERE `entry`=19887; +UPDATE `creature_template` SET `lootid`=17938 WHERE `entry`=19888; +UPDATE `creature_template` SET `lootid`=17959 WHERE `entry`=19889; +UPDATE `creature_template` SET `lootid`=17960 WHERE `entry`=19890; +UPDATE `creature_template` SET `lootid`=17940 WHERE `entry`=19891; +UPDATE `creature_template` SET `lootid`=17817 WHERE `entry`=19892; +UPDATE `creature_template` SET `lootid`=17963 WHERE `entry`=19902; +UPDATE `creature_template` SET `lootid`=17962 WHERE `entry`=19903; +UPDATE `creature_template` SET `lootid`=17964 WHERE `entry`=19904; +UPDATE `creature_template` SET `lootid`=17723 WHERE `entry`=20164; +UPDATE `creature_template` SET `lootid`=17731 WHERE `entry`=20173; +UPDATE `creature_template` SET `lootid`=19632 WHERE `entry`=20174; +UPDATE `creature_template` SET `lootid`=17732 WHERE `entry`=20175; +UPDATE `creature_template` SET `lootid`=17730 WHERE `entry`=20177; +UPDATE `creature_template` SET `lootid`=17771 WHERE `entry`=20179; +UPDATE `creature_template` SET `lootid`=17729 WHERE `entry`=20180; +UPDATE `creature_template` SET `lootid`=17728 WHERE `entry`=20181; +UPDATE `creature_template` SET `lootid`=17724 WHERE `entry`=20185; +UPDATE `creature_template` SET `lootid`=17734 WHERE `entry`=20187; +UPDATE `creature_template` SET `lootid`=17725 WHERE `entry`=20188; +UPDATE `creature_template` SET `lootid`=17871 WHERE `entry`=20190; +UPDATE `creature_template` SET `lootid`=17726 WHERE `entry`=20191; +UPDATE `creature_template` SET `lootid`=17727 WHERE `entry`=20192; +UPDATE `creature_template` SET `lootid`=17735 WHERE `entry`=20193; +UPDATE `creature_template` SET `lootid`=18311 WHERE `entry`=20255; +UPDATE `creature_template` SET `lootid`=18331 WHERE `entry`=20256; +UPDATE `creature_template` SET `lootid`=18317 WHERE `entry`=20257; +UPDATE `creature_template` SET `lootid`=18309 WHERE `entry`=20258; +UPDATE `creature_template` SET `lootid`=18313 WHERE `entry`=20259; +UPDATE `creature_template` SET `lootid`=18312 WHERE `entry`=20260; +UPDATE `creature_template` SET `lootid`=18315 WHERE `entry`=20261; +UPDATE `creature_template` SET `lootid`=19306 WHERE `entry`=20263; +UPDATE `creature_template` SET `lootid`=18314 WHERE `entry`=20264; +UPDATE `creature_template` SET `lootid`=19307 WHERE `entry`=20265; +UPDATE `creature_template` SET `lootid`=18524 WHERE `entry`=20298; +UPDATE `creature_template` SET `lootid`=18497 WHERE `entry`=20299; +UPDATE `creature_template` SET `lootid`=18702 WHERE `entry`=20300; +UPDATE `creature_template` SET `lootid`=18493 WHERE `entry`=20301; +UPDATE `creature_template` SET `lootid`=18495 WHERE `entry`=20302; +UPDATE `creature_template` SET `lootid`=18503 WHERE `entry`=20309; +UPDATE `creature_template` SET `lootid`=18557 WHERE `entry`=20310; +UPDATE `creature_template` SET `lootid`=18556 WHERE `entry`=20311; +UPDATE `creature_template` SET `lootid`=18558 WHERE `entry`=20312; +UPDATE `creature_template` SET `lootid`=18559 WHERE `entry`=20313; +UPDATE `creature_template` SET `lootid`=18521 WHERE `entry`=20315; +UPDATE `creature_template` SET `lootid`=18500 WHERE `entry`=20320; +UPDATE `creature_template` SET `lootid`=18498 WHERE `entry`=20321; +UPDATE `creature_template` SET `lootid`=18499 WHERE `entry`=20322; +UPDATE `creature_template` SET `lootid`=18501 WHERE `entry`=20323; +UPDATE `creature_template` SET `lootid`=18934 WHERE `entry`=20525; +UPDATE `creature_template` SET `lootid`=17820 WHERE `entry`=20526; +UPDATE `creature_template` SET `lootid`=17819 WHERE `entry`=20527; +UPDATE `creature_template` SET `lootid`=17840 WHERE `entry`=20528; +UPDATE `creature_template` SET `lootid`=17860 WHERE `entry`=20529; +UPDATE `creature_template` SET `lootid`=17833 WHERE `entry`=20530; +UPDATE `creature_template` SET `lootid`=18171 WHERE `entry`=20532; +UPDATE `creature_template` SET `lootid`=18172 WHERE `entry`=20533; +UPDATE `creature_template` SET `lootid`=18170 WHERE `entry`=20534; +UPDATE `creature_template` SET `lootid`=17815 WHERE `entry`=20537; +UPDATE `creature_template` SET `lootid`=17814 WHERE `entry`=20538; +UPDATE `creature_template` SET `lootid`=17846 WHERE `entry`=20543; +UPDATE `creature_template` SET `lootid`=18092 WHERE `entry`=20545; +UPDATE `creature_template` SET `lootid`=18094 WHERE `entry`=20546; +UPDATE `creature_template` SET `lootid`=18093 WHERE `entry`=20547; +UPDATE `creature_template` SET `lootid`=17721 WHERE `entry`=20620; +UPDATE `creature_template` SET `lootid`=17800 WHERE `entry`=20621; +UPDATE `creature_template` SET `lootid`=17803 WHERE `entry`=20622; +UPDATE `creature_template` SET `lootid`=17801 WHERE `entry`=20623; +UPDATE `creature_template` SET `lootid`=17805 WHERE `entry`=20624; +UPDATE `creature_template` SET `lootid`=17722 WHERE `entry`=20625; +UPDATE `creature_template` SET `lootid`=17802 WHERE `entry`=20626; +UPDATE `creature_template` SET `lootid`=17917 WHERE `entry`=20627; +UPDATE `creature_template` SET `lootid`=17799 WHERE `entry`=20628; +UPDATE `creature_template` SET `lootid`=18633 WHERE `entry`=20638; +UPDATE `creature_template` SET `lootid`=18636 WHERE `entry`=20639; +UPDATE `creature_template` SET `lootid`=18631 WHERE `entry`=20640; +UPDATE `creature_template` SET `lootid`=18635 WHERE `entry`=20641; +UPDATE `creature_template` SET `lootid`=18632 WHERE `entry`=20642; +UPDATE `creature_template` SET `lootid`=18641 WHERE `entry`=20643; +UPDATE `creature_template` SET `lootid`=18830 WHERE `entry`=20644; +UPDATE `creature_template` SET `lootid`=18794 WHERE `entry`=20645; +UPDATE `creature_template` SET `lootid`=18637 WHERE `entry`=20646; +UPDATE `creature_template` SET `lootid`=18639 WHERE `entry`=20647; +UPDATE `creature_template` SET `lootid`=18634 WHERE `entry`=20648; +UPDATE `creature_template` SET `lootid`=18640 WHERE `entry`=20649; +UPDATE `creature_template` SET `lootid`=18638 WHERE `entry`=20650; +UPDATE `creature_template` SET `lootid`=18642 WHERE `entry`=20651; +UPDATE `creature_template` SET `lootid`=18796 WHERE `entry`=20652; +UPDATE `creature_template` SET `lootid`=18663 WHERE `entry`=20655; +UPDATE `creature_template` SET `lootid`=18848 WHERE `entry`=20656; +UPDATE `creature_template` SET `lootid`=19208 WHERE `entry`=20660; +UPDATE `creature_template` SET `lootid`=19209 WHERE `entry`=20661; +UPDATE `creature_template` SET `lootid`=19429 WHERE `entry`=20686; +UPDATE `creature_template` SET `lootid`=19428 WHERE `entry`=20688; +UPDATE `creature_template` SET `lootid`=18327 WHERE `entry`=20691; +UPDATE `creature_template` SET `lootid`=18323 WHERE `entry`=20692; +UPDATE `creature_template` SET `lootid`=18318 WHERE `entry`=20693; +UPDATE `creature_template` SET `lootid`=18328 WHERE `entry`=20694; +UPDATE `creature_template` SET `lootid`=18325 WHERE `entry`=20695; +UPDATE `creature_template` SET `lootid`=18322 WHERE `entry`=20696; +UPDATE `creature_template` SET `lootid`=18319 WHERE `entry`=20697; +UPDATE `creature_template` SET `lootid`=18320 WHERE `entry`=20698; +UPDATE `creature_template` SET `lootid`=18326 WHERE `entry`=20699; +UPDATE `creature_template` SET `lootid`=18321 WHERE `entry`=20701; +UPDATE `creature_template` SET `lootid`=20923 WHERE `entry`=20993; +UPDATE `creature_template` SET `lootid`=19510 WHERE `entry`=21522; +UPDATE `creature_template` SET `lootid`=20990 WHERE `entry`=21523; +UPDATE `creature_template` SET `lootid`=19167 WHERE `entry`=21524; +UPDATE `creature_template` SET `lootid`=19231 WHERE `entry`=21527; +UPDATE `creature_template` SET `lootid`=19712 WHERE `entry`=21528; +UPDATE `creature_template` SET `lootid`=19716 WHERE `entry`=21531; +UPDATE `creature_template` SET `lootid`=19713 WHERE `entry`=21532; +UPDATE `creature_template` SET `lootid`=19168 WHERE `entry`=21539; +UPDATE `creature_template` SET `lootid`=20988 WHERE `entry`=21540; +UPDATE `creature_template` SET `lootid`=20059 WHERE `entry`=21541; +UPDATE `creature_template` SET `lootid`=19735 WHERE `entry`=21542; +UPDATE `creature_template` SET `lootid`=19166 WHERE `entry`=21543; +UPDATE `creature_template` SET `lootid`=20857 WHERE `entry`=21585; +UPDATE `creature_template` SET `lootid`=20869 WHERE `entry`=21586; +UPDATE `creature_template` SET `lootid`=20859 WHERE `entry`=21587; +UPDATE `creature_template` SET `lootid`=20911 WHERE `entry`=21588; +UPDATE `creature_template` SET `lootid`=20905 WHERE `entry`=21589; +UPDATE `creature_template` SET `lootid`=20867 WHERE `entry`=21591; +UPDATE `creature_template` SET `lootid`=20868 WHERE `entry`=21593; +UPDATE `creature_template` SET `lootid`=20880 WHERE `entry`=21594; +UPDATE `creature_template` SET `lootid`=20879 WHERE `entry`=21595; +UPDATE `creature_template` SET `lootid`=20896 WHERE `entry`=21596; +UPDATE `creature_template` SET `lootid`=20897 WHERE `entry`=21597; +UPDATE `creature_template` SET `lootid`=20898 WHERE `entry`=21598; +UPDATE `creature_template` SET `lootid`=20912 WHERE `entry`=21601; +UPDATE `creature_template` SET `lootid`=20875 WHERE `entry`=21604; +UPDATE `creature_template` SET `lootid`=20873 WHERE `entry`=21605; +UPDATE `creature_template` SET `lootid`=20906 WHERE `entry`=21606; +UPDATE `creature_template` SET `lootid`=20865 WHERE `entry`=21607; +UPDATE `creature_template` SET `lootid`=20864 WHERE `entry`=21608; +UPDATE `creature_template` SET `lootid`=20901 WHERE `entry`=21610; +UPDATE `creature_template` SET `lootid`=20902 WHERE `entry`=21611; +UPDATE `creature_template` SET `lootid`=20882 WHERE `entry`=21613; +UPDATE `creature_template` SET `lootid`=20866 WHERE `entry`=21614; +UPDATE `creature_template` SET `lootid`=20883 WHERE `entry`=21615; +UPDATE `creature_template` SET `lootid`=20909 WHERE `entry`=21616; +UPDATE `creature_template` SET `lootid`=20908 WHERE `entry`=21617; +UPDATE `creature_template` SET `lootid`=20910 WHERE `entry`=21618; +UPDATE `creature_template` SET `lootid`=20881 WHERE `entry`=21619; +UPDATE `creature_template` SET `lootid`=20900 WHERE `entry`=21621; +UPDATE `creature_template` SET `lootid`=21126 WHERE `entry`=21842; +UPDATE `creature_template` SET `lootid`=21127 WHERE `entry`=21843; +UPDATE `creature_template` SET `lootid`=21694 WHERE `entry`=21914; +UPDATE `creature_template` SET `lootid`=21696 WHERE `entry`=21916; +UPDATE `creature_template` SET `lootid`=21695 WHERE `entry`=21917; +UPDATE `creature_template` SET `lootid`=21891 WHERE `entry`=21989; +UPDATE `creature_template` SET `lootid`=21904 WHERE `entry`=21990; +UPDATE `creature_template` SET `lootid`=22128 WHERE `entry`=22129; +UPDATE `creature_template` SET `lootid`=18983 WHERE `entry`=22162; +UPDATE `creature_template` SET `lootid`=17952 WHERE `entry`=22163; +UPDATE `creature_template` SET `lootid`=18982 WHERE `entry`=22173; +UPDATE `creature_template` SET `lootid`=21702 WHERE `entry`=22346; +UPDATE `creature_template` SET `lootid`=13536 WHERE `entry`=22530; +UPDATE `creature_template` SET `lootid`=13539 WHERE `entry`=22532; +UPDATE `creature_template` SET `lootid`=13424 WHERE `entry`=22533; +UPDATE `creature_template` SET `lootid`=13542 WHERE `entry`=22534; +UPDATE `creature_template` SET `lootid`=13554 WHERE `entry`=22535; +UPDATE `creature_template` SET `lootid`=13545 WHERE `entry`=22536; +UPDATE `creature_template` SET `lootid`=13557 WHERE `entry`=22537; +UPDATE `creature_template` SET `lootid`=13425 WHERE `entry`=22538; +UPDATE `creature_template` SET `lootid`=13155 WHERE `entry`=22539; +UPDATE `creature_template` SET `lootid`=14770 WHERE `entry`=22543; +UPDATE `creature_template` SET `lootid`=14768 WHERE `entry`=22547; +UPDATE `creature_template` SET `lootid`=13378 WHERE `entry`=22550; +UPDATE `creature_template` SET `lootid`=603 WHERE `entry`=22555; +UPDATE `creature_template` SET `lootid`=13377 WHERE `entry`=22565; +UPDATE `creature_template` SET `lootid`=13416 WHERE `entry`=22576; +UPDATE `creature_template` SET `lootid`=13151 WHERE `entry`=22578; +UPDATE `creature_template` SET `lootid`=14767 WHERE `entry`=22579; +UPDATE `creature_template` SET `lootid`=13526 WHERE `entry`=22587; +UPDATE `creature_template` SET `lootid`=13530 WHERE `entry`=22592; +UPDATE `creature_template` SET `lootid`=14769 WHERE `entry`=22595; +UPDATE `creature_template` SET `lootid`=13527 WHERE `entry`=22607; +UPDATE `creature_template` SET `lootid`=13531 WHERE `entry`=22612; +UPDATE `creature_template` SET `lootid`=13140 WHERE `entry`=22613; +UPDATE `creature_template` SET `lootid`=13319 WHERE `entry`=22614; +UPDATE `creature_template` SET `lootid`=13320 WHERE `entry`=22615; +UPDATE `creature_template` SET `lootid`=13154 WHERE `entry`=22616; +UPDATE `creature_template` SET `lootid`=13152 WHERE `entry`=22617; +UPDATE `creature_template` SET `lootid`=13318 WHERE `entry`=22618; +UPDATE `creature_template` SET `lootid`=13153 WHERE `entry`=22619; +UPDATE `creature_template` SET `lootid`=13139 WHERE `entry`=22620; +UPDATE `creature_template` SET `lootid`=13446 WHERE `entry`=22621; +UPDATE `creature_template` SET `lootid`=13597 WHERE `entry`=22623; +UPDATE `creature_template` SET `lootid`=13357 WHERE `entry`=22624; +UPDATE `creature_template` SET `lootid`=13841 WHERE `entry`=22628; +UPDATE `creature_template` SET `lootid`=13598 WHERE `entry`=22634; +UPDATE `creature_template` SET `lootid`=13356 WHERE `entry`=22635; +UPDATE `creature_template` SET `lootid`=13449 WHERE `entry`=22639; +UPDATE `creature_template` SET `lootid`=13840 WHERE `entry`=22640; +UPDATE `creature_template` SET `lootid`=12048 WHERE `entry`=22645; +UPDATE `creature_template` SET `lootid`=12052 WHERE `entry`=22649; +UPDATE `creature_template` SET `lootid`=12047 WHERE `entry`=22657; +UPDATE `creature_template` SET `lootid`=13325 WHERE `entry`=22662; +UPDATE `creature_template` SET `lootid`=13327 WHERE `entry`=22663; +UPDATE `creature_template` SET `lootid`=13330 WHERE `entry`=22664; +UPDATE `creature_template` SET `lootid`=13335 WHERE `entry`=22667; +UPDATE `creature_template` SET `lootid`=13336 WHERE `entry`=22668; +UPDATE `creature_template` SET `lootid`=13337 WHERE `entry`=22669; +UPDATE `creature_template` SET `lootid`=13426 WHERE `entry`=22671; +UPDATE `creature_template` SET `lootid`=13427 WHERE `entry`=22672; +UPDATE `creature_template` SET `lootid`=13428 WHERE `entry`=22673; +UPDATE `creature_template` SET `lootid`=13528 WHERE `entry`=22676; +UPDATE `creature_template` SET `lootid`=13440 WHERE `entry`=22679; +UPDATE `creature_template` SET `lootid`=13324 WHERE `entry`=22687; +UPDATE `creature_template` SET `lootid`=13329 WHERE `entry`=22688; +UPDATE `creature_template` SET `lootid`=13524 WHERE `entry`=22689; +UPDATE `creature_template` SET `lootid`=13576 WHERE `entry`=22691; +UPDATE `creature_template` SET `lootid`=13298 WHERE `entry`=22700; +UPDATE `creature_template` SET `lootid`=13145 WHERE `entry`=22701; +UPDATE `creature_template` SET `lootid`=13296 WHERE `entry`=22702; +UPDATE `creature_template` SET `lootid`=13147 WHERE `entry`=22703; +UPDATE `creature_template` SET `lootid`=13299 WHERE `entry`=22704; +UPDATE `creature_template` SET `lootid`=13300 WHERE `entry`=22705; +UPDATE `creature_template` SET `lootid`=13146 WHERE `entry`=22706; +UPDATE `creature_template` SET `lootid`=13137 WHERE `entry`=22707; +UPDATE `creature_template` SET `lootid`=13138 WHERE `entry`=22708; +UPDATE `creature_template` SET `lootid`=13297 WHERE `entry`=22709; +UPDATE `creature_template` SET `lootid`=13143 WHERE `entry`=22710; +UPDATE `creature_template` SET `lootid`=13144 WHERE `entry`=22711; +UPDATE `creature_template` SET `lootid`=13525 WHERE `entry`=22713; +UPDATE `creature_template` SET `lootid`=13529 WHERE `entry`=22718; +UPDATE `creature_template` SET `lootid`=13333 WHERE `entry`=22719; +UPDATE `creature_template` SET `lootid`=10984 WHERE `entry`=22725; +UPDATE `creature_template` SET `lootid`=13776 WHERE `entry`=22736; +UPDATE `creature_template` SET `lootid`=13537 WHERE `entry`=22754; +UPDATE `creature_template` SET `lootid`=13777 WHERE `entry`=22759; +UPDATE `creature_template` SET `lootid`=13676 WHERE `entry`=22764; +UPDATE `creature_template` SET `lootid`=13618 WHERE `entry`=22765; +UPDATE `creature_template` SET `lootid`=13150 WHERE `entry`=22768; +UPDATE `creature_template` SET `lootid`=13149 WHERE `entry`=22769; +UPDATE `creature_template` SET `lootid`=13541 WHERE `entry`=22774; +UPDATE `creature_template` SET `lootid`=13544 WHERE `entry`=22776; +UPDATE `creature_template` SET `lootid`=12156 WHERE `entry`=22788; +UPDATE `creature_template` SET `lootid`=12158 WHERE `entry`=22789; +UPDATE `creature_template` SET `lootid`=13956 WHERE `entry`=22790; +UPDATE `creature_template` SET `lootid`=13958 WHERE `entry`=22791; +UPDATE `creature_template` SET `lootid`=12157 WHERE `entry`=22792; +UPDATE `creature_template` SET `lootid`=10983 WHERE `entry`=22794; +UPDATE `creature_template` SET `lootid`=13957 WHERE `entry`=22795; +UPDATE `creature_template` SET `lootid`=11679 WHERE `entry`=22796; +UPDATE `creature_template` SET `lootid`=24976 WHERE `entry`=25548; +UPDATE `creature_template` SET `lootid`=24698 WHERE `entry`=25551; +UPDATE `creature_template` SET `lootid`=16506 WHERE `entry`=29274; +UPDATE `creature_template` SET `lootid`=16156 WHERE `entry`=29833; +UPDATE `creature_template` SET `lootid`=22262 WHERE `entry`=30759; +UPDATE `creature_template` SET `lootid`=22261 WHERE `entry`=30760; +UPDATE `creature_template` SET `lootid`=22263 WHERE `entry`=30761; +UPDATE `creature_template` SET `lootid`=23174 WHERE `entry`=30763; +UPDATE `creature_template` SET `lootid`=23386 WHERE `entry`=30773; +UPDATE `creature_template` SET `lootid`=26690 WHERE `entry`=30822; +UPDATE `creature_template` SET `lootid`=26691 WHERE `entry`=30823; +UPDATE `creature_template` SET `lootid`=27729 WHERE `entry`=31178; +UPDATE `creature_template` SET `lootid`=28249 WHERE `entry`=31179; +UPDATE `creature_template` SET `lootid`=27732 WHERE `entry`=31180; +UPDATE `creature_template` SET `lootid`=28200 WHERE `entry`=31184; +UPDATE `creature_template` SET `lootid`=27734 WHERE `entry`=31187; +UPDATE `creature_template` SET `lootid`=28199 WHERE `entry`=31188; +UPDATE `creature_template` SET `lootid`=27736 WHERE `entry`=31199; +UPDATE `creature_template` SET `lootid`=28201 WHERE `entry`=31200; +UPDATE `creature_template` SET `lootid`=27731 WHERE `entry`=31201; +UPDATE `creature_template` SET `lootid`=27742 WHERE `entry`=31202; +UPDATE `creature_template` SET `lootid`=27744 WHERE `entry`=31203; +UPDATE `creature_template` SET `lootid`=27743 WHERE `entry`=31206; +UPDATE `creature_template` SET `lootid`=32915 WHERE `entry`=33391; +UPDATE `creature_template` SET `lootid`=33772 WHERE `entry`=33773; +UPDATE `creature_template` SET `lootid`=33432 WHERE `entry`=34106; +UPDATE `creature_template` SET `lootid`=33651 WHERE `entry`=34108; +UPDATE `creature_template` SET `lootid`=35305 WHERE `entry`=35306; +UPDATE `creature_template` SET `lootid`=35307 WHERE `entry`=35308; +UPDATE `creature_template` SET `lootid`=35309 WHERE `entry`=35310; +UPDATE `creature_template` SET `lootid`=35143 WHERE `entry`=35359; +UPDATE `creature_template` SET `lootid`=37532 WHERE `entry`=38151; +UPDATE `creature_template` SET `lootid`=39946 WHERE `entry`=39805; +UPDATE `creature_template` SET `lootid`=39948 WHERE `entry`=39823; +UPDATE `creature_template` SET `lootid`=39947 WHERE `entry`=39920; +UPDATE `creature_template` SET `lootid`=40419 WHERE `entry`=40420; diff --git a/sql/old/3.3.5a/2012_09_15_00_world_disables.sql b/sql/old/3.3.5a/2012_09_15_00_world_disables.sql new file mode 100644 index 00000000000..371315b5be7 --- /dev/null +++ b/sql/old/3.3.5a/2012_09_15_00_world_disables.sql @@ -0,0 +1,4 @@ +-- Remove achievements from disables +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=7323; -- Ruby Void +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=7324; -- Emerald Void +DELETE FROM `disables` WHERE `sourceType`=4 AND `entry`=7325; -- Amber Void diff --git a/sql/old/3.3.5a/2012_09_15_01_world_creature_loot_template.sql b/sql/old/3.3.5a/2012_09_15_01_world_creature_loot_template.sql new file mode 100644 index 00000000000..71068d95bde --- /dev/null +++ b/sql/old/3.3.5a/2012_09_15_01_world_creature_loot_template.sql @@ -0,0 +1,19 @@ +SET @SisterSvalna := 37126; -- Sister Svalna + +CALL `sp_get_ref_id`('RAID_CRE',@Reference); +SET @RefSisterSvalna := @Reference+1; + +DELETE FROM `creature_loot_template` WHERE `entry`=@SisterSvalna; +INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES +(@SisterSvalna,49426,100,1,0,1,1),-- Sister Svalna dropping 1 Emblem of Frost +(@SisterSvalna,1,100,1,0,-@RefSisterSvalna,1); + +DELETE FROM `reference_loot_template` WHERE `entry`=@RefSisterSvalna; +INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES +(@RefSisterSvalna,50452,6,1,1,1,1), -- Wodin's Lucky Necklace +(@RefSisterSvalna,50453,5,1,1,1,1); -- Ring of Rotting Sinew + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=10 AND `SourceGroup`=@RefSisterSvalna; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(10,@RefSisterSvalna,50452,0,0,19,0,3,0,0,0,0,'', 'Wodin''s Lucky Necklace only 25 heroic'), +(10,@RefSisterSvalna,50453,0,0,19,0,3,0,0,0,0,'', 'Ring of Rotting Sinew only 25 heroic'); diff --git a/sql/updates/world/2012_09_16_00_world_version.sql b/sql/updates/world/2012_09_16_00_world_version.sql new file mode 100644 index 00000000000..74a1cf67499 --- /dev/null +++ b/sql/updates/world/2012_09_16_00_world_version.sql @@ -0,0 +1 @@ +UPDATE `version` SET `db_version`='TDB 335.49', `cache_id`=49 LIMIT 1; diff --git a/sql/updates/world/2012_09_16_01_world_conditions.sql b/sql/updates/world/2012_09_16_01_world_conditions.sql new file mode 100644 index 00000000000..64f87262d0e --- /dev/null +++ b/sql/updates/world/2012_09_16_01_world_conditions.sql @@ -0,0 +1,4 @@ +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=10 AND `SourceGroup`=34379; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(10,34379,50452,0,0,19,0,8,0,0,0,0,'', 'Wodin''s Lucky Necklace only 25 heroic'), +(10,34379,50453,0,0,19,0,8,0,0,0,0,'', 'Ring of Rotting Sinew only 25 heroic'); diff --git a/sql/updates/world/2012_09_16_01_world_creature_loot_template.sql b/sql/updates/world/2012_09_16_01_world_creature_loot_template.sql new file mode 100644 index 00000000000..2d87ad3aa16 --- /dev/null +++ b/sql/updates/world/2012_09_16_01_world_creature_loot_template.sql @@ -0,0 +1 @@ +UPDATE `creature_loot_template` SET `item`=39657 WHERE `entry`=28546 AND `item`=36657; diff --git a/sql/updates/world/2012_09_16_01_world_creature_template_addon.sql b/sql/updates/world/2012_09_16_01_world_creature_template_addon.sql new file mode 100644 index 00000000000..15415e856f3 --- /dev/null +++ b/sql/updates/world/2012_09_16_01_world_creature_template_addon.sql @@ -0,0 +1,3 @@ +DELETE FROM `creature_template_addon` WHERE `entry`=28670; -- Frostbrood Vanquisher +INSERT INTO `creature_template_addon` (`entry`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES +(28670,0,0,0x3000000,0x1,0,'53112'); diff --git a/sql/updates/world/2012_09_16_02_world_fires_over_skettis.sql b/sql/updates/world/2012_09_16_02_world_fires_over_skettis.sql new file mode 100644 index 00000000000..d50f45bb020 --- /dev/null +++ b/sql/updates/world/2012_09_16_02_world_fires_over_skettis.sql @@ -0,0 +1,26 @@ +-- Add support for quest ID: 11008 - "Fires Over Skettis" Warpten fix and Nelegalno/shlomi1515 updates +-- Also add support for achievement - http://www.wowhead.com/achievement=1275/bombs-away +-- Fix previous SQL what is not changed is not included +SET @TRIGGER := 22991; +SET @EGG := 185549; +SET @SKYBLAST := 39844; +SET @SUMMEGG := 39843; +-- Adds SAI support for Monstrous Kaliri Egg Trigger and the GO +UPDATE `creature_template` SET `AIName`= 'SmartAI' WHERE `entry`=@TRIGGER; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@TRIGGER AND `source_type`=0; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@TRIGGER*100 AND `source_type`=9; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@TRIGGER,0,0,0,25,0,100,0,0,0,0,0,11,@SUMMEGG,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - On spawn/reset - Summon Monstrous Kaliri Egg (object wild)'), +(@TRIGGER,0,1,2,8,0,100,0,@SKYBLAST,0,0,0,33,@TRIGGER,0,0,0,0,0,16,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - On Skyguard Blasting Charge hit - Give kill credit to invoker party'), +(@TRIGGER,0,2,0,61,0,100,0,0,0,0,0,80,@TRIGGER*100,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger - Linked with previous event - Start script 0'), +(@TRIGGER*100,9,0,0,0,0,100,0,44000,44000,0,0,11,@SUMMEGG,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Monstrous Kaliri Egg Trigger /On actionlist/ - Action 0 - Cast Summon Monstrous Kaliri Egg'); +-- Add conditions (thanks to Vincent-Michael for adding and Shauren for noticing my failure miss) +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry`=@SKYBLAST; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(13,1,@SKYBLAST,0,0,31,0,3,22991,0,0,0,'','Skyguard Blasting Charge can hit only Monstrous Kaliri Egg Trigger'), +(13,2,@SKYBLAST,0,0,31,0,5,185549,0,0,0,'','Skyguard Blasting can hit only Monstrous Kaliri Egg'); +-- Remove SAI for Cannonball Stack +UPDATE `gameobject_template` SET `AIName`='' WHERE `entry`=@EGG; +DELETE FROM `smart_scripts` WHERE `entryorguid`=@EGG AND `source_type`=1; +-- Delete GO spawns that are not needed +DELETE FROM `gameobject` WHERE `id`=@EGG; diff --git a/sql/updates/world/2012_09_16_03_world_spell_script_names.sql b/sql/updates/world/2012_09_16_03_world_spell_script_names.sql new file mode 100644 index 00000000000..8b7e6aa92ba --- /dev/null +++ b/sql/updates/world/2012_09_16_03_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM spell_script_names WHERE scriptName="spell_dru_savage_roar"; +INSERT INTO spell_script_names (spell_id, ScriptName) VALUES +(52610, 'spell_dru_savage_roar'); diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index d55d2cf02b3..fc4d4dfcc9b 100755 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -196,7 +196,7 @@ const AuthHandler table[] = Patcher PatchesCache; // Constructor - set the N and g values for SRP6 -AuthSocket::AuthSocket(RealmSocket& socket) : socket_(socket), pPatch(NULL) +AuthSocket::AuthSocket(RealmSocket& socket) : pPatch(NULL), socket_(socket) { N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); g.SetDword(7); @@ -409,7 +409,7 @@ bool AuthSocket::_HandleLogonChallenge() PreparedQueryResult banresult = LoginDatabase.Query(stmt); if (banresult) { - if ((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64()) + if ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32()) { pkt << uint8(WOW_FAIL_BANNED); sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ()); diff --git a/src/server/collision/Management/IVMapManager.h b/src/server/collision/Management/IVMapManager.h index a645e88ef05..7cf296625f4 100755 --- a/src/server/collision/Management/IVMapManager.h +++ b/src/server/collision/Management/IVMapManager.h @@ -35,7 +35,7 @@ namespace VMAP { VMAP_LOAD_RESULT_ERROR, VMAP_LOAD_RESULT_OK, - VMAP_LOAD_RESULT_IGNORED, + VMAP_LOAD_RESULT_IGNORED }; #define VMAP_INVALID_HEIGHT -100000.0f // for check diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index f35e36d92fd..89412a69c33 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -125,7 +125,7 @@ namespace VMAP } StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath) - : iMapID(mapID), iTreeValues(0), iBasePath(basePath), iIsTiled(false) + : iMapID(mapID), iIsTiled(false), iTreeValues(0), iBasePath(basePath) { if (iBasePath.length() > 0 && iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\') { diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp index 8458ffdd5d3..434522d3515 100644 --- a/src/server/collision/Maps/TileAssembler.cpp +++ b/src/server/collision/Maps/TileAssembler.cpp @@ -54,7 +54,7 @@ namespace VMAP //================================================================= TileAssembler::TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName) - : iSrcDir(pSrcDirName), iDestDir(pDestDirName), iCurrentUniqueNameId(0), iFilterMethod(NULL) + : iDestDir(pDestDirName), iSrcDir(pSrcDirName), iFilterMethod(NULL), iCurrentUniqueNameId(0) { //mkdir(iDestDir); //init(); diff --git a/src/server/collision/Models/GameObjectModel.h b/src/server/collision/Models/GameObjectModel.h index 0bb6c0f47bc..78a0e876676 100644 --- a/src/server/collision/Models/GameObjectModel.h +++ b/src/server/collision/Models/GameObjectModel.h @@ -61,6 +61,8 @@ public: void disable() { phasemask = 0;} void enable(uint32 ph_mask) { phasemask = ph_mask;} + bool isEnabled() const {return phasemask != 0;} + bool intersectRay(const G3D::Ray& Ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const; static GameObjectModel* Create(const GameObject& go); diff --git a/src/server/collision/Models/ModelInstance.h b/src/server/collision/Models/ModelInstance.h index 2745628ac7e..b0189ad8542 100755 --- a/src/server/collision/Models/ModelInstance.h +++ b/src/server/collision/Models/ModelInstance.h @@ -63,7 +63,7 @@ namespace VMAP class ModelInstance: public ModelSpawn { public: - ModelInstance(): iModel(0), iInvScale(0.0f) {} + ModelInstance(): iInvScale(0.0f), iModel(0) {} ModelInstance(const ModelSpawn &spawn, WorldModel* model); void setUnloaded() { iModel = 0; } bool intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const; diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 7d7a27fce13..5ab5f99310a 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -111,6 +111,11 @@ void CombatAI::UpdateAI(const uint32 diff) DoMeleeAttackIfReady(); } +void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) +{ + events.RescheduleEvent(spellId, unTimeMs); +} + ///////////////// //CasterAI ///////////////// diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index ad98cec0779..fa31e57d780 100755 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -46,6 +46,7 @@ class CombatAI : public CreatureAI void EnterCombat(Unit* who); void JustDied(Unit* killer); void UpdateAI(const uint32 diff); + void SpellInterrupted(uint32 spellId, uint32 unTimeMs); static int Permissible(const Creature*); protected: EventMap events; diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 593f0d15e18..119cfd3d35e 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -35,7 +35,7 @@ enum GeneralScriptTexts EMOTE_GENERIC_FRENZY = -1000002, EMOTE_GENERIC_ENRAGED = -1000003, EMOTE_GENERIC_BERSERK = -1000004, - EMOTE_GENERIC_BERSERK_RAID = -1000005, // RaidBossEmote version of the previous one + EMOTE_GENERIC_BERSERK_RAID = -1000005 // RaidBossEmote version of the previous one }; //Selection method used by SelectTarget @@ -45,7 +45,7 @@ enum SelectAggroTarget SELECT_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom SELECT_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top SELECT_TARGET_NEAREST, - SELECT_TARGET_FARTHEST, + SELECT_TARGET_FARTHEST }; // default predicate function to select target based on distance, player and/or aura criteria @@ -242,6 +242,10 @@ class UnitAI // Called when the unit heals virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {} + /// Called when a spell is interrupted by Spell::EffectInterruptCast + /// Use to reschedule next planned cast of spell. + virtual void SpellInterrupted(uint32 /*spellId*/, uint32 /*unTimeMs*/) {} + void AttackStartCaster(Unit* victim, float dist); void DoAddAuraToAllHostilePlayers(uint32 spellid); diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 68752b82e7f..d3ad27935ca 100755 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -45,7 +45,7 @@ enum SelectTargetType SELECT_TARGET_SINGLE_FRIEND, //Only Single Friend SELECT_TARGET_AOE_FRIEND, //Only AoE Friend - SELECT_TARGET_ANY_FRIEND, //AoE or Single Friend + SELECT_TARGET_ANY_FRIEND //AoE or Single Friend }; //Spell Effects used by SelectSpell @@ -54,7 +54,7 @@ enum SelectEffect SELECT_EFFECT_DONTCARE = 0, //All spell effects allowed SELECT_EFFECT_DAMAGE, //Spell does damage SELECT_EFFECT_HEALING, //Spell does healing - SELECT_EFFECT_AURA, //Spell applies an aura + SELECT_EFFECT_AURA //Spell applies an aura }; enum SCEquip diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index d097adf38ec..981ac1f5f16 100755 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -505,14 +505,14 @@ enum AITarget AITARGET_ENEMY, AITARGET_ALLY, AITARGET_BUFF, - AITARGET_DEBUFF, + AITARGET_DEBUFF }; enum AICondition { AICOND_AGGRO, AICOND_COMBAT, - AICOND_DIE, + AICOND_DIE }; #define AI_DEFAULT_COOLDOWN 5000 diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index aa14bc1b56e..951a035628a 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -1317,6 +1317,10 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false))) return false; + //Spell is on cooldown + if (me->HasSpellCooldown(spell->Id)) + return false; + return true; } diff --git a/src/server/game/AI/EventAI/CreatureEventAI.h b/src/server/game/AI/EventAI/CreatureEventAI.h index b9e1ae32be4..da5f0b084cf 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.h +++ b/src/server/game/AI/EventAI/CreatureEventAI.h @@ -60,7 +60,7 @@ enum EventAI_Type EVENT_T_TARGET_BUFFED = 24, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max EVENT_T_RESET = 35, // Is it called after combat, when the creature respawn and spawn. -- TRINITY ONLY - EVENT_T_END, + EVENT_T_END }; enum EventAI_ActionType @@ -119,7 +119,7 @@ enum EventAI_ActionType ACTION_T_ATTACK_START_PULSE = 103, //Distance ACTION_T_SUMMON_GO = 104, //GameObjectID, DespawnTime in ms - ACTION_T_END = 105, + ACTION_T_END = 105 }; enum Target @@ -156,7 +156,7 @@ enum CastFlags CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself - CAST_AURA_NOT_PRESENT = 0x20, //Only casts the spell if the target does not have an aura from the spell + CAST_AURA_NOT_PRESENT = 0x20 //Only casts the spell if the target does not have an aura from the spell }; enum EventFlags diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 0b8236908a0..7dd4053b82f 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -634,8 +634,11 @@ void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo) void SmartAI::DamageTaken(Unit* doneBy, uint32& damage) { GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage); - if ((me->GetHealth() - damage) <= mInvincibilityHpLevel) - damage = me->GetHealth() - mInvincibilityHpLevel; + if (mInvincibilityHpLevel && (damage >= me->GetHealth() - mInvincibilityHpLevel)) + { + damage = 0; + me->SetHealth(mInvincibilityHpLevel); + } } void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth) diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 79cef0c3b37..f81d6e86850 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -40,7 +40,7 @@ enum SmartEscortState enum SmartEscortVars { SMART_ESCORT_MAX_PLAYER_DIST = 50, - SMART_MAX_AID_DIST = SMART_ESCORT_MAX_PLAYER_DIST / 2, + SMART_MAX_AID_DIST = SMART_ESCORT_MAX_PLAYER_DIST / 2 }; class SmartAI : public CreatureAI diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 69ecb1ef581..dbc6f6bae1a 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1951,6 +1951,20 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u delete targets; break; } + case SMART_ACTION_SET_HOME_POS: + { + if (!me) + break; + + if (e.GetTargetType() == SMART_TARGET_SELF) + me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); + else if (e.GetTargetType() == SMART_TARGET_POSITION) + me->SetHomePosition(e.target.x, e.target.y, e.target.z, e.target.o); + else + sLog->outError(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is not using SMART_TARGET_SELF or SMART_TARGET_POSITION, skipping"); + + break; + } default: sLog->outError(LOG_FILTER_SQL, "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); break; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index ef5c7511124..654cdee72c3 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -904,6 +904,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_SEND_GOSSIP_MENU: case SMART_ACTION_GO_SET_LOOT_STATE: case SMART_ACTION_SEND_TARGET_TO_TARGET: + case SMART_ACTION_SET_HOME_POS: break; default: sLog->outError(LOG_FILTER_SQL, "SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index f1747734a29..19aa6886ea0 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -54,7 +54,7 @@ enum SMART_EVENT_PHASE SMART_EVENT_PHASE_6 = 6, SMART_EVENT_PHASE_MAX = 7, - SMART_EVENT_PHASE_COUNT = 6, + SMART_EVENT_PHASE_COUNT = 6 }; enum SMART_EVENT_PHASE_BITS @@ -66,7 +66,7 @@ enum SMART_EVENT_PHASE_BITS SMART_EVENT_PHASE_4_BIT = 8, SMART_EVENT_PHASE_5_BIT = 16, SMART_EVENT_PHASE_6_BIT = 32, - SMART_EVENT_PHASE_ALL = SMART_EVENT_PHASE_1_BIT + SMART_EVENT_PHASE_2_BIT + SMART_EVENT_PHASE_3_BIT + SMART_EVENT_PHASE_4_BIT + SMART_EVENT_PHASE_5_BIT + SMART_EVENT_PHASE_6_BIT, + SMART_EVENT_PHASE_ALL = SMART_EVENT_PHASE_1_BIT + SMART_EVENT_PHASE_2_BIT + SMART_EVENT_PHASE_3_BIT + SMART_EVENT_PHASE_4_BIT + SMART_EVENT_PHASE_5_BIT + SMART_EVENT_PHASE_6_BIT }; const uint32 SmartPhaseMask[SMART_EVENT_PHASE_COUNT][2] = @@ -76,7 +76,7 @@ const uint32 SmartPhaseMask[SMART_EVENT_PHASE_COUNT][2] = {SMART_EVENT_PHASE_3, SMART_EVENT_PHASE_3_BIT }, {SMART_EVENT_PHASE_4, SMART_EVENT_PHASE_4_BIT }, {SMART_EVENT_PHASE_5, SMART_EVENT_PHASE_5_BIT }, - {SMART_EVENT_PHASE_6, SMART_EVENT_PHASE_6_BIT }, + {SMART_EVENT_PHASE_6, SMART_EVENT_PHASE_6_BIT } }; enum SMART_EVENT @@ -156,7 +156,7 @@ enum SMART_EVENT SMART_EVENT_ACTION_DONE = 72, // eventId (SharedDefines.EventId) SMART_EVENT_ON_SPELLCLICK = 73, // clicker (unit) - SMART_EVENT_END = 74, + SMART_EVENT_END = 74 }; struct SmartEvent @@ -376,7 +376,7 @@ enum SMART_SCRIPT_RESPAWN_CONDITION SMART_SCRIPT_RESPAWN_CONDITION_NONE = 0, SMART_SCRIPT_RESPAWN_CONDITION_MAP = 1, SMART_SCRIPT_RESPAWN_CONDITION_AREA = 2, - SMART_SCRIPT_RESPAWN_CONDITION_END = 3, + SMART_SCRIPT_RESPAWN_CONDITION_END = 3 }; enum SMART_ACTION @@ -484,8 +484,9 @@ enum SMART_ACTION SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId SMART_ACTION_GO_SET_LOOT_STATE = 99, // state SMART_ACTION_SEND_TARGET_TO_TARGET = 100, // id + SMART_ACTION_SET_HOME_POS = 101, // none - SMART_ACTION_END = 101, + SMART_ACTION_END = 102 }; struct SmartAction @@ -934,7 +935,7 @@ enum SMARTAI_TEMPLATE SMARTAI_TEMPLATE_PASSIVE = 3, SMARTAI_TEMPLATE_CAGED_GO_PART = 4, //creatureID, give credit at point end?, SMARTAI_TEMPLATE_CAGED_NPC_PART = 5, //gameObjectID, despawntime, run?, dist, TextGroupID - SMARTAI_TEMPLATE_END = 6, + SMARTAI_TEMPLATE_END = 6 }; enum SMARTAI_TARGETS @@ -964,7 +965,7 @@ enum SMARTAI_TARGETS SMART_TARGET_ACTION_INVOKER_VEHICLE = 22, // Unit's vehicle who caused this Event to occur SMART_TARGET_OWNER_OR_SUMMONER = 23, // Unit's owner or summoner SMART_TARGET_THREAT_LIST = 24, // All units on creature's threat list - SMART_TARGET_END = 25, + SMART_TARGET_END = 25 }; struct SmartTarget @@ -1057,12 +1058,12 @@ struct SmartTarget enum eSmartAI { - SMART_EVENT_PARAM_COUNT = 4, - SMART_ACTION_PARAM_COUNT = 6, - SMART_SUMMON_COUNTER = 0xFFFFFF, + SMART_EVENT_PARAM_COUNT = 4, + SMART_ACTION_PARAM_COUNT = 6, + SMART_SUMMON_COUNTER = 0xFFFFFF, SMART_ESCORT_LAST_OOC_POINT = 0xFFFFFF, - SMART_RANDOM_POINT = 0xFFFFFE, - SMART_ESCORT_TARGETS = 0xFFFFFF + SMART_RANDOM_POINT = 0xFFFFFE, + SMART_ESCORT_TARGETS = 0xFFFFFF }; enum SmartScriptType @@ -1091,7 +1092,7 @@ enum SmartAITypeMaskId SMART_SCRIPT_TYPE_MASK_SPELL = 64, SMART_SCRIPT_TYPE_MASK_TRANSPORT = 128, SMART_SCRIPT_TYPE_MASK_INSTANCE = 256, - SMART_SCRIPT_TYPE_MASK_TIMED_ACTIONLIST = 512, + SMART_SCRIPT_TYPE_MASK_TIMED_ACTIONLIST = 512 }; const uint32 SmartAITypeMask[SMART_SCRIPT_TYPE_MAX][2] = @@ -1183,7 +1184,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] = {SMART_EVENT_GO_STATE_CHANGED, SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_GO_EVENT_INFORM, SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_ACTION_DONE, SMART_SCRIPT_TYPE_MASK_CREATURE }, - {SMART_EVENT_ON_SPELLCLICK, SMART_SCRIPT_TYPE_MASK_CREATURE }, + {SMART_EVENT_ON_SPELLCLICK, SMART_SCRIPT_TYPE_MASK_CREATURE } }; enum SmartEventFlags @@ -1209,14 +1210,15 @@ enum SmartCastFlags //CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range //CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range //CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself - SMARTCAST_AURA_NOT_PRESENT = 0x20, //Only casts the spell if the target does not have an aura from the spell + SMARTCAST_AURA_NOT_PRESENT = 0x20 //Only casts the spell if the target does not have an aura from the spell }; // one line in DB is one event struct SmartScriptHolder { - SmartScriptHolder() : timer(0), active(false), runOnce(false), link(0), entryOrGuid(0), - event_id(0), enableTimed(false), source_type(SMART_SCRIPT_TYPE_CREATURE) {} + SmartScriptHolder() : entryOrGuid(0), source_type(SMART_SCRIPT_TYPE_CREATURE) + , event_id(0), link(0), timer(0), active(false), runOnce(false) + , enableTimed(false) {} int32 entryOrGuid; SmartScriptType source_type; diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index c69f3c0a6f3..aaaf4f4f603 100755 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -55,6 +55,6 @@ namespace AccountMgr bool IsGMAccount(uint32 gmlevel); bool IsAdminAccount(uint32 gmlevel); bool IsConsoleAccount(uint32 gmlevel); -}; +} #endif diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 506495469d3..dff155926de 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -128,12 +128,6 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria) } return true; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE: - if (!classRace.class_id && !classRace.race_id) - { - sLog->outError(LOG_FILTER_SQL, "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE (%u) must not have 0 in either value field, ignored.", - criteria->ID, criteria->requiredType, dataType); - return false; - } if (classRace.class_id && ((1 << (classRace.class_id-1)) & CLASSMASK_ALL_PLAYABLE) == 0) { sLog->outError(LOG_FILTER_SQL, "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE (%u) has non-existing class in value1 (%u), ignored.", @@ -364,7 +358,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un return sScriptMgr->OnCriteriaCheck(this, const_cast<Player*>(source), const_cast<Unit*>(target)); case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: if (source->GetMap()->IsRaid()) - if (source->GetMap()->Is25ManRaid() != (difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN)) + if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0)) return false; return source->GetMap()->GetSpawnMode() >= difficulty.difficulty; case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT: @@ -723,7 +717,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8); data.append(GetPlayer()->GetPackGUID()); data << uint32(achievement->ID); - data << uint32(secsToTimeBitFields(time(NULL))); + data.AppendPackedTime(time(NULL)); data << uint32(0); GetPlayer()->SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true); } @@ -741,7 +735,7 @@ void AchievementMgr::SendCriteriaUpdate(AchievementCriteriaEntry const* entry, C data << uint32(0); else data << uint32(timedCompleted ? 0 : 1); // this are some flags, 1 is for keeping the counter at 0 in client - data << uint32(secsToTimeBitFields(progress->date)); + data.AppendPackedTime(progress->date); data << uint32(timeElapsed); // time elapsed in seconds data << uint32(0); // unk GetPlayer()->SendDirectMessage(&data); @@ -2132,7 +2126,7 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket* data) const continue; *data << uint32(iter->first); - *data << uint32(secsToTimeBitFields(iter->second.date)); + data->AppendPackedTime(iter->second.date); } *data << int32(-1); @@ -2142,7 +2136,7 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket* data) const data->appendPackGUID(iter->second.counter); data->append(GetPlayer()->GetPackGUID()); *data << uint32(0); - *data << uint32(secsToTimeBitFields(iter->second.date)); + data->AppendPackedTime(iter->second.date); *data << uint32(0); *data << uint32(0); } diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h index c7d838fcb44..3215b4196f7 100755 --- a/src/server/game/Achievements/AchievementMgr.h +++ b/src/server/game/Achievements/AchievementMgr.h @@ -63,7 +63,7 @@ enum AchievementCriteriaDataType ACHIEVEMENT_CRITERIA_DATA_INSTANCE_SCRIPT = 18, // 0 0 maker instance script call for check current criteria requirements fit ACHIEVEMENT_CRITERIA_DATA_TYPE_S_EQUIPED_ITEM = 19, // item_level item_quality for equipped item in slot to check item level and quality ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_ID = 20, // map_id 0 player must be on map with id in map_id - ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE = 21, // class_id race_id + ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE = 21 // class_id race_id }; #define MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE 22 // maximum value in AchievementCriteriaDataType enum diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 84b5513b659..75bac2ca5ca 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -34,7 +34,7 @@ enum eAuctionHouse { - AH_MINIMUM_DEPOSIT = 100, + AH_MINIMUM_DEPOSIT = 100 }; AuctionHouseMgr::AuctionHouseMgr() diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index ffc5e48290b..ae58f3504b4 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -60,6 +60,13 @@ Battlefield::Battlefield() Battlefield::~Battlefield() { + for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) + delete itr->second; + + for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr) + delete *itr; + + m_capturePoints.clear(); } // Called when a player enters the zone @@ -444,8 +451,8 @@ WorldPacket Battlefield::BuildWarningAnnPacket(std::string msg) data << uint32(1); data << uint8(0); data << uint64(0); - data << uint32(strlen(msg.c_str()) + 1); - data << msg.c_str(); + data << uint32(msg.length() + 1); + data << msg; data << uint8(0); return data; @@ -456,7 +463,7 @@ void Battlefield::SendWarningToAllInZone(uint32 entry) if (Unit* unit = sObjectAccessor->FindUnit(StalkerGuid)) if (Creature* stalker = unit->ToCreature()) // FIXME: replaced CHAT_TYPE_END with CHAT_MSG_BG_SYSTEM_NEUTRAL to fix compile, it's a guessed change :/ - sCreatureTextMgr->SendChat(stalker, (uint8) entry, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_ADDON, TEXT_RANGE_ZONE); + sCreatureTextMgr->SendChat(stalker, (uint8) entry, 0, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_ADDON, TEXT_RANGE_ZONE); } /*void Battlefield::SendWarningToAllInWar(int32 entry,...) @@ -669,8 +676,8 @@ BfGraveyard::BfGraveyard(Battlefield* battlefield) m_Bf = battlefield; m_GraveyardId = 0; m_ControlTeam = TEAM_NEUTRAL; - m_SpiritGuide[0] = NULL; - m_SpiritGuide[1] = NULL; + m_SpiritGuide[0] = 0; + m_SpiritGuide[1] = 0; m_ResurrectQueue.clear(); } diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 07daf33d431..480aafbeb42 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -29,13 +29,12 @@ enum BattlefieldTypes { - BATTLEFIELD_WG, // Wintergrasp - BATTLEFIELD_TB, // Tol Barad (cataclysm) + BATTLEFIELD_WG // Wintergrasp }; enum BattlefieldIDs { - BATTLEFIELD_BATTLEID_WG = 1, // Wintergrasp battle + BATTLEFIELD_BATTLEID_WG = 1 // Wintergrasp battle }; enum BattlefieldObjectiveStates @@ -46,7 +45,7 @@ enum BattlefieldObjectiveStates BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE, BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE, BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE, - BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE, + BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE }; enum BattlefieldSounds diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 09783176094..9a701b5b044 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -30,13 +30,16 @@ enum WGVehicles NPC_WG_SEIGE_ENGINE_ALLIANCE = 28312, NPC_WG_SEIGE_ENGINE_HORDE = 32627, NPC_WG_DEMOLISHER = 28094, - NPC_WG_CATAPULT = 27881, + NPC_WG_CATAPULT = 27881 }; BattlefieldWG::~BattlefieldWG() { for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr) delete *itr; + + for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) + delete *itr; } bool BattlefieldWG::SetupBattlefield() diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index 734154020d9..11510e1ea98 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -47,7 +47,7 @@ typedef std::set<Group*> GroupSet; enum WintergrastData { BATTLEFIELD_WG_ZONEID = 4197, // Wintergrasp - BATTLEFIELD_WG_MAPID = 571, // Northrend + BATTLEFIELD_WG_MAPID = 571 // Northrend }; enum WintergraspSpells @@ -91,7 +91,7 @@ enum WintergraspSpells SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT = 56617, // ADDS PHASE 32 SPELL_HORDE_CONTROL_PHASE_SHIFT = 55773, // ADDS PHASE 64 - SPELL_ALLIANCE_CONTROL_PHASE_SHIFT = 55774, // ADDS PHASE 128 + SPELL_ALLIANCE_CONTROL_PHASE_SHIFT = 55774 // ADDS PHASE 128 }; enum WintergraspData @@ -104,7 +104,7 @@ enum WintergraspData BATTLEFIELD_WG_DATA_MAX_VEHICLE_H, BATTLEFIELD_WG_DATA_VEHICLE_A, BATTLEFIELD_WG_DATA_VEHICLE_H, - BATTLEFIELD_WG_DATA_MAX, + BATTLEFIELD_WG_DATA_MAX }; enum WintergraspAchievements @@ -124,7 +124,7 @@ enum WintergraspAchievements ACHIEVEMENTS_STONE_KEEPER_1000 = 2089, // todo ACHIEVEMENTS_WG_RANGER = 2199, // todo ACHIEVEMENTS_DESTRUCTION_DERBY_H = 2476, // todo - ACHIEVEMENTS_WG_MASTER_H = 2776, // todo + ACHIEVEMENTS_WG_MASTER_H = 2776 // todo }; enum WintergraspWorldStates @@ -136,7 +136,7 @@ enum WintergraspWorldStates BATTLEFIELD_WG_WORLD_STATE_ACTIVE = 3801, BATTLEFIELD_WG_WORLD_STATE_DEFENDER = 3802, BATTLEFIELD_WG_WORLD_STATE_ATTACKER = 3803, - BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE = 3710, + BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE = 3710 }; enum WintergraspAreaIds @@ -147,7 +147,7 @@ enum WintergraspAreaIds AREA_WESTPARK_WORKSHOP = 4611, AREA_EASTPARK_WORKSHOP = 4612, AREA_WINTERGRASP = 4197, - AREA_THE_CHILLED_QUAGMIRE = 4589, + AREA_THE_CHILLED_QUAGMIRE = 4589 }; /*######################### @@ -174,7 +174,7 @@ enum WGGraveyardId BATTLEFIELD_WG_GY_KEEP, BATTLEFIELD_WG_GY_HORDE, BATTLEFIELD_WG_GY_ALLIANCE, - BATTLEFIELD_WG_GRAVEYARD_MAX, + BATTLEFIELD_WG_GRAVEYARD_MAX }; enum WGGossipText @@ -185,7 +185,7 @@ enum WGGossipText BATTLEFIELD_WG_GOSSIPTEXT_GY_SW = -1850503, BATTLEFIELD_WG_GOSSIPTEXT_GY_KEEP = -1850500, BATTLEFIELD_WG_GOSSIPTEXT_GY_HORDE = -1850505, - BATTLEFIELD_WG_GOSSIPTEXT_GY_ALLIANCE = -1850506, + BATTLEFIELD_WG_GOSSIPTEXT_GY_ALLIANCE = -1850506 }; enum WintergraspNpcs @@ -222,7 +222,7 @@ enum WintergraspNpcs NPC_WINTERGRASP_SIEGE_ENGINE_HORDE = 32627, NPC_WINTERGRASP_CATAPULT = 27881, NPC_WINTERGRASP_DEMOLISHER = 28094, - NPC_WINTERGRASP_TOWER_CANNON = 28366, + NPC_WINTERGRASP_TOWER_CANNON = 28366 }; struct BfWGCoordGY @@ -456,7 +456,7 @@ enum WintergraspGameObjectBuildingType BATTLEFIELD_WG_OBJECTTYPE_WALL, BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST, BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER, - BATTLEFIELD_WG_OBJECTTYPE_TOWER, + BATTLEFIELD_WG_OBJECTTYPE_TOWER }; enum WintergraspGameObjectState @@ -470,7 +470,7 @@ enum WintergraspGameObjectState BATTLEFIELD_WG_OBJECTSTATE_HORDE_DESTROY, BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT, BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE, - BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY, + BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY }; enum WintergraspWorkshopIds @@ -480,7 +480,7 @@ enum WintergraspWorkshopIds BATTLEFIELD_WG_WORKSHOP_SE, BATTLEFIELD_WG_WORKSHOP_SW, BATTLEFIELD_WG_WORKSHOP_KEEP_WEST, - BATTLEFIELD_WG_WORKSHOP_KEEP_EAST, + BATTLEFIELD_WG_WORKSHOP_KEEP_EAST }; enum WintergraspWorldstates @@ -497,7 +497,7 @@ enum WintergraspTeamControl { BATTLEFIELD_WG_TEAM_ALLIANCE, BATTLEFIELD_WG_TEAM_HORDE, - BATTLEFIELD_WG_TEAM_NEUTRAL, + BATTLEFIELD_WG_TEAM_NEUTRAL }; // TODO: Handle this with creature_text ? @@ -525,7 +525,7 @@ enum WintergraspText BATTLEFIELD_WG_TEXT_TOWER_NAME_E = 12070, BATTLEFIELD_WG_TEXT_TOWER_NAME_W = 12071, BATTLEFIELD_WG_TEXT_DEFEND_KEEP = 12068, - BATTLEFIELD_WG_TEXT_WIN_KEEP = 12072, + BATTLEFIELD_WG_TEXT_WIN_KEEP = 12072 }; enum WintergraspGameObject @@ -549,8 +549,7 @@ enum WintergraspGameObject GO_WINTERGRASP_FORTRESS_GATE = 190375, GO_WINTERGRASP_VAULT_GATE = 191810, - GO_WINTERGRASP_KEEP_COLLISION_WALL = 194323, - + GO_WINTERGRASP_KEEP_COLLISION_WALL = 194323 }; struct WintergraspObjectPositionData @@ -1133,9 +1132,9 @@ const WGWorkshopData WorkshopsData[WG_MAX_WORKSHOP] = // SW {BATTLEFIELD_WG_WORKSHOP_SW, WORLDSTATE_WORKSHOP_SW, BATTLEFIELD_WG_TEXT_WORKSHOP_NAME_SW}, // KEEP WEST - It can't be taken, so it doesn't have a textid - {BATTLEFIELD_WG_WORKSHOP_KEEP_WEST, WORLDSTATE_WORKSHOP_K_W, NULL}, + {BATTLEFIELD_WG_WORKSHOP_KEEP_WEST, WORLDSTATE_WORKSHOP_K_W, 0}, // KEEP EAST - It can't be taken, so it doesn't have a textid - {BATTLEFIELD_WG_WORKSHOP_KEEP_EAST, WORLDSTATE_WORKSHOP_K_E, NULL} + {BATTLEFIELD_WG_WORKSHOP_KEEP_EAST, WORLDSTATE_WORKSHOP_K_E, 0} }; // ******************************************************************** diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 01dfbb23033..e658ac4ecbd 100755 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -38,7 +38,7 @@ enum BattlegroundSounds SOUND_HORDE_WINS = 8454, SOUND_ALLIANCE_WINS = 8455, SOUND_BG_START = 3439, - SOUND_BG_START_L70ETC = 11803, + SOUND_BG_START_L70ETC = 11803 }; enum BattlegroundQuests @@ -79,7 +79,7 @@ enum BattlegroundMarksCount enum BattlegroundCreatures { BG_CREATURE_ENTRY_A_SPIRITGUIDE = 13116, // alliance - BG_CREATURE_ENTRY_H_SPIRITGUIDE = 13117, // horde + BG_CREATURE_ENTRY_H_SPIRITGUIDE = 13117 // horde }; enum BattlegroundSpells @@ -99,7 +99,7 @@ enum BattlegroundSpells SPELL_AURA_PLAYER_INACTIVE = 43681, // Inactive SPELL_HONORABLE_DEFENDER_25Y = 68652, // +50% honor when standing at a capture point that you control, 25yards radius (added in 3.2) SPELL_HONORABLE_DEFENDER_60Y = 66157, // +50% honor when standing at a capture point that you control, 60yards radius (added in 3.2), probably for 40+ player battlegrounds - SPELL_THE_LAST_STANDING = 26549, // Arena achievement related + SPELL_THE_LAST_STANDING = 26549 // Arena achievement related }; enum BattlegroundTimeIntervals @@ -112,7 +112,7 @@ enum BattlegroundTimeIntervals MAX_OFFLINE_TIME = 300, // secs RESPAWN_ONE_DAY = 86400, // secs RESPAWN_IMMEDIATELY = 0, // secs - BUFF_RESPAWN_TIME = 180, // secs + BUFF_RESPAWN_TIME = 180 // secs }; enum BattlegroundStartTimeIntervals @@ -121,7 +121,7 @@ enum BattlegroundStartTimeIntervals BG_START_DELAY_1M = 60000, // ms (1 minute) BG_START_DELAY_30S = 30000, // ms (30 seconds) BG_START_DELAY_15S = 15000, // ms (15 seconds) Used only in arena - BG_START_DELAY_NONE = 0, // ms + BG_START_DELAY_NONE = 0 // ms }; enum BattlegroundBuffObjects @@ -137,8 +137,8 @@ enum BattlegroundRandomRewards BG_REWARD_WINNER_ARENA_FIRST = 25, BG_REWARD_WINNER_HONOR_LAST = 15, BG_REWARD_WINNER_ARENA_LAST = 0, - BG_REWARD_LOSER_HONOR_FIRST = 5, - BG_REWARD_LOSER_HONOR_LAST = 5 + BG_REWARD_LOSER_HONOR_FIRST = 5, + BG_REWARD_LOSER_HONOR_LAST = 5 }; const uint32 Buff_Entries[3] = { BG_OBJECTID_SPEEDBUFF_ENTRY, BG_OBJECTID_REGENBUFF_ENTRY, BG_OBJECTID_BERSERKERBUFF_ENTRY }; @@ -209,7 +209,7 @@ enum ScoreType SCORE_SECONDARY_OBJECTIVES = 17, //SOTA SCORE_DESTROYED_DEMOLISHER = 18, - SCORE_DESTROYED_WALL = 19, + SCORE_DESTROYED_WALL = 19 }; enum ArenaType @@ -275,7 +275,7 @@ enum GroupJoinBattlegroundResult ERR_BATTLEGROUND_JOIN_FAILED = -12, // Join as a group failed (uint64 guid doesn't exist in client cache) ERR_LFG_CANT_USE_BATTLEGROUND = -13, // You cannot queue for a battleground or arena while using the dungeon system. ERR_IN_RANDOM_BG = -14, // Can't do that while in a Random Battleground queue. - ERR_IN_NON_RANDOM_BG = -15, // Can't queue for Random Battleground while in another Battleground queue. + ERR_IN_NON_RANDOM_BG = -15 // Can't queue for Random Battleground while in another Battleground queue. }; class BattlegroundScore diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 8b2543f20ff..9ebaf481098 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -371,9 +371,10 @@ void BattlegroundAB::_NodeOccupied(uint8 node, Team team) if (node >= BG_AB_DYNAMIC_NODES_COUNT)//only dynamic nodes, no start points return; - Creature* trigger = GetBGCreature(node+7);//0-6 spirit guides + + Creature* trigger = BgCreatures[node+7] ? GetBGCreature(node+7) : NULL;//0-6 spirit guides if (!trigger) - trigger = AddCreature(WORLD_TRIGGER, node+7, team, BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1], BG_AB_NodePositions[node][2], BG_AB_NodePositions[node][3]); + trigger = AddCreature(WORLD_TRIGGER, node+7, team, BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1], BG_AB_NodePositions[node][2], BG_AB_NodePositions[node][3]); //add bonus honor aura trigger creature when node is accupied //cast bonus aura (+50% honor in 25yards) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index 2cac5df73a9..870b3965522 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -102,7 +102,7 @@ enum BG_AB_ObjectType BG_AB_OBJECT_SPEEDBUFF_GOLD_MINE = 54, BG_AB_OBJECT_REGENBUFF_GOLD_MINE = 55, BG_AB_OBJECT_BERSERKBUFF_GOLD_MINE = 56, - BG_AB_OBJECT_MAX = 57, + BG_AB_OBJECT_MAX = 57 }; /* Object id templates from DB */ @@ -123,7 +123,7 @@ enum BG_AB_ObjectTypes enum BG_AB_Timers { - BG_AB_FLAG_CAPTURING_TIME = 60000, + BG_AB_FLAG_CAPTURING_TIME = 60000 }; enum BG_AB_Score @@ -146,7 +146,7 @@ enum BG_AB_BattlegroundNodes BG_AB_SPIRIT_ALIANCE = 5, BG_AB_SPIRIT_HORDE = 6, - BG_AB_ALL_NODES_COUNT = 7, // all nodes (dynamic and static) + BG_AB_ALL_NODES_COUNT = 7 // all nodes (dynamic and static) }; enum BG_AB_NodeStatus diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index f073b69a779..b71b3476fcc 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -95,7 +95,7 @@ horde: AV_SOUND_BOTH_TOWER_DEFEND = 8192, AV_SOUND_ALLIANCE_CAPTAIN = 8232, //gets called when someone attacks them and at the beginning after 3min+rand(x)*10sec (maybe buff) - AV_SOUND_HORDE_CAPTAIN = 8333, + AV_SOUND_HORDE_CAPTAIN = 8333 }; @@ -1359,7 +1359,7 @@ enum BG_AV_WorldStates //Neutral //Snowfall Grave */ - AV_SNOWFALL_N = 1966, //over aa + AV_SNOWFALL_N = 1966 //over aa /* AV_SNOWFALL_A_C = 1341, //over hc AV_SNOWFALL_A_A = 1343, //over ha diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index aaf08ba1313..d9e60079bf6 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -52,14 +52,14 @@ enum BattlegroundDSCreatureTypes enum BattlegroundDSCreatures { - BG_DS_NPC_TYPE_WATER_SPOUT = 28567, + BG_DS_NPC_TYPE_WATER_SPOUT = 28567 }; enum BattlegroundDSSpells { BG_DS_SPELL_FLUSH = 57405, // Visual and target selector for the starting knockback from the pipe BG_DS_SPELL_FLUSH_KNOCKBACK = 61698, // Knockback effect for previous spell (triggered, not need to be casted) - BG_DS_SPELL_WATER_SPOUT = 58873, // Knockback effect of the central waterfall + BG_DS_SPELL_WATER_SPOUT = 58873 // Knockback effect of the central waterfall }; enum BattlegroundDSData @@ -76,7 +76,7 @@ enum BattlegroundDSData BG_DS_WATERFALL_STATUS_WARNING = 1, // Water starting to fall, but no LoS Blocking nor movement blocking BG_DS_WATERFALL_STATUS_ON = 2, // LoS and Movement blocking active - BG_DS_WATERFALL_STATUS_OFF = 3, + BG_DS_WATERFALL_STATUS_OFF = 3 }; class BattlegroundDSScore : public BattlegroundScore diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 534a40484ce..c7ee4c62504 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -26,7 +26,7 @@ class Battleground; enum BG_EY_Misc { BG_EY_FLAG_RESPAWN_TIME = (8*IN_MILLISECONDS), - BG_EY_FPOINTS_TICK_TIME = (2*IN_MILLISECONDS), + BG_EY_FPOINTS_TICK_TIME = (2*IN_MILLISECONDS) }; enum BG_EY_WorldStates diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 90f39a61e12..20f44acc14f 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -178,7 +178,7 @@ enum gameobjectsIC GO_HORDE_BANNER_GRAVEYARD_H_CONT = 195394, GO_HORDE_GUNSHIP = 195276, - GO_ALLIANCE_GUNSHIP = 195121, + GO_ALLIANCE_GUNSHIP = 195121 }; #define MAX_REINFORCEMENTS 300 @@ -336,7 +336,7 @@ enum BG_IC_GOs BG_IC_GO_TELEPORTER_EFFECTS_H_3, BG_IC_GO_TELEPORTER_EFFECTS_H_4, BG_IC_GO_TELEPORTER_EFFECTS_H_5, - BG_IC_GO_TELEPORTER_EFFECTS_H_6, + BG_IC_GO_TELEPORTER_EFFECTS_H_6 }; enum BG_IC_NPCs @@ -411,7 +411,7 @@ enum BG_IC_NPCs BG_IC_NPC_SPIRIT_GUIDE_4, BG_IC_NPC_SPIRIT_GUIDE_5, BG_IC_NPC_SPIRIT_GUIDE_6, - BG_IC_NPC_SPIRIT_GUIDE_7, + BG_IC_NPC_SPIRIT_GUIDE_7 }; enum BannersTypes @@ -751,7 +751,7 @@ enum ICDoorList BG_IC_A_FRONT, BG_IC_A_WEST, BG_IC_A_EAST, - BG_IC_MAXDOOR, + BG_IC_MAXDOOR }; enum ICNodePointType diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h index 8c5746931e3..d8ac082ec19 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h @@ -46,7 +46,7 @@ enum BattlegroundRVObjectTypes BG_RV_OBJECT_ELEVATOR_1, BG_RV_OBJECT_ELEVATOR_2, - BG_RV_OBJECT_MAX, + BG_RV_OBJECT_MAX }; enum BattlegroundRVObjects @@ -73,7 +73,7 @@ enum BattlegroundRVObjects BG_RV_OBJECT_TYPE_PILAR_1 = 194583, // axe BG_RV_OBJECT_TYPE_PILAR_2 = 194584, // arena BG_RV_OBJECT_TYPE_PILAR_3 = 194585, // lightning - BG_RV_OBJECT_TYPE_PILAR_4 = 194587, // ivory + BG_RV_OBJECT_TYPE_PILAR_4 = 194587 // ivory }; enum BattlegroundRVData @@ -88,7 +88,7 @@ enum BattlegroundRVData BG_RV_FIRST_TIMER = 20133, BG_RV_WORLD_STATE_A = 0xe10, BG_RV_WORLD_STATE_H = 0xe11, - BG_RV_WORLD_STATE = 0xe1a, + BG_RV_WORLD_STATE = 0xe1a }; class BattlegroundRVScore : public BattlegroundScore diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index fd11cb2c5ea..78653a993a0 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -104,7 +104,7 @@ enum BG_SA_WorldStates BG_SA_LEFT_GY_HORDE = 3633, BG_SA_CENTER_GY_HORDE = 3634, BG_SA_BONUS_TIMER = 0xdf3, - BG_SA_ENABLE_TIMER = 3564, + BG_SA_ENABLE_TIMER = 3564 }; enum npc @@ -112,7 +112,7 @@ enum npc NPC_ANTI_PERSONNAL_CANNON = 27894, NPC_DEMOLISHER_SA = 28781, NPC_RIGGER_SPARKLIGHT = 29260, - NPC_GORGRIL_RIGSPARK = 29262, + NPC_GORGRIL_RIGSPARK = 29262 }; enum BG_SA_NPCs @@ -146,7 +146,7 @@ enum BG_SA_Boat BG_SA_BOAT_ONE_A = 193182, BG_SA_BOAT_TWO_H = 193183, BG_SA_BOAT_ONE_H = 193184, - BG_SA_BOAT_TWO_A = 193185, + BG_SA_BOAT_TWO_A = 193185 }; uint32 const BG_SA_NpcEntries[BG_SA_MAXNPC] = diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 8df6f93a082..e4803af8a21 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -731,7 +731,6 @@ void BattlegroundWS::Reset() _bothFlagsKept = false; _flagDebuffState = 0; _flagSpellForceTimer = 0; - _lastFlagCaptureTeam = 0; _flagsDropTimer[BG_TEAM_ALLIANCE] = 0; _flagsDropTimer[BG_TEAM_HORDE] = 0; _flagsTimer[BG_TEAM_ALLIANCE] = 0; diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index 9564dbb381e..04bb4ae2916 100755 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -68,7 +68,7 @@ enum ChatNotify CHAT_NOT_IN_AREA_NOTICE = 0x20, //+ "[%s] You are not in the correct area for this channel."; -- The user is trying to send a chat to a zone specific channel, and they're not physically in that zone. CHAT_NOT_IN_LFG_NOTICE = 0x21, //+ "[%s] You must be queued in looking for group before joining this channel."; -- The user must be in the looking for group system to join LFG chat channels. CHAT_VOICE_ON_NOTICE = 0x22, //+ "[%s] Channel voice enabled by %s."; - CHAT_VOICE_OFF_NOTICE = 0x23, //+ "[%s] Channel voice disabled by %s."; + CHAT_VOICE_OFF_NOTICE = 0x23 //+ "[%s] Channel voice disabled by %s."; }; enum ChannelFlags @@ -101,7 +101,7 @@ enum ChannelDBCFlags CHANNEL_DBC_FLAG_DEFENSE = 0x10000, // LocalDefense, WorldDefense CHANNEL_DBC_FLAG_GUILD_REQ = 0x20000, // GuildRecruitment CHANNEL_DBC_FLAG_LFG = 0x40000, // LFG - CHANNEL_DBC_FLAG_UNK1 = 0x80000, // General + CHANNEL_DBC_FLAG_UNK1 = 0x80000 // General }; enum ChannelMemberFlags @@ -112,7 +112,7 @@ enum ChannelMemberFlags MEMBER_FLAG_VOICED = 0x04, MEMBER_FLAG_MUTED = 0x08, MEMBER_FLAG_CUSTOM = 0x10, - MEMBER_FLAG_MIC_MUTED = 0x20, + MEMBER_FLAG_MIC_MUTED = 0x20 // 0x40 // 0x80 }; diff --git a/src/server/game/Combat/UnitEvents.h b/src/server/game/Combat/UnitEvents.h index 07d8b20af52..8d57ef6c59c 100755 --- a/src/server/game/Combat/UnitEvents.h +++ b/src/server/game/Combat/UnitEvents.h @@ -49,7 +49,7 @@ enum UNIT_EVENT_TYPE UEV_THREAT_SET_NEXT_TARGET = 1<<5, // A new victim (target) was set. Could be NULL - UEV_THREAT_VICTIM_CHANGED = 1<<6, + UEV_THREAT_VICTIM_CHANGED = 1<<6 // Future use //UEV_UNIT_KILLED = 1<<7, diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index e24547f1a31..ddf450d2d56 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -279,6 +279,11 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) condMeets = player->HasTitle(ConditionValue1); break; } + case CONDITION_SPAWNMASK: + { + condMeets = ((1 << object->GetMap()->GetSpawnMode()) & ConditionValue1); + break; + } default: condMeets = false; break; @@ -430,6 +435,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() case CONDITION_TITLE: mask |= GRID_MAP_TYPE_MASK_PLAYER; break; + case CONDITION_SPAWNMASK: + mask |= GRID_MAP_TYPE_MASK_ALL; + break; default: ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!"); break; @@ -1842,9 +1850,15 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) } break; } - case CONDITION_UNUSED_19: - sLog->outError(LOG_FILTER_SQL, "Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring"); - return false; + case CONDITION_SPAWNMASK: + { + if (cond->ConditionValue1 > SPAWNMASK_RAID_ALL) + { + sLog->outError(LOG_FILTER_SQL, "SpawnMask condition has non existing SpawnMask in value1 (%u), skipped", cond->ConditionValue1); + return false; + } + break; + } case CONDITION_UNUSED_20: sLog->outError(LOG_FILTER_SQL, "Found ConditionTypeOrReference = CONDITION_UNUSED_20 in `conditions` table - ignoring"); return false; diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 130a23a0cb0..bd72015d76f 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -49,7 +49,7 @@ enum ConditionTypes CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race CONDITION_ACHIEVEMENT = 17, // achievement_id 0 0 true if achievement is complete CONDITION_TITLE = 18, // title id 0 0 true if player has title - CONDITION_UNUSED_19 = 19, // + CONDITION_SPAWNMASK = 19, // spawnMask 0 0 true if in spawnMask CONDITION_UNUSED_20 = 20, // CONDITION_UNUSED_21 = 21, // CONDITION_MAPID = 22, // map_id 0 0 true if in map_id @@ -149,7 +149,7 @@ enum RelationType enum { - MAX_CONDITION_TARGETS = 3, + MAX_CONDITION_TARGETS = 3 }; struct ConditionSourceInfo diff --git a/src/server/game/Conditions/DisableMgr.h b/src/server/game/Conditions/DisableMgr.h index 0f9310ace3b..b1bb43315bd 100755 --- a/src/server/game/Conditions/DisableMgr.h +++ b/src/server/game/Conditions/DisableMgr.h @@ -31,7 +31,7 @@ enum DisableType DISABLE_TYPE_BATTLEGROUND = 3, DISABLE_TYPE_ACHIEVEMENT_CRITERIA = 4, DISABLE_TYPE_OUTDOORPVP = 5, - DISABLE_TYPE_VMAP = 6, + DISABLE_TYPE_VMAP = 6 }; enum SpellDisableTypes @@ -43,7 +43,7 @@ enum SpellDisableTypes SPELL_DISABLE_MAP = 0x10, SPELL_DISABLE_AREA = 0x20, MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET | - SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA), + SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA) }; enum VmapDisableTypes @@ -51,7 +51,7 @@ enum VmapDisableTypes VMAP_DISABLE_AREAFLAG = 0x1, VMAP_DISABLE_HEIGHT = 0x2, VMAP_DISABLE_LOS = 0x4, - VMAP_DISABLE_LIQUIDSTATUS = 0x8, + VMAP_DISABLE_LIQUIDSTATUS = 0x8 }; namespace DisableMgr diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index e73480cb4de..12ec7206141 100755 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -53,7 +53,7 @@ enum AchievementFaction { ACHIEVEMENT_FACTION_HORDE = 0, ACHIEVEMENT_FACTION_ALLIANCE = 1, - ACHIEVEMENT_FACTION_ANY = -1, + ACHIEVEMENT_FACTION_ANY = -1 }; enum AchievementFlags @@ -67,7 +67,7 @@ enum AchievementFlags ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, // Show as average value (value / time_in_days) depend from other flag (by def use last criteria value) ACHIEVEMENT_FLAG_BAR = 0x00000080, // Show as progress bar (value / max vale) depend from other flag (by def use last criteria value) ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100, // - ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200, // + ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200 // }; #define MAX_CRITERIA_REQUIREMENTS 2 @@ -81,7 +81,7 @@ enum AchievementCriteriaCondition ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE = 4, // only used in "Win 10 arenas without losing" ACHIEVEMENT_CRITERIA_CONDITION_NO_SPELL_HIT = 9, // requires the player not to be hit by specific spell ACHIEVEMENT_CRITERIA_CONDITION_NOT_IN_GROUP = 10, // requires the player not to be in group - ACHIEVEMENT_CRITERIA_CONDITION_UNK3 = 13, // unk + ACHIEVEMENT_CRITERIA_CONDITION_UNK3 = 13 // unk }; enum AchievementCriteriaFlags @@ -91,7 +91,7 @@ enum AchievementCriteriaFlags ACHIEVEMENT_CRITERIA_FLAG_UNK3 = 0x00000004, // BG related?? ACHIEVEMENT_CRITERIA_FLAG_UNK4 = 0x00000008, // ACHIEVEMENT_CRITERIA_FLAG_UNK5 = 0x00000010, // not used - ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER = 0x00000020, // Displays counter as money + ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER = 0x00000020 // Displays counter as money }; enum AchievementCriteriaTimedTypes @@ -103,7 +103,7 @@ enum AchievementCriteriaTimedTypes ACHIEVEMENT_TIMED_TYPE_CREATURE = 7, // Timer is started by killing creature with entry in timerStartEvent ACHIEVEMENT_TIMED_TYPE_ITEM = 9, // Timer is started by using item with entry in timerStartEvent - ACHIEVEMENT_TIMED_TYPE_MAX, + ACHIEVEMENT_TIMED_TYPE_MAX }; enum AchievementCriteriaTypes @@ -223,12 +223,12 @@ enum AchievementCriteriaTypes // 122 // 123 // 0..123 => 124 criteria types total - ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124, + ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124 }; enum AchievementCategory { - CATEGORY_CHILDRENS_WEEK = 163, + CATEGORY_CHILDRENS_WEEK = 163 }; enum AreaFlags @@ -275,7 +275,7 @@ enum Difficulty RAID_DIFFICULTY_10MAN_NORMAL = 0, RAID_DIFFICULTY_25MAN_NORMAL = 1, RAID_DIFFICULTY_10MAN_HEROIC = 2, - RAID_DIFFICULTY_25MAN_HEROIC = 3, + RAID_DIFFICULTY_25MAN_HEROIC = 3 }; #define RAID_DIFFICULTY_MASK_25MAN 1 // since 25man difficulties are 1 and 3, we can check them like that @@ -300,14 +300,14 @@ enum SpawnMask SPAWNMASK_RAID_25MAN_HEROIC = (1 << RAID_DIFFICULTY_25MAN_HEROIC), SPAWNMASK_RAID_HEROIC_ALL = (SPAWNMASK_RAID_10MAN_HEROIC | SPAWNMASK_RAID_25MAN_HEROIC), - SPAWNMASK_RAID_ALL = (SPAWNMASK_RAID_NORMAL_ALL | SPAWNMASK_RAID_HEROIC_ALL), + SPAWNMASK_RAID_ALL = (SPAWNMASK_RAID_NORMAL_ALL | SPAWNMASK_RAID_HEROIC_ALL) }; enum FactionTemplateFlags { FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats - FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT= 0x00002000, + FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT= 0x00002000 }; enum FactionMasks @@ -350,7 +350,7 @@ enum ItemEnchantmentType enum ItemLimitCategoryMode { ITEM_LIMIT_CATEGORY_MODE_HAVE = 0, // limit applied to amount items in inventory/bank - ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1, // limit applied to amount equipped items (including used gems) + ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1 // limit applied to amount equipped items (including used gems) }; enum TotemCategoryType @@ -411,7 +411,7 @@ enum SummonPropFlags SUMMON_PROP_FLAG_UNK13 = 0x00001000, // Lightwell, Jeeves, Gnomish Alarm-o-bot, Build vehicles(wintergrasp) SUMMON_PROP_FLAG_UNK14 = 0x00002000, // Guides, player follows SUMMON_PROP_FLAG_UNK15 = 0x00004000, // Force of Nature, Shadowfiend, Feral Spirit, Summon Water Elemental - SUMMON_PROP_FLAG_UNK16 = 0x00008000, // Light/Dark Bullet, Soul/Fiery Consumption, Twisted Visage, Twilight Whelp. Phase related? + SUMMON_PROP_FLAG_UNK16 = 0x00008000 // Light/Dark Bullet, Soul/Fiery Consumption, Twisted Visage, Twilight Whelp. Phase related? }; enum VehicleSeatFlags @@ -436,7 +436,7 @@ enum VehicleSeatFlags VEHICLE_SEAT_FLAG_HAS_START_WARITING_FOR_VEH_TRANSITION_ANIM_EXIT = 0x10000000, VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI VEHICLE_SEAT_FLAG_UNK2 = 0x40000000, // checked in conjunction with 0x800 in CastSpell2 - VEHICLE_SEAT_FLAG_ALLOWS_INTERACTION = 0x80000000, + VEHICLE_SEAT_FLAG_ALLOWS_INTERACTION = 0x80000000 }; enum VehicleSeatFlagsB @@ -449,7 +449,7 @@ enum VehicleSeatFlagsB VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100, VEHICLE_SEAT_FLAG_B_USABLE_FORCED_4 = 0x02000000, VEHICLE_SEAT_FLAG_B_CAN_SWITCH = 0x04000000, - VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000, // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000 + VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000 // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000 }; #endif diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index fdec06f6f48..ef949f43f49 100755 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -1092,7 +1092,7 @@ struct ItemEntry uint32 ID; // 0 uint32 Class; // 1 uint32 SubClass; // 2 some items have strange subclasses - int32 Unk0; // 3 + int32 SoundOverrideSubclass; // 3 int32 Material; // 4 uint32 DisplayId; // 5 uint32 InventoryType; // 6 diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index f21818deb64..e341b21706f 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -29,7 +29,7 @@ class Player; enum LFGenum { - LFG_TIME_ROLECHECK = 2*MINUTE, + LFG_TIME_ROLECHECK = 40*IN_MILLISECONDS, LFG_TIME_BOOT = 2*MINUTE, LFG_TIME_PROPOSAL = 2*MINUTE, LFG_TANKS_NEEDED = 1, diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index afa4b62d8b0..b92c3048b45 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2231,6 +2231,38 @@ bool Creature::HasSpellCooldown(uint32 spell_id) const return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id); } +void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +{ + time_t curTime = time(NULL); + for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) + { + if (m_spells[i] == 0) + continue; + + uint32 unSpellId = m_spells[i]; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId); + if (!spellInfo) + { + ASSERT(spellInfo); + continue; + } + + // Not send cooldown for this spells + if (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE) + continue; + + if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE) + continue; + + if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs) + { + _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); + if (UnitAI* ai = GetAI()) + ai->SpellInterrupted(unSpellId, unTimeMs); + } + } +} + bool Creature::HasSpell(uint32 spellID) const { uint8 i; @@ -2448,7 +2480,7 @@ void Creature::SetPosition(float x, float y, float z, float o) GetMap()->CreatureRelocation(ToCreature(), x, y, z, o); if (IsVehicle()) - GetVehicleKit()->RelocatePassengers(x, y, z, o); + GetVehicleKit()->RelocatePassengers(); } bool Creature::IsDungeonBoss() const diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 4dd080f8b15..abab3738ff7 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -54,7 +54,7 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_NO_SKILLGAIN = 0x00040000, // creature won't increase weapon skills CREATURE_FLAG_EXTRA_TAUNT_DIMINISH = 0x00080000, // Taunt is a subject to diminishing returns on this creautre CREATURE_FLAG_EXTRA_ALL_DIMINISH = 0x00100000, // Creature is subject to all diminishing returns as player are - CREATURE_FLAG_EXTRA_DUNGEON_BOSS = 0x10000000, // creature is a dungeon boss (SET DYNAMICALLY, DO NOT ADD IN DB) + CREATURE_FLAG_EXTRA_DUNGEON_BOSS = 0x10000000 // creature is a dungeon boss (SET DYNAMICALLY, DO NOT ADD IN DB) }; #define CREATURE_FLAG_EXTRA_DB_ALLOWED (CREATURE_FLAG_EXTRA_INSTANCE_BIND | CREATURE_FLAG_EXTRA_CIVILIAN | \ @@ -412,15 +412,15 @@ typedef std::map<uint32, time_t> CreatureSpellCooldowns; enum CreatureCellMoveState { - CREATURE_CELL_MOVE_NONE, //not in move list - CREATURE_CELL_MOVE_ACTIVE, //in move list - CREATURE_CELL_MOVE_INACTIVE, //in move list but should not move + CREATURE_CELL_MOVE_NONE, // not in move list + CREATURE_CELL_MOVE_ACTIVE, // in move list + CREATURE_CELL_MOVE_INACTIVE // in move list but should not move }; class MapCreature { - friend class Map; //map for moving creatures - friend class ObjectGridLoader; //grid loader for loading creatures + friend class Map; // map for moving creatures + friend class ObjectGridLoader; // grid loader for loading creatures protected: MapCreature() : _moveState(CREATURE_CELL_MOVE_NONE) {} @@ -540,6 +540,13 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature void AddCreatureSpellCooldown(uint32 spellid); bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; + uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const + { + CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId); + time_t t = time(NULL); + return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0); + } + virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); bool HasSpell(uint32 spellID) const; diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index 7e68f6acd38..68da99ac668 100755 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -29,7 +29,7 @@ enum DynamicObjectType { DYNAMIC_OBJECT_PORTAL = 0x0, // unused DYNAMIC_OBJECT_AREA_SPELL = 0x1, - DYNAMIC_OBJECT_FARSIGHT_FOCUS = 0x2, + DYNAMIC_OBJECT_FARSIGHT_FOCUS = 0x2 }; class DynamicObject : public WorldObject, public GridObject<DynamicObject> diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 751107ac011..c28ff21bfa5 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -133,13 +133,13 @@ void GameObject::AddToWorld() m_zoneScript->OnGameObjectCreate(this); sObjectAccessor->AddObject(this); - bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false); + // The state can be changed after GameObject::Create but before GameObject::AddToWorld - bool toggledState = GetGOData() ? GetGOData()->go_state != GO_STATE_READY : false; + bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : GetGoState() == GO_STATE_READY; if (m_model) GetMap()->InsertGameObjectModel(*m_model); - EnableCollision(startOpen ^ toggledState); + EnableCollision(toggledState); WorldObject::AddToWorld(); } } @@ -1707,6 +1707,11 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const float dy = y - GetPositionY(); float dz = z - GetPositionZ(); float dist = sqrt(dx*dx + dy*dy); + //! Check if the distance between the 2 objects is 0, can happen if both objects are on the same position. + //! The code below this check wont crash if dist is 0 because 0/0 in float operations is valid, and returns infinite + if (G3D::fuzzyEq(dist, 0.0f)) + return true; + float sinB = dx / dist; float cosB = dy / dist; dx = dist * (cosA * cosB + sinA * sinB); @@ -1926,17 +1931,12 @@ void GameObject::SetLootState(LootState state, Unit* unit) sScriptMgr->OnGameObjectLootStateChanged(this, state, unit); if (m_model) { - // startOpen determines whether we are going to add or remove the LoS on activation - bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false); - + bool collision = false; // Use the current go state - if (GetGoState() != GO_STATE_READY) - startOpen = !startOpen; + if ((GetGoState() != GO_STATE_READY && (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)) || state == GO_READY) + collision = !collision; - if (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED) - EnableCollision(startOpen); - else if (state == GO_READY) - EnableCollision(!startOpen); + EnableCollision(collision); } } @@ -1950,12 +1950,11 @@ void GameObject::SetGoState(GOState state) return; // startOpen determines whether we are going to add or remove the LoS on activation - bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false); - - if (state != GO_STATE_READY) - startOpen = !startOpen; + bool collision = false; + if (state == GO_STATE_READY) + collision = !collision; - EnableCollision(startOpen); + EnableCollision(collision); } } @@ -1968,7 +1967,8 @@ void GameObject::SetDisplayId(uint32 displayid) void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update) { WorldObject::SetPhaseMask(newPhaseMask, update); - EnableCollision(true); + if (m_model && m_model->isEnabled()) + EnableCollision(true); } void GameObject::EnableCollision(bool enable) diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h index 5088a30157c..f2f41d6a8b9 100755 --- a/src/server/game/Entities/Item/ItemPrototype.h +++ b/src/server/game/Entities/Item/ItemPrototype.h @@ -181,7 +181,7 @@ enum ItemFieldFlags ITEM_FLAG_UNK25 = 0x40000000, // ? ITEM_FLAG_UNK26 = 0x80000000, // ? - ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14, + ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14 }; enum ItemFlagsExtra @@ -196,7 +196,7 @@ enum ItemFlagsCustom { ITEM_FLAGS_CU_DURATION_REAL_TIME = 0x0001, // Item duration will tick even if player is offline ITEM_FLAGS_CU_IGNORE_QUEST_STATUS = 0x0002, // No quest status will be checked when this item drops - ITEM_FLAGS_CU_FOLLOW_LOOT_RULES = 0x0004, // Item will always follow group/master/need before greed looting rules + ITEM_FLAGS_CU_FOLLOW_LOOT_RULES = 0x0004 // Item will always follow group/master/need before greed looting rules }; enum BAG_FAMILY_MASK @@ -588,7 +588,7 @@ struct ItemTemplate uint32 ItemId; uint32 Class; // id from ItemClass.dbc uint32 SubClass; // id from ItemSubClass.dbc - int32 Unk0; + int32 SoundOverrideSubclass; // < 0: id from ItemSubClass.dbc, used to override weapon sound from actual SubClass std::string Name1; uint32 DisplayInfoID; // id from ItemDisplayInfo.dbc uint32 Quality; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index fe5d32b9b95..cbdae9de0bf 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2537,6 +2537,15 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const return go; } +GameObject* WorldObject::FindNearestGameObjectOfType(GameobjectTypes type, float range) const +{ + GameObject* go = NULL; + Trinity::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range); + Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectTypeInObjectRangeCheck> searcher(this, go, checker); + VisitNearbyGridObject(range, searcher); + return go; +} + void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const { CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY())); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index ab9ea2daea9..410903f6619 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -799,6 +799,7 @@ class WorldObject : public Object, public WorldLocation Creature* FindNearestCreature(uint32 entry, float range, bool alive = true) const; GameObject* FindNearestGameObject(uint32 entry, float range) const; + GameObject* FindNearestGameObjectOfType(GameobjectTypes type, float range) const; void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const; void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const; diff --git a/src/server/game/Entities/Object/ObjectDefines.h b/src/server/game/Entities/Object/ObjectDefines.h index c227d081d8b..a3c8901880f 100755 --- a/src/server/game/Entities/Object/ObjectDefines.h +++ b/src/server/game/Entities/Object/ObjectDefines.h @@ -44,7 +44,7 @@ enum HighGuid HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100 HIGHGUID_CORPSE = 0xF101, // blizz F100 HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT) - HIGHGUID_GROUP = 0x1F50, + HIGHGUID_GROUP = 0x1F50 }; #define IS_EMPTY_GUID(Guid) (Guid == 0) diff --git a/src/server/game/Entities/Object/Updates/UpdateFieldFlags.h b/src/server/game/Entities/Object/Updates/UpdateFieldFlags.h index 71b3f0cd4aa..2cd303d5fc5 100644 --- a/src/server/game/Entities/Object/Updates/UpdateFieldFlags.h +++ b/src/server/game/Entities/Object/Updates/UpdateFieldFlags.h @@ -32,7 +32,7 @@ enum UpdatefieldFlags UF_FLAG_SPECIAL_INFO = 0x020, UF_FLAG_PARTY_MEMBER = 0x040, UF_FLAG_UNUSED2 = 0x080, - UF_FLAG_DYNAMIC = 0x100, + UF_FLAG_DYNAMIC = 0x100 }; extern uint32 ItemUpdateFieldFlags[CONTAINER_END]; diff --git a/src/server/game/Entities/Object/Updates/UpdateFields.h b/src/server/game/Entities/Object/Updates/UpdateFields.h index 825bda98ae6..2190fee19d9 100755 --- a/src/server/game/Entities/Object/Updates/UpdateFields.h +++ b/src/server/game/Entities/Object/Updates/UpdateFields.h @@ -28,7 +28,7 @@ enum EObjectFields OBJECT_FIELD_ENTRY = 0x0003, // Size: 1, Type: INT, Flags: PUBLIC OBJECT_FIELD_SCALE_X = 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC OBJECT_FIELD_PADDING = 0x0005, // Size: 1, Type: INT, Flags: NONE - OBJECT_END = 0x0006, + OBJECT_END = 0x0006 }; enum EItemFields @@ -71,7 +71,7 @@ enum EItemFields ITEM_FIELD_MAXDURABILITY = OBJECT_END + 0x0037, // Size: 1, Type: INT, Flags: OWNER, ITEM_OWNER ITEM_FIELD_CREATE_PLAYED_TIME = OBJECT_END + 0x0038, // Size: 1, Type: INT, Flags: PUBLIC ITEM_FIELD_PAD = OBJECT_END + 0x0039, // Size: 1, Type: INT, Flags: NONE - ITEM_END = OBJECT_END + 0x003A, + ITEM_END = OBJECT_END + 0x003A }; enum EContainerFields @@ -79,7 +79,7 @@ enum EContainerFields CONTAINER_FIELD_NUM_SLOTS = ITEM_END + 0x0000, // Size: 1, Type: INT, Flags: PUBLIC CONTAINER_ALIGN_PAD = ITEM_END + 0x0001, // Size: 1, Type: BYTES, Flags: NONE CONTAINER_FIELD_SLOT_1 = ITEM_END + 0x0002, // Size: 72, Type: LONG, Flags: PUBLIC - CONTAINER_END = ITEM_END + 0x004A, + CONTAINER_END = ITEM_END + 0x004A }; enum EUnitFields @@ -390,7 +390,7 @@ enum EUnitFields PLAYER_FIELD_GLYPHS_1 = UNIT_END + 0x0492, // Size: 6, Type: INT, Flags: PRIVATE PLAYER_GLYPHS_ENABLED = UNIT_END + 0x0498, // Size: 1, Type: INT, Flags: PRIVATE PLAYER_PET_SPELL_POWER = UNIT_END + 0x0499, // Size: 1, Type: INT, Flags: PRIVATE - PLAYER_END = UNIT_END + 0x049A, + PLAYER_END = UNIT_END + 0x049A }; enum EGameObjectFields @@ -403,7 +403,7 @@ enum EGameObjectFields GAMEOBJECT_FACTION = OBJECT_END + 0x0009, // Size: 1, Type: INT, Flags: PUBLIC GAMEOBJECT_LEVEL = OBJECT_END + 0x000A, // Size: 1, Type: INT, Flags: PUBLIC GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B, // Size: 1, Type: BYTES, Flags: PUBLIC - GAMEOBJECT_END = OBJECT_END + 0x000C, + GAMEOBJECT_END = OBJECT_END + 0x000C }; enum EDynamicObjectFields @@ -413,7 +413,7 @@ enum EDynamicObjectFields DYNAMICOBJECT_SPELLID = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC DYNAMICOBJECT_RADIUS = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC DYNAMICOBJECT_CASTTIME = OBJECT_END + 0x0005, // Size: 1, Type: INT, Flags: PUBLIC - DYNAMICOBJECT_END = OBJECT_END + 0x0006, + DYNAMICOBJECT_END = OBJECT_END + 0x0006 }; enum ECorpseFields @@ -428,6 +428,6 @@ enum ECorpseFields CORPSE_FIELD_FLAGS = OBJECT_END + 0x001B, // Size: 1, Type: INT, Flags: PUBLIC CORPSE_FIELD_DYNAMIC_FLAGS = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: DYNAMIC CORPSE_FIELD_PAD = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: NONE - CORPSE_END = OBJECT_END + 0x001E, + CORPSE_END = OBJECT_END + 0x001E }; #endif diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 17b214857db..ead018ac620 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -2033,3 +2033,40 @@ void Pet::SynchronizeLevelWithOwner() break; } } + +void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +{ + WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); + data << uint64(GetGUID()); + data << uint8(0x0); // flags (0x1, 0x2) + time_t curTime = time(NULL); + for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + { + if (itr->second.state == PETSPELL_REMOVED) + continue; + uint32 unSpellId = itr->first; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId); + if (!spellInfo) + { + ASSERT(spellInfo); + continue; + } + + // Not send cooldown for this spells + if (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE) + continue; + + if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE) + continue; + + if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs) + { + data << uint32(unSpellId); + data << uint32(unTimeMs); // in m.secs + _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); + } + } + + if (Player* owner = GetOwner()) + owner->GetSession()->SendPacket(&data); +}
\ No newline at end of file diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 3475817816d..6e080263862 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -27,7 +27,7 @@ enum PetType { SUMMON_PET = 0, HUNTER_PET = 1, - MAX_PET_TYPE = 4, + MAX_PET_TYPE = 4 }; #define MAX_PET_STABLES 4 @@ -61,7 +61,7 @@ enum PetSpellType { PETSPELL_NORMAL = 0, PETSPELL_FAMILY = 1, - PETSPELL_TALENT = 2, + PETSPELL_TALENT = 2 }; struct PetSpell @@ -200,6 +200,7 @@ class Pet : public Guardian bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); void CleanupActionBar(); + virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); PetSpellMap m_spells; AutoSpellList m_autospells; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 65f6588f80e..a2eb4385587 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7913,6 +7913,9 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -val, apply); m_spellPenetrationItemMod += apply ? val : -val; break; + case ITEM_MOD_BLOCK_VALUE: + HandleBaseModValue(SHIELD_BLOCK_VALUE, FLAT_MOD, float(val), apply); + break; // deprecated item mods case ITEM_MOD_SPELL_HEALING_DONE: case ITEM_MOD_SPELL_DAMAGE_DONE: @@ -11528,7 +11531,11 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool if (eslot == EQUIPMENT_SLOT_OFFHAND) { - if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND) + // Do not allow polearm to be equipped in the offhand (rare case for the only 1h polearm 41750) + if (type == INVTYPE_WEAPON && pProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM) + return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT; + + else if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND) { if (!CanDualWield()) return EQUIP_ERR_CANT_DUAL_WIELD; @@ -14723,13 +14730,14 @@ bool Player::CanSeeStartQuest(Quest const* quest) bool Player::CanTakeQuest(Quest const* quest, bool msg) { - return SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg) + return !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) + && SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg) && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) && SatisfyQuestPreviousQuest(quest, msg) && SatisfyQuestTimed(quest, msg) && SatisfyQuestNextChain(quest, msg) && SatisfyQuestPrevChain(quest, msg) && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) - && SatisfyQuestSeasonal(quest,msg) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) + && SatisfyQuestSeasonal(quest,msg) && SatisfyQuestConditions(quest, msg); } @@ -22090,7 +22098,7 @@ void Player::SendInitialPacketsBeforeAddToMap() SendEquipmentSetList(); data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4); - data << uint32(secsToTimeBitFields(sWorld->GetGameTime())); + data.AppendPackedTime(sWorld->GetGameTime()); data << float(0.01666667f); // game speed data << uint32(0); // added in 3.1.2 GetSession()->SendPacket(&data); @@ -24502,11 +24510,11 @@ bool Player::canSeeSpellClickOn(Creature const* c) const ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(c->GetEntry(), itr->second.spellId); ConditionSourceInfo info = ConditionSourceInfo(const_cast<Player*>(this), const_cast<Creature*>(c)); - if (!sConditionMgr->IsObjectMeetToConditions(info, conds)) - return false; + if (sConditionMgr->IsObjectMeetToConditions(info, conds)) + return true; } - return true; + return false; } void Player::BuildPlayerTalentsInfoData(WorldPacket* data) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 71915f42784..5637b3b5af0 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -299,7 +299,7 @@ struct Areas enum RuneCooldowns { RUNE_BASE_COOLDOWN = 10000, - RUNE_MISS_COOLDOWN = 1500, // cooldown applied on runes when the spell misses + RUNE_MISS_COOLDOWN = 1500 // cooldown applied on runes when the spell misses }; enum RuneType @@ -399,7 +399,7 @@ enum PlayerFlags PLAYER_FLAGS_UNK28 = 0x10000000, PLAYER_FLAGS_UNK29 = 0x20000000, PLAYER_FLAGS_UNK30 = 0x40000000, - PLAYER_FLAGS_UNK31 = 0x80000000, + PLAYER_FLAGS_UNK31 = 0x80000000 }; // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1) @@ -672,7 +672,7 @@ enum TradeSlots TRADE_SLOT_COUNT = 7, TRADE_SLOT_TRADED_COUNT = 6, TRADE_SLOT_NONTRADED = 6, - TRADE_SLOT_INVALID = -1, + TRADE_SLOT_INVALID = -1 }; enum TransferAbortReason @@ -692,7 +692,7 @@ enum TransferAbortReason TRANSFER_ABORT_NOT_FOUND2 = 0x0D, // 3.1 TRANSFER_ABORT_NOT_FOUND3 = 0x0E, // 3.2 TRANSFER_ABORT_REALM_ONLY = 0x0F, // All players on party must be from the same realm. - TRANSFER_ABORT_MAP_NOT_ALLOWED = 0x10, // Map can't be entered at this time. + TRANSFER_ABORT_MAP_NOT_ALLOWED = 0x10 // Map can't be entered at this time. }; enum InstanceResetWarningType @@ -739,7 +739,7 @@ enum TeleportToOptions TELE_TO_NOT_LEAVE_TRANSPORT = 0x02, TELE_TO_NOT_LEAVE_COMBAT = 0x04, TELE_TO_NOT_UNSUMMON_PET = 0x08, - TELE_TO_SPELL = 0x10, + TELE_TO_SPELL = 0x10 }; /// Type of environmental damages @@ -761,7 +761,7 @@ enum PlayerChatTag CHAT_TAG_DND = 0x02, CHAT_TAG_GM = 0x04, CHAT_TAG_COM = 0x08, // Commentator - CHAT_TAG_DEV = 0x10, + CHAT_TAG_DEV = 0x10 }; enum PlayedTimeIndex @@ -807,7 +807,7 @@ enum PlayerLoginQueryIndex PLAYER_LOGIN_QUERY_LOADQUESTSTATUSREW = 29, PLAYER_LOGIN_QUERY_LOADINSTANCELOCKTIMES = 30, PLAYER_LOGIN_QUERY_LOADSEASONALQUESTSTATUS = 31, - MAX_PLAYER_LOGIN_QUERY, + MAX_PLAYER_LOGIN_QUERY }; enum PlayerDelayedOperations diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index a9a0484a4ea..d5d1bd99277 100755 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -98,6 +98,12 @@ void Totem::InitSummon() void Totem::UnSummon(uint32 msTime) { + if (msTime) + { + m_Events.AddEvent(new ForcedUnsummonDelayEvent(*this), m_Events.CalculateTime(msTime)); + return; + } + CombatStop(); RemoveAurasDueToSpell(GetSpell(), GetGUID()); diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 88d3108dbe2..558fdd72a95 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -704,17 +704,15 @@ void Transport::UpdateNPCPositions() } } -//! This method transforms supplied transport offsets into global coordinates void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o) { float inx = x, iny = y, inz = z, ino = o; o = GetOrientation() + ino; - x = GetPositionX() + (inx * cos(GetOrientation()) + iny * sin(GetOrientation() + M_PI)); - y = GetPositionY() + (iny * cos(GetOrientation()) + inx * sin(GetOrientation())); + x = GetPositionX() + inx * cos(GetOrientation()) - iny * sin(GetOrientation()); + y = GetPositionY() + iny * cos(GetOrientation()) + inx * sin(GetOrientation()); z = GetPositionZ() + inz; } -//! This method transforms supplied global coordinates into local offsets void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o) { o -= GetOrientation(); @@ -722,6 +720,6 @@ void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o) y -= GetPositionY(); // y = searchedY * cos(o) + searchedX * sin(o) x -= GetPositionX(); // x = searchedX * cos(o) + searchedY * sin(o + pi) float inx = x, iny = y; - y = (iny - inx * tan(GetOrientation())) / (cos(GetOrientation()) - sin(GetOrientation() + M_PI) * tan(GetOrientation())); - x = (inx - iny * sin(GetOrientation() + M_PI) / cos(GetOrientation())) / (cos(GetOrientation()) - tan(GetOrientation()) * sin(GetOrientation() + M_PI)); + y = (iny - inx * tan(GetOrientation())) / (cos(GetOrientation()) + sin(GetOrientation()) * tan(GetOrientation())); + x = (inx + iny * tan(GetOrientation())) / (cos(GetOrientation()) + sin(GetOrientation()) * tan(GetOrientation())); } diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index 4b0c42c9071..8fd12b50695 100755 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -20,12 +20,13 @@ #define TRANSPORTS_H #include "GameObject.h" +#include "VehicleDefines.h" #include <map> #include <set> #include <string> -class Transport : public GameObject +class Transport : public GameObject, public TransportBase { public: Transport(uint32 period, uint32 script); @@ -47,8 +48,13 @@ class Transport : public GameObject uint32 AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim=0); void UpdatePosition(MovementInfo* mi); void UpdateNPCPositions(); + + /// This method transforms supplied transport offsets into global coordinates void CalculatePassengerPosition(float& x, float& y, float& z, float& o); + + /// This method transforms supplied global coordinates into local offsets void CalculatePassengerOffset(float& x, float& y, float& z, float& o); + void BuildStartMovePacket(Map const* targetMap); void BuildStopMovePacket(Map const* targetMap); uint32 GetScriptId() const { return ScriptId; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5118b5810b6..ed3f3bf3827 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -154,12 +154,25 @@ _hitMask(hitMask), _spell(spell), _damageInfo(damageInfo), _healInfo(healInfo) #ifdef _MSC_VER #pragma warning(disable:4355) #endif -Unit::Unit(bool isWorldObject): WorldObject(isWorldObject), -m_movedPlayer(NULL), m_lastSanctuaryTime(0), IsAIEnabled(false), NeedChangeAI(false), -m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()), i_AI(NULL), -i_disabledAI(NULL), m_procDeep(0), m_removedAurasCount(0), i_motionMaster(this), -m_ThreatManager(this), m_vehicle(NULL), m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), -m_HostileRefManager(this), m_TempSpeed(0.0f), m_AutoRepeatFirstCast(false) +Unit::Unit(bool isWorldObject): WorldObject(isWorldObject) + , m_movedPlayer(NULL) + , m_lastSanctuaryTime(0) + , m_TempSpeed(0.0f) + , IsAIEnabled(false) + , NeedChangeAI(false) + , m_ControlledByPlayer(false) + , movespline(new Movement::MoveSpline()) + , i_AI(NULL) + , i_disabledAI(NULL) + , m_AutoRepeatFirstCast(false) + , m_procDeep(0) + , m_removedAurasCount(0) + , i_motionMaster(this) + , m_ThreatManager(this) + , m_vehicle(NULL) + , m_vehicleKit(NULL) + , m_unitTypeMask(UNIT_MASK_NONE) + , m_HostileRefManager(this) { #ifdef _MSC_VER #pragma warning(default:4355) @@ -254,8 +267,8 @@ m_HostileRefManager(this), m_TempSpeed(0.0f), m_AutoRepeatFirstCast(false) m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); _focusSpell = NULL; - _targetLocked = false; _lastLiquid = NULL; + _isWalkingBeforeCharm = false; } //////////////////////////////////////////////////////////// @@ -380,9 +393,7 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed) void Unit::UpdateSplineMovement(uint32 t_diff) { - enum{ - POSITION_UPDATE_DELAY = 400, - }; + uint32 const positionUpdateDelay = 400; if (movespline->Finalized()) return; @@ -396,7 +407,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff) m_movesplineTimer.Update(t_diff); if (m_movesplineTimer.Passed() || arrived) { - m_movesplineTimer.Reset(POSITION_UPDATE_DELAY); + m_movesplineTimer.Reset(positionUpdateDelay); Movement::Location loc = movespline->ComputePosition(); if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT)) @@ -406,17 +417,14 @@ void Unit::UpdateSplineMovement(uint32 t_diff) pos.m_positionY = loc.y; pos.m_positionZ = loc.z; pos.m_orientation = loc.orientation; - if (Unit* vehicle = GetVehicleBase()) - { - loc.x += vehicle->GetPositionX(); - loc.y += vehicle->GetPositionY(); - loc.z += vehicle->GetPositionZMinusOffset(); - loc.orientation = vehicle->GetOrientation(); - } - else if (Transport* trans = GetTransport()) - trans->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); + + if (TransportBase* transport = GetDirectTransport()) + transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); } + if (HasUnitState(UNIT_STATE_CANNOT_TURN)) + loc.orientation = GetOrientation(); + UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); } } @@ -542,12 +550,11 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam GetAI()->DamageDealt(victim, damage, damagetype); if (victim->GetTypeId() == TYPEID_PLAYER) + { if (victim->ToPlayer()->GetCommandStatus(CHEAT_GOD)) return 0; - // Signal to pets that their owner was attacked - if (victim->GetTypeId() == TYPEID_PLAYER) - { + // Signal to pets that their owner was attacked Pet* pet = victim->ToPlayer()->GetPet(); if (pet && pet->isAlive()) @@ -863,17 +870,24 @@ void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1); if (bp2) values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2); - CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); + CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) { CustomSpellValues values; values.AddSpellMod(mod, value); - CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); + CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } -void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +{ + CustomSpellValues values; + values.AddSpellMod(mod, value); + CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster); +} + +void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) @@ -884,7 +898,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* SpellCastTargets targets; targets.SetUnitTarget(victim); - CastSpell(targets, spellInfo, &value, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); + CastSpell(targets, spellInfo, &value, triggerFlags, castItem, triggeredByAura, originalCaster); } void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) @@ -4299,11 +4313,16 @@ uint32 Unit::GetDoTsByCaster(uint64 casterGUID) const int32 Unit::GetTotalAuraModifier(AuraType auratype) const { + std::map<SpellGroup, int32> SameEffectSpellGroup; int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) - modifier += (*i)->GetAmount(); + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup)) + modifier += (*i)->GetAmount(); + + for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr) + modifier += itr->second; return modifier; } @@ -4347,14 +4366,19 @@ int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { + std::map<SpellGroup, int32> SameEffectSpellGroup; int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); + for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) - { - if ((*i)->GetMiscValue()& misc_mask) - modifier += (*i)->GetAmount(); - } + if ((*i)->GetMiscValue() & misc_mask) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup)) + modifier += (*i)->GetAmount(); + + for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr) + modifier += itr->second; + return modifier; } @@ -6666,34 +6690,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere CastCustomSpell(target, triggered_spell_id, &basepoints0, &basepoints0, NULL, true, castItem, triggeredByAura); return true; } - // Sacred Shield - if (dummySpell->SpellFamilyFlags[1] & 0x80000) - { - if (procFlag & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS) - { - if (procSpell->SpellFamilyName == SPELLFAMILY_PALADIN && (procSpell->SpellFamilyFlags[0] & 0x40000000)) - { - basepoints0 = damage / 12; - - if (basepoints0) - CastCustomSpell(this, 66922, &basepoints0, NULL, NULL, true, 0, triggeredByAura, victim->GetGUID()); - - return true; - } - else - return false; - } - else if (damage > 0) - triggered_spell_id = 58597; - - // Item - Paladin T8 Holy 4P Bonus - if (Unit* caster = triggeredByAura->GetCaster()) - if (AuraEffect const* aurEff = caster->GetAuraEffect(64895, 0)) - cooldown = aurEff->GetAmount(); - - target = this; - break; - } // Righteous Vengeance if (dummySpell->SpellIconID == 3025) { @@ -6714,6 +6710,23 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere } switch (dummySpell->Id) { + // Sacred Shield + case 53601: + { + if (procFlag & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS) + return false; + + if (damage > 0) + triggered_spell_id = 58597; + + // Item - Paladin T8 Holy 4P Bonus + if (Unit* caster = triggeredByAura->GetCaster()) + if (AuraEffect const* aurEff = caster->GetAuraEffect(64895, 0)) + cooldown = aurEff->GetAmount(); + + target = this; + break; + } // Heart of the Crusader case 20335: // rank 1 triggered_spell_id = 21183; @@ -6727,10 +6740,13 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Judgement of Light case 20185: { - // 2% of base mana - basepoints0 = int32(victim->CountPctFromMaxHealth(2)); - victim->CastCustomSpell(victim, 20267, &basepoints0, 0, 0, true, 0, triggeredByAura); - return true; + if (!victim) + return false; + + // 2% of maximum health + basepoints0 = int32(victim->CountPctFromMaxHealth(2)); + victim->CastCustomSpell(victim, 20267, &basepoints0, 0, 0, true, 0, triggeredByAura); + return true; } // Judgement of Wisdom case 20186: @@ -9978,7 +9994,8 @@ void Unit::SetCharm(Unit* charm, bool apply) if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID()); - if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING)) + _isWalkingBeforeCharm = charm->IsWalking(); + if (_isWalkingBeforeCharm) { charm->SetWalk(false); charm->SendMovementFlagUpdate(); @@ -10016,6 +10033,12 @@ void Unit::SetCharm(Unit* charm, bool apply) charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0); } + if (charm->IsWalking() != _isWalkingBeforeCharm) + { + charm->SetWalk(_isWalkingBeforeCharm); + charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player. + } + if (charm->GetTypeId() == TYPEID_PLAYER || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) || charm->GetOwnerGUID() != GetGUID()) @@ -10290,6 +10313,10 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) return pdamage; + // Some spells don't benefit from done mods + if (spellProto->AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS) + return pdamage; + // small exception for Deep Wounds, can't find any general rule // should ignore ALL damage mods, they already calculated in trigger spell if (spellProto->Id == 12721) // Deep Wounds @@ -10691,13 +10718,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); } - // Some spells don't benefit from done mods - if (spellProto->AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS) - { - DoneTotal = 0; - DoneTotalMod = 1.0f; - } - float tmpDamage = (int32(pdamage) + DoneTotal) * DoneTotalMod; // apply spellmod to Done damage (flat and pct) if (Player* modOwner = GetSpellModOwner()) @@ -11081,9 +11101,12 @@ uint32 Unit::SpellCriticalDamageBonus(SpellInfo const* spellProto, uint32 damage crit_bonus -= damage; - // adds additional damage to crit_bonus (from talents) - if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); + if (damage > uint32(crit_bonus)) + { + // adds additional damage to critBonus (from talents) + if (Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); + } crit_bonus += damage; @@ -11248,16 +11271,6 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); } - // Gift of the Naaru - if (spellProto->SpellFamilyFlags[2] & 0x80000000 && spellProto->SpellIconID == 329) - { - int32 apBonus = int32(std::max(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAttackPowerValue(RANGED_ATTACK))); - if (apBonus > DoneAdvertisedBenefit) - DoneTotal += int32(apBonus * 0.22f); // 22% of AP per tick - else - DoneTotal += int32(DoneAdvertisedBenefit * 0.377f); // 37.7% of BH per tick - } - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { switch (spellProto->Effects[i].ApplyAuraName) @@ -12266,19 +12279,21 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo if (GetReactionTo(target) == REP_NEUTRAL && target->GetReactionTo(this) == REP_NEUTRAL) { - if ( - !(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) && - !(target->GetTypeId() == TYPEID_UNIT && GetTypeId() == TYPEID_UNIT) - ) + if (!(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) && + !(target->GetTypeId() == TYPEID_UNIT && GetTypeId() == TYPEID_UNIT)) { Player const* player = target->GetTypeId() == TYPEID_PLAYER ? target->ToPlayer() : ToPlayer(); Unit const* creature = target->GetTypeId() == TYPEID_UNIT ? target : this; if (FactionTemplateEntry const* factionTemplate = creature->getFactionTemplateEntry()) - if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction)) - if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry)) - if (!(repState->Flags & FACTION_FLAG_AT_WAR)) - return false; + { + if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate))) + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction)) + if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry)) + if (!(repState->Flags & FACTION_FLAG_AT_WAR)) + return false; + + } } } @@ -13218,13 +13233,13 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in } break; case SPELLFAMILY_PALADIN: - if (spellProto->SpellFamilyFlags[0] & 0x00000002) + if ((spellProto->SpellFamilyFlags[0] & 0x00000002) && spellProto->SpellIconID == 298) { // Glyph of Blessing of Might if (AuraEffect* aurEff = GetAuraEffect(57958, 0)) duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; } - else if (spellProto->SpellFamilyFlags[0] & 0x00010000) + else if ((spellProto->SpellFamilyFlags[0] & 0x00010000) && spellProto->SpellIconID == 306) { // Glyph of Blessing of Wisdom if (AuraEffect* aurEff = GetAuraEffect(57979, 0)) @@ -14761,11 +14776,11 @@ void Unit::StopMoving() init.Launch(); } -void Unit::SendMovementFlagUpdate() +void Unit::SendMovementFlagUpdate(bool self /* = false */) { WorldPacket data; BuildHeartBeatMsg(&data); - SendMessageToSet(&data, false); + SendMessageToSet(&data, self); } bool Unit::IsSitState() const @@ -16142,7 +16157,8 @@ void Unit::RemoveCharmedBy(Unit* charmer) if (Creature* creature = ToCreature()) { - creature->AI()->OnCharmed(false); + if (creature->AI()) + creature->AI()->OnCharmed(false); if (type != CHARM_TYPE_VEHICLE) // Vehicles' AI is never modified { @@ -16281,6 +16297,13 @@ uint64 Unit::GetTransGUID() const return 0; } +TransportBase* Unit::GetDirectTransport() const +{ + if (Vehicle* veh = GetVehicle()) + return veh; + return GetTransport(); +} + bool Unit::IsInPartyWith(Unit const* unit) const { if (this == unit) @@ -16957,19 +16980,20 @@ void Unit::JumpTo(WorldObject* obj, float speedZ) bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) { + bool result = false; uint32 spellClickEntry = GetVehicleKit() ? GetVehicleKit()->GetCreatureEntry() : GetEntry(); SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(spellClickEntry); for (SpellClickInfoContainer::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) { //! First check simple relations from clicker to clickee if (!itr->second.IsFitToRequirements(clicker, this)) - return false; + continue; //! Check database conditions ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(spellClickEntry, itr->second.spellId); ConditionSourceInfo info = ConditionSourceInfo(clicker, this); if (!sConditionMgr->IsObjectMeetToConditions(info, conds)) - return false; + continue; Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this; Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this; @@ -16995,11 +17019,11 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) if (!valid) { sLog->outError(LOG_FILTER_SQL, "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", itr->second.spellId); - return false; + continue; } if (IsInMap(caster)) - caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, false, NULL, NULL, origCasterGUID); + caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID); else // This can happen during Player::_LoadAuras { int32 bp0 = seatId; @@ -17009,22 +17033,27 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) else { if (IsInMap(caster)) - caster->CastSpell(target, spellEntry, false, NULL, NULL, origCasterGUID); + caster->CastSpell(target, spellEntry, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID); else Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, NULL, NULL, origCasterGUID); } + + result = true; } - Creature* creature = ToCreature(); - if (creature && creature->IsAIEnabled) - creature->AI()->OnSpellClick(clicker); + if (result) + { + Creature* creature = ToCreature(); + if (creature && creature->IsAIEnabled) + creature->AI()->OnSpellClick(clicker); + } - return true; + return result; } void Unit::EnterVehicle(Unit* base, int8 seatId) { - CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, false); + CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE); } void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp) @@ -17042,6 +17071,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a sLog->outDebug(LOG_FILTER_VEHICLES, "EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_vehicle->GetBase()->GetEntry(), GetTransSeat(), seatId); ChangeSeat(seatId); } + return; } else @@ -17077,6 +17107,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a ASSERT(!m_vehicle); m_vehicle = vehicle; + if (!m_vehicle->AddPassenger(this, seatId)) { m_vehicle = NULL; @@ -17129,9 +17160,11 @@ void Unit::_ExitVehicle(Position const* exitPosition) m_vehicle->RemovePassenger(this); + Player* player = ToPlayer(); + // If player is on mouted duel and exits the mount should immediatly lose the duel - if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->duel && ToPlayer()->duel->isMounted) - ToPlayer()->DuelComplete(DUEL_FLED); + if (player && player->duel && player->duel->isMounted) + player->DuelComplete(DUEL_FLED); // This should be done before dismiss, because there may be some aura removal Vehicle* vehicle = m_vehicle; @@ -17148,8 +17181,8 @@ void Unit::_ExitVehicle(Position const* exitPosition) AddUnitState(UNIT_STATE_MOVE); - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetFallInformation(0, GetPositionZ()); + if (player) + player->SetFallInformation(0, GetPositionZ()); else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT)) { WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8); @@ -17165,7 +17198,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) //GetMotionMaster()->MoveFall(); // Enable this once passenger positions are calculater properly (see above) - if (Player* player = ToPlayer()) + if (player) player->ResummonPetTemporaryUnSummonedIfAny(); if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION)) @@ -17294,7 +17327,7 @@ void Unit::UpdateOrientation(float orientation) { SetOrientation(orientation); if (IsVehicle()) - GetVehicleKit()->RelocatePassengers(GetPositionX(), GetPositionY(), GetPositionZ(), orientation); + GetVehicleKit()->RelocatePassengers(); } //! Only server-side height update, does not broadcast to client @@ -17302,7 +17335,7 @@ void Unit::UpdateHeight(float newZ) { Relocate(GetPositionX(), GetPositionY(), newZ); if (IsVehicle()) - GetVehicleKit()->RelocatePassengers(GetPositionX(), GetPositionY(), newZ, GetOrientation()); + GetVehicleKit()->RelocatePassengers(); } void Unit::SendThreatListUpdate() @@ -17700,3 +17733,31 @@ void Unit::SendMovementCanFlyChange() BuildMovementPacket(&data); SendMessageToSet(&data, false); } + +void Unit::FocusTarget(Spell const* focusSpell, uint64 target) +{ + // already focused + if (_focusSpell) + return; + + _focusSpell = focusSpell; + SetUInt64Value(UNIT_FIELD_TARGET, target); + if (focusSpell->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_DONT_TURN_DURING_CAST) + AddUnitState(UNIT_STATE_ROTATING); +} + +void Unit::ReleaseFocus(Spell const* focusSpell) +{ + // focused to something else + if (focusSpell != _focusSpell) + return; + + _focusSpell = NULL; + if (Unit* victim = getVictim()) + SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); + else + SetUInt64Value(UNIT_FIELD_TARGET, 0); + + if (focusSpell->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_DONT_TURN_DURING_CAST) + ClearUnitState(UNIT_STATE_ROTATING); +} diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 2ec3ffec8ef..8eb822831aa 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -46,7 +46,7 @@ enum SpellInterruptFlags SPELL_INTERRUPT_FLAG_PUSH_BACK = 0x02, // push back SPELL_INTERRUPT_FLAG_UNK3 = 0x04, // any info? SPELL_INTERRUPT_FLAG_INTERRUPT = 0x08, // interrupt - SPELL_INTERRUPT_FLAG_ABORT_ON_DMG = 0x10, // _complete_ interrupt on direct damage + SPELL_INTERRUPT_FLAG_ABORT_ON_DMG = 0x10 // _complete_ interrupt on direct damage //SPELL_INTERRUPT_UNK = 0x20 // unk, 564 of 727 spells having this spell start with "Glyph" }; @@ -86,7 +86,7 @@ enum SpellAuraInterruptFlags AURA_INTERRUPT_FLAG_DIRECT_DAMAGE = 0x01000000, // 24 removed by any direct damage AURA_INTERRUPT_FLAG_LANDING = 0x02000000, // 25 removed by hitting the ground - AURA_INTERRUPT_FLAG_NOT_VICTIM = (AURA_INTERRUPT_FLAG_HITBYSPELL | AURA_INTERRUPT_FLAG_TAKE_DAMAGE | AURA_INTERRUPT_FLAG_DIRECT_DAMAGE), + AURA_INTERRUPT_FLAG_NOT_VICTIM = (AURA_INTERRUPT_FLAG_HITBYSPELL | AURA_INTERRUPT_FLAG_TAKE_DAMAGE | AURA_INTERRUPT_FLAG_DIRECT_DAMAGE) }; enum SpellModOp @@ -133,7 +133,7 @@ enum SpellValueMod SPELLVALUE_BASE_POINT2, SPELLVALUE_RADIUS_MOD, SPELLVALUE_MAX_TARGETS, - SPELLVALUE_AURA_STACK, + SPELLVALUE_AURA_STACK }; typedef std::pair<SpellValueMod, int32> CustomSpellValueMod; @@ -253,7 +253,7 @@ enum UnitPVPStateFlags enum UnitRename { UNIT_CAN_BE_RENAMED = 0x01, - UNIT_CAN_BE_ABANDONED = 0x02, + UNIT_CAN_BE_ABANDONED = 0x02 }; #define CREATURE_MAX_SPELLS 8 @@ -339,6 +339,7 @@ class UnitAI; class Totem; class Transport; class Vehicle; +class TransportBase; typedef std::list<Unit*> UnitList; typedef std::list< std::pair<Aura*, uint8> > DispelChargesList; @@ -402,7 +403,7 @@ enum TriggerCastFlags TRIGGERED_IGNORE_CASTER_AURAS = 0x00010000, //! Will ignore caster aura restrictions or requirements TRIGGERED_DISALLOW_PROC_EVENTS = 0x00020000, //! Disallows proc events from triggered spell (default) TRIGGERED_DONT_REPORT_CAST_ERROR = 0x00040000, //! Will return SPELL_FAILED_DONT_REPORT in CheckCast functions - TRIGGERED_FULL_MASK = 0xFFFFFFFF, + TRIGGERED_FULL_MASK = 0xFFFFFFFF }; enum UnitMods @@ -461,11 +462,11 @@ enum BaseModType enum DeathState { - ALIVE = 0, - JUST_DIED = 1, - CORPSE = 2, - DEAD = 3, - JUST_RESPAWNED = 4, + ALIVE = 0, + JUST_DIED = 1, + CORPSE = 2, + DEAD = 3, + JUST_RESPAWNED = 4 }; enum UnitState @@ -635,7 +636,7 @@ enum UnitFlags2 UNIT_FLAG2_DISABLE_TURN = 0x00008000, UNIT_FLAG2_UNK2 = 0x00010000, UNIT_FLAG2_PLAY_DEATH_ANIM = 0x00020000, // Plays special death animation upon death - UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL + UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000 // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL }; /// Non Player Character flags @@ -667,7 +668,7 @@ enum NPCFlags UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click) - UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000, // players with mounts that have vehicle data should have it set + UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000 // players with mounts that have vehicle data should have it set }; enum MovementFlags @@ -719,7 +720,7 @@ enum MovementFlags //! TODO if needed: add more flags to this masks that are exclusive to players MOVEMENTFLAG_MASK_PLAYER_ONLY = - MOVEMENTFLAG_FLYING, + MOVEMENTFLAG_FLYING }; enum MovementFlags2 { @@ -739,7 +740,7 @@ enum MovementFlags2 MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00001000, MOVEMENTFLAG2_UNK14 = 0x00002000, MOVEMENTFLAG2_UNK15 = 0x00004000, - MOVEMENTFLAG2_UNK16 = 0x00008000, + MOVEMENTFLAG2_UNK16 = 0x00008000 }; enum UnitTypeMask @@ -754,7 +755,7 @@ enum UnitTypeMask UNIT_MASK_PUPPET = 0x00000040, UNIT_MASK_HUNTER_PET = 0x00000080, UNIT_MASK_CONTROLABLE_GUARDIAN = 0x00000100, - UNIT_MASK_ACCESSORY = 0x00000200, + UNIT_MASK_ACCESSORY = 0x00000200 }; namespace Movement{ @@ -768,7 +769,7 @@ enum DiminishingLevels DIMINISHING_LEVEL_3 = 2, DIMINISHING_LEVEL_IMMUNE = 3, DIMINISHING_LEVEL_4 = 3, - DIMINISHING_LEVEL_TAUNT_IMMUNE = 4, + DIMINISHING_LEVEL_TAUNT_IMMUNE = 4 }; struct DiminishingReturn @@ -1079,7 +1080,7 @@ enum CharmType CHARM_TYPE_CHARM, CHARM_TYPE_POSSESS, CHARM_TYPE_VEHICLE, - CHARM_TYPE_CONVERT, + CHARM_TYPE_CONVERT }; typedef UnitActionBarEntry CharmSpellInfo; @@ -1089,7 +1090,7 @@ enum ActionBarIndex ACTION_BAR_INDEX_START = 0, ACTION_BAR_INDEX_PET_SPELL_START = 3, ACTION_BAR_INDEX_PET_SPELL_END = 7, - ACTION_BAR_INDEX_END = 10, + ACTION_BAR_INDEX_END = 10 }; #define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START) @@ -1189,7 +1190,7 @@ enum PlayerTotemType SUMMON_TYPE_TOTEM_FIRE = 63, SUMMON_TYPE_TOTEM_EARTH = 81, SUMMON_TYPE_TOTEM_WATER = 82, - SUMMON_TYPE_TOTEM_AIR = 83, + SUMMON_TYPE_TOTEM_AIR = 83 }; // delay time next attack to prevent client attack animation problems @@ -1568,13 +1569,14 @@ class Unit : public WorldObject void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem= NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem= NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem= NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* Victim = NULL, bool triggered = true, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim = NULL, bool triggered = true, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); Aura* AddAura(uint32 spellId, Unit* target); Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target); void SetAuraStack(uint32 spellId, Unit* target, uint32 stack); @@ -1606,7 +1608,7 @@ class Unit : public WorldObject void MonsterMoveWithSpeed(float x, float y, float z, float speed); //void SetFacing(float ori, WorldObject* obj = NULL); //void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL); - void SendMovementFlagUpdate(); + void SendMovementFlagUpdate(bool self = false); /*! These methods send the same packet to the client in apply and unapply case. The client-side interpretation of this packet depends on the presence of relevant movementflags @@ -2168,6 +2170,8 @@ class Unit : public WorldObject uint32 GetTransTime() const { return m_movementInfo.t_time; } int8 GetTransSeat() const { return m_movementInfo.t_seat; } uint64 GetTransGUID() const; + /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) + TransportBase* GetDirectTransport() const; bool m_ControlledByPlayer; @@ -2203,34 +2207,13 @@ class Unit : public WorldObject void SetTarget(uint64 guid) { - if (!_targetLocked) + if (!_focusSpell) SetUInt64Value(UNIT_FIELD_TARGET, guid); } - void FocusTarget(Spell const* focusSpell, uint64 target) - { - // already focused - if (_focusSpell) - return; - - _focusSpell = focusSpell; - _targetLocked = true; - SetUInt64Value(UNIT_FIELD_TARGET, target); - } - - void ReleaseFocus(Spell const* focusSpell) - { - // focused to something else - if (focusSpell != _focusSpell) - return; - - _focusSpell = NULL; - _targetLocked = false; - if (Unit* victim = getVictim()) - SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); - else - SetUInt64Value(UNIT_FIELD_TARGET, 0); - } + // Handling caster facing during spellcast + void FocusTarget(Spell const* focusSpell, uint64 target); + void ReleaseFocus(Spell const* focusSpell); // Movement info Movement::MoveSpline * movespline; @@ -2354,8 +2337,8 @@ class Unit : public WorldObject bool m_cleanupDone; // lock made to not add stuff after cleanup before delete bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world - Spell const* _focusSpell; - bool _targetLocked; // locks the target during spell cast for proper facing + Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing + bool _isWalkingBeforeCharm; // Are we walking before we were charmed? }; namespace Trinity diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 710821f2f24..ef4ed1a7f81 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -437,23 +437,23 @@ void Vehicle::RemovePassenger(Unit* unit) } //! Must be called after m_base::Relocate -void Vehicle::RelocatePassengers(float x, float y, float z, float ang) +void Vehicle::RelocatePassengers() { ASSERT(_me->GetMap()); - // not sure that absolute position calculation is correct, it must depend on vehicle orientation and pitch angle + // not sure that absolute position calculation is correct, it must depend on vehicle pitch angle for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr) + { if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger)) { ASSERT(passenger->IsInWorld()); - float px = x + passenger->m_movementInfo.t_pos.m_positionX; - float py = y + passenger->m_movementInfo.t_pos.m_positionY; - float pz = z + passenger->m_movementInfo.t_pos.m_positionZ; - float po = ang + passenger->m_movementInfo.t_pos.m_orientation; - + float px, py, pz, po; + passenger->m_movementInfo.t_pos.GetPosition(px, py, pz, po); + CalculatePassengerPosition(px, py, pz, po); passenger->UpdatePosition(px, py, pz, po); } + } } void Vehicle::Dismiss() @@ -512,3 +512,23 @@ uint8 Vehicle::GetAvailableSeatCount() const return ret; } + +void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float& o) +{ + float inx = x, iny = y, inz = z, ino = o; + o = GetBase()->GetOrientation() + ino; + x = GetBase()->GetPositionX() + inx * cos(GetBase()->GetOrientation()) - iny * sin(GetBase()->GetOrientation()); + y = GetBase()->GetPositionY() + iny * cos(GetBase()->GetOrientation()) + inx * sin(GetBase()->GetOrientation()); + z = GetBase()->GetPositionZ() + inz; +} + +void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float& o) +{ + o -= GetBase()->GetOrientation(); + z -= GetBase()->GetPositionZ(); + y -= GetBase()->GetPositionY(); // y = searchedY * cos(o) + searchedX * sin(o) + x -= GetBase()->GetPositionX(); // x = searchedX * cos(o) + searchedY * sin(o + pi) + float inx = x, iny = y; + y = (iny - inx * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation())); + x = (inx + iny * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation())); +} diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 95fc2364256..4ad8663a17a 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -27,7 +27,7 @@ class Unit; typedef std::set<uint64> GuidSet; -class Vehicle +class Vehicle : public TransportBase { public: explicit Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry); @@ -52,7 +52,7 @@ class Vehicle bool AddPassenger(Unit* passenger, int8 seatId = -1); void EjectPassenger(Unit* passenger, Unit* controller); void RemovePassenger(Unit* passenger); - void RelocatePassengers(float x, float y, float z, float ang); + void RelocatePassengers(); void RemoveAllPassengers(); void Dismiss(); void TeleportVehicle(float x, float y, float z, float ang); @@ -66,6 +66,12 @@ class Vehicle SeatMap::iterator GetSeatIteratorForPassenger(Unit* passenger); void InitMovementInfoForBase(); + /// This method transforms supplied transport offsets into global coordinates + void CalculatePassengerPosition(float& x, float& y, float& z, float& o); + + /// This method transforms supplied global coordinates into local offsets + void CalculatePassengerOffset(float& x, float& y, float& z, float& o); + Unit* _me; VehicleEntry const* _vehicleInfo; GuidSet vehiclePlayers; diff --git a/src/server/game/Entities/Vehicle/VehicleDefines.h b/src/server/game/Entities/Vehicle/VehicleDefines.h index df34a61d444..cb8a6628b80 100644 --- a/src/server/game/Entities/Vehicle/VehicleDefines.h +++ b/src/server/game/Entities/Vehicle/VehicleDefines.h @@ -44,7 +44,7 @@ enum VehicleFlags VEHICLE_FLAG_FULLSPEEDPITCHING = 0x00000020, // Sets MOVEFLAG2_FULLSPEEDPITCHING VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040, // If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2 VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400, // Lua_IsVehicleAimAngleAdjustable - VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800, // Lua_IsVehicleAimPowerAdjustable + VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800 // Lua_IsVehicleAimPowerAdjustable }; enum VehicleSpells @@ -75,4 +75,14 @@ typedef std::vector<VehicleAccessory> VehicleAccessoryList; typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryContainer; typedef std::map<int8, VehicleSeat> SeatMap; +class TransportBase +{ + public: + /// This method transforms supplied transport offsets into global coordinates + virtual void CalculatePassengerPosition(float& x, float& y, float& z, float& o) = 0; + + /// This method transforms supplied global coordinates into local offsets + virtual void CalculatePassengerOffset(float& x, float& y, float& z, float& o) = 0; +}; + #endif diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index bead65bbfdd..2116738fac3 100755 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -205,7 +205,7 @@ void GameEventMgr::LoadFromDB() { { uint32 oldMSTime = getMSTime(); - // 1 2 3 4 5 6 7 8 + // 0 1 2 3 4 5 6 7 QueryResult result = WorldDatabase.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, description, world_event FROM game_event"); if (!result) { @@ -366,7 +366,7 @@ void GameEventMgr::LoadFromDB() { uint32 oldMSTime = getMSTime(); - // 1 2 + // 0 1 QueryResult result = WorldDatabase.Query("SELECT creature.guid, game_event_creature.eventEntry FROM creature" " JOIN game_event_creature ON creature.guid = game_event_creature.guid"); @@ -860,7 +860,7 @@ void GameEventMgr::LoadFromDB() if (!result) { - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 battleground holidays in game events. DB table `game_event_condition` is empty."); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 battleground holidays in game events. DB table `game_event_battleground_holiday` is empty."); } else { diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index d9b5890bfe5..dbc2c7ead10 100755 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -28,12 +28,12 @@ enum GameEventState { - GAMEEVENT_NORMAL = 0, // standard game events - GAMEEVENT_WORLD_INACTIVE = 1, // not yet started - GAMEEVENT_WORLD_CONDITIONS = 2, // condition matching phase - GAMEEVENT_WORLD_NEXTPHASE = 3, // conditions are met, now 'length' timer to start next event - GAMEEVENT_WORLD_FINISHED = 4, // next events are started, unapply this one - GAMEEVENT_INTERNAL = 5, // never handled in update + GAMEEVENT_NORMAL = 0, // standard game events + GAMEEVENT_WORLD_INACTIVE = 1, // not yet started + GAMEEVENT_WORLD_CONDITIONS = 2, // condition matching phase + GAMEEVENT_WORLD_NEXTPHASE = 3, // conditions are met, now 'length' timer to start next event + GAMEEVENT_WORLD_FINISHED = 4, // next events are started, unapply this one + GAMEEVENT_INTERNAL = 5 // never handled in update }; struct GameEventFinishCondition diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 3d58d5f4ce9..7d94e0ad209 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2001,8 +2001,8 @@ void ObjectMgr::LoadItemTemplates() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, unk0, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, " + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, " // 13 14 15 16 17 18 19 20 "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, " // 21 22 23 24 25 26 27 28 @@ -2055,7 +2055,7 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.ItemId = entry; itemTemplate.Class = uint32(fields[1].GetUInt8()); itemTemplate.SubClass = uint32(fields[2].GetUInt8()); - itemTemplate.Unk0 = fields[3].GetInt32(); + itemTemplate.SoundOverrideSubclass = int32(fields[3].GetInt8()); itemTemplate.Name1 = fields[4].GetString(); itemTemplate.DisplayInfoID = fields[5].GetUInt32(); itemTemplate.Quality = uint32(fields[6].GetUInt8()); @@ -2171,11 +2171,11 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.Class = dbcitem->Class; } - if (itemTemplate.Unk0 != dbcitem->Unk0) + if (itemTemplate.SoundOverrideSubclass != dbcitem->SoundOverrideSubclass) { - sLog->outError(LOG_FILTER_SQL, "Item (Entry: %u) does not have a correct Unk0 (%i), must be %i .", entry, itemTemplate.Unk0, dbcitem->Unk0); + sLog->outError(LOG_FILTER_SQL, "Item (Entry: %u) does not have a correct SoundOverrideSubclass (%i), must be %i .", entry, itemTemplate.SoundOverrideSubclass, dbcitem->SoundOverrideSubclass); if (enforceDBCAttributes) - itemTemplate.Unk0 = dbcitem->Unk0; + itemTemplate.SoundOverrideSubclass = dbcitem->SoundOverrideSubclass; } if (itemTemplate.Material != dbcitem->Material) { @@ -5606,8 +5606,8 @@ WorldSafeLocsEntry const* ObjectMgr::GetDefaultGraveYard(uint32 team) { enum DefaultGraveyard { - HORDE_GRAVEYARD = 10, // Crossroads - ALLIANCE_GRAVEYARD = 4, // Westfall + HORDE_GRAVEYARD = 10, // Crossroads + ALLIANCE_GRAVEYARD = 4 // Westfall }; if (team == HORDE) @@ -7301,6 +7301,11 @@ uint8 ObjectMgr::CheckPlayerName(const std::string& name, bool create) if (!isValidString(wname, strictMask, false, create)) return CHAR_NAME_MIXED_LANGUAGES; + wstrToLower(wname); + for (size_t i = 2; i < wname.size(); ++i) + if (wname[i] == wname[i-1] && wname[i] == wname[i-2]) + return CHAR_NAME_THREE_CONSECUTIVE; + return CHAR_NAME_SUCCESS; } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index da0d37cf27a..a6d1dc6c386 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -128,7 +128,7 @@ enum eScriptFlags SF_PLAYSOUND_DISTANCE_SOUND = 0x2, // Orientation flags - SF_ORIENTATION_FACE_TARGET = 0x1, + SF_ORIENTATION_FACE_TARGET = 0x1 }; struct ScriptInfo @@ -536,7 +536,7 @@ enum SkillRangeType SKILL_RANGE_LEVEL, // 1..max skill for level SKILL_RANGE_MONO, // 1..1, grey monolite bar SKILL_RANGE_RANK, // 1..skill for known rank - SKILL_RANGE_NONE, // 0..0 always + SKILL_RANGE_NONE // 0..0 always }; SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial); @@ -561,7 +561,7 @@ LanguageDesc const* GetLanguageDescByID(uint32 lang); enum EncounterCreditType { ENCOUNTER_CREDIT_KILL_CREATURE = 0, - ENCOUNTER_CREDIT_CAST_SPELL = 1, + ENCOUNTER_CREDIT_CAST_SPELL = 1 }; struct DungeonEncounter @@ -1285,7 +1285,7 @@ class ObjectMgr CREATURE_TO_CREATURE, CREATURE_TO_GO, // Creature is dependant on GO GO_TO_GO, - GO_TO_CREATURE, // GO is dependant on creature + GO_TO_CREATURE // GO is dependant on creature }; }; diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h index 6bf558a4d5e..0ef885703be 100755 --- a/src/server/game/Grids/NGrid.h +++ b/src/server/game/Grids/NGrid.h @@ -79,7 +79,12 @@ class NGrid public: typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType; NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) - : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false), i_GridInfo(GridInfo(expiry, unload)) + : i_gridId(id) + , i_GridInfo(GridInfo(expiry, unload)) + , i_x(x) + , i_y(y) + , i_cellstate(GRID_STATE_INVALID) + , i_GridObjectDataLoaded(false) { } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 072db578220..db4dc819557 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -694,6 +694,30 @@ namespace Trinity NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&); }; + // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO with a certain type) + class NearestGameObjectTypeInObjectRangeCheck + { + public: + NearestGameObjectTypeInObjectRangeCheck(WorldObject const& obj, GameobjectTypes type, float range) : i_obj(obj), i_type(type), i_range(range) {} + bool operator()(GameObject* go) + { + if (go->GetGoType() == i_type && i_obj.IsWithinDistInMap(go, i_range)) + { + i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check + return true; + } + return false; + } + float GetLastRange() const { return i_range; } + private: + WorldObject const& i_obj; + GameobjectTypes i_type; + float i_range; + + // prevent clone this object + NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&); + }; + class GameObjectWithDbGUIDCheck { public: diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index de622a16301..a00b7e1ef3a 100755 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -66,20 +66,20 @@ enum GroupMemberOnlineStatus MEMBER_STATUS_PVP_FFA = 0x0010, // Lua_UnitIsPVPFreeForAll MEMBER_STATUS_UNK3 = 0x0020, // used in calls from Lua_GetPlayerMapPosition/Lua_GetBattlefieldFlagPosition MEMBER_STATUS_AFK = 0x0040, // Lua_UnitIsAFK - MEMBER_STATUS_DND = 0x0080, // Lua_UnitIsDND + MEMBER_STATUS_DND = 0x0080 // Lua_UnitIsDND }; enum GroupMemberFlags { MEMBER_FLAG_ASSISTANT = 0x01, MEMBER_FLAG_MAINTANK = 0x02, - MEMBER_FLAG_MAINASSIST = 0x04, + MEMBER_FLAG_MAINASSIST = 0x04 }; enum GroupMemberAssignment { GROUP_ASSIGN_MAINTANK = 0, - GROUP_ASSIGN_MAINASSIST = 1, + GROUP_ASSIGN_MAINASSIST = 1 }; enum GroupType @@ -89,7 +89,7 @@ enum GroupType GROUPTYPE_RAID = 0x02, GROUPTYPE_BGRAID = GROUPTYPE_BG | GROUPTYPE_RAID, // mask GROUPTYPE_UNK1 = 0x04, - GROUPTYPE_LFG = 0x08, + GROUPTYPE_LFG = 0x08 // 0x10, leave/change group?, I saw this flag when leaving group and after leaving BG while in group }; @@ -117,7 +117,7 @@ enum GroupUpdateFlags GROUP_UPDATE_FLAG_PET_AURAS = 0x00040000, // uint64 mask, for each bit set uint32 spellid + uint8 unk, pet auras... GROUP_UPDATE_FLAG_VEHICLE_SEAT = 0x00080000, // uint32 vehicle_seat_id (index from VehicleSeat.dbc) GROUP_UPDATE_PET = 0x0007FC00, // all pet flags - GROUP_UPDATE_FULL = 0x0007FFFF, // all known flags + GROUP_UPDATE_FULL = 0x0007FFFF // all known flags }; #define GROUP_UPDATE_FLAGS_COUNT 20 diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 4df77f874f3..332c0924b61 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -1717,7 +1717,7 @@ void Guild::SendInfo(WorldSession* session) const { WorldPacket data(SMSG_GUILD_INFO, m_name.size() + 4 + 4 + 4); data << m_name; - data << secsToTimeBitFields(m_createdDate); // 3.x (prev. year + month + day) + data.AppendPackedTime(m_createdDate); // 3.x (prev. year + month + day) data << uint32(m_members.size()); // Number of members data << m_accountsNumber; // Number of accounts diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index e18e62e51b7..dd1fb7cc6b6 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -37,7 +37,7 @@ enum GuildMisc GUILD_RANK_NONE = 0xFF, GUILD_WITHDRAW_MONEY_UNLIMITED = 0xFFFFFFFF, GUILD_WITHDRAW_SLOT_UNLIMITED = 0xFFFFFFFF, - GUILD_EVENT_LOG_GUID_UNDEFINED = 0xFFFFFFFF, + GUILD_EVENT_LOG_GUID_UNDEFINED = 0xFFFFFFFF }; enum GuildDefaultRanks @@ -47,7 +47,7 @@ enum GuildDefaultRanks GR_OFFICER = 1, GR_VETERAN = 2, GR_MEMBER = 3, - GR_INITIATE = 4, + GR_INITIATE = 4 // When promoting member server does: rank-- // When demoting member server does: rank++ }; @@ -141,7 +141,7 @@ enum PetitionTurns { PETITION_TURN_OK = 0, PETITION_TURN_ALREADY_IN_GUILD = 2, - PETITION_TURN_NEED_MORE_SIGNATURES = 4, + PETITION_TURN_NEED_MORE_SIGNATURES = 4 }; enum PetitionSigns @@ -150,7 +150,7 @@ enum PetitionSigns PETITION_SIGN_ALREADY_SIGNED = 1, PETITION_SIGN_ALREADY_IN_GUILD = 2, PETITION_SIGN_CANT_SIGN_OWN = 3, - PETITION_SIGN_NOT_SERVER = 4, + PETITION_SIGN_NOT_SERVER = 4 }; enum GuildBankRights @@ -160,7 +160,7 @@ enum GuildBankRights GUILD_BANK_RIGHT_UPDATE_TEXT = 0x04, GUILD_BANK_RIGHT_DEPOSIT_ITEM = GUILD_BANK_RIGHT_VIEW_TAB | GUILD_BANK_RIGHT_PUT_ITEM, - GUILD_BANK_RIGHT_FULL = 0xFF, + GUILD_BANK_RIGHT_FULL = 0xFF }; enum GuildBankEventLogTypes @@ -173,7 +173,7 @@ enum GuildBankEventLogTypes GUILD_BANK_LOG_REPAIR_MONEY = 6, GUILD_BANK_LOG_MOVE_ITEM2 = 7, GUILD_BANK_LOG_UNK1 = 8, - GUILD_BANK_LOG_UNK2 = 9, + GUILD_BANK_LOG_UNK2 = 9 }; enum GuildEventLogTypes @@ -183,7 +183,7 @@ enum GuildEventLogTypes GUILD_EVENT_LOG_PROMOTE_PLAYER = 3, GUILD_EVENT_LOG_DEMOTE_PLAYER = 4, GUILD_EVENT_LOG_UNINVITE_PLAYER = 5, - GUILD_EVENT_LOG_LEAVE_GUILD = 6, + GUILD_EVENT_LOG_LEAVE_GUILD = 6 }; enum GuildEmblemError diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 475c1c42fca..72a6e0e1bec 100755 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -244,7 +244,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recv_data*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message"); @@ -252,39 +252,44 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_ if (!bg) // can't be received if player not in battleground return; - uint32 count = 0; - Player* aplr = NULL; - Player* hplr = NULL; + uint32 flagCarrierCount = 0; + Player* allianceFlagCarrier = NULL; + Player* hordeFlagCarrier = NULL; if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_ALLIANCE)) { - aplr = ObjectAccessor::FindPlayer(guid); - if (aplr) - ++count; + allianceFlagCarrier = ObjectAccessor::FindPlayer(guid); + if (allianceFlagCarrier) + ++flagCarrierCount; } if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_HORDE)) { - hplr = ObjectAccessor::FindPlayer(guid); - if (hplr) - ++count; + hordeFlagCarrier = ObjectAccessor::FindPlayer(guid); + if (hordeFlagCarrier) + ++flagCarrierCount; } - WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count); - data << 0; - data << count; - if (aplr) + WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * flagCarrierCount); + // Used to send several player positions (found used in AV) + data << 0; // CGBattlefieldInfo__m_numPlayerPositions + /* + for (CGBattlefieldInfo__m_numPlayerPositions) + data << guid << posx << posy; + */ + data << flagCarrierCount; + if (allianceFlagCarrier) { - data << uint64(aplr->GetGUID()); - data << float(aplr->GetPositionX()); - data << float(aplr->GetPositionY()); + data << uint64(allianceFlagCarrier->GetGUID()); + data << float(allianceFlagCarrier->GetPositionX()); + data << float(allianceFlagCarrier->GetPositionY()); } - if (hplr) + if (hordeFlagCarrier) { - data << uint64(hplr->GetGUID()); - data << float(hplr->GetPositionX()); - data << float(hplr->GetPositionY()); + data << uint64(hordeFlagCarrier->GetGUID()); + data << float(hordeFlagCarrier->GetPositionX()); + data << float(hordeFlagCarrier->GetPositionY()); } SendPacket(&data); @@ -457,6 +462,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); break; case 0: // leave queue + if (bg->isArena() && bg->GetStatus() != STATUS_WAIT_QUEUE) + return; + // if player leaves rated arena match before match start, it is counted as he played but he lost if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID) { diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index b721e789268..d1209eead22 100755 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -90,9 +90,9 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(*it)) { data << uint64(*it); - data << calendarEvent->GetTitle().c_str(); + data << calendarEvent->GetTitle(); data << uint32(calendarEvent->GetType()); - data << uint32(calendarEvent->GetTime()); + data.AppendPackedTime(calendarEvent->GetTime()); data << uint32(calendarEvent->GetFlags()); data << uint32(calendarEvent->GetDungeonId()); data.appendPackGUID(calendarEvent->GetCreatorGUID()); @@ -111,7 +111,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) } data << uint32(cur_time); // server time - data << uint32(secsToTimeBitFields(cur_time)); // server time + data.AppendPackedTime(cur_time); // server time uint32 counter = 0; size_t p_counter = data.wpos(); @@ -240,7 +240,10 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) uint8 rank; recvData >> title >> description >> type >> repeatable >> maxInvites; - recvData >> dungeonId >> eventPackedTime >> unkPackedTime >> flags; + recvData >> dungeonId; + recvData.ReadPackedTime(eventPackedTime); + recvData.ReadPackedTime(unkPackedTime); + recvData >> flags; if (!(flags & CALENDAR_FLAG_WITHOUT_INVITES)) { @@ -317,7 +320,9 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) recvData >> eventId >> inviteId >> title >> description >> type; recvData >> repeatable >> maxInvites >> dungeonId; - recvData >> eventPackedTime >> timeZoneTime >> flags; + recvData.ReadPackedTime(eventPackedTime); + recvData.ReadPackedTime(timeZoneTime); + recvData >> flags; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_UPDATE_EVENT [" UI64FMTD "] EventId [" UI64FMTD "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u " @@ -372,7 +377,8 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) uint64 inviteId; uint32 time; - recvData >> eventId >> inviteId >> time; + recvData >> eventId >> inviteId; + recvData.ReadPackedTime(time); sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time); @@ -607,15 +613,15 @@ void WorldSession::SendCalendarEvent(CalendarEvent const& calendarEvent, Calenda data << uint8(sendEventType); data.appendPackGUID(calendarEvent.GetCreatorGUID()); data << uint64(eventId); - data << calendarEvent.GetTitle().c_str(); - data << calendarEvent.GetDescription().c_str(); + data << calendarEvent.GetTitle(); + data << calendarEvent.GetDescription(); data << uint8(calendarEvent.GetType()); data << uint8(calendarEvent.GetRepeatable()); data << uint32(calendarEvent.GetMaxInvites()); data << int32(calendarEvent.GetDungeonId()); data << uint32(calendarEvent.GetFlags()); - data << uint32(calendarEvent.GetTime()); - data << uint32(calendarEvent.GetTimeZoneTime()); + data.AppendPackedTime(calendarEvent.GetTime()); + data.AppendPackedTime(calendarEvent.GetTimeZoneTime()); data << uint32(calendarEvent.GetGuildId()); CalendarInviteIdList const& invites = calendarEvent.GetInviteIdList(); @@ -635,7 +641,7 @@ void WorldSession::SendCalendarEvent(CalendarEvent const& calendarEvent, Calenda data << uint8(calendarEvent.GetGuildId() != 0); data << uint64(invite->GetInviteId()); data << uint32(invite->GetStatusTime()); - data << invite->GetText().c_str(); + data << invite->GetText(); } else { @@ -692,7 +698,7 @@ void WorldSession::SendCalendarEventInviteAlert(CalendarEvent const& calendarEve WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT); data << uint64(eventId); data << calendarEvent.GetTitle().c_str(); - data << uint32(calendarEvent.GetTime()); + data.AppendPackedTime(calendarEvent.GetTime()); data << uint32(calendarEvent.GetFlags()); data << uint32(calendarEvent.GetType()); data << uint32(calendarEvent.GetDungeonId()); @@ -717,9 +723,9 @@ void WorldSession::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEve calendarEvent.GetTitle().size() + calendarEvent.GetDescription().size() + 1 + 4 + 4); data << uint8(sendEventType); data << uint64(eventId); - data << uint32(calendarEvent.GetTime()); + data.AppendPackedTime(calendarEvent.GetTime()); data << uint32(calendarEvent.GetFlags()); - data << uint32(calendarEvent.GetTime()); + data.AppendPackedTime(calendarEvent.GetTime()); data << uint8(calendarEvent.GetType()); data << uint32(calendarEvent.GetDungeonId()); data << calendarEvent.GetTitle().c_str(); @@ -734,7 +740,7 @@ void WorldSession::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEv { uint64 guid = _player->GetGUID(); uint64 eventId = calendarEvent.GetEventId(); - uint32 eventTime = (calendarEvent.GetTime()); + uint32 eventTime = calendarEvent.GetTime(); sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_REMOVED_ALERT [" UI64FMTD "] EventId [" UI64FMTD "] Time %u", guid, eventId, eventTime); @@ -742,7 +748,7 @@ void WorldSession::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEv WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 1 + 8 + 1); data << uint8(1); // FIXME: If true does not SignalEvent(EVENT_CALENDAR_ACTION_PENDING) data << uint64(eventId); - data << uint32(eventTime); + data.AppendPackedTime(eventTime); SendPacket(&data); } @@ -752,11 +758,11 @@ void WorldSession::SendCalendarEventStatus(CalendarEvent const& calendarEvent, C uint64 eventId = calendarEvent.GetEventId(); uint64 inviteId = invite.GetInviteId(); uint64 invitee = invite.GetInvitee(); - uint32 eventTime = (calendarEvent.GetTime()); + uint32 eventTime = calendarEvent.GetTime(); uint32 flags = calendarEvent.GetFlags(); uint8 status = invite.GetStatus(); uint8 rank = invite.GetRank(); - uint32 statusTime = secsToTimeBitFields(invite.GetStatusTime()); + uint32 statusTime = invite.GetStatusTime(); sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_STATUS [" UI64FMTD "] EventId [" @@ -768,11 +774,11 @@ void WorldSession::SendCalendarEventStatus(CalendarEvent const& calendarEvent, C WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); data.appendPackGUID(invitee); data << uint64(eventId); - data << uint32(eventTime); + data.AppendPackedTime(eventTime); data << uint32(flags); data << uint8(status); data << uint8(rank); - data << uint32(statusTime); + data.AppendPackedTime(statusTime); SendPacket(&data); } @@ -801,7 +807,7 @@ void WorldSession::SendCalendarEventInviteRemoveAlert(CalendarEvent const& calen { uint64 guid = _player->GetGUID(); uint64 eventId = calendarEvent.GetEventId(); - uint32 eventTime = (calendarEvent.GetTime()); + uint32 eventTime = calendarEvent.GetTime(); uint32 flags = calendarEvent.GetFlags(); sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT [" @@ -810,7 +816,7 @@ void WorldSession::SendCalendarEventInviteRemoveAlert(CalendarEvent const& calen WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1); data << uint64(eventId); - data << uint32(eventTime); + data.AppendPackedTime(eventTime); data << uint32(flags); data << uint8(status); SendPacket(&data); @@ -877,7 +883,7 @@ void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) if (add) { data.SetOpcode(SMSG_CALENDAR_RAID_LOCKOUT_ADDED); - data << uint32(secsToTimeBitFields(currTime)); + data.AppendPackedTime(currTime); } data << uint32(save->GetMapId()); @@ -899,7 +905,7 @@ void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save) time_t cur_time = time_t(time(NULL)); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8); - data << secsToTimeBitFields(cur_time); + data.AppendPackedTime(cur_time); data << uint32(save->GetMapId()); data << uint32(save->GetDifficulty()); data << uint32(0); // Amount of seconds that has changed to the reset time diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index c294dd9b772..39704828d7f 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1308,12 +1308,29 @@ void WorldSession::HandleAlterAppearance(WorldPacket & recv_data) if (bs_skinColor && (bs_skinColor->type != 3 || bs_skinColor->race != _player->getRace() || bs_skinColor->gender != _player->getGender())) return; - uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, bs_skinColor); + GameObject* go = _player->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_BARBER_CHAIR, 5.0f); + if (!go) + { + WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4); + data << uint32(2); + SendPacket(&data); + return; + } + + if (_player->getStandState() != UNIT_STAND_STATE_SIT_LOW_CHAIR + go->GetGOInfo()->barberChair.chairheight) + { + WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4); + data << uint32(2); + SendPacket(&data); + return; + } + + uint32 cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, bs_skinColor); // 0 - ok // 1, 3 - not enough money // 2 - you have to seat on barber chair - if (!_player->HasEnoughMoney(Cost)) + if (!_player->HasEnoughMoney(cost)) { WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4); data << uint32(1); // no money @@ -1327,8 +1344,8 @@ void WorldSession::HandleAlterAppearance(WorldPacket & recv_data) SendPacket(&data); } - _player->ModifyMoney(-int32(Cost)); // it isn't free - _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, Cost); + _player->ModifyMoney(-int32(cost)); // it isn't free + _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, cost); _player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id)); _player->SetByteValue(PLAYER_BYTES, 3, uint8(Color)); diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 260220bb8d5..76c719443bb 100755 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -306,7 +306,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data) data << pProto->ItemId; data << pProto->Class; data << pProto->SubClass; - data << int32(pProto->Unk0); // new 2.0.3, not exist in wdb cache? + data << pProto->SoundOverrideSubclass; data << Name; data << uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name... data << uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 80caee7d896..aa353549c10 100755 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -1741,7 +1741,7 @@ void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recv_data*/) if (_player->isInFlight()) return; - if(Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId())) + if (/*Battlefield* bf = */sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId())) { // bf->PlayerAskToLeave(_player); FIXME return; diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index f0c3093aa25..085e3c49157 100755 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -44,7 +44,7 @@ enum StableResultCode STABLE_SUCCESS_STABLE = 0x08, // stable success STABLE_SUCCESS_UNSTABLE = 0x09, // unstable/swap success STABLE_SUCCESS_BUY_SLOT = 0x0A, // buy slot success - STABLE_ERR_EXOTIC = 0x0C, // "you are unable to control exotic creatures" + STABLE_ERR_EXOTIC = 0x0C // "you are unable to control exotic creatures" }; void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket & recv_data) diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index f9731ba85db..8872816f87d 100755 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -84,9 +84,13 @@ void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket & recv_data) unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect" } -void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data) +void WorldSession::HandleUnlearnSkillOpcode(WorldPacket& recvData) { - uint32 skill_id; - recv_data >> skill_id; - GetPlayer()->SetSkill(skill_id, 0, 0, 0); + uint32 skillId; + recvData >> skillId; + + if (!IsPrimaryProfessionSkill(skillId)) + return; + + GetPlayer()->SetSkill(skillId, 0, 0, 0); } diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index ba6d327e631..f1766833aee 100755 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -49,7 +49,7 @@ enum EncounterFrameType ENCOUNTER_FRAME_ENABLE_OBJECTIVE = 4, ENCOUNTER_FRAME_UPDATE_OBJECTIVE = 5, ENCOUNTER_FRAME_DISABLE_OBJECTIVE = 6, - ENCOUNTER_FRAME_UNK7 = 7, // Seems to have something to do with sorting the encounter units + ENCOUNTER_FRAME_UNK7 = 7 // Seems to have something to do with sorting the encounter units }; enum EncounterState @@ -59,7 +59,7 @@ enum EncounterState FAIL = 2, DONE = 3, SPECIAL = 4, - TO_BE_DECIDED = 5, + TO_BE_DECIDED = 5 }; enum DoorType @@ -67,7 +67,7 @@ enum DoorType DOOR_TYPE_ROOM = 0, // Door can open if encounter is not in progress DOOR_TYPE_PASSAGE = 1, // Door can open if encounter is done DOOR_TYPE_SPAWN_HOLE = 2, // Door can open if encounter is in progress, typically used for spawning places - MAX_DOOR_TYPES, + MAX_DOOR_TYPES }; enum BoundaryType @@ -84,7 +84,7 @@ enum BoundaryType BOUNDARY_MAX_X = BOUNDARY_N, BOUNDARY_MIN_X = BOUNDARY_S, BOUNDARY_MAX_Y = BOUNDARY_W, - BOUNDARY_MIN_Y = BOUNDARY_E, + BOUNDARY_MIN_Y = BOUNDARY_E }; typedef std::map<BoundaryType, float> BossBoundaryMap; diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 72636a5d2aa..fca8d78a3de 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -524,7 +524,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player) // increase once if one looter only, looter-times if free for all if (item.freeforall || !item.is_blocked) ++unlootedCount; - if (!player->GetGroup() || (player->GetGroup()->GetLootMethod() != GROUP_LOOT || player->GetGroup()->GetLootMethod() != ROUND_ROBIN)) + if (!player->GetGroup() || (player->GetGroup()->GetLootMethod() != GROUP_LOOT && player->GetGroup()->GetLootMethod() != ROUND_ROBIN)) item.is_blocked = true; if (items.size() + ql->size() == MAX_NR_LOOT_ITEMS) diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 1af5bd1ea62..45fc5c7983c 100755 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -69,7 +69,7 @@ enum PermissionTypes MASTER_PERMISSION = 2, ROUND_ROBIN_PERMISSION = 3, OWNER_PERMISSION = 4, - NONE_PERMISSION = 5, + NONE_PERMISSION = 5 }; enum LootType @@ -94,7 +94,7 @@ enum LootSlotType LOOT_SLOT_TYPE_ROLL_ONGOING = 1, // roll is ongoing. player cannot loot. LOOT_SLOT_TYPE_MASTER = 2, // item can only be distributed by group loot master. LOOT_SLOT_TYPE_LOCKED = 3, // item is shown in red. player cannot loot. - LOOT_SLOT_TYPE_OWNER = 4, // ignore binding confirmation and etc, for single player looting + LOOT_SLOT_TYPE_OWNER = 4 // ignore binding confirmation and etc, for single player looting }; class Player; diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 8efb33bda9a..10095268ead 100755 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -36,7 +36,7 @@ enum MailMessageType MAIL_AUCTION = 2, MAIL_CREATURE = 3, // client send CMSG_CREATURE_QUERY on this mailmessagetype MAIL_GAMEOBJECT = 4, // client send CMSG_GAMEOBJECT_QUERY on this mailmessagetype - MAIL_ITEM = 5, // client send CMSG_ITEM_QUERY on this mailmessagetype + MAIL_ITEM = 5 // client send CMSG_ITEM_QUERY on this mailmessagetype }; enum MailCheckMask @@ -46,7 +46,7 @@ enum MailCheckMask MAIL_CHECK_MASK_RETURNED = 0x02, /// This mail was returned. Do not allow returning mail back again. MAIL_CHECK_MASK_COPIED = 0x04, /// This mail was copied. Do not allow making a copy of items in mail. MAIL_CHECK_MASK_COD_PAYMENT = 0x08, - MAIL_CHECK_MASK_HAS_BODY = 0x10, /// This mail has body text. + MAIL_CHECK_MASK_HAS_BODY = 0x10 /// This mail has body text. }; // gathered from Stationery.dbc @@ -58,7 +58,7 @@ enum MailStationery MAIL_STATIONERY_AUCTION = 62, MAIL_STATIONERY_VAL = 64, // Valentine MAIL_STATIONERY_CHR = 65, // Christmas - MAIL_STATIONERY_ORP = 67, // Orphan + MAIL_STATIONERY_ORP = 67 // Orphan }; enum MailState @@ -74,7 +74,7 @@ enum MailShowFlags MAIL_SHOW_DELETE = 0x0002, // forced show delete button instead return button MAIL_SHOW_AUCTION = 0x0004, // from old comment MAIL_SHOW_UNK2 = 0x0008, // unknown, COD will be shown even without that flag - MAIL_SHOW_RETURN = 0x0010, + MAIL_SHOW_RETURN = 0x0010 }; class MailSender diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index c06c7414e6e..aee516f6f1d 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -711,7 +711,7 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie player->Relocate(x, y, z, orientation); if (player->IsVehicle()) - player->GetVehicleKit()->RelocatePassengers(x, y, z, orientation); + player->GetVehicleKit()->RelocatePassengers(); if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell)) { @@ -757,7 +757,7 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa { creature->Relocate(x, y, z, ang); if (creature->IsVehicle()) - creature->GetVehicleKit()->RelocatePassengers(x, y, z, ang); + creature->GetVehicleKit()->RelocatePassengers(); creature->UpdateObjectVisibility(false); RemoveCreatureFromMoveList(creature); } @@ -1223,8 +1223,8 @@ bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/) } if (!(header.flags & MAP_LIQUID_NO_HEIGHT)) { - _liquidMap = new float[_liquidWidth*_liquidHeight]; - if (fread(_liquidMap, sizeof(float), _liquidWidth*_liquidHeight, in) != _liquidWidth*_liquidHeight) + _liquidMap = new float[uint32(_liquidWidth) * uint32(_liquidHeight)]; + if (fread(_liquidMap, sizeof(float), _liquidWidth*_liquidHeight, in) != (uint32(_liquidWidth) * uint32(_liquidHeight))) return false; } return true; diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index a766108dbb0..5893bbd6564 100755 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -86,7 +86,8 @@ enum TrinityStrings LANG_CONNECTED_PLAYERS = 60, LANG_ACCOUNT_ADDON = 61, LANG_IMPROPER_VALUE = 62, - // Room for more level 0 63-99 not used + LANG_CANT_DO_NOW = 63, + // Room for more level 0 64-99 not used // level 1 chat LANG_GLOBAL_NOTIFY = 100, @@ -337,7 +338,13 @@ enum TrinityStrings LANG_TITLE_REMOVE_RES = 354, LANG_TITLE_CURRENT_RES = 355, LANG_CURRENT_TITLE_RESET = 356, - // Room for more level 2 357-399 not used + LANG_COMMAND_CHEAT_STATUS = 357, + LANG_COMMAND_CHEAT_GOD = 358, + LANG_COMMAND_CHEAT_CT = 359, + LANG_COMMAND_CHEAT_CD = 360, + LANG_COMMAND_CHEAT_POWER = 361, + LANG_COMMAND_CHEAT_WW = 362, + // Room for more level 2 363-399 not used // level 3 chat LANG_SCRIPTS_RELOADED = 400, @@ -1069,7 +1076,7 @@ enum TrinityStrings // Use for custom patches 11000-11999 LANG_AUTO_BROADCAST = 11000, - LANG_INVALID_REALMID = 11001, + LANG_INVALID_REALMID = 11001 // NOT RESERVED IDS 12000-1999999999 // `db_script_string` table index 2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID) diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index f74d6c44be7..4f6ad917423 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -26,7 +26,7 @@ enum SpellEffIndex { EFFECT_0 = 0, EFFECT_1 = 1, - EFFECT_2 = 2, + EFFECT_2 = 2 }; // used in script definitions @@ -124,7 +124,7 @@ enum UnitClass UNIT_CLASS_WARRIOR = 1, UNIT_CLASS_PALADIN = 2, UNIT_CLASS_ROGUE = 4, - UNIT_CLASS_MAGE = 8, + UNIT_CLASS_MAGE = 8 }; #define CLASSMASK_ALL_CREATURES ((1<<(UNIT_CLASS_WARRIOR-1)) | (1<<(UNIT_CLASS_PALADIN-1)) | (1<<(UNIT_CLASS_ROGUE-1)) | (1<<(UNIT_CLASS_MAGE-1))) @@ -245,7 +245,7 @@ enum ItemQualities enum SpellCategory { SPELL_CATEGORY_FOOD = 11, - SPELL_CATEGORY_DRINK = 59, + SPELL_CATEGORY_DRINK = 59 }; const uint32 ItemQualityColors[MAX_ITEM_QUALITY] = @@ -465,7 +465,7 @@ enum SpellAttr5 SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK = 0x00010000, // 16 this allows spells with EquippedItemClass to affect spells from other items if the required item is equipped SPELL_ATTR5_USABLE_WHILE_FEARED = 0x00020000, // 17 usable while feared SPELL_ATTR5_USABLE_WHILE_CONFUSED = 0x00040000, // 18 usable while confused - SPELL_ATTR5_UNK19 = 0x00080000, // 19 + SPELL_ATTR5_DONT_TURN_DURING_CAST = 0x00080000, // 19 Blocks caster's turning when casting (client does not automatically turn caster's model to face UNIT_FIELD_TARGET) SPELL_ATTR5_UNK20 = 0x00100000, // 20 SPELL_ATTR5_UNK21 = 0x00200000, // 21 SPELL_ATTR5_UNK22 = 0x00400000, // 22 @@ -572,7 +572,7 @@ enum SpellClickCastFlags { NPC_CLICK_CAST_CASTER_CLICKER = 0x01, NPC_CLICK_CAST_TARGET_CLICKER = 0x02, - NPC_CLICK_CAST_ORIG_CASTER_OWNER = 0x04, + NPC_CLICK_CAST_ORIG_CASTER_OWNER = 0x04 }; enum SheathTypes @@ -642,7 +642,7 @@ enum TeamId { TEAM_ALLIANCE = 0, TEAM_HORDE, - TEAM_NEUTRAL, + TEAM_NEUTRAL }; enum Team @@ -654,7 +654,7 @@ enum Team //TEAM_HORDE_FORCES = 892, //TEAM_SANCTUARY = 936, //TEAM_OUTLAND = 980, - TEAM_OTHER = 0, // if ReputationListId > 0 && Flags != FACTION_FLAG_TEAM_HEADER + TEAM_OTHER = 0 // if ReputationListId > 0 && Flags != FACTION_FLAG_TEAM_HEADER }; enum SpellEffects @@ -1121,7 +1121,7 @@ enum SpellCustomErrors SPELL_CUSTOM_ERROR_MAX_NUMBER_OF_RECRUITS = 96, // You already have the max number of recruits. SPELL_CUSTOM_ERROR_MAX_NUMBER_OF_VOLUNTEERS = 97, // You already have the max number of volunteers. SPELL_CUSTOM_ERROR_FROSTMOURNE_RENDERED_RESSURECT = 98, // Frostmourne has rendered you unable to ressurect. - SPELL_CUSTOM_ERROR_CANT_MOUNT_WITH_SHAPESHIFT = 99, // You can't mount while affected by that shapeshift. + SPELL_CUSTOM_ERROR_CANT_MOUNT_WITH_SHAPESHIFT = 99 // You can't mount while affected by that shapeshift. }; enum StealthType @@ -1192,7 +1192,7 @@ enum AuraStateType //AURA_STATE_UNKNOWN20 = 20, // c | only (45317 Suicide) //AURA_STATE_UNKNOWN21 = 21, // | not used AURA_STATE_UNKNOWN22 = 22, // C t| varius spells (63884, 50240) - AURA_STATE_HEALTH_ABOVE_75_PERCENT = 23, // C | + AURA_STATE_HEALTH_ABOVE_75_PERCENT = 23 // C | }; #define PER_CASTER_AURA_STATE_MASK (\ @@ -1485,7 +1485,7 @@ enum GameObjectFlags GO_FLAG_NODESPAWN = 0x00000020, // never despawn, typically for doors, they just change state GO_FLAG_TRIGGERED = 0x00000040, // typically, summoned objects. Triggered by spell or other events GO_FLAG_DAMAGED = 0x00000200, - GO_FLAG_DESTROYED = 0x00000400, + GO_FLAG_DESTROYED = 0x00000400 }; enum GameObjectDynamicLowFlags @@ -1493,7 +1493,7 @@ enum GameObjectDynamicLowFlags GO_DYNFLAG_LO_ACTIVATE = 0x01, // enables interaction with GO GO_DYNFLAG_LO_ANIMATE = 0x02, // possibly more distinct animation of GO GO_DYNFLAG_LO_NO_INTERACT = 0x04, // appears to disable interaction (not fully verified) - GO_DYNFLAG_LO_SPARKLE = 0x08, // makes GO sparkle + GO_DYNFLAG_LO_SPARKLE = 0x08 // makes GO sparkle }; enum GameObjectDestructibleState @@ -1501,7 +1501,7 @@ enum GameObjectDestructibleState GO_DESTRUCTIBLE_INTACT = 0, GO_DESTRUCTIBLE_DAMAGED = 1, GO_DESTRUCTIBLE_DESTROYED = 2, - GO_DESTRUCTIBLE_REBUILDING = 3, + GO_DESTRUCTIBLE_REBUILDING = 3 }; // EmotesText.dbc @@ -1758,7 +1758,7 @@ enum TextEmotes TEXT_EMOTE_LOOK = 449, TEXT_EMOTE_OBJECT = 450, TEXT_EMOTE_SWEAT = 451, - TEXT_EMOTE_YW = 453, + TEXT_EMOTE_YW = 453 }; // Emotes.dbc @@ -2595,7 +2595,7 @@ enum CreatureTypeFlags CREATURE_TYPEFLAGS_UNK28 = 0x10000000, CREATURE_TYPEFLAGS_UNK29 = 0x20000000, CREATURE_TYPEFLAGS_UNK30 = 0x40000000, - CREATURE_TYPEFLAGS_UNK31 = 0x80000000, + CREATURE_TYPEFLAGS_UNK31 = 0x80000000 }; enum CreatureEliteType @@ -2700,7 +2700,7 @@ enum QuestSort QUEST_SORT_JEWELCRAFTING = 373, QUEST_SORT_NOBLEGARDEN = 374, QUEST_SORT_PILGRIMS_BOUNTY = 375, - QUEST_SORT_LOVE_IS_IN_THE_AIR = 376, + QUEST_SORT_LOVE_IS_IN_THE_AIR = 376 }; inline uint8 ClassByQuestSort(int32 QuestSort) @@ -3085,7 +3085,7 @@ enum AiReaction AI_REACTION_FRIENDLY = 1, // (NOT used in client packet handler) AI_REACTION_HOSTILE = 2, // sent on every attack, triggers aggro sound (used in client packet handler) AI_REACTION_AFRAID = 3, // seen for polymorph (when AI not in control of self?) (NOT used in client packet handler) - AI_REACTION_DESTROY = 4, // used on object destroy (NOT used in client packet handler) + AI_REACTION_DESTROY = 4 // used on object destroy (NOT used in client packet handler) }; // Diminishing Returns Types @@ -3119,7 +3119,7 @@ enum DiminishingGroup DIMINISHING_SLEEP = 17, DIMINISHING_TAUNT = 18, DIMINISHING_LIMITONLY = 19, - DIMINISHING_DRAGONS_BREATH = 20, + DIMINISHING_DRAGONS_BREATH = 20 }; enum SummonCategory @@ -3129,7 +3129,7 @@ enum SummonCategory SUMMON_CATEGORY_PET = 2, SUMMON_CATEGORY_PUPPET = 3, SUMMON_CATEGORY_VEHICLE = 4, - SUMMON_CATEGORY_UNK = 5, // as of patch 3.3.5a only Bone Spike in Icecrown Citadel + SUMMON_CATEGORY_UNK = 5 // as of patch 3.3.5a only Bone Spike in Icecrown Citadel // uses this category }; @@ -3146,12 +3146,12 @@ enum SummonType SUMMON_TYPE_WILD3 = 8, SUMMON_TYPE_VEHICLE = 9, SUMMON_TYPE_VEHICLE2 = 10, - SUMMON_TYPE_OBJECT = 11, + SUMMON_TYPE_OBJECT = 11 }; enum EventId { - EVENT_CHARGE = 1003, + EVENT_CHARGE = 1003 }; enum ResponseCodes @@ -3335,7 +3335,7 @@ enum MailResponseResult MAIL_ERR_MAIL_AND_CHAT_SUSPENDED = 17, MAIL_ERR_TOO_MANY_ATTACHMENTS = 18, MAIL_ERR_MAIL_ATTACHMENT_INVALID = 19, - MAIL_ERR_ITEM_HAS_EXPIRED = 21, + MAIL_ERR_ITEM_HAS_EXPIRED = 21 }; enum SpellFamilyNames @@ -3401,7 +3401,7 @@ enum RemoveMethod { GROUP_REMOVEMETHOD_DEFAULT = 0, GROUP_REMOVEMETHOD_KICK = 1, - GROUP_REMOVEMETHOD_LEAVE = 2, + GROUP_REMOVEMETHOD_LEAVE = 2 }; enum ActivateTaxiReply @@ -3428,7 +3428,7 @@ enum CalendarFlags CALENDAR_FLAG_ALL_ALLOWED = 0x001, CALENDAR_FLAG_INVITES_LOCKED = 0x010, CALENDAR_FLAG_WITHOUT_INVITES = 0x040, - CALENDAR_FLAG_GUILD_ONLY = 0x400, + CALENDAR_FLAG_GUILD_ONLY = 0x400 }; enum CalendarActionData @@ -3442,21 +3442,21 @@ enum CalendarActionData CALENDAR_ACTION_MODIFY_EVENT_INVITE, CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE, CALENDAR_ACTION_REMOVE_EVENT_INVITE, - CALENDAR_ACTION_SIGNUP_TO_EVENT, + CALENDAR_ACTION_SIGNUP_TO_EVENT }; enum CalendarModerationRank { CALENDAR_RANK_PLAYER, CALENDAR_RANK_MODERATOR, - CALENDAR_RANK_OWNER, + CALENDAR_RANK_OWNER }; enum CalendarSendEventType { CALENDAR_SENDTYPE_GET, CALENDAR_SENDTYPE_ADD, - CALENDAR_SENDTYPE_COPY, + CALENDAR_SENDTYPE_COPY }; enum CalendarEventType @@ -3465,7 +3465,7 @@ enum CalendarEventType CALENDAR_TYPE_DUNGEON, CALENDAR_TYPE_PVP, CALENDAR_TYPE_MEETING, - CALENDAR_TYPE_OTHER, + CALENDAR_TYPE_OTHER }; enum CalendarInviteStatus @@ -3479,7 +3479,7 @@ enum CalendarInviteStatus CALENDAR_STATUS_CONFIRMED, CALENDAR_STATUS_NO_OWNER, CALENDAR_STATUS_8, - CALENDAR_STATUS_9, + CALENDAR_STATUS_9 }; enum CalendarError diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 727f626cdea..8d7fdee7ad2 100755 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -51,7 +51,7 @@ enum MovementGeneratorType FOLLOW_MOTION_TYPE = 14, ROTATE_MOTION_TYPE = 15, EFFECT_MOTION_TYPE = 16, - NULL_MOTION_TYPE = 17, + NULL_MOTION_TYPE = 17 }; enum MovementSlot @@ -59,7 +59,7 @@ enum MovementSlot MOTION_SLOT_IDLE, MOTION_SLOT_ACTIVE, MOTION_SLOT_CONTROLLED, - MAX_MOTION_SLOT, + MAX_MOTION_SLOT }; enum MMCleanFlag @@ -72,7 +72,7 @@ enum MMCleanFlag enum RotateDirection { ROTATE_DIRECTION_LEFT, - ROTATE_DIRECTION_RIGHT, + ROTATE_DIRECTION_RIGHT }; // assume it is 25 yard per 0.6 second diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index 7e130a2c143..56818e95a2b 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -140,7 +140,12 @@ bool FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float angle = i_cur_angle + static_cast<float>(M_PI); distance /= 2; break; + default: + angle = 0.0f; + distance = 0.0f; + break; } + temp_x = x + distance * cos(angle); temp_y = y + distance * sin(angle); Trinity::NormalizeMapCoord(temp_x); diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index fdff5a92564..2cd3d745750 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -89,6 +89,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner) Movement::MoveSplineInit init(owner); init.MoveTo(x,y,z); + init.SetFacing(i_target.getTarget()); init.SetWalk(((D*)this)->EnableWalking()); init.Launch(); } diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 61bd3900b9d..699d054be4b 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -107,7 +107,7 @@ struct FallInitializer }; enum{ - minimal_duration = 1, + minimal_duration = 1 }; struct CommonInitializer @@ -167,6 +167,7 @@ void MoveSpline::Initialize(const MoveSplineInitArgs& args) point_Idx_offset = args.path_Idx_offset; initialOrientation = args.initialOrientation; + onTransport = false; time_passed = 0; vertical_acceleration = 0.f; effect_start_time = 0; @@ -217,7 +218,7 @@ bool MoveSplineInitArgs::_checkPathBounds() const if (!(flags & MoveSplineFlag::Mask_CatmullRom) && path.size() > 2) { enum{ - MAX_OFFSET = (1 << 11) / 2, + MAX_OFFSET = (1 << 11) / 2 }; Vector3 middle = (path.front()+path.back()) / 2; Vector3 offset; diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h index d4b19b21634..945adf6d9f8 100644 --- a/src/server/game/Movement/Spline/MoveSpline.h +++ b/src/server/game/Movement/Spline/MoveSpline.h @@ -45,7 +45,7 @@ namespace Movement Result_None = 0x01, Result_Arrived = 0x02, Result_NextCycle = 0x04, - Result_NextSegment = 0x08, + Result_NextSegment = 0x08 }; friend class PacketBuilder; protected: @@ -119,6 +119,7 @@ namespace Movement const Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx+1) : Vector3();} int32 currentPathIdx() const; + bool onTransport; std::string ToString() const; }; } diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h index cfc2fdee450..a7262182391 100644 --- a/src/server/game/Movement/Spline/MoveSplineFlag.h +++ b/src/server/game/Movement/Spline/MoveSplineFlag.h @@ -70,7 +70,7 @@ namespace Movement // CatmullRom interpolation mode used Mask_CatmullRom = Flying | Catmullrom, // Unused, not suported flags - Mask_Unused = No_Spline|Enter_Cycle|Frozen|Unknown7|Unknown8|Unknown10|Unknown11|Unknown12|Unknown13, + Mask_Unused = No_Spline|Enter_Cycle|Frozen|Unknown7|Unknown8|Unknown10|Unknown11|Unknown12|Unknown13 }; inline uint32& raw() { return (uint32&)*this;} diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index c539dd3cc39..fec629c3329 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -74,7 +74,8 @@ namespace Movement // there is a big chance that current position is unknown if current state is not finalized, need compute it // this also allows calculate spline position and update map position in much greater intervals - if (!move_spline.Finalized()) + // Don't compute for transport movement if the unit is in a motion between two transports + if (!move_spline.Finalized() && move_spline.onTransport == transport) real_position = move_spline.ComputePosition(); // should i do the things that user should do? - no. @@ -84,6 +85,7 @@ namespace Movement // corrent first vertex args.path[0] = real_position; args.initialOrientation = real_position.orientation; + move_spline.onTransport = transport; uint32 moveFlags = unit.m_movementInfo.GetMovementFlags(); if (args.flags.walkmode) @@ -158,17 +160,9 @@ namespace Movement { if (_transformForTransport) { - if (Unit* vehicle = _owner.GetVehicleBase()) - { - input.x -= vehicle->GetPositionX(); - input.y -= vehicle->GetPositionY(); - input.z -= vehicle->GetPositionZMinusOffset(); - } - else if (Transport* transport = _owner.GetTransport()) - { - float unused = 0.0f; + float unused = 0.0f; + if (TransportBase* transport = _owner.GetDirectTransport()) transport->CalculatePassengerOffset(input.x, input.y, input.z, unused); - } } return input; diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index ef847809ac8..cae9f1321d2 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -30,7 +30,7 @@ namespace Movement ToGround = 0, // 460 = ToGround, index of AnimationData.dbc FlyToFly = 1, // 461 = FlyToFly? ToFly = 2, // 458 = ToFly - FlyToGround = 3, // 463 = FlyToGround + FlyToGround = 3 // 463 = FlyToGround }; // Transforms coordinates from global to transport offsets diff --git a/src/server/game/Movement/Spline/Spline.h b/src/server/game/Movement/Spline/Spline.h index 627cdcf3e3b..63e61b84579 100644 --- a/src/server/game/Movement/Spline/Spline.h +++ b/src/server/game/Movement/Spline/Spline.h @@ -53,7 +53,7 @@ protected: // lesser value saves more performance in cost of lover precision // minimal value is 1 // client's value is 20, blizzs use 2-3 steps to compute length - STEPS_PER_SEGMENT = 3, + STEPS_PER_SEGMENT = 3 }; static_assert(STEPS_PER_SEGMENT > 0, "shouldn't be lesser than 1"); diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 5a4d5734929..9919a47642e 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -30,7 +30,7 @@ #include "CellImpl.h" OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp) : -m_capturePointGUID(0), m_capturePoint(NULL), m_minValue(0.0f), m_maxValue(0.0f), m_maxSpeed(0), +m_capturePointGUID(0), m_capturePoint(NULL), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) { diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index 6ea13d353c5..e896fa2acf6 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -31,7 +31,7 @@ enum OutdoorPvPTypes OUTDOOR_PVP_TF = 3, OUTDOOR_PVP_ZM = 4, OUTDOOR_PVP_SI = 5, - OUTDOOR_PVP_EP = 6, + OUTDOOR_PVP_EP = 6 }; #define MAX_OUTDOORPVP_TYPES 7 @@ -44,7 +44,7 @@ enum ObjectiveStates OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE, OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE, OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE, - OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE, + OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE }; #define OTHER_TEAM(a) (a == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE) diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 6155e33d35e..5a8891d888c 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -90,7 +90,7 @@ enum __QuestTradeSkill QUEST_TRSKILL_MINING = 11, QUEST_TRSKILL_FISHING = 12, QUEST_TRSKILL_SKINNING = 13, - QUEST_TRSKILL_JEWELCRAFTING = 14, + QUEST_TRSKILL_JEWELCRAFTING = 14 }; enum QuestStatus @@ -158,7 +158,7 @@ enum __QuestFlags QUEST_TRINITY_FLAGS_SPEAKTO = 0x08000000, // Internal flag computed only QUEST_TRINITY_FLAGS_KILL_OR_CAST = 0x10000000, // Internal flag computed only QUEST_TRINITY_FLAGS_TIMED = 0x20000000, // Internal flag computed only - QUEST_TRINITY_FLAGS_PLAYER_KILL = 0x40000000, // Internal flag computed only + QUEST_TRINITY_FLAGS_PLAYER_KILL = 0x40000000 // Internal flag computed only }; struct QuestLocale diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 1848250ec8e..fc56106ab6f 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -325,6 +325,7 @@ void AddSC_bug_trio(); void AddSC_boss_sartura(); void AddSC_boss_skeram(); void AddSC_boss_twinemperors(); +void AddSC_boss_ouro(); void AddSC_mob_anubisath_sentinel(); void AddSC_instance_temple_of_ahnqiraj(); void AddSC_wailing_caverns(); //Wailing caverns @@ -953,6 +954,7 @@ void AddKalimdorScripts() AddSC_boss_sartura(); AddSC_boss_skeram(); AddSC_boss_twinemperors(); + AddSC_boss_ouro(); AddSC_mob_anubisath_sentinel(); AddSC_instance_temple_of_ahnqiraj(); AddSC_wailing_caverns(); //Wailing caverns diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index bd993a24193..625ee88a853 100755 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -1356,7 +1356,7 @@ enum SessionStatus STATUS_TRANSFER, // Player transferring to another map (_player != NULL, m_GUID == _player->GetGUID(), !inWorld()) STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT, // _player != NULL or _player == NULL && m_playerRecentlyLogout && m_playerLogout, m_GUID store last _player guid) STATUS_NEVER, // Opcode not accepted from client (deprecated or server side only) - STATUS_UNHANDLED, // Opcode not handled yet + STATUS_UNHANDLED // Opcode not handled yet }; enum PacketProcessing diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 0aa14eb78a8..bc9e6ac4298 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -68,7 +68,7 @@ enum AccountDataType GLOBAL_MACROS_CACHE = 4, // 0x10 g PER_CHARACTER_MACROS_CACHE = 5, // 0x20 p PER_CHARACTER_LAYOUT_CACHE = 6, // 0x40 p - PER_CHARACTER_CHAT_CACHE = 7, // 0x80 p + PER_CHARACTER_CHAT_CACHE = 7 // 0x80 p }; #define NUM_ACCOUNT_DATA_TYPES 8 @@ -132,7 +132,7 @@ enum BFLeaveReason //BF_LEAVE_REASON_UNK1 = 0x00000002, (not used) //BF_LEAVE_REASON_UNK2 = 0x00000004, (not used) BF_LEAVE_REASON_EXITED = 0x00000008, - BF_LEAVE_REASON_LOW_LEVEL = 0x00000010, + BF_LEAVE_REASON_LOW_LEVEL = 0x00000010 }; enum ChatRestrictionType diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h index ddb230d6773..6902dd60c80 100755 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -47,14 +47,14 @@ enum AuraEffectHandleModes AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK = (AURA_EFFECT_HANDLE_SEND_FOR_CLIENT | AURA_EFFECT_HANDLE_REAL), // any case handler need to send packet AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK = (AURA_EFFECT_HANDLE_CHANGE_AMOUNT | AURA_EFFECT_HANDLE_REAL), // any case handler applies effect depending on amount AURA_EFFECT_HANDLE_CHANGE_AMOUNT_SEND_FOR_CLIENT_MASK = (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK), - AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK = (AURA_EFFECT_HANDLE_REAPPLY | AURA_EFFECT_HANDLE_REAL), + AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK = (AURA_EFFECT_HANDLE_REAPPLY | AURA_EFFECT_HANDLE_REAL) }; //m_schoolAbsorb enum DAMAGE_ABSORB_TYPE { ALL_DAMAGE_ABSORB = -2, - ONLY_MAGIC_ABSORB = -1, + ONLY_MAGIC_ABSORB = -1 }; enum AuraType @@ -382,6 +382,7 @@ enum AuraType enum AuraObjectType { UNIT_AURA_TYPE, - DYNOBJ_AURA_TYPE, + DYNOBJ_AURA_TYPE }; + #endif diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index bca26bd7391..29dcde9d616 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -5042,7 +5042,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool } case 43681: // Inactive { - if (!target || target->GetTypeId() != TYPEID_PLAYER || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + if (target->GetTypeId() != TYPEID_PLAYER || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) return; if (target->GetMap()->IsBattleground()) diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 9ee05b9a2a4..3de11b98e30 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -425,7 +425,7 @@ void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * auraA if (itr == m_applications.end()) { sLog->outError(LOG_FILTER_SPELLS_AURAS, "Aura::_UnapplyForTarget, target:%u, caster:%u, spell:%u was not found in owners application map!", - target->GetGUIDLow(), caster->GetGUIDLow(), auraApp->GetBase()->GetSpellInfo()->Id); + target->GetGUIDLow(), caster ? caster->GetGUIDLow() : 0, auraApp->GetBase()->GetSpellInfo()->Id); ASSERT(false); } @@ -766,7 +766,7 @@ void Aura::SetCharges(uint8 charges) uint8 Aura::CalcMaxCharges(Unit* caster) const { - uint8 maxProcCharges = m_spellInfo->ProcCharges; + uint32 maxProcCharges = m_spellInfo->ProcCharges; if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId())) maxProcCharges = procEntry->charges; @@ -1414,10 +1414,16 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b if (caster->GetTypeId() == TYPEID_PLAYER) { if (caster->ToPlayer()->HasSpellCooldown(aura->GetId())) - break; - // and add if needed - caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, uint32(time(NULL) + 12)); + { + // This additional check is needed to add a minimal delay before cooldown in in effect + // to allow all bubbles broken by a single damage source proc mana return + if (caster->ToPlayer()->GetSpellCooldownDelay(aura->GetId()) <= 11) + break; + } + else // and add if needed + caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, uint32(time(NULL) + 12)); } + // effect on caster if (AuraEffect const* aurEff = aura->GetEffect(0)) { @@ -2062,6 +2068,7 @@ void Aura::LoadScripts() { std::list<AuraScript*>::iterator bitr = itr; ++itr; + delete (*bitr); m_loadedScripts.erase(bitr); continue; } @@ -2324,7 +2331,7 @@ UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne LoadScripts(); _InitEffects(effMask, caster, baseAmount); GetUnitOwner()->_AddAura(this, caster); -}; +} void UnitAura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) { diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 95345ed8b93..bac8d2fe4eb 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -583,7 +583,7 @@ m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharme && !m_spellInfo->IsPassive() && !m_spellInfo->IsPositive(); CleanupTargetList(); - CleanupEffectExecuteData(); + memset(m_effectExecuteData, 0, MAX_SPELL_EFFECTS * sizeof(ByteBuffer*)); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) m_destTargets[i] = SpellDestination(*m_caster); @@ -916,7 +916,7 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa { case TARGET_UNIT_CHANNEL_TARGET: { - WorldObject* target = ObjectAccessor::GetUnit(*m_caster, channeledSpell->m_targets.GetUnitTargetGUID()); + WorldObject* target = ObjectAccessor::GetUnit(*m_caster, m_originalCaster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT)); CallScriptObjectTargetSelectHandlers(target, effIndex); // unit target may be no longer avalible - teleported out of map for example if (target && target->ToUnit()) @@ -928,7 +928,7 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa case TARGET_DEST_CHANNEL_TARGET: if (channeledSpell->m_targets.HasDst()) m_targets.SetDst(channeledSpell->m_targets); - else if (WorldObject* target = ObjectAccessor::GetWorldObject(*m_caster, channeledSpell->m_targets.GetObjectTargetGUID())) + else if (WorldObject* target = ObjectAccessor::GetWorldObject(*m_caster, m_originalCaster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT))) { CallScriptObjectTargetSelectHandlers(target, effIndex); if (target) @@ -2525,7 +2525,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) } } - if (missInfo != SPELL_MISS_EVADE && m_caster && !m_caster->IsFriendlyTo(unit) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL))) + if (missInfo != SPELL_MISS_EVADE && !m_caster->IsFriendlyTo(unit) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL))) { m_caster->CombatStart(unit, !(m_spellInfo->AttributesEx3 & SPELL_ATTR3_NO_INITIAL_AGGRO)); @@ -3025,7 +3025,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered if (m_caster->GetTypeId() == TYPEID_PLAYER) { m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); - + // Set casttime to 0 if .cheat casttime is enabled. if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME)) m_casttime = 0; @@ -3069,10 +3069,9 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered SendSpellStart(); // set target for proper facing - if (m_casttime && !(_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING)) - if (uint64 target = m_targets.GetUnitTargetGUID()) - if (m_caster->GetGUID() != target && m_caster->GetTypeId() == TYPEID_UNIT) - m_caster->FocusTarget(this, target); + if ((m_casttime || m_spellInfo->IsChanneled()) && !(_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING)) + if (m_caster->GetGUID() != m_targets.GetObjectTargetGUID() && m_caster->GetTypeId() == TYPEID_UNIT) + m_caster->FocusTarget(this, m_targets.GetObjectTargetGUID()); if (!(_triggeredCastFlags & TRIGGERED_IGNORE_GCD)) TriggerGlobalCooldown(); @@ -3323,7 +3322,7 @@ void Spell::cast(bool skipCheck) if (m_caster->GetTypeId() == TYPEID_PLAYER) { m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); - + //Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled. if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN)) m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true); @@ -4083,41 +4082,47 @@ void Spell::WriteAmmoToPacket(WorldPacket* data) *data << uint32(ammoInventoryType); } +/// Writes miss and hit targets for a SMSG_SPELL_GO packet void Spell::WriteSpellGoTargets(WorldPacket* data) { // This function also fill data for channeled spells: // 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) { if ((*ihit).effectMask == 0) // No effect apply - all immuned add state - { // possibly SPELL_MISS_IMMUNE2 for this?? ihit->missCondition = SPELL_MISS_IMMUNE2; - ++miss; - } - else if ((*ihit).missCondition == SPELL_MISS_NONE) - ++hit; - else - ++miss; } - *data << (uint8)hit; - for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) + // Hit and miss target counts are both uint8, that limits us to 255 targets for each + // sending more than 255 targets crashes the client (since count sent would be wrong) + // Spells like 40647 (with a huge radius) can easily reach this limit (spell might need + // target conditions but we still need to limit the number of targets sent and keeping + // correct count for both hit and miss). + + uint32 hit = 0; + size_t hitPos = data->wpos(); + *data << (uint8)0; // placeholder + for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end() && hit <= 255; ++ihit) { if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits { *data << uint64(ihit->targetGUID); m_channelTargetEffectMask |=ihit->effectMask; + ++hit; } } - for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit) + for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end() && hit <= 255; ++ighit) + { *data << uint64(ighit->targetGUID); // Always hits + ++hit; + } - *data << (uint8)miss; - for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) + uint32 miss = 0; + size_t missPos = data->wpos(); + *data << (uint8)0; // placeholder + for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end() && miss <= 255; ++ihit) { if (ihit->missCondition != SPELL_MISS_NONE) // Add only miss { @@ -4125,11 +4130,15 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) *data << uint8(ihit->missCondition); if (ihit->missCondition == SPELL_MISS_REFLECT) *data << uint8(ihit->reflectResult); + ++miss; } } // Reset m_needAliveTargetMask for non channeled spell if (!m_spellInfo->IsChanneled()) m_channelTargetEffectMask = 0; + + data->put<uint8>(hitPos, (uint8)hit); + data->put<uint8>(missPos, (uint8)miss); } void Spell::SendLogExecute() @@ -4268,6 +4277,9 @@ void Spell::SendChannelUpdate(uint32 time) void Spell::SendChannelStart(uint32 duration) { uint64 channelTarget = m_targets.GetObjectTargetGUID(); + if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget()) + if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY + channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID; WorldPacket data(MSG_CHANNEL_START, (8+4+4)); data.append(m_caster->GetPackGUID()); @@ -5135,6 +5147,10 @@ SpellCastResult Spell::CheckCast(bool strict) } if (m_caster->HasUnitState(UNIT_STATE_ROOT)) return SPELL_FAILED_ROOTED; + if (m_caster->GetTypeId() == TYPEID_PLAYER) + if (Unit* target = m_targets.GetUnitTarget()) + if (!target->isAlive()) + return SPELL_FAILED_BAD_TARGETS; break; } case SPELL_EFFECT_SKINNING: @@ -6915,12 +6931,6 @@ void Spell::InitEffectExecuteData(uint8 effIndex) } } -void Spell::CleanupEffectExecuteData() -{ - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - m_effectExecuteData[i] = NULL; -} - void Spell::CheckEffectExecuteData() { for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) @@ -6936,6 +6946,7 @@ void Spell::LoadScripts() { std::list<SpellScript*>::iterator bitr = itr; ++itr; + delete (*bitr); m_loadedScripts.erase(bitr); continue; } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 1376b0fbd40..d2bdf4b8970 100755 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -69,14 +69,14 @@ enum SpellCastFlags CAST_FLAG_UNKNOWN_29 = 0x10000000, CAST_FLAG_UNKNOWN_30 = 0x20000000, CAST_FLAG_UNKNOWN_31 = 0x40000000, - CAST_FLAG_UNKNOWN_32 = 0x80000000, + CAST_FLAG_UNKNOWN_32 = 0x80000000 }; enum SpellRangeFlag { SPELL_RANGE_DEFAULT = 0, SPELL_RANGE_MELEE = 1, //melee - SPELL_RANGE_RANGED = 2, //hunter range and ranged weapon + SPELL_RANGE_RANGED = 2 //hunter range and ranged weapon }; struct SpellDestination @@ -203,7 +203,7 @@ enum SpellEffectHandleMode SPELL_EFFECT_HANDLE_LAUNCH, SPELL_EFFECT_HANDLE_LAUNCH_TARGET, SPELL_EFFECT_HANDLE_HIT, - SPELL_EFFECT_HANDLE_HIT_TARGET, + SPELL_EFFECT_HANDLE_HIT_TARGET }; class Spell @@ -616,7 +616,6 @@ class Spell // spell execution log void InitEffectExecuteData(uint8 effIndex); - void CleanupEffectExecuteData(); void CheckEffectExecuteData(); // Scripting system diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 3637bb18049..dcbd1888b03 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1153,6 +1153,14 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/) if (unitTarget->getLevel() > uiMaxSafeLevel) { unitTarget->AddAura(60444, unitTarget); //Apply Lost! Aura + + // ALLIANCE from 60323 to 60330 - HORDE from 60328 to 60335 + uint32 spellId = 60323; + if (m_caster->ToPlayer()->GetTeam() == HORDE) + spellId += 5; + + spellId += urand(0, 7); + m_caster->CastSpell(m_caster, spellId, true); return; } break; @@ -1724,8 +1732,7 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) pItem->SetUInt32Value(ITEM_FIELD_CREATOR, player->GetGUIDLow()); // send info to the client - if (pItem) - player->SendNewItem(pItem, num_to_add, true, bgType == 0); + player->SendNewItem(pItem, num_to_add, true, bgType == 0); // we succeeded in creating at least one item, so a levelup is possible if (bgType == 0) @@ -2079,7 +2086,8 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) bg->EventPlayerClickedOnFlag(player, gameObjTarget); return; } - }else if (m_spellInfo->Id == 1842 && gameObjTarget->GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && gameObjTarget->GetOwner()) + } + else if (m_spellInfo->Id == 1842 && gameObjTarget->GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && gameObjTarget->GetOwner()) { gameObjTarget->SetLootState(GO_JUST_DEACTIVATED); return; @@ -2116,7 +2124,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) if (gameObjTarget) SendLoot(guid, LOOT_SKINNING); - else + else if (itemTarget) itemTarget->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_UNLOCKED); // not allow use skill grow at item base open @@ -4141,6 +4149,8 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) return; } case 59317: // Teleporting + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; @@ -4152,20 +4162,6 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) unitTarget->CastSpell(unitTarget, 59314, true); return; - // random spell learn instead placeholder - case 60893: // Northrend Alchemy Research - case 61177: // Northrend Inscription Research - case 61288: // Minor Inscription Research - case 61756: // Northrend Inscription Research (FAST QA VERSION) - case 64323: // Book of Glyph Mastery - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - // learn random explicit discovery recipe (if any) - if (uint32 discoveredSpell = GetExplicitDiscoverySpell(m_spellInfo->Id, m_caster->ToPlayer())) - m_caster->ToPlayer()->learnSpell(discoveredSpell, false); - return; } case 62482: // Grab Crate { diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 7b3f9a1bef9..0531549cbd3 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -361,7 +361,7 @@ bool SpellEffectInfo::IsAura() const bool SpellEffectInfo::IsAura(AuraType aura) const { - return IsAura() && ApplyAuraName == aura; + return IsAura() && ApplyAuraName == uint32(aura); } bool SpellEffectInfo::IsTargetingArea() const @@ -1020,7 +1020,7 @@ bool SpellInfo::IsPassiveStackableWithRanks() const bool SpellInfo::IsMultiSlotAura() const { - return IsPassive() || Id == 44413; + return IsPassive() || Id == 40075 || Id == 44413; // No other way to make 40075 have more than 1 copy of aura } bool SpellInfo::IsDeathPersistent() const @@ -1127,10 +1127,6 @@ bool SpellInfo::CanPierceImmuneAura(SpellInfo const* aura) const bool SpellInfo::CanDispelAura(SpellInfo const* aura) const { - // These auras (like ressurection sickness) can't be dispelled - if (aura->Attributes & SPELL_ATTR0_NEGATIVE_1) - return false; - // These spells (like Mass Dispel) can dispell all auras if (Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) return true; diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 54430cd7116..2d53c7d8ace 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -67,7 +67,7 @@ enum SpellCastTargetFlags | TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT_ALLY | TARGET_FLAG_UNIT_DEAD | TARGET_FLAG_UNIT_MINIPET | TARGET_FLAG_UNIT_PASSENGER, TARGET_FLAG_GAMEOBJECT_MASK = TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_GAMEOBJECT_ITEM, TARGET_FLAG_CORPSE_MASK = TARGET_FLAG_CORPSE_ALLY | TARGET_FLAG_CORPSE_ENEMY, - TARGET_FLAG_ITEM_MASK = TARGET_FLAG_TRADE_ITEM | TARGET_FLAG_ITEM | TARGET_FLAG_GAMEOBJECT_ITEM, + TARGET_FLAG_ITEM_MASK = TARGET_FLAG_TRADE_ITEM | TARGET_FLAG_ITEM | TARGET_FLAG_GAMEOBJECT_ITEM }; enum SpellTargetSelectionCategories @@ -77,7 +77,7 @@ enum SpellTargetSelectionCategories TARGET_SELECT_CATEGORY_CHANNEL, TARGET_SELECT_CATEGORY_NEARBY, TARGET_SELECT_CATEGORY_CONE, - TARGET_SELECT_CATEGORY_AREA, + TARGET_SELECT_CATEGORY_AREA }; enum SpellTargetReferenceTypes @@ -87,7 +87,7 @@ enum SpellTargetReferenceTypes TARGET_REFERENCE_TYPE_TARGET, TARGET_REFERENCE_TYPE_LAST, TARGET_REFERENCE_TYPE_SRC, - TARGET_REFERENCE_TYPE_DEST, + TARGET_REFERENCE_TYPE_DEST }; enum SpellTargetObjectTypes @@ -103,7 +103,7 @@ enum SpellTargetObjectTypes TARGET_OBJECT_TYPE_CORPSE, // only for effect target type TARGET_OBJECT_TYPE_CORPSE_ENEMY, - TARGET_OBJECT_TYPE_CORPSE_ALLY, + TARGET_OBJECT_TYPE_CORPSE_ALLY }; enum SpellTargetCheckTypes @@ -115,7 +115,7 @@ enum SpellTargetCheckTypes TARGET_CHECK_PARTY, TARGET_CHECK_RAID, TARGET_CHECK_RAID_CLASS, - TARGET_CHECK_PASSENGER, + TARGET_CHECK_PASSENGER }; enum SpellTargetDirectionTypes @@ -130,14 +130,14 @@ enum SpellTargetDirectionTypes TARGET_DIR_BACK_LEFT, TARGET_DIR_FRONT_LEFT, TARGET_DIR_RANDOM, - TARGET_DIR_ENTRY, + TARGET_DIR_ENTRY }; enum SpellEffectImplicitTargetTypes { EFFECT_IMPLICIT_TARGET_NONE = 0, EFFECT_IMPLICIT_TARGET_EXPLICIT, - EFFECT_IMPLICIT_TARGET_CASTER, + EFFECT_IMPLICIT_TARGET_CASTER }; // Spell clasification @@ -165,7 +165,7 @@ enum SpellSpecificType SPELL_SPECIFIC_MAGE_ARCANE_BRILLANCE = 25, SPELL_SPECIFIC_WARRIOR_ENRAGE = 26, SPELL_SPECIFIC_PRIEST_DIVINE_SPIRIT = 27, - SPELL_SPECIFIC_HAND = 28, + SPELL_SPECIFIC_HAND = 28 }; enum SpellCustomAttributes @@ -187,7 +187,7 @@ enum SpellCustomAttributes SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER = 0x00010000, SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET = 0x00020000, - SPELL_ATTR0_CU_NEGATIVE = SPELL_ATTR0_CU_NEGATIVE_EFF0 | SPELL_ATTR0_CU_NEGATIVE_EFF1 | SPELL_ATTR0_CU_NEGATIVE_EFF2, + SPELL_ATTR0_CU_NEGATIVE = SPELL_ATTR0_CU_NEGATIVE_EFF0 | SPELL_ATTR0_CU_NEGATIVE_EFF1 | SPELL_ATTR0_CU_NEGATIVE_EFF2 }; uint32 GetTargetFlagMask(SpellTargetObjectTypes objType); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index e17e71f8869..81807e63fb1 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1135,7 +1135,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 case 68719: // Oil Refinery - Isle of Conquest. case 68720: // Quarry - Isle of Conquest. { - if (player->GetBattlegroundTypeId() != BATTLEGROUND_IC || !player->GetBattleground()) + if (!player || player->GetBattlegroundTypeId() != BATTLEGROUND_IC || !player->GetBattleground()) return false; uint8 nodeType = spellId == 68719 ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY; @@ -3422,6 +3422,9 @@ void SpellMgr::LoadDbcDataCorrections() case 71159: // Awaken Plagued Zombies spellInfo->DurationIndex = 21; break; + case 70530: // Volatile Ooze Beam Protection (Professor Putricide) + spellInfo->Effect[0] = SPELL_EFFECT_APPLY_AURA; // for an unknown reason this was SPELL_EFFECT_APPLY_AREA_AURA_RAID + break; // THIS IS HERE BECAUSE COOLDOWN ON CREATURE PROCS IS NOT IMPLEMENTED case 71604: // Mutated Strength (Professor Putricide) case 72673: // Mutated Strength (Professor Putricide) diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 9c5619ef5f6..9423ebf2893 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -38,8 +38,8 @@ enum SpellCategories SPELLCATEGORY_HEALTH_MANA_POTIONS = 4, SPELLCATEGORY_DEVOUR_MAGIC = 12, SPELLCATEGORY_JUDGEMENT = 1210, // Judgement (seal trigger) - SPELLCATEGORY_FOOD = 11, - SPELLCATEGORY_DRINK = 59, + SPELLCATEGORY_FOOD = 11, + SPELLCATEGORY_DRINK = 59 }; //SpellFamilyFlags @@ -85,7 +85,7 @@ enum SpellFamilyFlag SPELLFAMILYFLAG_DK_DEATH_COIL = 0x00002000, // TODO: Figure out a more accurate name for the following familyflag(s) - SPELLFAMILYFLAG_SHAMAN_TOTEM_EFFECTS = 0x04000000, // Seems to be linked to most totems and some totem effects + SPELLFAMILYFLAG_SHAMAN_TOTEM_EFFECTS = 0x04000000 // Seems to be linked to most totems and some totem effects }; @@ -96,7 +96,7 @@ enum SpellLinkedType SPELL_LINK_CAST = 0, // +: cast; -: remove SPELL_LINK_HIT = 1 * 200000, SPELL_LINK_AURA = 2 * 200000, // +: aura; -: immune - SPELL_LINK_REMOVE = 0, + SPELL_LINK_REMOVE = 0 }; @@ -177,7 +177,7 @@ enum ProcFlags | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG | PROC_FLAG_TAKEN_PERIODIC | PROC_FLAG_TAKEN_DAMAGE, - REQ_SPELL_PHASE_PROC_FLAG_MASK = SPELL_PROC_FLAG_MASK & DONE_HIT_PROC_FLAG_MASK, + REQ_SPELL_PHASE_PROC_FLAG_MASK = SPELL_PROC_FLAG_MASK & DONE_HIT_PROC_FLAG_MASK }; #define MELEE_BASED_TRIGGER_MASK (PROC_FLAG_DONE_MELEE_AUTO_ATTACK | \ @@ -261,12 +261,12 @@ enum ProcFlagsHit PROC_HIT_REFLECT = 0x0000800, PROC_HIT_INTERRUPT = 0x0001000, // (not used atm) PROC_HIT_FULL_BLOCK = 0x0002000, - PROC_HIT_MASK_ALL = 0x2FFF, + PROC_HIT_MASK_ALL = 0x2FFF }; enum ProcAttributes { - PROC_ATTR_REQ_EXP_OR_HONOR = 0x0000010, + PROC_ATTR_REQ_EXP_OR_HONOR = 0x0000010 }; struct SpellProcEventEntry @@ -322,12 +322,12 @@ typedef UNORDERED_MAP<uint32, SpellBonusEntry> SpellBonusMap; enum SpellGroup { - SPELL_GROUP_NONE = 0, - SPELL_GROUP_ELIXIR_BATTLE = 1, - SPELL_GROUP_ELIXIR_GUARDIAN = 2, - SPELL_GROUP_ELIXIR_UNSTABLE = 3, + SPELL_GROUP_NONE = 0, + SPELL_GROUP_ELIXIR_BATTLE = 1, + SPELL_GROUP_ELIXIR_GUARDIAN = 2, + SPELL_GROUP_ELIXIR_UNSTABLE = 3, SPELL_GROUP_ELIXIR_SHATTRATH = 4, - SPELL_GROUP_CORE_RANGE_MAX = 5, + SPELL_GROUP_CORE_RANGE_MAX = 5 }; #define SPELL_GROUP_DB_RANGE_MIN 1000 @@ -342,11 +342,12 @@ typedef std::pair<SpellGroupSpellMap::const_iterator, SpellGroupSpellMap::const_ enum SpellGroupStackRule { - SPELL_GROUP_STACK_RULE_DEFAULT = 0, - SPELL_GROUP_STACK_RULE_EXCLUSIVE = 1, + SPELL_GROUP_STACK_RULE_DEFAULT = 0, + SPELL_GROUP_STACK_RULE_EXCLUSIVE = 1, SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER = 2, - SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT = 3, + SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT = 3 }; + #define SPELL_GROUP_STACK_RULE_MAX 4 typedef std::map<SpellGroup, SpellGroupStackRule> SpellGroupStackMap; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 376e7f18edc..460a4e20d7f 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -47,7 +47,7 @@ enum SpellScriptState SPELL_SCRIPT_STATE_NONE = 0, SPELL_SCRIPT_STATE_REGISTRATION, SPELL_SCRIPT_STATE_LOADING, - SPELL_SCRIPT_STATE_UNLOADING, + SPELL_SCRIPT_STATE_UNLOADING }; #define SPELL_SCRIPT_STATE_END SPELL_SCRIPT_STATE_UNLOADING + 1 @@ -136,7 +136,7 @@ enum SpellScriptHookType SPELL_SCRIPT_HOOK_CHECK_CAST, SPELL_SCRIPT_HOOK_BEFORE_CAST, SPELL_SCRIPT_HOOK_ON_CAST, - SPELL_SCRIPT_HOOK_AFTER_CAST, + SPELL_SCRIPT_HOOK_AFTER_CAST }; #define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT_HIT @@ -425,7 +425,7 @@ enum AuraScriptHookType AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, AURA_SCRIPT_HOOK_CHECK_AREA_TARGET, AURA_SCRIPT_HOOK_DISPEL, - AURA_SCRIPT_HOOK_AFTER_DISPEL, + AURA_SCRIPT_HOOK_AFTER_DISPEL /*AURA_SCRIPT_HOOK_APPLY, AURA_SCRIPT_HOOK_REMOVE, */ }; diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index be8b4063d84..ecf315c059c 100755 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -29,13 +29,13 @@ class ChatHandler; enum GMTicketSystemStatus { GMTICKET_QUEUE_STATUS_DISABLED = 0, - GMTICKET_QUEUE_STATUS_ENABLED = 1, + GMTICKET_QUEUE_STATUS_ENABLED = 1 }; enum GMTicketStatus { GMTICKET_STATUS_HASTEXT = 0x06, - GMTICKET_STATUS_DEFAULT = 0x0A, + GMTICKET_STATUS_DEFAULT = 0x0A }; enum GMTicketResponse @@ -45,7 +45,7 @@ enum GMTicketResponse GMTICKET_RESPONSE_CREATE_ERROR = 3, GMTICKET_RESPONSE_UPDATE_SUCCESS = 4, GMTICKET_RESPONSE_UPDATE_ERROR = 5, - GMTICKET_RESPONSE_TICKET_DELETED = 9, + GMTICKET_RESPONSE_TICKET_DELETED = 9 }; // from Blizzard LUA: @@ -58,14 +58,14 @@ enum GMTicketEscalationStatus TICKET_UNASSIGNED = 0, TICKET_ASSIGNED = 1, TICKET_IN_ESCALATION_QUEUE = 2, - TICKET_ESCALATED_ASSIGNED = 3, + TICKET_ESCALATED_ASSIGNED = 3 }; // from blizzard lua enum GMTicketOpenedByGMStatus { GMTICKET_OPENEDBYGM_STATUS_NOT_OPENED = 0, // ticket has never been opened by a gm - GMTICKET_OPENEDBYGM_STATUS_OPENED = 1, // ticket has been opened by a gm + GMTICKET_OPENEDBYGM_STATUS_OPENED = 1 // ticket has been opened by a gm }; enum LagReportType diff --git a/src/server/game/Tools/PlayerDump.h b/src/server/game/Tools/PlayerDump.h index b5655328507..6662d91fb31 100755 --- a/src/server/game/Tools/PlayerDump.h +++ b/src/server/game/Tools/PlayerDump.h @@ -48,7 +48,7 @@ enum DumpTableType DTT_ITEM_GIFT, // <- item guids // character_gifts DTT_PET, // -> pet guids collection // character_pet - DTT_PET_TABLE, // <- pet guids // pet_aura, pet_spell, pet_spell_cooldown + DTT_PET_TABLE // <- pet guids // pet_aura, pet_spell, pet_spell_cooldown }; enum DumpReturn diff --git a/src/server/game/Warden/Warden.h b/src/server/game/Warden/Warden.h index d16890b31b9..7a8f0f52315 100644 --- a/src/server/game/Warden/Warden.h +++ b/src/server/game/Warden/Warden.h @@ -54,7 +54,7 @@ enum WardenCheckType DRIVER_CHECK = 0x71, // 113: uint Seed + byte[20] SHA1 + byte driverNameIndex (check to ensure driver isn't loaded) TIMING_CHECK = 0x57, // 87: empty (check to ensure GetTickCount() isn't detoured) PROC_CHECK = 0x7E, // 126: uint Seed + byte[20] SHA1 + byte moluleNameIndex + byte procNameIndex + uint Offset + byte Len (check to ensure proc isn't detoured) - MODULE_CHECK = 0xD9, // 217: uint Seed + byte[20] SHA1 (check to ensure module isn't injected) + MODULE_CHECK = 0xD9 // 217: uint Seed + byte[20] SHA1 (check to ensure module isn't injected) }; #if defined(__GNUC__) diff --git a/src/server/game/Weather/Weather.h b/src/server/game/Weather/Weather.h index dadd1151a53..59bff95d7ea 100755 --- a/src/server/game/Weather/Weather.h +++ b/src/server/game/Weather/Weather.h @@ -57,7 +57,7 @@ enum WeatherState WEATHER_STATE_HEAVY_SANDSTORM = 42, WEATHER_STATE_THUNDERS = 86, WEATHER_STATE_BLACKRAIN = 90, - WEATHER_STATE_BLACKSNOW = 106, + WEATHER_STATE_BLACKSNOW = 106 }; /// Weather for one zone diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index f310934ac08..1d1fb45b74e 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1194,6 +1194,11 @@ void World::LoadConfigSettings(bool reload) m_bool_configs[CONFIG_AUTOBROADCAST] = ConfigMgr::GetBoolDefault("AutoBroadcast.On", false); m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = ConfigMgr::GetIntDefault("AutoBroadcast.Center", 0); m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL] = ConfigMgr::GetIntDefault("AutoBroadcast.Timer", 60000); + if (reload) + { + m_timers[WUPDATE_AUTOBROADCAST].SetInterval(m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL]); + m_timers[WUPDATE_AUTOBROADCAST].Reset(); + } // MySQL ping time interval m_int_configs[CONFIG_DB_PING_INTERVAL] = ConfigMgr::GetIntDefault("MaxPingTime", 30); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 8a1b3b4ae31..90bb82f1c2e 100755 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -55,14 +55,14 @@ enum ServerMessageType enum ShutdownMask { SHUTDOWN_MASK_RESTART = 1, - SHUTDOWN_MASK_IDLE = 2, + SHUTDOWN_MASK_IDLE = 2 }; enum ShutdownExitCode { SHUTDOWN_EXIT_CODE = 0, ERROR_EXIT_CODE = 1, - RESTART_EXIT_CODE = 2, + RESTART_EXIT_CODE = 2 }; /// Timers for different object refresh rates @@ -409,18 +409,18 @@ enum BillingPlanFlags SESSION_USAGE = 0x10, SESSION_TIME_MIXTURE = 0x20, SESSION_RESTRICTED = 0x40, - SESSION_ENABLE_CAIS = 0x80, + SESSION_ENABLE_CAIS = 0x80 }; /// Type of server, this is values from second column of Cfg_Configs.dbc enum RealmType { - REALM_TYPE_NORMAL = 0, - REALM_TYPE_PVP = 1, - REALM_TYPE_NORMAL2 = 4, - REALM_TYPE_RP = 6, - REALM_TYPE_RPPVP = 8, - REALM_TYPE_FFA_PVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries + REALM_TYPE_NORMAL = 0, + REALM_TYPE_PVP = 1, + REALM_TYPE_NORMAL2 = 4, + REALM_TYPE_RP = 6, + REALM_TYPE_RPPVP = 8, + REALM_TYPE_FFA_PVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries // replaced by REALM_PVP in realm list }; diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp index ade1b9fae02..4f503fdbb76 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -41,6 +41,7 @@ public: { "cooldown", SEC_GAMEMASTER, false, &HandleCoolDownCheatCommand, "", NULL }, { "power", SEC_GAMEMASTER, false, &HandlePowerCheatCommand, "", NULL }, { "waterwalk", SEC_GAMEMASTER, false, &HandleWaterWalkCheatCommand, "", NULL }, + { "status", SEC_GAMEMASTER, false, &HandleCheatStatusCommand, "", NULL }, { "taxi", SEC_GAMEMASTER, false, &HandleTaxiCheatCommand, "", NULL }, { "explore", SEC_GAMEMASTER, false, &HandleExploreCheatCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } @@ -159,6 +160,22 @@ public: return false; } + static bool HandleCheatStatusCommand(ChatHandler* handler, const char* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); + + const char* enabled = "enabled"; + const char* disabled = "disabled"; + + handler->SendSysMessage(LANG_COMMAND_CHEAT_STATUS); + handler->PSendSysMessage(LANG_COMMAND_CHEAT_GOD, player->GetCommandStatus(CHEAT_GOD) ? enabled : disabled); + handler->PSendSysMessage(LANG_COMMAND_CHEAT_CD, player->GetCommandStatus(CHEAT_COOLDOWN) ? enabled : disabled); + handler->PSendSysMessage(LANG_COMMAND_CHEAT_CT, player->GetCommandStatus(CHEAT_CASTTIME) ? enabled : disabled); + handler->PSendSysMessage(LANG_COMMAND_CHEAT_POWER, player->GetCommandStatus(CHEAT_POWER) ? enabled : disabled); + handler->PSendSysMessage(LANG_COMMAND_CHEAT_WW, player->GetCommandStatus(CHEAT_WATERWALK) ? enabled : disabled); + return true; + } + static bool HandleWaterWalkCheatCommand(ChatHandler* handler, const char* args) { if (!handler->GetSession() && !handler->GetSession()->GetPlayer()) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index fa4b0ce3957..2c9623b23a6 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ -
+ #include "Chat.h" #include "ScriptMgr.h" #include "AccountMgr.h" @@ -29,12 +29,12 @@ #include "TargetedMovementGenerator.h" #include "WeatherMgr.h" #include "ace/INET_Addr.h" -
+ class misc_commandscript : public CommandScript { public: misc_commandscript() : CommandScript("misc_commandscript") { } -
+ ChatCommand* GetCommands() const { static ChatCommand groupCommandTable[] = @@ -81,7 +81,7 @@ public: { "save", SEC_PLAYER, false, &HandleSaveCommand, "", NULL }, { "saveall", SEC_MODERATOR, true, &HandleSaveAllCommand, "", NULL }, { "kick", SEC_GAMEMASTER, true, &HandleKickPlayerCommand, "", NULL }, - { "start", SEC_PLAYER, false, &HandleStartCommand, "", NULL }, + { "unstuck", SEC_PLAYER, true, &HandleUnstuckCommand, "", NULL }, { "linkgrave", SEC_ADMINISTRATOR, false, &HandleLinkGraveCommand, "", NULL }, { "neargrave", SEC_ADMINISTRATOR, false, &HandleNearGraveCommand, "", NULL }, { "showarea", SEC_ADMINISTRATOR, false, &HandleShowAreaCommand, "", NULL }, @@ -117,7 +117,7 @@ public: }; return commandTable; } -
+ static bool HandleDevCommand(ChatHandler* handler, char const* args) { if (!*args) @@ -128,28 +128,28 @@ public: handler->GetSession()->SendNotification(LANG_DEV_OFF); return true; } -
+ std::string argstr = (char*)args; -
+ if (argstr == "on") { handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); handler->GetSession()->SendNotification(LANG_DEV_ON); return true; } -
+ if (argstr == "off") { handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); handler->GetSession()->SendNotification(LANG_DEV_OFF); return true; } -
+ handler->SendSysMessage(LANG_USE_BOL); handler->SetSentErrorMessage(true); return false; } -
+ static bool HandleGPSCommand(ChatHandler* handler, char const* args) { WorldObject* object = NULL; @@ -158,7 +158,7 @@ public: uint64 guid = handler->extractGuidFromLink((char*)args); if (guid) object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); -
+ if (!object) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -169,7 +169,7 @@ public: else { object = handler->getSelectedUnit(); -
+ if (!object) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); @@ -177,35 +177,35 @@ public: return false; } } -
+ CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()); Cell cell(cellCoord); -
+ uint32 zoneId, areaId; object->GetZoneAndAreaId(zoneId, areaId); -
+ MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId()); AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId); AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId); -
+ float zoneX = object->GetPositionX(); float zoneY = object->GetPositionY(); -
+ Map2ZoneCoordinates(zoneX, zoneY, zoneId); -
+ Map const* map = object->GetMap(); float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT); float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()); -
+ GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY()); -
+ // 63? WHY? int gridX = 63 - gridCoord.x_coord; int gridY = 63 - gridCoord.y_coord; -
+ uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0; uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0; -
+ if (haveVMap) { if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ())) @@ -215,7 +215,7 @@ public: } else handler->PSendSysMessage("no VMAP available for area info"); -
+ handler->PSendSysMessage(LANG_MAP_POSITION, object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"), zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), @@ -224,16 +224,16 @@ public: object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(), zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap); -
+ LiquidData liquidStatus; ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus); -
+ if (status) handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status); -
+ return true; } -
+ static bool HandleAuraCommand(ChatHandler* handler, char const* args) { Unit* target = handler->getSelectedUnit(); @@ -243,16 +243,16 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); -
+ if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, target, target); -
+ return true; } -
+ static bool HandleUnAuraCommand(ChatHandler* handler, char const* args) { Unit* target = handler->getSelectedUnit(); @@ -262,21 +262,21 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ std::string argstr = args; if (argstr == "all") { target->RemoveAllAuras(); return true; } -
+ // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); if (!spellId) return false; -
+ target->RemoveAurasDueToSpell(spellId); -
+ return true; } // Teleport to Player @@ -287,7 +287,7 @@ public: std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; -
+ Player* _player = handler->GetSession()->GetPlayer(); if (target == _player || targetGuid == _player->GetGUID()) { @@ -295,15 +295,15 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (target) { // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ std::string chrNameLink = handler->playerLink(targetName); -
+ Map* map = target->GetMap(); if (map->IsBattlegroundOrArena()) { @@ -317,7 +317,7 @@ public: // if both players are in different bgs else if (_player->GetBattlegroundId() && _player->GetBattlegroundId() != target->GetBattlegroundId()) _player->LeaveBattleground(false); // Note: should be changed so _player gets no Deserter debuff -
+ // all's well, set bg id // when porting out from the bg, it will be reset to 0 _player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId()); @@ -350,7 +350,7 @@ public: return false; } } -
+ // if the player or the player's group is bound to another instance // the player will not be bound to another one InstancePlayerBind* bind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(map->IsRaid())); @@ -363,15 +363,15 @@ public: if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId())) _player->BindToInstance(save, !save->CanReset()); } -
+ if (map->IsRaid()) _player->SetRaidDifficulty(target->GetRaidDifficulty()); else _player->SetDungeonDifficulty(target->GetDungeonDifficulty()); } -
+ handler->PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str()); -
+ // stop flight if need if (_player->isInFlight()) { @@ -381,11 +381,11 @@ public: // save only in non-flight case else _player->SaveRecallPosition(); -
+ // to point to see at target with same orientation float x, y, z; target->GetContactPoint(_player, x, y, z); -
+ _player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE); _player->SetPhaseMask(target->GetPhaseMask(), true); } @@ -394,18 +394,18 @@ public: // check offline security if (handler->HasLowerSecurity(NULL, targetGuid)) return false; -
+ std::string nameLink = handler->playerLink(targetName); -
+ handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str()); -
+ // to point where player stay (if loaded) float x, y, z, o; uint32 map; bool in_flight; if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid)) return false; -
+ // stop flight if need if (_player->isInFlight()) { @@ -415,10 +415,10 @@ public: // save only in non-flight case else _player->SaveRecallPosition(); -
+ _player->TeleportTo(map, x, y, z, _player->GetOrientation()); } -
+ return true; } // Summon Player @@ -429,7 +429,7 @@ public: std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; -
+ Player* _player = handler->GetSession()->GetPlayer(); if (target == _player || targetGuid == _player->GetGUID()) { @@ -437,23 +437,23 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (target) { std::string nameLink = handler->playerLink(targetName); // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ if (target->IsBeingTeleported()) { handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str()); handler->SetSentErrorMessage(true); return false; } -
+ Map* map = handler->GetSession()->GetPlayer()->GetMap(); -
+ if (map->IsBattlegroundOrArena()) { // only allow if gm mode is on @@ -466,7 +466,7 @@ public: // if both players are in different bgs else if (target->GetBattlegroundId() && handler->GetSession()->GetPlayer()->GetBattlegroundId() != target->GetBattlegroundId()) target->LeaveBattleground(false); // Note: should be changed so target gets no Deserter debuff -
+ // all's well, set bg id // when porting out from the bg, it will be reset to 0 target->SetBattlegroundId(handler->GetSession()->GetPlayer()->GetBattlegroundId(), handler->GetSession()->GetPlayer()->GetBattlegroundTypeId()); @@ -477,10 +477,10 @@ public: else if (map->IsDungeon()) { Map* map = target->GetMap(); -
+ if (map->Instanceable() && map->GetInstanceId() != map->GetInstanceId()) target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true); -
+ // we are in instance, and can summon only player in our group with us as lead if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() || (target->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) || @@ -492,11 +492,11 @@ public: return false; } } -
+ handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); if (handler->needReportToTarget(target)) ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str()); -
+ // stop flight if need if (target->isInFlight()) { @@ -506,7 +506,7 @@ public: // save only in non-flight case else target->SaveRecallPosition(); -
+ // before GM float x, y, z; handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize()); @@ -518,11 +518,11 @@ public: // check offline security if (handler->HasLowerSecurity(NULL, targetGuid)) return false; -
+ std::string nameLink = handler->playerLink(targetName); -
+ handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE)); -
+ // in point where GM stay Player::SavePositionInDB(handler->GetSession()->GetPlayer()->GetMapId(), handler->GetSession()->GetPlayer()->GetPositionX(), @@ -532,7 +532,7 @@ public: handler->GetSession()->GetPlayer()->GetZoneId(), targetGuid); } -
+ return true; } // Summon group of player @@ -541,25 +541,25 @@ public: Player* target; if (!handler->extractPlayerTarget((char*)args, &target)) return false; -
+ // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ Group* group = target->GetGroup(); -
+ std::string nameLink = handler->GetNameLink(target); -
+ if (!group) { handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); handler->SetSentErrorMessage(true); return false; } -
+ Map* gmMap = handler->GetSession()->GetPlayer()->GetMap(); bool toInstance = gmMap->Instanceable(); -
+ // we are in instance, and can summon only player in our group with us as lead if (toInstance && ( !handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) || @@ -570,31 +570,31 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* player = itr->getSource(); -
+ if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession()) continue; -
+ // check online security if (handler->HasLowerSecurity(player, 0)) return false; -
+ std::string plNameLink = handler->GetNameLink(player); -
+ if (player->IsBeingTeleported() == true) { handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); handler->SetSentErrorMessage(true); return false; } -
+ if (toInstance) { Map* playerMap = player->GetMap(); -
+ if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId()) { // cannot summon from instance to instance @@ -603,11 +603,11 @@ public: return false; } } -
+ handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); if (handler->needReportToTarget(player)) ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str()); -
+ // stop flight if need if (player->isInFlight()) { @@ -617,39 +617,39 @@ public: // save only in non-flight case else player->SaveRecallPosition(); -
+ // before GM float x, y, z; handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize()); player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation()); } -
+ return true; } -
+ static bool HandleCommandsCommand(ChatHandler* handler, char const* /*args*/) { handler->ShowHelpForCommand(handler->getCommandTable(), ""); return true; } -
+ static bool HandleDieCommand(ChatHandler* handler, char const* /*args*/) { Unit* target = handler->getSelectedUnit(); -
+ if (!target || !handler->GetSession()->GetPlayer()->GetSelection()) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); handler->SetSentErrorMessage(true); return false; } -
+ if (target->GetTypeId() == TYPEID_PLAYER) { if (handler->HasLowerSecurity((Player*)target, 0, false)) return false; } -
+ if (target->isAlive()) { if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE)) @@ -657,17 +657,17 @@ public: else handler->GetSession()->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } -
+ return true; } -
+ static bool HandleReviveCommand(ChatHandler* handler, char const* args) { Player* target; uint64 targetGuid; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) return false; -
+ if (target) { target->ResurrectPlayer(!AccountMgr::IsPlayerAccount(target->GetSession()->GetSecurity()) ? 1.0f : 0.5f); @@ -677,14 +677,14 @@ public: else // will resurrected at login without corpse sObjectAccessor->ConvertCorpseForPlayer(targetGuid); -
+ return true; } -
+ static bool HandleDismountCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); -
+ // If player is not mounted, so go out :) if (!player->IsMounted()) { @@ -692,34 +692,34 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (player->isInFlight()) { handler->SendSysMessage(LANG_YOU_IN_FLIGHT); handler->SetSentErrorMessage(true); return false; } -
+ player->Dismount(); player->RemoveAurasByType(SPELL_AURA_MOUNTED); return true; } -
+ static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/) { uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); -
+ if (guid == 0) { handler->SendSysMessage(LANG_NO_SELECTION); handler->SetSentErrorMessage(true); return false; } -
+ handler->PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid)); return true; } -
+ static bool HandleHelpCommand(ChatHandler* handler, char const* args) { char const* cmd = strtok((char*)args, " "); @@ -733,7 +733,7 @@ public: if (!handler->ShowHelpForCommand(handler->getCommandTable(), cmd)) handler->SendSysMessage(LANG_NO_HELP_CMD); } -
+ return true; } // move item to other slot @@ -741,35 +741,35 @@ public: { if (!*args) return false; -
+ char const* param1 = strtok((char*)args, " "); if (!param1) return false; -
+ char const* param2 = strtok(NULL, " "); if (!param2) return false; -
+ uint8 srcSlot = uint8(atoi(param1)); uint8 dstSlot = uint8(atoi(param2)); -
+ if (srcSlot == dstSlot) return true; -
+ if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcSlot, true)) return false; -
+ if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, dstSlot, false)) return false; -
+ uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcSlot); uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstSlot); -
+ handler->GetSession()->GetPlayer()->SwapItem(src, dst); -
+ return true; } -
+ static bool HandleCooldownCommand(ChatHandler* handler, char const* args) { Player* target = handler->getSelectedPlayer(); @@ -779,9 +779,9 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ std::string nameLink = handler->GetNameLink(target); -
+ if (!*args) { target->RemoveAllSpellCooldown(); @@ -793,30 +793,30 @@ public: uint32 spellIid = handler->extractSpellIdFromLink((char*)args); if (!spellIid) return false; -
+ if (!sSpellMgr->GetSpellInfo(spellIid)) { handler->PSendSysMessage(LANG_UNKNOWN_SPELL, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str()); handler->SetSentErrorMessage(true); return false; } -
+ target->RemoveSpellCooldown(spellIid, true); handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str()); } return true; } -
+ static bool HandleGetDistanceCommand(ChatHandler* handler, char const* args) { WorldObject* obj = NULL; -
+ if (*args) { uint64 guid = handler->extractGuidFromLink((char*)args); if (guid) obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT); -
+ if (!obj) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -827,7 +827,7 @@ public: else { obj = handler->getSelectedUnit(); -
+ if (!obj) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); @@ -835,7 +835,7 @@ public: return false; } } -
+ handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(obj), handler->GetSession()->GetPlayer()->GetDistance2d(obj), handler->GetSession()->GetPlayer()->GetExactDist(obj), handler->GetSession()->GetPlayer()->GetExactDist2d(obj)); return true; } @@ -845,33 +845,33 @@ public: Player* target; if (!handler->extractPlayerTarget((char*)args, &target)) return false; -
+ // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ if (target->IsBeingTeleported()) { handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->GetNameLink(target).c_str()); handler->SetSentErrorMessage(true); return false; } -
+ // stop flight if need if (target->isInFlight()) { target->GetMotionMaster()->MovementExpired(); target->CleanupAfterTaxiFlight(); } -
+ target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO); return true; } -
+ static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); -
+ // save GM account without delay and output message if (!AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity())) { @@ -882,15 +882,15 @@ public: handler->SendSysMessage(LANG_PLAYER_SAVED); return true; } -
+ // save if the player has last been saved over 20 seconds ago uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE); if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS)) player->SaveToDB(); -
+ return true; } -
+ // Save all players in the world static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/) { @@ -898,7 +898,7 @@ public: handler->SendSysMessage(LANG_PLAYERS_SAVED); return true; } -
+ // kick player static bool HandleKickPlayerCommand(ChatHandler* handler, char const* args) { @@ -906,73 +906,106 @@ public: std::string playerName; if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName)) return false; -
+ if (handler->GetSession() && target == handler->GetSession()->GetPlayer()) { handler->SendSysMessage(LANG_COMMAND_KICKSELF); handler->SetSentErrorMessage(true); return false; } -
+ // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD)) sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); else handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); -
+ target->GetSession()->KickPlayer(); -
+ return true; } -
- static bool HandleStartCommand(ChatHandler* handler, char const* /*args*/) + + static bool HandleUnstuckCommand(ChatHandler* handler, char const* args) { - Player* player = handler->GetSession()->GetPlayer(); -
- if (player->isInFlight()) + //No args required for players + if (handler->GetSession() && AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity())) { - handler->SendSysMessage(LANG_YOU_IN_FLIGHT); - handler->SetSentErrorMessage(true); - return false; + Player* player = handler->GetSession()->GetPlayer(); + if (player->isInFlight() || player->isInCombat()) + { + handler->SendSysMessage(LANG_CANT_DO_NOW); + handler->SetSentErrorMessage(true); + return false; + } + + //7355: "Stuck" + player->CastSpell(player, 7355, false); + return true; } -
- if (player->isInCombat()) + + if (!*args) + return false; + + char* player_str = strtok((char*)args, " "); + if (!player_str) + return false; + + std::string location_str = "inn"; + if (char const* loc = strtok(NULL, " ")) + location_str = loc; + + Player* player = NULL; + if (!handler->extractPlayerTarget(player_str, &player)) + return false; + + if (player->isInFlight() || player->isInCombat()) { - handler->SendSysMessage(LANG_YOU_IN_COMBAT); + handler->SendSysMessage(LANG_CANT_DO_NOW); handler->SetSentErrorMessage(true); return false; } -
- if (player->isDead() || player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + + if (location_str == "inn") + { + player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation()); + return true; + } + + if (location_str == "graveyard") { - // if player is dead and stuck, send ghost to graveyard player->RepopAtGraveyard(); return true; } -
- // cast spell Stuck - player->CastSpell(player, 7355, false); - return true; + + if (location_str == "startzone") + { + player->TeleportTo(player->GetStartPosition()); + return true; + } + + //Not a supported argument + return false; + } -
+ static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ char* px = strtok((char*)args, " "); if (!px) return false; -
+ uint32 graveyardId = uint32(atoi(px)); -
+ uint32 team; -
+ char* px2 = strtok(NULL, " "); -
+ if (!px2) team = 0; else if (strncmp(px2, "horde", 6) == 0) @@ -981,20 +1014,20 @@ public: team = ALLIANCE; else return false; -
+ WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(graveyardId); -
+ if (!graveyard) { handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId); handler->SetSentErrorMessage(true); return false; } -
+ Player* player = handler->GetSession()->GetPlayer(); -
+ uint32 zoneId = player->GetZoneId(); -
+ AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(zoneId); if (!areaEntry || areaEntry->zone !=0) { @@ -1002,21 +1035,21 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (sObjectMgr->AddGraveYardLink(graveyardId, zoneId, team)) handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId); else handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId); -
+ return true; } -
+ static bool HandleNearGraveCommand(ChatHandler* handler, char const* args) { uint32 team; -
+ size_t argStr = strlen(args); -
+ if (!*args) team = 0; else if (strncmp((char*)args, "horde", argStr) == 0) @@ -1025,17 +1058,17 @@ public: team = ALLIANCE; else return false; -
+ Player* player = handler->GetSession()->GetPlayer(); uint32 zone_id = player->GetZoneId(); -
+ WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard( player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team); -
+ if (graveyard) { uint32 graveyardId = graveyard->ID; -
+ GraveYardData const* data = sObjectMgr->FindGraveYardData(graveyardId, zone_id); if (!data) { @@ -1043,45 +1076,45 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ team = data->team; -
+ std::string team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM); -
+ if (team == 0) team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); else if (team == HORDE) team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); else if (team == ALLIANCE) team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); -
+ handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name.c_str(), zone_id); } else { std::string team_name; -
+ if (team == 0) team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); else if (team == HORDE) team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); else if (team == ALLIANCE) team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); -
+ if (team == ~uint32(0)) handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id); else handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str()); } -
+ return true; } -
+ static bool HandleShowAreaCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ Player* playerTarget = handler->getSelectedPlayer(); if (!playerTarget) { @@ -1089,30 +1122,30 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ int32 area = GetAreaFlagByAreaID(atoi((char*)args)); int32 offset = area / 32; uint32 val = uint32((1 << (area % 32))); -
+ if (area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } -
+ uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields | val))); -
+ handler->SendSysMessage(LANG_EXPLORE_AREA); return true; } -
+ static bool HandleHideAreaCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ Player* playerTarget = handler->getSelectedPlayer(); if (!playerTarget) { @@ -1120,45 +1153,45 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ int32 area = GetAreaFlagByAreaID(atoi((char*)args)); int32 offset = area / 32; uint32 val = uint32((1 << (area % 32))); -
+ if (area < 0 || offset >= PLAYER_EXPLORED_ZONES_SIZE) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } -
+ uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields ^ val))); -
+ handler->SendSysMessage(LANG_UNEXPLORE_AREA); return true; } -
+ static bool HandleAddItemCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ uint32 itemId = 0; -
+ if (args[0] == '[') // [name] manual form { char const* itemNameStr = strtok((char*)args, "]"); -
+ if (itemNameStr && itemNameStr[0]) { std::string itemName = itemNameStr+1; WorldDatabase.EscapeString(itemName); -
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME); stmt->setString(0, itemName); PreparedQueryResult result = WorldDatabase.Query(stmt); -
+ if (!result) { handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, itemNameStr+1); @@ -1177,24 +1210,24 @@ public: return false; itemId = uint32(atol(id)); } -
+ char const* ccount = strtok(NULL, " "); -
+ int32 count = 1; -
+ if (ccount) count = strtol(ccount, NULL, 10); -
+ if (count == 0) count = 1; -
+ Player* player = handler->GetSession()->GetPlayer(); Player* playerTarget = handler->getSelectedPlayer(); if (!playerTarget) playerTarget = player; -
+ sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEM), itemId, count); -
+ ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId); if (!itemTemplate) { @@ -1202,7 +1235,7 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ // Subtract if (count < 0) { @@ -1210,55 +1243,55 @@ public: handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str()); return true; } -
+ // Adding items uint32 noSpaceForCount = 0; -
+ // check space and find places ItemPosCountVec dest; InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; -
+ if (count == 0 || dest.empty()) // can't add any { handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); handler->SetSentErrorMessage(true); return false; } -
+ Item* item = playerTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); -
+ // remove binding (let GM give it to another player later) if (player == playerTarget) for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) if (Item* item1 = player->GetItemByPos(itr->pos)) item1->SetBinding(false); -
+ if (count > 0 && item) { player->SendNewItem(item, count, false, true); if (player != playerTarget) playerTarget->SendNewItem(item, count, true, false); } -
+ if (noSpaceForCount > 0) handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); -
+ return true; } -
+ static bool HandleAddItemSetCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ char const* id = handler->extractKeyFromLink((char*)args, "Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r if (!id) return false; -
+ uint32 itemSetId = atol(id); -
+ // prevent generation all items with itemset field value '0' if (itemSetId == 0) { @@ -1266,14 +1299,14 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ Player* player = handler->GetSession()->GetPlayer(); Player* playerTarget = handler->getSelectedPlayer(); if (!playerTarget) playerTarget = player; -
+ sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEMSET), itemSetId); -
+ bool found = false; ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr) @@ -1286,11 +1319,11 @@ public: if (msg == EQUIP_ERR_OK) { Item* item = playerTarget->StoreNewItem(dest, itr->second.ItemId, true); -
+ // remove binding (let GM give it to another player later) if (player == playerTarget) item->SetBinding(false); -
+ player->SendNewItem(item, 1, false, true); if (player != playerTarget) playerTarget->SendNewItem(item, 1, true, false); @@ -1302,28 +1335,28 @@ public: } } } -
+ if (!found) { handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId); handler->SetSentErrorMessage(true); return false; } -
+ return true; } -
+ static bool HandleBankCommand(ChatHandler* handler, char const* /*args*/) { handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID()); return true; } -
+ static bool HandleChangeWeather(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ // Weather is OFF if (!sWorld->getBoolConfig(CONFIG_WEATHER)) { @@ -1331,22 +1364,22 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ // *Change the weather of a cell char const* px = strtok((char*)args, " "); char const* py = strtok(NULL, " "); -
+ if (!px || !py) return false; -
+ uint32 type = uint32(atoi(px)); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand float grade = float(atof(py)); //0 to 1, sending -1 is instand good weather -
+ Player* player = handler->GetSession()->GetPlayer(); uint32 zoneid = player->GetZoneId(); -
+ Weather* weather = WeatherMgr::FindWeather(zoneid); -
+ if (!weather) weather = WeatherMgr::AddWeather(zoneid); if (!weather) @@ -1355,12 +1388,12 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ weather->SetWeather(WeatherType(type), grade); -
+ return true; } -
+ static bool HandleMaxSkillCommand(ChatHandler* handler, char const* /*args*/) { @@ -1371,25 +1404,25 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ // each skills that have max skill value dependent from level seted to current level max skill value SelectedPlayer->UpdateSkillsToMaxSkillsForLevel(); return true; } -
+ static bool HandleSetSkillCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r char const* skillStr = handler->extractKeyFromLink((char*)args, "Hskill"); if (!skillStr) return false; -
+ char const* levelStr = strtok(NULL, " "); if (!levelStr) return false; -
+ char const* maxPureSkill = strtok(NULL, " "); -
+ int32 skill = atoi(skillStr); if (skill <= 0) { @@ -1397,9 +1430,9 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ int32 level = uint32(atol(levelStr)); -
+ Player* target = handler->getSelectedPlayer(); if (!target) { @@ -1407,7 +1440,7 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skill); if (!skillLine) { @@ -1415,24 +1448,24 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ std::string tNameLink = handler->GetNameLink(target); -
+ if (!target->GetSkillValue(skill)) { handler->PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, skillLine->name[handler->GetSessionDbcLocale()]); handler->SetSentErrorMessage(true); return false; } -
+ uint16 max = maxPureSkill ? atol (maxPureSkill) : target->GetPureMaxSkillValue(skill); -
+ if (level <= 0 || level > max || max <= 0) return false; -
+ target->SetSkill(skill, target->GetSkillStep(skill), level, max); handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->name[handler->GetSessionDbcLocale()], tNameLink.c_str(), level, max); -
+ return true; } // show info of player @@ -1441,9 +1474,9 @@ public: Player* target; uint64 targetGuid; std::string targetName; -
+ uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); -
+ if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName)) { target = sObjectMgr->GetPlayerByLowGUID(parseGUID); @@ -1451,7 +1484,7 @@ public: } else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; -
+ uint32 accId = 0; uint32 money = 0; uint32 totalPlayerTime = 0; @@ -1464,14 +1497,14 @@ public: uint32 mapId; uint32 areaId; uint32 phase = 0; -
+ // get additional information from Player object if (target) { // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ accId = target->GetSession()->GetAccountId(); money = target->GetMoney(); totalPlayerTime = target->GetTotalPlayedTime(); @@ -1490,14 +1523,14 @@ public: // check offline security if (handler->HasLowerSecurity(NULL, targetGuid)) return false; -
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO); stmt->setUInt32(0, GUID_LOPART(targetGuid)); PreparedQueryResult result = CharacterDatabase.Query(stmt); -
+ if (!result) return false; -
+ Field* fields = result->Fetch(); totalPlayerTime = fields[0].GetUInt32(); level = fields[1].GetUInt8(); @@ -1508,18 +1541,18 @@ public: mapId = fields[6].GetUInt16(); areaId = fields[7].GetUInt16(); } -
+ std::string userName = handler->GetTrinityString(LANG_ERROR); std::string eMail = handler->GetTrinityString(LANG_ERROR); std::string lastIp = handler->GetTrinityString(LANG_ERROR); uint32 security = 0; std::string lastLogin = handler->GetTrinityString(LANG_ERROR); -
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO); stmt->setInt32(0, int32(realmID)); stmt->setUInt32(1, accId); PreparedQueryResult result = LoginDatabase.Query(stmt); -
+ if (result) { Field* fields = result->Fetch(); @@ -1527,26 +1560,26 @@ public: security = fields[1].GetUInt8(); eMail = fields[2].GetString(); muteTime = fields[5].GetUInt64(); -
+ if (eMail.empty()) eMail = "-"; -
+ if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security)) { lastIp = fields[3].GetString(); lastLogin = fields[4].GetString(); -
+ uint32 ip = inet_addr(lastIp.c_str()); #if TRINITY_ENDIAN == BIGENDIAN EndianConvertReverse(ip); #endif -
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY); -
+ stmt->setUInt32(0, ip); -
+ PreparedQueryResult result2 = WorldDatabase.Query(stmt); -
+ if (result2) { Field* fields2 = result2->Fetch(); @@ -1561,14 +1594,14 @@ public: lastLogin = "-"; } } -
+ std::string nameLink = handler->playerLink(targetName); -
+ handler->PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : handler->GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(targetGuid), userName.c_str(), accId, eMail.c_str(), security, lastIp.c_str(), lastLogin.c_str(), latency); -
+ std::string bannedby = "unknown"; std::string banreason = ""; -
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS); stmt->setUInt32(0, accId); PreparedQueryResult result2 = LoginDatabase.Query(stmt); @@ -1578,7 +1611,7 @@ public: stmt->setUInt32(0, GUID_LOPART(targetGuid)); result2 = CharacterDatabase.Query(stmt); } -
+ if (result2) { Field* fields = result2->Fetch(); @@ -1586,13 +1619,13 @@ public: bannedby = fields[2].GetString(); banreason = fields[3].GetString(); } -
+ if (muteTime > 0) handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str()); -
+ if (banTime >= 0) handler->PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str()); -
+ std::string raceStr, ClassStr; switch (race) { @@ -1627,7 +1660,7 @@ public: raceStr = "Draenei"; break; } -
+ switch (Class) { case CLASS_WARRIOR: @@ -1661,30 +1694,30 @@ public: ClassStr = "Druid"; break; } -
+ std::string timeStr = secsToTimeString(totalPlayerTime, true, true); uint32 gold = money /GOLD; uint32 silv = (money % GOLD) / SILVER; uint32 copp = (money % GOLD) % SILVER; handler->PSendSysMessage(LANG_PINFO_LEVEL, raceStr.c_str(), ClassStr.c_str(), timeStr.c_str(), level, gold, silv, copp); -
+ // Add map, zone, subzone and phase to output int locale = handler->GetSessionDbcLocale(); std::string areaName = "<unknown>"; std::string zoneName = ""; -
+ MapEntry const* map = sMapStore.LookupEntry(mapId); -
+ AreaTableEntry const* area = GetAreaEntryByAreaID(areaId); if (area) { areaName = area->area_name[locale]; -
+ AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); if (zone) zoneName = zone->area_name[locale]; } -
+ if (target) { if (!zoneName.empty()) @@ -1694,14 +1727,14 @@ public: } else handler->PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str()); -
+ return true; } -
+ static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); -
+ // accept only explicitly selected target (not implicitly self targeting case) Unit* target = handler->getSelectedUnit(); if (player->GetSelection() && target) @@ -1712,22 +1745,22 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (target->isDead()) target->ToCreature()->Respawn(); return true; } -
+ CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY())); Cell cell(p); cell.SetNoCreate(); -
+ Trinity::RespawnDo u_do; Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do); -
+ TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange()); -
+ return true; } // mute player for some times @@ -1738,33 +1771,33 @@ public: handler->extractOptFirstArg((char*)args, &nameStr, &delayStr); if (!delayStr) return false; -
+ char const* muteReason = strtok(NULL, "\r"); std::string muteReasonStr = "No reason"; if (muteReason != NULL) muteReasonStr = muteReason; -
+ Player* target; uint64 targetGuid; std::string targetName; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) return false; -
+ uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); -
+ // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(accountId)) target = session->GetPlayer(); -
+ uint32 notSpeakTime = uint32(atoi(delayStr)); -
+ // must have strong lesser security level if (handler->HasLowerSecurity (target, targetGuid, true)) return false; -
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); -
+ if (target) { // Target is online, mute will be in effect right away. @@ -1779,16 +1812,16 @@ public: int32 muteTime = -int32(notSpeakTime * MINUTE); stmt->setInt64(0, muteTime); } -
+ stmt->setUInt32(1, accountId); LoginDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); -
+ handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); -
+ return true; } -
+ // unmute player static bool HandleUnmuteCommand(ChatHandler* handler, char const* args) { @@ -1797,18 +1830,18 @@ public: std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; -
+ uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); -
+ // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(accountId)) target = session->GetPlayer(); -
+ // must have strong lesser security level if (handler->HasLowerSecurity (target, targetGuid, true)) return false; -
+ if (target) { if (target->CanSpeak()) @@ -1817,25 +1850,25 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ target->GetSession()->m_muteTime = 0; } -
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); stmt->setInt64(0, 0); stmt->setUInt32(1, accountId); LoginDatabase.Execute(stmt); -
+ if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); -
+ std::string nameLink = handler->playerLink(targetName); -
+ handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str()); -
+ return true; } -
+ static bool HandleMovegensCommand(ChatHandler* handler, char const* /*args*/) { @@ -1846,13 +1879,13 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow()); -
+ MotionMaster* motionMaster = unit->GetMotionMaster(); float x, y, z; motionMaster->GetDestination(x, y, z); -
+ for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i) { MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i); @@ -1861,7 +1894,7 @@ public: handler->SendSysMessage("Empty"); continue; } -
+ switch (movementGenerator->GetMovementGeneratorType()) { case IDLE_MOTION_TYPE: @@ -1886,7 +1919,7 @@ public: target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget(); else target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget(); -
+ if (!target) handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) @@ -1902,7 +1935,7 @@ public: target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget(); else target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget(); -
+ if (!target) handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) @@ -1953,7 +1986,7 @@ public: char const* newFlagStr = strtok((char*)args, " "); if (!newFlagStr) return false; -
+ Creature* caster = handler->getSelectedCreature(); if (!caster) { @@ -1961,19 +1994,19 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ Player* player = handler->GetSession()->GetPlayer(); -
+ caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); -
+ return true; } -
+ static bool HandleDamageCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ Unit* target = handler->getSelectedUnit(); if (!target || !handler->GetSession()->GetPlayer()->GetSelection()) { @@ -1981,28 +2014,28 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (target->GetTypeId() == TYPEID_PLAYER) { if (handler->HasLowerSecurity((Player*)target, 0, false)) return false; } -
+ if (!target->isAlive()) return true; -
+ char* damageStr = strtok((char*)args, " "); if (!damageStr) return false; -
+ int32 damage_int = atoi((char*)damageStr); if (damage_int <= 0) return true; -
+ uint32 damage = damage_int; -
+ char* schoolStr = strtok((char*)NULL, " "); -
+ // flat melee damage without resistence/etc reduction if (!schoolStr) { @@ -2011,52 +2044,52 @@ public: handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0); return true; } -
+ uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL; if (school >= MAX_SPELL_SCHOOL) return false; -
+ SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); -
+ if (Unit::IsDamageReducedByArmor(schoolmask)) damage = handler->GetSession()->GetPlayer()->CalcArmorReducedDamage(target, damage, NULL, BASE_ATTACK); -
+ char* spellStr = strtok((char*)NULL, " "); -
+ // melee damage by specific school if (!spellStr) { uint32 absorb = 0; uint32 resist = 0; -
+ handler->GetSession()->GetPlayer()->CalcAbsorbResist(target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); -
+ if (damage <= absorb + resist) return true; -
+ damage -= absorb + resist; -
+ handler->GetSession()->GetPlayer()->DealDamageMods(target, damage, &absorb); handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0); return true; } -
+ // non-melee damage -
+ // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellid = handler->extractSpellIdFromLink((char*)args); if (!spellid || !sSpellMgr->GetSpellInfo(spellid)) return false; -
+ handler->GetSession()->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage); return true; } -
+ static bool HandleCombatStopCommand(ChatHandler* handler, char const* args) { Player* target = NULL; -
+ if (args && strlen(args) > 0) { target = sObjectAccessor->FindPlayerByName(args); @@ -2067,48 +2100,48 @@ public: return false; } } -
+ if (!target) { if (!handler->extractPlayerTarget((char*)args, &target)) return false; } -
+ // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ target->CombatStop(); target->getHostileRefManager().deleteReferences(); return true; } -
+ static bool HandleFlushArenaPointsCommand(ChatHandler* /*handler*/, char const* /*args*/) { sArenaTeamMgr->DistributeArenaPoints(); return true; } -
+ static bool HandleRepairitemsCommand(ChatHandler* handler, char const* args) { Player* target; if (!handler->extractPlayerTarget((char*)args, &target)) return false; -
+ // check online security if (handler->HasLowerSecurity(target, 0)) return false; -
+ // Repair items target->DurabilityRepairAll(false, 0, false); -
+ handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, handler->GetNameLink().c_str()); -
+ return true; } -
+ // Send mail by command static bool HandleSendMailCommand(ChatHandler* handler, char const* args) { @@ -2118,37 +2151,37 @@ public: std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; -
+ char* tail1 = strtok(NULL, ""); if (!tail1) return false; -
+ char const* msgSubject = handler->extractQuotedArg(tail1); if (!msgSubject) return false; -
+ char* tail2 = strtok(NULL, ""); if (!tail2) return false; -
+ char const* msgText = handler->extractQuotedArg(tail2); if (!msgText) return false; -
+ // msgSubject, msgText isn't NUL after prev. check std::string subject = msgSubject; std::string text = msgText; -
+ // from console show not existed sender MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); -
+ //- TODO: Fix poor design SQLTransaction trans = CharacterDatabase.BeginTransaction(); MailDraft(subject, text) .SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender); -
+ CharacterDatabase.CommitTransaction(trans); -
+ std::string nameLink = handler->playerLink(targetName); handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); return true; @@ -2162,49 +2195,49 @@ public: std::string receiverName; if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName)) return false; -
+ char* tail1 = strtok(NULL, ""); if (!tail1) return false; -
+ char const* msgSubject = handler->extractQuotedArg(tail1); if (!msgSubject) return false; -
+ char* tail2 = strtok(NULL, ""); if (!tail2) return false; -
+ char const* msgText = handler->extractQuotedArg(tail2); if (!msgText) return false; -
+ // msgSubject, msgText isn't NUL after prev. check std::string subject = msgSubject; std::string text = msgText; -
+ // extract items typedef std::pair<uint32, uint32> ItemPair; typedef std::list< ItemPair > ItemPairs; ItemPairs items; -
+ // get all tail string char* tail = strtok(NULL, ""); -
+ // get from tail next item str while (char* itemStr = strtok(tail, " ")) { // and get new tail tail = strtok(NULL, ""); -
+ // parse item str char const* itemIdStr = strtok(itemStr, ":"); char const* itemCountStr = strtok(NULL, " "); -
+ uint32 itemId = atoi(itemIdStr); if (!itemId) return false; -
+ ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(itemId); if (!item_proto) { @@ -2212,7 +2245,7 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ uint32 itemCount = itemCountStr ? atoi(itemCountStr) : 1; if (itemCount < 1 || (item_proto->MaxCount > 0 && itemCount > uint32(item_proto->MaxCount))) { @@ -2220,15 +2253,15 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ while (itemCount > item_proto->GetMaxStackSize()) { items.push_back(ItemPair(itemId, item_proto->GetMaxStackSize())); itemCount -= item_proto->GetMaxStackSize(); } -
+ items.push_back(ItemPair(itemId, itemCount)); -
+ if (items.size() > MAX_MAIL_ITEMS) { handler->PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); @@ -2236,15 +2269,15 @@ public: return false; } } -
+ // from console show not existed sender MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); -
+ // fill mail MailDraft draft(subject, text); -
+ SQLTransaction trans = CharacterDatabase.BeginTransaction(); -
+ for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) { if (Item* item = Item::CreateItem(itr->first, itr->second, handler->GetSession() ? handler->GetSession()->GetPlayer() : 0)) @@ -2253,10 +2286,10 @@ public: draft.AddItem(item); } } -
+ draft.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender); CharacterDatabase.CommitTransaction(trans); -
+ std::string nameLink = handler->playerLink(receiverName); handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); return true; @@ -2265,49 +2298,49 @@ public: static bool HandleSendMoneyCommand(ChatHandler* handler, char const* args) { /// format: name "subject text" "mail text" money -
+ Player* receiver; uint64 receiverGuid; std::string receiverName; if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName)) return false; -
+ char* tail1 = strtok(NULL, ""); if (!tail1) return false; -
+ char* msgSubject = handler->extractQuotedArg(tail1); if (!msgSubject) return false; -
+ char* tail2 = strtok(NULL, ""); if (!tail2) return false; -
+ char* msgText = handler->extractQuotedArg(tail2); if (!msgText) return false; -
+ char* moneyStr = strtok(NULL, ""); int32 money = moneyStr ? atoi(moneyStr) : 0; if (money <= 0) return false; -
+ // msgSubject, msgText isn't NUL after prev. check std::string subject = msgSubject; std::string text = msgText; -
+ // from console show not existed sender MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); -
+ SQLTransaction trans = CharacterDatabase.BeginTransaction(); -
+ MailDraft(subject, text) .AddMoney(money) .SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender); -
+ CharacterDatabase.CommitTransaction(trans); -
+ std::string nameLink = handler->playerLink(receiverName); handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); return true; @@ -2319,11 +2352,11 @@ public: Player* player; if (!handler->extractPlayerTarget((char*)args, &player)) return false; -
+ char* msgStr = strtok(NULL, ""); if (!msgStr) return false; -
+ ///- Check that he is not logging out. if (player->GetSession()->isLogingOut()) { @@ -2331,31 +2364,31 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ /// - Send the message // Use SendAreaTriggerMessage for fastest delivery. player->GetSession()->SendAreaTriggerMessage("%s", msgStr); player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); -
+ // Confirmation message std::string nameLink = handler->GetNameLink(player); handler->PSendSysMessage(LANG_SENDMESSAGE, nameLink.c_str(), msgStr); -
+ return true; } -
+ static bool HandleCreatePetCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creatureTarget = handler->getSelectedCreature(); -
+ if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER) { handler->PSendSysMessage(LANG_SELECT_CREATURE); handler->SetSentErrorMessage(true); return false; } -
+ CreatureTemplate const* creatrueTemplate = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry()); // Creatures with family 0 crashes the server if (!creatrueTemplate->family) @@ -2364,14 +2397,14 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ if (player->GetPetGUID()) { handler->PSendSysMessage("You already have a pet"); handler->SetSentErrorMessage(true); return false; } -
+ // Everything looks OK, create new pet Pet* pet = new Pet(player, HUNTER_PET); if (!pet->CreateBaseAtCreature(creatureTarget)) @@ -2380,14 +2413,14 @@ public: handler->PSendSysMessage("Error 1"); return false; } -
+ creatureTarget->setDeathState(JUST_DIED); creatureTarget->RemoveCorpse(); creatureTarget->SetHealth(0); // just for nice GM-mode view -
+ pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID()); pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction()); -
+ if (!pet->InitStatsForLevel(creatureTarget->getLevel())) { sLog->outError(LOG_FILTER_GENERAL, "InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); @@ -2395,47 +2428,47 @@ public: delete pet; return false; } -
+ // prepare visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1); -
+ pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true); // this enables pet details window (Shift+P) pet->InitPetCreateSpells(); pet->SetFullHealth(); -
+ pet->GetMap()->AddToMap(pet->ToCreature()); -
+ // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()); -
+ player->SetMinion(pet, true); pet->SavePetToDB(PET_SAVE_AS_CURRENT); player->PetSpellInitialize(); -
+ return true; } -
+ static bool HandlePetLearnCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ Player* player = handler->GetSession()->GetPlayer(); Pet* pet = player->GetPet(); -
+ if (!pet) { handler->PSendSysMessage("You have no pet"); handler->SetSentErrorMessage(true); return false; } -
+ uint32 spellId = handler->extractSpellIdFromLink((char*)args); -
+ if (!spellId || !sSpellMgr->GetSpellInfo(spellId)) return false; -
+ // Check if pet already has it if (pet->HasSpell(spellId)) { @@ -2443,7 +2476,7 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ // Check if spell is valid SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo)) @@ -2452,18 +2485,18 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ pet->learnSpell(spellId); -
+ handler->PSendSysMessage("Pet has learned spell %u", spellId); return true; } -
+ static bool HandlePetUnlearnCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ Player* player = handler->GetSession()->GetPlayer(); Pet* pet = player->GetPet(); if (!pet) @@ -2472,17 +2505,17 @@ public: handler->SetSentErrorMessage(true); return false; } -
+ uint32 spellId = handler->extractSpellIdFromLink((char*)args); -
+ if (pet->HasSpell(spellId)) pet->removeSpell(spellId, false); else handler->PSendSysMessage("Pet doesn't have that spell"); -
+ return true; } -
+ static bool HandleFreezeCommand(ChatHandler* handler, char const* args) { std::string name; @@ -2503,31 +2536,31 @@ public: normalizePlayerName(name); player = sObjectAccessor->FindPlayerByName(name.c_str()); } -
+ if (!player) { handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG); return true; } -
+ if (player == handler->GetSession()->GetPlayer()) { handler->SendSysMessage(LANG_COMMAND_FREEZE_ERROR); return true; } -
+ // effect if (player && (player != handler->GetSession()->GetPlayer())) { handler->PSendSysMessage(LANG_COMMAND_FREEZE, name.c_str()); -
+ // stop combat + make player unattackable + duel stop + stop some spells player->setFaction(35); player->CombatStop(); if (player->IsNonMeleeSpellCasted(true)) player->InterruptNonMeleeSpells(true); player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); -
+ // if player class = hunter || warlock remove pet if alive if ((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK)) { @@ -2539,23 +2572,23 @@ public: player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT); } } -
+ if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(9454)) Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, player, player); -
+ // save player player->SaveToDB(); } -
+ return true; } -
+ static bool HandleUnFreezeCommand(ChatHandler* handler, char const*args) { std::string name; Player* player; char* targetName = strtok((char*)args, " "); // Get entered name -
+ if (targetName) { name = targetName; @@ -2568,18 +2601,18 @@ public: if (player) name = player->GetName(); } -
+ if (player) { handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str()); -
+ // Reset player faction + allow combat + allow duels player->setFactionForRace(player->getRace()); player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); -
+ // Remove Freeze spell (allowing movement and spells) player->RemoveAurasDueToSpell(9454); -
+ // Save player player->SaveToDB(); } @@ -2591,21 +2624,21 @@ public: PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_BY_NAME); stmt->setString(0, name); PreparedQueryResult result = CharacterDatabase.Query(stmt); -
+ if (!result) { handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG); return true; } -
+ // If player found: delete his freeze aura Field* fields = result->Fetch(); uint32 lowGuid = fields[0].GetUInt32(); -
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); stmt->setUInt32(0, lowGuid); CharacterDatabase.Execute(stmt); -
+ handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str()); return true; } @@ -2615,10 +2648,10 @@ public: return true; } } -
+ return true; } -
+ static bool HandleListFreezeCommand(ChatHandler* handler, char const* /*args*/) { // Get names from DB @@ -2629,10 +2662,10 @@ public: handler->SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS); return true; } -
+ // Header of the names handler->PSendSysMessage(LANG_COMMAND_LIST_FREEZE); -
+ // Output of the results do { @@ -2641,120 +2674,120 @@ public: handler->PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str()); } while (result->NextRow()); -
+ return true; } -
+ static bool HandleGroupLeaderCommand(ChatHandler* handler, char const* args) { Player* player = NULL; Group* group = NULL; uint64 guid = 0; char* nameStr = strtok((char*)args, " "); -
+ if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid)) if (group && group->GetLeaderGUID() != guid) { group->ChangeLeader(guid); group->SendUpdate(); } -
+ return true; } -
+ static bool HandleGroupDisbandCommand(ChatHandler* handler, char const* args) { Player* player = NULL; Group* group = NULL; uint64 guid = 0; char* nameStr = strtok((char*)args, " "); -
+ if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid)) if (group) group->Disband(); -
+ return true; } -
+ static bool HandleGroupRemoveCommand(ChatHandler* handler, char const* args) { Player* player = NULL; Group* group = NULL; uint64 guid = 0; char* nameStr = strtok((char*)args, " "); -
+ if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid, true)) if (group) group->RemoveMember(guid); -
+ return true; } -
+ static bool HandlePlayAllCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -
+ uint32 soundId = atoi((char*)args); -
+ if (!sSoundEntriesStore.LookupEntry(soundId)) { handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); handler->SetSentErrorMessage(true); return false; } -
+ WorldPacket data(SMSG_PLAY_SOUND, 4); data << uint32(soundId) << handler->GetSession()->GetPlayer()->GetGUID(); sWorld->SendGlobalMessage(&data); -
+ handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); return true; } -
+ static bool HandlePossessCommand(ChatHandler* handler, char const* /*args*/) { Unit* unit = handler->getSelectedUnit(); if (!unit) return false; -
+ handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true); return true; } -
+ static bool HandleUnPossessCommand(ChatHandler* handler, char const* /*args*/) { Unit* unit = handler->getSelectedUnit(); if (!unit) unit = handler->GetSession()->GetPlayer(); -
+ unit->RemoveCharmAuras(); -
+ return true; } -
+ static bool HandleBindSightCommand(ChatHandler* handler, char const* /*args*/) { Unit* unit = handler->getSelectedUnit(); if (!unit) return false; -
+ handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true); return true; } -
+ static bool HandleUnbindSightCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); -
+ if (player->isPossessing()) return false; -
+ player->StopCastingBindSight(); return true; } }; -
+ void AddSC_misc_commandscript() { new misc_commandscript(); diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 3bb29f8abfe..7d2a4304054 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -467,56 +467,57 @@ public: cInfo->rangeattacktime = fields[29].GetUInt32(); cInfo->unit_class = fields[30].GetUInt8(); cInfo->unit_flags = fields[31].GetUInt32(); - cInfo->dynamicflags = fields[32].GetUInt32(); - cInfo->family = fields[33].GetUInt8(); - cInfo->trainer_type = fields[34].GetUInt8(); - cInfo->trainer_spell = fields[35].GetUInt32(); - cInfo->trainer_class = fields[36].GetUInt8(); - cInfo->trainer_race = fields[37].GetUInt8(); - cInfo->minrangedmg = fields[38].GetFloat(); - cInfo->maxrangedmg = fields[39].GetFloat(); - cInfo->rangedattackpower = fields[40].GetUInt16(); - cInfo->type = fields[41].GetUInt8(); - cInfo->type_flags = fields[42].GetUInt32(); - cInfo->lootid = fields[43].GetUInt32(); - cInfo->pickpocketLootId = fields[44].GetUInt32(); - cInfo->SkinLootId = fields[45].GetUInt32(); + cInfo->unit_flags2 = fields[32].GetUInt32(); + cInfo->dynamicflags = fields[33].GetUInt32(); + cInfo->family = fields[34].GetUInt8(); + cInfo->trainer_type = fields[35].GetUInt8(); + cInfo->trainer_spell = fields[36].GetUInt32(); + cInfo->trainer_class = fields[37].GetUInt8(); + cInfo->trainer_race = fields[38].GetUInt8(); + cInfo->minrangedmg = fields[39].GetFloat(); + cInfo->maxrangedmg = fields[40].GetFloat(); + cInfo->rangedattackpower = fields[41].GetUInt16(); + cInfo->type = fields[42].GetUInt8(); + cInfo->type_flags = fields[43].GetUInt32(); + cInfo->lootid = fields[44].GetUInt32(); + cInfo->pickpocketLootId = fields[45].GetUInt32(); + cInfo->SkinLootId = fields[46].GetUInt32(); for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - cInfo->resistance[i] = fields[46 + i -1].GetUInt16(); - - cInfo->spells[0] = fields[52].GetUInt32(); - cInfo->spells[1] = fields[53].GetUInt32(); - cInfo->spells[2] = fields[54].GetUInt32(); - cInfo->spells[3] = fields[55].GetUInt32(); - cInfo->spells[4] = fields[56].GetUInt32(); - cInfo->spells[5] = fields[57].GetUInt32(); - cInfo->spells[6] = fields[58].GetUInt32(); - cInfo->spells[7] = fields[59].GetUInt32(); - cInfo->PetSpellDataId = fields[60].GetUInt32(); - cInfo->VehicleId = fields[61].GetUInt32(); - cInfo->mingold = fields[62].GetUInt32(); - cInfo->maxgold = fields[63].GetUInt32(); - cInfo->AIName = fields[64].GetString(); - cInfo->MovementType = fields[65].GetUInt8(); - cInfo->InhabitType = fields[66].GetUInt8(); - cInfo->HoverHeight = fields[67].GetFloat(); - cInfo->ModHealth = fields[68].GetFloat(); - cInfo->ModMana = fields[69].GetFloat(); - cInfo->ModArmor = fields[70].GetFloat(); - cInfo->RacialLeader = fields[71].GetBool(); - cInfo->questItems[0] = fields[72].GetUInt32(); - cInfo->questItems[1] = fields[73].GetUInt32(); - cInfo->questItems[2] = fields[74].GetUInt32(); - cInfo->questItems[3] = fields[75].GetUInt32(); - cInfo->questItems[4] = fields[76].GetUInt32(); - cInfo->questItems[5] = fields[77].GetUInt32(); - cInfo->movementId = fields[78].GetUInt32(); - cInfo->RegenHealth = fields[79].GetBool(); - cInfo->equipmentId = fields[80].GetUInt32(); - cInfo->MechanicImmuneMask = fields[81].GetUInt32(); - cInfo->flags_extra = fields[82].GetUInt32(); - cInfo->ScriptID = sObjectMgr->GetScriptId(fields[83].GetCString()); + cInfo->resistance[i] = fields[47 + i -1].GetUInt16(); + + cInfo->spells[0] = fields[53].GetUInt32(); + cInfo->spells[1] = fields[54].GetUInt32(); + cInfo->spells[2] = fields[55].GetUInt32(); + cInfo->spells[3] = fields[56].GetUInt32(); + cInfo->spells[4] = fields[57].GetUInt32(); + cInfo->spells[5] = fields[58].GetUInt32(); + cInfo->spells[6] = fields[59].GetUInt32(); + cInfo->spells[7] = fields[60].GetUInt32(); + cInfo->PetSpellDataId = fields[61].GetUInt32(); + cInfo->VehicleId = fields[62].GetUInt32(); + cInfo->mingold = fields[63].GetUInt32(); + cInfo->maxgold = fields[64].GetUInt32(); + cInfo->AIName = fields[65].GetString(); + cInfo->MovementType = fields[66].GetUInt8(); + cInfo->InhabitType = fields[67].GetUInt8(); + cInfo->HoverHeight = fields[68].GetFloat(); + cInfo->ModHealth = fields[69].GetFloat(); + cInfo->ModMana = fields[70].GetFloat(); + cInfo->ModArmor = fields[71].GetFloat(); + cInfo->RacialLeader = fields[72].GetBool(); + cInfo->questItems[0] = fields[73].GetUInt32(); + cInfo->questItems[1] = fields[74].GetUInt32(); + cInfo->questItems[2] = fields[75].GetUInt32(); + cInfo->questItems[3] = fields[76].GetUInt32(); + cInfo->questItems[4] = fields[77].GetUInt32(); + cInfo->questItems[5] = fields[78].GetUInt32(); + cInfo->movementId = fields[79].GetUInt32(); + cInfo->RegenHealth = fields[80].GetBool(); + cInfo->equipmentId = fields[81].GetUInt32(); + cInfo->MechanicImmuneMask = fields[82].GetUInt32(); + cInfo->flags_extra = fields[83].GetUInt32(); + cInfo->ScriptID = sObjectMgr->GetScriptId(fields[84].GetCString()); sObjectMgr->CheckCreatureTemplate(cInfo); } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index d5add0f0bb7..f4195620dda 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -233,7 +233,7 @@ public: SWPainTimer = 20000; AmplifyDamageTimer = 5000; Cleave_Timer = 8000; - InfernalTimer = 45000; + InfernalTimer = 40000; InfernalCleanupTimer = 47000; AxesTargetSwitchTimer = urand(7500, 20000); SunderArmorTimer = urand(5000, 10000); diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp index 46fb62eae7f..0aad2857a45 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp @@ -283,6 +283,12 @@ public: DoScriptText(SAY_WH_KILL, me); } + void DamageTaken(Unit* /*attacker*/, uint32& damage) + { + if (!_bCanResurrectCheck && damage >= me->GetHealth()) + damage = me->GetHealth() - 1; + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) diff --git a/src/server/scripts/Kalimdor/ashenvale.cpp b/src/server/scripts/Kalimdor/ashenvale.cpp index 248932ecbb6..6a9dd77433a 100644 --- a/src/server/scripts/Kalimdor/ashenvale.cpp +++ b/src/server/scripts/Kalimdor/ashenvale.cpp @@ -447,7 +447,7 @@ class npc_muglash : public CreatureScript DoScriptText(SAY_MUG_START1, creature); creature->setFaction(113); - pEscortAI->Start(true, true, player->GetGUID()); + pEscortAI->Start(true, false, player->GetGUID()); } } return true; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 89fdcc7f725..564df34462b 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -85,8 +85,10 @@ enum BossSpells SPELL_SPIDER_FRENZY = 66128, SPELL_EXPOSE_WEAKNESS = 67720, //Passive - Triggered SPELL_SHADOW_STRIKE = 66134, - SPELL_SUBMERGE_EFFECT = 53421, - SPELL_EMERGE_EFFECT = 66947, + SPELL_SUBMERGE_EFFECT = 68394, + SPELL_EMERGE_EFFECT = 65982, + SPELL_AWAKENED = 66311, + SPELL_PERSISTENT_DIRT = 68048, SUMMON_SCARAB = NPC_SCARAB, SUMMON_FROSTSPHERE = NPC_FROST_SPHERE, @@ -96,6 +98,7 @@ enum BossSpells SPELL_FROST_SPHERE = 67539, SPELL_PERMAFROST = 66193, SPELL_PERMAFROST_VISUAL = 65882, + SPELL_PERMAFROST_MODEL = 66185, //Spike SPELL_SUMMON_SPIKE = 66169, @@ -117,12 +120,12 @@ enum SummonActions const Position SphereSpawn[6] = { - { 786.6439f, 108.2498f, 155.6701f, 0 }, - { 806.8429f, 150.5902f, 155.6701f, 0 }, - { 759.1386f, 163.9654f, 155.6701f, 0 }, - { 744.3701f, 119.5211f, 155.6701f, 0 }, - { 710.0211f, 120.8152f, 155.6701f, 0 }, - { 706.6383f, 161.5266f, 155.6701f, 0 }, + {779.8038f, 150.6580f, 158.1426f, 0}, + {736.0243f, 113.4201f, 158.0226f, 0}, + {712.5712f, 160.9948f, 158.4368f, 0}, + {701.4271f, 126.4740f, 158.0205f, 0}, + {747.9202f, 155.0920f, 158.0613f, 0}, + {769.6285f, 121.1024f, 158.0504f, 0}, }; enum MovementPoints @@ -219,7 +222,10 @@ public: //Summon Scarab Swarms neutral at random places for (int i=0; i < 10; i++) if (Creature* temp = me->SummonCreature(NPC_SCARAB, AnubarakLoc[1].GetPositionX()+urand(0, 50)-25, AnubarakLoc[1].GetPositionY()+urand(0, 50)-25, AnubarakLoc[1].GetPositionZ())) + { temp->setFaction(31); + temp->GetMotionMaster()->MoveRandom(10); + } } void JustDied(Unit* /*killer*/) @@ -447,10 +453,9 @@ public: m_uiDeterminationTimer = urand(5*IN_MILLISECONDS, 60*IN_MILLISECONDS); DoCast(me, SPELL_ACID_MANDIBLE); me->SetInCombatWithZone(); - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) - me->AddThreat(target, 20000.0f); - if (!me->isInCombat()) - me->DisappearAndDie(); + if (me->isInCombat()) + if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANUBARAK))) + Anubarak->AI()->JustSummoned(me); } void DoAction(const int32 actionId) @@ -511,14 +516,16 @@ public: void Reset() { - me->SetCorpseDelay(0); + me->SetCorpseDelay(10); m_uiSpiderFrenzyTimer = urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS); m_uiSubmergeTimer = 30*IN_MILLISECONDS; DoCast(me, SPELL_EXPOSE_WEAKNESS); DoCast(me, SPELL_SPIDER_FRENZY); + DoCast(me, SPELL_AWAKENED); me->SetInCombatWithZone(); - if (!me->isInCombat()) - me->DisappearAndDie(); + if (me->isInCombat()) + if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANUBARAK))) + Anubarak->AI()->JustSummoned(me); } void DoAction(const int32 actionId) @@ -526,8 +533,9 @@ public: switch (actionId) { case ACTION_SHADOW_STRIKE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_SHADOW_STRIKE); + if (!me->HasAura(SPELL_AWAKENED)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_SHADOW_STRIKE); break; } } @@ -537,22 +545,25 @@ public: if (!UpdateVictim()) return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + if ((m_uiSubmergeTimer <= uiDiff) && HealthBelowPct(80)) { if (me->HasAura(SPELL_SUBMERGE_EFFECT)) { me->RemoveAurasDueToSpell(SPELL_SUBMERGE_EFFECT); DoCast(me, SPELL_EMERGE_EFFECT); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); - me->CombatStart(me->SelectNearestTarget()); + DoCast(me, SPELL_AWAKENED); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } else { if (!me->HasAura(SPELL_PERMAFROST_HELPER)) { DoCast(me, SPELL_SUBMERGE_EFFECT); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); - me->CombatStop(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_PERSISTENT_DIRT, true); } } m_uiSubmergeTimer = 20*IN_MILLISECONDS; @@ -577,16 +588,10 @@ class mob_frost_sphere : public CreatureScript void Reset() { - _isFalling = false; me->SetReactState(REACT_PASSIVE); - //! Confirmed sniff 3.3.5.a - me->SetDisableGravity(true); - me->SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER); - //! end + DoCast(SPELL_FROST_SPHERE); me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); - me->SetSpeed(MOVE_RUN, 0.5f, false); me->GetMotionMaster()->MoveRandom(20.0f); - DoCast(SPELL_FROST_SPHERE); } void DamageTaken(Unit* /*who*/, uint32& damage) @@ -594,9 +599,20 @@ class mob_frost_sphere : public CreatureScript if (me->GetHealth() <= damage) { damage = 0; - if (!_isFalling) + float floorZ = me->GetMap()->GetHeight(me->GetPhaseMask(), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); + if (fabs(me->GetPositionZ() - floorZ) < 0.1f) { - _isFalling = true; + // we are close to the ground + me->GetMotionMaster()->MoveIdle(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); + DoCast(SPELL_PERMAFROST_MODEL); + DoCast(SPELL_PERMAFROST); + me->SetObjectScale(2.0f); + } + else + { + // we are in air me->GetMotionMaster()->MoveIdle(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); //At hit the ground @@ -615,16 +631,13 @@ class mob_frost_sphere : public CreatureScript { case POINT_FALL_GROUND: me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); - me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); + DoCast(SPELL_PERMAFROST_MODEL); DoCast(SPELL_PERMAFROST_VISUAL); DoCast(SPELL_PERMAFROST); me->SetObjectScale(2.0f); break; } } - - private: - bool _isFalling; }; CreatureAI* GetAI(Creature* creature) const diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index 10f7150351e..87e7801566e 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -329,6 +329,8 @@ public: // used to despawn corpse immediately me->DespawnOrUnsummon(); } + + void UpdateAI(uint32 const /*diff*/) {} }; }; @@ -438,6 +440,8 @@ public: // used to despawn corpse immediately me->DespawnOrUnsummon(); } + + void UpdateAI(uint32 const /*diff*/) {} }; }; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp index 9767126371b..af6104008ff 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp @@ -332,7 +332,8 @@ class instance_trial_of_the_crusader : public InstanceMapScript } if (tributeChest) if (Creature* tirion = instance->GetCreature(TirionGUID)) - if (GameObject* chest = tirion->SummonGameObject(tributeChest, 805.62f, 134.87f, 142.16f, 3.27f, 0, 0, 0, 0, 90000000)) + // need proper location.this one is guessed based on videos + if (GameObject* chest = tirion->SummonGameObject(tributeChest, 643.814f, 136.027f, 141.295f, 0, 0, 0, 0, 0, 90000000)) chest->SetRespawnTime(chest->GetRespawnDelay()); break; } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp index 37d08484f0b..0476b2cbacb 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp @@ -25,7 +25,6 @@ EndScriptData */ //Known Bugs: // - Need better implementation of Gossip and correct gossip text and option -// - Misses Dalaran Teleport at the end. #include "ScriptMgr.h" #include "ScriptedCreature.h" @@ -121,11 +120,8 @@ class npc_announcer_toc10 : public CreatureScript { npc_announcer_toc10AI(Creature* creature) : ScriptedAI(creature) { - instance = creature->GetInstanceScript(); } - InstanceScript* instance; - void Reset() { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -219,7 +215,7 @@ class npc_announcer_toc10 : public CreatureScript return true; if (GameObject* floor = GameObject::GetGameObject(*player, instanceScript->GetData64(GO_ARGENT_COLISEUM_FLOOR))) - floor->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); + floor->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); creature->CastSpell(creature, 69016, false); @@ -275,7 +271,7 @@ class boss_lich_king_toc : public CreatureScript void MovementInform(uint32 uiType, uint32 uiId) { - if (uiType != POINT_MOTION_TYPE) + if (uiType != POINT_MOTION_TYPE || !instance) return; switch (uiId) { @@ -337,22 +333,20 @@ class boss_lich_king_toc : public CreatureScript break; case 5080: if (GameObject* go = instance->instance->GetGameObject(instance->GetData64(GO_ARGENT_COLISEUM_FLOOR))) - go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); + go->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); me->CastSpell(me, 69016, false); - if (instance) - { - instance->SetData(TYPE_LICH_KING, DONE); - Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_ANUBARAK)); - if (!temp || !temp->isAlive()) - temp = me->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); + instance->SetData(TYPE_LICH_KING, DONE); + Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_ANUBARAK)); + if (!temp || !temp->isAlive()) + temp = me->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); - instance->SetData(TYPE_EVENT, 0); - } + instance->SetData(TYPE_EVENT, 0); me->DespawnOrUnsummon(); m_uiUpdateTimer = 20000; break; } } else m_uiUpdateTimer -= uiDiff; + instance->SetData(TYPE_EVENT_TIMER, m_uiUpdateTimer); } }; @@ -797,7 +791,9 @@ class npc_tirion_toc : public CreatureScript instance->SetData(TYPE_EVENT, 0); break; case 6000: - me->NearTeleportTo(AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 4.0f); + me->SummonCreature(NPC_TIRION_FORDRING, EndSpawnLoc[0].GetPositionX(), EndSpawnLoc[0].GetPositionY(), EndSpawnLoc[0].GetPositionZ()); + me->SummonCreature(NPC_ARGENT_MAGE, EndSpawnLoc[1].GetPositionX(), EndSpawnLoc[1].GetPositionY(), EndSpawnLoc[1].GetPositionZ()); + me->SummonGameObject(GO_PORTAL_TO_DALARAN, EndSpawnLoc[2].GetPositionX(), EndSpawnLoc[2].GetPositionY(), EndSpawnLoc[2].GetPositionZ(), 5, 0, 0, 0, 0, 0); m_uiUpdateTimer = 20000; instance->SetData(TYPE_EVENT, 6005); break; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h index ba230551b24..58cbd727963 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h @@ -129,6 +129,13 @@ const Position AnubarakLoc[]= {740.184509f, 193.443390f, 142.117584f, 0}, // 4 - Nerub Spawn }; +const Position EndSpawnLoc[]= +{ + {648.9167f, 131.0208f, 141.6161f, 0}, // 0 - Highlord Tirion Fordring + {649.1614f, 142.0399f, 141.3057f ,0}, // 1 - Argent Mage + {644.6250f, 149.2743f, 140.6015f ,0}, // 2 - Portal to Dalaran +}; + enum euiWorldStates { UPDATE_STATE_UI_SHOW = 4390, @@ -163,6 +170,7 @@ enum eCreature NPC_BARRENT = 34816, NPC_TIRION = 34996, NPC_TIRION_FORDRING = 36095, + NPC_ARGENT_MAGE = 36097, NPC_FIZZLEBANG = 35458, NPC_GARROSH = 34995, NPC_VARIAN = 34990, @@ -245,6 +253,7 @@ enum eGameObject GO_MAIN_GATE_DOOR = 195647, GO_EAST_PORTCULLIS = 195648, GO_WEB_DOOR = 195485, + GO_PORTAL_TO_DALARAN = 195682, }; enum eAchievementData diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index a9ba0baa86f..489616332c8 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -23,6 +23,7 @@ #include "Spell.h" #include "icecrown_citadel.h" #include "Vehicle.h" +#include "GridNotifiers.h" enum ScriptTexts { @@ -185,12 +186,15 @@ class AbominationDespawner if (Vehicle* veh = summon->GetVehicleKit()) veh->RemoveAllPassengers(); // also despawns the vehicle + // Found unit is Mutated Abomination, remove it return true; } + // Found unit is not Mutated Abomintaion, leave it return false; } + // No unit found, remove from SummonList return true; } @@ -198,6 +202,19 @@ class AbominationDespawner Unit* _owner; }; +struct RotfaceHeightCheck +{ + RotfaceHeightCheck(Creature* rotface) : _rotface(rotface) { } + + bool operator()(Creature* stalker) const + { + return stalker->GetPositionZ() < _rotface->GetPositionZ() + 5.0f; + } + +private: + Creature* _rotface; +}; + class boss_professor_putricide : public CreatureScript { public: @@ -246,7 +263,7 @@ class boss_professor_putricide : public CreatureScript events.Reset(); events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_SLIME_PUDDLE, 10000); - events.ScheduleEvent(EVENT_UNSTABLE_EXPERIMENT, urand(25000, 30000)); + events.ScheduleEvent(EVENT_UNSTABLE_EXPERIMENT, urand(30000, 35000)); if (IsHeroic()) events.ScheduleEvent(EVENT_UNBOUND_PLAGUE, 20000); @@ -295,18 +312,16 @@ class boss_professor_putricide : public CreatureScript // no possible aura seen in sniff adding the aurastate summon->ModifyAuraState(AURA_STATE_UNKNOWN22, true); summon->CastSpell(summon, SPELL_GASEOUS_BLOAT_PROC, true); - summon->CastCustomSpell(SPELL_GASEOUS_BLOAT, SPELLVALUE_AURA_STACK, 10, summon, false); summon->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK, true); summon->SetReactState(REACT_PASSIVE); - return; + break; case NPC_VOLATILE_OOZE: // no possible aura seen in sniff adding the aurastate summon->ModifyAuraState(AURA_STATE_UNKNOWN19, true); summon->CastSpell(summon, SPELL_OOZE_ERUPTION_SEARCH_PERIODIC, true); - summon->CastSpell(summon, SPELL_VOLATILE_OOZE_ADHESIVE, false); summon->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK, true); summon->SetReactState(REACT_PASSIVE); - return; + break; case NPC_CHOKING_GAS_BOMB: summon->CastSpell(summon, SPELL_CHOKING_GAS_BOMB_PERIODIC, true); summon->CastSpell(summon, SPELL_CHOKING_GAS_EXPLOSION_TRIGGER, true); @@ -428,7 +443,8 @@ class boss_professor_putricide : public CreatureScript if (Creature* rotface = Unit::GetCreature(*me, instance->GetData64(DATA_ROTFACE))) { std::list<Creature*> list; - GetCreatureListWithEntryInGrid(list, rotface, NPC_PUDDLE_STALKER, 36.0f); + GetCreatureListWithEntryInGrid(list, rotface, NPC_PUDDLE_STALKER, 50.0f); + list.remove_if(RotfaceHeightCheck(rotface)); if (list.size() > 4) { list.sort(Trinity::ObjectDistanceOrderPred(rotface)); @@ -510,7 +526,6 @@ class boss_professor_putricide : public CreatureScript SetPhase(PHASE_COMBAT_3); events.ScheduleEvent(EVENT_MUTATED_PLAGUE, 25000); events.CancelEvent(EVENT_UNSTABLE_EXPERIMENT); - summons.remove_if(AbominationDespawner(me)); break; default: break; @@ -643,7 +658,7 @@ class boss_professor_putricide : public CreatureScript case EVENT_UNBOUND_PLAGUE: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) { - me->CastCustomSpell(SPELL_UNBOUND_PLAGUE, SPELLVALUE_BASE_POINT0, 775, target); + DoCast(target, SPELL_UNBOUND_PLAGUE); DoCast(target, SPELL_UNBOUND_PLAGUE_SEARCHER); } events.ScheduleEvent(EVENT_UNBOUND_PLAGUE, 90000); @@ -668,6 +683,7 @@ class boss_professor_putricide : public CreatureScript me->SetFacingToObject(face); me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); Talk(SAY_TRANSFORM_2); + summons.remove_if(AbominationDespawner(me)); events.ScheduleEvent(EVENT_RESUME_ATTACK, 8500, 0, PHASE_COMBAT_3); break; default: @@ -702,57 +718,78 @@ class boss_professor_putricide : public CreatureScript } }; -class npc_volatile_ooze : public CreatureScript +class npc_putricide_oozeAI : public ScriptedAI { public: - npc_volatile_ooze() : CreatureScript("npc_volatile_ooze") { } + npc_putricide_oozeAI(Creature* creature, uint32 hitTargetSpellId) : ScriptedAI(creature), + _newTargetSelectTimer(0), _hitTargetSpellId(hitTargetSpellId) + { + } - struct npc_putricide_oozeAI : public ScriptedAI + void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) { - npc_putricide_oozeAI(Creature* creature) : ScriptedAI(creature) - { - _newTargetSelectTimer = 0; - } + if (!_newTargetSelectTimer && spell->Id == sSpellMgr->GetSpellIdForDifficulty(_hitTargetSpellId, me)) + _newTargetSelectTimer = 1000; + } - void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) - { - if (!_newTargetSelectTimer && spell->Id == sSpellMgr->GetSpellIdForDifficulty(SPELL_OOZE_ERUPTION, me)) - _newTargetSelectTimer = 1000; - } + void SpellHit(Unit* /*caster*/, SpellInfo const* spell) + { + if (spell->Id == SPELL_TEAR_GAS_CREATURE) + _newTargetSelectTimer = 1000; + } + + void UpdateAI(uint32 const diff) + { + if (!UpdateVictim() && !_newTargetSelectTimer) + return; + + if (!_newTargetSelectTimer && !me->IsNonMeleeSpellCasted(false, false, true, false, true)) + _newTargetSelectTimer = 1000; + + DoMeleeAttackIfReady(); - void SpellHit(Unit* /*caster*/, SpellInfo const* spell) + if (!_newTargetSelectTimer) + return; + + if (me->HasAura(SPELL_TEAR_GAS_CREATURE)) + return; + + if (_newTargetSelectTimer <= diff) { - if (spell->Id == SPELL_TEAR_GAS_CREATURE) - _newTargetSelectTimer = 1000; + _newTargetSelectTimer = 0; + CastMainSpell(); } + else + _newTargetSelectTimer -= diff; + } - void UpdateAI(uint32 const diff) - { - if (!UpdateVictim() && !_newTargetSelectTimer) - return; + virtual void CastMainSpell() = 0; - if (!_newTargetSelectTimer) - return; + private: + uint32 _hitTargetSpellId; + uint32 _newTargetSelectTimer; +}; - if (me->HasAura(SPELL_TEAR_GAS_CREATURE)) - return; +class npc_volatile_ooze : public CreatureScript +{ + public: + npc_volatile_ooze() : CreatureScript("npc_volatile_ooze") { } - if (_newTargetSelectTimer <= diff) - { - _newTargetSelectTimer = 0; - me->CastSpell(me, SPELL_VOLATILE_OOZE_ADHESIVE, false); - } - else - _newTargetSelectTimer -= diff; + struct npc_volatile_oozeAI : public npc_putricide_oozeAI + { + npc_volatile_oozeAI(Creature* creature) : npc_putricide_oozeAI(creature, SPELL_OOZE_ERUPTION) + { } - private: - uint32 _newTargetSelectTimer; + void CastMainSpell() + { + me->CastSpell(me, SPELL_VOLATILE_OOZE_ADHESIVE, false); + } }; CreatureAI* GetAI(Creature* creature) const { - return GetIcecrownCitadelAI<npc_putricide_oozeAI>(creature); + return GetIcecrownCitadelAI<npc_volatile_oozeAI>(creature); } }; @@ -761,45 +798,16 @@ class npc_gas_cloud : public CreatureScript public: npc_gas_cloud() : CreatureScript("npc_gas_cloud") { } - struct npc_gas_cloudAI : public ScriptedAI + struct npc_gas_cloudAI : public npc_putricide_oozeAI { - npc_gas_cloudAI(Creature* creature) : ScriptedAI(creature) + npc_gas_cloudAI(Creature* creature) : npc_putricide_oozeAI(creature, SPELL_EXPUNGED_GAS) { _newTargetSelectTimer = 0; } - void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) - { - if (!_newTargetSelectTimer && spell->Id == sSpellMgr->GetSpellIdForDifficulty(SPELL_EXPUNGED_GAS, me)) - _newTargetSelectTimer = 1000; - } - - void SpellHit(Unit* /*caster*/, SpellInfo const* spell) + void CastMainSpell() { - if (spell->Id == SPELL_TEAR_GAS_CREATURE) - _newTargetSelectTimer = 1000; - } - - void UpdateAI(uint32 const diff) - { - if (!UpdateVictim() && !_newTargetSelectTimer) - return; - - DoMeleeAttackIfReady(); - - if (!_newTargetSelectTimer) - return; - - if (me->HasAura(SPELL_TEAR_GAS_CREATURE)) - return; - - if (_newTargetSelectTimer <= diff) - { - _newTargetSelectTimer = 0; - me->CastCustomSpell(SPELL_GASEOUS_BLOAT, SPELLVALUE_AURA_STACK, 10, me, false); - } - else - _newTargetSelectTimer -= diff; + me->CastCustomSpell(SPELL_GASEOUS_BLOAT, SPELLVALUE_AURA_STACK, 10, me, false); } private: @@ -900,23 +908,12 @@ class spell_putricide_ooze_channel : public SpellScriptLoader GetCaster()->AddThreat(GetHitUnit(), 500000000.0f); // value seen in sniff } - // temporary, until SelectTarget are not called on empty lists - void CheckTarget() - { - if (_target) - return; - - FinishCast(SPELL_FAILED_NO_VALID_TARGETS); - GetCaster()->ToCreature()->DespawnOrUnsummon(1); // despawn next update - } - void Register() { OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel_SpellScript::SetTarget, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel_SpellScript::SetTarget, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); AfterHit += SpellHitFn(spell_putricide_ooze_channel_SpellScript::StartAttack); - OnCast += SpellCastFn(spell_putricide_ooze_channel_SpellScript::CheckTarget); } WorldObject* _target; @@ -1125,6 +1122,21 @@ class spell_putricide_unbound_plague : public SpellScriptLoader return true; } + SpellCastResult CheckCast() + { + if (AuraEffect const* eff = GetCaster()->GetAuraEffect(SPELL_UNBOUND_PLAGUE_SEARCHER, EFFECT_0)) + if (eff->GetTickNumber() < 2) + return SPELL_FAILED_DONT_REPORT; + + return SPELL_CAST_OK; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + targets.remove_if(Trinity::UnitAuraCheck(true, sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()))); + Trinity::Containers::RandomResizeList(targets, 1); + } + void HandleScript(SpellEffIndex /*effIndex*/) { if (!GetHitUnit()) @@ -1159,6 +1171,8 @@ class spell_putricide_unbound_plague : public SpellScriptLoader void Register() { + OnCheckCast += SpellCheckCastFn(spell_putricide_unbound_plague_SpellScript::CheckCast); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_unbound_plague_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); OnEffectHitTarget += SpellEffectFn(spell_putricide_unbound_plague_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index a8657925131..ba1a0614cdf 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -2112,7 +2112,7 @@ class spell_the_lich_king_necrotic_plague : public SpellScriptLoader CustomSpellValues values; //values.AddSpellMod(SPELLVALUE_AURA_STACK, 2); values.AddSpellMod(SPELLVALUE_MAX_TARGETS, 1); - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, true, NULL, NULL, GetCasterGUID()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, TRIGGERED_FULL_MASK, NULL, NULL, GetCasterGUID()); if (Unit* caster = GetCaster()) caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); } @@ -2204,7 +2204,7 @@ class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader CustomSpellValues values; values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, true, NULL, NULL, GetCasterGUID()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, TRIGGERED_FULL_MASK, NULL, NULL, GetCasterGUID()); if (Unit* caster = GetCaster()) caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); } @@ -2223,7 +2223,7 @@ class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader CustomSpellValues values; values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); values.AddSpellMod(SPELLVALUE_BASE_POINT1, AURA_REMOVE_BY_ENEMY_SPELL); // add as marker (spell has no effect 1) - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, true, NULL, NULL, GetCasterGUID()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, TRIGGERED_FULL_MASK, NULL, NULL, GetCasterGUID()); if (Unit* caster = GetCaster()) caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp index 708ed600933..e68e28be99b 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp @@ -113,6 +113,13 @@ enum EmeraldDrake SPELL_EMERALD_DREAM_FUNNEL = 50344 //(60 yds) - Channeled - Transfers 5% of the caster's max health to a friendly drake every second for 10 seconds as long as the caster channels. }; +enum EregosData +{ + DATA_RUBY_VOID = 0, // http://www.wowhead.com/achievement=2044 + DATA_EMERALD_VOID = 1, // http://www.wowhead.com/achievement=2045 + DATA_AMBER_VOID = 2 // http://www.wowhead.com/achievement=2046 +}; + class boss_eregos : public CreatureScript { public: @@ -126,12 +133,15 @@ public: struct boss_eregosAI : public BossAI { boss_eregosAI(Creature* creature) : BossAI(creature, DATA_EREGOS_EVENT) { } - + void Reset() { _Reset(); + _phase = PHASE_NORMAL; - phase = PHASE_NORMAL; + _rubyVoid = true; + _emeraldVoid = true; + _amberVoid = true; DoAction(ACTION_SET_NORMAL_EVENTS); } @@ -141,6 +151,31 @@ public: _EnterCombat(); Talk(SAY_AGGRO); + /* Checks for present drakes vehicles from each type and deactivate achievement that corresponds to each found + The checks are so big in case some party try weird things like pulling boss down or hiding out of check range, the only thing player need is to get the boss kill credit after the check /even if he or his drake die/ + Drakes mechanic would despawn all after unmount and also drakes should be auto mounted after item use, item use after Eregos is engaged leads to his despawn - based on retail data. */ + if (me->FindNearestCreature(NPC_RUBY_DRAKE_VEHICLE, 500.0f, true)) + _rubyVoid = false; + if (me->FindNearestCreature(NPC_EMERALD_DRAKE_VEHICLE, 500.0f, true)) + _emeraldVoid = false; + if (me->FindNearestCreature(NPC_AMBER_DRAKE_VEHICLE, 500.0f, true)) + _amberVoid = false; + } + + uint32 GetData(uint32 type) + { + switch (type) + { + case DATA_RUBY_VOID: + return _rubyVoid; + case DATA_EMERALD_VOID: + return _emeraldVoid; + case DATA_AMBER_VOID: + return _amberVoid; + default: + break; + } + return 0; } void DoAction(const int32 action) @@ -180,11 +215,11 @@ public: if (!me->GetMap()->IsHeroic()) return; - if ( (me->GetHealthPct() < 60.0f && me->GetHealthPct() > 20.0f && phase < PHASE_FIRST_PLANAR) - || (me->GetHealthPct() < 20.0f && phase < PHASE_SECOND_PLANAR) ) + if ( (me->GetHealthPct() < 60.0f && me->GetHealthPct() > 20.0f && _phase < PHASE_FIRST_PLANAR) + || (me->GetHealthPct() < 20.0f && _phase < PHASE_SECOND_PLANAR) ) { events.Reset(); - phase = (me->GetHealthPct() < 60.0f && me->GetHealthPct() > 20.0f) ? PHASE_FIRST_PLANAR : PHASE_SECOND_PLANAR; + _phase = (me->GetHealthPct() < 60.0f && me->GetHealthPct() > 20.0f) ? PHASE_FIRST_PLANAR : PHASE_SECOND_PLANAR; DoCast(SPELL_PLANAR_SHIFT); @@ -241,8 +276,11 @@ public: _JustDied(); } - private: - uint8 phase; + private: + uint8 _phase; + bool _rubyVoid; + bool _emeraldVoid; + bool _amberVoid; }; }; @@ -274,8 +312,25 @@ class spell_eregos_planar_shift : public SpellScriptLoader } }; -void AddSC_boss_eregos() +class achievement_gen_eregos_void : public AchievementCriteriaScript { + public: + achievement_gen_eregos_void(char const* name, uint32 data) : AchievementCriteriaScript(name), _data(data) { } + + bool OnCheck(Player* /*player*/, Unit* target) + { + return target && target->GetAI()->GetData(_data); + } + + private: + uint32 _data; +}; + + void AddSC_boss_eregos() + { new boss_eregos(); new spell_eregos_planar_shift(); -} + new achievement_gen_eregos_void("achievement_ruby_void", DATA_RUBY_VOID); + new achievement_gen_eregos_void("achievement_emerald_void", DATA_EMERALD_VOID); + new achievement_gen_eregos_void("achievement_amber_void", DATA_AMBER_VOID); + } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index f53020a72c4..b987b00fa5b 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -125,7 +125,8 @@ public: void Reset() { - instance->SetData(DATA_PRINCEKELESETH_EVENT, NOT_STARTED); + if (instance) + instance->SetData(DATA_PRINCEKELESETH_EVENT, NOT_STARTED); events.Reset(); events.ScheduleEvent(EVENT_SHADOWBOLT, urand(2,3)*IN_MILLISECONDS); @@ -140,13 +141,15 @@ public: void EnterCombat(Unit* /*who*/) { me->SetInCombatWithZone(); - instance->SetData(DATA_PRINCEKELESETH_EVENT, IN_PROGRESS); + if (instance) + instance->SetData(DATA_PRINCEKELESETH_EVENT, IN_PROGRESS); Talk(SAY_START_COMBAT); } void JustDied(Unit* /*killer*/) { - instance->SetData(DATA_PRINCEKELESETH_EVENT, DONE); + if (instance) + instance->SetData(DATA_PRINCEKELESETH_EVENT, DONE); summons.DespawnAll(); Talk(SAY_DEATH); } diff --git a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp index 122d051f1dd..870ea893b78 100644 --- a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp @@ -782,10 +782,13 @@ struct violet_hold_trashAI : public npc_escortAI void JustDied(Unit* /*killer*/) { - if (Creature* portal = Unit::GetCreature((*me), instance->GetData64(DATA_TELEPORTATION_PORTAL))) - CAST_AI(npc_teleportation_portal_vh::npc_teleportation_portalAI, portal->AI())->SummonedMobDied(me); if (instance) + { + if (Creature* portal = Unit::GetCreature((*me), instance->GetData64(DATA_TELEPORTATION_PORTAL))) + CAST_AI(npc_teleportation_portal_vh::npc_teleportation_portalAI, portal->AI())->SummonedMobDied(me); + instance->SetData(DATA_NPC_PRESENCE_AT_DOOR_REMOVE, 1); + } } void CreatureStartAttackDoor() diff --git a/src/server/scripts/Northrend/dragonblight.cpp b/src/server/scripts/Northrend/dragonblight.cpp index 1f1d24453ee..a26ee4e9270 100644 --- a/src/server/scripts/Northrend/dragonblight.cpp +++ b/src/server/scripts/Northrend/dragonblight.cpp @@ -190,7 +190,7 @@ class npc_wyrmrest_defender : public CreatureScript npc_wyrmrest_defender() : CreatureScript("npc_wyrmrest_defender") { } bool OnGossipHello(Player* player, Creature* creature) - { + { if (player->GetQuestStatus(QUEST_DEFENDING_WYRMREST_TEMPLE) == QUEST_STATUS_INCOMPLETE) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); diff --git a/src/server/scripts/Northrend/storm_peaks.cpp b/src/server/scripts/Northrend/storm_peaks.cpp index 60c289dc8de..976a6e5dba5 100644 --- a/src/server/scripts/Northrend/storm_peaks.cpp +++ b/src/server/scripts/Northrend/storm_peaks.cpp @@ -20,6 +20,7 @@ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "Vehicle.h" +#include "CombatAI.h" /*###### ## npc_agnetta_tyrsdottar @@ -131,132 +132,6 @@ public: } }; -/*###### -## npc_thorim -######*/ - -#define GOSSIP_HN "Thorim?" -#define GOSSIP_SN1 "Can you tell me what became of Sif?" -#define GOSSIP_SN2 "He did more than that, Thorim. He controls Ulduar now." -#define GOSSIP_SN3 "It needn't end this way." - -enum eThorim -{ - QUEST_SIBLING_RIVALRY = 13064, - NPC_THORIM = 29445, - GOSSIP_TEXTID_THORIM1 = 13799, - GOSSIP_TEXTID_THORIM2 = 13801, - GOSSIP_TEXTID_THORIM3 = 13802, - GOSSIP_TEXTID_THORIM4 = 13803 -}; - -class npc_thorim : public CreatureScript -{ -public: - npc_thorim() : CreatureScript("npc_thorim") { } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (creature->isQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); - - if (player->GetQuestStatus(QUEST_SIBLING_RIVALRY) == QUEST_STATUS_INCOMPLETE) { - player->ADD_GOSSIP_ITEM(0, GOSSIP_HN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM1, creature->GetGUID()); - return true; - } - return false; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) - { - player->PlayerTalkClass->ClearMenus(); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, GOSSIP_SN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM2, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, GOSSIP_SN2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM3, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, GOSSIP_SN3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM4, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->CLOSE_GOSSIP_MENU(); - player->CompleteQuest(QUEST_SIBLING_RIVALRY); - break; - } - return true; - } -}; - -/*###### -## npc_loklira_crone -######*/ - -#define GOSSIP_LOKLIRACRONE "Tell me about this proposal" -#define GOSSIP_LOKLIRACRONE1 "What happened then?" -#define GOSSIP_LOKLIRACRONE2 "You want me to take part in the Hyldsmeet to end the war?" -#define GOSSIP_LOKLIRACRONE3 "Very well. I'll take part in this competition." - -enum eLokliraCrone -{ - QUEST_HYLDSMEET = 12970, - - GOSSIP_TEXTID_LOK1 = 13778, - GOSSIP_TEXTID_LOK2 = 13779, - GOSSIP_TEXTID_LOK3 = 13780 -}; - -class npc_loklira_crone : public CreatureScript -{ -public: - npc_loklira_crone() : CreatureScript("npc_loklira_crone") { } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (creature->isQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); - - if (player->GetQuestStatus(QUEST_HYLDSMEET) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); - return true; - } - return false; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) - { - player->PlayerTalkClass->ClearMenus(); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_LOK1, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_LOK2, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_LOK3, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->CLOSE_GOSSIP_MENU(); - player->CompleteQuest(QUEST_HYLDSMEET); - break; - } - return true; - } -}; - ///////////////////// ///npc_injured_goblin ///////////////////// @@ -409,14 +284,12 @@ public: ## npc_brunnhildar_prisoner ######*/ -enum brunhildar { - NPC_QUEST_GIVER = 29592, - +enum BrunnhildarPrisoner { SPELL_ICE_PRISON = 54894, - SPELL_KILL_CREDIT_PRISONER = 55144, - SPELL_KILL_CREDIT_DRAKE = 55143, - SPELL_SUMMON_LIBERATED = 55073, - SPELL_ICE_LANCE = 55046 + SPELL_ICE_LANCE = 55046, + SPELL_FREE_PRISONER = 55048, + SPELL_RIDE_DRAKE = 55074, + SPELL_SHARD_IMPACT = 55047 }; class npc_brunnhildar_prisoner : public CreatureScript @@ -428,129 +301,169 @@ public: { npc_brunnhildar_prisonerAI(Creature* creature) : ScriptedAI(creature) {} - uint64 drakeGUID; - uint16 enter_timer; - bool hasEmptySeats; + bool freed; void Reset() { + freed = false; me->CastSpell(me, SPELL_ICE_PRISON, true); - enter_timer = 0; - drakeGUID = 0; - hasEmptySeats = false; } - void UpdateAI(const uint32 diff) + void JustRespawned() { - //TODO: not good script - if (!drakeGUID) + Reset(); + } + + void UpdateAI(const uint32 /*diff*/) + { + if (!freed) return; - Creature* drake = Unit::GetCreature(*me, drakeGUID); - if (!drake) + if (!me->HasUnitState(UNIT_STATE_ONVEHICLE)) { - drakeGUID = 0; - return; + me->DespawnOrUnsummon(); } + } - // drake unsummoned, passengers dropped - if (!me->IsOnVehicle(drake) && !hasEmptySeats) - me->DespawnOrUnsummon(3000); - - if (enter_timer <= 0) + void SpellHit(Unit* caster, const SpellInfo* spell) + { + if (spell->Id != SPELL_ICE_LANCE) return; - if (enter_timer < diff) + if (caster->GetVehicleKit()->GetAvailableSeatCount() != 0) { - enter_timer = 0; - if (hasEmptySeats) - me->JumpTo(drake, 25.0f); - else - Reset(); + me->CastSpell(me, SPELL_FREE_PRISONER, true); + me->CastSpell(caster, SPELL_RIDE_DRAKE, true); + me->CastSpell(me, SPELL_SHARD_IMPACT, true); + freed = true; } - else - enter_timer -= diff; } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_brunnhildar_prisonerAI(creature); + } +}; + +/*###### +## npc_freed_protodrake +######*/ + +enum FreedProtoDrake +{ + AREA_VALLEY_OF_ANCIENT_WINTERS = 4437, + TEXT_EMOTE = 0, + SPELL_KILL_CREDIT_PRISONER = 55144, + SPELL_SUMMON_LIBERATED = 55073, + SPELL_KILL_CREDIT_DRAKE = 55143 +}; + +const Position FreedDrakeWaypoints[16] = +{ + {7294.96f, -2418.733f, 823.869f, 0.0f}, + {7315.984f, -2331.46f, 826.3972f, 0.0f}, + {7271.826f, -2271.479f, 833.5917f, 0.0f}, + {7186.253f, -2218.475f, 847.5632f, 0.0f}, + {7113.195f, -2164.288f, 850.2301f, 0.0f}, + {7078.018f, -2063.106f, 854.7581f, 0.0f}, + {7073.221f, -1983.382f, 861.9246f, 0.0f}, + {7061.455f, -1885.899f, 865.119f, 0.0f}, + {7033.32f, -1826.775f, 876.2578f, 0.0f}, + {6999.902f, -1784.012f, 897.4521f, 0.0f}, + {6954.913f, -1747.043f, 897.4521f, 0.0f}, + {6933.856f, -1720.698f, 882.2022f, 0.0f}, + {6932.729f, -1687.306f, 866.1189f, 0.0f}, + {6952.458f, -1663.802f, 849.8133f, 0.0f}, + {7002.819f, -1651.681f, 831.397f, 0.0f}, + {7026.531f, -1649.239f, 828.8406f, 0.0f} +}; - void MoveInLineOfSight(Unit* who) + +class npc_freed_protodrake : public CreatureScript +{ +public: + npc_freed_protodrake() : CreatureScript("npc_freed_protodrake") { } + + struct npc_freed_protodrakeAI : public VehicleAI + { + npc_freed_protodrakeAI(Creature* creature) : VehicleAI(creature) {} + + bool autoMove; + bool wpReached; + uint16 CheckTimer; + uint16 countWP; + + void Reset() { - if (!who || !drakeGUID) + autoMove = false; + wpReached = false; + CheckTimer = 5000; + countWP = 0; + } + + void MovementInform(uint32 type, uint32 id) + { + if (type != POINT_MOTION_TYPE) return; - Creature* drake = Unit::GetCreature(*me, drakeGUID); - if (!drake) + if (id < 15) { - drakeGUID = 0; - return; + ++countWP; + wpReached = true; } - - if (!me->IsOnVehicle(drake) && !me->HasAura(SPELL_ICE_PRISON)) + else + // drake reached village { - if (who->IsVehicle() && me->IsWithinDist(who, 25.0f, true) && who->ToCreature() && who->ToCreature()->GetEntry() == 29709) + // get player that rides drake (from seat 0) + Unit* player = me->GetVehicleKit()->GetPassenger(0); + if (player && player->GetTypeId() == TYPEID_PLAYER) { - uint8 seat = who->GetVehicleKit()->GetNextEmptySeat(0, true); - if (seat <= 0) - return; - - me->EnterVehicle(who, seat); - me->SendMovementFlagUpdate(); - hasEmptySeats = false; + // for each prisoner on drake,give credit + for (uint8 i = 1; i < 4; ++i) + if (Unit* prisoner = me->GetVehicleKit()->GetPassenger(i)) + { + if (prisoner->GetTypeId() != TYPEID_UNIT) + return; + prisoner->CastSpell(player, SPELL_KILL_CREDIT_PRISONER, true); + prisoner->CastSpell(prisoner, SPELL_SUMMON_LIBERATED, true); + prisoner->ExitVehicle(); + } + me->CastSpell(me, SPELL_KILL_CREDIT_DRAKE, true); + player->ExitVehicle(); } } + } - if (who->ToCreature() && me->IsOnVehicle(drake)) + void UpdateAI(const uint32 diff) + { + if (!autoMove) { - if (who->ToCreature()->GetEntry() == NPC_QUEST_GIVER && me->IsWithinDist(who, 15.0f, false)) + if (CheckTimer < diff) { - Unit* rider = drake->GetVehicleKit()->GetPassenger(0); - if (!rider) - return; - - rider->CastSpell(rider, SPELL_KILL_CREDIT_PRISONER, true); - - me->ExitVehicle(); - me->CastSpell(me, SPELL_SUMMON_LIBERATED, true); - me->DespawnOrUnsummon(500); - - // drake is empty now, deliver credit for drake and despawn him - if (drake->GetVehicleKit()->HasEmptySeat(1) && - drake->GetVehicleKit()->HasEmptySeat(2) && - drake->GetVehicleKit()->HasEmptySeat(3)) + CheckTimer = 5000; + if (me->GetAreaId() == AREA_VALLEY_OF_ANCIENT_WINTERS) { - // not working rider->CastSpell(rider, SPELL_KILL_CREDIT_DRAKE, true); - if (rider->ToPlayer()) - rider->ToPlayer()->KilledMonsterCredit(29709, 0); - - drake->DespawnOrUnsummon(0); + Talk(TEXT_EMOTE, me->GetVehicleKit()->GetPassenger(0)->GetGUID()); + autoMove = true; + wpReached = true; } } + else + CheckTimer -= diff; } - } - - void SpellHit(Unit* hitter, const SpellInfo* spell) - { - if (!hitter || !spell) - return; - - if (spell->Id != SPELL_ICE_LANCE) - return; - me->RemoveAura(SPELL_ICE_PRISON); - enter_timer = 500; - - if (hitter->IsVehicle()) - drakeGUID = hitter->GetGUID(); - else - return; - - if (hitter->GetVehicleKit()->GetNextEmptySeat(0, true)) - hasEmptySeats = true; + if (wpReached && autoMove) + { + wpReached = false; + me->GetMotionMaster()->MovePoint(countWP, FreedDrakeWaypoints[countWP]); + } } }; CreatureAI* GetAI(Creature* creature) const { - return new npc_brunnhildar_prisonerAI(creature); + return new npc_freed_protodrakeAI(creature); } }; @@ -655,11 +568,10 @@ void AddSC_storm_peaks() { new npc_agnetta_tyrsdottar(); new npc_frostborn_scout(); - new npc_thorim(); - new npc_loklira_crone(); new npc_injured_goblin(); new npc_roxi_ramrocket(); new npc_brunnhildar_prisoner(); + new npc_freed_protodrake(); new npc_icefang(); new npc_hyldsmeet_protodrake(); } diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index 44c37fc9753..ec9e4e116bf 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -181,6 +181,23 @@ public: me->RemoveAurasDueToSpell(SPELL_SUBMERGE); } + void MoveInLineOfSight(Unit* who) + { + if (!who) + return; + + if (me->isInCombat()) + return; + + if (who->GetTypeId() != TYPEID_PLAYER) + return; + + if (me->GetDistance(who) > 50.0f) + return; + + AttackStartNoMove(who); + } + void EnterCombat(Unit* who) { me->AddThreat(who, 10000.0f); @@ -412,6 +429,7 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->Yell(SUFF_SAY_RECAP, LANG_UNIVERSAL, 0); DoScriptText(SUFF_SAY_RECAP, me); + me->SetReactState(REACT_PASSIVE); } } @@ -532,6 +550,7 @@ public: damage = 0; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); DoScriptText(SUFF_SAY_RECAP, me); + me->SetReactState(REACT_PASSIVE); } else { diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp index 84d292e1fe4..b42641c5171 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp @@ -160,7 +160,7 @@ class go_broggok_lever : public GameObjectScript public: go_broggok_lever() : GameObjectScript("go_broggok_lever") {} - bool OnGossipHello(Player* player, GameObject* go) + bool OnGossipHello(Player* /*player*/, GameObject* go) { if (InstanceScript* instance = go->GetInstanceScript()) if (instance->GetData(TYPE_BROGGOK_EVENT) != DONE && instance->GetData(TYPE_BROGGOK_EVENT) != IN_PROGRESS) diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp index 893f97fe711..233a8d82497 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp @@ -133,7 +133,7 @@ class instance_blood_furnace : public InstanceMapScript } } - void OnCreatureDeath(Creature* unit) + void OnUnitDeath(Unit* unit) { if (unit && unit->GetTypeId() == TYPEID_UNIT && unit->GetEntry() == 17398) PrisonerDied(unit->GetGUID()); @@ -350,10 +350,10 @@ class instance_blood_furnace : public InstanceMapScript ++PrisonerCounter8; } else - return; + return; } else - return; + return; ResetPrisoner(creature); } diff --git a/src/server/scripts/Outland/shadowmoon_valley.cpp b/src/server/scripts/Outland/shadowmoon_valley.cpp index 1656f7221ed..078f8f5a4f0 100644 --- a/src/server/scripts/Outland/shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/shadowmoon_valley.cpp @@ -839,19 +839,10 @@ public: return 1500; break; case 16: - if (player) - { - Illi->CastSpell(player, SPELL_TWO, true); - player->RemoveAurasDueToSpell(SPELL_THREE); - player->RemoveAurasDueToSpell(SPELL_FOUR); - return 5000; - } - else - { - player->FailQuest(QUEST_LORD_ILLIDAN_STORMRAGE); - Step = 30; - return 100; - } + Illi->CastSpell(player, SPELL_TWO, true); + player->RemoveAurasDueToSpell(SPELL_THREE); + player->RemoveAurasDueToSpell(SPELL_FOUR); + return 5000; break; case 17: DoScriptText(LORD_ILLIDAN_SAY_5, Illi); @@ -1871,8 +1862,8 @@ public: enum ZuluhedChains { - QUEST_ZULUHED = 10866, - NPC_KARYNAKU = 22112, + QUEST_ZULUHED = 10866, + NPC_KARYNAKU = 22112, }; class spell_unlocking_zuluheds_chains : public SpellScriptLoader @@ -1884,18 +1875,21 @@ class spell_unlocking_zuluheds_chains : public SpellScriptLoader { PrepareSpellScript(spell_unlocking_zuluheds_chains_SpellScript); - void HandleOnCast() + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleAfterHit() { - // FIXME: Hackish solution, a better way to reward killcredit should be found - if (Unit* caster = GetCaster()) - if(Player* player = caster->ToPlayer()) - if (player->GetQuestStatus(QUEST_ZULUHED) == QUEST_STATUS_INCOMPLETE) - player->CastedCreatureOrGO(NPC_KARYNAKU, MAKE_NEW_GUID(0, NPC_KARYNAKU, HIGHGUID_UNIT), 0); + Player* caster = GetCaster()->ToPlayer(); + if (caster->GetQuestStatus(QUEST_ZULUHED) == QUEST_STATUS_INCOMPLETE) + caster->KilledMonsterCredit(NPC_KARYNAKU, 0); } void Register() { - OnCast += SpellCastFn(spell_unlocking_zuluheds_chains_SpellScript::HandleOnCast); + AfterHit += SpellHitFn(spell_unlocking_zuluheds_chains_SpellScript::HandleAfterHit); } }; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 5153010c0cc..d10d7725e2e 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -907,9 +907,22 @@ class spell_gen_profession_research : public SpellScriptLoader return SPELL_CAST_OK; } + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + uint32 spellId = GetSpellInfo()->Id; + + // learn random explicit discovery recipe (if any) + if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster)) + caster->learnSpell(discoveredSpellId, false); + + caster->UpdateCraftSkill(spellId); + } + void Register() { OnCheckCast += SpellCheckCastFn(spell_gen_profession_research_SpellScript::CheckRequirement); + OnEffectHitTarget += SpellEffectFn(spell_gen_profession_research_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -3237,6 +3250,58 @@ class spell_gen_bonked : public SpellScriptLoader } }; +class spell_gen_gift_of_naaru : public SpellScriptLoader +{ + public: + spell_gen_gift_of_naaru() : SpellScriptLoader("spell_gen_gift_of_naaru") { } + + class spell_gen_gift_of_naaru_AuraScript : public AuraScript + { + PrepareAuraScript(spell_gen_gift_of_naaru_AuraScript); + + void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) + { + if (!GetCaster()) + return; + + float heal = 0.0f; + switch (GetSpellInfo()->SpellFamilyName) + { + case SPELLFAMILY_MAGE: + case SPELLFAMILY_WARLOCK: + case SPELLFAMILY_PRIEST: + heal = 1.885f * float(GetCaster()->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask())); + break; + case SPELLFAMILY_PALADIN: + case SPELLFAMILY_SHAMAN: + heal = std::max(1.885f * float(GetCaster()->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask())), 1.1f * float(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK))); + break; + case SPELLFAMILY_WARRIOR: + case SPELLFAMILY_HUNTER: + case SPELLFAMILY_DEATHKNIGHT: + heal = 1.1f * float(std::max(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK), GetCaster()->GetTotalAttackPowerValue(RANGED_ATTACK))); + break; + case SPELLFAMILY_GENERIC: + default: + break; + } + + int32 healTick = floor(heal / aurEff->GetTotalTicks()); + amount += int32(std::max(healTick, 0)); + } + + void Register() + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_gift_of_naaru_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_HEAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_gen_gift_of_naaru_AuraScript(); + } +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -3312,4 +3377,5 @@ void AddSC_generic_spell_scripts() new spell_gen_mount("spell_x53_touring_rocket", 0, 0, 0, SPELL_X53_TOURING_ROCKET_150, SPELL_X53_TOURING_ROCKET_280, SPELL_X53_TOURING_ROCKET_310); new spell_gen_upper_deck_create_foam_sword(); new spell_gen_bonked(); + new spell_gen_gift_of_naaru(); } diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 3c89cb7005a..0508d95a60b 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -836,9 +836,20 @@ class spell_item_book_of_glyph_mastery : public SpellScriptLoader return SPELL_CAST_OK; } + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + uint32 spellId = GetSpellInfo()->Id; + + // learn random explicit discovery recipe (if any) + if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster)) + caster->learnSpell(discoveredSpellId, false); + } + void Register() { OnCheckCast += SpellCheckCastFn(spell_item_book_of_glyph_mastery_SpellScript::CheckRequirement); + OnEffectHitTarget += SpellEffectFn(spell_item_book_of_glyph_mastery_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index cbf45910495..06d3602d8e8 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -25,6 +25,9 @@ #include "ScriptedCreature.h" #include "SpellScript.h" #include "Vehicle.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" class spell_generic_quest_update_entry_SpellScript : public SpellScript { @@ -1314,6 +1317,174 @@ class spell_q12372_destabilize_azure_dragonshrine_dummy : public SpellScriptLoad } }; +// "Bombing Run" and "Bomb Them Again!" +enum Quest11010_11102_11023Data +{ + // Spell + SPELL_FLAK_CANNON_TRIGGER = 40110, + SPELL_CHOOSE_LOC = 40056, + SPELL_AGGRO_CHECK = 40112, + // NPCs + NPC_FEL_CANNON2 = 23082 +}; + +// 40113 Knockdown Fel Cannon: The Aggro Check Aura +class spell_q11010_q11102_q11023_aggro_check_aura : public SpellScriptLoader +{ + public: + spell_q11010_q11102_q11023_aggro_check_aura() : SpellScriptLoader("spell_q11010_q11102_q11023_aggro_check_aura") { } + + class spell_q11010_q11102_q11023_aggro_check_aura_AuraScript : public AuraScript + { + PrepareAuraScript(spell_q11010_q11102_q11023_aggro_check_aura_AuraScript); + + void HandleTriggerSpell(AuraEffect const* /*aurEff*/) + { + if (Unit* target = GetTarget()) + // On trigger proccing + target->CastSpell(target, SPELL_AGGRO_CHECK); + } + + void Register() + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_q11010_q11102_q11023_aggro_check_aura_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_q11010_q11102_q11023_aggro_check_aura_AuraScript(); + } +}; + +// 40112 Knockdown Fel Cannon: The Aggro Check +class spell_q11010_q11102_q11023_aggro_check : public SpellScriptLoader +{ + public: + spell_q11010_q11102_q11023_aggro_check() : SpellScriptLoader("spell_q11010_q11102_q11023_aggro_check") { } + + class spell_q11010_q11102_q11023_aggro_check_SpellScript : public SpellScript + { + PrepareSpellScript(spell_q11010_q11102_q11023_aggro_check_SpellScript); + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Player* playerTarget = GetHitPlayer()) + // Check if found player target is on fly mount or using flying form + if (playerTarget->HasAuraType(SPELL_AURA_FLY) || playerTarget->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)) + playerTarget->CastSpell(playerTarget, SPELL_FLAK_CANNON_TRIGGER, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q11010_q11102_q11023_aggro_check_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_q11010_q11102_q11023_aggro_check_SpellScript(); + } +}; + +// 40119 Knockdown Fel Cannon: The Aggro Burst +class spell_q11010_q11102_q11023_aggro_burst : public SpellScriptLoader +{ + public: + spell_q11010_q11102_q11023_aggro_burst() : SpellScriptLoader("spell_q11010_q11102_q11023_aggro_burst") { } + + class spell_q11010_q11102_q11023_aggro_burst_AuraScript : public AuraScript + { + PrepareAuraScript(spell_q11010_q11102_q11023_aggro_burst_AuraScript); + + void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) + { + if (Unit* target = GetTarget()) + // On each tick cast Choose Loc to trigger summon + target->CastSpell(target, SPELL_CHOOSE_LOC); + } + + void Register() + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_q11010_q11102_q11023_aggro_burst_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_q11010_q11102_q11023_aggro_burst_AuraScript(); + } +}; + +// 40056 Knockdown Fel Cannon: Choose Loc +class spell_q11010_q11102_q11023_choose_loc : public SpellScriptLoader +{ + public: + spell_q11010_q11102_q11023_choose_loc() : SpellScriptLoader("spell_q11010_q11102_q11023_choose_loc") { } + + class spell_q11010_q11102_q11023_choose_loc_SpellScript : public SpellScript + { + PrepareSpellScript(spell_q11010_q11102_q11023_choose_loc_SpellScript); + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + // Check for player that is in 65 y range + std::list<Player*> playerList; + Trinity::AnyPlayerInObjectRangeCheck checker(caster, 765.0f); + Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(caster, playerList, checker); + caster->VisitNearbyWorldObject(65.0f, searcher); + for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) + // Check if found player target is on fly mount or using flying form + if ((*itr)->HasAuraType(SPELL_AURA_FLY) || (*itr)->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)) + // Summom Fel Cannon (bunny version) at found player + caster->SummonCreature(NPC_FEL_CANNON2, (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ()); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_q11010_q11102_q11023_choose_loc_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_q11010_q11102_q11023_choose_loc_SpellScript(); + } +}; + +// 39844 - Skyguard Blasting Charge +// 40160 - Throw Bomb +class spell_q11010_q11102_q11023_q11008_check_fly_mount : public SpellScriptLoader +{ + public: + spell_q11010_q11102_q11023_q11008_check_fly_mount() : SpellScriptLoader("spell_q11010_q11102_q11023_q11008_check_fly_mount") { } + + class spell_q11010_q11102_q11023_q11008_check_fly_mount_SpellScript : public SpellScript + { + PrepareSpellScript(spell_q11010_q11102_q11023_q11008_check_fly_mount_SpellScript); + + SpellCastResult CheckRequirement() + { + Unit* caster = GetCaster(); + // This spell will be cast only if caster has one of these auras + if (!(caster->HasAuraType(SPELL_AURA_FLY) || caster->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))) + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + return SPELL_CAST_OK; + } + + void Register() + { + OnCheckCast += SpellCheckCastFn(spell_q11010_q11102_q11023_q11008_check_fly_mount_SpellScript::CheckRequirement); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_q11010_q11102_q11023_q11008_check_fly_mount_SpellScript(); + } +}; + void AddSC_quest_spell_scripts() { new spell_q55_sacred_cleansing(); @@ -1345,4 +1516,9 @@ void AddSC_quest_spell_scripts() new spell_q12735_song_of_cleansing(); new spell_q12372_cast_from_gossip_trigger(); new spell_q12372_destabilize_azure_dragonshrine_dummy(); + new spell_q11010_q11102_q11023_aggro_check_aura(); + new spell_q11010_q11102_q11023_aggro_check(); + new spell_q11010_q11102_q11023_aggro_burst(); + new spell_q11010_q11102_q11023_choose_loc(); + new spell_q11010_q11102_q11023_q11008_check_fly_mount(); } diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index e0131190916..0def62b7d3a 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -41,6 +41,10 @@ enum WarlockSpells WARLOCK_HAUNT_HEAL = 48210, WARLOCK_UNSTABLE_AFFLICTION_DISPEL = 31117, WARLOCK_CURSE_OF_DOOM_EFFECT = 18662, + WARLOCK_IMPROVED_HEALTH_FUNNEL_R1 = 18703, + WARLOCK_IMPROVED_HEALTH_FUNNEL_R2 = 18704, + WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1 = 60955, + WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2 = 60956, }; class spell_warl_banish : public SpellScriptLoader @@ -671,6 +675,48 @@ class spell_warl_curse_of_doom : public SpellScriptLoader } }; +class spell_warl_health_funnel : public SpellScriptLoader +{ +public: + spell_warl_health_funnel() : SpellScriptLoader("spell_warl_health_funnel") { } + + class spell_warl_health_funnel_AuraScript : public AuraScript + { + PrepareAuraScript(spell_warl_health_funnel_AuraScript); + + void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + if (!caster) + return; + + Unit* target = GetTarget(); + if (caster->HasAura(WARLOCK_IMPROVED_HEALTH_FUNNEL_R2)) + target->CastSpell(target, WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2, true); + else if (caster->HasAura(WARLOCK_IMPROVED_HEALTH_FUNNEL_R1)) + target->CastSpell(target, WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1, true); + } + + void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + target->RemoveAurasDueToSpell(WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1); + target->RemoveAurasDueToSpell(WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2); + } + + void Register() + { + OnEffectRemove += AuraEffectRemoveFn(spell_warl_health_funnel_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL); + OnEffectApply += AuraEffectApplyFn(spell_warl_health_funnel_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_warl_health_funnel_AuraScript(); + } +}; + void AddSC_warlock_spell_scripts() { new spell_warl_banish(); @@ -686,4 +732,5 @@ void AddSC_warlock_spell_scripts() new spell_warl_haunt(); new spell_warl_unstable_affliction(); new spell_warl_curse_of_doom(); + new spell_warl_health_funnel(); } diff --git a/src/server/shared/AutoPtr.h b/src/server/shared/AutoPtr.h index 19f0680c267..f4199880abd 100644 --- a/src/server/shared/AutoPtr.h +++ b/src/server/shared/AutoPtr.h @@ -48,6 +48,6 @@ namespace Trinity return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() != x; } }; -}; +} -#endif
\ No newline at end of file +#endif diff --git a/src/server/shared/Containers.h b/src/server/shared/Containers.h index f0242cbff0e..0a1b6738f1a 100644 --- a/src/server/shared/Containers.h +++ b/src/server/shared/Containers.h @@ -63,9 +63,9 @@ namespace Trinity std::advance(it, urand(0, container.size() - 1)); return *it; } - }; + } //! namespace Containers -}; +} //! namespace Trinity -#endif //! #ifdef TRINITY_CONTAINERS_H
\ No newline at end of file +#endif //! #ifdef TRINITY_CONTAINERS_H diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp index 146b2c37ad3..8e424e9bcdb 100755 --- a/src/server/shared/Cryptography/BigNumber.cpp +++ b/src/server/shared/Cryptography/BigNumber.cpp @@ -164,7 +164,7 @@ uint32 BigNumber::AsDword() bool BigNumber::isZero() const { - return BN_is_zero(_bn)!=0; + return BN_is_zero(_bn); } uint8 *BigNumber::AsByteArray(int minSize, bool reverse) diff --git a/src/server/shared/DataStores/DBCFileLoader.cpp b/src/server/shared/DataStores/DBCFileLoader.cpp index 85b61c4f143..6f78ce5a02d 100755 --- a/src/server/shared/DataStores/DBCFileLoader.cpp +++ b/src/server/shared/DataStores/DBCFileLoader.cpp @@ -23,7 +23,7 @@ #include "DBCFileLoader.h" #include "Errors.h" -DBCFileLoader::DBCFileLoader() : stringTable(NULL), data(NULL), fieldsOffset(NULL) +DBCFileLoader::DBCFileLoader() : fieldsOffset(NULL), data(NULL), stringTable(NULL) { } diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index 001e74fc6c6..a0816686734 100755 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -507,7 +507,7 @@ class DatabaseWorkerPool { IDX_ASYNC, IDX_SYNCH, - IDX_SIZE, + IDX_SIZE }; ACE_Activation_Queue* _queue; //! Queue shared by async worker threads. diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index e1530f36e44..823ad874de9 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -513,7 +513,7 @@ enum CharacterDatabaseStatements CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT, - MAX_CHARACTERDATABASE_STATEMENTS, + MAX_CHARACTERDATABASE_STATEMENTS }; #endif diff --git a/src/server/shared/Database/Implementation/LoginDatabase.h b/src/server/shared/Database/Implementation/LoginDatabase.h index 7c2a94eec94..b4f6713d118 100755 --- a/src/server/shared/Database/Implementation/LoginDatabase.h +++ b/src/server/shared/Database/Implementation/LoginDatabase.h @@ -108,7 +108,7 @@ enum LoginDatabaseStatements LOGIN_SEL_REALMLIST_SECURITY_LEVEL, LOGIN_DEL_ACCOUNT, - MAX_LOGINDATABASE_STATEMENTS, + MAX_LOGINDATABASE_STATEMENTS }; #endif diff --git a/src/server/shared/Database/Implementation/WorldDatabase.h b/src/server/shared/Database/Implementation/WorldDatabase.h index 6d7df87cc80..195d2ea8da5 100755 --- a/src/server/shared/Database/Implementation/WorldDatabase.h +++ b/src/server/shared/Database/Implementation/WorldDatabase.h @@ -113,7 +113,7 @@ enum WorldDatabaseStatements WORLD_INS_DISABLES, WORLD_DEL_DISABLES, - MAX_WORLDDATABASE_STATEMENTS, + MAX_WORLDDATABASE_STATEMENTS }; #endif diff --git a/src/server/shared/Database/MySQLConnection.h b/src/server/shared/Database/MySQLConnection.h index c05c4e62c96..c597476967d 100755 --- a/src/server/shared/Database/MySQLConnection.h +++ b/src/server/shared/Database/MySQLConnection.h @@ -33,7 +33,7 @@ enum ConnectionFlags { CONNECTION_ASYNC = 0x1, CONNECTION_SYNCH = 0x2, - CONNECTION_BOTH = CONNECTION_ASYNC | CONNECTION_SYNCH, + CONNECTION_BOTH = CONNECTION_ASYNC | CONNECTION_SYNCH }; struct MySQLConnectionInfo diff --git a/src/server/shared/Database/QueryHolder.cpp b/src/server/shared/Database/QueryHolder.cpp index 0908ad410cd..ed228c74667 100755 --- a/src/server/shared/Database/QueryHolder.cpp +++ b/src/server/shared/Database/QueryHolder.cpp @@ -24,7 +24,7 @@ bool SQLQueryHolder::SetQuery(size_t index, const char *sql) { if (m_queries.size() <= index) { - sLog->outError(LOG_FILTER_SQL, "Query index (%zu) out of range (size: %u) for query: %s", index, (uint32)m_queries.size(), sql); + sLog->outError(LOG_FILTER_SQL, "Query index (%u) out of range (size: %u) for query: %s", uint32(index), (uint32)m_queries.size(), sql); return false; } @@ -44,7 +44,7 @@ bool SQLQueryHolder::SetPQuery(size_t index, const char *format, ...) { if (!format) { - sLog->outError(LOG_FILTER_SQL, "Query (index: %zu) is empty.", index); + sLog->outError(LOG_FILTER_SQL, "Query (index: %u) is empty.", uint32(index)); return false; } @@ -67,7 +67,7 @@ bool SQLQueryHolder::SetPreparedQuery(size_t index, PreparedStatement* stmt) { if (m_queries.size() <= index) { - sLog->outError(LOG_FILTER_SQL, "Query index (%zu) out of range (size: %u) for prepared statement", index, (uint32)m_queries.size()); + sLog->outError(LOG_FILTER_SQL, "Query index (%u) out of range (size: %u) for prepared statement", uint32(index), (uint32)m_queries.size()); return false; } diff --git a/src/server/shared/Database/SQLOperation.h b/src/server/shared/Database/SQLOperation.h index b911c1c92aa..401535e39f7 100755 --- a/src/server/shared/Database/SQLOperation.h +++ b/src/server/shared/Database/SQLOperation.h @@ -37,7 +37,7 @@ union SQLElementUnion enum SQLElementDataType { SQL_ELEMENT_RAW, - SQL_ELEMENT_PREPARED, + SQL_ELEMENT_PREPARED }; //- The element diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp index febc5ef3573..96a115f8057 100644 --- a/src/server/shared/Debugging/WheatyExceptionReport.cpp +++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp @@ -409,11 +409,12 @@ void WheatyExceptionReport::printTracesForAllThreads() CONTEXT context; context.ContextFlags = 0xffffffff; HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, false, te32.th32ThreadID); - if (threadHandle && GetThreadContext(threadHandle, &context)) + if (threadHandle) { - WriteStackDetails(&context, false, threadHandle); + if (GetThreadContext(threadHandle, &context)) + WriteStackDetails(&context, false, threadHandle); + CloseHandle(threadHandle); } - CloseHandle(threadHandle); } } while (Thread32Next(hThreadSnap, &te32)); @@ -521,7 +522,7 @@ PEXCEPTION_POINTERS pExceptionInfo) _tprintf(_T("Global Variables\r\n")); SymEnumSymbols(GetCurrentProcess(), - (DWORD64)GetModuleHandle(szFaultingModule), + (UINT_PTR)GetModuleHandle(szFaultingModule), 0, EnumerateSymbolsCallback, 0); // #endif // X86 Only! @@ -989,7 +990,7 @@ PVOID pAddress) if (!IsBadStringPtr(*(PSTR*)pAddress, 32)) { pszCurrBuffer += sprintf(pszCurrBuffer, " = \"%.31s\"", - *(PDWORD)pAddress); + *(PSTR*)pAddress); } else pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", diff --git a/src/server/shared/Dynamic/TypeContainerFunctions.h b/src/server/shared/Dynamic/TypeContainerFunctions.h index 19ebfb3adfc..5011ec1c1be 100755 --- a/src/server/shared/Dynamic/TypeContainerFunctions.h +++ b/src/server/shared/Dynamic/TypeContainerFunctions.h @@ -36,7 +36,7 @@ namespace Trinity template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<SPECIFIC_TYPE> &elements, SPECIFIC_TYPE* /*fake*/) { return elements._element.getSize(); - }; + } template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE* /*fake*/) { @@ -64,7 +64,7 @@ namespace Trinity //elements._element[hdl] = obj; obj->AddToGrid(elements._element); return obj; - }; + } template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/) { diff --git a/src/server/shared/Dynamic/TypeContainerVisitor.h b/src/server/shared/Dynamic/TypeContainerVisitor.h index beddb31f343..155989f15f6 100755 --- a/src/server/shared/Dynamic/TypeContainerVisitor.h +++ b/src/server/shared/Dynamic/TypeContainerVisitor.h @@ -35,7 +35,7 @@ template<class T, class Y> class TypeContainerVisitor; template<class VISITOR, class TYPE_CONTAINER> void VisitorHelper(VISITOR &v, TYPE_CONTAINER &c) { v.Visit(c); -}; +} // terminate condition for container list template<class VISITOR> void VisitorHelper(VISITOR &v, ContainerList<TypeNull> &c) diff --git a/src/server/shared/Logging/Appender.h b/src/server/shared/Logging/Appender.h index c0e03b13db1..5c4b009ef67 100644 --- a/src/server/shared/Logging/Appender.h +++ b/src/server/shared/Logging/Appender.h @@ -80,7 +80,7 @@ enum LogLevel LOG_LEVEL_INFO = 3, LOG_LEVEL_WARN = 4, LOG_LEVEL_ERROR = 5, - LOG_LEVEL_FATAL = 6, + LOG_LEVEL_FATAL = 6 }; const uint8 MaxLogLevels = 6; @@ -90,7 +90,7 @@ enum AppenderType APPENDER_NONE, APPENDER_CONSOLE, APPENDER_FILE, - APPENDER_DB, + APPENDER_DB }; enum AppenderFlags diff --git a/src/server/shared/Logging/AppenderConsole.cpp b/src/server/shared/Logging/AppenderConsole.cpp index 839f8512ad7..be6dc6c807f 100644 --- a/src/server/shared/Logging/AppenderConsole.cpp +++ b/src/server/shared/Logging/AppenderConsole.cpp @@ -59,7 +59,7 @@ void AppenderConsole::InitColors(std::string const& str) void AppenderConsole::SetColor(bool stdout_stream, ColorTypes color) { - #if PLATFORM == PLATFORWINDOWS + #if PLATFORM == PLATFORM_WINDOWS static WORD WinColorFG[MaxColors] = { 0, // BLACK @@ -146,7 +146,7 @@ void AppenderConsole::SetColor(bool stdout_stream, ColorTypes color) void AppenderConsole::ResetColor(bool stdout_stream) { - #if PLATFORM == PLATFORWINDOWS + #if PLATFORM == PLATFORM_WINDOWS HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE); SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); #else diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 88259831095..ed65104d6ac 100755 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -272,19 +272,6 @@ void Log::EnableDBAppenders() ((AppenderDB *)it->second)->setEnable(true); } -void Log::log(LogFilterType filter, LogLevel level, char const* str, ...) -{ - if (!str || !ShouldLog(filter, level)) - return; - - va_list ap; - va_start(ap, str); - - vlog(filter, level, str, ap); - - va_end(ap); -} - void Log::vlog(LogFilterType filter, LogLevel level, char const* str, va_list argptr) { char text[MAX_QUERY_LEN]; diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index 7980df0d52a..b66e774b527 100755 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -45,8 +45,6 @@ class Log bool ShouldLog(LogFilterType type, LogLevel level) const; bool SetLogLevel(std::string const& name, char const* level, bool isLogger = true); - void log(LogFilterType f, LogLevel level, char const* str, ...) ATTR_PRINTF(4,5); - void outTrace(LogFilterType f, char const* str, ...) ATTR_PRINTF(3,4); void outDebug(LogFilterType f, char const* str, ...) ATTR_PRINTF(3,4); void outInfo(LogFilterType f, char const* str, ...) ATTR_PRINTF(3,4); diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 760fcfd48d9..1fa3148504a 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -359,6 +359,28 @@ class ByteBuffer } } + uint32 ReadPackedTime() + { + uint32 packedDate = read<uint32>(); + tm lt; + memset(<, 0, sizeof(lt)); + + lt.tm_min = packedDate & 0x3F; + lt.tm_hour = (packedDate >> 6) & 0x1F; + //lt.tm_wday = (packedDate >> 11) & 7; + lt.tm_mday = ((packedDate >> 14) & 0x3F) + 1; + lt.tm_mon = (packedDate >> 20) & 0xF; + lt.tm_year = ((packedDate >> 24) & 0x1F) + 100; + + return mktime(<) + timezone; + } + + ByteBuffer& ReadPackedTime(uint32& time) + { + time = ReadPackedTime(); + return *this; + } + const uint8 *contents() const { return &_storage[0]; } size_t size() const { return _storage.size(); } @@ -438,6 +460,12 @@ class ByteBuffer append(packGUID, size); } + void AppendPackedTime(time_t time) + { + tm* lt = localtime(&time); + append<uint32>((lt->tm_year - 100) << 24 | lt->tm_mon << 20 | (lt->tm_mday - 1) << 14 | lt->tm_wday << 11 | lt->tm_hour << 6 | lt->tm_min); + } + void put(size_t pos, const uint8 *src, size_t cnt) { if (pos + cnt > size()) diff --git a/src/server/shared/Threading/Threading.h b/src/server/shared/Threading/Threading.h index 8b10e223828..7cc74574873 100755 --- a/src/server/shared/Threading/Threading.h +++ b/src/server/shared/Threading/Threading.h @@ -51,7 +51,7 @@ namespace ACE_Based Normal, High, Highest, - Realtime, + Realtime }; #define MAXPRIORITYNUM (Realtime + 1) diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 9917bbb5309..89942b978df 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -92,7 +92,7 @@ Tokens::Tokens(const std::string &src, const char sep, uint32 vectorReserve) void stripLineInvisibleChars(std::string &str) { - static std::string invChars = " \t\7\n"; + static std::string const invChars = " \t\7\n"; size_t wpos = 0; diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 196882dc2a0..37782c31d8b 100755 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -48,12 +48,6 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hou uint32 TimeStringToSecs(const std::string& timestring); std::string TimeToTimestampStr(time_t t); -inline uint32 secsToTimeBitFields(time_t secs) -{ - tm* lt = localtime(&secs); - return (lt->tm_year - 100) << 24 | lt->tm_mon << 20 | (lt->tm_mday - 1) << 14 | lt->tm_wday << 11 | lt->tm_hour << 6 | lt->tm_min; -} - /* Return a random number in the range min..max; (max-min) must be smaller than 32768. */ int32 irand(int32 min, int32 max); @@ -89,22 +83,6 @@ inline bool roll_chance_i(int chance) return chance > irand(0, 99); } -inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply) -{ - int32 cur = var; - cur += (apply ? val : -val); - if (cur < 0) - cur = 0; - var = cur; -} - -inline void ApplyModFloatVar(float& var, float val, bool apply) -{ - var += (apply ? val : -val); - if (var < 0) - var = 0; -} - inline void ApplyPercentModFloatVar(float& var, float val, bool apply) { if (val == -100.0f) // prevent set var to zero @@ -475,7 +453,7 @@ public: return 0; } return 0; - }; + } template<class type> inline bool operator < (type & right) const @@ -488,7 +466,7 @@ public: return 0; } return 0; - }; + } template<class type> inline bool operator != (type & right) @@ -508,7 +486,7 @@ public: || part[2]!=right.part[2]) return true; return false; - }; + } template<class type> inline bool operator == (type & right) @@ -518,7 +496,7 @@ public: || part[2]!=right.part[2]) return false; return true; - }; + } template<class type> inline bool operator == (type & right) const @@ -528,7 +506,7 @@ public: || part[2]!=right.part[2]) return false; return true; - }; + } template<class type> inline void operator = (type & right) @@ -536,7 +514,7 @@ public: part[0]=right.part[0]; part[1]=right.part[1]; part[2]=right.part[2]; - }; + } template<class type> inline flag96 operator & (type & right) @@ -544,20 +522,21 @@ public: flag96 ret(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]); return ret; - }; + } + template<class type> inline flag96 operator & (type & right) const { flag96 ret(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]); return ret; - }; + } template<class type> inline void operator &= (type & right) { *this=*this & right; - }; + } template<class type> inline flag96 operator | (type & right) @@ -565,7 +544,7 @@ public: flag96 ret(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]); return ret; - }; + } template<class type> inline flag96 operator | (type & right) const @@ -573,13 +552,13 @@ public: flag96 ret(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]); return ret; - }; + } template<class type> inline void operator |= (type & right) { *this=*this | right; - }; + } inline void operator ~ () { @@ -594,7 +573,7 @@ public: flag96 ret(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]); return ret; - }; + } template<class type> inline flag96 operator ^ (type & right) const @@ -602,13 +581,13 @@ public: flag96 ret(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]); return ret; - }; + } template<class type> inline void operator ^= (type & right) { *this=*this^right; - }; + } inline operator bool() const { diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 7e200e59046..55443f4253b 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -400,8 +400,8 @@ PersistentCharacterCleanFlags = 0 # # PidFile # Description: World daemon PID file -# Example: "./worldd.pid" - (Enabled) -# Default: "" - (Disabled) +# Example: "./world.pid" - (Enabled) +# Default: "" - (Disabled) PidFile = "" diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt index bde62c24c70..55a136f6329 100644 --- a/src/tools/map_extractor/CMakeLists.txt +++ b/src/tools/map_extractor/CMakeLists.txt @@ -43,5 +43,5 @@ add_dependencies(mapextractor mpq) if( UNIX ) install(TARGETS mapextractor DESTINATION bin) elseif( WIN32 ) - install(TARGETS mapextractor DESTINATION "${CMAKE_INSTALL_PREFIX}") + install(TARGETS mapextractor DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index f474925313e..d0342717324 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -9,6 +9,7 @@ #include "direct.h" #else #include <sys/stat.h> +#include <unistd.h> #endif #include "dbcfile.h" |