[7847] Replace paramter unions by uniton of event ai action type structures. Add...
[getmangos.git] / src / game / PetHandler.cpp
blobe7e32390041d723f1d80c779ab4ec67289d78e4b
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "WorldPacket.h"
21 #include "WorldSession.h"
22 #include "ObjectMgr.h"
23 #include "SpellMgr.h"
24 #include "Log.h"
25 #include "Opcodes.h"
26 #include "Spell.h"
27 #include "ObjectAccessor.h"
28 #include "CreatureAI.h"
29 #include "Util.h"
30 #include "Pet.h"
32 void WorldSession::HandlePetAction( WorldPacket & recv_data )
34 CHECK_PACKET_SIZE(recv_data, 8+2+2+8);
36 uint64 guid1;
37 uint16 spellid;
38 uint16 flag;
39 uint64 guid2;
40 recv_data >> guid1; //pet guid
41 recv_data >> spellid;
42 recv_data >> flag; //delete = 0x0700 CastSpell = C100
43 recv_data >> guid2; //tag guid
45 // used also for charmed creature
46 Unit* pet= ObjectAccessor::GetUnit(*_player, guid1);
47 sLog.outDetail("HandlePetAction.Pet %u flag is %u, spellid is %u, target %u.", uint32(GUID_LOPART(guid1)), flag, spellid, uint32(GUID_LOPART(guid2)) );
48 if(!pet)
50 sLog.outError( "Pet %u not exist.", uint32(GUID_LOPART(guid1)) );
51 return;
54 if(pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())
56 sLog.outError("HandlePetAction.Pet %u isn't pet of player %s.", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName() );
57 return;
60 if(!pet->isAlive())
61 return;
63 if(pet->GetTypeId() == TYPEID_PLAYER && !(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))
64 return;
66 CharmInfo *charmInfo = pet->GetCharmInfo();
67 if(!charmInfo)
69 sLog.outError("WorldSession::HandlePetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
70 return;
73 switch(flag)
75 case ACT_COMMAND: //0x0700
76 switch(spellid)
78 case COMMAND_STAY: //flat=1792 //STAY
79 pet->StopMoving();
80 pet->GetMotionMaster()->Clear();
81 pet->GetMotionMaster()->MoveIdle();
82 charmInfo->SetCommandState( COMMAND_STAY );
83 break;
84 case COMMAND_FOLLOW: //spellid=1792 //FOLLOW
85 pet->AttackStop();
86 pet->GetMotionMaster()->MoveFollow(_player,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
87 charmInfo->SetCommandState( COMMAND_FOLLOW );
88 break;
89 case COMMAND_ATTACK: //spellid=1792 //ATTACK
91 const uint64& selguid = _player->GetSelection();
92 Unit *TargetUnit = ObjectAccessor::GetUnit(*_player, selguid);
93 if(!TargetUnit)
94 return;
96 // not let attack friendly units.
97 if(GetPlayer()->IsFriendlyTo(TargetUnit))
98 return;
99 // Not let attack through obstructions
100 if(!pet->IsWithinLOSInMap(TargetUnit))
101 return;
103 // This is true if pet has no target or has target but targets differs.
104 if(pet->getVictim() != TargetUnit)
106 if (pet->getVictim())
107 pet->AttackStop();
109 if(pet->GetTypeId() != TYPEID_PLAYER)
111 pet->GetMotionMaster()->Clear();
112 if (((Creature*)pet)->AI())
113 ((Creature*)pet)->AI()->AttackStart(TargetUnit);
115 //10% chance to play special pet attack talk, else growl
116 if(((Creature*)pet)->isPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10)
117 pet->SendPetTalk((uint32)PET_TALK_ATTACK);
118 else
120 // 90% chance for pet and 100% chance for charmed creature
121 pet->SendPetAIReaction(guid1);
124 else // charmed player
126 pet->Attack(TargetUnit,true);
127 pet->SendPetAIReaction(guid1);
130 break;
132 case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
133 if(((Creature*)pet)->isPet())
135 Pet* p = (Pet*)pet;
136 if(p->getPetType() == HUNTER_PET)
137 _player->RemovePet(p,PET_SAVE_AS_DELETED);
138 else
139 //dismissing a summoned pet is like killing them (this prevents returning a soulshard...)
140 p->setDeathState(CORPSE);
142 else // charmed
143 _player->Uncharm();
144 break;
145 default:
146 sLog.outError("WORLD: unknown PET flag Action %i and spellid %i.", flag, spellid);
148 break;
149 case ACT_REACTION: // 0x600
150 switch(spellid)
152 case REACT_PASSIVE: //passive
153 case REACT_DEFENSIVE: //recovery
154 case REACT_AGGRESSIVE: //activete
155 charmInfo->SetReactState( ReactStates(spellid) );
156 break;
158 break;
159 case ACT_DISABLED: // 0x8100 spell (disabled), ignore
160 case ACT_PASSIVE: // 0x0100
161 case ACT_ENABLED: // 0xC100 spell
163 Unit* unit_target = NULL;
164 if (((Creature*)pet)->GetGlobalCooldown() > 0)
165 return;
167 if(guid2)
168 unit_target = ObjectAccessor::GetUnit(*_player,guid2);
170 // do not cast unknown spells
171 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid );
172 if(!spellInfo)
174 sLog.outError("WORLD: unknown PET spell id %i", spellid);
175 return;
178 for(uint32 i = 0; i < 3;++i)
180 if(spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED)
181 return;
184 // do not cast not learned spells
185 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
186 return;
188 pet->clearUnitState(UNIT_STAT_FOLLOW);
190 Spell *spell = new Spell(pet, spellInfo, false);
192 SpellCastResult result = spell->CheckPetCast(unit_target);
194 //auto turn to target unless possessed
195 if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
197 if(unit_target)
199 pet->SetInFront(unit_target);
200 if (unit_target->GetTypeId() == TYPEID_PLAYER)
201 pet->SendUpdateToPlayer( (Player*)unit_target );
203 else if(Unit *unit_target2 = spell->m_targets.getUnitTarget())
205 pet->SetInFront(unit_target2);
206 if (unit_target2->GetTypeId() == TYPEID_PLAYER)
207 pet->SendUpdateToPlayer( (Player*)unit_target2 );
209 if (Unit* powner = pet->GetCharmerOrOwner())
210 if(powner->GetTypeId() == TYPEID_PLAYER)
211 pet->SendUpdateToPlayer((Player*)powner);
212 result = SPELL_CAST_OK;
215 if(result == SPELL_CAST_OK)
217 ((Creature*)pet)->AddCreatureSpellCooldown(spellid);
218 if (((Creature*)pet)->isPet())
219 ((Pet*)pet)->CheckLearning(spellid);
221 unit_target = spell->m_targets.getUnitTarget();
223 //10% chance to play special pet attack talk, else growl
224 //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
225 if(((Creature*)pet)->isPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10))
226 pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
227 else
229 pet->SendPetAIReaction(guid1);
232 if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
234 // This is true if pet has no target or has target but targets differs.
235 if (pet->getVictim() != unit_target)
237 if (pet->getVictim())
238 pet->AttackStop();
239 pet->GetMotionMaster()->Clear();
240 if (((Creature*)pet)->AI())
241 ((Creature*)pet)->AI()->AttackStart(unit_target);
245 spell->prepare(&(spell->m_targets));
247 else
249 if(pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
251 WorldPacket data(SMSG_CAST_FAILED, (4+1+1));
252 data << uint8(0) << uint32(spellid) << uint8(result);
253 switch (result)
255 case SPELL_FAILED_REQUIRES_SPELL_FOCUS:
256 data << uint32(spellInfo->RequiresSpellFocus);
257 break;
258 default:
259 break;
261 SendPacket(&data);
263 else
264 pet->SendPetCastFail(spellid, result);
266 if(!((Creature*)pet)->HasSpellCooldown(spellid))
267 pet->SendPetClearCooldown(spellid);
269 spell->finish(false);
270 delete spell;
272 break;
274 default:
275 sLog.outError("WORLD: unknown PET flag Action %i and spellid %i.", flag, spellid);
279 void WorldSession::HandlePetNameQuery( WorldPacket & recv_data )
281 CHECK_PACKET_SIZE(recv_data,4+8);
283 sLog.outDetail( "HandlePetNameQuery. CMSG_PET_NAME_QUERY" );
285 uint32 petnumber;
286 uint64 petguid;
288 recv_data >> petnumber;
289 recv_data >> petguid;
291 SendPetNameQuery(petguid,petnumber);
294 void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
296 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
297 if(!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
298 return;
300 std::string name = pet->GetName();
302 WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
303 data << uint32(petnumber);
304 data << name.c_str();
305 data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));
307 if( pet->isPet() && ((Pet*)pet)->GetDeclinedNames() )
309 data << uint8(1);
310 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
311 data << ((Pet*)pet)->GetDeclinedNames()->name[i];
313 else
314 data << uint8(0);
316 _player->GetSession()->SendPacket(&data);
319 void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
321 CHECK_PACKET_SIZE(recv_data, 8+4+2+2);
323 sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION" );
325 uint64 petguid;
326 uint32 position;
327 uint16 spell_id;
328 uint16 act_state;
329 uint8 count;
331 recv_data >> petguid;
333 // FIXME: charmed case
334 //Pet* pet = ObjectAccessor::Instance().GetPet(petguid);
335 if(ObjectAccessor::FindPlayer(petguid))
336 return;
338 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
340 if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
342 sLog.outError( "HandlePetSetAction: Unknown pet or pet owner." );
343 return;
346 CharmInfo *charmInfo = pet->GetCharmInfo();
347 if(!charmInfo)
349 sLog.outError("WorldSession::HandlePetSetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
350 return;
353 count = (recv_data.size() == 24) ? 2 : 1;
354 for(uint8 i = 0; i < count; ++i)
356 recv_data >> position;
357 recv_data >> spell_id;
358 recv_data >> act_state;
360 sLog.outDetail( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position, spell_id, act_state);
362 //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
363 if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
365 //sign for autocast
366 if(act_state == ACT_ENABLED && spell_id)
368 if(pet->isCharmed())
369 charmInfo->ToggleCreatureAutocast(spell_id, true);
370 else
371 ((Pet*)pet)->ToggleAutocast(spell_id, true);
373 //sign for no/turn off autocast
374 else if(act_state == ACT_DISABLED && spell_id)
376 if(pet->isCharmed())
377 charmInfo->ToggleCreatureAutocast(spell_id, false);
378 else
379 ((Pet*)pet)->ToggleAutocast(spell_id, false);
382 charmInfo->GetActionBarEntry(position)->Type = act_state;
383 charmInfo->GetActionBarEntry(position)->SpellOrAction = spell_id;
388 void WorldSession::HandlePetRename( WorldPacket & recv_data )
390 CHECK_PACKET_SIZE(recv_data, 8+1);
392 sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME" );
394 uint64 petguid;
395 uint8 isdeclined;
397 std::string name;
398 DeclinedName declinedname;
400 recv_data >> petguid;
401 recv_data >> name;
402 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
403 recv_data >> isdeclined;
405 Pet* pet = ObjectAccessor::GetPet(petguid);
406 // check it!
407 if( !pet || !pet->isPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET ||
408 pet->GetByteValue(UNIT_FIELD_BYTES_2, 2) != UNIT_RENAME_ALLOWED ||
409 pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() )
410 return;
412 if(!ObjectMgr::IsValidPetName(name))
414 SendPetNameInvalid(PET_NAME_INVALID, name, NULL);
415 return;
418 if(objmgr.IsReservedName(name))
420 SendPetNameInvalid(PET_NAME_RESERVED, name, NULL);
421 return;
424 pet->SetName(name);
426 Unit *owner = pet->GetOwner();
427 if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
428 ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
430 pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED);
432 if(isdeclined)
434 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
436 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
437 recv_data >> declinedname.name[i];
440 std::wstring wname;
441 Utf8toWStr(name, wname);
442 if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname))
444 SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname);
445 return;
449 CharacterDatabase.BeginTransaction();
450 if(isdeclined)
452 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
453 CharacterDatabase.escape_string(declinedname.name[i]);
454 CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
455 CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
456 pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
459 CharacterDatabase.escape_string(name);
460 CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
461 CharacterDatabase.CommitTransaction();
463 pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
466 void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
468 CHECK_PACKET_SIZE(recv_data, 8);
470 uint64 guid;
471 recv_data >> guid; //pet guid
472 sLog.outDetail( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) );
474 // pet/charmed
475 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
476 if(pet)
478 if(pet->isPet())
480 if(pet->GetGUID() == _player->GetPetGUID())
482 uint32 feelty = pet->GetPower(POWER_HAPPINESS);
483 pet->SetPower(POWER_HAPPINESS ,(feelty-50000) > 0 ?(feelty-50000) : 0);
486 _player->RemovePet((Pet*)pet,PET_SAVE_AS_DELETED);
488 else if(pet->GetGUID() == _player->GetCharmGUID())
490 _player->Uncharm();
495 void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
497 CHECK_PACKET_SIZE(recvPacket,8);
499 sLog.outDetail("CMSG_PET_UNLEARN");
500 uint64 guid;
501 recvPacket >> guid; // Pet guid
503 Pet* pet = _player->GetPet();
505 if(!pet || pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0)
506 return;
508 if(guid != pet->GetGUID())
510 sLog.outError( "HandlePetUnlearnOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
511 return;
514 CharmInfo *charmInfo = pet->GetCharmInfo();
515 if(!charmInfo)
517 sLog.outError("WorldSession::HandlePetUnlearnOpcode: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
518 return;
520 pet->resetTalents();
523 void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
525 CHECK_PACKET_SIZE(recvPacket,8+2+2+1);
527 sLog.outDetail("CMSG_PET_SPELL_AUTOCAST");
528 uint64 guid;
529 uint16 spellid;
530 uint16 spellid2; //maybe second spell, automatically toggled off when first toggled on?
531 uint8 state; //1 for on, 0 for off
532 recvPacket >> guid >> spellid >> spellid2 >> state;
534 if(!_player->GetPet() && !_player->GetCharm())
535 return;
537 if(ObjectAccessor::FindPlayer(guid))
538 return;
540 Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
542 if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
544 sLog.outError( "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
545 return;
548 // do not add not learned spells/ passive spells
549 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
550 return;
552 CharmInfo *charmInfo = pet->GetCharmInfo();
553 if(!charmInfo)
555 sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
556 return;
559 if(pet->isCharmed())
560 //state can be used as boolean
561 pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
562 else
563 ((Pet*)pet)->ToggleAutocast(spellid, state);
565 for(uint8 i = 0; i < 10; ++i)
567 if((charmInfo->GetActionBarEntry(i)->Type == ACT_ENABLED || charmInfo->GetActionBarEntry(i)->Type == ACT_DISABLED) && spellid == charmInfo->GetActionBarEntry(i)->SpellOrAction)
568 charmInfo->GetActionBarEntry(i)->Type = state ? ACT_ENABLED : ACT_DISABLED;
572 void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
574 sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL");
576 CHECK_PACKET_SIZE(recvPacket,8+1+4+1);
577 uint64 guid;
578 uint32 spellid;
579 uint8 cast_count;
580 uint8 unk_flags; // flags (if 0x02 - some additional data are received)
582 recvPacket >> guid >> cast_count >> spellid >> unk_flags;
584 sLog.outDebug("WORLD: CMSG_PET_CAST_SPELL, cast_count: %u, spellid %u, unk_flags %u", cast_count, spellid, unk_flags);
586 if(!_player->GetPet() && !_player->GetCharm())
587 return;
589 if (GUID_HIPART(guid) == HIGHGUID_PLAYER)
590 return;
592 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
594 if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm()))
596 sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
597 return;
600 if (pet->GetGlobalCooldown() > 0)
601 return;
603 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);
604 if(!spellInfo)
606 sLog.outError("WORLD: unknown PET spell id %i", spellid);
607 return;
610 // do not cast not learned spells
611 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
612 return;
614 SpellCastTargets targets;
615 if(!targets.read(&recvPacket,pet))
616 return;
618 pet->clearUnitState(UNIT_STAT_FOLLOW);
620 Spell *spell = new Spell(pet, spellInfo, false);
621 spell->m_cast_count = cast_count; // probably pending spell cast
622 spell->m_targets = targets;
624 SpellCastResult result = spell->CheckPetCast(NULL);
625 if(result == SPELL_CAST_OK)
627 pet->AddCreatureSpellCooldown(spellid);
628 if(pet->isPet())
630 Pet* p = (Pet*)pet;
631 p->CheckLearning(spellid);
632 //10% chance to play special pet attack talk, else growl
633 //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
634 if(p->getPetType() == SUMMON_PET && (urand(0, 100) < 10))
635 pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
636 else
637 pet->SendPetAIReaction(guid);
640 spell->prepare(&(spell->m_targets));
642 else
644 pet->SendPetCastFail(spellid, result);
645 if(!pet->HasSpellCooldown(spellid))
646 pet->SendPetClearCooldown(spellid);
648 spell->finish(false);
649 delete spell;
653 void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName)
655 WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1);
656 data << uint32(error);
657 data << name;
658 if(declinedName)
660 data << uint8(1);
661 for(uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
662 data << declinedName->name[i];
664 else
665 data << uint8(0);
666 SendPacket(&data);
669 void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
671 sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT");
673 CHECK_PACKET_SIZE(recv_data, 8+4+4);
675 uint64 guid;
676 uint32 talent_id, requested_rank;
677 recv_data >> guid >> talent_id >> requested_rank;
679 _player->LearnPetTalent(guid, talent_id, requested_rank);