From 0927c5af4057c45c79d19a870f1d1d7d4b190942 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 27 Feb 2025 21:06:41 +0100 Subject: [PATCH] Core/Misc: backported most boost changes from master branch --- cmake/showoptions.cmake | 6 + dep/CMakeLists.txt | 1 + dep/boost/CMakeLists.txt | 102 ++-- dep/short_alloc/CMakeLists.txt | 15 + dep/short_alloc/short_alloc/short_alloc.h | 162 ++++++ src/common/Asio/DeadlineTimer.h | 17 +- src/common/Asio/Resolver.h | 1 + src/common/CMakeLists.txt | 3 +- src/common/Configuration/Config.cpp | 1 + src/common/Containers/FlatSet.h | 105 ++++ src/common/Logging/Log.cpp | 2 +- src/common/Metric/Metric.cpp | 4 +- src/common/Utilities/ByteConverter.h | 5 +- src/common/Utilities/EventProcessor.h | 3 +- src/common/Utilities/IteratorPair.h | 22 +- src/common/Utilities/Memory.h | 143 ++++- src/common/Utilities/Regex.h | 8 +- src/common/Utilities/StartProcess.cpp | 61 +-- src/common/Utilities/TaskScheduler.h | 1 - src/common/Utilities/Types.h | 4 +- src/common/Utilities/UniqueTrackablePtr.h | 494 ++++++++++++++++++ src/common/Utilities/advstd.h | 66 +-- src/server/bnetserver/Main.cpp | 8 +- .../bnetserver/Realms/BNetRealmList.cpp | 2 +- src/server/database/Updater/UpdateFetcher.cpp | 2 + src/server/game/AI/CoreAI/UnitAI.cpp | 92 +++- src/server/game/AI/CoreAI/UnitAI.h | 94 +--- src/server/game/AI/CreatureAI.cpp | 1 + .../game/AI/ScriptedAI/ScriptedCreature.cpp | 8 +- .../game/AI/ScriptedAI/ScriptedCreature.h | 8 +- .../game/AI/SmartScripts/SmartScript.cpp | 1 + .../game/Chat/ChatCommands/ChatCommand.h | 15 +- .../game/Chat/ChatCommands/ChatCommandArgs.h | 10 +- .../Chat/ChatCommands/ChatCommandHelpers.h | 2 +- .../Chat/ChatCommands/ChatCommandHyperlinks.h | 6 +- .../game/Chat/ChatCommands/ChatCommandTags.h | 2 +- src/server/game/Combat/ThreatManager.cpp | 140 +++-- src/server/game/Combat/ThreatManager.h | 48 +- .../game/Entities/Creature/Creature.cpp | 1 + .../game/Entities/GameObject/GameObject.cpp | 1 + src/server/game/Entities/Unit/Unit.cpp | 2 + src/server/game/Handlers/MovementHandler.cpp | 19 +- src/server/game/Maps/Map.cpp | 44 +- src/server/game/Maps/Map.h | 7 +- src/server/game/Phasing/PhaseShift.h | 4 +- .../game/Server/Packets/PacketUtilities.h | 95 +++- src/server/game/Server/WorldSession.cpp | 3 +- src/server/game/Server/WorldSession.h | 4 +- src/server/game/Spells/Spell.cpp | 5 +- src/server/game/Texts/CreatureTextMgr.cpp | 3 +- src/server/game/World/World.cpp | 1 + src/server/scripts/Commands/cs_server.cpp | 5 +- .../BaradinHold/boss_alizabal.cpp | 1 + .../BaradinHold/boss_occuthar.cpp | 1 + .../BaradinHold/boss_pit_lord_argaloth.cpp | 1 + .../boss_ascendant_council.cpp | 1 + .../BastionOfTwilight/boss_chogall.cpp | 1 + .../boss_halfus_wyrmbreaker.cpp | 1 + .../boss_theralion_and_valiona.cpp | 1 + .../BlackrockDepths/boss_coren_direbrew.cpp | 1 + .../BlackwingDescent/boss_atramedes.cpp | 1 + .../BlackwingDescent/boss_chimaeron.cpp | 5 +- .../BlackwingDescent/boss_magmaw.cpp | 1 + .../BlackwingDescent/boss_maloriak.cpp | 1 + .../boss_omnotron_defense_system.cpp | 3 +- .../MoltenCore/boss_shazzrah.cpp | 1 + .../MoltenCore/boss_sulfuron_harbinger.cpp | 1 + .../Deadmines/boss_admiral_ripsnarl.cpp | 1 + .../Deadmines/boss_captain_cookie.cpp | 1 + .../Deadmines/boss_foe_reaper_5000.cpp | 1 + .../Deadmines/boss_glubtok.cpp | 1 + .../Deadmines/boss_helix_gearbreaker.cpp | 1 + .../Deadmines/boss_vanessa_van_cleef.cpp | 1 + .../Deadmines/instance_deadmines.cpp | 1 + .../Gilneas/gilneas_chapter_2.cpp | 1 + .../GrimBatol/boss_forgemaster_throngus.cpp | 1 + .../GrimBatol/boss_general_umbriss.cpp | 1 + .../Karazhan/boss_midnight.cpp | 1 + .../EasternKingdoms/Karazhan/boss_moroes.cpp | 1 + .../Karazhan/boss_prince_malchezaar.cpp | 1 + .../boss_bloodmage_thalnos.cpp | 1 + .../ShadowfangKeep/boss_apothecary_hummel.cpp | 1 + .../ShadowfangKeep/boss_baron_silverlaine.cpp | 3 +- .../ShadowfangKeep/boss_lord_godfrey.cpp | 1 + .../ShadowfangKeep/boss_lord_walden.cpp | 1 + .../ThroneOfTheTides/boss_lady_nazjar.cpp | 1 + .../ThroneOfTheTides/throne_of_the_tides.cpp | 1 + .../ZulGurub/boss_bloodlord_mandokir.cpp | 1 + .../ZulGurub/boss_high_priest_venoxis.cpp | 1 + .../ZulGurub/boss_high_priestess_kilnara.cpp | 1 + .../EasternKingdoms/ZulGurub/boss_zanzil.cpp | 1 + .../EasternKingdoms/zone_elwynn_forest.cpp | 1 + .../EasternKingdoms/zone_tol_barad.cpp | 1 + .../zone_twilight_highlands.cpp | 1 + .../scripts/EasternKingdoms/zone_westfall.cpp | 21 +- .../DragonSoul/boss_madness_of_deathwing.cpp | 1 + .../Kalimdor/Firelands/boss_alysrazor.cpp | 1 + .../Kalimdor/Firelands/boss_baleroc.cpp | 1 + .../Kalimdor/Firelands/boss_lord_rhyolith.cpp | 1 + .../Firelands/boss_ragnaros_firelands.cpp | 1 + .../Kalimdor/Firelands/instance_firelands.cpp | 1 + .../HallsOfOrigination/boss_ammunae.cpp | 1 + .../HallsOfOrigination/boss_anraphet.cpp | 3 +- .../boss_earthrager_ptah.cpp | 1 + .../Kalimdor/HallsOfOrigination/boss_rajh.cpp | 1 + .../HallsOfOrigination/boss_setesh.cpp | 7 +- .../boss_temple_guardian_anhuur.cpp | 5 +- .../halls_of_origination.cpp | 1 + .../instance_halls_of_origination.cpp | 1 + .../boss_general_husam.cpp | 1 + .../boss_high_prophet_barim.cpp | 1 + .../boss_lockmaw_and_augh.cpp | 1 + .../LostCityOfTheTolvir/boss_siamat.cpp | 1 + .../OnyxiasLair/instance_onyxias_lair.cpp | 1 + .../Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp | 1 + .../ThroneOfTheFourWinds/boss_alakir.cpp | 1 + .../boss_conclave_of_wind.cpp | 1 + .../Kalimdor/VortexPinnacle/boss_altairus.cpp | 1 + .../Kalimdor/VortexPinnacle/boss_asaad.cpp | 3 +- .../VortexPinnacle/vortex_pinnacle.cpp | 1 + .../Maelstrom/Stonecore/boss_corborus.cpp | 1 + .../AzjolNerub/Ahnkahet/instance_ahnkahet.cpp | 1 + .../ObsidianSanctum/boss_sartharion.cpp | 1 + .../RubySanctum/boss_halion.cpp | 1 + .../RubySanctum/boss_saviana_ragefire.cpp | 1 + .../boss_argent_challenge.cpp | 1 + .../TrialOfTheCrusader/boss_lord_jaraxxus.cpp | 1 + .../ForgeOfSouls/boss_devourer_of_souls.cpp | 1 + .../instance_halls_of_reflection.cpp | 1 + .../boss_blood_queen_lana_thel.cpp | 1 + .../boss_deathbringer_saurfang.cpp | 1 + .../IcecrownCitadel/boss_festergut.cpp | 1 + .../boss_icecrown_gunship_battle.cpp | 1 + .../boss_lady_deathwhisper.cpp | 1 + .../boss_professor_putricide.cpp | 1 + .../IcecrownCitadel/boss_rotface.cpp | 1 + .../IcecrownCitadel/boss_sindragosa.cpp | 1 + .../IcecrownCitadel/boss_the_lich_king.cpp | 1 + .../boss_valithria_dreamwalker.cpp | 1 + .../IcecrownCitadel/icecrown_citadel.cpp | 1 + .../Northrend/Naxxramas/boss_anubrekhan.cpp | 1 + .../Nexus/EyeOfEternity/boss_malygos.cpp | 1 + .../Northrend/Nexus/Oculus/boss_urom.cpp | 1 + .../Ulduar/boss_algalon_the_observer.cpp | 1 + .../Ulduar/Ulduar/boss_assembly_of_iron.cpp | 3 +- .../Ulduar/Ulduar/boss_flame_leviathan.cpp | 1 + .../Ulduar/Ulduar/boss_general_vezax.cpp | 1 + .../Northrend/Ulduar/Ulduar/boss_mimiron.cpp | 1 + .../Northrend/Ulduar/Ulduar/boss_thorim.cpp | 1 + .../Northrend/VaultOfArchavon/boss_emalon.cpp | 1 + .../Northrend/VioletHold/boss_xevozz.cpp | 1 + src/server/scripts/Northrend/zone_dalaran.cpp | 1 + .../SethekkHalls/boss_talon_king_ikiss.cpp | 1 + .../Outland/BlackTemple/boss_illidan.cpp | 1 + .../BlackTemple/boss_illidari_council.cpp | 1 + .../BlackTemple/boss_reliquary_of_souls.cpp | 1 + .../TheSlavePens/boss_ahune.cpp | 1 + .../Outland/zone_hellfire_peninsula.cpp | 1 + .../scripts/Outland/zone_netherstorm.cpp | 1 + src/server/scripts/Pet/pet_hunter.cpp | 1 + src/server/scripts/Spells/spell_generic.cpp | 5 +- src/server/scripts/Spells/spell_holiday.cpp | 1 + src/server/scripts/Spells/spell_item.cpp | 1 + src/server/scripts/World/npcs_special.cpp | 3 +- src/server/shared/Networking/NetworkThread.h | 4 +- src/server/worldserver/Main.cpp | 4 +- tests/common/FlatSet.cpp | 60 +++ 167 files changed, 1605 insertions(+), 484 deletions(-) create mode 100644 dep/short_alloc/CMakeLists.txt create mode 100644 dep/short_alloc/short_alloc/short_alloc.h create mode 100644 src/common/Containers/FlatSet.h create mode 100644 src/common/Utilities/UniqueTrackablePtr.h create mode 100644 tests/common/FlatSet.cpp diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake index cd49304923..f7fcdf46bf 100644 --- a/cmake/showoptions.cmake +++ b/cmake/showoptions.cmake @@ -120,6 +120,12 @@ if(PERFORMANCE_PROFILING) add_definitions(-DPERFORMANCE_PROFILING) endif() +if(WITH_BOOST_STACKTRACE) + if (BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE) + add_definitions(-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE="${BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE}") + endif() +endif() + if(BUILD_SHARED_LIBS) message("") message(" *** WITH_DYNAMIC_LINKING - INFO!") diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index a2daa321f6..545d6e1875 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -32,6 +32,7 @@ if(SERVERS) add_subdirectory(zmqpp) add_subdirectory(rapidjson) add_subdirectory(efsw) + add_subdirectory(short_alloc) endif() if(TOOLS) diff --git a/dep/boost/CMakeLists.txt b/dep/boost/CMakeLists.txt index 0a926afa93..54c2429d86 100644 --- a/dep/boost/CMakeLists.txt +++ b/dep/boost/CMakeLists.txt @@ -8,13 +8,25 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +set(BOOST_SEARCH_HINTS) if(WIN32) if(DEFINED ENV{BOOST_ROOT}) set(BOOST_ROOT $ENV{BOOST_ROOT}) - list(APPEND BOOST_LIBRARYDIR - ${BOOST_ROOT}/lib${PLATFORM}-msvc-14.2 ) - elseif(NOT DEFINED Boost_DIR AND NOT DEFINED BOOST_ROOT AND NOT DEFINED BOOSTROOT) - message(FATAL_ERROR "No BOOST_ROOT environment variable could be found! Please make sure it is set and the points to your Boost installation.") + endif() + if(DEFINED BOOST_ROOT AND MSVC) + # insert a dot (.) character before last digit of MSVC_TOOLSET_VERSION + # turn 143 into 14.3 + string(LENGTH "${MSVC_TOOLSET_VERSION}" _BOOST_MSVC_TOOLSET_VERSION_LENGTH) + math(EXPR _BOOST_MSVC_TOOLSET_VERSION_LENGTH "${_BOOST_MSVC_TOOLSET_VERSION_LENGTH} - 1" OUTPUT_FORMAT DECIMAL) + string(SUBSTRING "${MSVC_TOOLSET_VERSION}" 0 ${_BOOST_MSVC_TOOLSET_VERSION_LENGTH} _BOOST_MSVC_TOOLSET_VERSION_MAJOR) + string(SUBSTRING "${MSVC_TOOLSET_VERSION}" ${_BOOST_MSVC_TOOLSET_VERSION_LENGTH} -1 _BOOST_MSVC_TOOLSET_VERSION_MINOR) + + file(TO_CMAKE_PATH "${BOOST_ROOT}" BOOST_ROOT) + set(BOOST_SEARCH_HINTS "${BOOST_ROOT}/lib${PLATFORM}-msvc-${_BOOST_MSVC_TOOLSET_VERSION_MAJOR}.${_BOOST_MSVC_TOOLSET_VERSION_MINOR}/cmake") + + unset(_BOOST_MSVC_TOOLSET_VERSION_LENGTH) + unset(_BOOST_MSVC_TOOLSET_VERSION_MAJOR) + unset(_BOOST_MSVC_TOOLSET_VERSION_MINOR) endif() set(Boost_USE_STATIC_LIBS ON) @@ -22,42 +34,32 @@ if(WIN32) set(Boost_USE_STATIC_RUNTIME OFF) endif() -set(Boost_NO_WARN_NEW_VERSIONS ON) - -include (CheckCXXSourceCompiles) - -check_cxx_source_compiles(" - #include - int main() { std::wregex r(L\".*\"); }" - STD_HAS_WORKING_WREGEX) - if (WIN32) # On windows the requirements are higher according to the wiki. set(BOOST_REQUIRED_VERSION 1.78) else() - set(BOOST_REQUIRED_VERSION 1.71) + set(BOOST_REQUIRED_VERSION 1.74) endif() -if (STD_HAS_WORKING_WREGEX) - find_package(Boost ${BOOST_REQUIRED_VERSION} REQUIRED system filesystem thread program_options iostreams) -else() - find_package(Boost ${BOOST_REQUIRED_VERSION} REQUIRED system filesystem thread program_options iostreams regex) +find_package(Boost ${BOOST_REQUIRED_VERSION} + REQUIRED + COMPONENTS + system + filesystem + thread + program_options + regex + locale + CONFIG + HINTS + ${BOOST_SEARCH_HINTS}) + +if(NOT Boost_FOUND) + if(NOT DEFINED ENV{BOOST_ROOT} AND NOT DEFINED Boost_DIR AND NOT DEFINED BOOST_ROOT AND NOT DEFINED BOOSTROOT) + message(FATAL_ERROR "No BOOST_ROOT environment variable could be found! Please make sure it is set and the points to your Boost installation.") + endif() endif() -# Find if Boost was compiled in C++03 mode because it requires -DBOOST_NO_CXX11_SCOPED_ENUMS - -set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR}) -set(CMAKE_REQUIRED_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_IOSTREAMS_LIBRARY}) -set(CMAKE_REQUIRED_FLAGS "-std=c++11") -check_cxx_source_compiles(" - #include - #include - int main() { boost::filesystem::copy_file(boost::filesystem::path(), boost::filesystem::path()); }" -boost_filesystem_copy_links_without_NO_SCOPED_ENUM) -unset(CMAKE_REQUIRED_INCLUDES) -unset(CMAKE_REQUIRED_LIBRARIES) -unset(CMAKE_REQUIRED_FLAGS) - add_library(boost INTERFACE) target_link_libraries(boost @@ -70,19 +72,35 @@ target_include_directories(boost target_compile_definitions(boost INTERFACE - -DBOOST_ALL_NO_LIB - -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE - -DBOOST_ASIO_NO_DEPRECATED - -DBOOST_BIND_NO_PLACEHOLDERS) + BOOST_ALL_NO_LIB + BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE + BOOST_ASIO_NO_DEPRECATED + BOOST_BIND_NO_PLACEHOLDERS + BOOST_SYSTEM_USE_UTF8) + +if (WITH_BOOST_STACKTRACE AND NOT WIN32) + message(STATUS "libbacktrace will be linked") + + include(CheckIncludeFile) + + if (BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE) + check_include_file("${BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE}" HAS_BACKTRACE) + target_compile_definitions(boost + INTERFACE + BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=${BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE}) + else() + check_include_file("backtrace.h" HAS_BACKTRACE) + endif() + + if (NOT HAS_BACKTRACE) + message(FATAL_ERROR "Required header 'backtrace.h' not found. If building with a compiler other than GCC, please specify the full path in the CMake option BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE.") + endif() -if (NOT boost_filesystem_copy_links_without_NO_SCOPED_ENUM) target_compile_definitions(boost INTERFACE - -DBOOST_NO_CXX11_SCOPED_ENUMS) -endif() + BOOST_STACKTRACE_USE_BACKTRACE) -if (NOT STD_HAS_WORKING_WREGEX) - target_compile_definitions(boost + target_link_libraries(boost INTERFACE - -DTC_HAS_BROKEN_WSTRING_REGEX) + backtrace) endif() diff --git a/dep/short_alloc/CMakeLists.txt b/dep/short_alloc/CMakeLists.txt new file mode 100644 index 0000000000..fc6ae3941b --- /dev/null +++ b/dep/short_alloc/CMakeLists.txt @@ -0,0 +1,15 @@ +# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +add_library(short_alloc INTERFACE) + +target_include_directories(short_alloc + INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/dep/short_alloc/short_alloc/short_alloc.h b/dep/short_alloc/short_alloc/short_alloc.h new file mode 100644 index 0000000000..eb8d02c791 --- /dev/null +++ b/dep/short_alloc/short_alloc/short_alloc.h @@ -0,0 +1,162 @@ +#ifndef SHORT_ALLOC_H +#define SHORT_ALLOC_H + +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include + +namespace short_alloc +{ +template +class arena +{ + alignas(alignment) char buf_[N]; + char* ptr_; + +public: + ~arena() {ptr_ = nullptr;} + arena() noexcept : ptr_(buf_) {} + arena(const arena&) = delete; + arena& operator=(const arena&) = delete; + + template char* allocate(std::size_t n); + void deallocate(char* p, std::size_t n) noexcept; + + static constexpr std::size_t size() noexcept {return N;} + std::size_t used() const noexcept {return static_cast(ptr_ - buf_);} + void reset() noexcept {ptr_ = buf_;} + +private: + static + std::size_t + align_up(std::size_t n) noexcept + {return (n + (alignment-1)) & ~(alignment-1);} + + bool + pointer_in_buffer(char* p) noexcept + { + return std::uintptr_t(buf_) <= std::uintptr_t(p) && + std::uintptr_t(p) <= std::uintptr_t(buf_) + N; + } +}; + +template +template +char* +arena::allocate(std::size_t n) +{ + static_assert(ReqAlign <= alignment, "alignment is too small for this arena"); + assert(pointer_in_buffer(ptr_) && "short_alloc has outlived arena"); + auto const aligned_n = align_up(n); + if (static_cast(buf_ + N - ptr_) >= aligned_n) + { + char* r = ptr_; + ptr_ += aligned_n; + return r; + } + + static_assert(alignment <= alignof(std::max_align_t), "you've chosen an " + "alignment that is larger than alignof(std::max_align_t), and " + "cannot be guaranteed by normal operator new"); + return static_cast(::operator new(n)); +} + +template +void +arena::deallocate(char* p, std::size_t n) noexcept +{ + assert(pointer_in_buffer(ptr_) && "short_alloc has outlived arena"); + if (pointer_in_buffer(p)) + { + n = align_up(n); + if (p + n == ptr_) + ptr_ = p; + } + else + ::operator delete(p); +} + +template +class short_alloc +{ +public: + using value_type = T; + static auto constexpr alignment = Align; + static auto constexpr size = N; + using arena_type = arena; + +private: + arena_type& a_; + +public: + short_alloc(const short_alloc&) = default; + short_alloc& operator=(const short_alloc&) = delete; + + short_alloc(arena_type& a) noexcept : a_(a) + { + static_assert(size % alignment == 0, + "size N needs to be a multiple of alignment Align"); + } + template + short_alloc(const short_alloc& a) noexcept + : a_(a.a_) {} + + template struct rebind {using other = short_alloc<_Up, N, alignment>;}; + + T* allocate(std::size_t n) + { + return reinterpret_cast(a_.template allocate(n*sizeof(T))); + } + void deallocate(T* p, std::size_t n) noexcept + { + a_.deallocate(reinterpret_cast(p), n*sizeof(T)); + } + + template + friend + bool + operator==(const short_alloc& x, const short_alloc& y) noexcept; + + template friend class short_alloc; +}; + +template +inline +bool +operator==(const short_alloc& x, const short_alloc& y) noexcept +{ + return N == M && A1 == A2 && &x.a_ == &y.a_; +} + +template +inline +bool +operator!=(const short_alloc& x, const short_alloc& y) noexcept +{ + return !(x == y); +} +} +#endif // SHORT_ALLOC_H diff --git a/src/common/Asio/DeadlineTimer.h b/src/common/Asio/DeadlineTimer.h index 94531a2851..004376fd1f 100644 --- a/src/common/Asio/DeadlineTimer.h +++ b/src/common/Asio/DeadlineTimer.h @@ -18,18 +18,17 @@ #ifndef DeadlineTimer_h__ #define DeadlineTimer_h__ -#include +#include "Duration.h" +#include +#include -namespace Trinity +namespace Trinity::Asio { - namespace Asio + class DeadlineTimer : public boost::asio::basic_waitable_timer, boost::asio::io_context::executor_type> { - class DeadlineTimer : public boost::asio::basic_deadline_timer, boost::asio::io_context::executor_type> - { - public: - using basic_deadline_timer::basic_deadline_timer; - }; - } + public: + using basic_waitable_timer::basic_waitable_timer; + }; } #endif // DeadlineTimer_h__ diff --git a/src/common/Asio/Resolver.h b/src/common/Asio/Resolver.h index 01399e435e..08aa36b994 100644 --- a/src/common/Asio/Resolver.h +++ b/src/common/Asio/Resolver.h @@ -21,6 +21,7 @@ #include "IoContext.h" #include "Optional.h" #include +#include #include namespace Trinity diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 636da64ad9..a8531bc7fb 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -71,7 +71,8 @@ target_link_libraries(common openssl valgrind threads - jemalloc) + jemalloc + short_alloc) add_dependencies(common revision_data.h) diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index 9d669e930e..610e4724d6 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -18,6 +18,7 @@ #include "Config.h" #include "Log.h" #include "Util.h" +#include #include #include #include diff --git a/src/common/Containers/FlatSet.h b/src/common/Containers/FlatSet.h new file mode 100644 index 0000000000..5602ba1725 --- /dev/null +++ b/src/common/Containers/FlatSet.h @@ -0,0 +1,105 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +#ifndef TRINITYCORE_FLAT_SET_H +#define TRINITYCORE_FLAT_SET_H + +#include +#include + +namespace Trinity::Containers +{ +template , class KeyContainer = std::vector> +class FlatSet +{ +public: + using iterator = typename KeyContainer::iterator; + using const_iterator = typename KeyContainer::const_iterator; + + bool empty() const { return _storage.empty(); } + auto size() const { return _storage.size(); } + + auto begin() { return _storage.begin(); } + auto begin() const { return _storage.begin(); } + + auto end() { return _storage.end(); } + auto end() const { return _storage.end(); } + + auto find(Key const& value) const + { + auto end = this->end(); + auto itr = std::lower_bound(this->begin(), end, value, Compare()); + if (itr != end && Compare()(value, *itr)) + itr = end; + + return itr; + } + + auto find(Key const& value) + { + auto end = this->end(); + auto itr = std::lower_bound(this->begin(), end, value, Compare()); + if (itr != end && Compare()(value, *itr)) + itr = end; + + return itr; + } + + template + std::pair emplace(Args&&... args) + { + Key newElement(std::forward(args)...); + auto end = this->end(); + auto itr = std::lower_bound(this->begin(), end, newElement, Compare()); + if (itr != end && !Compare()(newElement, *itr)) + return { itr, false }; + + return { _storage.emplace(itr, std::move(newElement)), true }; + } + + std::pair insert(Key const& key) { return emplace(key); } + + std::size_t erase(Key const& key) + { + auto itr = this->find(key); + if (itr == this->end()) + return 0; + + this->erase(itr); + return 1; + } + auto erase(const_iterator itr) { return _storage.erase(itr); } + + void clear() { _storage.clear(); } + + void shrink_to_fit() { _storage.shrink_to_fit(); } + + friend bool operator==(FlatSet const& left, FlatSet const& right) + { + return left._storage == right._storage; + } + + friend bool operator!=(FlatSet const& left, FlatSet const& right) + { + return !(left == right); + } + +private: + KeyContainer _storage; +}; +} + +#endif // TRINITYCORE_FLAT_SET_H diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index ced1a7c540..c946d086b4 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -20,13 +20,13 @@ #include "AppenderFile.h" #include "Common.h" #include "Config.h" +#include "Duration.h" #include "Errors.h" #include "Logger.h" #include "LogMessage.h" #include "LogOperation.h" #include "Strand.h" #include "Util.h" -#include #include Log::Log() : AppenderId(0), lowestLogLevel(LOG_LEVEL_FATAL), _ioContext(nullptr), _strand(nullptr) diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index 6531f87367..0c41b790d2 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -200,7 +200,7 @@ void Metric::ScheduleSend() { if (_enabled) { - _batchTimer->expires_from_now(boost::posix_time::seconds(_updateInterval)); + _batchTimer->expires_after(std::chrono::seconds(_updateInterval)); _batchTimer->async_wait(std::bind(&Metric::SendBatch, this)); } else @@ -230,7 +230,7 @@ void Metric::ScheduleOverallStatusLog() { if (_enabled) { - _overallStatusTimer->expires_from_now(boost::posix_time::seconds(_overallStatusTimerInterval)); + _overallStatusTimer->expires_after(std::chrono::seconds(_overallStatusTimerInterval)); _overallStatusTimer->async_wait([this](const boost::system::error_code&) { _overallStatusTimerTriggered = true; diff --git a/src/common/Utilities/ByteConverter.h b/src/common/Utilities/ByteConverter.h index 59be4adb86..d9b74b8326 100644 --- a/src/common/Utilities/ByteConverter.h +++ b/src/common/Utilities/ByteConverter.h @@ -23,14 +23,15 @@ */ #include "Define.h" -#include namespace ByteConverter { template inline void convert(char *val) { - std::swap(*val, *(val + T - 1)); + char tmp = *val; + *val = *(val + T - 1); + *(val + T - 1) = tmp; convert(val + 1); } diff --git a/src/common/Utilities/EventProcessor.h b/src/common/Utilities/EventProcessor.h index f416c5d640..9ce3d7a950 100644 --- a/src/common/Utilities/EventProcessor.h +++ b/src/common/Utilities/EventProcessor.h @@ -21,7 +21,6 @@ #include "Define.h" #include "Duration.h" #include "Random.h" -#include "advstd.h" #include class EventProcessor; @@ -88,7 +87,7 @@ private: }; template -using is_lambda_event = std::enable_if_t>>>; +using is_lambda_event = std::enable_if_t>>>; class TC_COMMON_API EventProcessor { diff --git a/src/common/Utilities/IteratorPair.h b/src/common/Utilities/IteratorPair.h index 5d24c931ef..0782862d20 100644 --- a/src/common/Utilities/IteratorPair.h +++ b/src/common/Utilities/IteratorPair.h @@ -27,39 +27,39 @@ namespace Trinity * * @brief Utility class to enable range for loop syntax for multimap.equal_range uses */ - template + template class IteratorPair { public: constexpr IteratorPair() : _iterators() { } - constexpr IteratorPair(iterator first, iterator second) : _iterators(first, second) { } - constexpr IteratorPair(std::pair iterators) : _iterators(iterators) { } + constexpr IteratorPair(iterator first, end_iterator second) : _iterators(first, second) { } + constexpr IteratorPair(std::pair iterators) : _iterators(iterators) { } constexpr iterator begin() const { return _iterators.first; } - constexpr iterator end() const { return _iterators.second; } + constexpr end_iterator end() const { return _iterators.second; } private: - std::pair _iterators; + std::pair _iterators; }; namespace Containers { - template - constexpr Trinity::IteratorPair MakeIteratorPair(iterator first, iterator second) + template + constexpr IteratorPair MakeIteratorPair(iterator first, end_iterator second) { return { first, second }; } - template - constexpr Trinity::IteratorPair MakeIteratorPair(std::pair iterators) + template + constexpr IteratorPair MakeIteratorPair(std::pair iterators) { return iterators; } template - inline auto MapEqualRange(M& map, typename M::key_type const& key) -> IteratorPair + auto MapEqualRange(M& map, typename M::key_type const& key) { - return { map.equal_range(key) }; + return MakeIteratorPair(map.equal_range(key)); } } //! namespace Containers diff --git a/src/common/Utilities/Memory.h b/src/common/Utilities/Memory.h index 8d67e80210..629099bf3e 100644 --- a/src/common/Utilities/Memory.h +++ b/src/common/Utilities/Memory.h @@ -18,32 +18,157 @@ #ifndef TRINITY_MEMORY_H #define TRINITY_MEMORY_H +#include "CompilerDefs.h" +#include #include +#if TRINITY_COMPILER == TRINITY_COMPILER_GNU +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + namespace Trinity { namespace Impl { template -struct unique_ptr_deleter +struct stateful_unique_ptr_deleter { using pointer = T; - unique_ptr_deleter(Del deleter) : _deleter(std::move(deleter)) { } - - void operator()(pointer ptr) const { _deleter(ptr); } + explicit(false) stateful_unique_ptr_deleter(Del deleter) : _deleter(std::move(deleter)) { } + void operator()(pointer ptr) const { (void)_deleter(ptr); } private: Del _deleter; }; -} -template -auto make_unique_ptr_with_deleter(T ptr, Del&& deleter) +template +struct stateless_unique_ptr_deleter { - using Deleter_t = Impl::unique_ptr_deleter; + using pointer = T; + void operator()(pointer ptr) const + { + if constexpr (std::is_member_function_pointer_v) + (void)(ptr->*Del)(); + else + (void)Del(ptr); + } +}; +} - return std::unique_ptr(ptr, Deleter_t(std::forward(deleter))); +/** + * Convenience function to construct type aliases for std::unique_ptr stateful deleters (such as lambda with captures) + * @tparam Ptr Type of the pointer + * @tparam Del Type of object freeing function (deduced from argument) + * @param deleter Object deleter + * + * Example use + * @code + * void FreeV1(Resource*); + * void FreeV2(Resource*); + * + * using ResourceDeleter = decltype(Trinity::unique_ptr_deleter(&FreeV1)); + * + * std::unique_ptr resource = Trinity::make_unique_ptr_with_deleter(GetResourceV1(), &FreeV1); + * // do stuff ... + * // ... later get new resource + * resource = Trinity::make_unique_ptr_with_deleter(GetResourceV2(), &FreeV2); + * @endcode + */ +template requires std::invocable && std::is_pointer_v +Impl::stateful_unique_ptr_deleter unique_ptr_deleter(Del deleter) +{ + return Impl::stateful_unique_ptr_deleter(std::move(deleter)); +} + +/** + * Convenience function to construct type aliases for std::unique_ptr stateful deleters (such as lambda with captures) + * + * Main use is for forming struct/class members without the call to make_unique_ptr_with_deleter + * @tparam Ptr Type of the pointer + * @tparam Del The freeing function. This can be either a free function pointer that accepts T* as argument, pointer to a member function of T that accepts no arguments or a lambda with no captures + * + * Example use + * @code + * using FileDeleter = decltype(Trinity::unique_ptr_deleter()); + * + * class Resource + * { + * std::unique_ptr File; + * }; + * @endcode + */ +template requires std::invocable && std::is_pointer_v +Impl::stateless_unique_ptr_deleter unique_ptr_deleter() +{ + return Impl::stateless_unique_ptr_deleter(); +} + +/** + * Utility function to construct a std::unique_ptr object with custom stateful deleter (such as lambda with captures) + * @tparam Ptr Type of the pointer + * @tparam T Type of the pointed-to object (defaults to std::remove_pointer_t) + * @tparam Del Type of object freeing function (deduced from second argument) + * @param ptr Raw pointer to owned object + * @param deleter Object deleter + * + * Example use + * @code + * class Resource + * { + * }; + * class ResourceService + * { + * Resource* Create(); + * void Destroy(Resource*); + * }; + * + * ResourceService* service = GetResourceService(); + * + * // Lambda that captures all required variables for destruction + * auto resource = Trinity::make_unique_ptr_with_deleter(service->Create(), [service](Resource* res){ service->Destroy(res); }); + * @endcode + */ +template, typename Del> requires std::invocable && std::is_pointer_v +std::unique_ptr> make_unique_ptr_with_deleter(Ptr ptr, Del deleter) +{ + return std::unique_ptr>(ptr, std::move(deleter)); +} + +/** + * Utility function to construct a std::unique_ptr object with custom stateless deleter (function pointer, captureless lambda) + * @tparam Del The freeing function. This can be either a free function pointer that accepts T* as argument, pointer to a member function of T that accepts no arguments or a lambda with no captures + * @tparam Ptr Type of the pointer + * @tparam T Type of the pointed-to object (defaults to std::remove_pointer_t) + * @param ptr Raw pointer to owned object + * + * Example uses + * @code + * void DestroyResource(Resource*); + * class Resource + * { + * void Destroy(); + * }; + * + * // Free function + * auto free = Trinity::make_unique_ptr_with_deleter<&DestroyResource>(new Resource()); + * + * // Member function + * auto member = Trinity::make_unique_ptr_with_deleter<&Resource::Destroy>(new Resource()); + * + * // Lambda + * auto lambda = Trinity::make_unique_ptr_with_deleter<[](Resource* res){ res->Destroy(); }>(new Resource()); + * @endcode + */ +template> requires std::invocable && std::is_pointer_v +std::unique_ptr> make_unique_ptr_with_deleter(Ptr ptr) +{ + return std::unique_ptr>(ptr); } } +#if TRINITY_COMPILER == TRINITY_COMPILER_GNU +#pragma GCC diagnostic pop +#endif + #endif // TRINITY_MEMORY_H diff --git a/src/common/Utilities/Regex.h b/src/common/Utilities/Regex.h index e5d71f5918..bd3f0111d8 100644 --- a/src/common/Utilities/Regex.h +++ b/src/common/Utilities/Regex.h @@ -18,15 +18,11 @@ #ifndef TrinityCore_Regex_h__ #define TrinityCore_Regex_h__ -#ifndef TC_HAS_BROKEN_WSTRING_REGEX -#include -#define TC_REGEX_NAMESPACE std -#else + // std::wregex doesn't work with patterns provided in db2 files + // so we have to use boost #include #define TC_REGEX_NAMESPACE boost -#endif -// regex compatibility layer, required for clang building with libstdc++-4.9 namespace Trinity { using regex = TC_REGEX_NAMESPACE :: regex; diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp index aa12ef7564..5079c5df63 100644 --- a/src/common/Utilities/StartProcess.cpp +++ b/src/common/Utilities/StartProcess.cpp @@ -18,11 +18,11 @@ #include "StartProcess.h" #include "Errors.h" #include "Log.h" +#include "Memory.h" #include "Optional.h" #include "Util.h" #include -#include #include #include #include @@ -32,41 +32,9 @@ #include using namespace boost::process; -using namespace boost::iostreams; namespace Trinity { - -template -class TCLogSink -{ - T callback_; - -public: - typedef char char_type; - typedef sink_tag category; - - // Requires a callback type which has a void(std::string) signature - TCLogSink(T callback) - : callback_(std::move(callback)) { } - - std::streamsize write(char const* str, std::streamsize size) - { - std::string consoleStr(str, size); - std::string utf8; - if (consoleToUtf8(consoleStr, utf8)) - callback_(utf8); - return size; - } -}; - -template -auto MakeTCLogSink(T&& callback) - -> TCLogSink::type> -{ - return { std::forward(callback) }; -} - template static int CreateChildProcess(T waiter, std::string const& executable, std::vector const& argsVector, @@ -98,12 +66,7 @@ static int CreateChildProcess(T waiter, std::string const& executable, } // prepare file with only read permission (boost process opens with read_write) - std::shared_ptr inputFile(!input.empty() ? fopen(input.c_str(), "rb") : nullptr, [](FILE* ptr) - { - if (ptr != nullptr) - fclose(ptr); - }); - + auto inputFile = Trinity::make_unique_ptr_with_deleter(!input.empty() ? fopen(input.c_str(), "rb") : nullptr, &::fclose); // Start the child process child c = [&]() { @@ -133,18 +96,20 @@ static int CreateChildProcess(T waiter, std::string const& executable, } }(); - auto outInfo = MakeTCLogSink([&](std::string const& msg) + std::string line; + while (std::getline(outStream, line, '\n')) { - TC_LOG_INFO(logger, "%s", msg.c_str()); - }); + std::erase(line, '\r'); + if (!line.empty()) + TC_LOG_INFO(logger, "%s", line.c_str()); + } - auto outError = MakeTCLogSink([&](std::string const& msg) + while (std::getline(errStream, line, '\n')) { - TC_LOG_ERROR(logger, "%s", msg.c_str()); - }); - - copy(outStream, outInfo); - copy(errStream, outError); + std::erase(line, '\r'); + if (!line.empty()) + TC_LOG_ERROR(logger, "%s", line.c_str()); + } // Call the waiter in the current scope to prevent // the streams from closing too early on leaving the scope. diff --git a/src/common/Utilities/TaskScheduler.h b/src/common/Utilities/TaskScheduler.h index da80d02be8..e6ea663b08 100644 --- a/src/common/Utilities/TaskScheduler.h +++ b/src/common/Utilities/TaskScheduler.h @@ -22,7 +22,6 @@ #include "Optional.h" #include "Random.h" #include -#include #include #include #include diff --git a/src/common/Utilities/Types.h b/src/common/Utilities/Types.h index ab78fb871a..f441b7b680 100644 --- a/src/common/Utilities/Types.h +++ b/src/common/Utilities/Types.h @@ -18,7 +18,7 @@ #ifndef Types_h__ #define Types_h__ -#include "advstd.h" +#include namespace Trinity { @@ -35,7 +35,7 @@ namespace Trinity }; template typename Check, typename T1, typename... Ts> - struct find_type_if : std::conditional_t::value, advstd::type_identity, find_type_if> + struct find_type_if : std::conditional_t::value, std::type_identity, find_type_if> { }; diff --git a/src/common/Utilities/UniqueTrackablePtr.h b/src/common/Utilities/UniqueTrackablePtr.h new file mode 100644 index 0000000000..7b1d9c236d --- /dev/null +++ b/src/common/Utilities/UniqueTrackablePtr.h @@ -0,0 +1,494 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TRINITYCORE_UNIQUE_TRACKABLE_PTR_H +#define TRINITYCORE_UNIQUE_TRACKABLE_PTR_H + +#include + +namespace Trinity +{ +template +class unique_trackable_ptr; + +template +class unique_weak_ptr; + +template +class unique_strong_ref_ptr; + +/** + * \brief Specialized variant of std::shared_ptr that enforces unique ownership and/or std::unique_ptr with std::weak_ptr capabilities + * Implementation has the same overhead as a std::shared_ptr, that is, a separate allocation for control block that holds use counters + * \tparam T Type of held object + */ +template +class unique_trackable_ptr +{ +public: + using element_type = T; + using pointer = T*; + + unique_trackable_ptr() : _ptr() { } + + explicit unique_trackable_ptr(pointer ptr) + : _ptr(ptr) { } + + template , std::is_invocable>, int> = 0> + explicit unique_trackable_ptr(pointer ptr, Deleter deleter) + : _ptr(ptr, std::move(deleter)) { } + + unique_trackable_ptr(unique_trackable_ptr const&) = delete; + + unique_trackable_ptr(unique_trackable_ptr&& other) noexcept + : _ptr(std::move(other._ptr)) { } + + template , int> = 0> + unique_trackable_ptr(unique_trackable_ptr&& other) noexcept + : _ptr(std::move(other)._ptr) { } + + unique_trackable_ptr& operator=(unique_trackable_ptr const&) = delete; + + unique_trackable_ptr& operator=(unique_trackable_ptr&& other) noexcept + { + _ptr = std::move(other._ptr); + return *this; + } + + template , int> = 0> + unique_trackable_ptr& operator=(unique_trackable_ptr&& other) noexcept + { + _ptr = std::move(other)._ptr; + return *this; + } + + ~unique_trackable_ptr() = default; + + unique_trackable_ptr& operator=(std::nullptr_t) + { + reset(); + return *this; + } + + void swap(unique_trackable_ptr& other) noexcept + { + using std::swap; + swap(_ptr, other._ptr); + } + + element_type& operator*() const + { + return *_ptr; + } + + pointer operator->() const + { + return _ptr.operator->(); + } + + pointer get() const + { + return _ptr.get(); + } + + explicit operator bool() const + { + return static_cast(_ptr); + } + + void reset() + { + _ptr.reset(); + } + + void reset(pointer ptr) + { + _ptr.reset(ptr); + } + + template , std::is_invocable>, int> = 0> + void reset(pointer ptr, Deleter deleter) + { + _ptr.reset(ptr, std::move(deleter)); + } + +private: + template + friend class unique_trackable_ptr; + + template + friend class unique_weak_ptr; + + template + friend std::enable_if_t, unique_trackable_ptr> make_unique_trackable(Args&&... args); + + template + friend std::enable_if_t, unique_trackable_ptr> make_unique_trackable(std::size_t N); + + template + friend std::enable_if_t, unique_trackable_ptr> make_unique_trackable(std::size_t N, std::remove_extent_t const& val); + + template + friend std::enable_if_t, unique_trackable_ptr> make_unique_trackable(); + + template + friend std::enable_if_t, unique_trackable_ptr> make_unique_trackable(std::remove_extent_t const& val); + + std::shared_ptr _ptr; +}; + +/** + * \brief Trinity::unique_trackable_ptr companion class, replicating what std::weak_ptr is to std::shared_ptr + * \tparam T Type of held object + */ +template +class unique_weak_ptr +{ +public: + using element_type = T; + using pointer = T*; + + unique_weak_ptr() = default; + + unique_weak_ptr(unique_trackable_ptr const& trackable) + : _ptr(trackable._ptr) { } + + unique_weak_ptr(unique_weak_ptr const& other) = default; + + template , int> = 0> + unique_weak_ptr(unique_weak_ptr const& other) noexcept + : _ptr(other._ptr) { } + + unique_weak_ptr(unique_weak_ptr&& other) noexcept = default; + + template , int> = 0> + unique_weak_ptr(unique_weak_ptr&& other) noexcept + : _ptr(std::move(other)._ptr) { } + + unique_weak_ptr& operator=(unique_trackable_ptr const& trackable) + { + _ptr = trackable._ptr; + return *this; + } + + unique_weak_ptr& operator=(unique_weak_ptr const& other) = default; + + template , int> = 0> + unique_weak_ptr& operator=(unique_weak_ptr&& other) + { + _ptr = std::move(other)._ptr; + return *this; + } + + unique_weak_ptr& operator=(unique_weak_ptr&& other) noexcept = default; + + ~unique_weak_ptr() = default; + + void swap(unique_weak_ptr& other) noexcept + { + using std::swap; + swap(_ptr, other._ptr); + } + + bool expired() const + { + return _ptr.expired(); + } + + unique_strong_ref_ptr lock() const + { + return unique_strong_ref_ptr(_ptr.lock()); + } + +private: + template + friend class unique_weak_ptr; + + template + friend class unique_strong_ref_ptr; + + template + friend unique_weak_ptr static_pointer_cast(unique_weak_ptr const& other); + + template + friend unique_weak_ptr const_pointer_cast(unique_weak_ptr const& other); + + template + friend unique_weak_ptr reinterpret_pointer_cast(unique_weak_ptr const& other); + + template + friend unique_weak_ptr dynamic_pointer_cast(unique_weak_ptr const& other); + + std::weak_ptr _ptr; +}; + +/** + * \brief Result of unique_weak_ptr::lock() function, this class holds a temporary strong reference to held object + * to prevent it from being deallocated by another thread while it is being actively accessed. + * This class is non-movable and non-copypable and is intended only for short lived local variables + * \tparam T Type of held object + */ +template +class unique_strong_ref_ptr +{ +public: + using element_type = T; + using pointer = T*; + + unique_strong_ref_ptr(unique_strong_ref_ptr const&) = delete; + unique_strong_ref_ptr(unique_strong_ref_ptr&&) = delete; + unique_strong_ref_ptr& operator=(unique_strong_ref_ptr const&) = delete; + unique_strong_ref_ptr& operator=(unique_strong_ref_ptr&&) = delete; + + ~unique_strong_ref_ptr() = default; + + element_type& operator*() const + { + return *_ptr; + } + + pointer operator->() const + { + return _ptr.operator->(); + } + + pointer get() const + { + return _ptr.get(); + } + + explicit operator bool() const + { + return static_cast(_ptr); + } + + operator unique_weak_ptr() const + { + unique_weak_ptr weak; + weak._ptr = _ptr; + return weak; + } + +private: + template + friend class unique_weak_ptr; + + template + friend unique_strong_ref_ptr static_pointer_cast(unique_strong_ref_ptr const& other); + + template + friend unique_strong_ref_ptr static_pointer_cast(unique_strong_ref_ptr&& other); + + template + friend unique_strong_ref_ptr const_pointer_cast(unique_strong_ref_ptr const& other); + + template + friend unique_strong_ref_ptr const_pointer_cast(unique_strong_ref_ptr&& other); + + template + friend unique_strong_ref_ptr reinterpret_pointer_cast(unique_strong_ref_ptr const& other); + + template + friend unique_strong_ref_ptr reinterpret_pointer_cast(unique_strong_ref_ptr&& other); + + template + friend unique_strong_ref_ptr dynamic_pointer_cast(unique_strong_ref_ptr const& other); + + template + friend unique_strong_ref_ptr dynamic_pointer_cast(unique_strong_ref_ptr&& other); + + unique_strong_ref_ptr(std::shared_ptr ptr) : _ptr(std::move(ptr)) { } + + std::shared_ptr _ptr; +}; + +// unique_trackable_ptr funcions + +template +bool operator==(unique_trackable_ptr const& left, unique_trackable_ptr const& right) +{ + return left.get() == right.get(); +} + +template +std::strong_ordering operator<=>(unique_trackable_ptr const& left, unique_trackable_ptr const& right) +{ + return left.get() <=> right.get(); +} + +template +bool operator==(unique_trackable_ptr const& left, std::nullptr_t) +{ + return left.get() == nullptr; +} + +template +std::strong_ordering operator<=>(unique_trackable_ptr const& left, std::nullptr_t) +{ + return left.get() <=> nullptr; +} + +template +std::enable_if_t, unique_trackable_ptr> make_unique_trackable(Args&&... args) +{ + unique_trackable_ptr ptr; + ptr._ptr = std::make_shared(std::forward(args)...); + return ptr; +} + +template +std::enable_if_t, unique_trackable_ptr> make_unique_trackable(std::size_t N) +{ + unique_trackable_ptr ptr; + ptr._ptr = std::make_shared(N); + return ptr; +} + +template +std::enable_if_t, unique_trackable_ptr> make_unique_trackable(std::size_t N, std::remove_extent_t const& val) +{ + unique_trackable_ptr ptr; + ptr._ptr = std::make_shared(N, val); + return ptr; +} + +template +std::enable_if_t, unique_trackable_ptr> make_unique_trackable() +{ + unique_trackable_ptr ptr; + ptr._ptr = std::make_shared(); + return ptr; +} + +template +std::enable_if_t, unique_trackable_ptr> make_unique_trackable(std::remove_extent_t const& val) +{ + unique_trackable_ptr ptr; + ptr._ptr = std::make_shared(val); + return ptr; +} + +// unique_weak_ptr funcions + +template +unique_weak_ptr static_pointer_cast(unique_weak_ptr const& other) +{ + unique_weak_ptr to; + to._ptr = std::static_pointer_cast(other._ptr.lock()); + return to; +} + +template +unique_weak_ptr const_pointer_cast(unique_weak_ptr const& other) +{ + unique_weak_ptr to; + to._ptr = std::const_pointer_cast(other._ptr.lock()); + return to; +} + +template +unique_weak_ptr reinterpret_pointer_cast(unique_weak_ptr const& other) +{ + unique_weak_ptr to; + to._ptr = std::reinterpret_pointer_cast(other._ptr.lock()); + return to; +} + +template +unique_weak_ptr dynamic_pointer_cast(unique_weak_ptr const& other) +{ + unique_weak_ptr to; + to._ptr = std::dynamic_pointer_cast(other._ptr.lock()); + return to; +} + +// unique_strong_ref_ptr funcions + +template +bool operator==(unique_strong_ref_ptr const& left, unique_strong_ref_ptr const& right) +{ + return left.get() == right.get(); +} + +template +std::strong_ordering operator<=>(unique_strong_ref_ptr const& left, unique_strong_ref_ptr const& right) +{ + return left.get() <=> right.get(); +} + +template +bool operator==(unique_strong_ref_ptr const& left, std::nullptr_t) +{ + return left.get() == nullptr; +} + +template +std::strong_ordering operator<=>(unique_strong_ref_ptr const& left, std::nullptr_t) +{ + return left.get() <=> nullptr; +} + +template +unique_strong_ref_ptr static_pointer_cast(unique_strong_ref_ptr const& other) +{ + return unique_strong_ref_ptr(std::static_pointer_cast(other._ptr)); +} + +template +unique_strong_ref_ptr static_pointer_cast(unique_strong_ref_ptr&& other) +{ + return unique_strong_ref_ptr(std::static_pointer_cast(std::move(other._ptr))); +} + +template +unique_strong_ref_ptr const_pointer_cast(unique_strong_ref_ptr const& other) +{ + return unique_strong_ref_ptr(std::const_pointer_cast(other._ptr)); +} + +template +unique_strong_ref_ptr const_pointer_cast(unique_strong_ref_ptr&& other) +{ + return unique_strong_ref_ptr(std::const_pointer_cast(std::move(other._ptr))); +} + +template +unique_strong_ref_ptr reinterpret_pointer_cast(unique_strong_ref_ptr const& other) +{ + return unique_strong_ref_ptr(std::reinterpret_pointer_cast(other._ptr)); +} + +template +unique_strong_ref_ptr reinterpret_pointer_cast(unique_strong_ref_ptr&& other) +{ + return unique_strong_ref_ptr(std::reinterpret_pointer_cast(std::move(other._ptr))); +} + +template +unique_strong_ref_ptr dynamic_pointer_cast(unique_strong_ref_ptr const& other) +{ + return unique_strong_ref_ptr(std::dynamic_pointer_cast(other._ptr)); +} + +template +unique_strong_ref_ptr dynamic_pointer_cast(unique_strong_ref_ptr&& other) +{ + return unique_strong_ref_ptr(std::dynamic_pointer_cast(std::move(other._ptr))); +} +} + +#endif // TRINITYCORE_UNIQUE_TRACKABLE_PTR_H diff --git a/src/common/Utilities/advstd.h b/src/common/Utilities/advstd.h index cb7392c5e2..ff2717c975 100644 --- a/src/common/Utilities/advstd.h +++ b/src/common/Utilities/advstd.h @@ -18,71 +18,9 @@ #ifndef TRINITY_ADVSTD_H #define TRINITY_ADVSTD_H -#include -#include -#include -#include - // this namespace holds implementations of upcoming stdlib features that our c++ version doesn't have yet -namespace advstd { - // C++17 std::apply (constrained to only function pointers, not all callable) - template - using apply_tuple_type = std::tuple>...>; - template - R apply_impl(R(*func)(Ts...), apply_tuple_type&& args, std::index_sequence) - { - return func(std::get(std::forward>(args))...); - } - template - R apply(R(*func)(Ts...), apply_tuple_type&& args) - { - return apply_impl(func, std::forward>(args), std::index_sequence_for{}); - } - -#define forward_1v(stdname, type) template constexpr type stdname ## _v = std::stdname::value -#define forward_2v(stdname, type) template constexpr type stdname ## _v = std::stdname::value - - // C++17 std::is_same_v - forward_2v(is_same, bool); - - // C++17 std::is_integral_v - forward_1v(is_integral, bool); - - // C++17 std::is_assignable_v - forward_2v(is_assignable, bool); - - // C++17 std::is_signed_v - forward_1v(is_signed, bool); - - // C++17 std::is_unsigned_v - forward_1v(is_unsigned, bool); - - // C++17 std::is_base_of_v - forward_2v(is_base_of, bool); - - // C++17 std::is_floating_point_v - forward_1v(is_floating_point, bool); - - // C++17 std::tuple_size_v - forward_1v(tuple_size, size_t); - -#undef forward_1v -#undef forward_2v - - // C++20 std::remove_cvref_t - template - using remove_cvref_t = std::remove_cv_t>; - - // C++20 std::type_identity - template - struct type_identity - { - using type = T; - }; - - // C++20 std::type_identity_t - template - using type_identity_t = typename type_identity::type; +namespace advstd +{ } #endif diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index 839da862f2..6c641ac056 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -207,7 +207,7 @@ int main(int argc, char** argv) // Enabled a timed callback for handling the database keep alive ping int32 dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30); std::shared_ptr dbPingTimer = std::make_shared(*ioContext); - dbPingTimer->expires_from_now(boost::posix_time::minutes(dbPingInterval)); + dbPingTimer->expires_after(std::chrono::minutes(dbPingInterval)); dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr(dbPingTimer), dbPingInterval, std::placeholders::_1)); #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS @@ -215,7 +215,7 @@ int main(int argc, char** argv) if (m_ServiceStatus != -1) { serviceStatusWatchTimer = std::make_shared(*ioContext); - serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1)); + serviceStatusWatchTimer->expires_after(1s); serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher, std::weak_ptr(serviceStatusWatchTimer), std::weak_ptr(ioContext), @@ -280,7 +280,7 @@ void KeepDatabaseAliveHandler(std::weak_ptr dbPing TC_LOG_INFO("server.bnetserver", "Ping MySQL to keep connection alive"); LoginDatabase.KeepAlive(); - dbPingTimer->expires_from_now(boost::posix_time::minutes(dbPingInterval)); + dbPingTimer->expires_after(std::chrono::minutes(dbPingInterval)); dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, dbPingTimerRef, dbPingInterval, std::placeholders::_1)); } } @@ -299,7 +299,7 @@ void ServiceStatusWatcher(std::weak_ptr serviceSta } else if (std::shared_ptr serviceStatusWatchTimer = serviceStatusWatchTimerRef.lock()) { - serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1)); + serviceStatusWatchTimer->expires_after(1s); serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher, serviceStatusWatchTimerRef, ioContext, std::placeholders::_1)); } } diff --git a/src/server/bnetserver/Realms/BNetRealmList.cpp b/src/server/bnetserver/Realms/BNetRealmList.cpp index 8aa22c40a2..34665c01a1 100644 --- a/src/server/bnetserver/Realms/BNetRealmList.cpp +++ b/src/server/bnetserver/Realms/BNetRealmList.cpp @@ -206,7 +206,7 @@ void BNetRealmList::UpdateRealms(boost::system::error_code const& error) if (_updateInterval) { - _updateTimer->expires_from_now(boost::posix_time::seconds(_updateInterval)); + _updateTimer->expires_after(std::chrono::seconds(_updateInterval)); _updateTimer->async_wait(std::bind(&BNetRealmList::UpdateRealms, this, std::placeholders::_1)); } } diff --git a/src/server/database/Updater/UpdateFetcher.cpp b/src/server/database/Updater/UpdateFetcher.cpp index 6e9ecfc146..1305dc409e 100644 --- a/src/server/database/Updater/UpdateFetcher.cpp +++ b/src/server/database/Updater/UpdateFetcher.cpp @@ -17,12 +17,14 @@ #include "UpdateFetcher.h" #include "Common.h" +#include "Duration.h" #include "DBUpdater.h" #include "Field.h" #include "Log.h" #include "QueryResult.h" #include "Util.h" #include "SHA1.h" +#include #include #include #include diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 1fd39ade25..ab947aafa3 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -16,6 +16,7 @@ */ #include "UnitAI.h" +#include "Containers.h" #include "Creature.h" #include "CreatureAIImpl.h" #include "MotionMaster.h" @@ -265,14 +266,97 @@ void UnitAI::FillAISpellInfo() } } -ThreatManager& UnitAI::GetThreatManager() +Unit* UnitAI::FinalizeTargetSelection(std::list& targetList, SelectAggroTarget targetType) { - return me->GetThreatManager(); + // maybe nothing fulfills the predicate + if (targetList.empty()) + return nullptr; + + switch (targetType) + { + case SELECT_TARGET_MAXTHREAT: + case SELECT_TARGET_MINTHREAT: + case SELECT_TARGET_MAXDISTANCE: + case SELECT_TARGET_MINDISTANCE: + return targetList.front(); + case SELECT_TARGET_RANDOM: + return Trinity::Containers::SelectRandomContainerElement(targetList); + default: + break; + } + + return nullptr; } -void UnitAI::SortByDistance(std::list& list, bool ascending) +bool UnitAI::PrepareTargetListSelection(std::list& targetList, SelectAggroTarget targetType, uint32 offset) { - list.sort(Trinity::ObjectDistanceOrderPred(me, ascending)); + targetList.clear(); + ThreatManager& mgr = me->GetThreatManager(); + // shortcut: we're gonna ignore the first elements, and there's at most elements, so we ignore them all - nothing to do here + if (mgr.GetThreatListSize() <= offset) + return false; + + if (targetType == SELECT_TARGET_MAXDISTANCE || targetType == SELECT_TARGET_MINDISTANCE) + { + for (ThreatReference const* ref : mgr.GetUnsortedThreatList()) + { + if (ref->IsOffline()) + continue; + + targetList.push_back(ref->GetVictim()); + } + } + else + { + Unit* currentVictim = mgr.GetCurrentVictim(); + if (currentVictim) + targetList.push_back(currentVictim); + + for (ThreatReference const* ref : mgr.GetSortedThreatList()) + { + if (ref->IsOffline()) + continue; + + Unit* thisTarget = ref->GetVictim(); + if (thisTarget != currentVictim) + targetList.push_back(thisTarget); + } + } + + // shortcut: the list isn't gonna get any larger + if (targetList.size() <= offset) + { + targetList.clear(); + return false; + } + + // right now, list is unsorted for DISTANCE types - re-sort by SelectTargetMethod::MaxDistance + if (targetType == SELECT_TARGET_MAXDISTANCE || targetType == SELECT_TARGET_MINDISTANCE) + targetList.sort(Trinity::ObjectDistanceOrderPred(me, targetType == SELECT_TARGET_MINDISTANCE)); + + // now the list is MAX sorted, reverse for MIN types + if (targetType == SELECT_TARGET_MINTHREAT) + targetList.reverse(); + + // ignore the first elements + while (offset) + { + targetList.pop_front(); + --offset; + } + + return true; +} + +void UnitAI::FinalizeTargetListSelection(std::list& targetList, uint32 num, SelectAggroTarget targetType) +{ + if (targetList.size() <= num) + return; + + if (targetType == SELECT_TARGET_RANDOM) + Trinity::Containers::RandomResize(targetList, num); + else + targetList.resize(num); } DefaultTargetSelector::DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, bool withTank, int32 aura) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 6d43b5d1ee..ca32ee8e92 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -18,12 +18,11 @@ #ifndef TRINITY_UNITAI_H #define TRINITY_UNITAI_H -#include "Containers.h" #include "Errors.h" #include "EventMap.h" #include "ObjectGuid.h" +#include "SharedDefines.h" #include "SpellDefines.h" -#include "ThreatManager.h" #define CAST_AI(a, b) (dynamic_cast(b)) #define ENSURE_AI(a,b) (EnsureAI(b)) @@ -170,30 +169,10 @@ class TC_GAME_API UnitAI template Unit* SelectTarget(SelectAggroTarget targetType, uint32 offset, PREDICATE const& predicate) { - ThreatManager& mgr = GetThreatManager(); - // shortcut: if we ignore the first elements, and there are at most elements, then we ignore ALL elements - if (mgr.GetThreatListSize() <= offset) - return nullptr; - std::list targetList; - SelectTargetList(targetList, mgr.GetThreatListSize(), targetType, offset, predicate); + SelectTargetList(targetList, std::numeric_limits::max(), targetType, offset, predicate); - // maybe nothing fulfills the predicate - if (targetList.empty()) - return nullptr; - - switch (targetType) - { - case SELECT_TARGET_MAXTHREAT: - case SELECT_TARGET_MINTHREAT: - case SELECT_TARGET_MAXDISTANCE: - case SELECT_TARGET_MINDISTANCE: - return targetList.front(); - case SELECT_TARGET_RANDOM: - return Trinity::Containers::SelectRandomContainerElement(targetList); - default: - return nullptr; - } + return FinalizeTargetSelection(targetList, targetType); } // Select the best (up to) targets (in order) from the threat list that fulfill the following: @@ -212,71 +191,13 @@ class TC_GAME_API UnitAI template void SelectTargetList(std::list& targetList, uint32 num, SelectAggroTarget targetType, uint32 offset, PREDICATE const& predicate) { - targetList.clear(); - ThreatManager& mgr = GetThreatManager(); - // shortcut: we're gonna ignore the first elements, and there's at most elements, so we ignore them all - nothing to do here - if (mgr.GetThreatListSize() <= offset) + if (!PrepareTargetListSelection(targetList, targetType, offset)) return; - if (targetType == SELECT_TARGET_MAXDISTANCE || targetType == SELECT_TARGET_MINDISTANCE) - { - for (ThreatReference const* ref : mgr.GetUnsortedThreatList()) - { - if (ref->IsOffline()) - continue; - - targetList.push_back(ref->GetVictim()); - } - } - else - { - Unit* currentVictim = mgr.GetCurrentVictim(); - if (currentVictim) - targetList.push_back(currentVictim); - - for (ThreatReference const* ref : mgr.GetSortedThreatList()) - { - if (ref->IsOffline()) - continue; - - Unit* thisTarget = ref->GetVictim(); - if (thisTarget != currentVictim) - targetList.push_back(thisTarget); - } - } - - // shortcut: the list isn't gonna get any larger - if (targetList.size() <= offset) - { - targetList.clear(); - return; - } - - // right now, list is unsorted for DISTANCE types - re-sort by MAXDISTANCE - if (targetType == SELECT_TARGET_MAXDISTANCE || targetType == SELECT_TARGET_MINDISTANCE) - SortByDistance(targetList, targetType == SELECT_TARGET_MINDISTANCE); - - // now the list is MAX sorted, reverse for MIN types - if (targetType == SELECT_TARGET_MINTHREAT) - targetList.reverse(); - - // ignore the first elements - while (offset) - { - targetList.pop_front(); - --offset; - } - // then finally filter by predicate targetList.remove_if([&predicate](Unit* target) { return !predicate(target); }); - if (targetList.size() <= num) - return; - - if (targetType == SELECT_TARGET_RANDOM) - Trinity::Containers::RandomResize(targetList, num); - else - targetList.resize(num); + FinalizeTargetListSelection(targetList, num, targetType); } // Called when the unit enters combat @@ -330,8 +251,9 @@ class TC_GAME_API UnitAI UnitAI(UnitAI const& right) = delete; UnitAI& operator=(UnitAI const& right) = delete; - ThreatManager& GetThreatManager(); - void SortByDistance(std::list& list, bool ascending = true); + Unit* FinalizeTargetSelection(std::list& targetList, SelectAggroTarget targetType); + bool PrepareTargetListSelection(std::list& targetList, SelectAggroTarget targetType, uint32 offset); + void FinalizeTargetListSelection(std::list& targetList, uint32 num, SelectAggroTarget targetType); }; #endif diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index da7d4cf170..646b6a1257 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -32,6 +32,7 @@ #include "SpellHistory.h" #include "TemporarySummon.h" #include "Vehicle.h" +#include //Disable CreatureAI when charmed void CreatureAI::OnCharmed(bool isNew) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 7511521aa1..cdce02e0b2 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -19,6 +19,7 @@ #include "AreaBoundary.h" #include "Cell.h" #include "CellImpl.h" +#include "Containers.h" #include "DBCStores.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -111,9 +112,12 @@ bool SummonList::HasEntry(uint32 entry) const return false; } -void SummonList::DoActionImpl(int32 action, StorageType const& summons) +void SummonList::DoActionImpl(int32 action, StorageType& summons, uint16 max) { - for (auto const& guid : summons) + if (max) + Trinity::Containers::RandomResize(summons, max); + + for (ObjectGuid const& guid : summons) { Creature* summon = ObjectAccessor::GetCreature(*me, guid); if (summon && summon->IsAIEnabled()) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index fccf04119d..1251a73beb 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -97,9 +97,9 @@ public: void DoAction(int32 info, Predicate&& predicate, uint16 max = 0) { // We need to use a copy of SummonList here, otherwise original SummonList would be modified - StorageType listCopy = storage_; - Trinity::Containers::RandomResize(listCopy, std::forward(predicate), max); - DoActionImpl(info, listCopy); + StorageType listCopy; + std::copy_if(std::begin(storage_), std::end(storage_), std::inserter(listCopy, std::end(listCopy)), predicate); + DoActionImpl(info, listCopy, max); } void DoZoneInCombat(uint32 entry = 0); @@ -107,7 +107,7 @@ public: bool HasEntry(uint32 entry) const; private: - void DoActionImpl(int32 action, StorageType const& summons); + void DoActionImpl(int32 action, StorageType& summons, uint16 max); Creature* me; StorageType storage_; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index fd4aee50d5..693750eb97 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -21,6 +21,7 @@ #include "Creature.h" #include "CreatureTextMgr.h" #include "CreatureTextMgrImpl.h" +#include "Containers.h" #include "GameEventMgr.h" #include "GameObject.h" #include "GossipDef.h" diff --git a/src/server/game/Chat/ChatCommands/ChatCommand.h b/src/server/game/Chat/ChatCommands/ChatCommand.h index c1d6547921..1dd891e5ae 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommand.h +++ b/src/server/game/Chat/ChatCommands/ChatCommand.h @@ -18,7 +18,6 @@ #ifndef TRINITY_CHATCOMMAND_H #define TRINITY_CHATCOMMAND_H -#include "advstd.h" #include "ChatCommandArgs.h" #include "ChatCommandTags.h" #include "Define.h" @@ -169,7 +168,7 @@ class TC_GAME_API CommandArgs template auto TryConsume() { - Optional, advstd::remove_cvref_t, advstd::remove_cvref_t...>> rv; + Optional, std::remove_cvref_t, std::remove_cvref_t...>> rv; rv.emplace(); if (!TryConsumeToTuple<0>(rv.value())) rv = std::nullopt; @@ -179,7 +178,7 @@ class TC_GAME_API CommandArgs template auto TryConsume() { - using T = advstd::remove_cvref_t; + using T = std::remove_cvref_t; Optional rv; rv.emplace(); if (char const* next = CommandArgsConsumerSingle::TryConsumeTo(rv.value(), _args)) @@ -214,8 +213,8 @@ class TC_GAME_API CommandArgs char const* _args; }; -template struct ChatCommandHandlerToTuple { static_assert(!advstd::is_same_v, "Invalid command handler signature"); }; -template struct ChatCommandHandlerToTuple { using type = std::tuple...>; }; +template struct ChatCommandHandlerToTuple { static_assert(!std::is_same_v, "Invalid command handler signature"); }; +template struct ChatCommandHandlerToTuple { using type = std::tuple...>; }; template struct ChatCommandStoreLastArg { static void store(T&, CommandArgs&) {} }; template <> struct ChatCommandStoreLastArg { static void store(char const*& arg, CommandArgs& args) { arg = args.GetRemainingArgs(); } }; @@ -240,9 +239,9 @@ class TC_GAME_API ChatCommand CommandArgs args(argsStr); if (args.TryConsumeToTuple<1>(arguments)) { - auto& last = std::get-1>(arguments); - ChatCommandStoreLastArg>::store(last, args); - return advstd::apply(reinterpret_cast(handler), std::move(arguments)); + auto& last = std::get-1>(arguments); + ChatCommandStoreLastArg>::store(last, args); + return std::apply(reinterpret_cast(handler), std::move(arguments)); } else return false; diff --git a/src/server/game/Chat/ChatCommands/ChatCommandArgs.h b/src/server/game/Chat/ChatCommands/ChatCommandArgs.h index c347801bea..b0a34d294f 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandArgs.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandArgs.h @@ -37,11 +37,11 @@ namespace ChatCommands { |* *| \****************************************************************************************/ template -struct ArgInfo { static_assert(!advstd::is_same_v, "Invalid command parameter type - see ChatCommandArgs.h for possible types"); }; +struct ArgInfo { static_assert(!std::is_same_v, "Invalid command parameter type - see ChatCommandArgs.h for possible types"); }; // catch-all for signed integral types template -struct ArgInfo && advstd::is_signed_v>> +struct ArgInfo && std::is_signed_v>> { static char const* TryConsume(T& val, char const* args) { @@ -55,7 +55,7 @@ struct ArgInfo && advstd::is_signed // catch-all for unsigned integral types template -struct ArgInfo && advstd::is_unsigned_v>> +struct ArgInfo && std::is_unsigned_v>> { static char const* TryConsume(T& val, char const* args) { @@ -69,7 +69,7 @@ struct ArgInfo && advstd::is_unsign // catch-all for floating point types template -struct ArgInfo>> +struct ArgInfo>> { static char const* TryConsume(T& val, char const* args) { @@ -100,7 +100,7 @@ struct ArgInfo // a container tag template -struct ArgInfo>> +struct ArgInfo>> { static char const* TryConsume(T& tag, char const* args) { diff --git a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h index fecf046f15..7b8a3ad5b8 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h @@ -55,7 +55,7 @@ struct are_all_assignable template struct are_all_assignable { - static constexpr bool value = advstd::is_assignable_v && are_all_assignable::value; + static constexpr bool value = std::is_assignable_v && are_all_assignable::value; }; template diff --git a/src/server/game/Chat/ChatCommands/ChatCommandHyperlinks.h b/src/server/game/Chat/ChatCommands/ChatCommandHyperlinks.h index 456da70867..a93821ab3d 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandHyperlinks.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandHyperlinks.h @@ -32,7 +32,7 @@ template struct Hyperlink : public ContainerTag { typedef typename linktag::value_type value_type; - typedef advstd::remove_cvref_t storage_type; + typedef std::remove_cvref_t storage_type; public: operator value_type() const { return val; } @@ -105,7 +105,7 @@ struct base_tag } template - static std::enable_if_t && advstd::is_unsigned_v, bool> StoreTo(T& val, char const* pos, size_t len) + static std::enable_if_t && std::is_unsigned_v, bool> StoreTo(T& val, char const* pos, size_t len) { try { val = std::stoull(std::string(pos, len)); } catch (...) { return false; } @@ -113,7 +113,7 @@ struct base_tag } template - static std::enable_if_t && advstd::is_signed_v, bool> StoreTo(T& val, char const* pos, size_t len) + static std::enable_if_t && std::is_signed_v, bool> StoreTo(T& val, char const* pos, size_t len) { try { val = std::stoll(std::string(pos, len)); } catch (...) { return false; } diff --git a/src/server/game/Chat/ChatCommands/ChatCommandTags.h b/src/server/game/Chat/ChatCommands/ChatCommandTags.h index 92b1bd62c0..a2cd8385dc 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandTags.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandTags.h @@ -42,7 +42,7 @@ namespace ChatCommands { \****************************************************************************************/ struct ContainerTag {}; template -struct tag_base>> +struct tag_base>> { using type = typename T::value_type; }; diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 1f15dee576..f911f92b0e 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -19,6 +19,7 @@ #include "Creature.h" #include "CreatureAI.h" #include "CreatureGroups.h" +#include "Containers.h" #include "MotionMaster.h" #include "Player.h" #include "TemporarySummon.h" @@ -32,9 +33,14 @@ #include "ObjectAccessor.h" #include "WorldPacket.h" #include +#include const CompareThreatLessThan ThreatManager::CompareThreat; +class ThreatManager::Heap : public boost::heap::fibonacci_heap> +{ +}; + void ThreatReference::AddThreat(float amount) { if (amount == 0.0f) @@ -151,6 +157,24 @@ void ThreatReference::UnregisterAndFree() delete this; } +class ThreatReferenceImpl : public ThreatReference +{ +public: + explicit ThreatReferenceImpl(ThreatManager* mgr, Unit* victim) : ThreatReference(mgr, victim) {} + + ThreatManager::Heap::handle_type _handle; +}; + +void ThreatReference::HeapNotifyIncreased() +{ + _mgr._sortedThreatList->increase(static_cast(this)->_handle); +} + +void ThreatReference::HeapNotifyDecreased() +{ + _mgr._sortedThreatList->decrease(static_cast(this)->_handle); +} + /*static*/ bool ThreatManager::CanHaveThreatList(Unit const* who) { Creature const* cWho = who->ToCreature(); @@ -171,7 +195,8 @@ void ThreatReference::UnregisterAndFree() return true; } -ThreatManager::ThreatManager(Unit* owner) : _owner(owner), _ownerCanHaveThreatList(false), _needClientUpdate(false), _updateTimer(THREAT_UPDATE_INTERVAL), _currentVictimRef(nullptr), _fixateRef(nullptr) +ThreatManager::ThreatManager(Unit* owner) : _owner(owner), _ownerCanHaveThreatList(false), _needClientUpdate(false), _updateTimer(THREAT_UPDATE_INTERVAL), + _sortedThreatList(std::make_unique()), _currentVictimRef(nullptr), _fixateRef(nullptr) { for (int8 i = 0; i < MAX_SPELL_SCHOOL; ++i) _singleSchoolModifiers[i] = 1.0f; @@ -180,7 +205,7 @@ ThreatManager::ThreatManager(Unit* owner) : _owner(owner), _ownerCanHaveThreatLi ThreatManager::~ThreatManager() { ASSERT(_myThreatListEntries.empty(), "ThreatManager::~ThreatManager - %s: we still have %zu things threatening us, one of them is %s.", _owner->GetGUID().ToString().c_str(), _myThreatListEntries.size(), _myThreatListEntries.begin()->first.ToString().c_str()); - ASSERT(_sortedThreatList.empty(), "ThreatManager::~ThreatManager - %s: we still have %zu things threatening us, one of them is %s.", _owner->GetGUID().ToString().c_str(), _sortedThreatList.size(), (*_sortedThreatList.begin())->GetVictim()->GetGUID().ToString().c_str()); + ASSERT(_sortedThreatList->empty(), "ThreatManager::~ThreatManager - %s: we still have %zu things threatening us, one of them is %s.", _owner->GetGUID().ToString().c_str(), _sortedThreatList->size(), (*_sortedThreatList->begin())->GetVictim()->GetGUID().ToString().c_str()); ASSERT(_threatenedByMe.empty(), "ThreatManager::~ThreatManager - %s: we are still threatening %zu things, one of them is %s.", _owner->GetGUID().ToString().c_str(), _threatenedByMe.size(), _threatenedByMe.begin()->first.ToString().c_str()); } @@ -219,7 +244,7 @@ Unit* ThreatManager::GetLastVictim() const Unit* ThreatManager::GetAnyTarget() const { - for (ThreatReference const* ref : _sortedThreatList) + for (ThreatReference const* ref : *_sortedThreatList) if (!ref->IsOffline()) return ref->GetVictim(); return nullptr; @@ -228,8 +253,8 @@ Unit* ThreatManager::GetAnyTarget() const bool ThreatManager::IsThreatListEmpty(bool includeOffline) const { if (includeOffline) - return _sortedThreatList.empty(); - for (ThreatReference const* ref : _sortedThreatList) + return _sortedThreatList->empty(); + for (ThreatReference const* ref : *_sortedThreatList) if (ref->IsAvailable()) return false; return true; @@ -252,11 +277,44 @@ float ThreatManager::GetThreat(Unit const* who, bool includeOffline) const return (includeOffline || it->second->IsAvailable()) ? it->second->GetThreat() : 0.0f; } +size_t ThreatManager::GetThreatListSize() const +{ + return _sortedThreatList->size(); +} + +Trinity::IteratorPair ThreatManager::GetUnsortedThreatList() const +{ + auto itr = _myThreatListEntries.begin(); + auto end = _myThreatListEntries.end(); + std::function generator = [itr, end]() mutable -> ThreatReference const* + { + if (itr == end) + return nullptr; + + return (itr++)->second; + }; + return { ThreatListIterator{ std::move(generator) }, nullptr }; +} + +Trinity::IteratorPair ThreatManager::GetSortedThreatList() const +{ + auto itr = _sortedThreatList->ordered_begin(); + auto end = _sortedThreatList->ordered_end(); + std::function generator = [itr, end]() mutable -> ThreatReference const* + { + if (itr == end) + return nullptr; + + return *(itr++); + }; + return { ThreatListIterator{ std::move(generator) }, nullptr }; +} + std::vector ThreatManager::GetModifiableThreatList() { std::vector list; list.reserve(_myThreatListEntries.size()); - for (auto it = _sortedThreatList.ordered_begin(), end = _sortedThreatList.ordered_end(); it != end; ++it) + for (auto it = _sortedThreatList->ordered_begin(), end = _sortedThreatList->ordered_end(); it != end; ++it) list.push_back(const_cast(*it)); return list; } @@ -388,7 +446,7 @@ void ThreatManager::AddThreat(Unit* target, float amount, SpellInfo const* spell } // ok, we're now in combat - create the threat list reference and push it to the respective managers - ThreatReference* ref = new ThreatReference(this, target); + ThreatReference* ref = new ThreatReferenceImpl(this, target); PutThreatListRef(target->GetGUID(), ref); target->GetThreatManager().PutThreatenedByMeRef(_owner->GetGUID(), ref); @@ -411,10 +469,10 @@ void ThreatManager::ScaleThreat(Unit* target, float factor) void ThreatManager::MatchUnitThreatToHighestThreat(Unit* target) { - if (_sortedThreatList.empty()) + if (_sortedThreatList->empty()) return; - auto it = _sortedThreatList.ordered_begin(), end = _sortedThreatList.ordered_end(); + auto it = _sortedThreatList->ordered_begin(), end = _sortedThreatList->ordered_end(); ThreatReference const* highest = *it; if (!highest->IsAvailable()) return; @@ -523,7 +581,7 @@ void ThreatManager::UpdateVictim() ThreatReference const* ThreatManager::ReselectVictim() { - if (_sortedThreatList.empty()) + if (_sortedThreatList->empty()) return nullptr; for (auto const& pair : _myThreatListEntries) @@ -537,7 +595,7 @@ ThreatReference const* ThreatManager::ReselectVictim() if (oldVictimRef && oldVictimRef->IsOffline()) oldVictimRef = nullptr; // in 99% of cases - we won't need to actually look at anything beyond the first element - ThreatReference const* highest = _sortedThreatList.top(); + ThreatReference const* highest = _sortedThreatList->top(); // if the highest reference is offline, the entire list is offline, and we indicate this if (!highest->IsAvailable()) return nullptr; @@ -555,7 +613,7 @@ ThreatReference const* ThreatManager::ReselectVictim() return highest; // If we get here, highest threat is ranged, but below 130% of current - there might be a melee that breaks 110% below us somewhere, so now we need to actually look at the next highest element // luckily, this is a heap, so getting the next highest element is O(log n), and we're just gonna do that repeatedly until we've seen enough targets (or find a target) - auto it = _sortedThreatList.ordered_begin(), end = _sortedThreatList.ordered_end(); + auto it = _sortedThreatList->ordered_begin(), end = _sortedThreatList->ordered_end(); while (it != end) { ThreatReference const* next = *it; @@ -763,45 +821,33 @@ void ThreatManager::SendRemoveToClients(Unit const* victim) const void ThreatManager::SendThreatListToClients(bool newHighest) const { - uint32 availableReferences = 0; - for (ThreatReference const* ref : _sortedThreatList) - if (ref->IsAvailable()) - ++availableReferences; + auto fillSharedPacketDataAndSend = [&](auto& packet) + { + packet.UnitGUID = _owner->GetGUID(); + packet.ThreatList.reserve(_sortedThreatList->size()); + for (ThreatReference const* ref : *_sortedThreatList) + { + if (!ref->IsAvailable()) + continue; + + WorldPackets::Combat::ThreatInfo threatInfo; + threatInfo.UnitGUID = ref->GetVictim()->GetGUID(); + threatInfo.Threat = int64(ref->GetThreat() * 100); + packet.ThreatList.push_back(threatInfo); + } + _owner->SendMessageToSet(packet.Write(), false); + }; if (newHighest) { - WorldPackets::Combat::HighestThreatUpdate packet; - packet.UnitGUID = _owner->GetGUID(); - packet.HighestThreatGUID = _currentVictimRef->GetVictim()->GetGUID(); - packet.ThreatList.reserve(availableReferences); - for (ThreatReference const* ref : _sortedThreatList) - { - if (!ref->IsAvailable()) - continue; - - WorldPackets::Combat::ThreatInfo info; - info.UnitGUID = ref->GetVictim()->GetGUID(); - info.Threat = uint32(ref->GetThreat() * 100); - packet.ThreatList.push_back(info); - } - _owner->SendMessageToSet(packet.Write(), false); + WorldPackets::Combat::HighestThreatUpdate highestThreatUpdate; + highestThreatUpdate.HighestThreatGUID = _currentVictimRef->GetVictim()->GetGUID(); + fillSharedPacketDataAndSend(highestThreatUpdate); } else { - WorldPackets::Combat::ThreatUpdate packet; - packet.UnitGUID = _owner->GetGUID(); - packet.ThreatList.reserve(availableReferences); - for (ThreatReference const* ref : _sortedThreatList) - { - if (!ref->IsAvailable()) - continue; - - WorldPackets::Combat::ThreatInfo info; - info.UnitGUID = ref->GetVictim()->GetGUID(); - info.Threat = uint32(ref->GetThreat() * 100); - packet.ThreatList.push_back(info); - } - _owner->SendMessageToSet(packet.Write(), false); + WorldPackets::Combat::ThreatUpdate threatUpdate; + fillSharedPacketDataAndSend(threatUpdate); } } @@ -811,7 +857,7 @@ void ThreatManager::PutThreatListRef(ObjectGuid const& guid, ThreatReference* re auto& inMap = _myThreatListEntries[guid]; ASSERT(!inMap, "Duplicate threat reference at %p being inserted on %s for %s - memory leak!", ref, _owner->GetGUID().ToString().c_str(), guid.ToString().c_str()); inMap = ref; - ref->_handle = _sortedThreatList.push(ref); + static_cast(ref)->_handle = _sortedThreatList->push(ref); } void ThreatManager::PurgeThreatListRef(ObjectGuid const& guid) @@ -821,7 +867,7 @@ void ThreatManager::PurgeThreatListRef(ObjectGuid const& guid) return; ThreatReference* ref = it->second; _myThreatListEntries.erase(it); - _sortedThreatList.erase(ref->_handle); + _sortedThreatList->erase(static_cast(ref)->_handle); if (_fixateRef == ref) _fixateRef = nullptr; diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index 7d238af551..8af17cb523 100644 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -22,7 +22,6 @@ #include "IteratorPair.h" #include "ObjectGuid.h" #include "SharedDefines.h" -#include #include #include #include @@ -81,7 +80,7 @@ struct CompareThreatLessThan class TC_GAME_API ThreatManager { public: - typedef boost::heap::fibonacci_heap> threat_list_heap; + class Heap; class ThreatListIterator; static const uint32 THREAT_UPDATE_INTERVAL = 1000u; @@ -115,14 +114,14 @@ class TC_GAME_API ThreatManager bool IsThreatenedBy(Unit const* who, bool includeOffline = false) const; // returns ThreatReference amount if a ref exists, 0.0f otherwise float GetThreat(Unit const* who, bool includeOffline = false) const; - size_t GetThreatListSize() const { return _sortedThreatList.size(); } + size_t GetThreatListSize() const; // fastest of the three threat list getters - gets the threat list in "arbitrary" order // iterators will invalidate on adding/removing entries from the threat list; slightly less finicky than GetSorted. - Trinity::IteratorPair GetUnsortedThreatList() const { return { _myThreatListEntries.begin(), _myThreatListEntries.end() }; } + Trinity::IteratorPair GetUnsortedThreatList() const; // slightly slower than GetUnsorted, but, well...sorted - only use it if you need the sorted property, of course // this iterator pair will invalidate on any modification (even indirect) of the threat list; spell casts and similar can all induce this! // note: current tank is NOT guaranteed to be the first entry in this list - check GetLastVictim separately if you want that! - Trinity::IteratorPair GetSortedThreatList() const { return { _sortedThreatList.ordered_begin(), _sortedThreatList.ordered_end() }; } + Trinity::IteratorPair GetSortedThreatList() const; // slowest of the three threat list getters (by far), but lets you modify the threat references - this is also sorted std::vector GetModifiableThreatList(); @@ -198,7 +197,7 @@ class TC_GAME_API ThreatManager bool _needClientUpdate; uint32 _updateTimer; - threat_list_heap _sortedThreatList; + std::unique_ptr _sortedThreatList; std::unordered_map _myThreatListEntries; // AI notifies are delayed to ensure we are in a consistent state before we call out to arbitrary logic @@ -231,19 +230,27 @@ class TC_GAME_API ThreatManager class ThreatListIterator { - private: - decltype(_myThreatListEntries)::const_iterator _it; + private: + std::function _generator; + ThreatReference const* _current; - public: - ThreatReference const* operator*() const { return _it->second; } - ThreatReference const* operator->() const { return _it->second; } - ThreatListIterator& operator++() { ++_it; return *this; } - bool operator==(ThreatListIterator const& o) const { return _it == o._it; } - bool operator!=(ThreatListIterator const& o) const { return _it != o._it; } - ThreatListIterator(decltype(_it) it) : _it(it) {} + friend ThreatManager; + explicit ThreatListIterator(std::function&& generator) + : _generator(std::move(generator)), _current(_generator()) { + } + + public: + ThreatReference const* operator*() const { return _current; } + ThreatReference const* operator->() const { return _current; } + ThreatListIterator& operator++() { _current = _generator(); return *this; } + bool operator==(ThreatListIterator const& o) const { return _current == o._current; } + bool operator!=(ThreatListIterator const& o) const { return _current != o._current; } + bool operator==(std::nullptr_t) const { return _current == nullptr; } + bool operator!=(std::nullptr_t) const { return _current != nullptr; } }; friend class ThreatReference; + friend class ThreatReferenceImpl; friend struct CompareThreatLessThan; friend class debug_commandscript; }; @@ -274,16 +281,18 @@ class TC_GAME_API ThreatReference void ClearThreat(); // dealloc's this - private: + protected: static bool FlagsAllowFighting(Unit const* a, Unit const* b); - ThreatReference(ThreatManager* mgr, Unit* victim) : + explicit ThreatReference(ThreatManager* mgr, Unit* victim) : _owner(reinterpret_cast(mgr->_owner)), _mgr(*mgr), _victim(victim), _baseAmount(0.0f), _tempModifier(0), _taunted(TAUNT_STATE_NONE) { _online = ONLINE_STATE_OFFLINE; } + virtual ~ThreatReference() = default; + void UnregisterAndFree(); bool ShouldBeOffline() const; @@ -291,14 +300,13 @@ class TC_GAME_API ThreatReference void UpdateTauntState(TauntState state = TAUNT_STATE_NONE); Creature* const _owner; ThreatManager& _mgr; - void HeapNotifyIncreased() { _mgr._sortedThreatList.increase(_handle); } - void HeapNotifyDecreased() { _mgr._sortedThreatList.decrease(_handle); } + void HeapNotifyIncreased(); + void HeapNotifyDecreased(); Unit* const _victim; OnlineState _online; float _baseAmount; int32 _tempModifier; // Temporary effects (auras with SPELL_AURA_MOD_TOTAL_THREAT) - set from victim's threatmanager in ThreatManager::UpdateMyTempModifiers TauntState _taunted; - ThreatManager::threat_list_heap::handle_type _handle; public: ThreatReference(ThreatReference const&) = delete; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 19041a65da..950519a072 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -19,6 +19,7 @@ #include "BattlegroundMgr.h" #include "CellImpl.h" #include "Common.h" +#include "Containers.h" #include "CreatureAI.h" #include "CreatureAISelector.h" #include "CreatureGroups.h" diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 2c9300c65d..761ce30e2f 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -19,6 +19,7 @@ #include "ArchaeologyMgr.h" #include "Battleground.h" #include "CellImpl.h" +#include "Containers.h" #include "CreatureAISelector.h" #include "DatabaseEnv.h" #include "DBCStores.h" diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1cfe7d6953..c544a44b44 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -31,6 +31,7 @@ #include "CombatPackets.h" #include "Common.h" #include "ConditionMgr.h" +#include "Containers.h" #include "CreatureAI.h" #include "CreatureAIImpl.h" #include "CreatureGroups.h" @@ -88,6 +89,7 @@ #include "WorldPacket.h" #include "WorldSession.h" #include +#include float baseMoveSpeed[MAX_MOVE_TYPE] = { diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 1294c99f20..fd03d0d0fb 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -42,6 +42,7 @@ #include #include #include +#include void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recvData*/) { @@ -845,7 +846,7 @@ void WorldSession::HandleTimeSyncResp(WorldPacket& recvData) serverTime = clockDelta + clientTime */ int64 clockDelta = (int64)(serverTimeAtSent + lagDelay) - (int64)clientTimestamp; - _timeSyncClockDeltaQueue.push_back(std::pair(clockDelta, roundTripDuration)); + _timeSyncClockDeltaQueue->push_back(std::pair(clockDelta, roundTripDuration)); ComputeNewClockDelta(); } @@ -858,19 +859,18 @@ void WorldSession::ComputeNewClockDelta() accumulator_set > latencyAccumulator; - for (auto pair : _timeSyncClockDeltaQueue) - latencyAccumulator(pair.second); + for (auto [_, roundTripDuration] : *_timeSyncClockDeltaQueue) + latencyAccumulator(roundTripDuration); uint32 latencyMedian = static_cast(std::round(median(latencyAccumulator))); uint32 latencyStandardDeviation = static_cast(std::round(sqrt(variance(latencyAccumulator)))); accumulator_set > clockDeltasAfterFiltering; uint32 sampleSizeAfterFiltering = 0; - for (auto pair : _timeSyncClockDeltaQueue) + for (auto [clockDelta, roundTripDuration] : *_timeSyncClockDeltaQueue) { - if (pair.second < latencyStandardDeviation + latencyMedian) - { - clockDeltasAfterFiltering(pair.first); + if (roundTripDuration < latencyStandardDeviation + latencyMedian) { + clockDeltasAfterFiltering(clockDelta); sampleSizeAfterFiltering++; } } @@ -882,8 +882,5 @@ void WorldSession::ComputeNewClockDelta() _timeSyncClockDelta = meanClockDelta; } else if (_timeSyncClockDelta == 0) - { - std::pair back = _timeSyncClockDeltaQueue.back(); - _timeSyncClockDelta = back.first; - } + _timeSyncClockDelta = _timeSyncClockDeltaQueue->back().first; } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index add7ce6f15..c78024d37e 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -19,6 +19,7 @@ #include "BattlefieldMgr.h" #include "Battleground.h" #include "CellImpl.h" +#include "Containers.h" #include "DatabaseEnv.h" #include "DBCStores.h" #include "DynamicTree.h" @@ -53,6 +54,7 @@ #include "World.h" #include "WorldStateMgr.h" #include "WorldStatePackets.h" +#include #include #include @@ -65,6 +67,18 @@ GridState* si_GridStates[MAX_GRID_STATE]; ZoneDynamicInfo::ZoneDynamicInfo() : MusicId(0), DefaultWeather(nullptr), WeatherId(WEATHER_STATE_FINE), Intensity(0.0f) { } +struct RespawnInfoWithHandle; +struct RespawnListContainer : boost::heap::fibonacci_heap> +{ +}; + +struct RespawnInfoWithHandle : RespawnInfo +{ + explicit RespawnInfoWithHandle(RespawnInfo const& other) : RespawnInfo(other) { } + + RespawnListContainer::handle_type handle; +}; + RespawnInfo::~RespawnInfo() = default; Map::~Map() @@ -125,7 +139,7 @@ m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_VisibilityNotifyPeriod(DEFAULT_VISIBILITY_NOTIFY_PERIOD), m_activeNonPlayersIter(m_activeNonPlayers.end()), _transportsUpdateIter(_transports.end()), i_gridExpiry(expiry), m_terrain(sTerrainMgr.LoadTerrain(id)), m_forceEnabledNavMeshFilterFlags(0), m_forceDisabledNavMeshFilterFlags(0), -i_scriptLock(false), _respawnCheckTimer(0) +i_scriptLock(false), _respawnTimes(std::make_unique()), _respawnCheckTimer(0) { for (uint32 x = 0; x < MAX_NUMBER_OF_GRIDS; ++x) { @@ -1874,7 +1888,7 @@ void Map::Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans) if (info->respawnTime <= GameTime::GetGameTime()) return; info->respawnTime = GameTime::GetGameTime(); - _respawnTimes.increase(info->handle); + _respawnTimes->increase(static_cast(info)->handle); SaveRespawnInfoDB(*info, dbTrans); } @@ -1928,8 +1942,8 @@ bool Map::AddRespawnInfo(RespawnInfo const& info) else ASSERT(false, "Invalid respawn info for spawn id (%u,%u) being inserted", uint32(info.type), info.spawnId); - RespawnInfo* ri = new RespawnInfo(info); - ri->handle = _respawnTimes.push(ri); + RespawnInfoWithHandle* ri = new RespawnInfoWithHandle(info); + ri->handle = _respawnTimes->push(ri); bySpawnIdMap.emplace(ri->spawnId, ri); return true; } @@ -1960,9 +1974,9 @@ RespawnInfo* Map::GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawn void Map::UnloadAllRespawnInfos() // delete everything from memory { - for (RespawnInfo* info : _respawnTimes) + for (RespawnInfo* info : *_respawnTimes) delete info; - _respawnTimes.clear(); + _respawnTimes->clear(); _creatureRespawnTimesBySpawnId.clear(); _gameObjectRespawnTimesBySpawnId.clear(); } @@ -1980,7 +1994,7 @@ void Map::DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTr spawnMap.erase(it); // respawn heap - _respawnTimes.erase(info->handle); + _respawnTimes->erase(static_cast(info)->handle); // database DeleteRespawnInfoFromDB(info->type, info->spawnId, dbTrans); @@ -2029,16 +2043,16 @@ void Map::DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gr void Map::ProcessRespawns() { time_t now = GameTime::GetGameTime(); - while (!_respawnTimes.empty()) + while (!_respawnTimes->empty()) { - RespawnInfo* next = _respawnTimes.top(); + RespawnInfoWithHandle* next = _respawnTimes->top(); if (now < next->respawnTime) // done for this tick break; if (uint32 poolId = sPoolMgr->IsPartOfAPool(next->type, next->spawnId)) // is this part of a pool? { // if yes, respawn will be handled by (external) pooling logic, just delete the respawn time // step 1: remove entry from maps to avoid it being reachable by outside logic - _respawnTimes.pop(); + _respawnTimes->pop(); GetRespawnMapForType(next->type).erase(next->spawnId); // step 2: tell pooling logic to do its thing @@ -2051,7 +2065,7 @@ void Map::ProcessRespawns() else if (CheckRespawn(next)) // see if we're allowed to respawn { // ok, respawn // step 1: remove entry from maps to avoid it being reachable by outside logic - _respawnTimes.pop(); + _respawnTimes->pop(); GetRespawnMapForType(next->type).erase(next->spawnId); // step 2: do the respawn, which involves external logic @@ -2063,7 +2077,7 @@ void Map::ProcessRespawns() } else if (!next->respawnTime) { // just remove this respawn entry without rescheduling - _respawnTimes.pop(); + _respawnTimes->pop(); GetRespawnMapForType(next->type).erase(next->spawnId); RemoveRespawnTime(next->type, next->spawnId, nullptr, true); delete next; @@ -2071,7 +2085,7 @@ void Map::ProcessRespawns() else { // new respawn time, update heap position ASSERT(now < next->respawnTime); // infinite loop guard - _respawnTimes.decrease(next->handle); + _respawnTimes->decrease(next->handle); SaveRespawnInfoDB(*next); } } @@ -2759,8 +2773,8 @@ void InstanceMap::Update(uint32 t_diff) { Map::Update(t_diff); - if (i_data) - i_data->Update(t_diff); + if (i_data) + i_data->Update(t_diff); } void InstanceMap::RemovePlayerFromMap(Player* player, bool remove) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index b1cbf09f65..0edaf0cd33 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -35,7 +35,6 @@ #include "WorldStateDefines.h" #include "Transaction.h" #include "Weather.h" -#include #include #include #include @@ -118,8 +117,7 @@ struct CompareRespawnInfo bool operator()(RespawnInfo const* a, RespawnInfo const* b) const; }; using ZoneDynamicInfoMap = std::unordered_map; -using RespawnListContainer = boost::heap::fibonacci_heap>; -using RespawnListHandle = RespawnListContainer::handle_type; +struct RespawnListContainer; using RespawnInfoMap = std::unordered_map; struct TC_GAME_API RespawnInfo { @@ -130,7 +128,6 @@ struct TC_GAME_API RespawnInfo uint32 entry; time_t respawnTime; uint32 gridId; - RespawnListHandle handle; }; inline bool CompareRespawnInfo::operator()(RespawnInfo const* a, RespawnInfo const* b) const { @@ -700,7 +697,7 @@ class TC_GAME_API Map : public GridRefManager m_activeNonPlayers.erase(obj); } - RespawnListContainer _respawnTimes; + std::unique_ptr _respawnTimes; RespawnInfoMap _creatureRespawnTimesBySpawnId; RespawnInfoMap _gameObjectRespawnTimesBySpawnId; RespawnInfoMap& GetRespawnMapForType(SpawnObjectType type) diff --git a/src/server/game/Phasing/PhaseShift.h b/src/server/game/Phasing/PhaseShift.h index 0fadbcc42d..530b5db892 100644 --- a/src/server/game/Phasing/PhaseShift.h +++ b/src/server/game/Phasing/PhaseShift.h @@ -20,8 +20,8 @@ #include "Define.h" #include "EnumFlag.h" +#include "FlatSet.h" #include "ObjectGuid.h" -#include #include class PhasingHandler; @@ -81,7 +81,7 @@ public: typename Container::iterator Iterator; bool Erased; }; - typedef boost::container::flat_set PhaseContainer; + using PhaseContainer = Trinity::Containers::FlatSet; typedef std::map VisibleMapIdContainer; typedef std::map UiMapPhaseIdContainer; diff --git a/src/server/game/Server/Packets/PacketUtilities.h b/src/server/game/Server/Packets/PacketUtilities.h index 1ed6efb12b..61b252bdf8 100644 --- a/src/server/game/Server/Packets/PacketUtilities.h +++ b/src/server/game/Server/Packets/PacketUtilities.h @@ -19,6 +19,7 @@ #define PacketUtilities_h__ #include "ByteBuffer.h" +#include namespace WorldPackets { @@ -31,21 +32,49 @@ namespace WorldPackets /** * Utility class for automated prevention of loop counter spoofing in client packets */ - template + template class Array { - typedef std::vector storage_type; - - typedef typename storage_type::value_type value_type; - typedef typename storage_type::size_type size_type; - typedef typename storage_type::reference reference; - typedef typename storage_type::const_reference const_reference; - typedef typename storage_type::iterator iterator; - typedef typename storage_type::const_iterator const_iterator; - public: - Array() : _limit(N) { } - Array(size_type limit) : _limit(limit) { } + using allocator_type = short_alloc::short_alloc; + using arena_type = typename allocator_type::arena_type; + + using storage_type = std::vector; + + using max_capacity = std::integral_constant; + + using value_type = typename storage_type::value_type; + using size_type = typename storage_type::size_type; + using pointer = typename storage_type::pointer; + using const_pointer = typename storage_type::const_pointer; + using reference = typename storage_type::reference; + using const_reference = typename storage_type::const_reference; + using iterator = typename storage_type::iterator; + using const_iterator = typename storage_type::const_iterator; + + Array() : _storage(_data) {} + + Array(Array const& other) : Array() + { + for (T const& element : other) + _storage.push_back(element); + } + + Array(Array&& other) noexcept = delete; + + Array& operator=(Array const& other) + { + if (this == &other) + return *this; + + _storage.clear(); + for (T const& element : other) + _storage.push_back(element); + + return *this; + } + + Array& operator=(Array&& other) noexcept = delete; iterator begin() { return _storage.begin(); } const_iterator begin() const { return _storage.begin(); } @@ -53,6 +82,9 @@ namespace WorldPackets iterator end() { return _storage.end(); } const_iterator end() const { return _storage.end(); } + pointer data() { return _storage.data(); } + const_pointer data() const { return _storage.data(); } + size_type size() const { return _storage.size(); } bool empty() const { return _storage.empty(); } @@ -61,39 +93,48 @@ namespace WorldPackets void resize(size_type newSize) { - if (newSize > _limit) - throw PacketArrayMaxCapacityException(newSize, _limit); + if (newSize > max_capacity::value) + throw PacketArrayMaxCapacityException(newSize, max_capacity::value); _storage.resize(newSize); } - void reserve(size_type newSize) - { - if (newSize > _limit) - throw PacketArrayMaxCapacityException(newSize, _limit); - - _storage.reserve(newSize); - } - void push_back(value_type const& value) { - if (_storage.size() >= _limit) - throw PacketArrayMaxCapacityException(_storage.size() + 1, _limit); + if (_storage.size() >= max_capacity::value) + throw PacketArrayMaxCapacityException(_storage.size() + 1, max_capacity::value); _storage.push_back(value); } void push_back(value_type&& value) { - if (_storage.size() >= _limit) - throw PacketArrayMaxCapacityException(_storage.size() + 1, _limit); + if (_storage.size() >= max_capacity::value) + throw PacketArrayMaxCapacityException(_storage.size() + 1, max_capacity::value); _storage.push_back(std::forward(value)); } + template + T& emplace_back(Args&&... args) + { + _storage.emplace_back(std::forward(args)...); + return _storage.back(); + } + + iterator erase(const_iterator first, const_iterator last) + { + return _storage.erase(first, last); + } + + void clear() + { + _storage.clear(); + } + private: + arena_type _data; storage_type _storage; - size_type _limit; }; void CheckCompactArrayMaskOverflow(std::size_t index, std::size_t limit); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index d076f5c2fa..9b9a1592ff 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -55,6 +55,7 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSocket.h" +#include #include namespace { @@ -136,7 +137,7 @@ WorldSession::WorldSession(uint32 id, std::string&& name, uint32 battlenetAccoun expireTime(60000), // 1 min after socket loss, session is deleted forceExit(false), m_currentBankerGUID(), - _timeSyncClockDeltaQueue(6), + _timeSyncClockDeltaQueue(std::make_unique>>(6)), _timeSyncClockDelta(0), _pendingTimeSyncRequests(), _gameClient(new GameClient(this)) diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 1a617533bc..c9efd5c196 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -31,7 +31,7 @@ #include "SharedDefines.h" #include #include -#include +#include class BigNumber; class Creature; @@ -1415,7 +1415,7 @@ class TC_GAME_API WorldSession bool forceExit; ObjectGuid m_currentBankerGUID; - boost::circular_buffer> _timeSyncClockDeltaQueue; // first member: clockDelta. Second member: latency of the packet exchange that was used to compute that clockDelta. + std::unique_ptr>> _timeSyncClockDeltaQueue; // first member: clockDelta. Second member: latency of the packet exchange that was used to compute that clockDelta. int64 _timeSyncClockDelta; void ComputeNewClockDelta(); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index e8da74545c..7153c0787d 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -21,6 +21,7 @@ #include "Battleground.h" #include "CellImpl.h" #include "Common.h" +#include "Containers.h" #include "DatabaseEnv.h" #include "DBCStores.h" #include "DB2Stores.h" @@ -4807,7 +4808,7 @@ static std::pair CalcPredictedHealing(SpellInfo points += unitCaster->SpellHealingBonusDone(target, spellInfo, spellEffectInfo.CalcValue(unitCaster, nullptr, target), DIRECT_DAMAGE, i, 1, spell); - + if (target != unitCaster && (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER || spellEffectInfo.TargetB.GetTarget() == TARGET_UNIT_CASTER)) type = SPELL_HEAL_PREDICTION_TARGET_AND_CASTER; // Binding Heal-like spells else if (spellEffectInfo.TargetA.GetCheckType() == TARGET_CHECK_PARTY || spellEffectInfo.TargetB.GetCheckType() == TARGET_CHECK_PARTY) @@ -4816,7 +4817,7 @@ static std::pair CalcPredictedHealing(SpellInfo default: break; } - + if (withPeriodic) { switch (spellEffectInfo.ApplyAuraName) diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 0a08e10313..4f5159a965 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -20,6 +20,7 @@ #include "CellImpl.h" #include "Chat.h" #include "Common.h" +#include "Containers.h" #include "DatabaseEnv.h" #include "DBCStores.h" #include "GridNotifiersImpl.h" @@ -402,7 +403,7 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* case TEXT_RANGE_PERSONAL: if (!whisperTarget || !whisperTarget->IsPlayer()) return; - + whisperTarget->ToPlayer()->SendDirectMessage(data); return; case TEXT_RANGE_NORMAL: diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index c2ca7eb7b8..fc605d6e9d 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -35,6 +35,7 @@ #include "CharacterDatabaseCleaner.h" #include "Chat.h" #include "Config.h" +#include "Containers.h" #include "CreatureAIRegistry.h" #include "CreatureGroups.h" #include "CreatureTextMgr.h" diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 82ecd3196e..67c2625830 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -42,12 +42,11 @@ EndScriptData */ #include "VMapManager2.h" #include "World.h" #include "WorldSession.h" - -#include - +#include #include #include #include +#include class server_commandscript : public CommandScript { diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp index 45d4eb67f0..5baf3a1eff 100644 --- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp +++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "baradin_hold.h" +#include "Containers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "MoveSpline.h" diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp index ee03595a3f..af0b737dd1 100644 --- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp +++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "baradin_hold.h" +#include "Containers.h" #include "InstanceScript.h" #include "ObjectAccessor.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_pit_lord_argaloth.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_pit_lord_argaloth.cpp index 28809344e9..30c2db011b 100644 --- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_pit_lord_argaloth.cpp +++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_pit_lord_argaloth.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "baradin_hold.h" +#include "Containers.h" #include "InstanceScript.h" #include "ObjectAccessor.h" #include "Map.h" diff --git a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_ascendant_council.cpp b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_ascendant_council.cpp index a1070b1570..5ec9d9b0da 100644 --- a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_ascendant_council.cpp +++ b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_ascendant_council.cpp @@ -17,6 +17,7 @@ #include "CommonPredicates.h" #include "Creature.h" +#include "Containers.h" #include "InstanceScript.h" #include "GridNotifiers.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_chogall.cpp b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_chogall.cpp index b43c505790..be73e70b61 100644 --- a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_chogall.cpp +++ b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_chogall.cpp @@ -17,6 +17,7 @@ #include "Creature.h" #include "CreatureAIImpl.h" +#include "Containers.h" #include "InstanceScript.h" #include "GridNotifiers.h" #include "MotionMaster.h" diff --git a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_halfus_wyrmbreaker.cpp b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_halfus_wyrmbreaker.cpp index b97039f778..5e55e9f803 100644 --- a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_halfus_wyrmbreaker.cpp +++ b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_halfus_wyrmbreaker.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_theralion_and_valiona.cpp b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_theralion_and_valiona.cpp index 096ea5674d..083fabcf51 100644 --- a/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_theralion_and_valiona.cpp +++ b/src/server/scripts/EasternKingdoms/BastionOfTwilight/boss_theralion_and_valiona.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp index 5237fcd14d..2e7ae9e7f3 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "blackrock_depths.h" +#include "Containers.h" #include "GameObjectAI.h" #include "GridNotifiers.h" #include "Group.h" diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_atramedes.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_atramedes.cpp index 17914687fd..ef51fb4fdf 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_atramedes.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_atramedes.cpp @@ -18,6 +18,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" #include "CommonPredicates.h" +#include "Containers.h" #include "GridNotifiers.h" #include "Map.h" #include "MoveSpline.h" diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_chimaeron.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_chimaeron.cpp index ad0f846ce3..e36d073e39 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_chimaeron.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_chimaeron.cpp @@ -18,6 +18,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" #include "CommonPredicates.h" +#include "Containers.h" #include "GridNotifiers.h" #include "ScriptedCreature.h" #include "SpellScript.h" @@ -203,7 +204,7 @@ struct boss_chimaeron : public BossAI if (Creature* nefarius = instance->GetCreature(DATA_LORD_VICTOR_NEFARIUS_GENERIC)) if (nefarius->IsAIEnabled()) nefarius->AI()->DoAction(ACTION_CHIMAERON_DEFEATED); - + } void KilledUnit(Unit* victim) override @@ -244,7 +245,7 @@ struct boss_chimaeron : public BossAI { case SPELL_MASSACRE: { - // Hotfix (2011-01-05): "Chimaeron now resets his melee attack cycle after each Massacre and removes the Double Attack buff." + // Hotfix (2011-01-05): "Chimaeron now resets his melee attack cycle after each Massacre and removes the Double Attack buff." me->RemoveAurasDueToSpell(SPELL_DOUBLE_ATTACK); me->resetAttackTimer(); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_magmaw.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_magmaw.cpp index c18eeb6156..8eb2a712dd 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_magmaw.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_magmaw.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "Spell.h" #include "SpellScript.h" diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_maloriak.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_maloriak.cpp index d2eee969ea..a4532f9e68 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_maloriak.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_maloriak.cpp @@ -17,6 +17,7 @@ #include "blackwing_descent.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ObjectMgr.h" #include "CommonPredicates.h" #include "DBCStores.h" diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp index e0ae3c768a..5bd42e0f45 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingDescent/boss_omnotron_defense_system.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" @@ -328,7 +329,7 @@ struct boss_omnotron_defense_system : public BossAI golem->DespawnOrUnsummon(); } } - + instance->SetBossState(DATA_OMNOTRON_DEFENSE_SYSTEM, FAIL); RemoveDebuffsFromRaid(); summons.DespawnAll(); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp index bc2613ea29..a98ac2302c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "molten_core.h" #include "ScriptedCreature.h" #include "SpellScript.h" diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp index e5dbb34af0..c774c0ee75 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp @@ -23,6 +23,7 @@ SDCategory: Molten Core EndScriptData */ #include "ObjectMgr.h" +#include "Containers.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "molten_core.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_admiral_ripsnarl.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_admiral_ripsnarl.cpp index bbd9a518f5..02e418c673 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_admiral_ripsnarl.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_admiral_ripsnarl.cpp @@ -16,6 +16,7 @@ */ #include "GameEventMgr.h" +#include "Containers.h" #include "ObjectMgr.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp index e47f7dbfa5..e2e33bcb09 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_foe_reaper_5000.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_foe_reaper_5000.cpp index 1779cb5e6e..03fed4b74f 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_foe_reaper_5000.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_foe_reaper_5000.cpp @@ -16,6 +16,7 @@ */ #include "ObjectMgr.h" +#include "Containers.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_glubtok.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_glubtok.cpp index 051c6d61ca..e54281f00b 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_glubtok.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_glubtok.cpp @@ -16,6 +16,7 @@ */ #include "ObjectMgr.h" +#include "Containers.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_helix_gearbreaker.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_helix_gearbreaker.cpp index e59f50e264..ae459a5175 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_helix_gearbreaker.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_helix_gearbreaker.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "deadmines.h" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_vanessa_van_cleef.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_vanessa_van_cleef.cpp index 327e9d930b..fd53cfad2a 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_vanessa_van_cleef.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_vanessa_van_cleef.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "deadmines.h" #include "InstanceScript.h" #include "GridNotifiers.h" diff --git a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp index c254dc6507..0a24bbeff8 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "CreatureAI.h" +#include "Containers.h" #include "deadmines.h" #include "GameObject.h" #include "InstanceScript.h" diff --git a/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_2.cpp b/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_2.cpp index 8a20961dcd..c737f619a7 100644 --- a/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_2.cpp +++ b/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_2.cpp @@ -17,6 +17,7 @@ #include "gilneas.h" #include "ScriptMgr.h" +#include "Containers.h" #include "CombatAI.h" #include "MotionMaster.h" #include "MoveSplineInit.h" diff --git a/src/server/scripts/EasternKingdoms/GrimBatol/boss_forgemaster_throngus.cpp b/src/server/scripts/EasternKingdoms/GrimBatol/boss_forgemaster_throngus.cpp index c453395a2e..64be722a75 100644 --- a/src/server/scripts/EasternKingdoms/GrimBatol/boss_forgemaster_throngus.cpp +++ b/src/server/scripts/EasternKingdoms/GrimBatol/boss_forgemaster_throngus.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/EasternKingdoms/GrimBatol/boss_general_umbriss.cpp b/src/server/scripts/EasternKingdoms/GrimBatol/boss_general_umbriss.cpp index b92b6e05df..79dd3c2816 100644 --- a/src/server/scripts/EasternKingdoms/GrimBatol/boss_general_umbriss.cpp +++ b/src/server/scripts/EasternKingdoms/GrimBatol/boss_general_umbriss.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index c05fd72ea2..5741cf7355 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -23,6 +23,7 @@ SDCategory: Karazhan EndScriptData */ #include "ScriptMgr.h" +#include "Containers.h" #include "karazhan.h" #include "MotionMaster.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index e8f23f7df2..b3e7006a84 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -23,6 +23,7 @@ SDCategory: Karazhan EndScriptData */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "karazhan.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index feb15cafa5..a5927e86d5 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -23,6 +23,7 @@ SDCategory: Karazhan EndScriptData */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "karazhan.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp index 10a93d2bd2..04fc00f966 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "scarlet_monastery.h" diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp index fa18a9d9f2..e390b038ed 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "InstanceScript.h" diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_baron_silverlaine.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_baron_silverlaine.cpp index 80419db093..12f623011a 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_baron_silverlaine.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_baron_silverlaine.cpp @@ -16,6 +16,7 @@ */ #include "shadowfang_keep.h" +#include "Containers.h" #include "ObjectMgr.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" @@ -75,7 +76,7 @@ enum Spells SPELL_SUMMON_SPIRIT_OF_RAZORCLAW_THE_BUTCHER_DUMMY = 93921, // Dummy Summon SPELL_SUMMON_SPIRIT_OF_RAZORCLAW_THE_BUTCHER_SUMMON = 93924, - + SPELL_SUMMON_SPIRIT_OF_RETHILGORE_DUMMY = 93925, // Dummy Summon SPELL_SUMMON_SPIRIT_OF_RETHILGORE_SUMMON = 93927, diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_godfrey.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_godfrey.cpp index b37dd00c1f..2d11aa80f4 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_godfrey.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_godfrey.cpp @@ -16,6 +16,7 @@ */ #include "shadowfang_keep.h" +#include "Containers.h" #include "GameEventMgr.h" #include "ObjectMgr.h" #include "ScriptMgr.h" diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_walden.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_walden.cpp index 53741094a7..36d0b97b52 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_walden.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_lord_walden.cpp @@ -16,6 +16,7 @@ */ #include "shadowfang_keep.h" +#include "Containers.h" #include "SpellScript.h" #include "ObjectMgr.h" #include "ScriptMgr.h" diff --git a/src/server/scripts/EasternKingdoms/ThroneOfTheTides/boss_lady_nazjar.cpp b/src/server/scripts/EasternKingdoms/ThroneOfTheTides/boss_lady_nazjar.cpp index ab85143b85..c56f3be1c5 100644 --- a/src/server/scripts/EasternKingdoms/ThroneOfTheTides/boss_lady_nazjar.cpp +++ b/src/server/scripts/EasternKingdoms/ThroneOfTheTides/boss_lady_nazjar.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "throne_of_the_tides.h" +#include "Containers.h" #include "GameObject.h" #include "MoveSpline.h" #include "ObjectMgr.h" diff --git a/src/server/scripts/EasternKingdoms/ThroneOfTheTides/throne_of_the_tides.cpp b/src/server/scripts/EasternKingdoms/ThroneOfTheTides/throne_of_the_tides.cpp index bb870c9c83..735573417f 100644 --- a/src/server/scripts/EasternKingdoms/ThroneOfTheTides/throne_of_the_tides.cpp +++ b/src/server/scripts/EasternKingdoms/ThroneOfTheTides/throne_of_the_tides.cpp @@ -17,6 +17,7 @@ #include "throne_of_the_tides.h" #include "AreaBoundary.h" +#include "Containers.h" #include "GameObjectAI.h" #include "GridNotifiers.h" #include "InstanceScript.h" diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_bloodlord_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_bloodlord_mandokir.cpp index 25d60742ca..d86dea1541 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_bloodlord_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_bloodlord_mandokir.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiers.h" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priest_venoxis.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priest_venoxis.cpp index 9623ee1bb2..3bf090b2b8 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priest_venoxis.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priest_venoxis.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "zulgurub.h" #include "GridNotifiers.h" diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priestess_kilnara.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priestess_kilnara.cpp index ac889cb2d0..9708464c71 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priestess_kilnara.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_high_priestess_kilnara.cpp @@ -16,6 +16,7 @@ */ #include "GridNotifiers.h" +#include "Containers.h" #include "ObjectMgr.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_zanzil.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_zanzil.cpp index 4a6645619a..4f9b229e16 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_zanzil.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_zanzil.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Containers.h" #include "DynamicObject.h" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp index 2ec4d8af4e..41cf540044 100644 --- a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp +++ b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp @@ -16,6 +16,7 @@ */ #include "CellImpl.h" +#include "Containers.h" #include "CreatureAIImpl.h" #include "CreatureGroups.h" #include "GameEventMgr.h" diff --git a/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp b/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp index d627f1f0c0..c6abe962ba 100644 --- a/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp +++ b/src/server/scripts/EasternKingdoms/zone_tol_barad.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "Battlefield/BattlefieldTB.h" +#include "Containers.h" #include "DBCStores.h" #include "Player.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/EasternKingdoms/zone_twilight_highlands.cpp b/src/server/scripts/EasternKingdoms/zone_twilight_highlands.cpp index 626f0f7c67..2005c79dc9 100644 --- a/src/server/scripts/EasternKingdoms/zone_twilight_highlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_twilight_highlands.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "MotionMaster.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/EasternKingdoms/zone_westfall.cpp b/src/server/scripts/EasternKingdoms/zone_westfall.cpp index add282bd69..be2adfe91b 100644 --- a/src/server/scripts/EasternKingdoms/zone_westfall.cpp +++ b/src/server/scripts/EasternKingdoms/zone_westfall.cpp @@ -16,6 +16,7 @@ */ #include "Player.h" +#include "Containers.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "CombatAI.h" @@ -307,7 +308,7 @@ struct npc_westfall_hobo_witness : public ScriptedAI me->SetFacingToObject(player); uint16 slot = player->FindQuestSlot(QUEST_MURDER_WAS_THE_CASE_THAT_THEY_GAVE_ME); - + if (player->GetQuestSlotCounter(slot, CLUE1) == 0) { player->CastSpell(player, SPELL_HOBO_INFORMATION_1); @@ -315,7 +316,7 @@ struct npc_westfall_hobo_witness : public ScriptedAI me->DespawnOrUnsummon(12s); return; } - + if (player->GetQuestSlotCounter(slot, CLUE2) == 0) { player->CastSpell(player, SPELL_HOBO_INFORMATION_2); @@ -323,7 +324,7 @@ struct npc_westfall_hobo_witness : public ScriptedAI me->DespawnOrUnsummon(12s); return; } - + if (player->GetQuestSlotCounter(slot, CLUE3) == 0) { player->CastSpell(player, SPELL_HOBO_INFORMATION_3); @@ -331,7 +332,7 @@ struct npc_westfall_hobo_witness : public ScriptedAI me->DespawnOrUnsummon(12s); return; } - + if (player->GetQuestSlotCounter(slot, CLUE4) == 0) { player->CastSpell(player, SPELL_HOBO_INFORMATION_4); @@ -368,7 +369,7 @@ struct npc_westfall_hobo_witness : public ScriptedAI who->ToCreature()->AI()->DoAction(ACTION_AGGRO_HOBO_DONE); me->CastSpell(me, SPELL_SUMMON_RAGAMUFFIN_LOOTER); } - + void Reset() override { ScriptedAI::Reset(); @@ -1303,7 +1304,7 @@ enum WestFallText SAY_NPC_HOMELESS_STORMWIND_CITIZEN_2 = 12, SAY_NPC_TRANSIENT = 17, SAY_NPC_WEST_PLAINS_DRIFTER = 11, - SAY_NPC_WEST_PLAINS_DRIFTER_FOLLOWER = 6 + SAY_NPC_WEST_PLAINS_DRIFTER_FOLLOWER = 6 }; struct npc_westfall_westfall_stew: public ScriptedAI @@ -1398,10 +1399,10 @@ struct npc_westfall_homless_stormwind_citizen : public ScriptedAI case EVENT_START: { me->SetStandState(UNIT_STAND_STATE_STAND); - + if (me->HasAura(SPELL_COSMETIC_SLEEP)) me->RemoveAurasDueToSpell(SPELL_COSMETIC_SLEEP); - + _events.ScheduleEvent(EVENT_MOVE_TO_STEW, 2s); break; } @@ -1511,10 +1512,10 @@ struct npc_westfall_west_plains_drifter : public ScriptedAI { case EVENT_START: me->SetStandState(UNIT_STAND_STATE_STAND); - + if (me->HasAura(SPELL_COSMETIC_SLEEP)) me->RemoveAurasDueToSpell(SPELL_COSMETIC_SLEEP); - + _events.ScheduleEvent(EVENT_MOVE_TO_STEW, 2s); break; case EVENT_MOVE_TO_STEW: diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DragonSoul/boss_madness_of_deathwing.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DragonSoul/boss_madness_of_deathwing.cpp index d52a3380c1..0c4cc198f6 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DragonSoul/boss_madness_of_deathwing.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DragonSoul/boss_madness_of_deathwing.cpp @@ -18,6 +18,7 @@ #include "dragon_soul.h" #include "CreatureAI.h" #include "CreatureAIImpl.h" +#include "Containers.h" #include "GameObject.h" #include "Group.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp b/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp index 2a20a86cdf..e894723e76 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" +#include "Containers.h" #include "DBCStores.h" #include "firelands.h" #include "GridNotifiersImpl.h" diff --git a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp index 214206d5fe..8be01f2064 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp @@ -24,6 +24,7 @@ #include "ScriptMgr.h" #include "firelands.h" +#include "Containers.h" #include "GridNotifiers.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp b/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp index dc74151991..01b9ff2cac 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp @@ -16,6 +16,7 @@ */ #include "firelands.h" +#include "Containers.h" #include "InstanceScript.h" #include "PassiveAI.h" #include "PathGenerator.h" diff --git a/src/server/scripts/Kalimdor/Firelands/boss_ragnaros_firelands.cpp b/src/server/scripts/Kalimdor/Firelands/boss_ragnaros_firelands.cpp index 68f9ec9621..afedccf59e 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_ragnaros_firelands.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_ragnaros_firelands.cpp @@ -16,6 +16,7 @@ */ #include "firelands.h" +#include "Containers.h" #include "DynamicObject.h" #include "GameObject.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Kalimdor/Firelands/instance_firelands.cpp b/src/server/scripts/Kalimdor/Firelands/instance_firelands.cpp index bedb333653..6f698ea164 100644 --- a/src/server/scripts/Kalimdor/Firelands/instance_firelands.cpp +++ b/src/server/scripts/Kalimdor/Firelands/instance_firelands.cpp @@ -19,6 +19,7 @@ #include "AreaBoundary.h" #include "Creature.h" #include "CreatureAI.h" +#include "Containers.h" #include "EventProcessor.h" #include "firelands.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_ammunae.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_ammunae.cpp index e7e8823a37..27941d407e 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_ammunae.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_ammunae.cpp @@ -16,6 +16,7 @@ */ #include "halls_of_origination.h" +#include "Containers.h" #include "PassiveAI.h" #include "Player.h" #include "ScriptMgr.h" diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp index a8ec8e486c..c37db0be21 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiers.h" #include "halls_of_origination.h" #include "InstanceScript.h" @@ -75,7 +76,7 @@ enum Phases enum Points { POINT_ANRAPHET_ACTIVATE, - POINT_BRANN_SAY_TROGGS, + POINT_BRANN_SAY_TROGGS, POINT_BRANN_SAY_MOMENT, POINT_BRANN_TURN_BACK }; diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_earthrager_ptah.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_earthrager_ptah.cpp index e9e425cd25..9baacc54e1 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_earthrager_ptah.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_earthrager_ptah.cpp @@ -16,6 +16,7 @@ */ #include "halls_of_origination.h" +#include "Containers.h" #include "ScriptMgr.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp index a9255322ae..68902af3fb 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "halls_of_origination.h" #include "ScriptedCreature.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_setesh.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_setesh.cpp index 477e5f2db3..8f4777033f 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_setesh.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_setesh.cpp @@ -16,6 +16,7 @@ */ #include "halls_of_origination.h" +#include "Containers.h" #include "Map.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" @@ -65,7 +66,7 @@ enum Events EVENT_CONTINUE_FIGHT, EVENT_CHAOS_BLAST, EVENT_SEED_OF_CHAOS, - EVENT_REIGN_OF_CHAOS, + EVENT_REIGN_OF_CHAOS, // Chaos Portal EVENT_CAST_VISUAL, @@ -131,7 +132,7 @@ class boss_setesh : public CreatureScript BossAI::JustEngagedWith(who); Talk(SAY_AGGRO); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); - + events.ScheduleEvent(EVENT_CHAOS_PORTAL, Seconds(5)); events.ScheduleEvent(EVENT_CHAOS_BLAST, Seconds(15)); events.ScheduleEvent(EVENT_SEED_OF_CHAOS, Seconds(20)); @@ -188,7 +189,7 @@ class boss_setesh : public CreatureScript break; } - + } void DoAction(int32 action) override diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp index 55ba05e53d..34af98a8b5 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp @@ -16,10 +16,11 @@ */ /* To-do: */ -// - AreaTrigger: unknown purpose (id: 1843; pos: front-right stairs) - dust animation, aggro snakes? +// - AreaTrigger: unknown purpose (id: 1843; pos: front-right stairs) - dust animation, aggro snakes? #include "halls_of_origination.h" #include "ScriptMgr.h" +#include "Containers.h" #include "GameObject.h" #include "GameObjectAI.h" #include "GridNotifiers.h" @@ -36,7 +37,7 @@ enum Texts { SAY_AGGRO = 0, SAY_SHIELD = 1, - EMOTE_SHIELD = 2, + EMOTE_SHIELD = 2, EMOTE_SHIELD_REMOVED = 3, SAY_KILL = 4, SAY_DEATH = 5 diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/halls_of_origination.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/halls_of_origination.cpp index 38093caecd..c173fba7eb 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/halls_of_origination.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/halls_of_origination.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "CreatureGroups.h" #include "CreatureAI.h" #include "GameObject.h" diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/instance_halls_of_origination.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/instance_halls_of_origination.cpp index 0be5cb7091..5f9a51c573 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/instance_halls_of_origination.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/instance_halls_of_origination.cpp @@ -16,6 +16,7 @@ */ #include "halls_of_origination.h" +#include "Containers.h" #include "ObjectMgr.h" #include "ScriptMgr.h" #include "Creature.h" diff --git a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_general_husam.cpp b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_general_husam.cpp index a72ff88a4e..9b895a8ff7 100644 --- a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_general_husam.cpp +++ b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_general_husam.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "G3DPosition.hpp" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_high_prophet_barim.cpp b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_high_prophet_barim.cpp index c211f100ad..a93132b482 100644 --- a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_high_prophet_barim.cpp +++ b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_high_prophet_barim.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "lost_city_of_the_tolvir.h" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_lockmaw_and_augh.cpp b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_lockmaw_and_augh.cpp index 0417138707..6cee17f345 100644 --- a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_lockmaw_and_augh.cpp +++ b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_lockmaw_and_augh.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "lost_city_of_the_tolvir.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_siamat.cpp b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_siamat.cpp index bf99351be3..c42421094f 100644 --- a/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_siamat.cpp +++ b/src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_siamat.cpp @@ -17,6 +17,7 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp index 7f72f2c3ad..37e856766a 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "InstanceScript.h" #include "onyxias_lair.h" #include "TemporarySummon.h" +#include namespace OnyxiasLair { diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp index e38507d3aa..861eaaf325 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "ruins_of_ahnqiraj.h" diff --git a/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_alakir.cpp b/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_alakir.cpp index 1fd0278c90..5cdffa06cc 100644 --- a/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_alakir.cpp +++ b/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_alakir.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "throne_of_the_four_winds.h" +#include "Containers.h" #include "GameObject.h" #include "ObjectMgr.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_conclave_of_wind.cpp b/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_conclave_of_wind.cpp index 146404a8c9..5421217107 100644 --- a/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_conclave_of_wind.cpp +++ b/src/server/scripts/Kalimdor/ThroneOfTheFourWinds/boss_conclave_of_wind.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "throne_of_the_four_winds.h" #include "AreaBoundary.h" +#include "Containers.h" #include "GameObject.h" #include "ObjectMgr.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/Kalimdor/VortexPinnacle/boss_altairus.cpp b/src/server/scripts/Kalimdor/VortexPinnacle/boss_altairus.cpp index 5a295e00ec..ae975ff35f 100644 --- a/src/server/scripts/Kalimdor/VortexPinnacle/boss_altairus.cpp +++ b/src/server/scripts/Kalimdor/VortexPinnacle/boss_altairus.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiers.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Kalimdor/VortexPinnacle/boss_asaad.cpp b/src/server/scripts/Kalimdor/VortexPinnacle/boss_asaad.cpp index a798eaa1c9..af5a2b6d3b 100644 --- a/src/server/scripts/Kalimdor/VortexPinnacle/boss_asaad.cpp +++ b/src/server/scripts/Kalimdor/VortexPinnacle/boss_asaad.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "AreaBoundary.h" +#include "Containers.h" #include "InstanceScript.h" #include "Map.h" #include "MotionMaster.h" @@ -110,7 +111,7 @@ float const TRIANGLE_TOP_Z = 654.7143f; static uint8 const MaxStormTargetTrios = 13; static uint8 const MaxStormTargetTrianglePoints = 3; -static std::array StormTargetSummonPositions = +static std::array StormTargetSummonPositions = { Position(-633.771f, 490.976f, TRIANGLE_Z, 3.141593f), Position(-625.688f, 501.934f, TRIANGLE_Z, 3.141593f), diff --git a/src/server/scripts/Kalimdor/VortexPinnacle/vortex_pinnacle.cpp b/src/server/scripts/Kalimdor/VortexPinnacle/vortex_pinnacle.cpp index baca4d8b43..877c35798d 100644 --- a/src/server/scripts/Kalimdor/VortexPinnacle/vortex_pinnacle.cpp +++ b/src/server/scripts/Kalimdor/VortexPinnacle/vortex_pinnacle.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "AreaBoundary.h" +#include "Containers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "PassiveAI.h" diff --git a/src/server/scripts/Maelstrom/Stonecore/boss_corborus.cpp b/src/server/scripts/Maelstrom/Stonecore/boss_corborus.cpp index b661c620ee..546b883c69 100644 --- a/src/server/scripts/Maelstrom/Stonecore/boss_corborus.cpp +++ b/src/server/scripts/Maelstrom/Stonecore/boss_corborus.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "Map.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp index 8c9cfd1c06..2c284fd872 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp @@ -20,6 +20,7 @@ #include "AreaBoundary.h" #include "Creature.h" #include "CreatureAI.h" +#include "Containers.h" #include "GameObject.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp index 4bee7b041b..e938dcf006 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index e57e85bd31..6889054a46 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "DBCStores.h" #include "GameObject.h" #include "GameObjectAI.h" diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp index 5255c2cc4b..80743f512c 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "Map.h" #include "MotionMaster.h" #include "ruby_sanctum.h" diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp index c8b1235144..050dd76e00 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp @@ -23,6 +23,7 @@ SDCategory: Trial of the Champion EndScriptData */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index d644e432f3..3bccfbf2e7 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "Player.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index d63de8aaf3..24c7375f85 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "forge_of_souls.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp index a5f488d9a6..c940d27adc 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "Creature.h" #include "CreatureAI.h" +#include "Containers.h" #include "GameObject.h" #include "halls_of_reflection.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index ae2de87b27..e70b8c51d3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiers.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 30a4d7478d..0cafdc28f3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "icecrown_citadel.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index ab163aea64..c8d254311d 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "icecrown_citadel.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index e6b24fbee0..78a76c101f 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" #include "CreatureTextMgr.h" +#include "Containers.h" #include "GossipDef.h" #include "GridNotifiersImpl.h" #include "icecrown_citadel.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index e704200e1a..a847d82d62 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "Group.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 7637a951a9..634838889c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "DBCStores.h" #include "GameObject.h" #include "GridNotifiers.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index b81275d799..f8dba32bcf 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiers.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index fffed21e89..09a22af228 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GridNotifiers.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 5da3813626..f32804d6c5 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" #include "CreatureTextMgr.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 6dbaa5657f..f7bcc7c3db 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index d264a2419f..23d9e49dab 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "icecrown_citadel.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp index 0f2d7237b2..52440062a8 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "naxxramas.h" #include "ObjectAccessor.h" diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index c119cadd4b..30f1efaf50 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -22,6 +22,7 @@ Script Data End */ #include "ScriptMgr.h" #include "CombatAI.h" #include "CreatureTextMgr.h" +#include "Containers.h" #include "eye_of_eternity.h" #include "GameObject.h" #include "GameObjectAI.h" diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp index 8256111f4d..11dfe13af8 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp @@ -23,6 +23,7 @@ SDCategory: Instance Script EndScriptData */ #include "ScriptMgr.h" +#include "Containers.h" #include "MotionMaster.h" #include "oculus.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 61b5f09d60..4aeed248ee 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "DBCStores.h" #include "GameObject.h" #include "GameObjectAI.h" diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index c9b3197384..a90dfaa2a5 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "AreaBoundary.h" +#include "Containers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" @@ -540,7 +541,7 @@ struct boss_stormcaller_brundir : public ScriptedAI DoCastSelf(SPELL_BERSERK); _events.SetPhase(PHASE_ONE); - _events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 1ms); + _events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 1ms); _events.ScheduleEvent(EVENT_OVERLOAD, 42s, 1min); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index be93d761bf..24918e3da6 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -25,6 +25,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" #include "CombatAI.h" +#include "Containers.h" #include "GameObjectAI.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index 8fb0f96969..b43845220f 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "Map.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 7951d18622..8c6ab97ff1 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "GameObject.h" #include "GameObjectAI.h" #include "GridNotifiers.h" diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp index 1075ce8740..edc7ee248a 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "AreaBoundary.h" #include "CellImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp index ee1cff649e..6c8a16bb8f 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "ObjectAccessor.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp index e8888295f3..1c84606875 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "Player.h" diff --git a/src/server/scripts/Northrend/zone_dalaran.cpp b/src/server/scripts/Northrend/zone_dalaran.cpp index 07e81bd598..72f982fb80 100644 --- a/src/server/scripts/Northrend/zone_dalaran.cpp +++ b/src/server/scripts/Northrend/zone_dalaran.cpp @@ -24,6 +24,7 @@ SDCategory: Dalaran Script Data End */ #include "ScriptMgr.h" +#include "Containers.h" #include "DatabaseEnv.h" #include "Mail.h" #include "Map.h" diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp index b003e75f35..3796836901 100644 --- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp +++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "sethekk_halls.h" diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index a3d6f32ab8..1a0bf2f7d0 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "black_temple.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "Map.h" diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp index 7c8fc7773c..a94ca5feae 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "black_temple.h" #include "CellImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "PassiveAI.h" diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index f2f7780f5a..f8cb3be6ee 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "black_temple.h" +#include "Containers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "Player.h" diff --git a/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp b/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp index 11ce59acd1..923a0d800c 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "CreatureTextMgr.h" +#include "Containers.h" #include "GameObject.h" #include "GameObjectAI.h" #include "Group.h" diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index 90ceb1b7d5..5b91ee5667 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "CellImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "Log.h" #include "MotionMaster.h" diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index 7ec0793bd9..d9db2a4cd6 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -30,6 +30,7 @@ go_captain_tyralius_prison EndContentData */ #include "ScriptMgr.h" +#include "Containers.h" #include "GameObject.h" #include "GameObjectAI.h" #include "Log.h" diff --git a/src/server/scripts/Pet/pet_hunter.cpp b/src/server/scripts/Pet/pet_hunter.cpp index 94f72ec21d..0aeb1afa3e 100644 --- a/src/server/scripts/Pet/pet_hunter.cpp +++ b/src/server/scripts/Pet/pet_hunter.cpp @@ -22,6 +22,7 @@ #include "ScriptMgr.h" #include "CreatureAIImpl.h" +#include "Containers.h" #include "ScriptedCreature.h" #include "SpellAuraEffects.h" #include "SpellScript.h" diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 071ce131ad..eb59d49d2b 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -25,6 +25,7 @@ #include "ScriptMgr.h" #include "Battleground.h" #include "CellImpl.h" +#include "Containers.h" #include "DBCStores.h" #include "GameTime.h" #include "GridNotifiersImpl.h" @@ -4278,7 +4279,7 @@ class spell_gen_vengeance_triggered : public AuraScript void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) { - Unit* target = GetTarget(); + Unit* target = GetTarget(); // Get the total damage of the last two seconds and clean older damage data int32 damageLastTwoSeconds = 0; for (DamageInfoContainer::const_iterator itr = _damageInfo.begin(); itr != _damageInfo.end();) @@ -5006,7 +5007,7 @@ class spell_gen_shadowmeld : public AuraScript { return ValidateSpellInfo({ SPELL_RACIAL_ELUSIVENESS }); } - + void HandleStealthLevel(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { if (AuraEffect const* aurEff = GetUnitOwner()->GetAuraEffect(SPELL_RACIAL_ELUSIVENESS, EFFECT_0)) diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp index 81d5517efc..e851e6267c 100644 --- a/src/server/scripts/Spells/spell_holiday.cpp +++ b/src/server/scripts/Spells/spell_holiday.cpp @@ -24,6 +24,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" #include "CreatureAIImpl.h" +#include "Containers.h" #include "GridNotifiersImpl.h" #include "Player.h" #include "ScriptedCreature.h" diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index db360632e9..a0e9408a06 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -24,6 +24,7 @@ #include "ScriptMgr.h" #include "Battleground.h" #include "CreatureAIImpl.h" +#include "Containers.h" #include "DBCStores.h" #include "Map.h" #include "ObjectMgr.h" diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index b9909ea794..4f60e17cb7 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "CellImpl.h" #include "CombatAI.h" +#include "Containers.h" #include "CreatureTextMgr.h" #include "GameEventMgr.h" #include "GridNotifiersImpl.h" @@ -187,7 +188,7 @@ public: AirForceSpawn const& _spawn; ObjectGuid _myGuard; std::unordered_set _toAttack; - + }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/shared/Networking/NetworkThread.h b/src/server/shared/Networking/NetworkThread.h index 5f9071af65..e149867c96 100644 --- a/src/server/shared/Networking/NetworkThread.h +++ b/src/server/shared/Networking/NetworkThread.h @@ -122,7 +122,7 @@ protected: { TC_LOG_DEBUG("misc", "Network Thread Starting"); - _updateTimer.expires_from_now(boost::posix_time::milliseconds(1)); + _updateTimer.expires_after(1ms); _updateTimer.async_wait([this](boost::system::error_code const&) { Update(); }); _ioContext.run(); @@ -136,7 +136,7 @@ protected: if (_stopped) return; - _updateTimer.expires_from_now(boost::posix_time::milliseconds(1)); + _updateTimer.expires_after(1ms); _updateTimer.async_wait([this](boost::system::error_code const&) { Update(); }); AddNewSockets(); diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 65f89d73b7..73860ac635 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -101,7 +101,7 @@ class FreezeDetector static void Start(std::shared_ptr const& freezeDetector) { - freezeDetector->_timer.expires_from_now(boost::posix_time::seconds(5)); + freezeDetector->_timer.expires_after(5s); freezeDetector->_timer.async_wait([freezeDetectorRef = std::weak_ptr(freezeDetector)](boost::system::error_code const& error) { return Handler(freezeDetectorRef, error); @@ -541,7 +541,7 @@ void FreezeDetector::Handler(std::weak_ptr freezeDetectorRef, bo ABORT(); } - freezeDetector->_timer.expires_from_now(boost::posix_time::seconds(1)); + freezeDetector->_timer.expires_after(1s); freezeDetector->_timer.async_wait([freezeDetectorRef](boost::system::error_code const& timerError) { return Handler(freezeDetectorRef, timerError); diff --git a/tests/common/FlatSet.cpp b/tests/common/FlatSet.cpp new file mode 100644 index 0000000000..a0c50a62a4 --- /dev/null +++ b/tests/common/FlatSet.cpp @@ -0,0 +1,60 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "tc_catch2.h" + +#include "FlatSet.h" + +TEST_CASE("Insertion", "[FlatSet]") +{ + Trinity::Containers::FlatSet flat; + + REQUIRE(flat.insert(5).second == true); + REQUIRE(flat.insert(3).second == true); + REQUIRE(flat.insert(9).second == true); + REQUIRE(flat.insert(7).second == true); + + REQUIRE(flat.insert(5).second == false); + REQUIRE(flat.insert(3).second == false); + REQUIRE(flat.insert(9).second == false); + REQUIRE(flat.insert(7).second == false); + + REQUIRE(flat.size() == 4); + + auto itr = flat.begin(); + REQUIRE(*itr == 3); + ++itr; + REQUIRE(*itr == 5); + ++itr; + REQUIRE(*itr == 7); + ++itr; + REQUIRE(*itr == 9); + ++itr; + REQUIRE(itr == flat.end()); +} + +TEST_CASE("Erase", "[FlatSet]") +{ + Trinity::Containers::FlatSet flat; + flat.insert(3); + flat.insert(5); + flat.insert(7); + flat.insert(9); + + REQUIRE(flat.erase(7) == 1); + REQUIRE(flat.size() == 3); +}