Core/Packets: converted SMSG_DESTROY_OBJECT to packet class

This commit is contained in:
Ovahlord
2020-08-23 23:09:34 +02:00
parent c504068259
commit 47ac0004c2
4 changed files with 25 additions and 6 deletions

View File

@@ -263,16 +263,16 @@ void Object::BuildOutOfRangeUpdateBlock(UpdateData* data) const
data->AddOutOfRangeGUID(GetGUID());
}
void Object::DestroyForPlayer(Player* target, bool onDeath /*= false*/) const
void Object::DestroyForPlayer(Player* target, bool isDead /*= false*/) const
{
ASSERT(target);
WorldPacket data(SMSG_DESTROY_OBJECT, 8 + 1);
data << uint64(GetGUID());
WorldPackets::Misc::DestroyObject packet;
packet.Guid = GetGUID();
//! If the following bool is true, the client will call "void CGUnit_C::OnDeath()" for this object.
//! OnDeath() does for eg trigger death animation and interrupts certain spells/missiles/auras/sounds...
data << uint8(onDeath ? 1 : 0);
target->SendDirectMessage(&data);
packet.IsDead = isDead;
target->SendDirectMessage(packet.Write());
}
int32 Object::GetInt32Value(uint16 index) const

View File

@@ -89,7 +89,7 @@ class TC_GAME_API Object
void BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) const;
void BuildOutOfRangeUpdateBlock(UpdateData* data) const;
virtual void DestroyForPlayer(Player* target, bool onDeath = false) const;
virtual void DestroyForPlayer(Player* target, bool isDead = false) const;
int32 GetInt32Value(uint16 index) const;
uint32 GetUInt32Value(uint16 index) const;

View File

@@ -241,3 +241,11 @@ WorldPacket const* WorldPackets::Misc::StartTimer::Write()
return &_worldPacket;
}
WorldPacket const* WorldPackets::Misc::DestroyObject::Write()
{
_worldPacket << Guid;
_worldPacket << uint8(IsDead);
return &_worldPacket;
}

View File

@@ -295,6 +295,17 @@ namespace WorldPackets
int32 TimeLeft = 0;
int32 TotalTime = 0;
};
class DestroyObject final : public ServerPacket
{
public:
DestroyObject() : ServerPacket(SMSG_DESTROY_OBJECT, 9) { }
WorldPacket const* Write() override;
ObjectGuid Guid;
bool IsDead = false;
};
}
}