Added support for the packet #28 (0x1C): ENTITY_VELOCITY
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1283 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
1ed3b3aed2
commit
8557ed8359
@ -1990,6 +1990,22 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum,
|
||||
|
||||
|
||||
|
||||
void cChunk::BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||
{
|
||||
if (*itr == a_Exclude)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(*itr)->SendEntVelocity(a_Entity);
|
||||
} // for itr - LoadedByClient[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunk::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
|
||||
{
|
||||
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||
|
@ -211,6 +211,7 @@ public:
|
||||
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
|
||||
void BroadcastPlayerAnimation (const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
|
@ -322,6 +322,22 @@ void cChunkMap::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotN
|
||||
|
||||
|
||||
|
||||
void cChunkMap::BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), a_Entity.GetChunkY(), a_Entity.GetChunkZ());
|
||||
if (Chunk == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// It's perfectly legal to broadcast packets even to invalid chunks!
|
||||
Chunk->BroadcastEntVelocity(a_Entity, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunkMap::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
/// Broadcasts an entity equipment change to all clients in the chunk where a_Entity is
|
||||
void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
/// Broadcasts a EntVelocity packet to all clients in the chunk where a_Entity is. Velocity is measured in blocks/second
|
||||
void BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
/// Broadcasts a RelEntMoveLook packet to all clients in the chunk where a_Entity is
|
||||
void BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
|
@ -1453,6 +1453,17 @@ void cClientHandle::SendEntLook(const cEntity & a_Entity)
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendEntVelocity(const cEntity & a_Entity)
|
||||
{
|
||||
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
|
||||
|
||||
m_Protocol->SendEntVelocity(a_Entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendEntHeadLook(const cEntity & a_Entity)
|
||||
{
|
||||
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
|
||||
|
@ -93,6 +93,7 @@ public:
|
||||
void SendDisconnect (const AString & a_Reason);
|
||||
void SendEntHeadLook (const cEntity & a_Entity);
|
||||
void SendEntLook (const cEntity & a_Entity);
|
||||
void SendEntVelocity (const cEntity & a_Entity);
|
||||
void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ);
|
||||
void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ);
|
||||
void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item);
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
virtual void SendDisconnect (const AString & a_Reason) = 0;
|
||||
virtual void SendEntHeadLook (const cEntity & a_Entity) = 0;
|
||||
virtual void SendEntLook (const cEntity & a_Entity) = 0;
|
||||
virtual void SendEntVelocity (const cEntity & a_Entity) = 0;
|
||||
virtual void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
|
||||
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
|
||||
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
|
||||
|
@ -55,6 +55,7 @@ enum
|
||||
PACKET_COLLECT_PICKUP = 0x16,
|
||||
PACKET_SPAWN_OBJECT = 0x17,
|
||||
PACKET_SPAWN_MOB = 0x18,
|
||||
PACKET_ENTITY_VELOCITY = 0x1c,
|
||||
PACKET_DESTROY_ENTITY = 0x1d,
|
||||
PACKET_ENTITY = 0x1e,
|
||||
PACKET_ENT_REL_MOVE = 0x1f,
|
||||
@ -276,6 +277,21 @@ void cProtocol125::SendDisconnect(const AString & a_Reason)
|
||||
|
||||
|
||||
|
||||
void cProtocol125::SendEntVelocity(const cEntity & a_Entity)
|
||||
{
|
||||
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
|
||||
|
||||
cCSLock Lock(m_CSPacket);
|
||||
WriteByte(PACKET_ENTITY_VELOCITY);
|
||||
WriteInt (a_Entity.GetUniqueID());
|
||||
WriteShort((short) (a_Entity.GetSpeedX() * 400)); //400 = 8000 / 20
|
||||
WriteShort((short) (a_Entity.GetSpeedY() * 400));
|
||||
WriteShort((short) (a_Entity.GetSpeedZ() * 400));
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void cProtocol125::SendEntHeadLook(const cEntity & a_Entity)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
virtual void SendDisconnect (const AString & a_Reason) override;
|
||||
virtual void SendEntHeadLook (const cEntity & a_Entity) override;
|
||||
virtual void SendEntLook (const cEntity & a_Entity) override;
|
||||
virtual void SendEntVelocity (const cEntity & a_Entity) override;
|
||||
virtual void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
||||
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
||||
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
||||
|
@ -197,6 +197,14 @@ void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
|
||||
|
||||
|
||||
|
||||
void cProtocolRecognizer::SendEntVelocity(const cEntity & a_Entity)
|
||||
{
|
||||
ASSERT(m_Protocol != NULL);
|
||||
m_Protocol->SendEntVelocity(a_Entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void cProtocolRecognizer::SendEntHeadLook(const cEntity & a_Entity)
|
||||
{
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
virtual void SendDisconnect (const AString & a_Reason) override;
|
||||
virtual void SendEntHeadLook (const cEntity & a_Entity) override;
|
||||
virtual void SendEntLook (const cEntity & a_Entity) override;
|
||||
virtual void SendEntVelocity (const cEntity & a_Entity) override;
|
||||
virtual void SendEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
||||
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
||||
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
||||
|
@ -1307,6 +1307,14 @@ void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum,
|
||||
|
||||
|
||||
|
||||
void cWorld::BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
m_ChunkMap->BroadcastEntVelocity(a_Entity, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSPlayers);
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastPlayerAnimation (const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user