diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-08-25 00:27:37 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-10-23 00:11:44 +0200 |
commit | a5989dcee9150565e7f4b8e3f7a62a414a484a3f (patch) | |
tree | e20ec1eeddf0857b1f44fa045a8ed40a72081ab7 | |
parent | ab95c5e9d7b848716e1c9432754f29c65cdb9382 (diff) |
Core/Unit: Store charmer and charmed pointers on Unit directly, no more map lookups for Unit::GetCharmer and Unit::GetCharmed
(cherry picked from commit d4ef2529e91043bc719c3238714413fd21c9005c)
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/TemporarySummon.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 10 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 87 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 47 | ||||
-rw-r--r-- | src/server/game/Handlers/PetHandler.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Handlers/SpellHandler.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Handlers/VehicleHandler.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 8 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_hunter.cpp | 2 |
10 files changed, 85 insertions, 83 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 0d35077cebd..37f90c6e006 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -1347,7 +1347,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* error = LFG_TELEPORT_RESULT_EXHAUSTION; else if (player->GetVehicle()) error = LFG_TELEPORT_RESULT_ON_TRANSPORT; - else if (!player->GetCharmGUID().IsEmpty()) + else if (!player->GetCharmedGUID().IsEmpty()) error = LFG_TELEPORT_RESULT_IMMUNE_TO_SUMMONS; else if (player->HasAura(9454)) // check Freeze debuff error = LFG_TELEPORT_RESULT_NO_RETURN_LOCATION; diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 1ccb481c8a7..ef516455968 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -340,7 +340,7 @@ void Guardian::InitSummon() if (GetOwner()->GetTypeId() == TYPEID_PLAYER && GetOwner()->GetMinionGUID() == GetGUID() - && !GetOwner()->GetCharmGUID()) + && !GetOwner()->GetCharmedGUID()) { GetOwner()->ToPlayer()->CharmSpellInitialize(); } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 7b0861bf83b..bec840089fc 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21924,7 +21924,7 @@ void Player::RemovePetAura(PetAura const* petSpell) void Player::StopCastingCharm() { - Unit* charm = GetCharm(); + Unit* charm = GetCharmed(); if (!charm) return; @@ -21935,12 +21935,12 @@ void Player::StopCastingCharm() else if (charm->IsVehicle()) ExitVehicle(); } - if (!GetCharmGUID().IsEmpty()) + if (!GetCharmedGUID().IsEmpty()) charm->RemoveCharmAuras(); - if (!GetCharmGUID().IsEmpty()) + if (!GetCharmedGUID().IsEmpty()) { - TC_LOG_FATAL("entities.player", "Player::StopCastingCharm: Player '%s' (%s) is not able to uncharm unit (%s)", GetName().c_str(), GetGUID().ToString().c_str(), GetCharmGUID().ToString().c_str()); + TC_LOG_FATAL("entities.player", "Player::StopCastingCharm: Player '%s' (%s) is not able to uncharm unit (%s)", GetName().c_str(), GetGUID().ToString().c_str(), GetCharmedGUID().ToString().c_str()); if (!charm->GetCharmerGUID().IsEmpty()) { TC_LOG_FATAL("entities.player", "Player::StopCastingCharm: Charmed unit has charmer %s", charm->GetCharmerGUID().ToString().c_str()); @@ -22151,7 +22151,7 @@ void Player::PetSpellInitialize() void Player::PossessSpellInitialize() { - Unit* charm = GetCharm(); + Unit* charm = GetCharmed(); if (!charm) return; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f46ec932614..93db566db4e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -302,6 +302,7 @@ Unit::Unit(bool isWorldObject) : LastCharmerGUID(), m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()), m_AutoRepeatFirstCast(false), m_procDeep(0), m_removedAurasCount(0), m_interruptMask(SpellAuraInterruptFlags::None), m_interruptMask2(SpellAuraInterruptFlags2::None), + m_charmer(nullptr), m_charmed(nullptr), i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_vehicle(nullptr), m_vehicleKit(nullptr), m_unitTypeMask(UNIT_MASK_NONE), m_Diminishing(), m_combatManager(this), m_threatManager(this), _aiAnimKitId(0), _movementAnimKitId(0), _meleeAnimKitId(0), @@ -5746,15 +5747,6 @@ Player* Unit::GetControllingPlayer() const return const_cast<Player*>(ToPlayer()); } -Unit* Unit::GetCharmer() const -{ - ObjectGuid charmerGUID = GetCharmerGUID(); - if (!charmerGUID.IsEmpty()) - return ObjectAccessor::GetUnit(*this, charmerGUID); - - return nullptr; -} - Minion* Unit::GetFirstMinion() const { ObjectGuid pet_guid = GetMinionGUID(); @@ -5787,26 +5779,6 @@ Guardian* Unit::GetGuardianPet() const return nullptr; } -Unit* Unit::GetCharm() const -{ - ObjectGuid charm_guid = GetCharmGUID(); - if (!charm_guid.IsEmpty()) - { - if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) - return pet; - - TC_LOG_ERROR("entities.unit", "Unit::GetCharm: Charmed creature %s not exist.", charm_guid.ToString().c_str()); - const_cast<Unit*>(this)->SetCharmGUID(ObjectGuid::Empty); - } - - return nullptr; -} - -Unit* Unit::GetCharmerOrOwner() const -{ - return !GetCharmerGUID().IsEmpty() ? GetCharmer() : GetOwner(); -} - void Unit::SetMinion(Minion *minion, bool apply) { TC_LOG_DEBUG("entities.unit", "SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply); @@ -5933,7 +5905,7 @@ void Unit::SetMinion(Minion *minion, bool apply) for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) { // do not use this check, creature do not have charm guid - //if (GetCharmGUID() == (*itr)->GetGUID()) + //if (GetCharmedGUID() == (*itr)->GetGUID()) if (GetGUID() == (*itr)->GetCharmerGUID()) continue; @@ -5951,7 +5923,7 @@ void Unit::SetMinion(Minion *minion, bool apply) SetMinionGUID((*itr)->GetGUID()); // show another pet bar if there is no charm bar - if (GetTypeId() == TYPEID_PLAYER && !GetCharmGUID()) + if (GetTypeId() == TYPEID_PLAYER && !GetCharmedGUID()) { if ((*itr)->IsPet()) ToPlayer()->PetSpellInitialize(); @@ -5995,10 +5967,8 @@ void Unit::SetCharm(Unit* charm, bool apply) { if (GetTypeId() == TYPEID_PLAYER) { - if (GetCharmGUID().IsEmpty()) - SetCharmGUID(charm->GetGUID()); - else - TC_LOG_FATAL("entities.unit", "Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmGUID().ToString().c_str()); + if (!SetCharmedData(charm)) + TC_LOG_FATAL("entities.unit", "Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmedGUID().ToString().c_str()); charm->m_ControlledByPlayer = true; /// @todo maybe we can use this flag to check if controlled by player @@ -6010,9 +5980,7 @@ void Unit::SetCharm(Unit* charm, bool apply) // PvP, FFAPvP charm->SetPvpFlags(GetPvpFlags()); - if (charm->GetCharmGUID().IsEmpty()) - charm->SetCharmerGUID(GetGUID()); - else + if (!charm->SetCharmerData(this)) TC_LOG_FATAL("entities.unit", "Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); _isWalkingBeforeCharm = charm->IsWalking(); @@ -6027,15 +5995,11 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { - if (GetCharmGUID() == charm->GetGUID()) - SetCharmGUID(ObjectGuid::Empty); - else - TC_LOG_FATAL("entities.unit", "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmGUID().ToString().c_str()); + if (!ClearCharmedData(charm)) + TC_LOG_FATAL("entities.unit", "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmedGUID().ToString().c_str()); } - if (charm->GetCharmerGUID() == GetGUID()) - charm->SetCharmerGUID(ObjectGuid::Empty); - else + if (!charm->ClearCharmerData(this)) TC_LOG_FATAL("entities.unit", "Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); if (charm->GetTypeId() == TYPEID_PLAYER) @@ -6147,7 +6111,7 @@ Unit* Unit::GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo / Unit* Unit::GetFirstControlled() const { // Sequence: charmed, pet, other guardians - Unit* unit = GetCharm(); + Unit* unit = GetCharmed(); if (!unit) { ObjectGuid guid = GetMinionGUID(); @@ -6179,8 +6143,8 @@ void Unit::RemoveAllControlled() TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its pet %s", GetEntry(), GetPetGUID().ToString().c_str()); if (!GetMinionGUID().IsEmpty()) TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its minion %s", GetEntry(), GetMinionGUID().ToString().c_str()); - if (!GetCharmGUID().IsEmpty()) - TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmGUID().ToString().c_str()); + if (!GetCharmedGUID().IsEmpty()) + TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmedGUID().ToString().c_str()); if (!IsPet()) // pets don't use the flag for this RemoveUnitFlag(UNIT_FLAG_PET_IN_COMBAT); // m_controlled is now empty, so we know none of our minions are in combat } @@ -6192,12 +6156,12 @@ bool Unit::isPossessedByPlayer() const bool Unit::isPossessing(Unit* u) const { - return u->isPossessed() && GetCharmGUID() == u->GetGUID(); + return u->isPossessed() && GetCharmedGUID() == u->GetGUID(); } bool Unit::isPossessing() const { - if (Unit* u = GetCharm()) + if (Unit* u = GetCharmed()) return u->isPossessed(); else return false; @@ -7543,7 +7507,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) } // if we have charmed npc, stun him also (everywhere) - if (Unit* charm = player->GetCharm()) + if (Unit* charm = player->GetCharmed()) if (charm->GetTypeId() == TYPEID_UNIT) charm->AddUnitFlag(UNIT_FLAG_STUNNED); @@ -7587,7 +7551,7 @@ void Unit::Dismount() player->ResummonPetTemporaryUnSummonedIfAny(); // if we have charmed npc, remove stun also - if (Unit* charm = player->GetCharm()) + if (Unit* charm = player->GetCharmed()) if (charm->GetTypeId() == TYPEID_UNIT && charm->HasUnitFlag(UNIT_FLAG_STUNNED) && !charm->HasUnitState(UNIT_STATE_STUNNED)) charm->RemoveUnitFlag(UNIT_FLAG_STUNNED); } @@ -9160,11 +9124,11 @@ void Unit::RemoveFromWorld() RemoveAllFollowers(); - if (!GetCharmerGUID().IsEmpty()) - { - TC_LOG_FATAL("entities.unit", "Unit %u has charmer guid when removed from world", GetEntry()); - ABORT(); - } + if (IsCharmed()) + RemoveCharmedBy(nullptr); + + ASSERT(!GetCharmedGUID(), "Unit %u has charmed guid when removed from world", GetEntry()); + ASSERT(!GetCharmerGUID(), "Unit %u has charmer guid when removed from world", GetEntry()); if (Unit* owner = GetOwner()) { @@ -11104,7 +11068,12 @@ void Unit::RemoveCharmedBy(Unit* charmer) } if (GetTypeId() != TYPEID_PLAYER || charmer->GetTypeId() == TYPEID_UNIT) - GetAI()->OnCharmed(false); // AI will potentially schedule a charm ai update + { + if (UnitAI* charmedAI = GetAI()) + charmedAI->OnCharmed(false); // AI will potentially schedule a charm ai update + else + ScheduleAIChange(); + } if (Player* player = ToPlayer()) player->SetClientControl(this, true); @@ -12176,7 +12145,7 @@ void Unit::OutDebugInfo() const { TC_LOG_ERROR("entities.unit", "Unit::OutDebugInfo"); TC_LOG_DEBUG("entities.unit", "%s name %s", GetGUID().ToString().c_str(), GetName().c_str()); - TC_LOG_DEBUG("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmGUID().ToString().c_str()); + TC_LOG_DEBUG("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmedGUID().ToString().c_str()); TC_LOG_DEBUG("entities.unit", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask); if (IsInWorld()) TC_LOG_DEBUG("entities.unit", "Mapid %u", GetMapId()); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 78251ef831d..e93563bcd25 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1233,10 +1233,6 @@ class TC_GAME_API Unit : public WorldObject void SetCreatorGUID(ObjectGuid creator) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::CreatedBy), creator); } ObjectGuid GetMinionGUID() const { return m_unitData->Summon; } void SetMinionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Summon), guid); } - ObjectGuid GetCharmerGUID() const { return m_unitData->CharmedBy; } - void SetCharmerGUID(ObjectGuid owner) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::CharmedBy), owner); } - ObjectGuid GetCharmGUID() const { return m_unitData->Charm; } - void SetCharmGUID(ObjectGuid charm) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Charm), charm); } ObjectGuid GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; } void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; } ObjectGuid GetCritterGUID() const { return m_unitData->Critter; } @@ -1246,6 +1242,43 @@ class TC_GAME_API Unit : public WorldObject ObjectGuid GetDemonCreatorGUID() const { return m_unitData->DemonCreator; } void SetDemonCreatorGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DemonCreator), guid); } + bool SetCharmerData(Unit const* unit) + { + if (!GetCharmerGUID().IsEmpty()) + return false; + SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::CharmedBy), unit->GetGUID()); + m_charmer = const_cast<Unit*>(unit); + return true; + } + bool ClearCharmerData(Unit const* verify) + { + if (GetCharmerGUID() != verify->GetGUID()) + return false; + SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::CharmedBy), ObjectGuid::Empty); + m_charmer = nullptr; + return true; + } + ObjectGuid GetCharmerGUID() const { return m_unitData->CharmedBy; } + Unit* GetCharmer() const { return m_charmer; } + + bool SetCharmedData(Unit const* unit) + { + if (!GetCharmedGUID().IsEmpty()) + return false; + m_charmed = const_cast<Unit*>(unit); + return true; + } + bool ClearCharmedData(Unit const* verify) + { + if (GetCharmedGUID() != verify->GetGUID()) + return false; + SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Charm), ObjectGuid::Empty); + m_charmed = nullptr; + return true; + } + ObjectGuid GetCharmedGUID() const { return m_unitData->Charm; } + Unit* GetCharmed() const { return m_charmed; } + bool IsControlledByPlayer() const { return m_ControlledByPlayer; } Player* GetControllingPlayer() const; ObjectGuid GetCharmerOrOwnerGUID() const override { return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID(); } @@ -1253,9 +1286,7 @@ class TC_GAME_API Unit : public WorldObject Guardian* GetGuardianPet() const; Minion* GetFirstMinion() const; - Unit* GetCharmer() const; - Unit* GetCharm() const; - Unit* GetCharmerOrOwner() const; + Unit* GetCharmerOrOwner() const { return IsCharmed() ? GetCharmer() : GetOwner(); } void SetMinion(Minion *minion, bool apply); void GetAllMinionsByEntry(std::list<TempSummon*>& Minions, uint32 entry); @@ -1907,6 +1938,8 @@ class TC_GAME_API Unit : public WorldObject float m_speed_rate[MAX_MOVE_TYPE]; + Unit* m_charmer; // Unit that is charming ME + Unit* m_charmed; // Unit that is being charmed BY ME CharmInfo* m_charmInfo; SharedVisionList m_sharedVision; diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index a92119e7685..286fcf2e584 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -123,7 +123,7 @@ void WorldSession::HandlePetStopAttack(WorldPackets::Pet::PetStopAttack& packet) return; } - if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm()) + if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharmed()) { TC_LOG_ERROR("entities.pet", "HandlePetStopAttack: %s isn't a pet or charmed creature of player %s", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str()); @@ -616,7 +616,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPackets::Pet::PetSpellAutoc return; } - if (pet != _player->GetGuardianPet() && pet != _player->GetCharm()) + if (pet != _player->GetGuardianPet() && pet != _player->GetCharmed()) { TC_LOG_ERROR("entities.pet", "WorldSession::HandlePetSpellAutocastOpcode: %s isn't pet of player %s (%s).", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); @@ -667,7 +667,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPackets::Spells::PetCastSpell& } // This opcode is also sent from charmed and possessed units (players and creatures) - if (caster != _player->GetGuardianPet() && caster != _player->GetCharm()) + if (caster != _player->GetGuardianPet() && caster != _player->GetCharmed()) { TC_LOG_ERROR("spells.pet", "WorldSession::HandlePetCastSpellOpcode: %s isn't pet of player %s (%s).", petCastSpell.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); return; diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index f0a48c0eda3..55da4c5433b 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -416,7 +416,7 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPackets::Spells::PetCancelAura return; } - if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm()) + if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharmed()) { TC_LOG_ERROR("network", "HandlePetCancelAura: %s is not a pet of player '%s'", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str()); return; diff --git a/src/server/game/Handlers/VehicleHandler.cpp b/src/server/game/Handlers/VehicleHandler.cpp index 4fbfc6c2408..dc7f217a028 100644 --- a/src/server/game/Handlers/VehicleHandler.cpp +++ b/src/server/game/Handlers/VehicleHandler.cpp @@ -26,7 +26,7 @@ void WorldSession::HandleMoveDismissVehicle(WorldPackets::Vehicle::MoveDismissVehicle& moveDismissVehicle) { - ObjectGuid vehicleGUID = _player->GetCharmGUID(); + ObjectGuid vehicleGUID = _player->GetCharmedGUID(); if (vehicleGUID.IsEmpty()) return; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 22a1b24329c..aacba1e1f30 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3932,7 +3932,7 @@ void Spell::finish(bool ok) // Unsummon summon as possessed creatures on spell cancel if (m_spellInfo->IsChanneled() && unitCaster->GetTypeId() == TYPEID_PLAYER) { - if (Unit* charm = unitCaster->GetCharm()) + if (Unit* charm = unitCaster->GetCharmed()) if (charm->GetTypeId() == TYPEID_UNIT && charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET) && charm->m_unitData->CreatedBySpell == int32(m_spellInfo->Id)) @@ -5784,7 +5784,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 /* fallthrough */ // intentional, check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET case SUMMON_CATEGORY_PUPPET: - if (!unitCaster->GetCharmGUID().IsEmpty()) + if (!unitCaster->GetCharmedGUID().IsEmpty()) return SPELL_FAILED_ALREADY_HAVE_CHARM; break; } @@ -5821,7 +5821,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 return SPELL_FAILED_ALREADY_HAVE_SUMMON; } - if (!unitCaster->GetCharmGUID().IsEmpty()) + if (!unitCaster->GetCharmedGUID().IsEmpty()) return SPELL_FAILED_ALREADY_HAVE_CHARM; break; } @@ -6021,7 +6021,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 if (!m_spellInfo->HasAttribute(SPELL_ATTR1_DISMISS_PET) && !unitCaster->GetPetGUID().IsEmpty()) return SPELL_FAILED_ALREADY_HAVE_SUMMON; - if (!unitCaster->GetCharmGUID().IsEmpty()) + if (!unitCaster->GetCharmedGUID().IsEmpty()) return SPELL_FAILED_ALREADY_HAVE_CHARM; } diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 1e2c6b382b9..d8c880cb827 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -589,7 +589,7 @@ class spell_hun_tame_beast : public SpellScriptLoader if (!caster->GetPetGUID().IsEmpty()) return SPELL_FAILED_ALREADY_HAVE_SUMMON; - if (!caster->GetCharmGUID().IsEmpty()) + if (!caster->GetCharmedGUID().IsEmpty()) return SPELL_FAILED_ALREADY_HAVE_CHARM; } else |