Core/Misc: Port some 3.3.5 cherry-pick refactors

This commit is contained in:
Shauren
2026-05-18 00:28:59 +02:00
parent a4cdedfc6d
commit 6324222cdb
20 changed files with 117 additions and 220 deletions
+50 -69
View File
@@ -214,12 +214,6 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
PlayerInfo& playerInfo = _playersStore[guid];
playerInfo.SetInvisible(!player->isGMVisible());
/*
YouJoinedAppend appender;
ChannelNameBuilder<YouJoinedAppend> builder(this, appender);
SendToOne(builder, guid);
*/
auto builder = [&](LocaleConstant locale)
{
LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
@@ -237,7 +231,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
SendToOne(builder, guid);
JoinNotify(player);
JoinNotify(guid);
// Custom channel handling
if (!IsConstant())
@@ -269,16 +263,8 @@ void Channel::LeaveChannel(Player* player, bool send, bool suspend)
return;
}
player->LeftChannel(this);
if (send)
{
/*
YouLeftAppend appender;
ChannelNameBuilder<YouLeftAppend> builder(this, appender);
SendToOne(builder, guid);
*/
auto builder = [&](LocaleConstant locale)
{
LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
@@ -292,11 +278,12 @@ void Channel::LeaveChannel(Player* player, bool send, bool suspend)
};
SendToOne(builder, guid);
player->LeftChannel(this);
}
PlayerInfo& info = _playersStore.at(guid);
PlayerInfo info = _playersStore.extract(guid).mapped();
bool changeowner = info.IsOwner();
_playersStore.erase(guid);
if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
{
@@ -305,11 +292,11 @@ void Channel::LeaveChannel(Player* player, bool send, bool suspend)
SendToAll(builder);
}
LeaveNotify(player);
LeaveNotify(guid);
if (!IsConstant())
{
// If the channel owner left and there are still playersStore inside, pick a new owner
// If the channel owner left and there are players still inside, pick a new owner
// do not pick invisible gm owner unless there are only invisible gms in that channel (rare)
if (changeowner && _ownershipEnabled && !_playersStore.empty())
{
@@ -323,10 +310,10 @@ void Channel::LeaveChannel(Player* player, bool send, bool suspend)
if (itr == _playersStore.end())
itr = _playersStore.begin();
ObjectGuid const& newowner = itr->first;
ObjectGuid const& newOwner = itr->first;
itr->second.SetModerator(true);
SetOwner(newowner);
SetOwner(newOwner);
// if the new owner is invisible gm, set flag to automatically choose a new owner
if (itr->second.IsInvisible())
@@ -541,6 +528,40 @@ void Channel::SetInvisible(Player const* player, bool on)
_isOwnerInvisible = on;
}
void Channel::SetModerator(ObjectGuid const& guid, bool set)
{
if (!IsOn(guid))
return;
PlayerInfo& playerInfo = _playersStore.at(guid);
if (playerInfo.IsModerator() != set)
{
uint8 oldFlag = playerInfo.GetFlags();
playerInfo.SetModerator(set);
ModeChangeAppend appender(guid, oldFlag, playerInfo.GetFlags());
ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
SendToAll(builder);
}
}
void Channel::SetMute(ObjectGuid const& guid, bool set)
{
if (!IsOn(guid))
return;
PlayerInfo& playerInfo = _playersStore.at(guid);
if (playerInfo.IsMuted() != set)
{
uint8 oldFlag = playerInfo.GetFlags();
playerInfo.SetMuted(set);
ModeChangeAppend appender(guid, oldFlag, playerInfo.GetFlags());
ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
SendToAll(builder);
}
}
void Channel::SetOwner(Player const* player, std::string const& newname)
{
ObjectGuid const& guid = player->GetGUID();
@@ -597,7 +618,7 @@ void Channel::SendWhoOwner(Player const* player)
}
}
void Channel::List(Player const* player)
void Channel::List(Player const* player) const
{
ObjectGuid const& guid = player->GetGUID();
if (!IsOn(guid))
@@ -613,13 +634,13 @@ void Channel::List(Player const* player)
player->GetSession()->GetPlayerInfo(), channelName);
WorldPackets::Channel::ChannelListResponse list;
list._Display = true; /// always true?
list.Display = true; /// always true?
list._Channel = channelName;
list._ChannelFlags = GetFlags();
uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
list._Members.reserve(_playersStore.size());
list.Members.reserve(_playersStore.size());
for (PlayerContainer::value_type const& i : _playersStore)
{
Player* member = ObjectAccessor::FindConnectedPlayer(i.first);
@@ -631,7 +652,7 @@ void Channel::List(Player const* player)
member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) &&
member->IsVisibleGloballyFor(player))
{
list._Members.emplace_back(i.first, *member->m_playerData->VirtualPlayerRealm, i.second.GetFlags());
list.Members.emplace_back(i.first, *member->m_playerData->VirtualPlayerRealm, i.second.GetFlags());
}
}
@@ -661,7 +682,6 @@ void Channel::Announce(Player const* player)
_announceEnabled = !_announceEnabled;
WorldPackets::Channel::ChannelNotify notify;
if (_announceEnabled)
{
AnnouncementsOnAppend appender(guid);
@@ -841,7 +861,6 @@ void Channel::SetOwner(ObjectGuid const& guid, bool exclaim)
{
if (!_ownerGuid.IsEmpty())
{
// [] will re-add player after it possible removed
auto itr = _playersStore.find(_ownerGuid);
if (itr != _playersStore.end())
itr->second.SetOwner(false);
@@ -850,15 +869,15 @@ void Channel::SetOwner(ObjectGuid const& guid, bool exclaim)
_ownerGuid = guid;
if (!_ownerGuid.IsEmpty())
{
uint8 oldFlag = GetPlayerFlags(_ownerGuid);
auto itr = _playersStore.find(_ownerGuid);
if (itr == _playersStore.end())
return;
uint8 oldFlag = itr->second.GetFlags();
itr->second.SetModerator(true);
itr->second.SetOwner(true);
ModeChangeAppend appender(_ownerGuid, oldFlag, GetPlayerFlags(_ownerGuid));
ModeChangeAppend appender(_ownerGuid, oldFlag, itr->second.GetFlags());
ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
SendToAll(builder);
@@ -885,10 +904,8 @@ void Channel::DeclineInvite(Player const* /*player*/)
{
}
void Channel::JoinNotify(Player const* player)
void Channel::JoinNotify(ObjectGuid const& guid) const
{
ObjectGuid const& guid = player->GetGUID();
if (IsConstant())
{
auto builder = [&](LocaleConstant locale)
@@ -927,10 +944,8 @@ void Channel::JoinNotify(Player const* player)
}
}
void Channel::LeaveNotify(Player const* player)
void Channel::LeaveNotify(ObjectGuid const& guid) const
{
ObjectGuid const& guid = player->GetGUID();
auto builder = [&](LocaleConstant locale)
{
LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
@@ -950,40 +965,6 @@ void Channel::LeaveNotify(Player const* player)
SendToAll(builder);
}
void Channel::SetModerator(ObjectGuid const& guid, bool set)
{
if (!IsOn(guid))
return;
PlayerInfo& playerInfo = _playersStore.at(guid);
if (playerInfo.IsModerator() != set)
{
uint8 oldFlag = playerInfo.GetFlags();
playerInfo.SetModerator(set);
ModeChangeAppend appender(guid, oldFlag, playerInfo.GetFlags());
ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
SendToAll(builder);
}
}
void Channel::SetMute(ObjectGuid const& guid, bool set)
{
if (!IsOn(guid))
return;
PlayerInfo& playerInfo = _playersStore.at(guid);
if (playerInfo.IsMuted() != set)
{
uint8 oldFlag = playerInfo.GetFlags();
playerInfo.SetMuted(set);
ModeChangeAppend appender(guid, oldFlag, playerInfo.GetFlags());
ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
SendToAll(builder);
}
}
template <class Builder>
void Channel::SendToAll(Builder& builder, ObjectGuid const& guid, ObjectGuid const& accountGuid) const
{
+3 -11
View File
@@ -27,14 +27,6 @@
class Player;
struct AreaTableEntry;
namespace WorldPackets
{
namespace Channel
{
class ChannelNotify;
}
}
// EnumUtils: DESCRIBE THIS
enum ChatNotify : uint8
{
@@ -218,14 +210,14 @@ class TC_GAME_API Channel
void UnsetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, false); }
void SilenceAll(Player const* player, std::string const& name);
void UnsilenceAll(Player const* player, std::string const& name);
void List(Player const* player);
void List(Player const* player) const;
void Announce(Player const* player);
void Say(ObjectGuid const& guid, std::string const& what, uint32 lang) const;
void AddonSay(ObjectGuid const& guid, std::string const& prefix, std::string const& what, bool isLogged) const;
void DeclineInvite(Player const* player);
void Invite(Player const* player, std::string const& newp);
void JoinNotify(Player const* player);
void LeaveNotify(Player const* player);
void JoinNotify(ObjectGuid const& guid) const;
void LeaveNotify(ObjectGuid const& guid) const;
void SetOwnership(bool ownership) { _ownershipEnabled = ownership; }
private:
@@ -104,7 +104,7 @@ ItemRandomBonusListId GenerateItemRandomBonusListId(uint32 item_id)
return *Trinity::Containers::SelectRandomWeightedContainerElement(tab->second.BonusListIDs, std::span(tab->second.Chances));
}
TC_GAME_API float GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType, uint32 subClass)
float GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType, uint32 subClass)
{
uint32 propIndex;
@@ -168,6 +168,8 @@ TC_GAME_API float GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint
case ITEM_QUALITY_LEGENDARY:
case ITEM_QUALITY_ARTIFACT:
return randPropPointsEntry->EpicF[propIndex];
default:
break;
}
return 0;
@@ -24,6 +24,6 @@ using ItemRandomBonusListId = uint32;
TC_GAME_API void LoadItemRandomBonusListTemplates();
TC_GAME_API ItemRandomBonusListId GenerateItemRandomBonusListId(uint32 item_id);
TC_GAME_API float GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType, uint32 subclass);
TC_GAME_API float GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType, uint32 subClass);
#endif
+2 -7
View File
@@ -22932,8 +22932,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
spellModifier.ModIndex = AsUnderlyingType(mod->op);
boost::dynamic_bitset<uint32> mask;
mask.resize(128);
boost::dynamic_bitset<uint32> mask(128, 0);
boost::from_block_range(
&static_cast<SpellModifierByClassMask const*>(mod)->mask[0],
@@ -25543,11 +25542,7 @@ void Player::SendAurasForTarget(Unit* target) const
update.Auras.reserve(visibleAuras.size());
for (AuraApplication* auraApp : visibleAuras)
{
WorldPackets::Spells::AuraInfo auraInfo;
auraApp->BuildUpdatePacket(auraInfo, false);
update.Auras.push_back(auraInfo);
}
auraApp->BuildUpdatePacket(update.Auras.emplace_back(), false);
SendDirectMessage(update.Write());
}
+7 -6
View File
@@ -2096,6 +2096,8 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit
log.damage = splitDamage;
log.originalDamage = splitDamage;
log.absorb = split_absorb;
log.periodicLog = damageInfo.GetDamageType() == DOT;
log.HitInfo |= SPELL_HIT_TYPE_SPLIT;
caster->SendSpellNonMeleeDamageLog(&log);
// break 'Fear' and similar auras
@@ -12982,7 +12984,6 @@ void Unit::SendTeleportPacket(TeleportLocation const& teleportLocation)
moveUpdateTeleport.Status = &m_movementInfo;
if (_movementForces)
moveUpdateTeleport.MovementForces = _movementForces->GetForces();
Unit* broadcastSource = this;
// should this really be the unit _being_ moved? not the unit doing the moving?
if (Player* playerMover = Unit::ToPlayer(GetUnitBeingMoved()))
@@ -12995,14 +12996,15 @@ void Unit::SendTeleportPacket(TeleportLocation const& teleportLocation)
moveTeleport.SequenceIndex = m_movementCounter++;
playerMover->SendDirectMessage(moveTeleport.Write());
broadcastSource = playerMover;
// Broadcast the packet to everyone except self.
SendMessageToSet(moveUpdateTeleport.Write(), playerMover);
}
else
{
// This is the only packet sent for creatures which contains MovementInfo structure
// we do not update m_movementInfo for creatures so it needs to be done manually here
moveUpdateTeleport.Status->guid = GetGUID();
moveUpdateTeleport.Status->time = getMSTime();
moveUpdateTeleport.Status->time = GameTime::GetGameTimeMS();
if (teleportLocation.TransportGuid)
{
@@ -13018,10 +13020,9 @@ void Unit::SendTeleportPacket(TeleportLocation const& teleportLocation)
moveUpdateTeleport.Status->pos.Relocate(teleportLocation.Location);
moveUpdateTeleport.Status->transport.Reset();
}
}
// Broadcast the packet to everyone except self.
broadcastSource->SendMessageToSet(moveUpdateTeleport.Write(), false);
SendMessageToSet(moveUpdateTeleport.Write(), true);
}
}
bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool teleport)
+10 -10
View File
@@ -620,7 +620,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid)
if (!itemTemplate)
continue;
int32 leftInStock = !vendorItem->maxcount ? -1 : vendor->GetVendorItemCurrentCount(vendorItem);
int32 leftInStock = !vendorItem->maxcount ? -1 : int32(vendor->GetVendorItemCurrentCount(vendorItem));
if (!_player->IsGameMaster()) // ignore conditions if GM on
{
// Respect allowed class
@@ -656,20 +656,20 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid)
price = std::max(uint64(1), price);
item.MuID = slot + 1; // client expects counting to start at 1
item.ExtendedCostID = vendorItem->ExtendedCost;
item.Type = vendorItem->Type;
item.Quantity = leftInStock;
item.StackCount = itemTemplate->GetBuyCount();
item.Price = price;
item.DoNotFilterOnVendor = vendorItem->IgnoreFiltering;
item.Refundable = itemTemplate->HasFlag(ITEM_FLAG_ITEM_PURCHASE_RECORD) && vendorItem->ExtendedCost && itemTemplate->GetMaxStackSize() == 1;
item.Item.ItemID = vendorItem->item;
if (!vendorItem->BonusListIDs.empty())
{
item.Item.ItemBonus.emplace();
item.Item.ItemBonus->BonusListIDs = vendorItem->BonusListIDs;
}
item.Quantity = leftInStock;
item.Price = price;
item.StackCount = itemTemplate->GetBuyCount();
item.ExtendedCostID = vendorItem->ExtendedCost;
item.DoNotFilterOnVendor = vendorItem->IgnoreFiltering;
item.Refundable = itemTemplate->HasFlag(ITEM_FLAG_ITEM_PURCHASE_RECORD) && vendorItem->ExtendedCost && itemTemplate->GetMaxStackSize() == 1;
}
else if (vendorItem->Type == ITEM_VENDOR_TYPE_CURRENCY)
{
@@ -681,10 +681,10 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid)
continue; // there's no price defined for currencies, only extendedcost is used
item.MuID = slot + 1; // client expects counting to start at 1
item.ExtendedCostID = vendorItem->ExtendedCost;
item.Item.ItemID = vendorItem->item;
item.Type = vendorItem->Type;
item.Item.ItemID = vendorItem->item;
item.StackCount = vendorItem->maxcount;
item.ExtendedCostID = vendorItem->ExtendedCost;
item.DoNotFilterOnVendor = vendorItem->IgnoreFiltering;
}
else
+3
View File
@@ -727,6 +727,9 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPackets::Spells::PetCastSpell&
return;
}
if (petCastSpell.Cast.MoveUpdate)
HandleMovementOpcode(CMSG_MOVE_STOP, *petCastSpell.Cast.MoveUpdate);
Spell* spell = new Spell(caster, spellInfo, triggerCastFlags);
spell->m_fromClient = true;
std::ranges::copy(petCastSpell.Cast.Misc, std::ranges::begin(spell->m_misc.Raw.Data));
+7 -7
View File
@@ -228,13 +228,13 @@ void WorldSession::HandleGameobjectReportUse(WorldPackets::GameObject::GameObjRe
}
}
void WorldSession::HandleCastSpellOpcode(WorldPackets::Spells::CastSpell& cast)
void WorldSession::HandleCastSpellOpcode(WorldPackets::Spells::CastSpell& castRequest)
{
// Skip casting invalid spells right away
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cast.Cast.SpellID, _player->GetMap()->GetDifficultyID());
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(castRequest.Cast.SpellID, _player->GetMap()->GetDifficultyID());
if (!spellInfo)
{
TC_LOG_ERROR("network", "WorldSession::HandleCastSpellOpcode: attempted to cast a non-existing spell (Id: {})", cast.Cast.SpellID);
TC_LOG_ERROR("network", "WorldSession::HandleCastSpellOpcode: attempted to cast a non-existing spell (Id: {})", castRequest.Cast.SpellID);
return;
}
@@ -254,13 +254,13 @@ void WorldSession::HandleCastSpellOpcode(WorldPackets::Spells::CastSpell& cast)
castingUnit = _player;
}
if (cast.Cast.MoveUpdate.has_value())
HandleMovementOpcode(CMSG_MOVE_STOP, *cast.Cast.MoveUpdate);
if (castRequest.Cast.MoveUpdate.has_value())
HandleMovementOpcode(CMSG_MOVE_STOP, *castRequest.Cast.MoveUpdate);
if (_player->CanRequestSpellCast(spellInfo, castingUnit))
_player->RequestSpellCast(std::make_unique<SpellCastRequest>(std::move(cast.Cast), castingUnit->GetGUID()));
_player->RequestSpellCast(std::make_unique<SpellCastRequest>(std::move(castRequest.Cast), castingUnit->GetGUID()));
else
Spell::SendCastResult(_player, spellInfo, {}, cast.Cast.CastID, SPELL_FAILED_SPELL_IN_PROGRESS);
Spell::SendCastResult(_player, spellInfo, {}, castRequest.Cast.CastID, SPELL_FAILED_SPELL_IN_PROGRESS);
}
void WorldSession::HandleCancelCastOpcode(WorldPackets::Spells::CancelCast& packet)
@@ -24,13 +24,13 @@ namespace WorldPackets::Channel
{
WorldPacket const* ChannelListResponse::Write()
{
_worldPacket << Bits<1>(_Display);
_worldPacket << Bits<1>(Display);
_worldPacket << SizedString::BitsSize<7>(_Channel);
_worldPacket << uint32(_ChannelFlags);
_worldPacket << Size<uint32>(_Members);
_worldPacket << Size<uint32>(Members);
_worldPacket << SizedString::Data(_Channel);
for (ChannelPlayer const& player : _Members)
for (ChannelPlayer const& player : Members)
{
_worldPacket << player.Guid;
_worldPacket << uint32(player.VirtualRealmAddress);
@@ -42,10 +42,10 @@ namespace WorldPackets
WorldPacket const* Write() override;
std::vector<ChannelPlayer> _Members;
std::vector<ChannelPlayer> Members;
std::string _Channel; ///< Channel Name
uint32 _ChannelFlags = 0; ///< @see enum ChannelFlags
bool _Display = false;
bool Display = false;
};
class TC_GAME_API ChannelNotify final : public ServerPacket
@@ -246,7 +246,7 @@ namespace WorldPackets
class MoveSplineSetFlag final : public ServerPacket
{
public:
explicit MoveSplineSetFlag(OpcodeServer opcode) : ServerPacket(opcode, 8) { }
explicit MoveSplineSetFlag(OpcodeServer opcode) : ServerPacket(opcode, 18) { }
WorldPacket const* Write() override;
@@ -256,7 +256,7 @@ namespace WorldPackets
class MoveSetFlag final : public ServerPacket
{
public:
explicit MoveSetFlag(OpcodeServer opcode) : ServerPacket(opcode, 12) { }
explicit MoveSetFlag(OpcodeServer opcode) : ServerPacket(opcode, 18 + 4) { }
WorldPacket const* Write() override;
@@ -139,7 +139,7 @@ namespace WorldPackets
class SetActionButton final : public ClientPacket
{
public:
explicit SetActionButton(WorldPacket&& packet) : ClientPacket(CMSG_SET_ACTION_BUTTON, std::move(packet)) {}
explicit SetActionButton(WorldPacket&& packet) : ClientPacket(CMSG_SET_ACTION_BUTTON, std::move(packet)) { }
void Read() override;
@@ -24,7 +24,7 @@
enum AURA_FLAGS
{
AFLAG_NONE = 0x0000,
AFLAG_NOCASTER = 0x0001,
AFLAG_SELF_CAST = 0x0001,
AFLAG_POSITIVE = 0x0002,
AFLAG_DURATION = 0x0004,
AFLAG_SCALABLE = 0x0008,
+3 -6
View File
@@ -113,7 +113,7 @@ void AuraApplication::_Remove()
void AuraApplication::_InitFlags(Unit* caster, uint32 effMask)
{
// mark as selfcast if needed
_flags |= (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_NOCASTER : AFLAG_NONE;
_flags |= (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_SELF_CAST : AFLAG_NONE;
// aura is cast by self or an enemy
// one negative effect and we know aura is negative
@@ -261,7 +261,7 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo
auraData.Applications = aura->IsUsingStacks() ? aura->GetStackAmount() : aura->GetCharges();
if (!aura->GetCasterGUID().IsUnit())
auraData.CastUnit = ObjectGuid::Empty; // optional data is filled in, but cast unit contains empty guid in packet
else if (!(auraData.Flags & AFLAG_NOCASTER))
else if (!(auraData.Flags & AFLAG_SELF_CAST))
auraData.CastUnit = aura->GetCasterGUID();
if (!aura->GetCastItemGUID().IsEmpty())
@@ -304,10 +304,7 @@ void AuraApplication::ClientUpdate(bool remove)
WorldPackets::Spells::AuraUpdate update;
update.UpdateAll = false;
update.UnitGUID = GetTarget()->GetGUID();
WorldPackets::Spells::AuraInfo auraInfo;
BuildUpdatePacket(auraInfo, remove);
update.Auras.push_back(auraInfo);
BuildUpdatePacket(update.Auras.emplace_back(), remove);
_target->SendMessageToSet(update.Write(), true);
}
+1 -1
View File
@@ -86,7 +86,7 @@ class TC_GAME_API AuraApplication
uint32 GetEffectMask() const { return _effectMask; }
bool HasEffect(uint8 effect) const { ASSERT(effect < MAX_SPELL_EFFECTS); return (_effectMask & (1 << effect)) != 0; }
bool IsPositive() const { return (_flags & AFLAG_POSITIVE) != 0; }
bool IsSelfcast() const { return (_flags & AFLAG_NOCASTER) != 0; }
bool IsSelfcast() const { return (_flags & AFLAG_SELF_CAST) != 0; }
uint32 GetEffectsToApply() const { return _effectsToApply; }
void UpdateApplyEffectMask(uint32 newEffMask, bool canHandleNewEffects);
+16 -89
View File
@@ -4441,7 +4441,7 @@ void Spell::finish(SpellCastResult result)
}
template<class T>
inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo const* spellInfo, SpellCastResult result, SpellCustomErrors customError, int32* param1 /*= nullptr*/, int32* param2 /*= nullptr*/, Player* caster)
inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo const* spellInfo, SpellCastResult result, SpellCustomErrors customError, int32* param1, int32* param2)
{
packet.CastID = castId;
packet.SpellID = spellInfo->Id;
@@ -4490,30 +4490,26 @@ inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo cons
if (param1)
{
packet.FailedArg1 = *param1;
if (param2)
packet.FailedArg2 = *param2;
}
else
{
if (spellInfo->Totem[0])
packet.FailedArg1 = spellInfo->Totem[0];
if (spellInfo->Totem[1])
packet.FailedArg2 = spellInfo->Totem[1];
else if (spellInfo->Totem[1])
packet.FailedArg1 = spellInfo->Totem[1];
}
break;
case SPELL_FAILED_TOTEM_CATEGORY:
if (param1)
{
packet.FailedArg1 = *param1;
if (param2)
packet.FailedArg2 = *param2;
}
else
{
if (spellInfo->TotemCategory[0])
packet.FailedArg1 = spellInfo->TotemCategory[0];
if (spellInfo->TotemCategory[1])
packet.FailedArg2 = spellInfo->TotemCategory[1];
else if (spellInfo->TotemCategory[1])
packet.FailedArg1 = spellInfo->TotemCategory[1];
}
break;
case SPELL_FAILED_EQUIPPED_ITEM_CLASS:
@@ -4531,68 +4527,34 @@ inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo cons
}
break;
case SPELL_FAILED_TOO_MANY_OF_ITEM:
{
if (param1)
packet.FailedArg1 = *param1;
else
{
uint32 item = 0;
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
{
if (uint32 itemType = spellEffectInfo.ItemType)
{
item = itemType;
break;
}
}
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item);
if (proto && proto->GetItemLimitCategory())
packet.FailedArg1 = proto->GetItemLimitCategory();
}
packet.FailedArg1 = *param1; // ItemLimitCategory id
break;
}
case SPELL_FAILED_PREVENTED_BY_MECHANIC:
if (param1)
packet.FailedArg1 = *param1;
else
packet.FailedArg1 = spellInfo->GetAllEffectsMechanicMask(); // SpellMechanic.dbc id
break;
case SPELL_FAILED_NEED_EXOTIC_AMMO:
if (param1)
packet.FailedArg1 = *param1;
else
packet.FailedArg1 = spellInfo->EquippedItemSubClassMask; // seems correct...
packet.FailedArg1 = *param1; // weapon subclass id
break;
case SPELL_FAILED_NEED_MORE_ITEMS:
if (param1 && param2)
{
packet.FailedArg1 = *param1;
packet.FailedArg2 = *param2;
}
else
{
packet.FailedArg1 = 0; // Item id
packet.FailedArg2 = 0; // Item count?
packet.FailedArg1 = *param1; // Item id
packet.FailedArg2 = *param2; // Item count
}
break;
case SPELL_FAILED_MIN_SKILL:
if (param1 && param2)
{
packet.FailedArg1 = *param1;
packet.FailedArg2 = *param2;
}
else
{
packet.FailedArg1 = 0; // SkillLine.dbc id
packet.FailedArg2 = 0; // required skill value
packet.FailedArg1 = *param1; // SkillLine.dbc id
packet.FailedArg2 = *param2; // required skill value
}
break;
case SPELL_FAILED_FISHING_TOO_LOW:
if (param1)
packet.FailedArg1 = *param1;
else
packet.FailedArg1 = 0; // required fishing skill
packet.FailedArg1 = *param1; // required fishing skill
break;
case SPELL_FAILED_CUSTOM_ERROR:
packet.FailedArg1 = customError;
@@ -4604,44 +4566,9 @@ inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo cons
packet.FailedArg1 = 0; // Unknown
break;
case SPELL_FAILED_REAGENTS:
{
if (param1)
packet.FailedArg1 = *param1;
else
{
for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
{
if (spellInfo->Reagent[i] <= 0)
continue;
uint32 itemid = spellInfo->Reagent[i];
uint32 itemcount = spellInfo->ReagentCount[i];
if (caster && !caster->HasItemCount(itemid, itemcount))
{
packet.FailedArg1 = itemid; // first missing item
break;
}
}
}
if (param2)
packet.FailedArg2 = *param2;
else if (!param1)
{
for (SpellReagentsCurrencyEntry const* reagentsCurrency : spellInfo->ReagentsCurrency)
{
if (caster && !caster->HasCurrency(reagentsCurrency->CurrencyTypesID, reagentsCurrency->CurrencyCount))
{
packet.FailedArg1 = -1;
packet.FailedArg2 = reagentsCurrency->CurrencyTypesID;
break;
}
}
}
break;
}
case SPELL_FAILED_CANT_UNTALENT:
{
ASSERT(param1);
@@ -4675,7 +4602,7 @@ void Spell::SendCastResult(SpellCastResult result, int32* param1 /*= nullptr*/,
WorldPackets::Spells::CastFailed castFailed;
castFailed.Visual = m_SpellVisual;
FillSpellCastFailedArgs(castFailed, m_castId, m_spellInfo, result, m_customError, param1, param2, m_caster->ToPlayer());
FillSpellCastFailedArgs(castFailed, m_castId, m_spellInfo, result, m_customError, param1, param2);
receiver->SendDirectMessage(castFailed.Write());
}
@@ -4692,18 +4619,18 @@ void Spell::SendPetCastResult(SpellCastResult result, int32* param1 /*= nullptr*
result = SPELL_FAILED_DONT_REPORT;
WorldPackets::Spells::PetCastFailed petCastFailed;
FillSpellCastFailedArgs(petCastFailed, m_castId, m_spellInfo, result, SPELL_CUSTOM_ERROR_NONE, param1, param2, owner->ToPlayer());
FillSpellCastFailedArgs(petCastFailed, m_castId, m_spellInfo, result, SPELL_CUSTOM_ERROR_NONE, param1, param2);
owner->ToPlayer()->SendDirectMessage(petCastFailed.Write());
}
void Spell::SendCastResult(Player* caster, SpellInfo const* spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError /*= SPELL_CUSTOM_ERROR_NONE*/, int32* param1 /*= nullptr*/, int32* param2 /*= nullptr*/)
void Spell::SendCastResult(Player const* caster, SpellInfo const* spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError /*= SPELL_CUSTOM_ERROR_NONE*/, int32* param1 /*= nullptr*/, int32* param2 /*= nullptr*/)
{
if (result == SPELL_CAST_OK)
return;
WorldPackets::Spells::CastFailed packet;
packet.Visual = spellVisual;
FillSpellCastFailedArgs(packet, cast_count, spellInfo, result, customError, param1, param2, caster);
FillSpellCastFailedArgs(packet, cast_count, spellInfo, result, customError, param1, param2);
caster->SendDirectMessage(packet.Write());
}
+1 -1
View File
@@ -559,7 +559,7 @@ class TC_GAME_API Spell
void CheckSrc();
void CheckDst();
static void SendCastResult(Player* caster, SpellInfo const* spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, int32* param1 = nullptr, int32* param2 = nullptr);
static void SendCastResult(Player const* caster, SpellInfo const* spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, int32* param1 = nullptr, int32* param2 = nullptr);
void SendCastResult(SpellCastResult result, int32* param1 = nullptr, int32* param2 = nullptr) const;
void SendPetCastResult(SpellCastResult result, int32* param1 = nullptr, int32* param2 = nullptr) const;
void SendMountResult(MountResult result);
+1 -1
View File
@@ -437,7 +437,7 @@ public:
float GetSpeedZ() const { return m_speed * std::sin(m_pitch); }
void Update(WorldObject* caster);
std::string GetTargetString() const { return m_strTarget; }
std::string const& GetTargetString() const { return m_strTarget; }
private:
uint32 m_targetMask;
-1
View File
@@ -301,7 +301,6 @@ public:
castFailed.FailedArg1 = failArg1.value_or(-1);
castFailed.FailedArg2 = failArg2.value_or(-1);
handler->GetSession()->SendPacket(castFailed.Write());
return true;
}