aboutsummaryrefslogtreecommitdiff
path: root/src/game/PetHandler.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-27 17:02:39 -0500
committermegamage <none@none>2009-05-27 17:02:39 -0500
commit514fc49c3c5c8c0a1e1194c7817af1dade1b4aa7 (patch)
tree030a2ca3ce1a019b91f140f406024fa0a4da8ff9 /src/game/PetHandler.cpp
parent7ccd99ecab40b939464487bcba707167c9da9d7e (diff)
[7901] Refactoting pet action bar related code. Fixed some related bugs. Author: VladimirMangos
* 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 --HG-- branch : trunk
Diffstat (limited to 'src/game/PetHandler.cpp')
-rw-r--r--src/game/PetHandler.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
index 348af684411..de558c5435a 100644
--- a/src/game/PetHandler.cpp
+++ b/src/game/PetHandler.cpp
@@ -393,7 +393,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
@@ -414,8 +418,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
}
- charmInfo->GetActionBarEntry(position)->Type = act_state;
- charmInfo->GetActionBarEntry(position)->SpellOrAction = spell_id;
+ charmInfo->SetActionBar(position,spell_id,ActiveStates(act_state));
}
}
}
@@ -594,11 +597,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
else
pet->GetCharmInfo()->ToggleCreatureAutocast(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 )