diff options
author | treeston <treeston.mmoc@gmail.com> | 2015-11-29 18:41:36 +0100 |
---|---|---|
committer | treeston <treeston.mmoc@gmail.com> | 2015-11-29 18:41:36 +0100 |
commit | 1be635a0255955533c413d0b3cc5a36fa514e403 (patch) | |
tree | 6ab3a733231767f5d02471e149d38a3d1cd6a27f | |
parent | c1b4cd21f3debc2eb5e462c5adce659b558c7dc9 (diff) |
Unit/PossessBar: Fix spell ordering on possess bar to reflect spell position in DB. Fixes Razuvious adds et al.
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 63de39f570a..92fb04b4831 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13788,7 +13788,7 @@ void CharmInfo::InitPossessCreateSpells() break; } - for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) + for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) { uint32 spellId = _unit->ToCreature()->m_spells[i]; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); @@ -13797,7 +13797,7 @@ void CharmInfo::InitPossessCreateSpells() if (spellInfo->IsPassive()) _unit->CastSpell(_unit, spellInfo, true); else - AddSpellToActionBar(spellInfo, ACT_PASSIVE); + AddSpellToActionBar(spellInfo, ACT_PASSIVE, i % MAX_UNIT_ACTION_BAR_INDEX); } } } @@ -13855,11 +13855,12 @@ void CharmInfo::InitCharmCreateSpells() } } -bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate) +bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate, uint8 preferredSlot) { uint32 spell_id = spellInfo->Id; uint32 first_id = spellInfo->GetFirstRankSpell()->Id; + ASSERT(preferredSlot < MAX_UNIT_ACTION_BAR_INDEX); // new spell rank can be already listed for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { @@ -13876,9 +13877,10 @@ bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates new // or use empty slot in other case for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { - if (!PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) + uint8 j = (preferredSlot + i) % MAX_UNIT_ACTION_BAR_INDEX; + if (!PetActionBar[j].GetAction() && PetActionBar[j].IsActionBarForSpell()) { - SetActionBar(i, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_DISABLED : ACT_PASSIVE : newstate); + SetActionBar(j, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_DISABLED : ACT_PASSIVE : newstate); return true; } } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 2500f327849..72f3a6682fa 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1119,7 +1119,7 @@ struct CharmInfo void InitEmptyActionBar(bool withAttack = true); //return true if successful - bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE); + bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE, uint8 preferredSlot = 0); bool RemoveSpellFromActionBar(uint32 spell_id); void LoadPetActionBar(const std::string& data); void BuildActionBar(WorldPacket* data); |