aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/PetHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/PetHandler.cpp')
-rw-r--r--src/server/game/Handlers/PetHandler.cpp76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp
index 827dbe1ec91..0bc5d5006e7 100644
--- a/src/server/game/Handlers/PetHandler.cpp
+++ b/src/server/game/Handlers/PetHandler.cpp
@@ -65,12 +65,12 @@ void WorldSession::HandlePetAction(WorldPacket& recvData)
ObjectGuid guid1;
uint32 data;
ObjectGuid guid2;
- recvData >> guid1; //pet guid
+ recvData >> guid1; // pet guid
recvData >> data;
- recvData >> guid2; //tag guid
+ recvData >> guid2; // tag guid
uint32 spellid = UNIT_ACTION_BUTTON_ACTION(data);
- uint8 flag = UNIT_ACTION_BUTTON_TYPE(data); //delete = 0x07 CastSpell = C1
+ uint8 flag = UNIT_ACTION_BUTTON_TYPE(data); // delete = 0x07 CastSpell = C1
// used also for charmed creature
Unit* pet = ObjectAccessor::GetUnit(*_player, guid1);
@@ -105,7 +105,7 @@ void WorldSession::HandlePetAction(WorldPacket& recvData)
HandlePetActionHelper(pet, guid1, spellid, flag, guid2);
else
{
- //If a pet is dismissed, m_Controlled will change
+ // If a pet is dismissed, m_Controlled will change
std::vector<Unit*> controlled;
for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
if ((*itr)->GetEntry() == pet->GetEntry() && (*itr)->IsAlive())
@@ -155,15 +155,15 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
switch (flag)
{
- case ACT_COMMAND: //0x07
+ case ACT_COMMAND: // 0x07
switch (spellid)
{
- case COMMAND_STAY: //flat=1792 //STAY
+ case COMMAND_STAY: // flat = 1792 - STAY
pet->StopMoving();
pet->GetMotionMaster()->Clear();
pet->GetMotionMaster()->MoveIdle();
- charmInfo->SetCommandState(COMMAND_STAY);
+ charmInfo->SetCommandState(COMMAND_STAY);
charmInfo->SetIsCommandAttack(false);
charmInfo->SetIsAtStay(true);
charmInfo->SetIsCommandFollow(false);
@@ -171,24 +171,24 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
charmInfo->SetIsReturning(false);
charmInfo->SaveStayPosition();
break;
- case COMMAND_FOLLOW: //spellid=1792 //FOLLOW
+ case COMMAND_FOLLOW: // spellid = 1792 - FOLLOW
pet->AttackStop();
pet->InterruptNonMeleeSpells(false);
pet->GetMotionMaster()->MoveFollow(_player, PET_FOLLOW_DIST, pet->GetFollowAngle());
- charmInfo->SetCommandState(COMMAND_FOLLOW);
+ charmInfo->SetCommandState(COMMAND_FOLLOW);
charmInfo->SetIsCommandAttack(false);
charmInfo->SetIsAtStay(false);
charmInfo->SetIsReturning(true);
charmInfo->SetIsCommandFollow(true);
charmInfo->SetIsFollowing(false);
break;
- case COMMAND_ATTACK: //spellid=1792 //ATTACK
+ case COMMAND_ATTACK: // spellid = 1792 - ATTACK
{
// Can't attack if owner is pacified
if (_player->HasAuraType(SPELL_AURA_MOD_PACIFY))
{
- //pet->SendPetCastFail(spellid, SPELL_FAILED_PACIFIED);
+ // pet->SendPetCastFail(spellid, SPELL_FAILED_PACIFIED);
/// @todo Send proper error message to client
return;
}
@@ -222,7 +222,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
else
AI->AttackStart(TargetUnit);
- //10% chance to play special pet attack talk, else growl
+ // 10% chance to play special pet attack talk, else growl
if (pet->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10)
pet->SendPetTalk((uint32)PET_TALK_ATTACK);
else
@@ -231,7 +231,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
pet->SendPetAIReaction(guid1);
}
}
- else // charmed player
+ else // charmed player
{
charmInfo->SetIsCommandAttack(true);
charmInfo->SetIsAtStay(false);
@@ -245,7 +245,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
}
break;
}
- case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
+ case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
if (pet->GetCharmerGUID() == GetPlayer()->GetGUID())
_player->StopCastingCharm();
else if (pet->GetOwnerGUID() == GetPlayer()->GetGUID())
@@ -256,7 +256,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
if (((Pet*)pet)->getPetType() == HUNTER_PET)
GetPlayer()->RemovePet((Pet*)pet, PET_SAVE_AS_DELETED);
else
- //dismissing a summoned pet is like killing them (this prevents returning a soulshard...)
+ // dismissing a summoned pet is like killing them (this prevents returning a soulshard...)
pet->setDeathState(CORPSE);
}
else if (pet->HasUnitTypeMask(UNIT_MASK_MINION))
@@ -269,22 +269,22 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
TC_LOG_ERROR("entities.pet", "WORLD: unknown PET flag Action %i and spellid %i.", uint32(flag), spellid);
}
break;
- case ACT_REACTION: // 0x6
+ case ACT_REACTION: // 0x6
switch (spellid)
{
- case REACT_PASSIVE: //passive
+ case REACT_PASSIVE: // passive
pet->AttackStop();
/* fallthrough */
- case REACT_DEFENSIVE: //recovery
- case REACT_AGGRESSIVE: //activete
+ case REACT_DEFENSIVE: // recovery
+ case REACT_AGGRESSIVE: // activete
if (pet->GetTypeId() == TYPEID_UNIT)
pet->ToCreature()->SetReactState(ReactStates(spellid));
break;
}
break;
- case ACT_DISABLED: // 0x81 spell (disabled), ignore
- case ACT_PASSIVE: // 0x01
- case ACT_ENABLED: // 0xC1 spell
+ case ACT_DISABLED: // 0x81 spell (disabled), ignore
+ case ACT_PASSIVE: // 0x01
+ case ACT_ENABLED: // 0xC1 spell
{
Unit* unit_target = nullptr;
@@ -309,8 +309,8 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
if (!pet->HasSpell(spellid) || spellInfo->IsPassive())
return;
- // Clear the flags as if owner clicked 'attack'. AI will reset them
- // after AttackStart, even if spell failed
+ // Clear the flags as if owner clicked 'attack'. AI will reset them
+ // after AttackStart, even if spell failed
if (pet->GetCharmInfo())
{
pet->GetCharmInfo()->SetIsAtStay(false);
@@ -323,7 +323,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
SpellCastResult result = spell->CheckPetCast(unit_target);
- //auto turn to target unless possessed
+ // auto turn to target unless possessed
if (result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->isPossessed() && !pet->IsVehicle())
{
if (unit_target)
@@ -352,8 +352,8 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
{
unit_target = spell->m_targets.GetUnitTarget();
- //10% chance to play special pet attack talk, else growl
- //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
+ // 10% chance to play special pet attack talk, else growl
+ // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
if (pet->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10))
pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
else
@@ -507,7 +507,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData)
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
- //ignore invalid position
+ // ignore invalid position
if (position[i] >= MAX_UNIT_ACTION_BAR_INDEX)
return;
@@ -562,12 +562,12 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData)
TC_LOG_DEBUG("entities.pet", "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X",
_player->GetName().c_str(), position[i], spell_id, uint32(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
+ // 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 && !petControlled->HasSpell(spell_id)))
{
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id))
{
- //sign for autocast
+ // sign for autocast
if (act_state == ACT_ENABLED)
{
if (petControlled->GetTypeId() == TYPEID_UNIT && petControlled->IsPet())
@@ -577,7 +577,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData)
if ((*itr)->GetEntry() == petControlled->GetEntry())
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, true);
}
- //sign for no/turn off autocast
+ // sign for no/turn off autocast
else if (act_state == ACT_DISABLED)
{
if (petControlled->GetTypeId() == TYPEID_UNIT && petControlled->IsPet())
@@ -610,9 +610,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
recvData >> isdeclined;
Pet* pet = ObjectAccessor::GetPet(*_player, petguid);
- // check it!
- if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType() != HUNTER_PET ||
- !pet->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED) ||
+ if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType() != HUNTER_PET || !pet->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED) ||
pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo())
return;
@@ -685,7 +683,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
void WorldSession::HandlePetAbandon(WorldPacket& recvData)
{
ObjectGuid guid;
- recvData >> guid; //pet guid
+ recvData >> guid; // pet guid
TC_LOG_DEBUG("network.opcode", "WORLD: Received CMSG_PET_ABANDON %s", guid.ToString().c_str());
if (!_player->IsInWorld())
@@ -710,7 +708,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("network.opcode", "WORLD: Received CMSG_PET_SPELL_AUTOCAST");
ObjectGuid guid;
uint32 spellid;
- uint8 state; //1 for on, 0 for off
+ uint8 state; // 1 for on, 0 for off
recvPacket >> guid >> spellid >> state;
if (!_player->GetGuardianPet() && !_player->GetCharmed())
@@ -766,9 +764,9 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("network.opcode", "WORLD: Received CMSG_PET_CAST_SPELL");
ObjectGuid guid;
- uint8 castCount;
+ uint8 castCount;
uint32 spellId;
- uint8 castFlags;
+ uint8 castFlags;
recvPacket >> guid >> castCount >> spellId >> castFlags;
@@ -802,7 +800,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
HandleClientCastFlags(recvPacket, castFlags, targets);
Spell* spell = new Spell(caster, spellInfo, TRIGGERED_NONE);
- spell->m_cast_count = castCount; // probably pending spell cast
+ spell->m_cast_count = castCount; // probably pending spell cast
spell->m_targets = targets;
SpellCastResult result = spell->CheckPetCast(nullptr);