[7901] Refactoting pet action bar related code. Fixed some related bugs.

* Correctly update action bar at loading and other cases when listed unlearned/not existed spells
* Avoid send data by PetSpellInitialize() many times while pet loading
This commit is contained in:
VladimirMangos 2009-05-27 19:24:12 +04:00
parent 1abe4c0d79
commit 4d8adefe70
7 changed files with 175 additions and 122 deletions

View file

@ -357,7 +357,11 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
sLog.outDetail( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position, spell_id, act_state);
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
//ignore invalid position
if(position >= MAX_UNIT_ACTION_BAR_INDEX)
return;
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
{
//sign for autocast
@ -377,8 +381,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
((Pet*)pet)->ToggleAutocast(spell_id, false);
}
charmInfo->GetActionBarEntry(position)->Type = act_state;
charmInfo->GetActionBarEntry(position)->SpellOrAction = spell_id;
charmInfo->SetActionBar(position,spell_id,ActiveStates(act_state));
}
}
}
@ -560,11 +563,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
else
((Pet*)pet)->ToggleAutocast(spellid, state);
for(uint8 i = 0; i < 10; ++i)
{
if((charmInfo->GetActionBarEntry(i)->Type == ACT_ENABLED || charmInfo->GetActionBarEntry(i)->Type == ACT_DISABLED) && spellid == charmInfo->GetActionBarEntry(i)->SpellOrAction)
charmInfo->GetActionBarEntry(i)->Type = state ? ACT_ENABLED : ACT_DISABLED;
}
charmInfo->SetSpellAutocast(spellid,state);
}
void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )