From 7871583016dc6da143952c0b8dbf12c2cab5dd96 Mon Sep 17 00:00:00 2001 From: ariel- Date: Wed, 8 Mar 2017 11:52:10 -0300 Subject: [PATCH] Core/Auras: tidy up one little hack --- src/server/game/Entities/Unit/Unit.cpp | 31 ++++++++++++++----- src/server/game/Entities/Unit/Unit.h | 2 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 17 ++-------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 62f87b0823..870c3ba84a 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13324,13 +13324,13 @@ void Unit::SetDisplayId(uint32 modelId) void Unit::RestoreDisplayId() { - AuraEffect* handledAura = NULL; + AuraEffect* handledAura = nullptr; // try to receive model from transform auras - Unit::AuraEffectList const& transforms = GetAuraEffectsByType(SPELL_AURA_TRANSFORM); + AuraEffectList const& transforms = GetAuraEffectsByType(SPELL_AURA_TRANSFORM); if (!transforms.empty()) { // iterate over already applied transform auras - from newest to oldest - for (Unit::AuraEffectList::const_reverse_iterator i = transforms.rbegin(); i != transforms.rend(); ++i) + for (auto i = transforms.rbegin(); i != transforms.rend(); ++i) { if (AuraApplication const* aurApp = (*i)->GetBase()->GetApplicationOfTarget(GetGUID())) { @@ -13345,12 +13345,18 @@ void Unit::RestoreDisplayId() } } } + + AuraEffectList const& shapeshiftAura = GetAuraEffectsByType(SPELL_AURA_MOD_SHAPESHIFT); + // transform aura was found if (handledAura) handledAura->HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); - // we've found shapeshift - else if (uint32 modelId = GetModelForForm(GetShapeshiftForm())) - SetDisplayId(modelId); + else if (!shapeshiftAura.empty()) // we've found shapeshift + { + // only one such aura possible at a time + if (uint32 modelId = GetModelForForm(GetShapeshiftForm(), shapeshiftAura.front()->GetId())) + SetDisplayId(modelId); + } // no auras found - set modelid to default else SetDisplayId(GetNativeDisplayId()); @@ -15237,8 +15243,19 @@ uint32 Unit::GetCombatRatingDamageReduction(CombatRating cr, float rate, float c return CalculatePct(damage, percent); } -uint32 Unit::GetModelForForm(ShapeshiftForm form) const +uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const { + // Hardcoded cases + switch (spellId) + { + case 7090: // Bear Form + return 29414; + case 35200: // Roc Form + return 4877; + default: + break; + } + if (GetTypeId() == TYPEID_PLAYER) { switch (form) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 7739025b7f..5cffe373d4 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2125,7 +2125,7 @@ class TC_GAME_API Unit : public WorldObject void AddPetAura(PetAura const* petSpell); void RemovePetAura(PetAura const* petSpell); - uint32 GetModelForForm(ShapeshiftForm form) const; + uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const; uint32 GetModelForTotem(PlayerTotemType totemType); // Redirect Threat diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index bd1bf15055..eda557b938 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1699,20 +1699,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo TC_LOG_ERROR("spells", "Auras: Unknown Shapeshift Type: %u", GetMiscValue()); } - switch (GetId()) - { - // Bear Form - case 7090: - modelid = 29414; - break; - // Roc Form - case 35200: - modelid = 4877; - break; - default: - modelid = target->GetModelForForm(form); - break; - } + modelid = target->GetModelForForm(form, GetId()); if (apply) { @@ -2061,7 +2048,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode, uint32 model_id = 0; // choose a model, based on trigger flag - if (uint32 modelid = sObjectMgr->ChooseDisplayId(ci)) + if (uint32 modelid = ObjectMgr::ChooseDisplayId(ci)) model_id = modelid; // Polymorph (sheep)