aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/Opcodes.cpp2
-rw-r--r--src/game/PetHandler.cpp22
-rw-r--r--src/game/Unit.cpp28
-rw-r--r--src/game/Unit.h2
-rw-r--r--src/game/WorldSession.h1
5 files changed, 43 insertions, 12 deletions
diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp
index 03fb8fa1151..3501bf20fa8 100644
--- a/src/game/Opcodes.cpp
+++ b/src/game/Opcodes.cpp
@@ -1193,7 +1193,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x48A*/ { "CMSG_REMOVE_GLYPH", STATUS_LOGGEDIN, &WorldSession::HandleRemoveGlyph },
/*0x48B*/ { "CMSG_DUMP_OBJECTS", STATUS_NEVER, &WorldSession::Handle_NULL },
/*0x48C*/ { "SMSG_DUMP_OBJECTS_DATA", STATUS_NEVER, &WorldSession::Handle_ServerSide },
- /*0x48D*/ { "CMSG_DISMISS_CRITTER", STATUS_NEVER, &WorldSession::Handle_NULL },
+ /*0x48D*/ { "CMSG_DISMISS_CRITTER", STATUS_LOGGEDIN, &WorldSession::HandleDismissCritter },
/*0x48E*/ { "SMSG_NOTIFY_DEST_LOC_SPELL_CAST", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x48F*/ { "CMSG_AUCTION_LIST_PENDING_SALES", STATUS_LOGGEDIN, &WorldSession::HandleAuctionListPendingSales },
/*0x490*/ { "SMSG_AUCTION_LIST_PENDING_SALES", STATUS_NEVER, &WorldSession::Handle_ServerSide },
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;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 65187a92789..730792dc48b 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -9243,6 +9243,11 @@ void Unit::SetMinion(Minion *minion, bool apply)
minion->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
}
+ if (minion->HasUnitTypeMask(UNIT_MASK_MINION) && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
+ {
+ SetCritterGUID(minion->GetGUID());
+ }
+
// Can only have one pet. If a new one is summoned, dismiss the old one.
if (minion->IsGuardianPet())
{
@@ -9272,8 +9277,6 @@ void Unit::SetMinion(Minion *minion, bool apply)
{
}
}
- //else if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
- // AddUInt64Value(UNIT_FIELD_CRITTER, minion->GetGUID());
// PvP, FFAPvP
minion->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
@@ -9305,6 +9308,11 @@ void Unit::SetMinion(Minion *minion, bool apply)
m_Controlled.erase(minion);
+ if (minion->HasUnitTypeMask(UNIT_MASK_MINION) && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
+ {
+ SetCritterGUID(0);
+ }
+
if (minion->IsGuardianPet())
{
if (GetPetGUID() == minion->GetGUID())
@@ -9313,14 +9321,14 @@ void Unit::SetMinion(Minion *minion, bool apply)
else if (minion->isTotem())
{
// All summoned by totem minions must disappear when it is removed.
- if (const SpellEntry* spInfo = sSpellStore.LookupEntry(minion->ToTotem()->GetSpell()))
- for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
- {
- if (spInfo->Effect[i] != SPELL_EFFECT_SUMMON)
- continue;
+ if (const SpellEntry* spInfo = sSpellStore.LookupEntry(minion->ToTotem()->GetSpell()))
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ if (spInfo->Effect[i] != SPELL_EFFECT_SUMMON)
+ continue;
- this->RemoveAllMinionsByEntry(spInfo->EffectMiscValue[i]);
- }
+ this->RemoveAllMinionsByEntry(spInfo->EffectMiscValue[i]);
+ }
}
if (GetTypeId() == TYPEID_PLAYER)
@@ -9370,8 +9378,6 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
}
}
- //else if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
- // RemoveUInt64Value(UNIT_FIELD_CRITTER, minion->GetGUID());
}
}
diff --git a/src/game/Unit.h b/src/game/Unit.h
index a9ff929f910..8cc742f4d3f 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1465,6 +1465,8 @@ class Unit : public WorldObject
uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); }
void SetPetGUID(uint64 guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
uint64 GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; }
+ void SetCritterGUID(uint64 guid) { SetUInt64Value(UNIT_FIELD_CRITTER, guid); }
+ uint64 GetCritterGUID() const { return GetUInt64Value(UNIT_FIELD_CRITTER); }
bool IsControlledByPlayer() const { return m_ControlledByPlayer; }
uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h
index 350cfa42ad3..cb5f0396cd8 100644
--- a/src/game/WorldSession.h
+++ b/src/game/WorldSession.h
@@ -661,6 +661,7 @@ class WorldSession
void HandleSetPlayerDeclinedNames(WorldPacket& recv_data);
void HandleTotemDestroyed(WorldPacket& recv_data);
+ void HandleDismissCritter(WorldPacket& recv_data);
//BattleGround
void HandleBattlemasterHelloOpcode(WorldPacket &recv_data);