[7716] Fixed some typos and possible crashes.
[AHbot.git] / src / game / PetHandler.cpp
blob5d2f5d6e7611c67eae0e256f3d24038c62f68e45
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;
259 SendPacket(&data);
261 else
262 pet->SendPetCastFail(spellid, result);
264 if(!((Creature*)pet)->HasSpellCooldown(spellid))
265 pet->SendPetClearCooldown(spellid);
267 spell->finish(false);
268 delete spell;
270 break;
272 default:
273 sLog.outError("WORLD: unknown PET flag Action %i and spellid %i.", flag, spellid);
277 void WorldSession::HandlePetNameQuery( WorldPacket & recv_data )
279 CHECK_PACKET_SIZE(recv_data,4+8);
281 sLog.outDetail( "HandlePetNameQuery. CMSG_PET_NAME_QUERY" );
283 uint32 petnumber;
284 uint64 petguid;
286 recv_data >> petnumber;
287 recv_data >> petguid;
289 SendPetNameQuery(petguid,petnumber);
292 void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
294 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
295 if(!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
296 return;
298 std::string name = pet->GetName();
300 WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
301 data << uint32(petnumber);
302 data << name.c_str();
303 data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));
305 if( pet->isPet() && ((Pet*)pet)->GetDeclinedNames() )
307 data << uint8(1);
308 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
309 data << ((Pet*)pet)->GetDeclinedNames()->name[i];
311 else
312 data << uint8(0);
314 _player->GetSession()->SendPacket(&data);
317 void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
319 CHECK_PACKET_SIZE(recv_data, 8+4+2+2);
321 sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION" );
323 uint64 petguid;
324 uint32 position;
325 uint16 spell_id;
326 uint16 act_state;
327 uint8 count;
329 recv_data >> petguid;
331 // FIXME: charmed case
332 //Pet* pet = ObjectAccessor::Instance().GetPet(petguid);
333 if(ObjectAccessor::FindPlayer(petguid))
334 return;
336 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
338 if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
340 sLog.outError( "HandlePetSetAction: Unknown pet or pet owner." );
341 return;
344 CharmInfo *charmInfo = pet->GetCharmInfo();
345 if(!charmInfo)
347 sLog.outError("WorldSession::HandlePetSetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
348 return;
351 count = (recv_data.size() == 24) ? 2 : 1;
352 for(uint8 i = 0; i < count; i++)
354 recv_data >> position;
355 recv_data >> spell_id;
356 recv_data >> act_state;
358 sLog.outDetail( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position, spell_id, act_state);
360 //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
361 if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
363 //sign for autocast
364 if(act_state == ACT_ENABLED && spell_id)
366 if(pet->isCharmed())
367 charmInfo->ToggleCreatureAutocast(spell_id, true);
368 else
369 ((Pet*)pet)->ToggleAutocast(spell_id, true);
371 //sign for no/turn off autocast
372 else if(act_state == ACT_DISABLED && spell_id)
374 if(pet->isCharmed())
375 charmInfo->ToggleCreatureAutocast(spell_id, false);
376 else
377 ((Pet*)pet)->ToggleAutocast(spell_id, false);
380 charmInfo->GetActionBarEntry(position)->Type = act_state;
381 charmInfo->GetActionBarEntry(position)->SpellOrAction = spell_id;
386 void WorldSession::HandlePetRename( WorldPacket & recv_data )
388 CHECK_PACKET_SIZE(recv_data, 8+1);
390 sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME" );
392 uint64 petguid;
393 uint8 isdeclined;
395 std::string name;
396 DeclinedName declinedname;
398 recv_data >> petguid;
399 recv_data >> name;
400 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
401 recv_data >> isdeclined;
403 Pet* pet = ObjectAccessor::GetPet(petguid);
404 // check it!
405 if( !pet || !pet->isPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET ||
406 pet->GetByteValue(UNIT_FIELD_BYTES_2, 2) != UNIT_RENAME_ALLOWED ||
407 pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() )
408 return;
410 if(!ObjectMgr::IsValidPetName(name))
412 SendPetNameInvalid(PET_NAME_INVALID, name, NULL);
413 return;
416 if(objmgr.IsReservedName(name))
418 SendPetNameInvalid(PET_NAME_RESERVED, name, NULL);
419 return;
422 pet->SetName(name);
424 Unit *owner = pet->GetOwner();
425 if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
426 ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
428 pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED);
430 if(isdeclined)
432 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
434 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
435 recv_data >> declinedname.name[i];
438 std::wstring wname;
439 Utf8toWStr(name, wname);
440 if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname))
442 SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname);
443 return;
447 CharacterDatabase.BeginTransaction();
448 if(isdeclined)
450 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
451 CharacterDatabase.escape_string(declinedname.name[i]);
452 CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
453 CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
454 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());
457 CharacterDatabase.escape_string(name);
458 CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
459 CharacterDatabase.CommitTransaction();
461 pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
464 void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
466 CHECK_PACKET_SIZE(recv_data, 8);
468 uint64 guid;
469 recv_data >> guid; //pet guid
470 sLog.outDetail( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) );
472 // pet/charmed
473 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
474 if(pet)
476 if(pet->isPet())
478 if(pet->GetGUID() == _player->GetPetGUID())
480 uint32 feelty = pet->GetPower(POWER_HAPPINESS);
481 pet->SetPower(POWER_HAPPINESS ,(feelty-50000) > 0 ?(feelty-50000) : 0);
484 _player->RemovePet((Pet*)pet,PET_SAVE_AS_DELETED);
486 else if(pet->GetGUID() == _player->GetCharmGUID())
488 _player->Uncharm();
493 void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
495 CHECK_PACKET_SIZE(recvPacket,8);
497 sLog.outDetail("CMSG_PET_UNLEARN");
498 uint64 guid;
499 recvPacket >> guid; // Pet guid
501 Pet* pet = _player->GetPet();
503 if(!pet || pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0)
504 return;
506 if(guid != pet->GetGUID())
508 sLog.outError( "HandlePetUnlearnOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
509 return;
512 CharmInfo *charmInfo = pet->GetCharmInfo();
513 if(!charmInfo)
515 sLog.outError("WorldSession::HandlePetUnlearnOpcode: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
516 return;
518 pet->resetTalents();
521 void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
523 CHECK_PACKET_SIZE(recvPacket,8+2+2+1);
525 sLog.outDetail("CMSG_PET_SPELL_AUTOCAST");
526 uint64 guid;
527 uint16 spellid;
528 uint16 spellid2; //maybe second spell, automatically toggled off when first toggled on?
529 uint8 state; //1 for on, 0 for off
530 recvPacket >> guid >> spellid >> spellid2 >> state;
532 if(!_player->GetPet() && !_player->GetCharm())
533 return;
535 if(ObjectAccessor::FindPlayer(guid))
536 return;
538 Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
540 if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
542 sLog.outError( "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
543 return;
546 // do not add not learned spells/ passive spells
547 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
548 return;
550 CharmInfo *charmInfo = pet->GetCharmInfo();
551 if(!charmInfo)
553 sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
554 return;
557 if(pet->isCharmed())
558 //state can be used as boolean
559 pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
560 else
561 ((Pet*)pet)->ToggleAutocast(spellid, state);
563 for(uint8 i = 0; i < 10; ++i)
565 if((charmInfo->GetActionBarEntry(i)->Type == ACT_ENABLED || charmInfo->GetActionBarEntry(i)->Type == ACT_DISABLED) && spellid == charmInfo->GetActionBarEntry(i)->SpellOrAction)
566 charmInfo->GetActionBarEntry(i)->Type = state ? ACT_ENABLED : ACT_DISABLED;
570 void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
572 sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL");
574 CHECK_PACKET_SIZE(recvPacket,8+1+4+1);
575 uint64 guid;
576 uint32 spellid;
577 uint8 cast_count;
578 uint8 unk_flags; // flags (if 0x02 - some additional data are received)
580 recvPacket >> guid >> cast_count >> spellid >> unk_flags;
582 sLog.outDebug("WORLD: CMSG_PET_CAST_SPELL, cast_count: %u, spellid %u, unk_flags %u", cast_count, spellid, unk_flags);
584 if(!_player->GetPet() && !_player->GetCharm())
585 return;
587 if (GUID_HIPART(guid) == HIGHGUID_PLAYER)
588 return;
590 Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
592 if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm()))
594 sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
595 return;
598 if (pet->GetGlobalCooldown() > 0)
599 return;
601 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);
602 if(!spellInfo)
604 sLog.outError("WORLD: unknown PET spell id %i", spellid);
605 return;
608 // do not cast not learned spells
609 if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
610 return;
612 SpellCastTargets targets;
613 if(!targets.read(&recvPacket,pet))
614 return;
616 pet->clearUnitState(UNIT_STAT_FOLLOW);
618 Spell *spell = new Spell(pet, spellInfo, false);
619 spell->m_cast_count = cast_count; // probably pending spell cast
620 spell->m_targets = targets;
622 SpellCastResult result = spell->CheckPetCast(NULL);
623 if(result == SPELL_CAST_OK)
625 pet->AddCreatureSpellCooldown(spellid);
626 if(pet->isPet())
628 Pet* p = (Pet*)pet;
629 p->CheckLearning(spellid);
630 //10% chance to play special pet attack talk, else growl
631 //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
632 if(p->getPetType() == SUMMON_PET && (urand(0, 100) < 10))
633 pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
634 else
635 pet->SendPetAIReaction(guid);
638 spell->prepare(&(spell->m_targets));
640 else
642 pet->SendPetCastFail(spellid, result);
643 if(!pet->HasSpellCooldown(spellid))
644 pet->SendPetClearCooldown(spellid);
646 spell->finish(false);
647 delete spell;
651 void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName)
653 WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1);
654 data << uint32(error);
655 data << name;
656 if(declinedName)
658 data << uint8(1);
659 for(uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
660 data << declinedName->name[i];
662 else
663 data << uint8(0);
664 SendPacket(&data);
667 void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
669 sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT");
671 CHECK_PACKET_SIZE(recv_data, 8+4+4);
673 uint64 guid;
674 uint32 talent_id, requested_rank;
675 recv_data >> guid >> talent_id >> requested_rank;
677 _player->LearnPetTalent(guid, talent_id, requested_rank);