mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 10:03:47 +00:00
Fix corrupt item cache crashes, bot whispers, trade crashes
This commit is contained in:
@@ -212,6 +212,7 @@ Unit::Unit(bool isWorldObject) : WorldObject(isWorldObject),
|
||||
m_vehicleKit(nullptr),
|
||||
m_unitTypeMask(UNIT_MASK_NONE),
|
||||
m_HostileRefMgr(this),
|
||||
m_cannotReachTarget(false),
|
||||
m_comboTarget(nullptr),
|
||||
m_comboPoints(0)
|
||||
{
|
||||
@@ -9704,15 +9705,32 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem
|
||||
}
|
||||
}
|
||||
|
||||
return GetFactionReactionTo(factionTemplateEntry, targetFactionTemplateEntry);
|
||||
}
|
||||
|
||||
ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, FactionTemplateEntry const* targetFactionTemplateEntry)
|
||||
{
|
||||
// common faction based check
|
||||
if (factionTemplateEntry->IsHostileTo(*targetFactionTemplateEntry))
|
||||
{
|
||||
return REP_HOSTILE;
|
||||
}
|
||||
|
||||
if (factionTemplateEntry->IsFriendlyTo(*targetFactionTemplateEntry))
|
||||
{
|
||||
return REP_FRIENDLY;
|
||||
}
|
||||
|
||||
if (targetFactionTemplateEntry->IsFriendlyTo(*factionTemplateEntry))
|
||||
{
|
||||
return REP_FRIENDLY;
|
||||
}
|
||||
|
||||
if (factionTemplateEntry->factionFlags & FACTION_TEMPLATE_FLAG_HATES_ALL_EXCEPT_FRIENDS)
|
||||
{
|
||||
return REP_HOSTILE;
|
||||
}
|
||||
|
||||
// neutral by default
|
||||
return REP_NEUTRAL;
|
||||
}
|
||||
@@ -18304,11 +18322,23 @@ void Unit::SendPlaySpellVisual(uint32 id)
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendPlaySpellVisual(ObjectGuid guid, uint32 id)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4);
|
||||
data << guid;
|
||||
data << uint32(id); // SpellVisualKit.dbc index
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendPlaySpellImpact(ObjectGuid guid, uint32 id)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SPELL_IMPACT, 8 + 4);
|
||||
data << guid; // target
|
||||
data << uint32(id); // SpellVisualKit.dbc index
|
||||
|
||||
if (IsPlayer())
|
||||
ToPlayer()->SendDirectMessage(&data);
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
@@ -20529,3 +20559,15 @@ bool Unit::CanRestoreMana(SpellInfo const* spellInfo) const
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::SetCannotReachTarget(bool cannotReach, bool /*isChase = true*/)
|
||||
{
|
||||
if (cannotReach == m_cannotReachTarget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_cannotReachTarget = cannotReach;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1442,6 +1442,7 @@ public:
|
||||
|
||||
ReputationRank GetReactionTo(Unit const* target, bool checkOriginalFaction = false) const;
|
||||
ReputationRank GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, Unit const* target) const;
|
||||
static ReputationRank GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, FactionTemplateEntry const* targetFactionTemplateEntry);
|
||||
|
||||
bool IsHostileTo(Unit const* unit) const;
|
||||
[[nodiscard]] bool IsHostileToPlayers() const;
|
||||
@@ -1662,6 +1663,7 @@ public:
|
||||
Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
|
||||
void SetAuraStack(uint32 spellId, Unit* target, uint32 stack);
|
||||
void SendPlaySpellVisual(uint32 id);
|
||||
void SendPlaySpellVisual(ObjectGuid guid, uint32 id);
|
||||
void SendPlaySpellImpact(ObjectGuid guid, uint32 id);
|
||||
void BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown);
|
||||
void BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns);
|
||||
@@ -2381,6 +2383,9 @@ public:
|
||||
|
||||
[[nodiscard]] bool CanRestoreMana(SpellInfo const* spellInfo) const;
|
||||
|
||||
virtual bool SetCannotReachTarget(bool cannotReach, bool isChase = true);
|
||||
[[nodiscard]] bool CanNotReachTarget() const { return m_cannotReachTarget; }
|
||||
|
||||
protected:
|
||||
explicit Unit (bool isWorldObject);
|
||||
|
||||
@@ -2463,6 +2468,8 @@ protected:
|
||||
bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
|
||||
bool _instantCast;
|
||||
|
||||
bool m_cannotReachTarget;
|
||||
|
||||
private:
|
||||
bool IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const*& spellProcEvent, ProcEventInfo const& eventInfo);
|
||||
bool HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||
|
||||
Reference in New Issue
Block a user