mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: Minor compile time improving changes
(cherry picked from commit b5c99939a8)
# Conflicts:
# src/server/game/Entities/Item/Item.cpp
# src/server/game/Entities/Item/Item.h
# src/server/game/Entities/Player/Player.cpp
# src/server/game/Entities/Player/Player.h
This commit is contained in:
@@ -29,6 +29,21 @@
|
||||
|
||||
using namespace Trinity::Impl::ChatCommands;
|
||||
|
||||
ChatCommandResult Trinity::Impl::ChatCommands::TryConsumExactSequencee(std::string_view sequence, ChatHandler const* handler, std::string_view args)
|
||||
{
|
||||
if (args.empty())
|
||||
return std::nullopt;
|
||||
std::string_view start = args.substr(0, sequence.length());
|
||||
if (StringEqualI(start, sequence))
|
||||
{
|
||||
auto [remainingToken, tail] = Trinity::Impl::ChatCommands::tokenize(args.substr(sequence.length()));
|
||||
if (remainingToken.empty()) // if this is not empty, then we did not consume the full token
|
||||
return tail;
|
||||
start = args.substr(0, sequence.length() + remainingToken.length());
|
||||
}
|
||||
return Trinity::Impl::ChatCommands::FormatTrinityString(handler, LANG_CMDPARSER_EXACT_SEQ_MISMATCH, STRING_VIEW_FMT_ARG(sequence), STRING_VIEW_FMT_ARG(start));
|
||||
}
|
||||
|
||||
ChatCommandResult Trinity::ChatCommands::QuotedString::TryConsume(ChatHandler const* handler, std::string_view args)
|
||||
{
|
||||
if (args.empty())
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace Trinity::Impl::ChatCommands
|
||||
|
||||
// this creates always 25 elements - "abc" -> 'a', 'b', 'c', '\0', '\0', ... up to 25
|
||||
#define CHATCOMMANDS_IMPL_SPLIT_LITERAL(strliteral) CHATCOMMANDS_IMPL_SPLIT_LITERAL_CONSTRAINED(25, strliteral)
|
||||
|
||||
TC_GAME_API ChatCommandResult TryConsumExactSequencee(std::string_view sequence, ChatHandler const* handler, std::string_view args);
|
||||
}
|
||||
|
||||
namespace Trinity::ChatCommands
|
||||
@@ -90,17 +92,7 @@ namespace Trinity::ChatCommands
|
||||
|
||||
ChatCommandResult TryConsume(ChatHandler const* handler, std::string_view args) const
|
||||
{
|
||||
if (args.empty())
|
||||
return std::nullopt;
|
||||
std::string_view start = args.substr(0, _string.length());
|
||||
if (StringEqualI(start, _string))
|
||||
{
|
||||
auto [remainingToken, tail] = Trinity::Impl::ChatCommands::tokenize(args.substr(_string.length()));
|
||||
if (remainingToken.empty()) // if this is not empty, then we did not consume the full token
|
||||
return tail;
|
||||
start = args.substr(0, _string.length() + remainingToken.length());
|
||||
}
|
||||
return Trinity::Impl::ChatCommands::FormatTrinityString(handler, LANG_CMDPARSER_EXACT_SEQ_MISMATCH, STRING_VIEW_FMT_ARG(_string), STRING_VIEW_FMT_ARG(start));
|
||||
return Trinity::Impl::ChatCommands::TryConsumExactSequencee(_string, handler, args);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -200,12 +200,13 @@ void Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry,
|
||||
lineField.ActorIndex = line->ActorIdx;
|
||||
lineField.Flags = line->Flags;
|
||||
|
||||
std::array<Milliseconds, TOTAL_LOCALES>& startTimes = _lineStartTimes[line->Id];
|
||||
for (LocaleConstant locale = LOCALE_enUS; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
|
||||
{
|
||||
if (locale == LOCALE_none)
|
||||
continue;
|
||||
|
||||
_lineStartTimes[{ locale, line->Id }] = _lastLineEndTimes[locale];
|
||||
startTimes[locale] = _lastLineEndTimes[locale];
|
||||
if (locale == DEFAULT_LOCALE)
|
||||
lineField.StartTime = _lastLineEndTimes[locale].count();
|
||||
|
||||
@@ -216,7 +217,7 @@ void Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry,
|
||||
}
|
||||
}
|
||||
|
||||
_duration = Milliseconds(*std::max_element(_lastLineEndTimes.begin(), _lastLineEndTimes.end()));
|
||||
_duration = *std::ranges::max_element(_lastLineEndTimes);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Conversation::m_conversationData).ModifyValue(&UF::ConversationData::LastLineEndTime), _duration.count());
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Conversation::m_conversationData).ModifyValue(&UF::ConversationData::Lines), std::move(lines));
|
||||
|
||||
@@ -277,7 +278,10 @@ void Conversation::AddActor(int32 actorId, uint32 actorIdx, ConversationActorTyp
|
||||
|
||||
Milliseconds const* Conversation::GetLineStartTime(LocaleConstant locale, int32 lineId) const
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_lineStartTimes, { locale, lineId });
|
||||
if (std::array<Milliseconds, TOTAL_LOCALES> const* durations = Trinity::Containers::MapGetValuePtr(_lineStartTimes, lineId))
|
||||
return &(*durations)[locale];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Milliseconds Conversation::GetLastLineEndTime(LocaleConstant locale) const
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "Object.h"
|
||||
#include "GridObject.h"
|
||||
#include "Hash.h"
|
||||
|
||||
class ConversationAI;
|
||||
class Unit;
|
||||
@@ -100,7 +99,7 @@ class TC_GAME_API Conversation final : public WorldObject, public GridObject<Con
|
||||
Milliseconds _duration;
|
||||
uint32 _textureKitId;
|
||||
|
||||
std::unordered_map<std::pair<LocaleConstant /*locale*/, int32 /*lineId*/>, Milliseconds /*startTime*/> _lineStartTimes;
|
||||
std::unordered_map<int32 /*lineId*/, std::array<Milliseconds, TOTAL_LOCALES> /*startTime*/> _lineStartTimes;
|
||||
std::array<Milliseconds /*endTime*/, TOTAL_LOCALES> _lastLineEndTimes;
|
||||
|
||||
std::unique_ptr<ConversationAI> _ai;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AuthenticationPackets.h"
|
||||
#include "WorldSession.h"
|
||||
#include "AuthenticationPackets.h"
|
||||
#include "Battleground.h"
|
||||
#include "Corpse.h"
|
||||
#include "DB2Stores.h"
|
||||
@@ -28,18 +28,20 @@
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "MotionMaster.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "MovementGenerator.h"
|
||||
#include "MovementPackets.h"
|
||||
#include "Player.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "MotionMaster.h"
|
||||
#include "MovementGenerator.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Transport.h"
|
||||
#include "Vehicle.h"
|
||||
#include "SpellMgr.h"
|
||||
#include <boost/accumulators/framework/accumulator_set.hpp>
|
||||
#include <boost/accumulators/framework/features.hpp>
|
||||
#include <boost/accumulators/statistics/mean.hpp>
|
||||
#include <boost/accumulators/statistics/median.hpp>
|
||||
#include <boost/accumulators/statistics/variance.hpp>
|
||||
#include <boost/accumulators/accumulators.hpp>
|
||||
#include <boost/accumulators/statistics.hpp>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
void WorldSession::HandleMoveWorldportAckOpcode(WorldPackets::Movement::WorldPortResponse& /*packet*/)
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "Common.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Tuples.h"
|
||||
#include "Types.h"
|
||||
#include <boost/preprocessor/punctuation/remove_parens.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -1307,37 +1306,46 @@ class TC_GAME_API ScriptMgr
|
||||
namespace Trinity::SpellScripts
|
||||
{
|
||||
template<typename T>
|
||||
using is_SpellScript = std::is_base_of<SpellScript, T>;
|
||||
concept IsSpellScript = std::is_base_of_v<SpellScript, T>;
|
||||
|
||||
template<typename T>
|
||||
using is_AuraScript = std::is_base_of<AuraScript, T>;
|
||||
concept IsAuraScript = std::is_base_of_v<AuraScript, T>;
|
||||
|
||||
template<typename T>
|
||||
concept IsSpellOrAuraScript = IsSpellScript<T> || IsAuraScript<T>;
|
||||
|
||||
template<typename T, typename Other>
|
||||
concept ComplementScriptFor = (IsSpellScript<T> && IsAuraScript<Other>)
|
||||
|| (IsAuraScript<T> && IsSpellScript<Other>)
|
||||
|| std::same_as<T, void>;
|
||||
|
||||
template<typename T>
|
||||
concept ArgsTuple = Trinity::is_tuple_v<T>;
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
template <Trinity::SpellScripts::IsSpellOrAuraScript Script1, Trinity::SpellScripts::ComplementScriptFor<Script1> Script2, Trinity::SpellScripts::ArgsTuple ArgsType>
|
||||
class GenericSpellAndAuraScriptLoader : public SpellScriptLoader
|
||||
{
|
||||
using SpellScriptType = typename Trinity::find_type_if_t<Trinity::SpellScripts::is_SpellScript, Ts...>;
|
||||
using AuraScriptType = typename Trinity::find_type_if_t<Trinity::SpellScripts::is_AuraScript, Ts...>;
|
||||
using ArgsType = typename Trinity::find_type_if_t<Trinity::is_tuple, Ts...>;
|
||||
|
||||
static_assert(!std::conjunction_v<std::is_same<SpellScriptType, Trinity::find_type_end>, std::is_same<AuraScriptType, Trinity::find_type_end>>, "At least one of SpellScript/AuraScript arguments must be provided for GenericSpellAndAuraScriptLoader");
|
||||
|
||||
public:
|
||||
GenericSpellAndAuraScriptLoader(char const* name, ArgsType&& args) : SpellScriptLoader(name), _args(std::move(args)) { }
|
||||
|
||||
private:
|
||||
SpellScript* GetSpellScript() const override
|
||||
{
|
||||
if constexpr (!std::is_same_v<SpellScriptType, Trinity::find_type_end>)
|
||||
return Trinity::new_from_tuple<SpellScriptType>(_args);
|
||||
if constexpr (Trinity::SpellScripts::IsSpellScript<Script1>)
|
||||
return Trinity::new_from_tuple<Script1>(_args);
|
||||
else if constexpr (Trinity::SpellScripts::IsSpellScript<Script2>)
|
||||
return Trinity::new_from_tuple<Script2>(_args);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AuraScript* GetAuraScript() const override
|
||||
{
|
||||
if constexpr (!std::is_same_v<AuraScriptType, Trinity::find_type_end>)
|
||||
return Trinity::new_from_tuple<AuraScriptType>(_args);
|
||||
if constexpr (Trinity::SpellScripts::IsAuraScript<Script1>)
|
||||
return Trinity::new_from_tuple<Script1>(_args);
|
||||
else if constexpr (Trinity::SpellScripts::IsAuraScript<Script2>)
|
||||
return Trinity::new_from_tuple<Script2>(_args);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1345,10 +1353,10 @@ private:
|
||||
ArgsType _args;
|
||||
};
|
||||
|
||||
#define RegisterSpellScriptWithArgs(spell_script, script_name, ...) new GenericSpellAndAuraScriptLoader<BOOST_PP_REMOVE_PARENS(spell_script), decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__))
|
||||
#define RegisterSpellScript(spell_script) RegisterSpellScriptWithArgs(spell_script, #spell_script)
|
||||
#define RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, script_name, ...) new GenericSpellAndAuraScriptLoader<BOOST_PP_REMOVE_PARENS(script_1), BOOST_PP_REMOVE_PARENS(script_2), decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__))
|
||||
#define RegisterSpellAndAuraScriptPair(script_1, script_2) RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, #script_1)
|
||||
#define RegisterSpellScriptWithArgs(spell_script, script_name, ...) RegisterSpellAndAuraScriptPairWithArgs(spell_script, void, script_name, __VA_ARGS__)
|
||||
#define RegisterSpellScript(spell_script) RegisterSpellAndAuraScriptPairWithArgs(spell_script, void, #spell_script)
|
||||
|
||||
template <class AI>
|
||||
class GenericCreatureScript : public CreatureScript
|
||||
|
||||
@@ -50,9 +50,9 @@ ScriptReloadMgr* ScriptReloadMgr::instance()
|
||||
#include "Timer.h"
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/directory.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <efsw/efsw.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "RealmList.pb.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SessionKeyGenerator.h"
|
||||
#include "SslStream.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
@@ -106,8 +106,6 @@
|
||||
#include "WorldSocket.h"
|
||||
#include "WorldStateMgr.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
TC_GAME_API std::atomic<bool> World::m_stopEvent(false);
|
||||
TC_GAME_API uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
|
||||
|
||||
@@ -263,7 +261,13 @@ void World::SetMotd(std::string motd)
|
||||
sScriptMgr->OnMotdChange(motd);
|
||||
|
||||
_motd.clear();
|
||||
boost::split(_motd, motd, boost::is_any_of("@"));
|
||||
|
||||
std::vector<std::string_view> tokens = Trinity::Tokenize(motd, '@', true);
|
||||
|
||||
_motd.reserve(tokens.size());
|
||||
|
||||
for (std::string_view const& token : tokens)
|
||||
_motd.emplace_back(token);
|
||||
}
|
||||
|
||||
std::vector<std::string> const& World::GetMotd() const
|
||||
|
||||
@@ -30,7 +30,6 @@ EndScriptData */
|
||||
#include "CryptoGenerics.h"
|
||||
#include "CryptoRandom.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "IpAddress.h"
|
||||
#include "IPLocation.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "ChatCommand.h"
|
||||
#include "CryptoRandom.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "IpAddress.h"
|
||||
#include "IPLocation.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "DisableMgr.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "Group.h"
|
||||
#include "IpAddress.h"
|
||||
#include "IPLocation.h"
|
||||
#include "Item.h"
|
||||
#include "ItemBonusMgr.h"
|
||||
|
||||
Reference in New Issue
Block a user