diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-08-27 13:37:33 +0200 |
---|---|---|
committer | Treeston <treeston.mmoc@gmail.com> | 2018-08-27 13:37:50 +0200 |
commit | ce06767ef50e4eca7b9ff834a873f99e6ad381d5 (patch) | |
tree | 6b08d264336f838811bfc16c48f5fa452b6dab99 /src | |
parent | 073ba8ee5fb9dacfe6149e43f17754d73d418a57 (diff) |
Core/Unit: Inline some unnecessary helpers.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 28 |
2 files changed, 12 insertions, 36 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 08eb02c427e..215c658808b 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6001,8 +6001,9 @@ void Unit::SetCharm(Unit* charm, bool apply) { if (GetTypeId() == TYPEID_PLAYER) { - 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()); + ASSERT(AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()), + "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()); + m_charmed = charm; charm->m_ControlledByPlayer = true; /// @todo maybe we can use this flag to check if controlled by player @@ -6014,8 +6015,9 @@ void Unit::SetCharm(Unit* charm, bool apply) // PvP, FFAPvP charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); - 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()); + ASSERT(charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()), + "Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); + charm->m_charmer = this; _isWalkingBeforeCharm = charm->IsWalking(); if (_isWalkingBeforeCharm) @@ -6032,12 +6034,14 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { - 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()); + ASSERT(RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()), + "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmedGUID().ToString().c_str()); + m_charmed = nullptr; } - 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()); + ASSERT(charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()), + "Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); + charm->m_charmer = nullptr; if (charm->GetTypeId() == TYPEID_PLAYER) { diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index df6fd428290..069e881f24a 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1149,37 +1149,9 @@ class TC_GAME_API Unit : public WorldObject void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); } ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); } - bool SetCharmerData(Unit const* unit) - { - if (!AddGuidValue(UNIT_FIELD_CHARMEDBY, unit->GetGUID())) - return false; - m_charmer = const_cast<Unit*>(unit); - return true; - } - bool ClearCharmerData(Unit const* verify) - { - if (!RemoveGuidValue(UNIT_FIELD_CHARMEDBY, verify->GetGUID())) - return false; - m_charmer = nullptr; - return true; - } ObjectGuid GetCharmerGUID() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); } Unit* GetCharmer() const { return m_charmer; } - bool SetCharmedData(Unit const* unit) - { - if (!AddGuidValue(UNIT_FIELD_CHARM, unit->GetGUID())) - return false; - m_charmed = const_cast<Unit*>(unit); - return true; - } - bool ClearCharmedData(Unit const* verify) - { - if (!RemoveGuidValue(UNIT_FIELD_CHARM, verify->GetGUID())) - return false; - m_charmed = nullptr; - return true; - } ObjectGuid GetCharmedGUID() const { return GetGuidValue(UNIT_FIELD_CHARM); } Unit* GetCharmed() const { return m_charmed; } |