Core/Misc: Port some 3.3.5 cherry-pick refactors
This commit is contained in:
@@ -698,7 +698,7 @@ LocaleConstant CliHandler::GetSessionDbLocaleIndex() const
|
||||
return sObjectMgr->GetDBCLocaleIndex();
|
||||
}
|
||||
|
||||
std::string const AddonChannelCommandHandler::PREFIX = "TrinityCore";
|
||||
std::string_view const AddonChannelCommandHandler::PREFIX = "TrinityCore";
|
||||
|
||||
bool AddonChannelCommandHandler::ParseCommands(std::string_view str)
|
||||
{
|
||||
@@ -740,7 +740,7 @@ bool AddonChannelCommandHandler::ParseCommands(std::string_view str)
|
||||
}
|
||||
}
|
||||
|
||||
void AddonChannelCommandHandler::Send(std::string const& msg)
|
||||
void AddonChannelCommandHandler::Send(std::string_view msg)
|
||||
{
|
||||
WorldPackets::Chat::Chat chat;
|
||||
chat.Initialize(CHAT_MSG_WHISPER, LANG_ADDON, GetSession()->GetPlayer(), GetSession()->GetPlayer(), msg, 0, "", LOCALE_enUS, PREFIX);
|
||||
@@ -750,29 +750,26 @@ void AddonChannelCommandHandler::Send(std::string const& msg)
|
||||
void AddonChannelCommandHandler::SendAck() // a Command acknowledged, no body
|
||||
{
|
||||
ASSERT(echo);
|
||||
char ack[6] = "a";
|
||||
char ack[5] = "a";
|
||||
memcpy(ack + 1, echo, 4);
|
||||
ack[5] = '\0';
|
||||
Send(ack);
|
||||
Send(std::string_view(ack, 5));
|
||||
hadAck = true;
|
||||
}
|
||||
|
||||
void AddonChannelCommandHandler::SendOK() // o Command OK, no body
|
||||
{
|
||||
ASSERT(echo);
|
||||
char ok[6] = "o";
|
||||
char ok[5] = "o";
|
||||
memcpy(ok + 1, echo, 4);
|
||||
ok[5] = '\0';
|
||||
Send(ok);
|
||||
Send(std::string_view(ok, 5));
|
||||
}
|
||||
|
||||
void AddonChannelCommandHandler::SendFailed() // f Command failed, no body
|
||||
{
|
||||
ASSERT(echo);
|
||||
char fail[6] = "f";
|
||||
char fail[5] = "f";
|
||||
memcpy(fail + 1, echo, 4);
|
||||
fail[5] = '\0';
|
||||
Send(fail);
|
||||
Send(std::string_view(fail, 5));
|
||||
}
|
||||
|
||||
// m Command message, message in body
|
||||
|
||||
@@ -159,7 +159,7 @@ class TC_GAME_API CliHandler : public ChatHandler
|
||||
class TC_GAME_API AddonChannelCommandHandler : public ChatHandler
|
||||
{
|
||||
public:
|
||||
static std::string const PREFIX;
|
||||
static std::string_view const PREFIX;
|
||||
|
||||
using ChatHandler::ChatHandler;
|
||||
bool ParseCommands(std::string_view str) override;
|
||||
@@ -168,7 +168,7 @@ class TC_GAME_API AddonChannelCommandHandler : public ChatHandler
|
||||
bool IsHumanReadable() const override { return humanReadable; }
|
||||
|
||||
private:
|
||||
void Send(std::string const& msg);
|
||||
void Send(std::string_view msg);
|
||||
void SendAck();
|
||||
void SendOK();
|
||||
void SendFailed();
|
||||
|
||||
@@ -1435,14 +1435,14 @@ bool Player::TeleportTo(TeleportLocation const& teleportLocation, TeleportToOpti
|
||||
transferPending.TransferSpellID = teleportSpellId;
|
||||
if (teleportLocation.TransportGuid.has_value())
|
||||
{
|
||||
transferPending.Ship.emplace();
|
||||
WorldPackets::Movement::ShipTransferPending& shipTransferPending = transferPending.Ship.emplace();
|
||||
if (TransportSpawn const* transportSpawn = sTransportMgr->GetTransportSpawn(teleportLocation.TransportGuid->GetCounter()))
|
||||
{
|
||||
transferPending.Ship->ID = transportSpawn->TransportGameObjectId;
|
||||
shipTransferPending.ID = transportSpawn->TransportGameObjectId;
|
||||
if (dynamic_cast<Transport*>(GetTransport()))
|
||||
transferPending.Ship->OriginMapID = GetMapId();
|
||||
shipTransferPending.OriginMapID = GetMapId();
|
||||
else
|
||||
transferPending.Ship->OriginMapID = -1;
|
||||
shipTransferPending.OriginMapID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6103,9 +6103,9 @@ void Player::SendActionButtons(uint32 state) const
|
||||
{
|
||||
WorldPackets::Spells::UpdateActionButtons packet;
|
||||
|
||||
for (auto itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ++itr)
|
||||
if (itr->second.uState != ACTIONBUTTON_DELETED && itr->first < packet.ActionButtons.size())
|
||||
packet.ActionButtons[itr->first] = itr->second.packedData;
|
||||
for (auto const& [i, button] : m_actionButtons)
|
||||
if (button.uState != ACTIONBUTTON_DELETED && i < packet.ActionButtons.size())
|
||||
packet.ActionButtons[i] = button.packedData;
|
||||
|
||||
packet.Reason = state;
|
||||
|
||||
@@ -28203,7 +28203,7 @@ void Player::SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& newEqSet)
|
||||
if (newEqSet.Guid != 0)
|
||||
{
|
||||
// something wrong...
|
||||
EquipmentSetContainer::const_iterator itr = _equipmentSets.find(newEqSet.Guid);
|
||||
auto itr = _equipmentSets.find(newEqSet.Guid);
|
||||
if (itr == _equipmentSets.end() || itr->second.Data.Guid != newEqSet.Guid)
|
||||
{
|
||||
TC_LOG_ERROR("entities.player", "Player::SetEquipmentSet: Player '{}' ({}) tried to save nonexistent equipment set {} (index: {})",
|
||||
|
||||
@@ -713,7 +713,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPackets::Chat::CTextEmote& packet)
|
||||
return;
|
||||
}
|
||||
|
||||
sScriptMgr->OnPlayerTextEmote(_player, packet.SoundIndex, packet.EmoteID, packet.Target);
|
||||
sScriptMgr->OnPlayerTextEmote(_player, packet.EmoteID, packet.SoundIndex, packet.Target);
|
||||
|
||||
EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(packet.EmoteID);
|
||||
if (!em)
|
||||
@@ -754,9 +754,8 @@ void WorldSession::HandleTextEmoteOpcode(WorldPackets::Chat::CTextEmote& packet)
|
||||
_player->UpdateCriteria(CriteriaType::DoEmote, packet.EmoteID, 0, 0, unit);
|
||||
|
||||
// Send scripted event call
|
||||
if (unit)
|
||||
if (Creature* creature = unit->ToCreature())
|
||||
creature->AI()->ReceiveEmote(_player, packet.EmoteID);
|
||||
if (Creature* creature = Object::ToCreature(unit))
|
||||
creature->AI()->ReceiveEmote(_player, packet.EmoteID);
|
||||
|
||||
if (emote != EMOTE_ONESHOT_NONE)
|
||||
_player->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Anim);
|
||||
|
||||
@@ -93,15 +93,16 @@ enum TransferAbortReason : uint32
|
||||
TRANSFER_ABORT_MAX_PLAYERS = 2, // Transfer Aborted: instance is full
|
||||
TRANSFER_ABORT_NOT_FOUND = 3, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_TOO_MANY_INSTANCES = 4, // You have entered too many instances recently.
|
||||
TRANSFER_ABORT_LOGGING_OUT = 5,
|
||||
TRANSFER_ABORT_ZONE_IN_COMBAT = 6, // Unable to zone in while an encounter is in progress.
|
||||
TRANSFER_ABORT_INSUF_EXPAN_LVL = 7, // You must have <TBC, WotLK> expansion installed to access this area.
|
||||
TRANSFER_ABORT_DIFFICULTY = 8, // <Normal, Heroic, Epic> difficulty mode is not available for %s.
|
||||
TRANSFER_ABORT_UNIQUE_MESSAGE = 9, // Until you've escaped TLK's grasp, you cannot leave this place!
|
||||
TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 10, // Additional instances cannot be launched, please try again later.
|
||||
TRANSFER_ABORT_NEED_GROUP = 11, // Transfer Aborted: you must be in a raid group to enter this instance
|
||||
TRANSFER_ABORT_NOT_FOUND_2 = 12, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_NOT_FOUND_3 = 13, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_NOT_FOUND_4 = 14, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_NEED_SERVER = 12, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_TIMEOUT = 13, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_BUSY = 14, // Transfer Aborted: instance not found
|
||||
TRANSFER_ABORT_REALM_ONLY = 15, // All players in the party must be from the same realm to enter %s.
|
||||
TRANSFER_ABORT_MAP_NOT_ALLOWED = 16, // Map cannot be entered at this time.
|
||||
TRANSFER_ABORT_LOCKED_TO_DIFFERENT_INSTANCE = 18, // You are already locked to %s
|
||||
|
||||
@@ -5337,14 +5337,14 @@ void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, boo
|
||||
if (!triggeredSpellInfo)
|
||||
return;
|
||||
|
||||
Unit* caster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCaster() : target;
|
||||
if (!caster)
|
||||
return;
|
||||
|
||||
if (mode & AURA_EFFECT_HANDLE_REAL)
|
||||
{
|
||||
if (apply)
|
||||
{
|
||||
Unit* caster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCaster() : target;
|
||||
if (!caster)
|
||||
return;
|
||||
|
||||
CastSpellExtraArgs args(this);
|
||||
if (GetAmount()) // If amount avalible cast with basepoints (Crypt Fever for example)
|
||||
args.AddSpellMod(SPELLVALUE_BASE_POINT0, GetAmount());
|
||||
@@ -5776,11 +5776,6 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
|
||||
target->SendPeriodicAuraLog(&pInfo);
|
||||
}
|
||||
|
||||
bool AuraEffect::IsAreaAuraEffect() const
|
||||
{
|
||||
return GetSpellEffectInfo().IsAreaAuraEffect();
|
||||
}
|
||||
|
||||
void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const
|
||||
{
|
||||
if (!target->IsAlive())
|
||||
|
||||
@@ -104,10 +104,6 @@ class TC_GAME_API AuraEffect
|
||||
|
||||
SpellEffectInfo const& GetSpellEffectInfo() const { return m_effectInfo; }
|
||||
|
||||
bool IsEffect() const { return m_effectInfo.Effect != 0; }
|
||||
bool IsEffect(SpellEffects effectName) const { return m_effectInfo.Effect == effectName; }
|
||||
bool IsAreaAuraEffect() const;
|
||||
|
||||
private:
|
||||
Aura* const m_base;
|
||||
|
||||
|
||||
@@ -514,14 +514,14 @@ AuraScript* Aura::GetScriptByType(std::type_info const& type) const
|
||||
void Aura::_InitEffects(uint32 effMask, Unit* caster, SpellEffectValue const* baseAmount)
|
||||
{
|
||||
// shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
|
||||
_effects.resize(GetSpellInfo()->GetEffects().size());
|
||||
m_effects.resize(GetSpellInfo()->GetEffects().size());
|
||||
|
||||
for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
|
||||
if (effMask & (1 << spellEffectInfo.EffectIndex))
|
||||
_effects[spellEffectInfo.EffectIndex] = new AuraEffect(this, spellEffectInfo, baseAmount ? baseAmount + spellEffectInfo.EffectIndex : nullptr, caster);
|
||||
m_effects[spellEffectInfo.EffectIndex] = new AuraEffect(this, spellEffectInfo, baseAmount ? baseAmount + spellEffectInfo.EffectIndex : nullptr, caster);
|
||||
|
||||
while (!_effects.back())
|
||||
_effects.pop_back();
|
||||
while (!m_effects.back())
|
||||
m_effects.pop_back();
|
||||
}
|
||||
|
||||
bool Aura::CanPeriodicTickCrit() const
|
||||
@@ -544,7 +544,7 @@ Aura::~Aura()
|
||||
delete script;
|
||||
}
|
||||
|
||||
for (AuraEffect* effect : _effects)
|
||||
for (AuraEffect* effect : m_effects)
|
||||
delete effect;
|
||||
|
||||
ASSERT(m_applications.empty());
|
||||
@@ -575,10 +575,10 @@ WorldObject* Aura::GetWorldObjectCaster() const
|
||||
|
||||
AuraEffect* Aura::GetEffect(uint32 index) const
|
||||
{
|
||||
if (index >= _effects.size())
|
||||
if (index >= m_effects.size())
|
||||
return nullptr;
|
||||
|
||||
return _effects[index];
|
||||
return m_effects[index];
|
||||
}
|
||||
|
||||
AuraObjectType Aura::GetType() const
|
||||
@@ -1260,9 +1260,9 @@ AuraKey Aura::GenerateKey(uint32& recalculateMask) const
|
||||
key.SpellId = GetId();
|
||||
key.EffectMask = 0;
|
||||
recalculateMask = 0;
|
||||
for (uint32 i = 0; i < _effects.size(); ++i)
|
||||
for (uint32 i = 0; i < m_effects.size(); ++i)
|
||||
{
|
||||
if (AuraEffect const* effect = _effects[i])
|
||||
if (AuraEffect const* effect = m_effects[i])
|
||||
{
|
||||
key.EffectMask |= 1 << i;
|
||||
if (effect->CanBeRecalculated())
|
||||
|
||||
@@ -362,16 +362,16 @@ class TC_GAME_API Aura
|
||||
Trinity::IteratorPair<DBStorageIterator<AuraEffect*>> GetAuraEffects()
|
||||
{
|
||||
return Trinity::Containers::MakeIteratorPair(
|
||||
DBStorageIterator(_effects.data(), _effects.size()),
|
||||
DBStorageIterator(_effects.data(), _effects.size(), _effects.size()));
|
||||
DBStorageIterator(m_effects.data(), m_effects.size()),
|
||||
DBStorageIterator(m_effects.data(), m_effects.size(), m_effects.size()));
|
||||
}
|
||||
Trinity::IteratorPair<DBStorageIterator<AuraEffect const*>> GetAuraEffects() const
|
||||
{
|
||||
return Trinity::Containers::MakeIteratorPair(
|
||||
DBStorageIterator<AuraEffect const*>(_effects.data(), _effects.size()),
|
||||
DBStorageIterator<AuraEffect const*>(_effects.data(), _effects.size(), _effects.size()));
|
||||
DBStorageIterator<AuraEffect const*>(m_effects.data(), m_effects.size()),
|
||||
DBStorageIterator<AuraEffect const*>(m_effects.data(), m_effects.size(), m_effects.size()));
|
||||
}
|
||||
std::size_t GetAuraEffectCount() const { return _effects.size(); }
|
||||
std::size_t GetAuraEffectCount() const { return m_effects.size(); }
|
||||
|
||||
virtual std::string GetDebugInfo() const;
|
||||
|
||||
@@ -410,6 +410,7 @@ class TC_GAME_API Aura
|
||||
uint8 m_procCharges; // Aura charges (0 for infinite)
|
||||
uint8 m_stackAmount; // Aura stack amount
|
||||
|
||||
AuraEffectVector m_effects;
|
||||
ApplicationMap m_applications;
|
||||
|
||||
bool m_isRemoved;
|
||||
@@ -425,8 +426,6 @@ class TC_GAME_API Aura
|
||||
private:
|
||||
std::vector<AuraApplication*> _removedApplications;
|
||||
|
||||
AuraEffectVector _effects;
|
||||
|
||||
struct NoopAuraDeleter { void operator()(Aura*) const { /*noop - not managed*/ } };
|
||||
Trinity::unique_trackable_ptr<Aura> m_scriptRef;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user