From f4dcdf9507fe6832755c140f762c604c3ba04085 Mon Sep 17 00:00:00 2001 From: click Date: Thu, 29 Apr 2010 23:24:31 +0200 Subject: * Properly dismiss vanitypets (implements use of CMSG_DISMISS_CRITTER) Some small code cleanups --HG-- branch : trunk --- src/game/PetHandler.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/game/PetHandler.cpp') diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index abfb964237a..34e6845762b 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -32,6 +32,28 @@ #include "Pet.h" #include "World.h" +void WorldSession::HandleDismissCritter(WorldPacket &recv_data) +{ + uint64 guid; + recv_data >> guid; + + sLog.outDebug("WORLD: Received CMSG_DISMISS_CRITTER for GUID %u", guid); + + Unit* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid); + + if (!pet) + { + sLog.outError("Vanitypet %u does not exist", uint32(GUID_LOPART(guid))); + return; + } + + if (_player->GetCritterGUID() == pet->GetGUID()) + { + if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isSummon()) + pet->ToTempSummon()->UnSummon(); + } +} + void WorldSession::HandlePetAction(WorldPacket & recv_data) { uint64 guid1; -- cgit v1.2.3