aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dep/PackageList.txt2
-rw-r--r--dep/cppformat/ChangeLog.rst358
-rw-r--r--dep/cppformat/README.rst9
-rw-r--r--dep/cppformat/format.cc562
-rw-r--r--dep/cppformat/format.h1332
-rw-r--r--dep/cppformat/posix.cc5
-rw-r--r--dep/cppformat/posix.h6
-rw-r--r--sql/updates/world/2015_12_08_00_world_335.sql15
-rw-r--r--sql/updates/world/2015_12_08_01_world.sql2
-rw-r--r--sql/updates/world/2015_12_08_02_world.sql6
-rw-r--r--sql/updates/world/2015_12_09_00_world.sql3
-rw-r--r--sql/updates/world/2015_12_09_01_world.sql13
-rw-r--r--sql/updates/world/2015_12_11_00_world.sql19
-rw-r--r--sql/updates/world/2015_12_14_00_world.sql32
-rw-r--r--sql/updates/world/2015_12_15_00_world.sql2
-rw-r--r--sql/updates/world/2015_12_15_01_world.sql2
-rw-r--r--sql/updates/world/2015_12_15_02_world.sql22
-rw-r--r--sql/updates/world/2015_12_15_03_world.sql5
-rw-r--r--sql/updates/world/2015_12_16_00_world.sql91
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp123
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.h11
-rw-r--r--src/server/game/DataStores/DBCStructure.h2
-rw-r--r--src/server/game/DataStores/DBCfmt.h2
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp42
-rw-r--r--src/server/game/Entities/Creature/Creature.h3
-rw-r--r--src/server/game/Entities/Player/Player.cpp45
-rw-r--r--src/server/game/Entities/Player/Player.h4
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp16
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp19
-rw-r--r--src/server/game/Handlers/AuctionHouseHandler.cpp7
-rw-r--r--src/server/game/Spells/SpellMgr.cpp1
-rw-r--r--src/server/game/World/World.cpp8
-rw-r--r--src/server/game/World/World.h1
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp86
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp1
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp1
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp51
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp56
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp3
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp5
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp7
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h86
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp18
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp150
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp196
-rw-r--r--src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp8
-rw-r--r--src/server/scripts/Northrend/Naxxramas/naxxramas.h2
-rw-r--r--src/server/scripts/Pet/pet_mage.cpp185
48 files changed, 2567 insertions, 1058 deletions
diff --git a/dep/PackageList.txt b/dep/PackageList.txt
index 65533192da9..e84fef8d3b2 100644
--- a/dep/PackageList.txt
+++ b/dep/PackageList.txt
@@ -14,7 +14,7 @@ bzip2 (a freely available, patent free, high-quality data compressor)
cppformat (type safe format library)
https://github.com/cppformat/cppformat
- Version: 7859f8123311c1b8f69856d3c5e1b8501fbdae11
+ Version: 5c76d107cbaf5e851bd66b6c563e4fc7c90be7ad
G3D (a commercial-grade C++ 3D engine available as Open Source (BSD License)
http://g3d.sourceforge.net/
diff --git a/dep/cppformat/ChangeLog.rst b/dep/cppformat/ChangeLog.rst
index 89d5af8e9c7..d2a77f8712f 100644
--- a/dep/cppformat/ChangeLog.rst
+++ b/dep/cppformat/ChangeLog.rst
@@ -1,3 +1,356 @@
+2.0.0 - 2015-12-01
+------------------
+
+General
+~~~~~~~
+
+* [Breaking] Named arguments
+ (`#169 <https://github.com/cppformat/cppformat/pull/169>`_,
+ `#173 <https://github.com/cppformat/cppformat/pull/173>`_,
+ `#174 <https://github.com/cppformat/cppformat/pull/174>`_):
+
+ .. code:: c++
+
+ fmt::print("The answer is {answer}.", fmt::arg("answer", 42));
+
+ Thanks to `@jamboree <https://github.com/jamboree>`_.
+
+* [Experimental] User-defined literals for format and named arguments
+ (`#204 <https://github.com/cppformat/cppformat/pull/204>`_,
+ `#206 <https://github.com/cppformat/cppformat/pull/206>`_,
+ `#207 <https://github.com/cppformat/cppformat/pull/207>`_):
+
+ .. code:: c++
+
+ using namespace fmt::literals;
+ fmt::print("The answer is {answer}.", "answer"_a=42);
+
+ Thanks to `@dean0x7d (Dean Moldovan) <https://github.com/dean0x7d>`_.
+
+* [Breaking] Formatting of more than 16 arguments is now supported when using
+ variadic templates
+ (`#141 <https://github.com/cppformat/cppformat/issues/141>`_).
+ Thanks to `@Shauren <https://github.com/Shauren>`_.
+
+* Runtime width specification
+ (`#168 <https://github.com/cppformat/cppformat/pull/168>`_):
+
+ .. code:: c++
+
+ fmt::format("{0:{1}}", 42, 5); // gives " 42"
+
+ Thanks to `@jamboree <https://github.com/jamboree>`_.
+
+* [Breaking] Enums are now formatted with an overloaded ``std::ostream`` insertion
+ operator (``operator<<``) if available
+ (`#232 <https://github.com/cppformat/cppformat/issues/232>`_).
+
+* [Breaking] Changed default ``bool`` format to textual, "true" or "false"
+ (`#170 <https://github.com/cppformat/cppformat/issues/170>`_):
+
+ .. code:: c++
+
+ fmt::print("{}", true); // prints "true"
+
+ To print ``bool`` as a number use numeric format specifier such as ``d``:
+
+ .. code:: c++
+
+ fmt::print("{:d}", true); // prints "1"
+
+* ``fmt::printf`` and ``fmt::sprintf`` now support formatting of ``bool`` with the
+ ``%s`` specifier giving textual output, "true" or "false"
+ (`#223 <https://github.com/cppformat/cppformat/pull/223>`_):
+
+ .. code:: c++
+
+ fmt::printf("%s", true); // prints "true"
+
+ Thanks to `@LarsGullik <https://github.com/LarsGullik>`_.
+
+* [Breaking] ``signed char`` and ``unsigned char`` are now formatted as integers by default
+ (`#217 <https://github.com/cppformat/cppformat/pull/217>`_).
+
+* [Breaking] Pointers to C strings can now be formatted with the ``p`` specifier
+ (`#223 <https://github.com/cppformat/cppformat/pull/223>`_):
+
+ .. code:: c++
+
+ fmt::print("{:p}", "test"); // prints pointer value
+
+ Thanks to `@LarsGullik <https://github.com/LarsGullik>`_.
+
+* [Breaking] ``fmt::printf`` and ``fmt::sprintf`` now print null pointers as ``(nil)``
+ and null strings as ``(null)`` for consistency with glibc
+ (`#226 <https://github.com/cppformat/cppformat/pull/226>`_).
+ Thanks to `@LarsGullik <https://github.com/LarsGullik>`_.
+
+* [Breaking] ``fmt::(s)printf`` now supports formatting of objects of user-defined types
+ that provide an overloaded ``std::ostream`` insertion operator (``operator<<``)
+ (`#201 <https://github.com/cppformat/cppformat/issues/201>`_):
+
+ .. code:: c++
+
+ fmt::printf("The date is %s", Date(2012, 12, 9));
+
+* [Breaking] The ``Buffer`` template is now part of the public API and can be used
+ to implement custom memory buffers
+ (`#140 <https://github.com/cppformat/cppformat/issues/140>`_).
+ Thanks to `@polyvertex (Jean-Charles Lefebvre) <https://github.com/polyvertex>`_.
+
+* [Breaking] Improved compatibility between ``BasicStringRef`` and
+ `std::experimental::basic_string_view
+ <http://en.cppreference.com/w/cpp/experimental/basic_string_view>`_
+ (`#100 <https://github.com/cppformat/cppformat/issues/100>`_,
+ `#159 <https://github.com/cppformat/cppformat/issues/159>`_,
+ `#183 <https://github.com/cppformat/cppformat/issues/183>`_):
+
+ - Comparison operators now compare string content, not pointers
+ - ``BasicStringRef::c_str`` replaced by ``BasicStringRef::data``
+ - ``BasicStringRef`` is no longer assumed to be null-terminated
+
+ References to null-terminated strings are now represented by a new class,
+ ``BasicCStringRef``.
+
+* Dependency on pthreads introduced by Google Test is now optional
+ (`#185 <https://github.com/cppformat/cppformat/issues/185>`_).
+
+* New CMake options ``FMT_DOC``, ``FMT_INSTALL`` and ``FMT_TEST`` to control
+ generation of ``doc``, ``install`` and ``test`` targets respectively, on by default
+ (`#197 <https://github.com/cppformat/cppformat/issues/197>`_,
+ `#198 <https://github.com/cppformat/cppformat/issues/198>`_,
+ `#200 <https://github.com/cppformat/cppformat/issues/200>`_).
+ Thanks to `@maddinat0r (Alex Martin) <https://github.com/maddinat0r>`_.
+
+* ``noexcept`` is now used when compiling with MSVC2015
+ (`#215 <https://github.com/cppformat/cppformat/pull/215>`_).
+ Thanks to `@dmkrepo (Dmitriy) <https://github.com/dmkrepo>`_.
+
+* Added an option to disable use of ``windows.h`` when ``FMT_USE_WINDOWS_H``
+ is defined as 0 before including ``format.h``
+ (`#171 <https://github.com/cppformat/cppformat/issues/171>`_).
+ Thanks to `@alfps (Alf P. Steinbach) <https://github.com/alfps>`_.
+
+* [Breaking] ``windows.h`` is now included with ``NOMINMAX`` unless
+ ``FMT_WIN_MINMAX`` is defined. This is done to prevent breaking code using
+ ``std::min`` and ``std::max`` and only affects the header-only configuration
+ (`#152 <https://github.com/cppformat/cppformat/issues/152>`_,
+ `#153 <https://github.com/cppformat/cppformat/pull/153>`_,
+ `#154 <https://github.com/cppformat/cppformat/pull/154>`_).
+ Thanks to `@DevO2012 <https://github.com/DevO2012>`_.
+
+* Improved support for custom character types
+ (`#171 <https://github.com/cppformat/cppformat/issues/171>`_).
+ Thanks to `@alfps (Alf P. Steinbach) <https://github.com/alfps>`_.
+
+* Added an option to disable use of IOStreams when ``FMT_USE_IOSTREAMS``
+ is defined as 0 before including ``format.h``
+ (`#205 <https://github.com/cppformat/cppformat/issues/205>`_,
+ `#208 <https://github.com/cppformat/cppformat/pull/208>`_).
+ Thanks to `@JodiTheTigger <https://github.com/JodiTheTigger>`_.
+
+* Improved detection of ``isnan``, ``isinf`` and ``signbit``.
+
+Optimization
+~~~~~~~~~~~~
+
+* Made formatting of user-defined types more efficient with a custom stream buffer
+ (`#92 <https://github.com/cppformat/cppformat/issues/92>`_,
+ `#230 <https://github.com/cppformat/cppformat/pull/230>`_).
+ Thanks to `@NotImplemented <https://github.com/NotImplemented>`_.
+
+* Further improved performance of ``fmt::Writer`` on integer formatting
+ and fixed a minor regression. Now it is ~7% faster than ``karma::generate``
+ on Karma's benchmark
+ (`#186 <https://github.com/cppformat/cppformat/issues/186>`_).
+
+* [Breaking] Reduced `compiled code size
+ <https://github.com/cppformat/cppformat#compile-time-and-code-bloat>`_
+ (`#143 <https://github.com/cppformat/cppformat/issues/143>`_,
+ `#149 <https://github.com/cppformat/cppformat/pull/149>`_).
+
+Distribution
+~~~~~~~~~~~~
+
+* [Breaking] Headers are now installed in
+ ``${CMAKE_INSTALL_PREFIX}/include/cppformat``
+ (`#178 <https://github.com/cppformat/cppformat/issues/178>`_).
+ Thanks to `@jackyf (Eugene V. Lyubimkin) <https://github.com/jackyf>`_.
+
+* [Breaking] Changed the library name from ``format`` to ``cppformat``
+ for consistency with the project name and to avoid potential conflicts
+ (`#178 <https://github.com/cppformat/cppformat/issues/178>`_).
+ Thanks to `@jackyf (Eugene V. Lyubimkin) <https://github.com/jackyf>`_.
+
+* C++ Format is now available in `Debian <https://www.debian.org/>`_ GNU/Linux
+ (`stretch <https://packages.debian.org/source/stretch/cppformat>`_,
+ `sid <https://packages.debian.org/source/sid/cppformat>`_) and
+ derived distributions such as
+ `Ubuntu <https://launchpad.net/ubuntu/+source/cppformat>`_ 15.10 and later
+ (`#155 <https://github.com/cppformat/cppformat/issues/155>`_)::
+
+ $ sudo apt-get install libcppformat1-dev
+
+ Thanks to `@jackyf (Eugene V. Lyubimkin) <https://github.com/jackyf>`_.
+
+* `Packages for Fedora and RHEL <https://admin.fedoraproject.org/pkgdb/package/cppformat/>`_
+ are now available. Thanks to Dave Johansen.
+
+* C++ Format can now be installed via `Homebrew <http://brew.sh/>`_ on OS X
+ (`#157 <https://github.com/cppformat/cppformat/issues/157>`_)::
+
+ $ brew install cppformat
+
+ Thanks to `@ortho <https://github.com/ortho>`_, Anatoliy Bulukin.
+
+Documentation
+~~~~~~~~~~~~~
+
+* Migrated from ReadTheDocs to GitHub Pages for better responsiveness
+ and reliability
+ (`#128 <https://github.com/cppformat/cppformat/issues/128>`_).
+ New documentation address is http://cppformat.github.io/.
+
+
+* Added `Building the documentation
+ <http://cppformat.github.io/dev/usage.html#building-the-documentation>`_
+ section to the documentation.
+
+* Documentation build script is now compatible with Python 3 and newer pip versions.
+ (`#189 <https://github.com/cppformat/cppformat/pull/189>`_,
+ `#209 <https://github.com/cppformat/cppformat/issues/209>`_).
+ Thanks to `@JodiTheTigger <https://github.com/JodiTheTigger>`_ and
+ `@xentec <https://github.com/xentec>`_.
+
+* Documentation fixes and improvements
+ (`#36 <https://github.com/cppformat/cppformat/issues/36>`_,
+ `#75 <https://github.com/cppformat/cppformat/issues/75>`_,
+ `#125 <https://github.com/cppformat/cppformat/issues/125>`_,
+ `#160 <https://github.com/cppformat/cppformat/pull/160>`_,
+ `#161 <https://github.com/cppformat/cppformat/pull/161>`_,
+ `#162 <https://github.com/cppformat/cppformat/issues/162>`_,
+ `#165 <https://github.com/cppformat/cppformat/issues/165>`_,
+ `#210 <https://github.com/cppformat/cppformat/issues/210>`_).
+ Thanks to `@syohex (Syohei YOSHIDA) <https://github.com/syohex>`_ and
+ bug reporters.
+
+* Fixed out-of-tree documentation build
+ (`#177 <https://github.com/cppformat/cppformat/issues/177>`_).
+ Thanks to `@jackyf (Eugene V. Lyubimkin) <https://github.com/jackyf>`_.
+
+Fixes
+~~~~~
+
+* Fixed ``initializer_list`` detection
+ (`#136 <https://github.com/cppformat/cppformat/issues/136>`_).
+ Thanks to `@Gachapen (Magnus Bjerke Vik) <https://github.com/Gachapen>`_.
+
+* [Breaking] Fixed formatting of enums with numeric format specifiers in
+ ``fmt::(s)printf``
+ (`#131 <https://github.com/cppformat/cppformat/issues/131>`_,
+ `#139 <https://github.com/cppformat/cppformat/issues/139>`_):
+
+ .. code:: c++
+
+ enum { ANSWER = 42 };
+ fmt::printf("%d", ANSWER);
+
+ Thanks to `@Naios <https://github.com/Naios>`_.
+
+* Improved compatibility with old versions of MinGW
+ (`#129 <https://github.com/cppformat/cppformat/issues/129>`_,
+ `#130 <https://github.com/cppformat/cppformat/pull/130>`_,
+ `#132 <https://github.com/cppformat/cppformat/issues/132>`_).
+ Thanks to `@cstamford (Christopher Stamford) <https://github.com/cstamford>`_.
+
+* Fixed a compile error on MSVC with disabled exceptions
+ (`#144 <https://github.com/cppformat/cppformat/issues/144>`_).
+
+* Added a workaround for broken implementation of variadic templates in MSVC2012
+ (`#148 <https://github.com/cppformat/cppformat/issues/148>`_).
+
+* Placed the anonymous namespace within ``fmt`` namespace for the header-only
+ configuration
+ (`#171 <https://github.com/cppformat/cppformat/issues/171>`_).
+ Thanks to `@alfps (Alf P. Steinbach) <https://github.com/alfps>`_.
+
+* Fixed issues reported by Coverity Scan
+ (`#187 <https://github.com/cppformat/cppformat/issues/187>`_,
+ `#192 <https://github.com/cppformat/cppformat/issues/192>`_).
+
+* Implemented a workaround for a name lookup bug in MSVC2010
+ (`#188 <https://github.com/cppformat/cppformat/issues/188>`_).
+
+* Fixed compiler warnings
+ (`#95 <https://github.com/cppformat/cppformat/issues/95>`_,
+ `#96 <https://github.com/cppformat/cppformat/issues/96>`_,
+ `#114 <https://github.com/cppformat/cppformat/pull/114>`_,
+ `#135 <https://github.com/cppformat/cppformat/issues/135>`_,
+ `#142 <https://github.com/cppformat/cppformat/issues/142>`_,
+ `#145 <https://github.com/cppformat/cppformat/issues/145>`_,
+ `#146 <https://github.com/cppformat/cppformat/issues/146>`_,
+ `#158 <https://github.com/cppformat/cppformat/issues/158>`_,
+ `#163 <https://github.com/cppformat/cppformat/issues/163>`_,
+ `#175 <https://github.com/cppformat/cppformat/issues/175>`_,
+ `#190 <https://github.com/cppformat/cppformat/issues/190>`_,
+ `#191 <https://github.com/cppformat/cppformat/pull/191>`_,
+ `#194 <https://github.com/cppformat/cppformat/issues/194>`_,
+ `#196 <https://github.com/cppformat/cppformat/pull/196>`_,
+ `#216 <https://github.com/cppformat/cppformat/issues/216>`_,
+ `#218 <https://github.com/cppformat/cppformat/pull/218>`_,
+ `#220 <https://github.com/cppformat/cppformat/pull/220>`_,
+ `#229 <https://github.com/cppformat/cppformat/pull/229>`_,
+ `#233 <https://github.com/cppformat/cppformat/issues/233>`_,
+ `#234 <https://github.com/cppformat/cppformat/issues/234>`_,
+ `#236 <https://github.com/cppformat/cppformat/pull/236>`_).
+ Thanks to `@seanmiddleditch (Sean Middleditch) <https://github.com/seanmiddleditch>`_,
+ `@dixlorenz (Dix Lorenz) <https://github.com/dixlorenz>`_,
+ `@CarterLi (李通洲) <https://github.com/CarterLi>`_,
+ `@Naios <https://github.com/Naios>`_,
+ `@fmatthew5876 (Matthew Fioravante) <https://github.com/fmatthew5876>`_,
+ `@LevskiWeng (Levski Weng) <https://github.com/LevskiWeng>`_,
+ `@rpopescu <https://github.com/rpopescu>`_,
+ `@gabime (Gabi Melman) <https://github.com/gabime>`_,
+ `@cubicool (Jeremy Moles) <https://github.com/cubicool>`_,
+ `@jkflying (Julian Kent) <https://github.com/jkflying>`_,
+ `@LogicalKnight (Sean L) <https://github.com/LogicalKnight>`_,
+ `@inguin (Ingo van Lil) <https://github.com/inguin>`_ and
+ `@Jopie64 (Johan) <https://github.com/Jopie64>`_.
+
+* Fixed portability issues (mostly causing test failures) on ARM, ppc64, ppc64le,
+ s390x and SunOS 5.11 i386 (
+ `#138 <https://github.com/cppformat/cppformat/issues/138>`_,
+ `#179 <https://github.com/cppformat/cppformat/issues/179>`_,
+ `#180 <https://github.com/cppformat/cppformat/issues/180>`_,
+ `#202 <https://github.com/cppformat/cppformat/issues/202>`_,
+ `#225 <https://github.com/cppformat/cppformat/issues/225>`_,
+ `Red Hat Bugzilla Bug 1260297 <https://bugzilla.redhat.com/show_bug.cgi?id=1260297>`_).
+ Thanks to `@Naios <https://github.com/Naios>`_,
+ `@jackyf (Eugene V. Lyubimkin) <https://github.com/jackyf>`_ and Dave Johansen.
+
+* Fixed a name conflict with macro ``free`` defined in
+ ``crtdbg.h`` when ``_CRTDBG_MAP_ALLOC`` is set
+ (`#211 <https://github.com/cppformat/cppformat/issues/211>`_).
+
+* Fixed shared library build on OS X
+ (`#212 <https://github.com/cppformat/cppformat/pull/212>`_).
+ Thanks to `@dean0x7d (Dean Moldovan) <https://github.com/dean0x7d>`_.
+
+* Fixed an overload conflict on MSVC when ``/Zc:wchar_t-`` option is specified
+ (`#214 <https://github.com/cppformat/cppformat/pull/214>`_).
+ Thanks to `@slavanap (Vyacheslav Napadovsky) <https://github.com/slavanap>`_.
+
+* Improved compatibility with MSVC 2008
+ (`#236 <https://github.com/cppformat/cppformat/pull/236>`_).
+ Thanks to `@Jopie64 (Johan) <https://github.com/Jopie64>`_.
+
+* Improved compatibility with bcc32
+ (`#227 <https://github.com/cppformat/cppformat/issues/227>`_).
+
+* Fixed ``static_assert`` detection on Clang
+ (`#228 <https://github.com/cppformat/cppformat/pull/228>`_).
+ Thanks to `@dean0x7d (Dean Moldovan) <https://github.com/dean0x7d>`_.
+
1.1.0 - 2015-03-06
------------------
@@ -66,11 +419,6 @@
* Fixed packaging issues (`#94 <https://github.com/cppformat/cppformat/issues/94>`_).
-* Fixed warnings in GCC, MSVC and Xcode/Clang
- (`#95 <https://github.com/cppformat/cppformat/issues/95>`_,
- `#96 <https://github.com/cppformat/cppformat/issues/96>`_ and
- `#114 <https://github.com/cppformat/cppformat/pull/114>`_).
-
* Added `changelog <https://github.com/cppformat/cppformat/blob/master/ChangeLog.rst>`_
(`#103 <https://github.com/cppformat/cppformat/issues/103>`_).
diff --git a/dep/cppformat/README.rst b/dep/cppformat/README.rst
index 29f433480f3..fb4399f0af4 100644
--- a/dep/cppformat/README.rst
+++ b/dep/cppformat/README.rst
@@ -7,9 +7,6 @@ C++ Format
.. image:: https://ci.appveyor.com/api/projects/status/qk0bhyhqp1ekpat8
:target: https://ci.appveyor.com/project/vitaut/cppformat
-.. image:: https://webapi.biicode.com/v1/badges/vitaut/vitaut/cppformat/master?dummy
- :target: https://www.biicode.com/vitaut/cppformat
-
.. image:: https://badges.gitter.im/Join%20Chat.svg
:alt: Join the chat at https://gitter.im/cppformat/cppformat
:target: https://gitter.im/cppformat/cppformat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
@@ -149,6 +146,8 @@ Projects using this library
* `readpe <https://bitbucket.org/sys_dev/readpe>`_: Read Portable Executable
+* `redis-cerberus <https://github.com/HunanTV/redis-cerberus>`_: A Redis cluster proxy
+
* `Saddy <https://code.google.com/p/saddy/>`_:
Small crossplatform 2D graphic engine
@@ -157,6 +156,10 @@ Projects using this library
* `spdlog <https://github.com/gabime/spdlog>`_: Super fast C++ logging library
+* `Stellar <https://www.stellar.org/>`_: Financial platform
+
+* `Touch Surgery <https://www.touchsurgery.com/>`_: Surgery simulator
+
* `TrinityCore <https://github.com/TrinityCore/TrinityCore>`_: Open-source MMORPG framework
`More... <https://github.com/search?q=cppformat&type=Code>`_
diff --git a/dep/cppformat/format.cc b/dep/cppformat/format.cc
index 86b86c741b5..1970d53c500 100644
--- a/dep/cppformat/format.cc
+++ b/dep/cppformat/format.cc
@@ -34,6 +34,7 @@
#include <climits>
#include <cmath>
#include <cstdarg>
+#include <cstddef> // for std::ptrdiff_t
#if defined(_WIN32) && defined(__MINGW32__)
# include <cstring>
@@ -51,17 +52,6 @@
using fmt::internal::Arg;
-// Check if exceptions are disabled.
-#if __GNUC__ && !__EXCEPTIONS
-# define FMT_EXCEPTIONS 0
-#endif
-#if _MSC_VER && !_HAS_EXCEPTIONS
-# define FMT_EXCEPTIONS 0
-#endif
-#ifndef FMT_EXCEPTIONS
-# define FMT_EXCEPTIONS 1
-#endif
-
#if FMT_EXCEPTIONS
# define FMT_TRY try
# define FMT_CATCH(x) catch (x)
@@ -70,21 +60,13 @@ using fmt::internal::Arg;
# define FMT_CATCH(x) if (false)
#endif
-#ifndef FMT_THROW
-# if FMT_EXCEPTIONS
-# define FMT_THROW(x) throw x
-# else
-# define FMT_THROW(x) assert(false)
-# endif
-#endif
-
#ifdef FMT_HEADER_ONLY
# define FMT_FUNC inline
#else
# define FMT_FUNC
#endif
-#if _MSC_VER
+#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
# pragma warning(disable: 4702) // unreachable code
@@ -95,11 +77,11 @@ using fmt::internal::Arg;
// Dummy implementations of strerror_r and strerror_s called if corresponding
// system functions are not available.
-static inline fmt::internal::None<> strerror_r(int, char *, ...) {
- return fmt::internal::None<>();
+static inline fmt::internal::Null<> strerror_r(int, char *, ...) {
+ return fmt::internal::Null<>();
}
-static inline fmt::internal::None<> strerror_s(char *, std::size_t, ...) {
- return fmt::internal::None<>();
+static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
+ return fmt::internal::Null<>();
}
namespace fmt {
@@ -133,6 +115,7 @@ struct IntChecker {
unsigned max = INT_MAX;
return value <= max;
}
+ static bool fits_in_int(bool) { return true; }
};
template <>
@@ -141,6 +124,7 @@ struct IntChecker<true> {
static bool fits_in_int(T value) {
return value >= INT_MIN && value <= INT_MAX;
}
+ static bool fits_in_int(int) { return true; }
};
const char RESET_COLOR[] = "\x1b[0m";
@@ -185,7 +169,7 @@ int safe_strerror(
}
// Handle the case when strerror_r is not available.
- int handle(fmt::internal::None<>) {
+ int handle(fmt::internal::Null<>) {
return fallback(strerror_s(buffer_, buffer_size_, error_code_));
}
@@ -197,15 +181,15 @@ int safe_strerror(
}
// Fallback to strerror if strerror_r and strerror_s are not available.
- int fallback(fmt::internal::None<>) {
+ int fallback(fmt::internal::Null<>) {
errno = 0;
buffer_ = strerror(error_code_);
return errno;
}
public:
- StrError(int error_code, char *&buffer, std::size_t buffer_size)
- : error_code_(error_code), buffer_(buffer), buffer_size_(buffer_size) {}
+ StrError(int err_code, char *&buf, std::size_t buf_size)
+ : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {}
int run() {
strerror_r(0, 0, ""); // Suppress a warning about unused strerror_r.
@@ -250,50 +234,6 @@ class IsZeroInt : public fmt::internal::ArgVisitor<IsZeroInt, bool> {
bool visit_any_int(T value) { return value == 0; }
};
-// Parses an unsigned integer advancing s to the end of the parsed input.
-// This function assumes that the first character of s is a digit.
-template <typename Char>
-int parse_nonnegative_int(const Char *&s) {
- assert('0' <= *s && *s <= '9');
- unsigned value = 0;
- do {
- unsigned new_value = value * 10 + (*s++ - '0');
- // Check if value wrapped around.
- if (new_value < value) {
- value = UINT_MAX;
- break;
- }
- value = new_value;
- } while ('0' <= *s && *s <= '9');
- if (value > INT_MAX)
- FMT_THROW(fmt::FormatError("number is too big"));
- return value;
-}
-
-template <typename Char>
-inline bool is_name_start(Char c) {
- return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || '_' == c;
-}
-
-inline void require_numeric_argument(const Arg &arg, char spec) {
- if (arg.type > Arg::LAST_NUMERIC_TYPE) {
- std::string message =
- fmt::format("format specifier '{}' requires numeric argument", spec);
- FMT_THROW(fmt::FormatError(message));
- }
-}
-
-template <typename Char>
-void check_sign(const Char *&s, const Arg &arg) {
- char sign = static_cast<char>(*s);
- require_numeric_argument(arg, sign);
- if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
- FMT_THROW(fmt::FormatError(fmt::format(
- "format specifier '{}' requires signed argument", sign)));
- }
- ++s;
-}
-
// Checks if an argument is a valid printf width specifier and sets
// left alignment if it is negative.
class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
@@ -351,6 +291,11 @@ class ArgConverter : public fmt::internal::ArgVisitor<ArgConverter<T>, void> {
ArgConverter(fmt::internal::Arg &arg, wchar_t type)
: arg_(arg), type_(type) {}
+ void visit_bool(bool value) {
+ if (type_ != 's')
+ visit_any_int(value);
+ }
+
template <typename U>
void visit_any_int(U value) {
bool is_signed = type_ == 'd' || type_ == 'i';
@@ -399,128 +344,72 @@ class CharConverter : public fmt::internal::ArgVisitor<CharConverter, void> {
namespace internal {
-template <typename Impl, typename Char>
-class BasicArgFormatter : public ArgVisitor<Impl, void> {
- private:
- BasicWriter<Char> &writer_;
- FormatSpec &spec_;
+template <typename Char>
+class PrintfArgFormatter :
+ public ArgFormatterBase<PrintfArgFormatter<Char>, Char> {
- FMT_DISALLOW_COPY_AND_ASSIGN(BasicArgFormatter);
+ void write_null_pointer() {
+ this->spec().type_ = 0;
+ this->write("(nil)");
+ }
- protected:
- BasicWriter<Char> &writer() { return writer_; }
- const FormatSpec &spec() const { return spec_; }
+ typedef ArgFormatterBase<PrintfArgFormatter<Char>, Char> Base;
public:
- BasicArgFormatter(BasicWriter<Char> &w, FormatSpec &s)
- : writer_(w), spec_(s) {}
-
- template <typename T>
- void visit_any_int(T value) { writer_.write_int(value, spec_); }
-
- template <typename T>
- void visit_any_double(T value) { writer_.write_double(value, spec_); }
+ PrintfArgFormatter(BasicWriter<Char> &w, FormatSpec &s)
+ : ArgFormatterBase<PrintfArgFormatter<Char>, Char>(w, s) {}
void visit_bool(bool value) {
- if (spec_.type_) {
- writer_.write_int(value, spec_);
- return;
- }
- const char *str_value = value ? "true" : "false";
- Arg::StringValue<char> str = { str_value, strlen(str_value) };
- writer_.write_str(str, spec_);
+ FormatSpec &fmt_spec = this->spec();
+ if (fmt_spec.type_ != 's')
+ return this->visit_any_int(value);
+ fmt_spec.type_ = 0;
+ this->write(value);
}
void visit_char(int value) {
- if (spec_.type_ && spec_.type_ != 'c') {
- spec_.flags_ |= CHAR_FLAG;
- writer_.write_int(value, spec_);
- return;
- }
- if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
- FMT_THROW(FormatError("invalid format specifier for char"));
+ const FormatSpec &fmt_spec = this->spec();
+ BasicWriter<Char> &w = this->writer();
+ if (fmt_spec.type_ && fmt_spec.type_ != 'c')
+ w.write_int(value, fmt_spec);
typedef typename BasicWriter<Char>::CharPtr CharPtr;
- Char fill = internal::CharTraits<Char>::cast(spec_.fill());
CharPtr out = CharPtr();
- if (spec_.width_ > 1) {
- out = writer_.grow_buffer(spec_.width_);
- if (spec_.align_ == ALIGN_RIGHT) {
- std::fill_n(out, spec_.width_ - 1, fill);
- out += spec_.width_ - 1;
- } else if (spec_.align_ == ALIGN_CENTER) {
- out = writer_.fill_padding(out, spec_.width_, 1, fill);
+ if (fmt_spec.width_ > 1) {
+ Char fill = ' ';
+ out = w.grow_buffer(fmt_spec.width_);
+ if (fmt_spec.align_ != ALIGN_LEFT) {
+ std::fill_n(out, fmt_spec.width_ - 1, fill);
+ out += fmt_spec.width_ - 1;
} else {
- std::fill_n(out + 1, spec_.width_ - 1, fill);
+ std::fill_n(out + 1, fmt_spec.width_ - 1, fill);
}
} else {
- out = writer_.grow_buffer(1);
+ out = w.grow_buffer(1);
}
- *out = internal::CharTraits<Char>::cast(value);
- }
-
- void visit_string(Arg::StringValue<char> value) {
- writer_.write_str(value, spec_);
+ *out = static_cast<Char>(value);
}
- using ArgVisitor<Impl, void>::visit_wstring;
-
- void visit_wstring(Arg::StringValue<Char> value) {
- writer_.write_str(value, spec_);
+ void visit_cstring(const char *value) {
+ if (value)
+ Base::visit_cstring(value);
+ else if (this->spec().type_ == 'p')
+ write_null_pointer();
+ else
+ this->write("(null)");
}
void visit_pointer(const void *value) {
- if (spec_.type_ && spec_.type_ != 'p')
- report_unknown_type(spec_.type_, "pointer");
- spec_.flags_ = HASH_FLAG;
- spec_.type_ = 'x';
- writer_.write_int(reinterpret_cast<uintptr_t>(value), spec_);
+ if (value)
+ return Base::visit_pointer(value);
+ this->spec().type_ = 0;
+ write_null_pointer();
}
-};
-
-// An argument formatter.
-template <typename Char>
-class ArgFormatter : public BasicArgFormatter<ArgFormatter<Char>, Char> {
- private:
- BasicFormatter<Char> &formatter_;
- const Char *format_;
-
- public:
- ArgFormatter(BasicFormatter<Char> &f, FormatSpec &s, const Char *fmt)
- : BasicArgFormatter<ArgFormatter<Char>, Char>(f.writer(), s),
- formatter_(f), format_(fmt) {}
void visit_custom(Arg::CustomValue c) {
- c.format(&formatter_, c.value, &format_);
- }
-};
-
-template <typename Char>
-class PrintfArgFormatter :
- public BasicArgFormatter<PrintfArgFormatter<Char>, Char> {
- public:
- PrintfArgFormatter(BasicWriter<Char> &w, FormatSpec &s)
- : BasicArgFormatter<PrintfArgFormatter<Char>, Char>(w, s) {}
-
- void visit_char(int value) {
- const FormatSpec &spec = this->spec();
- BasicWriter<Char> &writer = this->writer();
- if (spec.type_ && spec.type_ != 'c')
- writer.write_int(value, spec);
- typedef typename BasicWriter<Char>::CharPtr CharPtr;
- CharPtr out = CharPtr();
- if (spec.width_ > 1) {
- Char fill = ' ';
- out = writer.grow_buffer(spec.width_);
- if (spec.align_ != ALIGN_LEFT) {
- std::fill_n(out, spec.width_ - 1, fill);
- out += spec.width_ - 1;
- } else {
- std::fill_n(out + 1, spec.width_ - 1, fill);
- }
- } else {
- out = writer.grow_buffer(1);
- }
- *out = static_cast<Char>(value);
+ BasicFormatter<Char> formatter(ArgList(), this->writer());
+ const Char format_str[] = {'}', 0};
+ const Char *format = format_str;
+ c.format(&formatter, c.value, &format);
}
};
} // namespace internal
@@ -611,14 +500,17 @@ FMT_FUNC void fmt::internal::report_unknown_type(char code, const char *type) {
#if FMT_USE_WINDOWS_H
FMT_FUNC fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
- int length = MultiByteToWideChar(
- CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s.size(), 0, 0);
static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16";
+ if (s.size() > INT_MAX)
+ FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG));
+ int s_size = static_cast<int>(s.size());
+ int length = MultiByteToWideChar(
+ CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, 0, 0);
if (length == 0)
FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
buffer_.resize(length + 1);
length = MultiByteToWideChar(
- CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s.size(), &buffer_[0], length);
+ CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, &buffer_[0], length);
if (length == 0)
FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
buffer_[length] = 0;
@@ -632,12 +524,15 @@ FMT_FUNC fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) {
}
FMT_FUNC int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
- int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s.size(), 0, 0, 0, 0);
+ if (s.size() > INT_MAX)
+ return ERROR_INVALID_PARAMETER;
+ int s_size = static_cast<int>(s.size());
+ int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, 0, 0, 0, 0);
if (length == 0)
return GetLastError();
buffer_.resize(length + 1);
length = WideCharToMultiByte(
- CP_UTF8, 0, s.data(), s.size(), &buffer_[0], length, 0, 0);
+ CP_UTF8, 0, s.data(), s_size, &buffer_[0], length, 0, 0);
if (length == 0)
return GetLastError();
buffer_[length] = 0;
@@ -679,7 +574,7 @@ FMT_FUNC void fmt::internal::format_windows_error(
}
}
} FMT_CATCH(...) {}
- format_error_code(out, error_code, message);
+ fmt::format_error_code(out, error_code, message); // 'fmt::' is for bcc32.
}
#endif // FMT_USE_WINDOWS_H
@@ -702,7 +597,7 @@ FMT_FUNC void fmt::internal::format_system_error(
buffer.resize(buffer.size() * 2);
}
} FMT_CATCH(...) {}
- format_error_code(out, error_code, message);
+ fmt::format_error_code(out, error_code, message); // 'fmt::' is for bcc32.
}
template <typename Char>
@@ -755,68 +650,6 @@ void fmt::internal::FixedBuffer<Char>::grow(std::size_t) {
FMT_THROW(std::runtime_error("buffer overflow"));
}
-template <typename Char>
-template <typename StrChar>
-void fmt::BasicWriter<Char>::write_str(
- const Arg::StringValue<StrChar> &s, const FormatSpec &spec) {
- // Check if StrChar is convertible to Char.
- internal::CharTraits<Char>::convert(StrChar());
- if (spec.type_ && spec.type_ != 's')
- internal::report_unknown_type(spec.type_, "string");
- const StrChar *str_value = s.value;
- std::size_t str_size = s.size;
- if (str_size == 0) {
- if (!str_value)
- FMT_THROW(FormatError("string pointer is null"));
- if (*str_value)
- str_size = std::char_traits<StrChar>::length(str_value);
- }
- std::size_t precision = spec.precision_;
- if (spec.precision_ >= 0 && precision < str_size)
- str_size = spec.precision_;
- write_str(str_value, str_size, spec);
-}
-
-template <typename Char>
-inline Arg fmt::BasicFormatter<Char>::get_arg(
- BasicStringRef<Char> arg_name, const char *&error) {
- if (check_no_auto_index(error)) {
- map_.init(args());
- const Arg *arg = map_.find(arg_name);
- if (arg)
- return *arg;
- error = "argument not found";
- }
- return Arg();
-}
-
-template <typename Char>
-inline Arg fmt::BasicFormatter<Char>::parse_arg_index(const Char *&s) {
- const char *error = 0;
- Arg arg = *s < '0' || *s > '9' ?
- next_arg(error) : get_arg(parse_nonnegative_int(s), error);
- if (error) {
- FMT_THROW(FormatError(
- *s != '}' && *s != ':' ? "invalid format string" : error));
- }
- return arg;
-}
-
-template <typename Char>
-inline Arg fmt::BasicFormatter<Char>::parse_arg_name(const Char *&s) {
- assert(is_name_start(*s));
- const Char *start = s;
- Char c;
- do {
- c = *++s;
- } while (is_name_start(c) || ('0' <= c && c <= '9'));
- const char *error = 0;
- Arg arg = get_arg(fmt::BasicStringRef<Char>(start, s - start), error);
- if (error)
- FMT_THROW(fmt::FormatError(error));
- return arg;
-}
-
FMT_FUNC Arg fmt::internal::FormatterBase::do_get_arg(
unsigned arg_index, const char *&error) {
Arg arg = args_[arg_index];
@@ -832,28 +665,6 @@ FMT_FUNC Arg fmt::internal::FormatterBase::do_get_arg(
return arg;
}
-inline Arg fmt::internal::FormatterBase::next_arg(const char *&error) {
- if (next_arg_index_ >= 0)
- return do_get_arg(next_arg_index_++, error);
- error = "cannot switch from manual to automatic argument indexing";
- return Arg();
-}
-
-inline bool fmt::internal::FormatterBase::check_no_auto_index(
- const char *&error) {
- if (next_arg_index_ > 0) {
- error = "cannot switch from automatic to manual argument indexing";
- return false;
- }
- next_arg_index_ = -1;
- return true;
-}
-
-inline Arg fmt::internal::FormatterBase::get_arg(
- unsigned arg_index, const char *&error) {
- return check_no_auto_index(error) ? do_get_arg(arg_index, error) : Arg();
-}
-
template <typename Char>
void fmt::internal::PrintfFormatter<Char>::parse_flags(
FormatSpec &spec, const Char *&s) {
@@ -929,10 +740,8 @@ unsigned fmt::internal::PrintfFormatter<Char>::parse_header(
template <typename Char>
void fmt::internal::PrintfFormatter<Char>::format(
- BasicWriter<Char> &writer, BasicCStringRef<Char> format_str,
- const ArgList &args) {
+ BasicWriter<Char> &writer, BasicCStringRef<Char> format_str) {
const Char *start = format_str.c_str();
- set_args(args);
const Char *s = start;
while (*s) {
Char c = *s++;
@@ -989,10 +798,10 @@ void fmt::internal::PrintfFormatter<Char>::format(
ArgConverter<intmax_t>(arg, *s).visit(arg);
break;
case 'z':
- ArgConverter<size_t>(arg, *s).visit(arg);
+ ArgConverter<std::size_t>(arg, *s).visit(arg);
break;
case 't':
- ArgConverter<ptrdiff_t>(arg, *s).visit(arg);
+ ArgConverter<std::ptrdiff_t>(arg, *s).visit(arg);
break;
case 'L':
// printf produces garbage when 'L' is omitted for long double, no
@@ -1028,207 +837,17 @@ void fmt::internal::PrintfFormatter<Char>::format(
write(writer, start, s);
}
-template <typename Char>
-const Char *fmt::BasicFormatter<Char>::format(
- const Char *&format_str, const Arg &arg) {
- const Char *s = format_str;
- FormatSpec spec;
- if (*s == ':') {
- if (arg.type == Arg::CUSTOM) {
- arg.custom.format(this, arg.custom.value, &s);
- return s;
- }
- ++s;
- // Parse fill and alignment.
- if (Char c = *s) {
- const Char *p = s + 1;
- spec.align_ = ALIGN_DEFAULT;
- do {
- switch (*p) {
- case '<':
- spec.align_ = ALIGN_LEFT;
- break;
- case '>':
- spec.align_ = ALIGN_RIGHT;
- break;
- case '=':
- spec.align_ = ALIGN_NUMERIC;
- break;
- case '^':
- spec.align_ = ALIGN_CENTER;
- break;
- }
- if (spec.align_ != ALIGN_DEFAULT) {
- if (p != s) {
- if (c == '}') break;
- if (c == '{')
- FMT_THROW(FormatError("invalid fill character '{'"));
- s += 2;
- spec.fill_ = c;
- } else ++s;
- if (spec.align_ == ALIGN_NUMERIC)
- require_numeric_argument(arg, '=');
- break;
- }
- } while (--p >= s);
- }
-
- // Parse sign.
- switch (*s) {
- case '+':
- check_sign(s, arg);
- spec.flags_ |= SIGN_FLAG | PLUS_FLAG;
- break;
- case '-':
- check_sign(s, arg);
- spec.flags_ |= MINUS_FLAG;
- break;
- case ' ':
- check_sign(s, arg);
- spec.flags_ |= SIGN_FLAG;
- break;
- }
-
- if (*s == '#') {
- require_numeric_argument(arg, '#');
- spec.flags_ |= HASH_FLAG;
- ++s;
- }
-
- // Parse zero flag.
- if (*s == '0') {
- require_numeric_argument(arg, '0');
- spec.align_ = ALIGN_NUMERIC;
- spec.fill_ = '0';
- ++s;
- }
-
- // Parse width.
- if ('0' <= *s && *s <= '9') {
- spec.width_ = parse_nonnegative_int(s);
- } else if (*s == '{') {
- ++s;
- Arg width_arg = is_name_start(*s) ?
- parse_arg_name(s) : parse_arg_index(s);
- if (*s++ != '}')
- FMT_THROW(FormatError("invalid format string"));
- ULongLong value = 0;
- switch (width_arg.type) {
- case Arg::INT:
- if (width_arg.int_value < 0)
- FMT_THROW(FormatError("negative width"));
- value = width_arg.int_value;
- break;
- case Arg::UINT:
- value = width_arg.uint_value;
- break;
- case Arg::LONG_LONG:
- if (width_arg.long_long_value < 0)
- FMT_THROW(FormatError("negative width"));
- value = width_arg.long_long_value;
- break;
- case Arg::ULONG_LONG:
- value = width_arg.ulong_long_value;
- break;
- default:
- FMT_THROW(FormatError("width is not integer"));
- }
- if (value > INT_MAX)
- FMT_THROW(FormatError("number is too big"));
- spec.width_ = static_cast<int>(value);
- }
-
- // Parse precision.
- if (*s == '.') {
- ++s;
- spec.precision_ = 0;
- if ('0' <= *s && *s <= '9') {
- spec.precision_ = parse_nonnegative_int(s);
- } else if (*s == '{') {
- ++s;
- Arg precision_arg =
- is_name_start(*s) ? parse_arg_name(s) : parse_arg_index(s);
- if (*s++ != '}')
- FMT_THROW(FormatError("invalid format string"));
- ULongLong value = 0;
- switch (precision_arg.type) {
- case Arg::INT:
- if (precision_arg.int_value < 0)
- FMT_THROW(FormatError("negative precision"));
- value = precision_arg.int_value;
- break;
- case Arg::UINT:
- value = precision_arg.uint_value;
- break;
- case Arg::LONG_LONG:
- if (precision_arg.long_long_value < 0)
- FMT_THROW(FormatError("negative precision"));
- value = precision_arg.long_long_value;
- break;
- case Arg::ULONG_LONG:
- value = precision_arg.ulong_long_value;
- break;
- default:
- FMT_THROW(FormatError("precision is not integer"));
- }
- if (value > INT_MAX)
- FMT_THROW(FormatError("number is too big"));
- spec.precision_ = static_cast<int>(value);
- } else {
- FMT_THROW(FormatError("missing precision specifier"));
- }
- if (arg.type <= Arg::LAST_INTEGER_TYPE || arg.type == Arg::POINTER) {
- FMT_THROW(FormatError(
- fmt::format("precision not allowed in {} format specifier",
- arg.type == Arg::POINTER ? "pointer" : "integer")));
- }
- }
-
- // Parse type.
- if (*s != '}' && *s)
- spec.type_ = static_cast<char>(*s++);
- }
-
- if (*s++ != '}')
- FMT_THROW(FormatError("missing '}' in format string"));
- start_ = s;
-
- // Format argument.
- internal::ArgFormatter<Char>(*this, spec, s - 1).visit(arg);
- return s;
-}
-
-template <typename Char>
-void fmt::BasicFormatter<Char>::format(
- BasicCStringRef<Char> format_str, const ArgList &args) {
- const Char *s = start_ = format_str.c_str();
- set_args(args);
- while (*s) {
- Char c = *s++;
- if (c != '{' && c != '}') continue;
- if (*s == c) {
- write(writer_, start_, s);
- start_ = ++s;
- continue;
- }
- if (c == '}')
- FMT_THROW(FormatError("unmatched '}' in format string"));
- write(writer_, start_, s - 1);
- Arg arg = is_name_start(*s) ? parse_arg_name(s) : parse_arg_index(s);
- s = format(s, arg);
- }
- write(writer_, start_, s);
-}
-
FMT_FUNC void fmt::report_system_error(
int error_code, fmt::StringRef message) FMT_NOEXCEPT {
- report_error(internal::format_system_error, error_code, message);
+ // 'fmt::' is for bcc32.
+ fmt::report_error(internal::format_system_error, error_code, message);
}
#if FMT_USE_WINDOWS_H
FMT_FUNC void fmt::report_windows_error(
int error_code, fmt::StringRef message) FMT_NOEXCEPT {
- report_error(internal::format_windows_error, error_code, message);
+ // 'fmt::' is for bcc32.
+ fmt::report_error(internal::format_windows_error, error_code, message);
}
#endif
@@ -1250,7 +869,7 @@ FMT_FUNC void fmt::print(std::ostream &os, CStringRef format_str, ArgList args)
FMT_FUNC void fmt::print_colored(Color c, CStringRef format, ArgList args) {
char escape[] = "\x1b[30m";
- escape[3] = '0' + static_cast<char>(c);
+ escape[3] = static_cast<char>('0' + c);
std::fputs(escape, stdout);
print(format, args);
std::fputs(RESET_COLOR, stdout);
@@ -1271,14 +890,10 @@ template struct fmt::internal::BasicData<void>;
template void fmt::internal::FixedBuffer<char>::grow(std::size_t);
-template const char *fmt::BasicFormatter<char>::format(
- const char *&format_str, const fmt::internal::Arg &arg);
-
-template void fmt::BasicFormatter<char>::format(
- CStringRef format, const ArgList &args);
+template void fmt::internal::ArgMap<char>::init(const fmt::ArgList &args);
template void fmt::internal::PrintfFormatter<char>::format(
- BasicWriter<char> &writer, CStringRef format, const ArgList &args);
+ BasicWriter<char> &writer, CStringRef format);
template int fmt::internal::CharTraits<char>::format_float(
char *buffer, std::size_t size, const char *format,
@@ -1292,15 +907,10 @@ template int fmt::internal::CharTraits<char>::format_float(
template void fmt::internal::FixedBuffer<wchar_t>::grow(std::size_t);
-template const wchar_t *fmt::BasicFormatter<wchar_t>::format(
- const wchar_t *&format_str, const fmt::internal::Arg &arg);
-
-template void fmt::BasicFormatter<wchar_t>::format(
- BasicCStringRef<wchar_t> format, const ArgList &args);
+template void fmt::internal::ArgMap<wchar_t>::init(const fmt::ArgList &args);
template void fmt::internal::PrintfFormatter<wchar_t>::format(
- BasicWriter<wchar_t> &writer, WCStringRef format,
- const ArgList &args);
+ BasicWriter<wchar_t> &writer, WCStringRef format);
template int fmt::internal::CharTraits<wchar_t>::format_float(
wchar_t *buffer, std::size_t size, const wchar_t *format,
@@ -1312,6 +922,6 @@ template int fmt::internal::CharTraits<wchar_t>::format_float(
#endif // FMT_HEADER_ONLY
-#if _MSC_VER
+#ifdef _MSC_VER
# pragma warning(pop)
#endif
diff --git a/dep/cppformat/format.h b/dep/cppformat/format.h
index dfe95a77931..a98a166091b 100644
--- a/dep/cppformat/format.h
+++ b/dep/cppformat/format.h
@@ -28,20 +28,39 @@
#ifndef FMT_FORMAT_H_
#define FMT_FORMAT_H_
+#if defined _MSC_VER && _MSC_VER <= 1500
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef long long intmax_t;
+#else
#include <stdint.h>
+#endif
#include <cassert>
#include <cmath>
-#include <cstddef> // for std::ptrdiff_t
#include <cstdio>
-#include <algorithm>
+#include <cstring>
#include <limits>
+#include <memory>
#include <stdexcept>
#include <string>
-#include <sstream>
#include <map>
-#if _SECURE_SCL
+#ifndef FMT_USE_IOSTREAMS
+# define FMT_USE_IOSTREAMS 1
+#endif
+
+#if FMT_USE_IOSTREAMS
+# include <ostream>
+#endif
+
+#ifdef _SECURE_SCL
+# define FMT_SECURE_SCL _SECURE_SCL
+#else
+# define FMT_SECURE_SCL 0
+#endif
+
+#if FMT_SECURE_SCL
# include <iterator>
#endif
@@ -92,6 +111,9 @@ inline uint32_t clzll(uint64_t x) {
// Disable the warning about declaration shadowing because it affects too
// many valid cases.
# pragma GCC diagnostic ignored "-Wshadow"
+// Disable the warning about implicit conversions that may change the sign of
+// an integer; silencing it otherwise would require many explicit casts.
+# pragma GCC diagnostic ignored "-Wsign-conversion"
# endif
# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__
# define FMT_HAS_GXX_CXX11 1
@@ -100,7 +122,7 @@ inline uint32_t clzll(uint64_t x) {
# define FMT_GCC_EXTENSION
#endif
-#ifdef __clang__
+#if defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdocumentation"
#endif
@@ -153,17 +175,45 @@ inline uint32_t clzll(uint64_t x) {
#endif
// Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature).
+#ifndef FMT_USE_NOEXCEPT
+# define FMT_USE_NOEXCEPT 0
+#endif
+
#ifndef FMT_NOEXCEPT
# if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \
- (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11)
+ (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \
+ _MSC_VER >= 1900
# define FMT_NOEXCEPT noexcept
# else
# define FMT_NOEXCEPT throw()
# endif
#endif
+// Check if exceptions are disabled.
+#if defined(__GNUC__) && !defined(__EXCEPTIONS)
+# define FMT_EXCEPTIONS 0
+#endif
+#if defined(_MSC_VER) && !_HAS_EXCEPTIONS
+# define FMT_EXCEPTIONS 0
+#endif
+#ifndef FMT_EXCEPTIONS
+# define FMT_EXCEPTIONS 1
+#endif
+
+#ifndef FMT_THROW
+# if FMT_EXCEPTIONS
+# define FMT_THROW(x) throw x
+# else
+# define FMT_THROW(x) assert(false)
+# endif
+#endif
+
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
+#ifndef FMT_USE_DELETED_FUNCTIONS
+# define FMT_USE_DELETED_FUNCTIONS 0
+#endif
+
#if FMT_USE_DELETED_FUNCTIONS || FMT_HAS_FEATURE(cxx_deleted_functions) || \
(FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800
# define FMT_DELETED_OR_UNDEFINED = delete
@@ -177,11 +227,93 @@ inline uint32_t clzll(uint64_t x) {
TypeName& operator=(const TypeName&)
#endif
+#ifndef FMT_USE_USER_DEFINED_LITERALS
+// All compilers which support UDLs also support variadic templates. This
+// makes the fmt::literals implementation easier. However, an explicit check
+// for variadic templates is added here just in case.
+# define FMT_USE_USER_DEFINED_LITERALS \
+ FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES && \
+ (FMT_HAS_FEATURE(cxx_user_literals) || \
+ (FMT_GCC_VERSION >= 407 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1900)
+#endif
+
#ifndef FMT_ASSERT
# define FMT_ASSERT(condition, message) assert((condition) && message)
#endif
namespace fmt {
+namespace internal {
+struct DummyInt {
+ int data[2];
+ operator int() const { return 0; }
+};
+typedef std::numeric_limits<fmt::internal::DummyInt> FPUtil;
+
+// Dummy implementations of system functions such as signbit and ecvt called
+// if the latter are not available.
+inline DummyInt signbit(...) { return DummyInt(); }
+inline DummyInt _ecvt_s(...) { return DummyInt(); }
+inline DummyInt isinf(...) { return DummyInt(); }
+inline DummyInt _finite(...) { return DummyInt(); }
+inline DummyInt isnan(...) { return DummyInt(); }
+inline DummyInt _isnan(...) { return DummyInt(); }
+
+// A helper function to suppress bogus "conditional expression is constant"
+// warnings.
+template <typename T>
+inline T check(T value) { return value; }
+}
+} // namespace fmt
+
+namespace std {
+// Standard permits specialization of std::numeric_limits. This specialization
+// is used to resolve ambiguity between isinf and std::isinf in glibc:
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891
+// and the same for isnan and signbit.
+template <>
+class numeric_limits<fmt::internal::DummyInt> :
+ public std::numeric_limits<int> {
+ public:
+ // Portable version of isinf.
+ template <typename T>
+ static bool isinfinity(T x) {
+ using namespace fmt::internal;
+ // The resolution "priority" is:
+ // isinf macro > std::isinf > ::isinf > fmt::internal::isinf
+ if (check(sizeof(isinf(x)) == sizeof(bool) ||
+ sizeof(isinf(x)) == sizeof(int))) {
+ return isinf(x) != 0;
+ }
+ return !_finite(static_cast<double>(x));
+ }
+
+ // Portable version of isnan.
+ template <typename T>
+ static bool isnotanumber(T x) {
+ using namespace fmt::internal;
+ if (check(sizeof(isnan(x)) == sizeof(bool) ||
+ sizeof(isnan(x)) == sizeof(int))) {
+ return isnan(x) != 0;
+ }
+ return _isnan(static_cast<double>(x)) != 0;
+ }
+
+ // Portable version of signbit.
+ static bool isnegative(double x) {
+ using namespace fmt::internal;
+ if (check(sizeof(signbit(x)) == sizeof(int)))
+ return signbit(x) != 0;
+ if (x < 0) return true;
+ if (!isnotanumber(x)) return false;
+ int dec = 0, sign = 0;
+ char buffer[2]; // The buffer size must be >= 2 or _ecvt_s will fail.
+ _ecvt_s(buffer, sizeof(buffer), x, 0, &dec, &sign);
+ return sign != 0;
+ }
+};
+} // namespace std
+
+namespace fmt {
// Fix the warning about long long on older versions of GCC
// that don't support the diagnostic pragma.
@@ -207,7 +339,7 @@ void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value);
/**
\rst
A string reference. It can be constructed from a C string or ``std::string``.
-
+
You can use one of the following typedefs for common character types:
+------------+-------------------------+
@@ -270,22 +402,38 @@ class BasicStringRef {
/** Returns the string size. */
std::size_t size() const { return size_; }
+ // Lexicographically compare this string reference to other.
+ int compare(BasicStringRef other) const {
+ std::size_t size = size_ < other.size_ ? size_ : other.size_;
+ int result = std::char_traits<Char>::compare(data_, other.data_, size);
+ if (result == 0)
+ result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
+ return result;
+ }
+
friend bool operator==(BasicStringRef lhs, BasicStringRef rhs) {
- return lhs.data_ == rhs.data_;
+ return lhs.compare(rhs) == 0;
}
friend bool operator!=(BasicStringRef lhs, BasicStringRef rhs) {
- return lhs.data_ != rhs.data_;
+ return lhs.compare(rhs) != 0;
}
friend bool operator<(BasicStringRef lhs, BasicStringRef rhs) {
- return std::lexicographical_compare(
- lhs.data_, lhs.data_ + lhs.size_, rhs.data_, rhs.data_ + rhs.size_);
+ return lhs.compare(rhs) < 0;
+ }
+ friend bool operator<=(BasicStringRef lhs, BasicStringRef rhs) {
+ return lhs.compare(rhs) <= 0;
+ }
+ friend bool operator>(BasicStringRef lhs, BasicStringRef rhs) {
+ return lhs.compare(rhs) > 0;
+ }
+ friend bool operator>=(BasicStringRef lhs, BasicStringRef rhs) {
+ return lhs.compare(rhs) >= 0;
}
};
typedef BasicStringRef<char> StringRef;
typedef BasicStringRef<wchar_t> WStringRef;
-
/**
\rst
A reference to a null terminated string. It can be constructed from a C
@@ -348,7 +496,7 @@ namespace internal {
// to avoid dynamic memory allocation.
enum { INLINE_BUFFER_SIZE = 500 };
-#if _SECURE_SCL
+#if FMT_SECURE_SCL
// Use checked iterator to avoid warnings on MSVC.
template <typename T>
inline stdext::checked_array_iterator<T*> make_ptr(T *ptr, std::size_t size) {
@@ -433,11 +581,13 @@ class Buffer {
template <typename T>
template <typename U>
void Buffer<T>::append(const U *begin, const U *end) {
- std::ptrdiff_t num_elements = end - begin;
- if (size_ + num_elements > capacity_)
- grow(size_ + num_elements);
- std::copy(begin, end, internal::make_ptr(ptr_, capacity_) + size_);
- size_ += num_elements;
+ assert(begin <= end);
+ std::size_t new_size = size_ + (end - begin);
+ if (new_size > capacity_)
+ grow(new_size);
+ std::uninitialized_copy(begin, end,
+ internal::make_ptr(ptr_, capacity_) + size_);
+ size_ = new_size;
}
namespace internal {
@@ -449,9 +599,9 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
private:
T data_[SIZE];
- // Free memory allocated by the buffer.
- void free() {
- if (this->ptr_ != data_) this->deallocate(this->ptr_, this->capacity_);
+ // Deallocate memory allocated by the buffer.
+ void deallocate() {
+ if (this->ptr_ != data_) Allocator::deallocate(this->ptr_, this->capacity_);
}
protected:
@@ -460,7 +610,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
public:
explicit MemoryBuffer(const Allocator &alloc = Allocator())
: Allocator(alloc), Buffer<T>(data_, SIZE) {}
- ~MemoryBuffer() { free(); }
+ ~MemoryBuffer() { deallocate(); }
#if FMT_USE_RVALUE_REFERENCES
private:
@@ -472,12 +622,12 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
this->capacity_ = other.capacity_;
if (other.ptr_ == other.data_) {
this->ptr_ = data_;
- std::copy(other.data_,
- other.data_ + this->size_, make_ptr(data_, this->capacity_));
+ std::uninitialized_copy(other.data_, other.data_ + this->size_,
+ make_ptr(data_, this->capacity_));
} else {
this->ptr_ = other.ptr_;
// Set pointer to the inline array so that delete is not called
- // when freeing.
+ // when deallocating.
other.ptr_ = other.data_;
}
}
@@ -489,7 +639,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
MemoryBuffer &operator=(MemoryBuffer &&other) {
assert(this != &other);
- free();
+ deallocate();
move(other);
return *this;
}
@@ -501,12 +651,13 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
template <typename T, std::size_t SIZE, typename Allocator>
void MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size) {
- std::size_t new_capacity =
- (std::max)(size, this->capacity_ + this->capacity_ / 2);
+ std::size_t new_capacity = this->capacity_ + this->capacity_ / 2;
+ if (size > new_capacity)
+ new_capacity = size;
T *new_ptr = this->allocate(new_capacity);
// The following code doesn't throw, so the raw pointer above doesn't leak.
- std::copy(this->ptr_,
- this->ptr_ + this->size_, make_ptr(new_ptr, new_capacity));
+ std::uninitialized_copy(this->ptr_, this->ptr_ + this->size_,
+ make_ptr(new_ptr, new_capacity));
std::size_t old_capacity = this->capacity_;
T *old_ptr = this->ptr_;
this->capacity_ = new_capacity;
@@ -515,7 +666,7 @@ void MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size) {
// the buffer already uses the new storage and will deallocate it in case
// of exception.
if (old_ptr != data_)
- this->deallocate(old_ptr, old_capacity);
+ Allocator::deallocate(old_ptr, old_capacity);
}
// A fixed-size buffer.
@@ -528,50 +679,15 @@ class FixedBuffer : public fmt::Buffer<Char> {
void grow(std::size_t size);
};
-#ifndef _MSC_VER
-// Portable version of signbit.
-inline int getsign(double x) {
- // When compiled in C++11 mode signbit is no longer a macro but a function
- // defined in namespace std and the macro is undefined.
-# ifdef signbit
- return signbit(x);
-# else
- return std::signbit(x);
-# endif
-}
-
-// Portable version of isinf.
-# ifdef isinf
-inline int isinfinity(double x) { return isinf(x); }
-inline int isinfinity(long double x) { return isinf(x); }
-# else
-inline int isinfinity(double x) { return std::isinf(x); }
-inline int isinfinity(long double x) { return std::isinf(x); }
-# endif
-#else
-inline int getsign(double value) {
- if (value < 0) return 1;
- if (value == value) return 0;
- int dec = 0, sign = 0;
- char buffer[2]; // The buffer size must be >= 2 or _ecvt_s will fail.
- _ecvt_s(buffer, sizeof(buffer), value, 0, &dec, &sign);
- return sign;
-}
-inline int isinfinity(double x) { return !_finite(x); }
-inline int isinfinity(long double x) {
- return !_finite(static_cast<double>(x));
-}
-#endif
-
template <typename Char>
class BasicCharTraits {
public:
-#if _SECURE_SCL
+#if FMT_SECURE_SCL
typedef stdext::checked_array_iterator<Char*> CharPtr;
#else
typedef Char *CharPtr;
#endif
- static Char cast(wchar_t value) { return static_cast<Char>(value); }
+ static Char cast(int value) { return static_cast<Char>(value); }
};
template <typename Char>
@@ -712,24 +828,23 @@ inline unsigned count_digits(uint32_t n) {
// Formats a decimal unsigned integer value writing into buffer.
template <typename UInt, typename Char>
inline void format_decimal(Char *buffer, UInt value, unsigned num_digits) {
- --num_digits;
+ buffer += num_digits;
while (value >= 100) {
// Integer division is slow so do it for a group of two digits instead
// of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison.
- unsigned index = (value % 100) * 2;
+ unsigned index = static_cast<unsigned>((value % 100) * 2);
value /= 100;
- buffer[num_digits] = Data::DIGITS[index + 1];
- buffer[num_digits - 1] = Data::DIGITS[index];
- num_digits -= 2;
+ *--buffer = Data::DIGITS[index + 1];
+ *--buffer = Data::DIGITS[index];
}
if (value < 10) {
- *buffer = static_cast<char>('0' + value);
+ *--buffer = static_cast<char>('0' + value);
return;
}
unsigned index = static_cast<unsigned>(value * 2);
- buffer[1] = Data::DIGITS[index + 1];
- buffer[0] = Data::DIGITS[index];
+ *--buffer = Data::DIGITS[index + 1];
+ *--buffer = Data::DIGITS[index];
}
#ifndef _WIN32
@@ -833,48 +948,80 @@ template <typename Char>
struct NamedArg;
template <typename T = void>
-struct None {};
+struct Null {};
// A helper class template to enable or disable overloads taking wide
// characters and strings in MakeValue.
template <typename T, typename Char>
struct WCharHelper {
- typedef None<T> Supported;
+ typedef Null<T> Supported;
typedef T Unsupported;
};
template <typename T>
struct WCharHelper<T, wchar_t> {
typedef T Supported;
- typedef None<T> Unsupported;
+ typedef Null<T> Unsupported;
};
+typedef char Yes[1];
+typedef char No[2];
+
+// These are non-members to workaround an overload resolution bug in bcc32.
+Yes &convert(fmt::ULongLong);
+Yes &convert(std::ostream &);
+No &convert(...);
+
template <typename T>
-class IsConvertibleToInt {
- private:
- typedef char yes[1];
- typedef char no[2];
+T &get();
+
+struct DummyStream : std::ostream {
+ // Hide all operator<< overloads from std::ostream.
+ void operator<<(Null<>);
+};
- static const T &get();
+No &operator<<(std::ostream &, int);
- static yes &check(fmt::ULongLong);
- static no &check(...);
-
- public:
- enum { value = (sizeof(check(get())) == sizeof(yes)) };
+template<typename T, bool ENABLE_CONVERSION>
+struct ConvertToIntImpl {
+ enum { value = false };
+};
+
+template<typename T>
+struct ConvertToIntImpl<T, true> {
+ // Convert to int only if T doesn't have an overloaded operator<<.
+ enum {
+ value = sizeof(convert(get<DummyStream>() << get<T>())) == sizeof(No)
+ };
+};
+
+template<typename T, bool ENABLE_CONVERSION>
+struct ConvertToIntImpl2 {
+ enum { value = false };
};
-#define FMT_CONVERTIBLE_TO_INT(Type) \
+template<typename T>
+struct ConvertToIntImpl2<T, true> {
+ enum {
+ // Don't convert numeric types.
+ value = ConvertToIntImpl<T, !std::numeric_limits<T>::is_specialized>::value
+ };
+};
+
+template<typename T>
+struct ConvertToInt {
+ enum { enable_conversion = sizeof(convert(get<T>())) == sizeof(Yes) };
+ enum { value = ConvertToIntImpl2<T, enable_conversion>::value };
+};
+
+#define FMT_DISABLE_CONVERSION_TO_INT(Type) \
template <> \
- class IsConvertibleToInt<Type> { \
- public: \
- enum { value = 1 }; \
- }
+ struct ConvertToInt<Type> { enum { value = 0 }; }
// Silence warnings about convering float to int.
-FMT_CONVERTIBLE_TO_INT(float);
-FMT_CONVERTIBLE_TO_INT(double);
-FMT_CONVERTIBLE_TO_INT(long double);
+FMT_DISABLE_CONVERSION_TO_INT(float);
+FMT_DISABLE_CONVERSION_TO_INT(double);
+FMT_DISABLE_CONVERSION_TO_INT(long double);
template<bool B, class T = void>
struct EnableIf {};
@@ -888,13 +1035,19 @@ struct Conditional { typedef T type; };
template<class T, class F>
struct Conditional<false, T, F> { typedef F type; };
-// A helper function to suppress bogus "conditional expression is constant"
-// warnings.
-inline bool check(bool value) { return value; }
+// For bcc32 which doesn't understand ! in template arguments.
+template<bool>
+struct Not { enum { value = 0 }; };
+
+template<>
+struct Not<false> { enum { value = 1 }; };
// Makes an Arg object from any type.
-template <typename Char>
+template <typename Formatter>
class MakeValue : public Arg {
+ public:
+ typedef typename Formatter::Char Char;
+
private:
// The following two methods are private to disallow formatting of
// arbitrary pointers. If you want to output a pointer cast it to
@@ -910,7 +1063,9 @@ class MakeValue : public Arg {
// characters and strings into narrow strings as in
// fmt::format("{}", L"test");
// To fix this, use a wide format string: fmt::format(L"{}", L"test").
+#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
MakeValue(typename WCharHelper<wchar_t, Char>::Unsupported);
+#endif
MakeValue(typename WCharHelper<wchar_t *, Char>::Unsupported);
MakeValue(typename WCharHelper<const wchar_t *, Char>::Unsupported);
MakeValue(typename WCharHelper<const std::wstring &, Char>::Unsupported);
@@ -930,7 +1085,7 @@ class MakeValue : public Arg {
template <typename T>
static void format_custom_arg(
void *formatter, const void *arg, void *format_str_ptr) {
- format(*static_cast<BasicFormatter<Char>*>(formatter),
+ format(*static_cast<Formatter*>(formatter),
*static_cast<const Char**>(format_str_ptr),
*static_cast<const T*>(arg));
}
@@ -979,14 +1134,16 @@ class MakeValue : public Arg {
FMT_MAKE_VALUE(float, double_value, DOUBLE)
FMT_MAKE_VALUE(double, double_value, DOUBLE)
FMT_MAKE_VALUE(long double, long_double_value, LONG_DOUBLE)
- FMT_MAKE_VALUE(signed char, int_value, CHAR)
- FMT_MAKE_VALUE(unsigned char, int_value, CHAR)
+ FMT_MAKE_VALUE(signed char, int_value, INT)
+ FMT_MAKE_VALUE(unsigned char, uint_value, UINT)
FMT_MAKE_VALUE(char, int_value, CHAR)
+#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
MakeValue(typename WCharHelper<wchar_t, Char>::Supported value) {
int_value = value;
}
static uint64_t type(wchar_t) { return Arg::CHAR; }
+#endif
#define FMT_MAKE_STR_VALUE(Type, TYPE) \
MakeValue(Type value) { set_string(value); } \
@@ -1016,24 +1173,25 @@ class MakeValue : public Arg {
template <typename T>
MakeValue(const T &value,
- typename EnableIf<!IsConvertibleToInt<T>::value, int>::type = 0) {
+ typename EnableIf<Not<
+ ConvertToInt<T>::value>::value, int>::type = 0) {
custom.value = &value;
custom.format = &format_custom_arg<T>;
}
template <typename T>
MakeValue(const T &value,
- typename EnableIf<IsConvertibleToInt<T>::value, int>::type = 0) {
+ typename EnableIf<ConvertToInt<T>::value, int>::type = 0) {
int_value = value;
}
template <typename T>
static uint64_t type(const T &) {
- return IsConvertibleToInt<T>::value ? Arg::INT : Arg::CUSTOM;
+ return ConvertToInt<T>::value ? Arg::INT : Arg::CUSTOM;
}
// Additional template param `Char_` is needed here because make_type always
- // uses MakeValue<char>.
+ // uses char.
template <typename Char_>
MakeValue(const NamedArg<Char_> &value) { pointer = &value; }
@@ -1045,10 +1203,12 @@ template <typename Char>
struct NamedArg : Arg {
BasicStringRef<Char> name;
+ typedef internal::MakeValue< BasicFormatter<Char> > MakeValue;
+
template <typename T>
- NamedArg(BasicStringRef<Char> name, const T &value)
- : name(name), Arg(MakeValue<Char>(value)) {
- type = static_cast<internal::Arg::Type>(MakeValue<Char>::type(value));
+ NamedArg(BasicStringRef<Char> argname, const T &value)
+ : Arg(MakeValue(value)), name(argname) {
+ type = static_cast<Arg::Type>(MakeValue::type(value));
}
};
@@ -1118,6 +1278,9 @@ class ArgVisitor {
return FMT_DISPATCH(visit_unhandled_arg());
}
+ Result visit_cstring(const char *) {
+ return FMT_DISPATCH(visit_unhandled_arg());
+ }
Result visit_string(Arg::StringValue<char>) {
return FMT_DISPATCH(visit_unhandled_arg());
}
@@ -1145,18 +1308,15 @@ class ArgVisitor {
case Arg::ULONG_LONG:
return FMT_DISPATCH(visit_ulong_long(arg.ulong_long_value));
case Arg::BOOL:
- return FMT_DISPATCH(visit_bool(arg.int_value));
+ return FMT_DISPATCH(visit_bool(arg.int_value != 0));
case Arg::CHAR:
return FMT_DISPATCH(visit_char(arg.int_value));
case Arg::DOUBLE:
return FMT_DISPATCH(visit_double(arg.double_value));
case Arg::LONG_DOUBLE:
return FMT_DISPATCH(visit_long_double(arg.long_double_value));
- case Arg::CSTRING: {
- Arg::StringValue<char> str = arg.string;
- str.size = 0;
- return FMT_DISPATCH(visit_string(str));
- }
+ case Arg::CSTRING:
+ return FMT_DISPATCH(visit_cstring(arg.string.value));
case Arg::STRING:
return FMT_DISPATCH(visit_string(arg.string));
case Arg::WSTRING:
@@ -1174,9 +1334,6 @@ class RuntimeError : public std::runtime_error {
RuntimeError() : std::runtime_error("") {}
};
-template <typename Impl, typename Char>
-class BasicArgFormatter;
-
template <typename Char>
class PrintfArgFormatter;
@@ -1248,111 +1405,6 @@ class ArgList {
}
};
-struct FormatSpec;
-
-namespace internal {
-
-template <typename Char>
-class ArgMap {
- private:
- typedef std::map<fmt::BasicStringRef<Char>, internal::Arg> MapType;
- typedef typename MapType::value_type Pair;
-
- MapType map_;
-
- public:
- void init(const ArgList &args);
-
- const internal::Arg* find(const fmt::BasicStringRef<Char> &name) const {
- typename MapType::const_iterator it = map_.find(name);
- return it != map_.end() ? &it->second : 0;
- }
-};
-
-class FormatterBase {
- private:
- ArgList args_;
- int next_arg_index_;
-
- // Returns the argument with specified index.
- Arg do_get_arg(unsigned arg_index, const char *&error);
-
- protected:
- const ArgList &args() const { return args_; }
-
- void set_args(const ArgList &args) {
- args_ = args;
- next_arg_index_ = 0;
- }
-
- // Returns the next argument.
- Arg next_arg(const char *&error);
-
- // Checks if manual indexing is used and returns the argument with
- // specified index.
- Arg get_arg(unsigned arg_index, const char *&error);
-
- bool check_no_auto_index(const char *&error);
-
- template <typename Char>
- void write(BasicWriter<Char> &w, const Char *start, const Char *end) {
- if (start != end)
- w << BasicStringRef<Char>(start, end - start);
- }
-};
-
-// A printf formatter.
-template <typename Char>
-class PrintfFormatter : private FormatterBase {
- private:
- void parse_flags(FormatSpec &spec, const Char *&s);
-
- // Returns the argument with specified index or, if arg_index is equal
- // to the maximum unsigned value, the next argument.
- Arg get_arg(const Char *s,
- unsigned arg_index = (std::numeric_limits<unsigned>::max)());
-
- // Parses argument index, flags and width and returns the argument index.
- unsigned parse_header(const Char *&s, FormatSpec &spec);
-
- public:
- void format(BasicWriter<Char> &writer,
- BasicCStringRef<Char> format_str, const ArgList &args);
-};
-} // namespace internal
-
-// A formatter.
-template <typename Char>
-class BasicFormatter : private internal::FormatterBase {
- private:
- BasicWriter<Char> &writer_;
- const Char *start_;
- internal::ArgMap<Char> map_;
-
- FMT_DISALLOW_COPY_AND_ASSIGN(BasicFormatter);
-
- using FormatterBase::get_arg;
-
- // Checks if manual indexing is used and returns the argument with
- // specified name.
- internal::Arg get_arg(BasicStringRef<Char> arg_name, const char *&error);
-
- // Parses argument index and returns corresponding argument.
- internal::Arg parse_arg_index(const Char *&s);
-
- // Parses argument name and returns corresponding argument.
- internal::Arg parse_arg_name(const Char *&s);
-
- public:
- explicit BasicFormatter(BasicWriter<Char> &w) : writer_(w) {}
-
- BasicWriter<Char> &writer() { return writer_; }
-
- void format(BasicCStringRef<Char> format_str, const ArgList &args);
-
- const Char *format(const Char *&format_str, const internal::Arg &arg);
-};
-
enum Alignment {
ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_NUMERIC
};
@@ -1574,6 +1626,242 @@ inline StrFormatSpec<wchar_t> pad(
return StrFormatSpec<wchar_t>(str, width, fill);
}
+namespace internal {
+
+template <typename Char>
+class ArgMap {
+ private:
+ typedef std::map<fmt::BasicStringRef<Char>, internal::Arg> MapType;
+ typedef typename MapType::value_type Pair;
+
+ MapType map_;
+
+ public:
+ void init(const ArgList &args);
+
+ const internal::Arg* find(const fmt::BasicStringRef<Char> &name) const {
+ typename MapType::const_iterator it = map_.find(name);
+ return it != map_.end() ? &it->second : 0;
+ }
+};
+
+template <typename Impl, typename Char>
+class ArgFormatterBase : public ArgVisitor<Impl, void> {
+ private:
+ BasicWriter<Char> &writer_;
+ FormatSpec &spec_;
+
+ FMT_DISALLOW_COPY_AND_ASSIGN(ArgFormatterBase);
+
+ void write_pointer(const void *p) {
+ spec_.flags_ = HASH_FLAG;
+ spec_.type_ = 'x';
+ writer_.write_int(reinterpret_cast<uintptr_t>(p), spec_);
+ }
+
+ protected:
+ BasicWriter<Char> &writer() { return writer_; }
+ FormatSpec &spec() { return spec_; }
+
+ void write(bool value) {
+ const char *str_value = value ? "true" : "false";
+ Arg::StringValue<char> str = { str_value, std::strlen(str_value) };
+ writer_.write_str(str, spec_);
+ }
+
+ void write(const char *value) {
+ Arg::StringValue<char> str = {value, value != 0 ? std::strlen(value) : 0};
+ writer_.write_str(str, spec_);
+ }
+
+ public:
+ ArgFormatterBase(BasicWriter<Char> &w, FormatSpec &s)
+ : writer_(w), spec_(s) {}
+
+ template <typename T>
+ void visit_any_int(T value) { writer_.write_int(value, spec_); }
+
+ template <typename T>
+ void visit_any_double(T value) { writer_.write_double(value, spec_); }
+
+ void visit_bool(bool value) {
+ if (spec_.type_)
+ return visit_any_int(value);
+ write(value);
+ }
+
+ void visit_char(int value) {
+ if (spec_.type_ && spec_.type_ != 'c') {
+ spec_.flags_ |= CHAR_FLAG;
+ writer_.write_int(value, spec_);
+ return;
+ }
+ if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
+ FMT_THROW(FormatError("invalid format specifier for char"));
+ typedef typename BasicWriter<Char>::CharPtr CharPtr;
+ Char fill = internal::CharTraits<Char>::cast(spec_.fill());
+ CharPtr out = CharPtr();
+ const unsigned CHAR_WIDTH = 1;
+ if (spec_.width_ > CHAR_WIDTH) {
+ out = writer_.grow_buffer(spec_.width_);
+ if (spec_.align_ == ALIGN_RIGHT) {
+ std::uninitialized_fill_n(out, spec_.width_ - CHAR_WIDTH, fill);
+ out += spec_.width_ - CHAR_WIDTH;
+ } else if (spec_.align_ == ALIGN_CENTER) {
+ out = writer_.fill_padding(out, spec_.width_,
+ internal::check(CHAR_WIDTH), fill);
+ } else {
+ std::uninitialized_fill_n(out + CHAR_WIDTH,
+ spec_.width_ - CHAR_WIDTH, fill);
+ }
+ } else {
+ out = writer_.grow_buffer(CHAR_WIDTH);
+ }
+ *out = internal::CharTraits<Char>::cast(value);
+ }
+
+ void visit_cstring(const char *value) {
+ if (spec_.type_ == 'p')
+ return write_pointer(value);
+ write(value);
+ }
+
+ void visit_string(Arg::StringValue<char> value) {
+ writer_.write_str(value, spec_);
+ }
+
+ using ArgVisitor<Impl, void>::visit_wstring;
+
+ void visit_wstring(Arg::StringValue<Char> value) {
+ writer_.write_str(value, spec_);
+ }
+
+ void visit_pointer(const void *value) {
+ if (spec_.type_ && spec_.type_ != 'p')
+ report_unknown_type(spec_.type_, "pointer");
+ write_pointer(value);
+ }
+};
+
+// An argument formatter.
+template <typename Char>
+class BasicArgFormatter :
+ public ArgFormatterBase<BasicArgFormatter<Char>, Char> {
+ private:
+ BasicFormatter<Char> &formatter_;
+ const Char *format_;
+
+ public:
+ BasicArgFormatter(BasicFormatter<Char> &f, FormatSpec &s, const Char *fmt)
+ : ArgFormatterBase<BasicArgFormatter<Char>, Char>(f.writer(), s),
+ formatter_(f), format_(fmt) {}
+
+ void visit_custom(Arg::CustomValue c) {
+ c.format(&formatter_, c.value, &format_);
+ }
+};
+
+class FormatterBase {
+ private:
+ ArgList args_;
+ int next_arg_index_;
+
+ // Returns the argument with specified index.
+ Arg do_get_arg(unsigned arg_index, const char *&error);
+
+ protected:
+ const ArgList &args() const { return args_; }
+
+ explicit FormatterBase(const ArgList &args) {
+ args_ = args;
+ next_arg_index_ = 0;
+ }
+
+ // Returns the next argument.
+ Arg next_arg(const char *&error) {
+ if (next_arg_index_ >= 0)
+ return do_get_arg(next_arg_index_++, error);
+ error = "cannot switch from manual to automatic argument indexing";
+ return Arg();
+ }
+
+ // Checks if manual indexing is used and returns the argument with
+ // specified index.
+ Arg get_arg(unsigned arg_index, const char *&error) {
+ return check_no_auto_index(error) ? do_get_arg(arg_index, error) : Arg();
+ }
+
+ bool check_no_auto_index(const char *&error) {
+ if (next_arg_index_ > 0) {
+ error = "cannot switch from automatic to manual argument indexing";
+ return false;
+ }
+ next_arg_index_ = -1;
+ return true;
+ }
+
+ template <typename Char>
+ void write(BasicWriter<Char> &w, const Char *start, const Char *end) {
+ if (start != end)
+ w << BasicStringRef<Char>(start, end - start);
+ }
+};
+
+// A printf formatter.
+template <typename Char>
+class PrintfFormatter : private FormatterBase {
+ private:
+ void parse_flags(FormatSpec &spec, const Char *&s);
+
+ // Returns the argument with specified index or, if arg_index is equal
+ // to the maximum unsigned value, the next argument.
+ Arg get_arg(const Char *s,
+ unsigned arg_index = (std::numeric_limits<unsigned>::max)());
+
+ // Parses argument index, flags and width and returns the argument index.
+ unsigned parse_header(const Char *&s, FormatSpec &spec);
+
+ public:
+ explicit PrintfFormatter(const ArgList &args) : FormatterBase(args) {}
+ void format(BasicWriter<Char> &writer, BasicCStringRef<Char> format_str);
+};
+} // namespace internal
+
+// A formatter.
+template <typename CharType>
+class BasicFormatter : private internal::FormatterBase {
+ public:
+ typedef CharType Char;
+
+ private:
+ BasicWriter<Char> &writer_;
+ internal::ArgMap<Char> map_;
+
+ FMT_DISALLOW_COPY_AND_ASSIGN(BasicFormatter);
+
+ using internal::FormatterBase::get_arg;
+
+ // Checks if manual indexing is used and returns the argument with
+ // specified name.
+ internal::Arg get_arg(BasicStringRef<Char> arg_name, const char *&error);
+
+ // Parses argument index and returns corresponding argument.
+ internal::Arg parse_arg_index(const Char *&s);
+
+ // Parses argument name and returns corresponding argument.
+ internal::Arg parse_arg_name(const Char *&s);
+
+ public:
+ BasicFormatter(const ArgList &args, BasicWriter<Char> &w)
+ : internal::FormatterBase(args), writer_(w) {}
+
+ BasicWriter<Char> &writer() { return writer_; }
+
+ void format(BasicCStringRef<Char> format_str);
+
+ const Char *format(const Char *&format_str, const internal::Arg &arg);
+};
+
// Generates a comma-separated list with results of applying f to
// numbers 0..n-1.
# define FMT_GEN(n, f) FMT_GEN##n(f)
@@ -1597,7 +1885,9 @@ namespace internal {
inline uint64_t make_type() { return 0; }
template <typename T>
-inline uint64_t make_type(const T &arg) { return MakeValue<char>::type(arg); }
+inline uint64_t make_type(const T &arg) {
+ return MakeValue< BasicFormatter<char> >::type(arg);
+}
template <unsigned N>
struct ArgArray {
@@ -1621,7 +1911,8 @@ inline void do_set_types(Arg *) {}
template <typename T, typename... Args>
inline void do_set_types(Arg *args, const T &arg, const Args & ... tail) {
- args->type = static_cast<Arg::Type>(MakeValue<T>::type(arg));
+ args->type = static_cast<Arg::Type>(
+ MakeValue< BasicFormatter<char> >::type(arg));
do_set_types(args + 1, tail...);
}
@@ -1637,24 +1928,24 @@ inline void set_types(Value *, const Args & ...) {
// Do nothing as types are passed separately from values.
}
-template <typename Char, typename Value>
+template <typename Formatter, typename Value>
inline void store_args(Value *) {}
-template <typename Char, typename Arg, typename T, typename... Args>
+template <typename Formatter, typename Arg, typename T, typename... Args>
inline void store_args(Arg *args, const T &arg, const Args & ... tail) {
// Assign only the Value subobject of Arg and don't overwrite type (if any)
// that is assigned by set_types.
Value &value = *args;
- value = MakeValue<Char>(arg);
- store_args<Char>(args + 1, tail...);
+ value = MakeValue<Formatter>(arg);
+ store_args<Formatter>(args + 1, tail...);
}
-template <typename Char, typename... Args>
+template <typename Formatter, typename... Args>
ArgList make_arg_list(typename ArgArray<sizeof...(Args)>::Type array,
const Args & ... args) {
if (check(sizeof...(Args) >= ArgList::MAX_PACKED_ARGS))
set_types(array, args...);
- store_args<Char>(array, args...);
+ store_args<Formatter>(array, args...);
return ArgList(make_type(args...), array);
}
#else
@@ -1677,13 +1968,47 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) {
(t12.type << 48) | (t13.type << 52) | (t14.type << 56);
}
#endif
+
+template <class Char>
+class FormatBuf : public std::basic_streambuf<Char> {
+ private:
+ typedef typename std::basic_streambuf<Char>::int_type int_type;
+ typedef typename std::basic_streambuf<Char>::traits_type traits_type;
+
+ Buffer<Char> &buffer_;
+ Char *start_;
+
+ public:
+ FormatBuf(Buffer<Char> &buffer) : buffer_(buffer), start_(&buffer[0]) {
+ this->setp(start_, start_ + buffer_.capacity());
+ }
+
+ int_type overflow(int_type ch = traits_type::eof()) {
+ if (!traits_type::eq_int_type(ch, traits_type::eof())) {
+ size_t size = this->pptr() - start_;
+ buffer_.resize(size);
+ buffer_.reserve(size * 2);
+
+ start_ = &buffer_[0];
+ start_[size] = traits_type::to_char_type(ch);
+ this->setp(start_+ size + 1, start_ + size * 2);
+ }
+ return ch;
+ }
+
+ size_t size() const {
+ return this->pptr() - start_;
+ }
+};
} // namespace internal
# define FMT_MAKE_TEMPLATE_ARG(n) typename T##n
# define FMT_MAKE_ARG_TYPE(n) T##n
# define FMT_MAKE_ARG(n) const T##n &v##n
-# define FMT_MAKE_REF_char(n) fmt::internal::MakeValue<char>(v##n)
-# define FMT_MAKE_REF_wchar_t(n) fmt::internal::MakeValue<wchar_t>(v##n)
+# define FMT_ASSIGN_char(n) \
+ arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<char> >(v##n)
+# define FMT_ASSIGN_wchar_t(n) \
+ arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<wchar_t> >(v##n)
#if FMT_USE_VARIADIC_TEMPLATES
// Defines a variadic function returning void.
@@ -1691,7 +2016,8 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) {
template <typename... Args> \
void func(arg_type arg0, const Args & ... args) { \
typename fmt::internal::ArgArray<sizeof...(Args)>::Type array; \
- func(arg0, fmt::internal::make_arg_list<Char>(array, args...)); \
+ func(arg0, fmt::internal::make_arg_list< \
+ fmt::BasicFormatter<Char> >(array, args...)); \
}
// Defines a variadic constructor.
@@ -1699,12 +2025,14 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) {
template <typename... Args> \
ctor(arg0_type arg0, arg1_type arg1, const Args & ... args) { \
typename fmt::internal::ArgArray<sizeof...(Args)>::Type array; \
- func(arg0, arg1, fmt::internal::make_arg_list<Char>(array, args...)); \
+ func(arg0, arg1, fmt::internal::make_arg_list< \
+ fmt::BasicFormatter<Char> >(array, args...)); \
}
#else
-# define FMT_MAKE_REF(n) fmt::internal::MakeValue<Char>(v##n)
+# define FMT_MAKE_REF(n) \
+ fmt::internal::MakeValue< fmt::BasicFormatter<Char> >(v##n)
# define FMT_MAKE_REF2(n) v##n
// Defines a wrapper for a function taking one argument of type arg_type
@@ -1799,7 +2127,7 @@ class SystemError : public internal::RuntimeError {
*error_code* is a system error code as given by ``errno``.
If *error_code* is not a valid error code such as -1, the system message
may look like "Unknown error -1" and is platform-dependent.
-
+
**Example**::
// This throws a SystemError with the description
@@ -1847,7 +2175,7 @@ class BasicWriter {
typedef typename internal::CharTraits<Char>::CharPtr CharPtr;
-#if _SECURE_SCL
+#if FMT_SECURE_SCL
// Returns pointer value.
static Char *get(CharPtr p) { return p.base(); }
#else
@@ -1867,12 +2195,33 @@ class BasicWriter {
return internal::make_ptr(&buffer_[size], n);
}
+ // Writes an unsigned decimal integer.
+ template <typename UInt>
+ Char *write_unsigned_decimal(UInt value, unsigned prefix_size = 0) {
+ unsigned num_digits = internal::count_digits(value);
+ Char *ptr = get(grow_buffer(prefix_size + num_digits));
+ internal::format_decimal(ptr + prefix_size, value, num_digits);
+ return ptr;
+ }
+
+ // Writes a decimal integer.
+ template <typename Int>
+ void write_decimal(Int value) {
+ typename internal::IntTraits<Int>::MainType abs_value = value;
+ if (internal::is_negative(value)) {
+ abs_value = 0 - abs_value;
+ *write_unsigned_decimal(abs_value, 1) = '-';
+ } else {
+ write_unsigned_decimal(abs_value, 0);
+ }
+ }
+
// Prepare a buffer for integer formatting.
CharPtr prepare_int_buffer(unsigned num_digits,
const EmptySpec &, const char *prefix, unsigned prefix_size) {
unsigned size = prefix_size + num_digits;
CharPtr p = grow_buffer(size);
- std::copy(prefix, prefix + prefix_size, p);
+ std::uninitialized_copy(prefix, prefix + prefix_size, p);
return p + size - 1;
}
@@ -1890,12 +2239,11 @@ class BasicWriter {
// Writes a formatted string.
template <typename StrChar>
- CharPtr write_str(
- const StrChar *s, std::size_t size, const AlignSpec &spec);
+ CharPtr write_str(const StrChar *s, std::size_t size, const AlignSpec &spec);
template <typename StrChar>
- void write_str(
- const internal::Arg::StringValue<StrChar> &str, const FormatSpec &spec);
+ void write_str(const internal::Arg::StringValue<StrChar> &str,
+ const FormatSpec &spec);
// This following methods are private to disallow writing wide characters
// and strings to a char stream. If you want to print a wide string as a
@@ -1915,7 +2263,7 @@ class BasicWriter {
void append_float_length(Char *&, T) {}
template <typename Impl, typename Char_>
- friend class internal::BasicArgFormatter;
+ friend class internal::ArgFormatterBase;
friend class internal::PrintfArgFormatter<Char>;
@@ -1967,7 +2315,7 @@ class BasicWriter {
/**
\rst
Writes formatted data.
-
+
*args* is an argument list representing arbitrary arguments.
**Example**::
@@ -1990,24 +2338,27 @@ class BasicWriter {
\endrst
*/
void write(BasicCStringRef<Char> format, ArgList args) {
- BasicFormatter<Char>(*this).format(format, args);
+ BasicFormatter<Char>(args, *this).format(format);
}
FMT_VARIADIC_VOID(write, BasicCStringRef<Char>)
BasicWriter &operator<<(int value) {
- return *this << IntFormatSpec<int>(value);
+ write_decimal(value);
+ return *this;
}
BasicWriter &operator<<(unsigned value) {
return *this << IntFormatSpec<unsigned>(value);
}
BasicWriter &operator<<(long value) {
- return *this << IntFormatSpec<long>(value);
+ write_decimal(value);
+ return *this;
}
BasicWriter &operator<<(unsigned long value) {
return *this << IntFormatSpec<unsigned long>(value);
}
BasicWriter &operator<<(LongLong value) {
- return *this << IntFormatSpec<LongLong>(value);
+ write_decimal(value);
+ return *this;
}
/**
@@ -2093,21 +2444,43 @@ typename BasicWriter<Char>::CharPtr BasicWriter<Char>::write_str(
out = grow_buffer(spec.width());
Char fill = internal::CharTraits<Char>::cast(spec.fill());
if (spec.align() == ALIGN_RIGHT) {
- std::fill_n(out, spec.width() - size, fill);
+ std::uninitialized_fill_n(out, spec.width() - size, fill);
out += spec.width() - size;
} else if (spec.align() == ALIGN_CENTER) {
out = fill_padding(out, spec.width(), size, fill);
} else {
- std::fill_n(out + size, spec.width() - size, fill);
+ std::uninitialized_fill_n(out + size, spec.width() - size, fill);
}
} else {
out = grow_buffer(size);
}
- std::copy(s, s + size, out);
+ std::uninitialized_copy(s, s + size, out);
return out;
}
template <typename Char>
+template <typename StrChar>
+void BasicWriter<Char>::write_str(
+ const internal::Arg::StringValue<StrChar> &s, const FormatSpec &spec) {
+ // Check if StrChar is convertible to Char.
+ internal::CharTraits<Char>::convert(StrChar());
+ if (spec.type_ && spec.type_ != 's')
+ internal::report_unknown_type(spec.type_, "string");
+ const StrChar *str_value = s.value;
+ std::size_t str_size = s.size;
+ if (str_size == 0) {
+ if (!str_value) {
+ FMT_THROW(FormatError("string pointer is null"));
+ return;
+ }
+ }
+ std::size_t precision = spec.precision_;
+ if (spec.precision_ >= 0 && precision < str_size)
+ str_size = spec.precision_;
+ write_str(str_value, str_size, spec);
+}
+
+template <typename Char>
typename BasicWriter<Char>::CharPtr
BasicWriter<Char>::fill_padding(
CharPtr buffer, unsigned total_size,
@@ -2115,10 +2488,11 @@ typename BasicWriter<Char>::CharPtr
std::size_t padding = total_size - content_size;
std::size_t left_padding = padding / 2;
Char fill_char = internal::CharTraits<Char>::cast(fill);
- std::fill_n(buffer, left_padding, fill_char);
+ std::uninitialized_fill_n(buffer, left_padding, fill_char);
buffer += left_padding;
CharPtr content = buffer;
- std::fill_n(buffer + content_size, padding - left_padding, fill_char);
+ std::uninitialized_fill_n(buffer + content_size,
+ padding - left_padding, fill_char);
return content;
}
@@ -2144,42 +2518,42 @@ typename BasicWriter<Char>::CharPtr
unsigned fill_size = width - number_size;
if (align != ALIGN_LEFT) {
CharPtr p = grow_buffer(fill_size);
- std::fill(p, p + fill_size, fill);
+ std::uninitialized_fill(p, p + fill_size, fill);
}
CharPtr result = prepare_int_buffer(
num_digits, subspec, prefix, prefix_size);
if (align == ALIGN_LEFT) {
CharPtr p = grow_buffer(fill_size);
- std::fill(p, p + fill_size, fill);
+ std::uninitialized_fill(p, p + fill_size, fill);
}
return result;
}
unsigned size = prefix_size + num_digits;
if (width <= size) {
CharPtr p = grow_buffer(size);
- std::copy(prefix, prefix + prefix_size, p);
+ std::uninitialized_copy(prefix, prefix + prefix_size, p);
return p + size - 1;
}
CharPtr p = grow_buffer(width);
CharPtr end = p + width;
if (align == ALIGN_LEFT) {
- std::copy(prefix, prefix + prefix_size, p);
+ std::uninitialized_copy(prefix, prefix + prefix_size, p);
p += size;
- std::fill(p, end, fill);
+ std::uninitialized_fill(p, end, fill);
} else if (align == ALIGN_CENTER) {
p = fill_padding(p, width, size, fill);
- std::copy(prefix, prefix + prefix_size, p);
+ std::uninitialized_copy(prefix, prefix + prefix_size, p);
p += size;
} else {
if (align == ALIGN_NUMERIC) {
if (prefix_size != 0) {
- p = std::copy(prefix, prefix + prefix_size, p);
+ p = std::uninitialized_copy(prefix, prefix + prefix_size, p);
size -= prefix_size;
}
} else {
- std::copy(prefix, prefix + prefix_size, end - size);
+ std::uninitialized_copy(prefix, prefix + prefix_size, end - size);
}
- std::fill(p, end - size, fill);
+ std::uninitialized_fill(p, end - size, fill);
p = end;
}
return p - 1;
@@ -2241,7 +2615,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size));
n = abs_value;
do {
- *p-- = '0' + (n & 1);
+ *p-- = static_cast<Char>('0' + (n & 1));
} while ((n >>= 1) != 0);
break;
}
@@ -2256,7 +2630,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size));
n = abs_value;
do {
- *p-- = '0' + (n & 7);
+ *p-- = static_cast<Char>('0' + (n & 7));
} while ((n >>= 3) != 0);
break;
}
@@ -2295,16 +2669,16 @@ void BasicWriter<Char>::write_double(
}
char sign = 0;
- // Use getsign instead of value < 0 because the latter is always
+ // Use isnegative instead of value < 0 because the latter is always
// false for NaN.
- if (internal::getsign(static_cast<double>(value))) {
+ if (internal::FPUtil::isnegative(static_cast<double>(value))) {
sign = '-';
value = -value;
} else if (spec.flag(SIGN_FLAG)) {
sign = spec.flag(PLUS_FLAG) ? '+' : ' ';
}
- if (value != value) {
+ if (internal::FPUtil::isnotanumber(value)) {
// Format NaN ourselves because sprintf's output is not consistent
// across platforms.
std::size_t nan_size = 4;
@@ -2319,7 +2693,7 @@ void BasicWriter<Char>::write_double(
return;
}
- if (internal::isinfinity(value)) {
+ if (internal::FPUtil::isinfinity(value)) {
// Format infinity ourselves because sprintf's output is not consistent
// across platforms.
std::size_t inf_size = 4;
@@ -2337,7 +2711,7 @@ void BasicWriter<Char>::write_double(
std::size_t offset = buffer_.size();
unsigned width = spec.width();
if (sign) {
- buffer_.reserve(buffer_.size() + (std::max)(width, 1u));
+ buffer_.reserve(buffer_.size() + (width > 1u ? width : 1u));
if (width > 0)
--width;
++offset;
@@ -2372,7 +2746,7 @@ void BasicWriter<Char>::write_double(
Char fill = internal::CharTraits<Char>::cast(spec.fill());
for (;;) {
std::size_t buffer_size = buffer_.capacity() - offset;
-#if _MSC_VER
+#ifdef _MSC_VER
// MSVC's vsnprintf_s doesn't work with zero size, so reserve
// space for at least one extra character to make the size non-zero.
// Note that the buffer's capacity will increase by more than 1.
@@ -2399,7 +2773,7 @@ void BasicWriter<Char>::write_double(
spec.width() > static_cast<unsigned>(n)) {
width = spec.width();
CharPtr p = grow_buffer(width);
- std::copy(p, p + n, p + (width - n) / 2);
+ std::memmove(get(p) + (width - n) / 2, get(p), n * sizeof(Char));
fill_padding(p, spec.width(), n, fill);
return;
}
@@ -2492,7 +2866,7 @@ typedef BasicMemoryWriter<wchar_t> WMemoryWriter;
This class template provides operations for formatting and writing data
into a fixed-size array. For writing into a dynamically growing buffer
use :class:`fmt::BasicMemoryWriter`.
-
+
Any write method will throw ``std::runtime_error`` if the output doesn't fit
into the array.
@@ -2539,12 +2913,16 @@ typedef BasicArrayWriter<wchar_t> WArrayWriter;
// Formats a value.
template <typename Char, typename T>
void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value) {
- std::basic_ostringstream<Char> os;
- os << value;
- std::basic_string<Char> str = os.str();
- internal::Arg arg = internal::MakeValue<Char>(str);
- arg.type = static_cast<internal::Arg::Type>(
- internal::MakeValue<Char>::type(str));
+ internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
+
+ internal::FormatBuf<Char> format_buf(buffer);
+ std::basic_ostream<Char> output(&format_buf);
+ output << value;
+
+ BasicStringRef<Char> str(&buffer[0], format_buf.size());
+ typedef internal::MakeValue< BasicFormatter<Char> > MakeValue;
+ internal::Arg arg = MakeValue(str);
+ arg.type = static_cast<internal::Arg::Type>(MakeValue::type(str));
format_str = f.format(format_str, arg);
}
@@ -2606,7 +2984,7 @@ enum Color { BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE };
Formats a string and prints it to stdout using ANSI escape sequences
to specify color (experimental).
Example:
- PrintColored(fmt::RED, "Elapsed time: {0:.2f} seconds") << 1.23;
+ print_colored(fmt::RED, "Elapsed time: {0:.2f} seconds", 1.23);
*/
void print_colored(Color c, CStringRef format, ArgList args);
@@ -2653,20 +3031,9 @@ void print(std::FILE *f, CStringRef format_str, ArgList args);
*/
void print(CStringRef format_str, ArgList args);
-/**
- \rst
- Prints formatted data to the stream *os*.
-
- **Example**::
-
- print(cerr, "Don't {}!", "panic");
- \endrst
- */
-void print(std::ostream &os, CStringRef format_str, ArgList args);
-
template <typename Char>
void printf(BasicWriter<Char> &w, BasicCStringRef<Char> format, ArgList args) {
- internal::PrintfFormatter<Char>().format(w, format, args);
+ internal::PrintfFormatter<Char>(args).format(w, format);
}
/**
@@ -2684,6 +3051,12 @@ inline std::string sprintf(CStringRef format, ArgList args) {
return w.str();
}
+inline std::wstring sprintf(WCStringRef format, ArgList args) {
+ WMemoryWriter w;
+ printf(w, format, args);
+ return w.str();
+}
+
/**
\rst
Prints formatted data to the file *f*.
@@ -2726,7 +3099,7 @@ class FormatInt {
// Integer division is slow so do it for a group of two digits instead
// of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison.
- unsigned index = (value % 100) * 2;
+ unsigned index = static_cast<unsigned>((value % 100) * 2);
value /= 100;
*--buffer_end = internal::Data::DIGITS[index + 1];
*--buffer_end = internal::Data::DIGITS[index];
@@ -2874,7 +3247,8 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED;
const Args & ... args) { \
typename fmt::internal::ArgArray<sizeof...(Args)>::Type array; \
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), \
- fmt::internal::make_arg_list<Char>(array, args...)); \
+ fmt::internal::make_arg_list< \
+ fmt::BasicFormatter<Char> >(array, args...)); \
}
#else
// Defines a wrapper for a function taking __VA_ARGS__ arguments
@@ -2883,7 +3257,8 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED;
template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \
inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__), \
FMT_GEN(n, FMT_MAKE_ARG)) { \
- fmt::internal::ArgArray<n>::Type arr = {FMT_GEN(n, FMT_MAKE_REF_##Char)}; \
+ fmt::internal::ArgArray<n>::Type arr; \
+ FMT_GEN(n, FMT_ASSIGN_##Char); \
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList( \
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \
}
@@ -2969,19 +3344,378 @@ FMT_VARIADIC(std::string, format, CStringRef)
FMT_VARIADIC_W(std::wstring, format, WCStringRef)
FMT_VARIADIC(void, print, CStringRef)
FMT_VARIADIC(void, print, std::FILE *, CStringRef)
-FMT_VARIADIC(void, print, std::ostream &, CStringRef)
+
FMT_VARIADIC(void, print_colored, Color, CStringRef)
FMT_VARIADIC(std::string, sprintf, CStringRef)
+FMT_VARIADIC_W(std::wstring, sprintf, WCStringRef)
FMT_VARIADIC(int, printf, CStringRef)
FMT_VARIADIC(int, fprintf, std::FILE *, CStringRef)
+
+#if FMT_USE_IOSTREAMS
+/**
+ \rst
+ Prints formatted data to the stream *os*.
+
+ **Example**::
+
+ print(cerr, "Don't {}!", "panic");
+ \endrst
+ */
+void print(std::ostream &os, CStringRef format_str, ArgList args);
+FMT_VARIADIC(void, print, std::ostream &, CStringRef)
+#endif
+
+namespace internal {
+template <typename Char>
+inline bool is_name_start(Char c) {
+ return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || '_' == c;
+}
+
+// Parses an unsigned integer advancing s to the end of the parsed input.
+// This function assumes that the first character of s is a digit.
+template <typename Char>
+int parse_nonnegative_int(const Char *&s) {
+ assert('0' <= *s && *s <= '9');
+ unsigned value = 0;
+ do {
+ unsigned new_value = value * 10 + (*s++ - '0');
+ // Check if value wrapped around.
+ if (new_value < value) {
+ value = (std::numeric_limits<unsigned>::max)();
+ break;
+ }
+ value = new_value;
+ } while ('0' <= *s && *s <= '9');
+ // Convert to unsigned to prevent a warning.
+ unsigned max_int = (std::numeric_limits<int>::max)();
+ if (value > max_int)
+ FMT_THROW(FormatError("number is too big"));
+ return value;
+}
+
+inline void require_numeric_argument(const Arg &arg, char spec) {
+ if (arg.type > Arg::LAST_NUMERIC_TYPE) {
+ std::string message =
+ fmt::format("format specifier '{}' requires numeric argument", spec);
+ FMT_THROW(fmt::FormatError(message));
+ }
+}
+
+template <typename Char>
+void check_sign(const Char *&s, const Arg &arg) {
+ char sign = static_cast<char>(*s);
+ require_numeric_argument(arg, sign);
+ if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
+ FMT_THROW(FormatError(fmt::format(
+ "format specifier '{}' requires signed argument", sign)));
+ }
+ ++s;
+}
+} // namespace internal
+
+template <typename Char>
+inline internal::Arg BasicFormatter<Char>::get_arg(
+ BasicStringRef<Char> arg_name, const char *&error) {
+ if (check_no_auto_index(error)) {
+ map_.init(args());
+ const internal::Arg *arg = map_.find(arg_name);
+ if (arg)
+ return *arg;
+ error = "argument not found";
+ }
+ return internal::Arg();
+}
+
+template <typename Char>
+inline internal::Arg BasicFormatter<Char>::parse_arg_index(const Char *&s) {
+ const char *error = 0;
+ internal::Arg arg = *s < '0' || *s > '9' ?
+ next_arg(error) : get_arg(internal::parse_nonnegative_int(s), error);
+ if (error) {
+ FMT_THROW(FormatError(
+ *s != '}' && *s != ':' ? "invalid format string" : error));
+ }
+ return arg;
+}
+
+template <typename Char>
+inline internal::Arg BasicFormatter<Char>::parse_arg_name(const Char *&s) {
+ assert(internal::is_name_start(*s));
+ const Char *start = s;
+ Char c;
+ do {
+ c = *++s;
+ } while (internal::is_name_start(c) || ('0' <= c && c <= '9'));
+ const char *error = 0;
+ internal::Arg arg = get_arg(BasicStringRef<Char>(start, s - start), error);
+ if (error)
+ FMT_THROW(FormatError(error));
+ return arg;
+}
+
+// Should be after FormatSpec
+template <typename Char>
+const Char *BasicFormatter<Char>::format(
+ const Char *&format_str, const internal::Arg &arg) {
+ using internal::Arg;
+ const Char *s = format_str;
+ FormatSpec spec;
+ if (*s == ':') {
+ if (arg.type == Arg::CUSTOM) {
+ arg.custom.format(this, arg.custom.value, &s);
+ return s;
+ }
+ ++s;
+ // Parse fill and alignment.
+ if (Char c = *s) {
+ const Char *p = s + 1;
+ spec.align_ = ALIGN_DEFAULT;
+ do {
+ switch (*p) {
+ case '<':
+ spec.align_ = ALIGN_LEFT;
+ break;
+ case '>':
+ spec.align_ = ALIGN_RIGHT;
+ break;
+ case '=':
+ spec.align_ = ALIGN_NUMERIC;
+ break;
+ case '^':
+ spec.align_ = ALIGN_CENTER;
+ break;
+ }
+ if (spec.align_ != ALIGN_DEFAULT) {
+ if (p != s) {
+ if (c == '}') break;
+ if (c == '{')
+ FMT_THROW(FormatError("invalid fill character '{'"));
+ s += 2;
+ spec.fill_ = c;
+ } else ++s;
+ if (spec.align_ == ALIGN_NUMERIC)
+ require_numeric_argument(arg, '=');
+ break;
+ }
+ } while (--p >= s);
+ }
+
+ // Parse sign.
+ switch (*s) {
+ case '+':
+ check_sign(s, arg);
+ spec.flags_ |= SIGN_FLAG | PLUS_FLAG;
+ break;
+ case '-':
+ check_sign(s, arg);
+ spec.flags_ |= MINUS_FLAG;
+ break;
+ case ' ':
+ check_sign(s, arg);
+ spec.flags_ |= SIGN_FLAG;
+ break;
+ }
+
+ if (*s == '#') {
+ require_numeric_argument(arg, '#');
+ spec.flags_ |= HASH_FLAG;
+ ++s;
+ }
+
+ // Parse zero flag.
+ if (*s == '0') {
+ require_numeric_argument(arg, '0');
+ spec.align_ = ALIGN_NUMERIC;
+ spec.fill_ = '0';
+ ++s;
+ }
+
+ // Parse width.
+ if ('0' <= *s && *s <= '9') {
+ spec.width_ = internal::parse_nonnegative_int(s);
+ } else if (*s == '{') {
+ ++s;
+ Arg width_arg = internal::is_name_start(*s) ?
+ parse_arg_name(s) : parse_arg_index(s);
+ if (*s++ != '}')
+ FMT_THROW(FormatError("invalid format string"));
+ ULongLong value = 0;
+ switch (width_arg.type) {
+ case Arg::INT:
+ if (width_arg.int_value < 0)
+ FMT_THROW(FormatError("negative width"));
+ value = width_arg.int_value;
+ break;
+ case Arg::UINT:
+ value = width_arg.uint_value;
+ break;
+ case Arg::LONG_LONG:
+ if (width_arg.long_long_value < 0)
+ FMT_THROW(FormatError("negative width"));
+ value = width_arg.long_long_value;
+ break;
+ case Arg::ULONG_LONG:
+ value = width_arg.ulong_long_value;
+ break;
+ default:
+ FMT_THROW(FormatError("width is not integer"));
+ }
+ if (value > (std::numeric_limits<int>::max)())
+ FMT_THROW(FormatError("number is too big"));
+ spec.width_ = static_cast<int>(value);
+ }
+
+ // Parse precision.
+ if (*s == '.') {
+ ++s;
+ spec.precision_ = 0;
+ if ('0' <= *s && *s <= '9') {
+ spec.precision_ = internal::parse_nonnegative_int(s);
+ } else if (*s == '{') {
+ ++s;
+ Arg precision_arg = internal::is_name_start(*s) ?
+ parse_arg_name(s) : parse_arg_index(s);
+ if (*s++ != '}')
+ FMT_THROW(FormatError("invalid format string"));
+ ULongLong value = 0;
+ switch (precision_arg.type) {
+ case Arg::INT:
+ if (precision_arg.int_value < 0)
+ FMT_THROW(FormatError("negative precision"));
+ value = precision_arg.int_value;
+ break;
+ case Arg::UINT:
+ value = precision_arg.uint_value;
+ break;
+ case Arg::LONG_LONG:
+ if (precision_arg.long_long_value < 0)
+ FMT_THROW(FormatError("negative precision"));
+ value = precision_arg.long_long_value;
+ break;
+ case Arg::ULONG_LONG:
+ value = precision_arg.ulong_long_value;
+ break;
+ default:
+ FMT_THROW(FormatError("precision is not integer"));
+ }
+ if (value > (std::numeric_limits<int>::max)())
+ FMT_THROW(FormatError("number is too big"));
+ spec.precision_ = static_cast<int>(value);
+ } else {
+ FMT_THROW(FormatError("missing precision specifier"));
+ }
+ if (arg.type <= Arg::LAST_INTEGER_TYPE || arg.type == Arg::POINTER) {
+ FMT_THROW(FormatError(
+ fmt::format("precision not allowed in {} format specifier",
+ arg.type == Arg::POINTER ? "pointer" : "integer")));
+ }
+ }
+
+ // Parse type.
+ if (*s != '}' && *s)
+ spec.type_ = static_cast<char>(*s++);
+ }
+
+ if (*s++ != '}')
+ FMT_THROW(FormatError("missing '}' in format string"));
+
+ // Format argument.
+ internal::BasicArgFormatter<Char>(*this, spec, s - 1).visit(arg);
+ return s;
}
+template <typename Char>
+void BasicFormatter<Char>::format(BasicCStringRef<Char> format_str) {
+ const Char *s = format_str.c_str();
+ const Char *start = s;
+ while (*s) {
+ Char c = *s++;
+ if (c != '{' && c != '}') continue;
+ if (*s == c) {
+ write(writer_, start, s);
+ start = ++s;
+ continue;
+ }
+ if (c == '}')
+ FMT_THROW(FormatError("unmatched '}' in format string"));
+ write(writer_, start, s - 1);
+ internal::Arg arg = internal::is_name_start(*s) ?
+ parse_arg_name(s) : parse_arg_index(s);
+ start = s = format(s, arg);
+ }
+ write(writer_, start, s);
+}
+} // namespace fmt
+
+#if FMT_USE_USER_DEFINED_LITERALS
+namespace fmt {
+namespace internal {
+
+template <typename Char>
+struct UdlFormat {
+ const Char *str;
+
+ template <typename... Args>
+ auto operator()(Args && ... args) const
+ -> decltype(format(str, std::forward<Args>(args)...)) {
+ return format(str, std::forward<Args>(args)...);
+ }
+};
+
+template <typename Char>
+struct UdlArg {
+ const Char *str;
+
+ template <typename T>
+ NamedArg<Char> operator=(T &&value) const {
+ return {str, std::forward<T>(value)};
+ }
+};
+
+} // namespace internal
+
+inline namespace literals {
+
+/**
+ \rst
+ C++11 literal equivalent of :func:`fmt::format`.
+
+ **Example**::
+
+ using namespace fmt::literals;
+ std::string message = "The answer is {}"_format(42);
+ \endrst
+ */
+inline internal::UdlFormat<char>
+operator"" _format(const char *s, std::size_t) { return {s}; }
+inline internal::UdlFormat<wchar_t>
+operator"" _format(const wchar_t *s, std::size_t) { return {s}; }
+
+/**
+ \rst
+ C++11 literal equivalent of :func:`fmt::arg`.
+
+ **Example**::
+
+ using namespace fmt::literals;
+ print("Elapsed time: {s:.2f} seconds", "s"_a=1.23);
+ \endrst
+ */
+inline internal::UdlArg<char>
+operator"" _a(const char *s, std::size_t) { return {s}; }
+inline internal::UdlArg<wchar_t>
+operator"" _a(const wchar_t *s, std::size_t) { return {s}; }
+
+} // inline namespace literals
+} // namespace fmt
+#endif // FMT_USE_USER_DEFINED_LITERALS
+
// Restore warnings.
#if FMT_GCC_VERSION >= 406
# pragma GCC diagnostic pop
#endif
-#ifdef __clang__
+#if defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma clang diagnostic pop
#endif
diff --git a/dep/cppformat/posix.cc b/dep/cppformat/posix.cc
index d36871f43a3..756281a0ebd 100644
--- a/dep/cppformat/posix.cc
+++ b/dep/cppformat/posix.cc
@@ -55,11 +55,14 @@
# ifdef __MINGW32__
# define _SH_DENYNO 0x40
-# undef fileno
# endif
#endif // _WIN32
+#ifdef fileno
+# undef fileno
+#endif
+
namespace {
#ifdef _WIN32
// Return type of read and write functions.
diff --git a/dep/cppformat/posix.h b/dep/cppformat/posix.h
index 722690a8b33..88bcb4f557b 100644
--- a/dep/cppformat/posix.h
+++ b/dep/cppformat/posix.h
@@ -69,7 +69,11 @@
# define FMT_UNUSED
#endif
-#if FMT_USE_STATIC_ASSERT || FMT_HAS_CPP_ATTRIBUTE(cxx_static_assert) || \
+#ifndef FMT_USE_STATIC_ASSERT
+# define FMT_USE_STATIC_ASSERT 0
+#endif
+
+#if FMT_USE_STATIC_ASSERT || FMT_HAS_FEATURE(cxx_static_assert) || \
(FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600
# define FMT_STATIC_ASSERT(cond, message) static_assert(cond, message)
#else
diff --git a/sql/updates/world/2015_12_08_00_world_335.sql b/sql/updates/world/2015_12_08_00_world_335.sql
new file mode 100644
index 00000000000..e742130b1a4
--- /dev/null
+++ b/sql/updates/world/2015_12_08_00_world_335.sql
@@ -0,0 +1,15 @@
+--
+DELETE FROM `gossip_menu_option` WHERE `menu_id` IN (2562) AND `id`=1;
+INSERT INTO `gossip_menu_option` (`menu_id`,`id`,`option_icon`,`option_text`,`OptionBroadcastTextID`,`option_id`,`npc_option_npcflag`,`action_menu_id`,`action_poi_id`,`box_coded`,`box_money`,`box_text`,`BoxBroadcastTextID`) VALUES
+(2562,1,0,"Gubber, I don't know how to fish.",5529,1,1,0,0,0,0,'',0);
+
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=2562;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
+(15,2562,1,0,9,1141,0,0,0,0,'','Show the gossip option if the quest 1141 is taken'),
+(15,2562,1,0,25,7620,0,0,1,0,'','Show the gossip option if Fishing is not learned');
+
+UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry`=10216;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=10216 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
+(10216, 0, 0, 1, 62, 0, 100, 0, 2562, 1, 0, 0, 85, 7733, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Gubber Blump- On Gossip Select - Cast Fishing'),
+(10216, 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, 'Gubber Blump- On Gossip Select - Close gossip');
diff --git a/sql/updates/world/2015_12_08_01_world.sql b/sql/updates/world/2015_12_08_01_world.sql
new file mode 100644
index 00000000000..9e24acd91db
--- /dev/null
+++ b/sql/updates/world/2015_12_08_01_world.sql
@@ -0,0 +1,2 @@
+--
+UPDATE `smart_scripts` SET `event_param2`=7 WHERE `entryorguid` IN (34146, 34150, 34151) AND `source_type`=0 AND `id`=0;
diff --git a/sql/updates/world/2015_12_08_02_world.sql b/sql/updates/world/2015_12_08_02_world.sql
new file mode 100644
index 00000000000..375d0941adb
--- /dev/null
+++ b/sql/updates/world/2015_12_08_02_world.sql
@@ -0,0 +1,6 @@
+-- maexxna cleanup
+DELETE FROM `creature_text` WHERE `entry`=15952;
+INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`probability`,`BroadcastTextId`,`TextRange`,`comment`) VALUES
+(15952,0,0,"Spiderlings appear on the web!",41,100,32305,3,"Maexxna EMOTE_SPIDERS"),
+(15952,1,0,"%s spins her web into a cocoon!",41,100,32303,3,"Maexxna EMOTE_WEB_WRAP"),
+(15952,2,0,"%s sprays strands of web everywhere!",41,100,32304,3,"Maexxna EMOTE_WEB_SPRAY");
diff --git a/sql/updates/world/2015_12_09_00_world.sql b/sql/updates/world/2015_12_09_00_world.sql
new file mode 100644
index 00000000000..6ac4da31404
--- /dev/null
+++ b/sql/updates/world/2015_12_09_00_world.sql
@@ -0,0 +1,3 @@
+--
+UPDATE `smart_scripts` SET `event_param1`=15, `comment`="Short John Mithril - On Waypoint 15 Reached - Say Line 1" WHERE `entryorguid`=14508 AND `source_Type`=0 AND `id` IN (2);
+UPDATE `smart_scripts` SET `event_param1`=15, `comment`="Short John Mithril - On Waypoint 15 Reached - Cast 'Summon Pirate Booty (DND)'" WHERE `entryorguid`=14508 AND `source_Type`=0 AND `id` IN (3);
diff --git a/sql/updates/world/2015_12_09_01_world.sql b/sql/updates/world/2015_12_09_01_world.sql
new file mode 100644
index 00000000000..d27bc7ff49a
--- /dev/null
+++ b/sql/updates/world/2015_12_09_01_world.sql
@@ -0,0 +1,13 @@
+--
+SET @ENTRY := 27131;
+UPDATE `creature_template` SET `AIName`="SmartAI" 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,0,1,0,100,0,10000,15000,10000,15000,5,7,0,0,0,0,0,1,0,0,0,0,0,0,0,"Grizzly Bear - Out of Combat - Play Emote 7");
+
+SET @ENTRY := 2713100;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=9;
+
+DELETE FROM `vehicle_template_accessory` WHERE `entry`=27131;
+INSERT INTO `vehicle_template_accessory` (`entry`,`accessory_entry`,`seat_id`,`minion`,`description`) VALUES
+(27131,27438,0,1, 'Grizzly Bear - Rainbow Trout');
diff --git a/sql/updates/world/2015_12_11_00_world.sql b/sql/updates/world/2015_12_11_00_world.sql
new file mode 100644
index 00000000000..dc5fd8c40b6
--- /dev/null
+++ b/sql/updates/world/2015_12_11_00_world.sql
@@ -0,0 +1,19 @@
+--
+DELETE FROM `smart_scripts` WHERE `entryorguid`=27530 AND `source_type`=0 AND `id`=1;
+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
+(27530,0,1,0,8,0,100,1,49349,0,0,0,41,5000,0,0,0,0,0,1,0,0,0,0,0,0,0,'Ruby Keeper - On Spellhit - Despawn');
+
+DELETE FROM `creature_addon` WHERE `guid` IN (108202,108203,108328,108329, 108330);
+INSERT INTO `creature_addon` (`guid`, `bytes1`, `auras`) VALUES
+(108202,33554432 ,""),(108203,33554432 ,""),(108328,33554432 ,""),(108329,33554432 ,""),(108330,33554432 ,"");
+UPDATE `creature_template` SET `InhabitType`=4 WHERE `entry`=27530;
+UPDATE `creature` SET `MovementType`=1, `spawndist`=10 WHERE `guid` IN (108202,108203,108328,108329, 108330);
+
+SET @GUID := 48254;
+DELETE FROM `creature` WHERE `guid` IN (@GUID,@GUID+1,@GUID+2,@GUID+3);
+INSERT INTO `creature` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`modelid`,`equipment_id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`currentwaypoint`,`curhealth`,`curmana`,`MovementType`, `unit_flags`, `dynamicflags`) VALUES
+(@GUID,27530,571,1,1,24137,0,3690.58, 1034.33, 55.7121, 1.43117,300,0,0,102820,0,0,537133568,32),
+(@GUID+1,27530,571,1,1,24137,0,3690.58, 1034.33, 55.7121, 1.43117,300,0,0,102820,0,0,537133568,32),
+(@GUID+2,27530,571,1,1,24137,0,3722.78, 872.282, 56.4471, 3.56587,300,0,0,102820,0,0,537133568,32),
+(@GUID+3,27530,571,1,1,24137,0,3678.09, 938.621, 57.2201, 1.50971,300,0,0,102820,0,0,537133568,32);
+UPDATE `creature` SET `unit_flags`=537133568 WHERE `id`=27530 AND `dynamicflags`=32;
diff --git a/sql/updates/world/2015_12_14_00_world.sql b/sql/updates/world/2015_12_14_00_world.sql
new file mode 100644
index 00000000000..85faf4448e2
--- /dev/null
+++ b/sql/updates/world/2015_12_14_00_world.sql
@@ -0,0 +1,32 @@
+-- instructor razuvious cleanup
+DELETE FROM `creature_text` WHERE `entry`=16061;
+INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`probability`,`sound`,`BroadcastTextId`,`TextRange`,`comment`) VALUES
+(16061,0,0,"Do as I taught you!",14,100,8855,13075,3,"Razuvious SAY_AGGRO #1"),
+(16061,0,1,"The time for practice is over! Show me what you have learned!",14,100,8859,13078,3,"Razuvious SAY_AGGRO #2"),
+(16061,0,2,"Show them no mercy!",14,100,8856,13076,3,"Razuvious SAY_AGGRO #3"),
+(16061,1,0,"%s lets loose a triumphant shout.",41,30,0,13082,3,"Razuvious SAY_SLAY"),
+(16061,2,0,"You should have stayed home.",14,50,8861,13081,3,"Razuvious SAY_TAUNTED #1"),
+(16061,2,1,"You disappoint me, students!",14,50,8858,13077,3,"Razuvious SAY_TAUNTED #2"),
+(16061,2,2,"I'm just getting warmed up!",14,50,8852,13072,3,"Razuvious SAY_TAUNTED #3"),
+(16061,2,3,"Stand and fight!",14,50,8853,13073,3,"Razuvious SAY_TAUNTED #4"),
+(16061,2,4,"Sweep the leg... Do you have a problem with that?",14,50,8861,13080,3,"Razuvious SAY_TAUNTED #5"),
+(16061,3,0,"An honorable... death.",14,100,8860,13079,3,"Razuvious SAY_DEATH");
+
+-- move understudies to summon groups for proper reset behavior
+DELETE FROM `creature` WHERE `guid` IN (128184,128185);
+DELETE FROM `linked_respawn` WHERE `guid` IN (128184,128185);
+DELETE FROM `creature_summon_groups` WHERE `summonerId`=16061 AND `summonerType`=0;
+INSERT INTO `creature_summon_groups` (`summonerId`,`summonerType`,`groupId`,`entry`,`position_x`,`position_y`,`position_z`,`orientation`,`summonType`) VALUES
+(16061,0,1,16803,2757.476,-3111.519,267.7678,3.926991,8),
+(16061,0,1,16803,2762.049,-3084.467,267.7678,2.129302,8),
+(16061,0,2,16803,2778.911,-3114.142,267.7678,5.288348,8),
+(16061,0,2,16803,2781.866,-3088.187,267.7678,0.9075712,8);
+
+-- "Hopeless" debuff on death may only target understudies
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry`=29125;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`NegativeCondition`,`Comment`) VALUES
+(13,1,29125,31,0,3,16803,0,"Instructor Razuvious - Hopeless debuff - only target Death Knight Understudy");
+
+-- transition understudies to scripted AI to prevent them overriding player control
+UPDATE `creature_template` SET `AIName`="",`ScriptName`="npc_dk_understudy" WHERE `entry`=16803;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=16803 AND `source_type`=0;
diff --git a/sql/updates/world/2015_12_15_00_world.sql b/sql/updates/world/2015_12_15_00_world.sql
new file mode 100644
index 00000000000..f27bb448bbd
--- /dev/null
+++ b/sql/updates/world/2015_12_15_00_world.sql
@@ -0,0 +1,2 @@
+--
+DELETE FROM `creature` WHERE `guid` IN (111277, 111300);
diff --git a/sql/updates/world/2015_12_15_01_world.sql b/sql/updates/world/2015_12_15_01_world.sql
new file mode 100644
index 00000000000..86fbec83c38
--- /dev/null
+++ b/sql/updates/world/2015_12_15_01_world.sql
@@ -0,0 +1,2 @@
+-- trinity_string 2022 (ticket message)
+UPDATE `trinity_string` SET `content_default`='|cff00ff00Ticket Message|r: [%s]|r ' WHERE `entry`=2022;
diff --git a/sql/updates/world/2015_12_15_02_world.sql b/sql/updates/world/2015_12_15_02_world.sql
new file mode 100644
index 00000000000..eda5c26550f
--- /dev/null
+++ b/sql/updates/world/2015_12_15_02_world.sql
@@ -0,0 +1,22 @@
+--
+UPDATE `creature_text` SET `sound`=14211 WHERE `BroadcastTextID`=25357;
+UPDATE `creature_text` SET `sound`=14212 WHERE `BroadcastTextID`=25358;
+UPDATE `creature_text` SET `sound`=14756 WHERE `BroadcastTextID`=25362;
+UPDATE `creature_text` SET `sound`=14212 WHERE `BroadcastTextID`=28189;
+UPDATE `creature_text` SET `sound`=14664 WHERE `BroadcastTextID`=25359;
+UPDATE `creature_text` SET `sound`=14665 WHERE `BroadcastTextID`=25360;
+UPDATE `creature_text` SET `sound`=14757 WHERE `BroadcastTextID`=25363;
+UPDATE `creature_text` SET `sound`=14666 WHERE `BroadcastTextID`=25366;
+UPDATE `creature_text` SET `sound`=14213 WHERE `BroadcastTextID`=25361;
+UPDATE `creature_text` SET `sound`=14758 WHERE `BroadcastTextID`=25364;
+UPDATE `creature_text` SET `sound`=14214 WHERE `BroadcastTextID`=25365;
+UPDATE `creature_text` SET `sound`=14196 WHERE `BroadcastTextID`=25841;
+UPDATE `creature_text` SET `sound`=14489 WHERE `BroadcastTextID`=25842;
+UPDATE `creature_text` SET `sound`=14197 WHERE `BroadcastTextID`=25847;
+UPDATE `creature_text` SET `sound`=14667 WHERE `BroadcastTextID`=25844;
+UPDATE `creature_text` SET `sound`=14490 WHERE `BroadcastTextID`=25843;
+UPDATE `creature_text` SET `sound`=14668 WHERE `BroadcastTextID`=25845;
+UPDATE `creature_text` SET `sound`=14491 WHERE `BroadcastTextID`=25848;
+UPDATE `creature_text` SET `sound`=14669 WHERE `BroadcastTextID`=25846;
+UPDATE `creature_text` SET `sound`=14492 WHERE `BroadcastTextID`=25849;
+UPDATE `creature_text` SET `sound`=14670 WHERE `BroadcastTextID`=25850;
diff --git a/sql/updates/world/2015_12_15_03_world.sql b/sql/updates/world/2015_12_15_03_world.sql
new file mode 100644
index 00000000000..99cc9e14646
--- /dev/null
+++ b/sql/updates/world/2015_12_15_03_world.sql
@@ -0,0 +1,5 @@
+DELETE FROM `areatrigger_scripts` WHERE `entry` IN (5732 /*entrance Lord Marrowgar*/, 5708/*Blood Prince Council*/, 5709 /*entrance Lady Deathwhisper*/);
+INSERT INTO `areatrigger_scripts` (`entry`, `ScriptName`) VALUES
+(5732, 'at_lord_marrowgar_entrance'),
+(5708, 'at_blood_prince_council_start_intro'),
+(5709, 'at_lady_deathwhisper_entrance');
diff --git a/sql/updates/world/2015_12_16_00_world.sql b/sql/updates/world/2015_12_16_00_world.sql
new file mode 100644
index 00000000000..62d640117f7
--- /dev/null
+++ b/sql/updates/world/2015_12_16_00_world.sql
@@ -0,0 +1,91 @@
+--
+-- Sulaa Waypointscript
+UPDATE `creature` SET spawndist = 0, MovementType = 0 WHERE guid = 61958;
+UPDATE `creature_template_addon` SET bytes1 = 0 WHERE Entry = 17219;
+
+-- Sulaa SAI
+SET @ENTRY := 17219;
+UPDATE `creature_template` SET `AIName`="SmartAI" 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,0,25,0,100,0,0,0,0,0,53,0,17219,1,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Reset - Start Waypoint"),
+(@ENTRY,0,1,0,64,0,100,0,0,0,0,0,54,20000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Gossip Hello - Pause Waypoint"),
+(@ENTRY,0,2,0,40,0,100,0,1,17219,0,0,80,@ENTRY*100+00,2,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Waypoint 1 Reached - Run Script"),
+(@ENTRY,0,3,0,40,0,100,0,4,17219,0,0,80,@ENTRY*100+01,2,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Waypoint 4 Reached - Run Script"),
+(@ENTRY,0,4,0,40,0,100,0,8,17219,0,0,80,@ENTRY*100+02,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Waypoint 8 Reached - Pause Waypoint"),
+(@ENTRY,0,5,0,40,0,100,0,12,17219,0,0,80,@ENTRY*100+03,2,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Waypoint 12 Reached - Run Script");
+
+-- Actionlist SAI
+SET @ENTRY := 1721900;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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
+(@ENTRY,9,0,0,0,0,100,0,0,0,0,0,54,300000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Pause Waypoint"),
+(@ENTRY,9,1,0,0,0,100,0,2000,2000,0,0,11,32992,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Cast 'Ice Cast Visual'"),
+(@ENTRY,9,2,0,0,0,100,0,5000,5000,0,0,45,1,1,0,0,0,0,10,67179,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,3,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67176,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,4,0,0,0,100,0,2000,2000,0,0,5,4,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Play Emote 4"),
+(@ENTRY,9,5,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67175,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,6,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67180,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,7,0,0,0,100,0,2000,2000,0,0,45,1,1,0,0,0,0,10,67173,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,8,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67178,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1");
+
+-- Actionlist SAI
+SET @ENTRY := 1721901;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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
+(@ENTRY,9,0,0,0,0,100,0,0,0,0,0,54,8000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Pause Waypoint"),
+(@ENTRY,9,1,0,0,0,100,0,2000,2000,0,0,11,32992,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Cast 'Ice Cast Visual'"),
+(@ENTRY,9,2,0,0,0,100,0,5000,5000,0,0,45,1,1,0,0,0,0,10,67179,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,3,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67181,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1"),
+(@ENTRY,9,4,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67182,18814,0,0,0,0,0,"Sulaa - On Script - Set Data 1 1");
+
+-- Actionlist SAI
+SET @ENTRY := 1721902;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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
+(@ENTRY,9,0,0,0,0,100,0,0,0,0,0,54,8000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Pause Waypoint"),
+(@ENTRY,9,1,0,0,0,100,0,2000,2000,0,0,11,32992,0,0,0,0,0,1,0,0,0,0,0,0,0,"On Script - Cast 'Ice Cast Visual'"),
+(@ENTRY,9,2,0,0,0,100,0,5000,5000,0,0,45,1,1,0,0,0,0,10,67176,18814,0,0,0,0,0,"On Script - Set Data 1 1"),
+(@ENTRY,9,3,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67171,18814,0,0,0,0,0,"On Script - Set Data 1 1"),
+(@ENTRY,9,4,0,0,0,100,0,0,0,0,0,45,1,1,0,0,0,0,10,67172,18814,0,0,0,0,0,"On Script - Set Data 1 1");
+
+-- Actionlist SAI
+SET @ENTRY := 1721903;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY 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
+(@ENTRY,9,0,0,0,0,100,0,0,0,0,0,54,12000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Pause Waypoint"),
+(@ENTRY,9,1,0,0,0,100,0,3000,3000,0,0,90,8,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Set Flag Standstate Kneel"),
+(@ENTRY,9,2,0,0,0,100,0,7000,7000,0,0,91,8,0,0,0,0,0,1,0,0,0,0,0,0,0,"Sulaa - On Script - Remove Flag Standstate Kneel");
+
+
+DELETE FROM `waypoints` WHERE `entry`=17219;
+INSERT INTO `waypoints` (`entry`, `pointid`, `position_x`, `position_y`, `position_z`, `point_comment`) VALUES
+(17219,1,-3778.78,-11409.2,-137.952, 'Sulaa'),
+(17219,2,-3778.9,-11411.9,-137.96, 'Sulaa'),
+(17219,3,-3779.4,-11415.4,-137.982, 'Sulaa'),
+(17219,4,-3775.53,-11420.1,-137.955, 'Sulaa'),
+(17219,5,-3777.94,-11421.6,-137.988, 'Sulaa'),
+(17219,6,-3781.69,-11422.3,-138.036, 'Sulaa'),
+(17219,7,-3788.19,-11418.6,-138.097, 'Sulaa'),
+(17219,8,-3789.85,-11414.1,-138.101, 'Sulaa'),
+(17219,9,-3788.37,-11413.7,-138.081, 'Sulaa'),
+(17219,10,-3783.87,-11414.4,-138.031, 'Sulaa'),
+(17219,11,-3779.87,-11410.7,-137.97, 'Sulaa'),
+(17219,12,-3777.9,-11407.2,-137.934, 'Sulaa');
+
+-- Exodar Invisible Stalker SAI
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=18814;
+DELETE FROM `smart_scripts` WHERE `entryorguid` IN (-67179, -67176, -67175, -67180, -67173, -67178, -67181, -67182, -67171, -67172) 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
+(-67179,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67176,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67175,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67180,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67173,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67178,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67181,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67182,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67171,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'"),
+(-67172,0,0,0,38,0,100,0,1,1,0,0,11,32995,0,0,0,0,0,1,0,0,0,0,0,0,0,"Exodar Invisible Stalker - On Data Set 1 1 - Cast 'Water Elemental Impact Visual'");
+
+UPDATE `creature_template` SET `InhabitType`=4 WHERE `entry`=17436;
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 768def2ff4d..20d30704c13 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -83,12 +83,23 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32
float multiplier = CalculatePct(float(entry->depositPercent), 3);
uint32 timeHr = (((time / 60) / 60) / 12);
- uint32 deposit = uint32(((multiplier * MSV * count / 3) * timeHr * 3) * sWorld->getRate(RATE_AUCTION_DEPOSIT));
+ uint32 deposit = uint32(MSV * multiplier * sWorld->getRate(RATE_AUCTION_DEPOSIT));
+ float remainderbase = float(MSV * multiplier * sWorld->getRate(RATE_AUCTION_DEPOSIT)) - deposit;
+
+ deposit *= timeHr * count;
+
+ int i = count;
+ while (i > 0 && (remainderbase * i) != uint32(remainderbase * i))
+ i--;
+
+ if (i)
+ deposit += remainderbase * i * timeHr;
TC_LOG_DEBUG("auctionHouse", "MSV: %u", MSV);
TC_LOG_DEBUG("auctionHouse", "Items: %u", count);
TC_LOG_DEBUG("auctionHouse", "Multiplier: %f", multiplier);
TC_LOG_DEBUG("auctionHouse", "Deposit: %u", deposit);
+ TC_LOG_DEBUG("auctionHouse", "Deposit rm: %f", remainderbase * count);
if (deposit < AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT))
return AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT);
@@ -389,6 +400,116 @@ bool AuctionHouseMgr::RemoveAItem(ObjectGuid::LowType id, bool deleteItem)
return true;
}
+void AuctionHouseMgr::PendingAuctionAdd(Player* player, AuctionEntry* aEntry)
+{
+ PlayerAuctions* thisAH;
+ auto itr = pendingAuctionMap.find(player->GetGUID());
+ if (itr != pendingAuctionMap.end())
+ thisAH = itr->second.first;
+ else
+ {
+ thisAH = new PlayerAuctions;
+ pendingAuctionMap[player->GetGUID()] = AuctionPair(thisAH, 0);
+ }
+ thisAH->push_back(aEntry);
+}
+
+uint32 AuctionHouseMgr::PendingAuctionCount(const Player* player) const
+{
+ auto const itr = pendingAuctionMap.find(player->GetGUID());
+ if (itr != pendingAuctionMap.end())
+ return itr->second.first->size();
+
+ return 0;
+}
+
+void AuctionHouseMgr::PendingAuctionProcess(Player* player)
+{
+ auto iterMap = pendingAuctionMap.find(player->GetGUID());
+ if (iterMap == pendingAuctionMap.end())
+ return;
+
+ PlayerAuctions* thisAH = iterMap->second.first;
+
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
+
+ uint32 totalItems = 0;
+ for (auto itrAH = thisAH->begin(); itrAH != thisAH->end(); ++itrAH)
+ {
+ AuctionEntry* AH = (*itrAH);
+ totalItems += AH->itemCount;
+ }
+
+ uint32 totaldeposit = 0;
+ auto itr = (*thisAH->begin());
+
+ if (Item* item = GetAItem(itr->itemGUIDLow))
+ totaldeposit = GetAuctionDeposit(itr->auctionHouseEntry, itr->etime, item, totalItems);
+
+ uint32 depositremain = totaldeposit;
+ for (auto itr = thisAH->begin(); itr != thisAH->end(); ++itr)
+ {
+ AuctionEntry* AH = (*itr);
+
+ if (next(itr) == thisAH->end())
+ AH->deposit = depositremain;
+ else
+ {
+ AH->deposit = totaldeposit / thisAH->size();
+ depositremain -= AH->deposit;
+ }
+
+ AH->DeleteFromDB(trans);
+ AH->SaveToDB(trans);
+ }
+
+ CharacterDatabase.CommitTransaction(trans);
+ pendingAuctionMap.erase(player->GetGUID());
+ delete thisAH;
+ player->ModifyMoney(-int32(totaldeposit));
+}
+
+void AuctionHouseMgr::UpdatePendingAuctions()
+{
+ for (auto itr = pendingAuctionMap.begin(); itr != pendingAuctionMap.end();)
+ {
+ ObjectGuid playerGUID = itr->first;
+ if (Player* player = ObjectAccessor::FindConnectedPlayer(playerGUID))
+ {
+ // Check if there were auctions since last update process if not
+ if (PendingAuctionCount(player) == itr->second.second)
+ {
+ ++itr;
+ PendingAuctionProcess(player);
+ }
+ else
+ {
+ ++itr;
+ pendingAuctionMap[playerGUID].second = PendingAuctionCount(player);
+ }
+ }
+ else
+ {
+ // Expire any auctions that we couldn't get a deposit for
+ TC_LOG_WARN("auctionHouse", "Player %s was offline, unable to retrieve deposit!", playerGUID.ToString().c_str());
+ PlayerAuctions* thisAH = itr->second.first;
+ ++itr;
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
+ for (auto AHitr = thisAH->begin(); AHitr != thisAH->end();)
+ {
+ AuctionEntry* AH = (*AHitr);
+ ++AHitr;
+ AH->expire_time = time(NULL);
+ AH->DeleteFromDB(trans);
+ AH->SaveToDB(trans);
+ }
+ CharacterDatabase.CommitTransaction(trans);
+ pendingAuctionMap.erase(playerGUID);
+ delete thisAH;
+ }
+ }
+}
+
void AuctionHouseMgr::Update()
{
mHordeAuctions.Update();
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h
index 45cdba361f3..1f885837a44 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.h
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h
@@ -22,6 +22,7 @@
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCStructure.h"
+#include <set>
class Item;
class Player;
@@ -82,6 +83,7 @@ struct AuctionEntry
time_t expire_time;
ObjectGuid::LowType bidder;
uint32 deposit; //deposit can be calculated only when creating auction
+ uint32 etime;
AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc
// helpers
@@ -151,6 +153,8 @@ class AuctionHouseMgr
}
typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap;
+ typedef std::vector<AuctionEntry*> PlayerAuctions;
+ typedef std::pair<PlayerAuctions*, uint32> AuctionPair;
AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId);
AuctionHouseObject* GetAuctionsMapByHouseId(uint8 auctionHouseId);
@@ -184,7 +188,10 @@ class AuctionHouseMgr
void AddAItem(Item* it);
bool RemoveAItem(ObjectGuid::LowType id, bool deleteItem = false);
-
+ void PendingAuctionAdd(Player* player, AuctionEntry* aEntry);
+ uint32 PendingAuctionCount(const Player* player) const;
+ void PendingAuctionProcess(Player* player);
+ void UpdatePendingAuctions();
void Update();
private:
@@ -193,6 +200,8 @@ class AuctionHouseMgr
AuctionHouseObject mAllianceAuctions;
AuctionHouseObject mNeutralAuctions;
+ std::map<ObjectGuid, AuctionPair> pendingAuctionMap;
+
ItemMap mAitems;
};
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index dc4ad55d9c2..a419864a194 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -809,7 +809,7 @@ struct CreatureModelDataEntry
{
uint32 Id;
uint32 Flags;
- //char* ModelPath[16]
+ char* ModelPath;
//uint32 Unk1;
float Scale; // Used in calculation of unit collision data
//int32 Unk2
diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h
index c75c0fff625..e81db5924f6 100644
--- a/src/server/game/DataStores/DBCfmt.h
+++ b/src/server/game/DataStores/DBCfmt.h
@@ -42,7 +42,7 @@ char const CinematicSequencesEntryfmt[] = "nxxxxxxxxx";
char const CreatureDisplayInfofmt[] = "nixifxxxxxxxxxxx";
char const CreatureDisplayInfoExtrafmt[] = "diixxxxxxxxxxxxxxxxxx";
char const CreatureFamilyfmt[] = "nfifiiiiixssssssssssssssssxx";
-char const CreatureModelDatafmt[] = "nixxfxxxxxxxxxxffxxxxxxxxxxx";
+char const CreatureModelDatafmt[] = "nisxfxxxxxxxxxxffxxxxxxxxxxx";
char const CreatureSpellDatafmt[] = "niiiixxxx";
char const CreatureTypefmt[] = "nxxxxxxxxxxxxxxxxxx";
char const CurrencyTypesfmt[] = "xnxi";
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index ea10ce7988b..6ba8fb44e09 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -103,6 +103,48 @@ uint32 CreatureTemplate::GetFirstValidModelId() const
return 0;
}
+uint32 CreatureTemplate::GetFirstInvisibleModel() const
+{
+ CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid1);
+ if (modelInfo && modelInfo->is_trigger)
+ return Modelid1;
+
+ modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid2);
+ if (modelInfo && modelInfo->is_trigger)
+ return Modelid2;
+
+ modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid3);
+ if (modelInfo && modelInfo->is_trigger)
+ return Modelid3;
+
+ modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid4);
+ if (modelInfo && modelInfo->is_trigger)
+ return Modelid4;
+
+ return 11686;
+}
+
+uint32 CreatureTemplate::GetFirstVisibleModel() const
+{
+ CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid1);
+ if (modelInfo && !modelInfo->is_trigger)
+ return Modelid1;
+
+ modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid2);
+ if (modelInfo && !modelInfo->is_trigger)
+ return Modelid2;
+
+ modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid3);
+ if (modelInfo && !modelInfo->is_trigger)
+ return Modelid3;
+
+ modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid4);
+ if (modelInfo && !modelInfo->is_trigger)
+ return Modelid4;
+
+ return 17519;
+}
+
bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
if (Unit* victim = ObjectAccessor::GetUnit(m_owner, m_victim))
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 9a41c8570ed..966944e099f 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -137,6 +137,8 @@ struct CreatureTemplate
uint32 ScriptID;
uint32 GetRandomValidModelId() const;
uint32 GetFirstValidModelId() const;
+ uint32 GetFirstInvisibleModel() const;
+ uint32 GetFirstVisibleModel() const;
// helpers
SkillType GetRequiredLootSkill() const
@@ -278,6 +280,7 @@ struct CreatureModelInfo
float combat_reach;
uint8 gender;
uint32 modelid_other_gender;
+ bool is_trigger;
};
// Benchmarked: Faster than std::map (insert/find)
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 58a9626776b..ceab7d06c96 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -1535,6 +1535,7 @@ void Player::Update(uint32 p_time)
//because we don't want player's ghost teleported from graveyard
if (IsHasDelayedTeleport() && IsAlive())
TeleportTo(m_teleport_dest, m_teleport_options);
+
}
void Player::setDeathState(DeathState s)
@@ -2149,6 +2150,17 @@ void Player::RemoveFromWorld()
}
}
+bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
+{
+ // players are immune to taunt (the aura and the spell effect)
+ if (spellInfo->Effects[index].IsAura(SPELL_AURA_MOD_TAUNT))
+ return true;
+ if (spellInfo->Effects[index].IsEffect(SPELL_EFFECT_ATTACK_ME))
+ return true;
+
+ return Unit::IsImmunedToSpellEffect(spellInfo, index);
+}
+
void Player::RegenerateAll()
{
//if (m_regenTimer <= 500)
@@ -5825,8 +5837,6 @@ void Player::UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool def
uint8 plevel = getLevel(); // if defense than victim == attacker
uint8 greylevel = Trinity::XP::GetGrayLevel(plevel);
uint8 moblevel = victim->getLevelForTarget(this);
- if (moblevel < greylevel)
- return;
if (moblevel > plevel + 5)
moblevel = plevel + 5;
@@ -13230,36 +13240,25 @@ void Player::TradeCancel(bool sendback)
void Player::UpdateSoulboundTradeItems()
{
- if (m_itemSoulboundTradeable.empty())
- return;
-
// also checks for garbage data
- for (ItemDurationList::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end();)
+ for (GuidUnorderedSet::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end();)
{
- ASSERT(*itr);
- if ((*itr)->GetOwnerGUID() != GetGUID())
- {
- m_itemSoulboundTradeable.erase(itr++);
- continue;
- }
- if ((*itr)->CheckSoulboundTradeExpire())
- {
- m_itemSoulboundTradeable.erase(itr++);
- continue;
- }
- ++itr;
+ Item* item = GetItemByGuid(*itr);
+ if (!item || item->GetOwnerGUID() != GetGUID() || item->CheckSoulboundTradeExpire())
+ itr = m_itemSoulboundTradeable.erase(itr);
+ else
+ ++itr;
}
}
void Player::AddTradeableItem(Item* item)
{
- m_itemSoulboundTradeable.push_back(item);
+ m_itemSoulboundTradeable.insert(item->GetGUID());
}
-/// @todo should never allow an item to be added to m_itemSoulboundTradeable twice
void Player::RemoveTradeableItem(Item* item)
{
- m_itemSoulboundTradeable.remove(item);
+ m_itemSoulboundTradeable.erase(item->GetGUID());
}
void Player::UpdateItemDuration(uint32 time, bool realtimeonly)
@@ -23833,7 +23832,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
// farsight dynobj or puppet may be very far away
UpdateVisibilityOf(target);
- if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
+ if (target->isType(TYPEMASK_UNIT) && target != GetVehicleBase())
((Unit*)target)->AddPlayerToVision(this);
}
else
@@ -23846,7 +23845,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
return;
}
- if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
+ if (target->isType(TYPEMASK_UNIT) && target != GetVehicleBase())
((Unit*)target)->RemovePlayerFromVision(this);
//must immediately set seer back otherwise may crash
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 8057a4ee54d..26944de9770 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1034,6 +1034,8 @@ class Player : public Unit, public GridObject<Player>
static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data);
+ bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
+
void SetInWater(bool apply);
bool IsInWater() const override { return m_isInWater; }
@@ -2392,7 +2394,7 @@ class Player : public Unit, public GridObject<Player>
EnchantDurationList m_enchantDuration;
ItemDurationList m_itemDuration;
- ItemDurationList m_itemSoulboundTradeable;
+ GuidUnorderedSet m_itemSoulboundTradeable;
void ResetTimeSync();
void SendTimeSync();
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 277ead92df7..27f6d5f614d 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -17791,22 +17791,8 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
}
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
- {
if (target->IsGameMaster())
- {
- if (cinfo->Modelid1)
- displayId = cinfo->Modelid1; // Modelid1 is a visible model for gms
- else
- displayId = 17519; // world visible trigger's model
- }
- else
- {
- if (cinfo->Modelid2)
- displayId = cinfo->Modelid2; // Modelid2 is an invisible model for players
- else
- displayId = 11686; // world invisible trigger's model
- }
- }
+ displayId = cinfo->GetFirstVisibleModel();
}
fieldBuffer << uint32(displayId);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index b2be5c49b91..6f5368ed150 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1236,7 +1236,11 @@ uint32 ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData co
if (data && data->displayid)
return data->displayid;
- return cinfo->GetRandomValidModelId();
+ if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER))
+ return cinfo->GetRandomValidModelId();
+
+ // Triggers by default receive the invisible model
+ return cinfo->GetFirstInvisibleModel();
}
void ObjectMgr::ChooseCreatureFlags(const CreatureTemplate* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData* data /*= NULL*/)
@@ -1301,6 +1305,12 @@ void ObjectMgr::LoadCreatureModelInfo()
Field* fields = result->Fetch();
uint32 modelId = fields[0].GetUInt32();
+ CreatureDisplayInfoEntry const* creatureDisplay = sCreatureDisplayInfoStore.LookupEntry(modelId);
+ if (!creatureDisplay)
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for nonexistent display id (%u).", modelId);
+ continue;
+ }
CreatureModelInfo& modelInfo = _creatureModelStore[modelId];
@@ -1308,12 +1318,10 @@ void ObjectMgr::LoadCreatureModelInfo()
modelInfo.combat_reach = fields[2].GetFloat();
modelInfo.gender = fields[3].GetUInt8();
modelInfo.modelid_other_gender = fields[4].GetUInt32();
+ modelInfo.is_trigger = false;
// Checks
- if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
- TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for nonexistent display id (%u).", modelId);
-
if (modelInfo.gender > GENDER_NONE)
{
TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender (%u) for display id (%u).", uint32(modelInfo.gender), modelId);
@@ -1329,6 +1337,9 @@ void ObjectMgr::LoadCreatureModelInfo()
if (modelInfo.combat_reach < 0.1f)
modelInfo.combat_reach = DEFAULT_COMBAT_REACH;
+ if (CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(creatureDisplay->ModelId))
+ modelInfo.is_trigger = strstr(modelData->ModelPath, "InvisibleStalker") != nullptr;
+
++count;
}
while (result->NextRow());
diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp
index 8ecf86680ca..a9680ff69bb 100644
--- a/src/server/game/Handlers/AuctionHouseHandler.cpp
+++ b/src/server/game/Handlers/AuctionHouseHandler.cpp
@@ -303,18 +303,21 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
AH->buyout = buyout;
AH->expire_time = time(NULL) + auctionTime;
AH->deposit = deposit;
+ AH->etime = etime;
AH->auctionHouseEntry = auctionHouseEntry;
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
_player->GetName().c_str(), _player->GetGUID().GetCounter(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUID().GetCounter(), item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
sAuctionMgr->AddAItem(item);
auctionHouse->AddAuction(AH);
+ sAuctionMgr->PendingAuctionAdd(_player, AH);
_player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->DeleteFromInventoryDB(trans);
item->SaveToDB(trans);
+
AH->SaveToDB(trans);
_player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
@@ -351,12 +354,14 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
AH->buyout = buyout;
AH->expire_time = time(NULL) + auctionTime;
AH->deposit = deposit;
+ AH->etime = etime;
AH->auctionHouseEntry = auctionHouseEntry;
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
_player->GetName().c_str(), _player->GetGUID().GetCounter(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUID().GetCounter(), newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
sAuctionMgr->AddAItem(newItem);
auctionHouse->AddAuction(AH);
+ sAuctionMgr->PendingAuctionAdd(_player, AH);
for (uint32 j = 0; j < itemsCount; ++j)
{
@@ -396,8 +401,6 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
}
-
- _player->ModifyMoney(-int32(deposit));
}
//this function is called when client bids or buys out auction
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 2d990ad3ed2..debe4ac3cbf 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -3053,6 +3053,7 @@ void SpellMgr::LoadSpellInfoCorrections()
case 52479: // Gift of the Harvester
case 48246: // Ball of Flame
case 36327: // Shoot Arcane Explosion Arrow
+ case 55479: // Force Obedience
spellInfo->MaxAffectedTargets = 1;
break;
case 36384: // Skartax Purple Beam
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index c41caa8f955..bcfd105f3c6 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1782,6 +1782,7 @@ void World::SetInitialWorldSettings()
m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS);
m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS);
+ m_timers[WUPDATE_AUCTIONS_PENDING].SetInterval(250);
m_timers[WUPDATE_UPTIME].SetInterval(m_int_configs[CONFIG_UPTIME_UPDATE]*MINUTE*IN_MILLISECONDS);
//Update "uptime" table based on configuration entry in minutes.
m_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS);
@@ -2052,6 +2053,13 @@ void World::Update(uint32 diff)
sAuctionMgr->Update();
}
+ if (m_timers[WUPDATE_AUCTIONS_PENDING].Passed())
+ {
+ m_timers[WUPDATE_AUCTIONS_PENDING].Reset();
+
+ sAuctionMgr->UpdatePendingAuctions();
+ }
+
/// <li> Handle AHBot operations
if (m_timers[WUPDATE_AHBOT].Passed())
{
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 133ac3f2386..c76b11276cc 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -69,6 +69,7 @@ enum ShutdownExitCode
enum WorldTimers
{
WUPDATE_AUCTIONS,
+ WUPDATE_AUCTIONS_PENDING,
WUPDATE_WEATHERS,
WUPDATE_UPTIME,
WUPDATE_CORPSES,
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp
index aeaf8a70ba5..cfeb31d5526 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp
@@ -136,11 +136,12 @@ enum Events
enum Actions
{
- ACTION_STAND_UP = 1,
- ACTION_CAST_INVOCATION = 2,
- ACTION_REMOVE_INVOCATION = 3,
- ACTION_KINETIC_BOMB_JUMP = 4,
- ACTION_FLAME_BALL_CHASE = 5,
+ ACTION_START_INTRO = 1,
+ ACTION_STAND_UP = 2,
+ ACTION_CAST_INVOCATION = 3,
+ ACTION_REMOVE_INVOCATION = 4,
+ ACTION_KINETIC_BOMB_JUMP = 5,
+ ACTION_FLAME_BALL_CHASE = 6,
};
enum Points
@@ -162,6 +163,7 @@ class StandUpEvent : public BasicEvent
bool Execute(uint64 /*eventTime*/, uint32 /*diff*/)
{
_owner.HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
+ _owner.SetReactState(REACT_AGGRESSIVE);
return true;
}
@@ -382,8 +384,6 @@ class boss_prince_keleseth_icc : public CreatureScript
if (!me->isDead())
JustRespawned();
-
- me->SetReactState(REACT_DEFENSIVE);
}
void Reset() override
@@ -395,7 +395,6 @@ class boss_prince_keleseth_icc : public CreatureScript
_isEmpowered = false;
me->SetHealth(_spawnHealth);
instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true));
- me->SetReactState(REACT_DEFENSIVE);
}
void EnterCombat(Unit* /*who*/) override
@@ -597,8 +596,6 @@ class boss_prince_taldaram_icc : public CreatureScript
if (!me->isDead())
JustRespawned();
-
- me->SetReactState(REACT_DEFENSIVE);
}
void Reset() override
@@ -610,12 +607,6 @@ class boss_prince_taldaram_icc : public CreatureScript
_isEmpowered = false;
me->SetHealth(_spawnHealth);
instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true));
- me->SetReactState(REACT_DEFENSIVE);
- }
-
- void MoveInLineOfSight(Unit* /*who*/) override
-
- {
}
void EnterCombat(Unit* /*who*/) override
@@ -821,8 +812,6 @@ class boss_prince_valanar_icc : public CreatureScript
if (!me->isDead())
JustRespawned();
-
- me->SetReactState(REACT_DEFENSIVE);
}
void Reset() override
@@ -834,12 +823,6 @@ class boss_prince_valanar_icc : public CreatureScript
_isEmpowered = false;
me->SetHealth(me->GetMaxHealth());
instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true));
- me->SetReactState(REACT_DEFENSIVE);
- }
-
- void MoveInLineOfSight(Unit* /*who*/) override
-
- {
}
void EnterCombat(Unit* /*who*/) override
@@ -905,6 +888,7 @@ class boss_prince_valanar_icc : public CreatureScript
default:
break;
}
+
summons.Summon(summon);
if (me->IsInCombat())
DoZoneInCombat(summon);
@@ -1070,25 +1054,28 @@ class npc_blood_queen_lana_thel : public CreatureScript
me->SetVisible(true);
}
- void MoveInLineOfSight(Unit* who) override
-
+ void DoAction(int32 action) override
{
- if (_introDone)
- return;
-
- if (!me->IsWithinDistInMap(who, 35.0f, false))
- return;
-
- _introDone = true;
- Talk(SAY_INTRO_1);
- _events.SetPhase(1);
- _events.ScheduleEvent(EVENT_INTRO_1, 14000);
- // summon a visual trigger
- if (Creature* summon = DoSummon(NPC_FLOATING_TRIGGER, triggerPos, 15000, TEMPSUMMON_TIMED_DESPAWN))
+ switch (action)
{
- summon->CastSpell(summon, SPELL_OOC_INVOCATION_VISUAL, true);
- summon->SetSpeed(MOVE_FLIGHT, 0.15f, true);
- summon->GetMotionMaster()->MovePoint(0, triggerEndPos);
+ case ACTION_START_INTRO:
+ if (!_introDone)
+ {
+ _introDone = true;
+ Talk(SAY_INTRO_1);
+ _events.SetPhase(1);
+ _events.ScheduleEvent(EVENT_INTRO_1, 14000);
+ // summon a visual trigger
+ if (Creature* summon = DoSummon(NPC_FLOATING_TRIGGER, triggerPos, 15000, TEMPSUMMON_TIMED_DESPAWN))
+ {
+ summon->CastSpell(summon, SPELL_OOC_INVOCATION_VISUAL, true);
+ summon->SetSpeed(MOVE_FLIGHT, 0.15f, true); // todo: creature is swimming, check if this is blizzlike or not.
+ summon->GetMotionMaster()->MovePoint(0, triggerEndPos);
+ }
+ }
+ break;
+ default:
+ break;
}
}
@@ -1328,7 +1315,6 @@ class npc_dark_nucleus : public CreatureScript
}
void MoveInLineOfSight(Unit* who) override
-
{
ScriptedAI::MoveInLineOfSight(who);
}
@@ -1670,6 +1656,21 @@ class spell_blood_council_shadow_prison_damage : public SpellScriptLoader
}
};
+class at_blood_prince_council_start_intro : public AreaTriggerScript
+{
+ public:
+ at_blood_prince_council_start_intro() : AreaTriggerScript("at_blood_prince_council_start_intro") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ if (InstanceScript* instance = player->GetInstanceScript())
+ if (Creature* bloodQueen = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL_COUNCIL)))
+ bloodQueen->AI()->DoAction(ACTION_START_INTRO);
+
+ return true;
+ }
+};
+
void AddSC_boss_blood_prince_council()
{
new boss_blood_council_controller();
@@ -1689,4 +1690,5 @@ void AddSC_boss_blood_prince_council()
new spell_valanar_kinetic_bomb_absorb();
new spell_blood_council_shadow_prison();
new spell_blood_council_shadow_prison_damage();
+ new at_blood_prince_council_start_intro();
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
index 365e0a1588d..54c24769246 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
@@ -268,7 +268,6 @@ class boss_deathbringer_saurfang : public CreatureScript
void Reset() override
{
_Reset();
- me->SetReactState(REACT_DEFENSIVE);
events.SetPhase(PHASE_COMBAT);
Initialize();
me->SetPower(POWER_ENERGY, 0);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
index e3e89d865ff..f76c415ab92 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
@@ -93,7 +93,6 @@ class boss_festergut : public CreatureScript
void Reset() override
{
_Reset();
- me->SetReactState(REACT_DEFENSIVE);
events.ScheduleEvent(EVENT_BERSERK, 300000);
events.ScheduleEvent(EVENT_INHALE_BLIGHT, urand(25000, 30000));
events.ScheduleEvent(EVENT_GAS_SPORE, urand(20000, 25000));
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
index 3a745e2c98c..78a279b94fd 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
@@ -174,6 +174,11 @@ enum DeprogrammingData
POINT_DESPAWN = 384721,
};
+enum Actions
+{
+ ACTION_START_INTRO
+};
+
#define NPC_DARNAVAN RAID_MODE<uint32>(NPC_DARNAVAN_10, NPC_DARNAVAN_25, NPC_DARNAVAN_10, NPC_DARNAVAN_25)
#define NPC_DARNAVAN_CREDIT RAID_MODE<uint32>(NPC_DARNAVAN_CREDIT_10, NPC_DARNAVAN_CREDIT_25, NPC_DARNAVAN_CREDIT_10, NPC_DARNAVAN_CREDIT_25)
#define QUEST_DEPROGRAMMING RAID_MODE<uint32>(QUEST_DEPROGRAMMING_10, QUEST_DEPROGRAMMING_25, QUEST_DEPROGRAMMING_10, QUEST_DEPROGRAMMING_25)
@@ -241,20 +246,26 @@ class boss_lady_deathwhisper : public CreatureScript
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false);
}
- void MoveInLineOfSight(Unit* who) override
-
+ void DoAction(int32 action) override
{
- if (!_introDone && me->IsWithinDistInMap(who, 110.0f))
+ switch (action)
{
- _introDone = true;
- Talk(SAY_INTRO_1);
- events.SetPhase(PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_2, 11000, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_3, 21000, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_4, 31500, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_5, 39500, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_6, 48500, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_7, 58000, 0, PHASE_INTRO);
+ case ACTION_START_INTRO:
+ if (!_introDone)
+ {
+ _introDone = true;
+ Talk(SAY_INTRO_1);
+ events.SetPhase(PHASE_INTRO);
+ events.ScheduleEvent(EVENT_INTRO_2, 11000, 0, PHASE_INTRO);
+ events.ScheduleEvent(EVENT_INTRO_3, 21000, 0, PHASE_INTRO);
+ events.ScheduleEvent(EVENT_INTRO_4, 31500, 0, PHASE_INTRO);
+ events.ScheduleEvent(EVENT_INTRO_5, 39500, 0, PHASE_INTRO);
+ events.ScheduleEvent(EVENT_INTRO_6, 48500, 0, PHASE_INTRO);
+ events.ScheduleEvent(EVENT_INTRO_7, 58000, 0, PHASE_INTRO);
+ }
+ break;
+ default:
+ break;
}
}
@@ -1024,6 +1035,21 @@ class spell_cultist_dark_martyrdom : public SpellScriptLoader
}
};
+class at_lady_deathwhisper_entrance : public AreaTriggerScript
+{
+ public:
+ at_lady_deathwhisper_entrance() : AreaTriggerScript("at_lady_deathwhisper_entrance") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ if (InstanceScript* instance = player->GetInstanceScript())
+ if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_LADY_DEATHWHISPER)))
+ ladyDeathwhisper->AI()->DoAction(ACTION_START_INTRO);
+
+ return true;
+ }
+};
+
void AddSC_boss_lady_deathwhisper()
{
new boss_lady_deathwhisper();
@@ -1033,4 +1059,5 @@ void AddSC_boss_lady_deathwhisper()
new npc_darnavan();
new spell_deathwhisper_mana_barrier();
new spell_cultist_dark_martyrdom();
+ new at_lady_deathwhisper_entrance();
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
index 2fbd1293891..993fc75fcde 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
@@ -89,11 +89,15 @@ enum MiscInfo
//DATA_SPIKE_IMMUNE_1, = 2, // Reserved & used
//DATA_SPIKE_IMMUNE_2, = 3, // Reserved & used
- ACTION_CLEAR_SPIKE_IMMUNITIES = 1,
-
MAX_BONE_SPIKE_IMMUNE = 3,
};
+enum Actions
+{
+ ACTION_CLEAR_SPIKE_IMMUNITIES = 1,
+ ACTION_TALK_ENTER_ZONE = 2
+};
+
class BoneSpikeTargetSelector : public std::unary_function<Unit*, bool>
{
public:
@@ -131,7 +135,6 @@ class boss_lord_marrowgar : public CreatureScript
_boneStormDuration = RAID_MODE<uint32>(20000, 30000, 20000, 30000);
_baseSpeed = creature->GetSpeedRate(MOVE_RUN);
_coldflameLastPos.Relocate(creature);
- _introDone = false;
_boneSlice = false;
}
@@ -146,6 +149,7 @@ class boss_lord_marrowgar : public CreatureScript
events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL);
events.ScheduleEvent(EVENT_WARN_BONE_STORM, urand(45000, 50000));
events.ScheduleEvent(EVENT_ENRAGE, 600000);
+ _introDone = false;
_boneSlice = false;
_boneSpikeImmune.clear();
}
@@ -179,16 +183,6 @@ class boss_lord_marrowgar : public CreatureScript
Talk(SAY_KILL);
}
- void MoveInLineOfSight(Unit* who) override
-
- {
- if (!_introDone && me->IsWithinDistInMap(who, 70.0f))
- {
- Talk(SAY_ENTER_ZONE);
- _introDone = true;
- }
- }
-
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim() || !CheckInRoom())
@@ -324,10 +318,21 @@ class boss_lord_marrowgar : public CreatureScript
void DoAction(int32 action) override
{
- if (action != ACTION_CLEAR_SPIKE_IMMUNITIES)
- return;
-
- _boneSpikeImmune.clear();
+ switch (action)
+ {
+ case ACTION_CLEAR_SPIKE_IMMUNITIES:
+ _boneSpikeImmune.clear();
+ break;
+ case ACTION_TALK_ENTER_ZONE:
+ if (!_introDone)
+ {
+ Talk(SAY_ENTER_ZONE);
+ _introDone = true;
+ }
+ break;
+ default:
+ break;
+ }
}
private:
@@ -742,6 +747,22 @@ class spell_marrowgar_bone_slice : public SpellScriptLoader
}
};
+class at_lord_marrowgar_entrance : public AreaTriggerScript
+{
+ public:
+ at_lord_marrowgar_entrance() : AreaTriggerScript("at_lord_marrowgar_entrance") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ if (InstanceScript* instance = player->GetInstanceScript())
+ if (Creature* lordMarrowgar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_LORD_MARROWGAR)))
+ lordMarrowgar->AI()->DoAction(ACTION_TALK_ENTER_ZONE);
+
+ return true;
+ }
+
+};
+
void AddSC_boss_lord_marrowgar()
{
new boss_lord_marrowgar();
@@ -753,4 +774,5 @@ void AddSC_boss_lord_marrowgar()
new spell_marrowgar_bone_spike_graveyard();
new spell_marrowgar_bone_storm();
new spell_marrowgar_bone_slice();
+ new at_lord_marrowgar_entrance();
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
index be134a06173..4c67c0a7163 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
@@ -236,7 +236,6 @@ class boss_professor_putricide : public CreatureScript
summons.DespawnAll();
SetPhase(PHASE_COMBAT_1);
_experimentState = EXPERIMENT_STATE_OOZE;
- me->SetReactState(REACT_DEFENSIVE);
me->SetWalk(false);
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
me->GetMotionMaster()->MovementExpired();
@@ -616,7 +615,7 @@ class boss_professor_putricide : public CreatureScript
DoCast(me, SPELL_TEAR_GAS_PERIODIC_TRIGGER, true);
break;
case EVENT_RESUME_ATTACK:
- me->SetReactState(REACT_DEFENSIVE);
+ me->SetReactState(REACT_AGGRESSIVE);
AttackStart(me->GetVictim());
// remove Tear Gas
me->RemoveAurasDueToSpell(SPELL_TEAR_GAS_PERIODIC_TRIGGER);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp
index 1a2ebd179fe..d03925f734a 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp
@@ -168,11 +168,6 @@ class boss_rotface : public CreatureScript
Talk(SAY_SLIME_SPRAY);
}
- void MoveInLineOfSight(Unit* /*who*/) override
- {
- // don't enter combat
- }
-
void JustSummoned(Creature* summon) override
{
if (summon->GetEntry() == NPC_VILE_GAS_STALKER)
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
index 65d99b022dc..8917af0038f 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
@@ -234,7 +234,6 @@ class boss_sindragosa : public CreatureScript
void Reset() override
{
BossAI::Reset();
- me->SetReactState(REACT_DEFENSIVE);
DoCast(me, SPELL_TANK_MARKER, true);
events.ScheduleEvent(EVENT_BERSERK, 600000);
events.ScheduleEvent(EVENT_CLEAVE, 10000, EVENT_GROUP_LAND_PHASE);
@@ -659,7 +658,6 @@ class npc_spinestalker : public CreatureScript
_events.ScheduleEvent(EVENT_BELLOWING_ROAR, urand(20000, 25000));
_events.ScheduleEvent(EVENT_CLEAVE_SPINESTALKER, urand(10000, 15000));
_events.ScheduleEvent(EVENT_TAIL_SWEEP, urand(8000, 12000));
- me->SetReactState(REACT_DEFENSIVE);
if (!_summoned)
{
@@ -699,6 +697,7 @@ class npc_spinestalker : public CreatureScript
me->GetMotionMaster()->MoveIdle();
me->StopMoving();
me->GetMotionMaster()->MovePoint(POINT_FROSTWYRM_FLY_IN, SpinestalkerFlyPos);
+ me->SetReactState(REACT_DEFENSIVE);
}
}
@@ -714,6 +713,7 @@ class npc_spinestalker : public CreatureScript
me->SetHomePosition(SpinestalkerLandPos);
me->SetFacingTo(SpinestalkerLandPos.GetOrientation());
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ me->SetReactState(REACT_AGGRESSIVE);
}
void UpdateAI(uint32 diff) override
@@ -794,7 +794,6 @@ class npc_rimefang : public CreatureScript
_events.Reset();
_events.ScheduleEvent(EVENT_FROST_BREATH_RIMEFANG, urand(12000, 15000));
_events.ScheduleEvent(EVENT_ICY_BLAST, urand(30000, 35000));
- me->SetReactState(REACT_DEFENSIVE);
Initialize();
if (!_summoned)
@@ -835,6 +834,7 @@ class npc_rimefang : public CreatureScript
me->GetMotionMaster()->MoveIdle();
me->StopMoving();
me->GetMotionMaster()->MovePoint(POINT_FROSTWYRM_FLY_IN, RimefangFlyPos);
+ me->SetReactState(REACT_DEFENSIVE);
}
}
@@ -850,6 +850,7 @@ class npc_rimefang : public CreatureScript
me->SetHomePosition(RimefangLandPos);
me->SetFacingTo(RimefangLandPos.GetOrientation());
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ me->SetReactState(REACT_AGGRESSIVE);
}
void EnterCombat(Unit* /*victim*/) override
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h
index e739f5a5036..224aa6cda45 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h
+++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h
@@ -72,50 +72,51 @@ enum TeleporterSpells
enum DataTypes
{
// Encounter States/Boss GUIDs
- DATA_LORD_MARROWGAR = 0,
- DATA_LADY_DEATHWHISPER = 1,
- DATA_ICECROWN_GUNSHIP_BATTLE = 2,
- DATA_DEATHBRINGER_SAURFANG = 3,
- DATA_FESTERGUT = 4,
- DATA_ROTFACE = 5,
- DATA_PROFESSOR_PUTRICIDE = 6,
- DATA_BLOOD_PRINCE_COUNCIL = 7,
- DATA_BLOOD_QUEEN_LANA_THEL = 8,
- DATA_SISTER_SVALNA = 9,
- DATA_VALITHRIA_DREAMWALKER = 10,
- DATA_SINDRAGOSA = 11,
- DATA_THE_LICH_KING = 12,
+ DATA_LORD_MARROWGAR = 0,
+ DATA_LADY_DEATHWHISPER = 1,
+ DATA_ICECROWN_GUNSHIP_BATTLE = 2,
+ DATA_DEATHBRINGER_SAURFANG = 3,
+ DATA_FESTERGUT = 4,
+ DATA_ROTFACE = 5,
+ DATA_PROFESSOR_PUTRICIDE = 6,
+ DATA_BLOOD_PRINCE_COUNCIL = 7,
+ DATA_BLOOD_QUEEN_LANA_THEL = 8,
+ DATA_SISTER_SVALNA = 9,
+ DATA_VALITHRIA_DREAMWALKER = 10,
+ DATA_SINDRAGOSA = 11,
+ DATA_THE_LICH_KING = 12,
// Additional data
- DATA_SAURFANG_EVENT_NPC = 13,
- DATA_BONED_ACHIEVEMENT = 14,
- DATA_OOZE_DANCE_ACHIEVEMENT = 15,
- DATA_PUTRICIDE_TABLE = 16,
- DATA_NAUSEA_ACHIEVEMENT = 17,
- DATA_ORB_WHISPERER_ACHIEVEMENT = 18,
- DATA_PRINCE_KELESETH_GUID = 19,
- DATA_PRINCE_TALDARAM_GUID = 20,
- DATA_PRINCE_VALANAR_GUID = 21,
- DATA_BLOOD_PRINCES_CONTROL = 22,
- DATA_SINDRAGOSA_FROSTWYRMS = 23,
- DATA_SPINESTALKER = 24,
- DATA_RIMEFANG = 25,
- DATA_COLDFLAME_JETS = 26,
- DATA_TEAM_IN_INSTANCE = 27,
- DATA_BLOOD_QUICKENING_STATE = 28,
- DATA_HEROIC_ATTEMPTS = 29,
- DATA_CROK_SCOURGEBANE = 30,
- DATA_CAPTAIN_ARNATH = 31,
- DATA_CAPTAIN_BRANDON = 32,
- DATA_CAPTAIN_GRONDEL = 33,
- DATA_CAPTAIN_RUPERT = 34,
- DATA_VALITHRIA_TRIGGER = 35,
- DATA_VALITHRIA_LICH_KING = 36,
- DATA_HIGHLORD_TIRION_FORDRING = 37,
- DATA_ARTHAS_PLATFORM = 38,
- DATA_TERENAS_MENETHIL = 39,
- DATA_ENEMY_GUNSHIP = 40,
- DATA_UPPERSPIRE_TELE_ACT = 41,
+ DATA_SAURFANG_EVENT_NPC = 13,
+ DATA_BONED_ACHIEVEMENT = 14,
+ DATA_OOZE_DANCE_ACHIEVEMENT = 15,
+ DATA_PUTRICIDE_TABLE = 16,
+ DATA_NAUSEA_ACHIEVEMENT = 17,
+ DATA_ORB_WHISPERER_ACHIEVEMENT = 18,
+ DATA_PRINCE_KELESETH_GUID = 19,
+ DATA_PRINCE_TALDARAM_GUID = 20,
+ DATA_PRINCE_VALANAR_GUID = 21,
+ DATA_BLOOD_PRINCES_CONTROL = 22,
+ DATA_SINDRAGOSA_FROSTWYRMS = 23,
+ DATA_SPINESTALKER = 24,
+ DATA_RIMEFANG = 25,
+ DATA_COLDFLAME_JETS = 26,
+ DATA_TEAM_IN_INSTANCE = 27,
+ DATA_BLOOD_QUICKENING_STATE = 28,
+ DATA_HEROIC_ATTEMPTS = 29,
+ DATA_CROK_SCOURGEBANE = 30,
+ DATA_CAPTAIN_ARNATH = 31,
+ DATA_CAPTAIN_BRANDON = 32,
+ DATA_CAPTAIN_GRONDEL = 33,
+ DATA_CAPTAIN_RUPERT = 34,
+ DATA_VALITHRIA_TRIGGER = 35,
+ DATA_VALITHRIA_LICH_KING = 36,
+ DATA_HIGHLORD_TIRION_FORDRING = 37,
+ DATA_ARTHAS_PLATFORM = 38,
+ DATA_TERENAS_MENETHIL = 39,
+ DATA_ENEMY_GUNSHIP = 40,
+ DATA_UPPERSPIRE_TELE_ACT = 41,
+ DATA_BLOOD_QUEEN_LANA_THEL_COUNCIL = 42
};
enum CreaturesIds
@@ -247,6 +248,7 @@ enum CreaturesIds
NPC_KINETIC_BOMB_TARGET = 38458,
NPC_KINETIC_BOMB = 38454,
NPC_SHOCK_VORTEX = 38422,
+ NPC_BLOOD_QUEEN_LANA_THEL_COUNCIL = 38004,
// Blood-Queen Lana'thel
NPC_BLOOD_QUEEN_LANA_THEL = 37955,
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp
index 5354d1772b6..718c0ebe231 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp
@@ -173,6 +173,12 @@ class instance_icecrown_citadel : public InstanceMapScript
switch (creature->GetEntry())
{
+ case NPC_LORD_MARROWGAR:
+ LordMarrowgarGUID = creature->GetGUID();
+ break;
+ case NPC_LADY_DEATHWHISPER:
+ LadyDeahtwhisperGUID = creature->GetGUID();
+ break;
case NPC_KOR_KRON_GENERAL:
if (TeamInInstance == ALLIANCE)
creature->UpdateEntry(NPC_ALLIANCE_COMMANDER);
@@ -249,6 +255,9 @@ class instance_icecrown_citadel : public InstanceMapScript
case NPC_BLOOD_ORB_CONTROLLER:
BloodCouncilControllerGUID = creature->GetGUID();
break;
+ case NPC_BLOOD_QUEEN_LANA_THEL_COUNCIL:
+ BloodQueenLanaThelCouncilGUID = creature->GetGUID();
+ break;
case NPC_BLOOD_QUEEN_LANA_THEL:
BloodQueenLanaThelGUID = creature->GetGUID();
break;
@@ -712,6 +721,10 @@ class instance_icecrown_citadel : public InstanceMapScript
{
switch (type)
{
+ case DATA_LORD_MARROWGAR:
+ return LordMarrowgarGUID;
+ case DATA_LADY_DEATHWHISPER:
+ return LadyDeahtwhisperGUID;
case DATA_ICECROWN_GUNSHIP_BATTLE:
return GunshipGUID;
case DATA_ENEMY_GUNSHIP:
@@ -738,6 +751,8 @@ class instance_icecrown_citadel : public InstanceMapScript
return BloodCouncilGUIDs[2];
case DATA_BLOOD_PRINCES_CONTROL:
return BloodCouncilControllerGUID;
+ case DATA_BLOOD_QUEEN_LANA_THEL_COUNCIL:
+ return BloodQueenLanaThelCouncilGUID;
case DATA_BLOOD_QUEEN_LANA_THEL:
return BloodQueenLanaThelGUID;
case DATA_CROK_SCOURGEBANE:
@@ -1425,6 +1440,8 @@ class instance_icecrown_citadel : public InstanceMapScript
protected:
EventMap Events;
+ ObjectGuid LordMarrowgarGUID;
+ ObjectGuid LadyDeahtwhisperGUID;
ObjectGuid LadyDeathwisperElevatorGUID;
ObjectGuid GunshipGUID;
ObjectGuid EnemyGunshipGUID;
@@ -1452,6 +1469,7 @@ class instance_icecrown_citadel : public InstanceMapScript
ObjectGuid PutricideTableGUID;
ObjectGuid BloodCouncilGUIDs[3];
ObjectGuid BloodCouncilControllerGUID;
+ ObjectGuid BloodQueenLanaThelCouncilGUID;
ObjectGuid BloodQueenLanaThelGUID;
ObjectGuid CrokScourgebaneGUID;
ObjectGuid CrokCaptainGUIDs[4];
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp
index e52731d003e..0d938122f28 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp
@@ -18,6 +18,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "PassiveAI.h"
+#include "SpellScript.h"
#include "naxxramas.h"
enum Spells
@@ -28,6 +29,14 @@ enum Spells
SPELL_NECROTIC_POISON = 28776,
SPELL_FRENZY = 54123
};
+#define SPELL_FRENZY_HELPER RAID_MODE(54123,54124)
+
+enum Emotes
+{
+ EMOTE_SPIDERS = 0,
+ EMOTE_WEB_WRAP = 1,
+ EMOTE_WEB_SPRAY = 2
+};
enum Creatures
{
@@ -35,12 +44,16 @@ enum Creatures
NPC_SPIDERLING = 17055,
};
-#define MAX_POS_WRAP 3
-const Position PosWrap[MAX_POS_WRAP] =
+#define MAX_WRAP_POSITION 7
+const Position WrapPositions[MAX_WRAP_POSITION] =
{
- {3546.796f, -3869.082f, 296.450f, 0.0f},
- {3531.271f, -3847.424f, 299.450f, 0.0f},
- {3497.067f, -3843.384f, 302.384f, 0.0f},
+ {3453.818f, -3854.651f, 308.7581f, 4.362833f},
+ {3535.042f, -3842.383f, 300.795f, 3.179324f},
+ {3538.399f, -3846.088f, 299.964f, 4.310297f},
+ {3548.464f, -3854.676f, 298.6075f, 4.546609f},
+ {3557.663f, -3870.123f, 297.5027f, 3.756433f},
+ {3560.546f, -3879.353f, 297.4843f, 2.508937f},
+ {3562.535f, -3892.507f, 298.532f, 6.022466f},
};
enum Events
@@ -51,7 +64,24 @@ enum Events
EVENT_POISON,
EVENT_WRAP,
EVENT_SUMMON,
- EVENT_FRENZY,
+};
+
+const float WEB_WRAP_MOVE_SPEED = 20.0f;
+
+struct WebTargetSelector : public std::unary_function<Unit*, bool>
+{
+ WebTargetSelector(Unit* maexxna) : _maexxna(maexxna) {}
+ bool operator()(Unit const* target) const
+ {
+ if (_maexxna->GetVictim() == target) // never target tank
+ return false;
+ if (target->HasAura(SPELL_WEB_WRAP)) // never target targets that are already webbed
+ return false;
+ return true;
+ }
+
+ private:
+ const Unit* _maexxna;
};
class boss_maexxna : public CreatureScript
@@ -66,27 +96,22 @@ public:
struct boss_maexxnaAI : public BossAI
{
- boss_maexxnaAI(Creature* creature) : BossAI(creature, BOSS_MAEXXNA)
- {
- Initialize();
- }
+ boss_maexxnaAI(Creature* creature) : BossAI(creature, BOSS_MAEXXNA) { }
- void Initialize()
+ void EnterCombat(Unit* /*who*/) override
{
- enraged = false;
+ _EnterCombat();
+ events.ScheduleEvent(EVENT_WRAP, 20 * IN_MILLISECONDS);
+ events.ScheduleEvent(EVENT_SPRAY, 40 * IN_MILLISECONDS);
+ events.ScheduleEvent(EVENT_SHOCK, urandms(5, 10));
+ events.ScheduleEvent(EVENT_POISON, urandms(10, 15));
+ events.ScheduleEvent(EVENT_SUMMON, 30 * IN_MILLISECONDS);
}
- bool enraged;
-
- void EnterCombat(Unit* /*who*/) override
+ void Reset() override
{
- _EnterCombat();
- Initialize();
- events.ScheduleEvent(EVENT_WRAP, 20000);
- events.ScheduleEvent(EVENT_SPRAY, 40000);
- events.ScheduleEvent(EVENT_SHOCK, urand(5000, 10000));
- events.ScheduleEvent(EVENT_POISON, urand(10000, 15000));
- events.ScheduleEvent(EVENT_SUMMON, 30000);
+ _Reset();
+ instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_WEB_WRAP);
}
void UpdateAI(uint32 diff) override
@@ -94,10 +119,9 @@ public:
if (!UpdateVictim() || !CheckInRoom())
return;
- if (!enraged && HealthBelowPct(30))
+ if (HealthBelowPct(30) && !me->HasAura(SPELL_FRENZY_HELPER))
{
- enraged = true;
- events.ScheduleEvent(EVENT_FRENZY, 0); // will be cast immediately
+ DoCast(SPELL_FRENZY);
}
events.Update(diff);
@@ -107,41 +131,49 @@ public:
switch (eventId)
{
case EVENT_WRAP:
- /// @todo Add missing text
- for (uint8 i = 0; i < RAID_MODE(1, 2); ++i)
+ {
+ std::list<Unit*> targets;
+ SelectTargetList(targets, WebTargetSelector(me), RAID_MODE(1, 2), SELECT_TARGET_RANDOM);
+ if (!targets.empty())
{
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true, -SPELL_WEB_WRAP))
+ Talk(EMOTE_WEB_WRAP);
+ int8 wrapPos = -1;
+ for (Unit* target : targets)
{
+ if (wrapPos == -1) // allow all positions on the first target
+ wrapPos = urand(0, MAX_WRAP_POSITION - 1);
+ else // on subsequent iterations, only allow positions that are not equal to the previous one (this is sufficient since we should only have two targets at most, ever)
+ wrapPos = (wrapPos + urand(1, MAX_WRAP_POSITION - 1)) % MAX_WRAP_POSITION;
+
target->RemoveAura(sSpellMgr->GetSpellIdForDifficulty(SPELL_WEB_SPRAY, me));
- uint8 pos = rand32() % MAX_POS_WRAP;
- target->GetMotionMaster()->MoveJump(PosWrap[pos].GetPositionX(), PosWrap[pos].GetPositionY(), PosWrap[pos].GetPositionZ(), 20, 20);
- if (Creature* wrap = DoSummon(NPC_WEB_WRAP, PosWrap[pos], 0, TEMPSUMMON_CORPSE_DESPAWN))
- wrap->AI()->SetGUID(target->GetGUID());
+ if (Creature* wrap = DoSummon(NPC_WEB_WRAP, WrapPositions[wrapPos], 70 * IN_MILLISECONDS, TEMPSUMMON_TIMED_DESPAWN))
+ {
+ wrap->AI()->SetGUID(target->GetGUID()); // handles application of debuff
+ target->GetMotionMaster()->MoveJump(WrapPositions[wrapPos], WEB_WRAP_MOVE_SPEED, WEB_WRAP_MOVE_SPEED); // move after stun to avoid stun cancelling move
+ }
}
}
events.ScheduleEvent(EVENT_WRAP, 40000);
break;
+ }
case EVENT_SPRAY:
+ Talk(EMOTE_WEB_SPRAY);
DoCastAOE(SPELL_WEB_SPRAY);
events.ScheduleEvent(EVENT_SPRAY, 40000);
break;
case EVENT_SHOCK:
DoCastAOE(SPELL_POISON_SHOCK);
- events.ScheduleEvent(EVENT_SHOCK, urand(10000, 20000));
+ events.ScheduleEvent(EVENT_SHOCK, urandms(10, 20));
break;
case EVENT_POISON:
DoCastVictim(SPELL_NECROTIC_POISON);
- events.ScheduleEvent(EVENT_POISON, urand(10000, 20000));
- break;
- case EVENT_FRENZY:
- DoCast(me, SPELL_FRENZY, true);
- events.ScheduleEvent(EVENT_FRENZY, 600000);
+ events.ScheduleEvent(EVENT_POISON, urandms(10, 20));
break;
case EVENT_SUMMON:
- /// @todo Add missing text
+ Talk(EMOTE_SPIDERS);
uint8 amount = urand(8, 10);
for (uint8 i = 0; i < amount; ++i)
- DoSummon(NPC_SPIDERLING, me, 0, TEMPSUMMON_CORPSE_DESPAWN);
+ DoSummon(NPC_SPIDERLING, me, 4.0f, 5 * IN_MILLISECONDS, TEMPSUMMON_CORPSE_TIMED_DESPAWN);
events.ScheduleEvent(EVENT_SUMMON, 40000);
break;
}
@@ -165,23 +197,49 @@ public:
struct npc_webwrapAI : public NullCreatureAI
{
- npc_webwrapAI(Creature* creature) : NullCreatureAI(creature) { }
+ npc_webwrapAI(Creature* creature) : NullCreatureAI(creature), visibleTimer(0) { }
ObjectGuid victimGUID;
+ uint32 visibleTimer;
+
+ void InitializeAI() override
+ {
+ me->SetVisible(false);
+ }
void SetGUID(ObjectGuid guid, int32 /*param*/) override
{
+ if (!guid)
+ return;
victimGUID = guid;
- if (me->m_spells[0] && victimGUID)
- if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
- victim->CastSpell(victim, me->m_spells[0], true, NULL, NULL, me->GetGUID());
+ if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
+ {
+ visibleTimer = (me->GetDistance2d(victim)/WEB_WRAP_MOVE_SPEED + 0.5f) * IN_MILLISECONDS;
+ victim->CastSpell(victim, SPELL_WEB_WRAP, true, NULL, NULL, me->GetGUID());
+ }
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ if (!visibleTimer)
+ return;
+
+ if (diff >= visibleTimer)
+ {
+ visibleTimer = 0;
+ me->SetVisible(true);
+ }
+ else
+ visibleTimer -= diff;
}
void JustDied(Unit* /*killer*/) override
{
- if (me->m_spells[0] && victimGUID)
+ if (victimGUID)
if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
- victim->RemoveAurasDueToSpell(me->m_spells[0], me->GetGUID());
+ victim->RemoveAurasDueToSpell(SPELL_WEB_WRAP, me->GetGUID());
+
+ me->DespawnOrUnsummon(5 * IN_MILLISECONDS);
}
};
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp b/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp
index 1683667a02a..f94f7b227bf 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp
@@ -17,43 +17,40 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
+#include "SpellInfo.h"
#include "naxxramas.h"
-//Razuvious - NO TEXT sound only
-//8852 aggro01 - Hah hah, I'm just getting warmed up!
-//8853 aggro02 Stand and fight!
-//8854 aggro03 Show me what you've got!
-//8861 slay1 - You should've stayed home!
-//8863 slay2-
-//8858 cmmnd3 - You disappoint me, students!
-//8855 cmmnd1 - Do as I taught you!
-//8856 cmmnd2 - Show them no mercy!
-//8859 cmmnd4 - The time for practice is over! Show me what you've learned!
-//8861 Sweep the leg! Do you have a problem with that?
-//8860 death - An honorable... death...
-//8947 - Aggro Mixed? - ?
-
-#define SOUND_AGGRO RAND(8852, 8853, 8854)
-#define SOUND_SLAY RAND(8861, 8863)
-#define SOUND_COMMND RAND(8855, 8856, 8858, 8859, 8861)
-#define SOUND_DEATH 8860
-#define SOUND_AGGROMIX 8847
+enum Yells
+{
+ SAY_AGGRO = 0,
+ SAY_SLAY = 1,
+ SAY_TAUNTED = 2,
+ SAY_DEATH = 3
+};
enum Spells
{
- SPELL_UNBALANCING_STRIKE = 26613,
- SPELL_DISRUPTING_SHOUT = 29107,
- SPELL_JAGGED_KNIFE = 55550,
- SPELL_HOPELESS = 29125
+ SPELL_UNBALANCING_STRIKE = 26613,
+ SPELL_DISRUPTING_SHOUT = 29107,
+ SPELL_JAGGED_KNIFE = 55550,
+ SPELL_HOPELESS = 29125,
+ SPELL_UNDERSTUDY_TAUNT = 29060,
+ SPELL_UNDERSTUDY_BLOOD_STRIKE = 61696,
+ SPELL_FORCE_OBEDIENCE = 55479
};
enum Events
{
- EVENT_NONE,
+ EVENT_ATTACK = 1,
EVENT_STRIKE,
EVENT_SHOUT,
- EVENT_KNIFE,
- EVENT_COMMAND,
+ EVENT_KNIFE
+};
+
+enum SummonGroups
+{
+ SUMMON_GROUP_10MAN = 1,
+ SUMMON_GROUP_25MAN = 2
};
class boss_razuvious : public CreatureScript
@@ -70,36 +67,60 @@ public:
{
boss_razuviousAI(Creature* creature) : BossAI(creature, BOSS_RAZUVIOUS) { }
- void KilledUnit(Unit* /*victim*/) override
+ void SummonAdds()
{
- if (!(rand32() % 3))
- DoPlaySoundToSet(me, SOUND_SLAY);
+ me->SummonCreatureGroup(SUMMON_GROUP_10MAN);
+ if (Is25ManRaid())
+ me->SummonCreatureGroup(SUMMON_GROUP_25MAN);
}
- void DamageTaken(Unit* pDone_by, uint32& uiDamage) override
+ void InitializeAI() override
{
- // Damage done by the controlled Death Knight understudies should also count toward damage done by players
- if (pDone_by->GetTypeId() == TYPEID_UNIT && (pDone_by->GetEntry() == 16803 || pDone_by->GetEntry() == 29941))
+ if (!me->isDead())
{
- me->LowerPlayerDamageReq(uiDamage);
+ Reset();
+ SummonAdds();
}
}
+ void JustReachedHome() override
+ {
+ _JustReachedHome();
+ SummonAdds();
+ me->GetMotionMaster()->Initialize();
+ }
+
+ void KilledUnit(Unit* victim) override
+ {
+ if (victim->GetTypeId() == TYPEID_PLAYER || (victim->GetTypeId() == TYPEID_UNIT && victim->GetEntry() == NPC_DK_UNDERSTUDY))
+ Talk(SAY_SLAY);
+ }
+
+ void SpellHit(Unit* caster, SpellInfo const* spell) override
+ {
+ if (spell->Id == SPELL_UNDERSTUDY_TAUNT)
+ Talk(SAY_TAUNTED, caster);
+ }
+
void JustDied(Unit* /*killer*/) override
{
- _JustDied();
- DoPlaySoundToSet(me, SOUND_DEATH);
- me->CastSpell(me, SPELL_HOPELESS, true); /// @todo this may affect other creatures
+ Talk(SAY_DEATH);
+ DoCastAOE(SPELL_HOPELESS, true);
+
+ events.Reset();
+ instance->SetBossState(BOSS_RAZUVIOUS, DONE);
}
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
- DoPlaySoundToSet(me, SOUND_AGGRO);
- events.ScheduleEvent(EVENT_STRIKE, 30000);
- events.ScheduleEvent(EVENT_SHOUT, 25000);
- events.ScheduleEvent(EVENT_COMMAND, 40000);
- events.ScheduleEvent(EVENT_KNIFE, 10000);
+ me->StopMoving();
+ summons.DoZoneInCombat();
+ Talk(SAY_AGGRO);
+ events.ScheduleEvent(EVENT_ATTACK, 7 * IN_MILLISECONDS);
+ events.ScheduleEvent(EVENT_STRIKE, 21 * IN_MILLISECONDS);
+ events.ScheduleEvent(EVENT_SHOUT, 16 * IN_MILLISECONDS);
+ events.ScheduleEvent(EVENT_KNIFE, 10 * IN_MILLISECONDS);
}
void UpdateAI(uint32 diff) override
@@ -113,33 +134,112 @@ public:
{
switch (eventId)
{
+ case EVENT_ATTACK:
+ SetCombatMovement(true);
+ if (Unit* victim = me->GetVictim())
+ me->GetMotionMaster()->MoveChase(victim);
+ break;
case EVENT_STRIKE:
DoCastVictim(SPELL_UNBALANCING_STRIKE);
- events.ScheduleEvent(EVENT_STRIKE, 30000);
+ events.ScheduleEvent(EVENT_STRIKE, 6 * IN_MILLISECONDS);
return;
case EVENT_SHOUT:
DoCastAOE(SPELL_DISRUPTING_SHOUT);
- events.ScheduleEvent(EVENT_SHOUT, 25000);
+ events.ScheduleEvent(EVENT_SHOUT, 16 * IN_MILLISECONDS);
return;
case EVENT_KNIFE:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f))
DoCast(target, SPELL_JAGGED_KNIFE);
- events.ScheduleEvent(EVENT_KNIFE, 10000);
- return;
- case EVENT_COMMAND:
- DoPlaySoundToSet(me, SOUND_COMMND);
- events.ScheduleEvent(EVENT_COMMAND, 40000);
+ events.ScheduleEvent(EVENT_KNIFE, urandms(10,15));
return;
}
}
DoMeleeAttackIfReady();
}
+
+ void Reset() override
+ {
+ SetCombatMovement(false);
+ _Reset();
+ }
};
};
+class npc_dk_understudy : public CreatureScript
+{
+ public:
+ npc_dk_understudy() : CreatureScript("npc_dk_understudy") { }
+
+ struct npc_dk_understudyAI : public ScriptedAI
+ {
+ npc_dk_understudyAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), bloodStrikeTimer(0) { }
+
+ void EnterCombat(Unit* /*who*/) override
+ {
+ me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
+ if (Creature* razuvious = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_RAZUVIOUS)))
+ razuvious->AI()->DoZoneInCombat(nullptr, 250.0f);
+ }
+
+ void JustReachedHome() override
+ {
+ if (_instance->GetBossState(BOSS_RAZUVIOUS) == DONE)
+ me->DespawnOrUnsummon();
+ else
+ ScriptedAI::JustReachedHome();
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ if (!me->isPossessedByPlayer() && !UpdateVictim())
+ return;
+
+ if (!me->isPossessedByPlayer())
+ {
+ if (diff < bloodStrikeTimer)
+ bloodStrikeTimer -= diff;
+ else
+ DoCastVictim(SPELL_UNDERSTUDY_BLOOD_STRIKE);
+ }
+
+ DoMeleeAttackIfReady();
+ }
+
+ void OnCharmed(bool apply) override
+ {
+ ScriptedAI::OnCharmed(apply);
+ if (apply)
+ {
+ if (!me->IsInCombat())
+ EnterCombat(nullptr);
+ me->StopMoving();
+ me->SetReactState(REACT_PASSIVE);
+ _charmer = me->GetCharmerGUID();
+ }
+ else
+ {
+ me->SetReactState(REACT_AGGRESSIVE);
+ if (Unit* charmer = ObjectAccessor::GetUnit(*me, _charmer))
+ me->AddThreat(charmer, 100000.0f);
+ DoZoneInCombat(nullptr, 250.0f);
+ }
+ }
+ private:
+ InstanceScript* const _instance;
+ ObjectGuid _charmer;
+ uint32 bloodStrikeTimer;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return GetInstanceAI<npc_dk_understudyAI>(creature);
+ }
+};
+
void AddSC_boss_razuvious()
{
new boss_razuvious();
+ new npc_dk_understudy();
}
diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
index 53ce68d3efc..0e572835a51 100644
--- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
@@ -60,7 +60,6 @@ DoorData const doorData[] =
MinionData const minionData[] =
{
- { NPC_DK_UNDERSTUDY, BOSS_RAZUVIOUS },
{ NPC_SIR, BOSS_HORSEMEN },
{ NPC_THANE, BOSS_HORSEMEN },
{ NPC_LADY, BOSS_HORSEMEN },
@@ -143,6 +142,9 @@ class instance_naxxramas : public InstanceMapScript
case NPC_FAERLINA:
FaerlinaGUID = creature->GetGUID();
break;
+ case NPC_RAZUVIOUS:
+ RazuviousGUID = creature->GetGUID();
+ break;
case NPC_THANE:
ThaneGUID = creature->GetGUID();
break;
@@ -378,6 +380,8 @@ class instance_naxxramas : public InstanceMapScript
return AnubRekhanGUID;
case DATA_FAERLINA:
return FaerlinaGUID;
+ case DATA_RAZUVIOUS:
+ return RazuviousGUID;
case DATA_THANE:
return ThaneGUID;
case DATA_LADY:
@@ -652,6 +656,8 @@ class instance_naxxramas : public InstanceMapScript
ObjectGuid HeiganGUID;
/* The Military Quarter */
+ // Instructor Razuvious
+ ObjectGuid RazuviousGUID;
// Gothik the Harvester
ObjectGuid GothikGateGUID;
// The Four Horsemen
diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.h b/src/server/scripts/Northrend/Naxxramas/naxxramas.h
index d2b99784953..e4d15cf84ba 100644
--- a/src/server/scripts/Northrend/Naxxramas/naxxramas.h
+++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.h
@@ -66,6 +66,7 @@ enum Data64
{
DATA_ANUBREKHAN,
DATA_FAERLINA,
+ DATA_RAZUVIOUS,
DATA_THANE,
DATA_LADY,
DATA_BARON,
@@ -87,6 +88,7 @@ enum CreaturesIds
{
NPC_ANUBREKHAN = 15956,
NPC_FAERLINA = 15953,
+ NPC_RAZUVIOUS = 16061,
NPC_THANE = 16064,
NPC_LADY = 16065,
NPC_BARON = 30549,
diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp
index 0d6353cfb86..14d2687c298 100644
--- a/src/server/scripts/Pet/pet_mage.cpp
+++ b/src/server/scripts/Pet/pet_mage.cpp
@@ -24,11 +24,25 @@
#include "ScriptedCreature.h"
#include "CombatAI.h"
#include "Pet.h"
+#include "PetAI.h"
+#include "Cell.h"
+#include "CellImpl.h"
+#include "GridNotifiers.h"
+#include "GridNotifiersImpl.h"
enum MageSpells
{
SPELL_MAGE_CLONE_ME = 45204,
- SPELL_MAGE_MASTERS_THREAT_LIST = 58838
+ SPELL_MAGE_MASTERS_THREAT_LIST = 58838,
+ SPELL_MAGE_FROST_BOLT = 59638,
+ SPELL_MAGE_FIRE_BLAST = 59637
+};
+
+enum MirrorImageTimers
+{
+ TIMER_MIRROR_IMAGE_INIT = 0,
+ TIMER_MIRROR_IMAGE_FROST_BOLT = 4000,
+ TIMER_MIRROR_IMAGE_FIRE_BLAST = 6000
};
class npc_pet_mage_mirror_image : public CreatureScript
@@ -40,20 +54,184 @@ class npc_pet_mage_mirror_image : public CreatureScript
{
npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { }
+ void Init()
+ {
+ Unit* owner = me->GetCharmerOrOwner();
+
+ std::list<Unit*> targets;
+ Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
+ Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
+ me->VisitNearbyObject(40.0f, searcher);
+
+ Unit* highestThreatUnit = nullptr;
+ float highestThreat = 0.0f;
+ Unit* nearestPlayer = nullptr;
+ for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
+ {
+ // Consider only units without CC
+ if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter)))
+ {
+ // Take first found unit
+ if (!highestThreatUnit && (*iter)->GetTypeId() != TYPEID_PLAYER)
+ {
+ highestThreatUnit = (*iter);
+ continue;
+ }
+ if (!nearestPlayer && ((*iter)->GetTypeId() == TYPEID_PLAYER))
+ {
+ nearestPlayer = (*iter);
+ continue;
+ }
+ // else compare best fit unit with current unit
+ ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList();
+ for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr)
+ {
+ // Try to find threat referenced to owner
+ if ((*trig_citr)->getTarget() == owner)
+ {
+ // Check if best fit hostile unit hs lower threat than this current unit
+ if (highestThreat < (*trig_citr)->getThreat())
+ {
+ // If so, update best fit unit
+ highestThreat = (*trig_citr)->getThreat();
+ highestThreatUnit = (*iter);
+ break;
+ }
+ }
+ }
+ // In case no unit with threat was found so far, always check for nearest unit (only for players)
+ if ((*iter)->GetTypeId() == TYPEID_PLAYER)
+ {
+ // If this player is closer than the previous one, update it
+ if (me->GetDistance((*iter)->GetPosition()) < me->GetDistance(nearestPlayer->GetPosition()))
+ nearestPlayer = (*iter);
+ }
+ }
+ }
+ // Prioritize units with threat referenced to owner
+ if (highestThreat > 0.0f && highestThreatUnit)
+ me->Attack(highestThreatUnit, false);
+ // If there is no such target, try to attack nearest hostile unit if such exists
+ else if (nearestPlayer)
+ me->Attack(nearestPlayer, false);
+ }
+
+ bool IsInThreatList(Unit* target)
+ {
+ Unit* owner = me->GetCharmerOrOwner();
+
+ std::list<Unit*> targets;
+ Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
+ Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
+ me->VisitNearbyObject(40.0f, searcher);
+
+ for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
+ {
+ if ((*iter) == target)
+ {
+ // Consider only units without CC
+ if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter)))
+ {
+ ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList();
+ for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr)
+ {
+ // Try to find threat referenced to owner
+ if ((*trig_citr)->getTarget() == owner)
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
void InitializeAI() override
{
CasterAI::InitializeAI();
Unit* owner = me->GetOwner();
if (!owner)
return;
- // Inherit Master's Threat List (not yet implemented)
- owner->CastSpell((Unit*)NULL, SPELL_MAGE_MASTERS_THREAT_LIST, true);
+
// here mirror image casts on summoner spell (not present in client dbc) 49866
// here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcast by mirror images (stats related?)
// Clone Me!
owner->CastSpell(me, SPELL_MAGE_CLONE_ME, false);
}
+ void EnterCombat(Unit* who) override
+ {
+ if (me->GetVictim() && !me->GetVictim()->HasBreakableByDamageCrowdControlAura(me))
+ {
+ me->CastSpell(who, SPELL_MAGE_FIRE_BLAST, false);
+ events.ScheduleEvent(SPELL_MAGE_FROST_BOLT, TIMER_MIRROR_IMAGE_INIT);
+ events.ScheduleEvent(SPELL_MAGE_FIRE_BLAST, TIMER_MIRROR_IMAGE_FIRE_BLAST);
+ }
+ else
+ EnterEvadeMode();
+ }
+
+ void Reset() override
+ {
+ events.Reset();
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ Unit* owner = me->GetCharmerOrOwner();
+ Unit* target = owner->getAttackerForHelper();
+
+ events.Update(diff);
+
+ // prevent CC interrupts by images
+ if (me->GetVictim() && me->EnsureVictim()->HasBreakableByDamageCrowdControlAura(me))
+ {
+ me->InterruptNonMeleeSpells(false);
+ return;
+ }
+
+ if (me->HasUnitState(UNIT_STATE_CASTING))
+ return;
+
+ if (!owner)
+ return;
+
+ // assign target if image doesnt have any or the target is not actual
+ if (!target || me->GetVictim() != target)
+ {
+ Unit* ownerTarget = nullptr;
+ if (Player* owner = me->GetCharmerOrOwner()->ToPlayer())
+ ownerTarget = owner->GetSelectedUnit();
+
+ // recognize which victim will be choosen
+ if (ownerTarget && ownerTarget->GetTypeId() == TYPEID_PLAYER)
+ {
+ if (!ownerTarget->HasBreakableByDamageCrowdControlAura(ownerTarget))
+ me->Attack(ownerTarget, false);
+ }
+ else if (ownerTarget && (ownerTarget->GetTypeId() != TYPEID_PLAYER) && IsInThreatList(ownerTarget))
+ {
+ if (!ownerTarget->HasBreakableByDamageCrowdControlAura(ownerTarget))
+ me->Attack(ownerTarget, false);
+ }
+ else
+ Init();
+ }
+
+ if (uint32 spellId = events.ExecuteEvent())
+ {
+ if (spellId == SPELL_MAGE_FROST_BOLT)
+ {
+ events.ScheduleEvent(SPELL_MAGE_FROST_BOLT, TIMER_MIRROR_IMAGE_FROST_BOLT);
+ DoCastVictim(spellId);
+ }
+ else if (spellId == SPELL_MAGE_FIRE_BLAST)
+ {
+ DoCastVictim(spellId);
+ events.ScheduleEvent(SPELL_MAGE_FIRE_BLAST, TIMER_MIRROR_IMAGE_FIRE_BLAST);
+ }
+ }
+ }
+
// Do not reload Creature templates on evade mode enter - prevent visual lost
void EnterEvadeMode() override
{
@@ -68,6 +246,7 @@ class npc_pet_mage_mirror_image : public CreatureScript
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
}
+ Init();
}
};