mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-17 05:19:40 -04:00
* Properly dismiss vanitypets (implements use of CMSG_DISMISS_CRITTER)
Some small code cleanups --HG-- branch : trunk
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user