summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-07 15:06:06 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-07 15:06:06 +0200
commitb1d05b0f57e03261eaf776c9bb9b81cfa05a13f5 (patch)
tree7684b48d5aa7b37cdaa6fdd12fb27ca46a9ed241
parentAnvilStats: moved into the Tools folder (diff)
downloadcuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.tar
cuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.tar.gz
cuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.tar.bz2
cuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.tar.lz
cuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.tar.xz
cuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.tar.zst
cuberite-b1d05b0f57e03261eaf776c9bb9b81cfa05a13f5.zip
-rw-r--r--source/Chunk.cpp116
-rw-r--r--source/Chunk.h30
-rw-r--r--source/ChunkMap.cpp145
-rw-r--r--source/ChunkMap.h59
-rw-r--r--source/ClientHandle.cpp305
-rw-r--r--source/ClientHandle.h20
-rw-r--r--source/Entity.cpp14
-rw-r--r--source/FallingBlock.cpp2
-rw-r--r--source/Minecart.cpp2
-rw-r--r--source/Pickup.cpp2
-rw-r--r--source/Player.cpp6
-rw-r--r--source/Protocol/Protocol.h14
-rw-r--r--source/Protocol/Protocol125.cpp141
-rw-r--r--source/Protocol/Protocol125.h14
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp61
-rw-r--r--source/Protocol/ProtocolRecognizer.h14
-rw-r--r--source/TNTEntity.cpp2
-rw-r--r--source/World.cpp160
-rw-r--r--source/World.h40
19 files changed, 587 insertions, 560 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 049a4944d..62d411b0c 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -2449,7 +2449,7 @@ void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V
-void cChunk::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude)
+void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2457,7 +2457,7 @@ void cChunk::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation
{
continue;
}
- (*itr)->SendPlayerAnimation(a_Player, a_Animation);
+ (*itr)->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
} // for itr - LoadedByClient[]
}
@@ -2465,15 +2465,15 @@ void cChunk::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation
-void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
+void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
+ (*itr)->SendBlockBreakAnim(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage);
} // for itr - LoadedByClient[]
}
@@ -2481,15 +2481,21 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum,
-void cChunk::BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ // We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list
+ cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
+ if (Entity == NULL)
+ {
+ return;
+ }
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendEntVelocity(a_Entity);
+ Entity->SendTo(*(*itr));
} // for itr - LoadedByClient[]
}
@@ -2497,15 +2503,15 @@ void cChunk::BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle
-void cChunk::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
+void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
+ (*itr)->SendChunkData(m_PosX, m_PosZ, a_Serializer);
} // for itr - LoadedByClient[]
}
@@ -2513,15 +2519,15 @@ void cChunk::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char
-void cChunk::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
+void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
+ (*itr)->SendCollectPickup(a_Pickup, a_Player);
} // for itr - LoadedByClient[]
}
@@ -2529,7 +2535,7 @@ void cChunk::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_R
-void cChunk::BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2537,7 +2543,7 @@ void cChunk::BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_
{
continue;
}
- (*itr)->SendEntLook(a_Entity);
+ (*itr)->SendDestroyEntity(a_Entity);
} // for itr - LoadedByClient[]
}
@@ -2545,7 +2551,7 @@ void cChunk::BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_
-void cChunk::BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2553,7 +2559,7 @@ void cChunk::BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHandle
{
continue;
}
- (*itr)->SendEntHeadLook(a_Entity);
+ (*itr)->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
} // for itr - LoadedByClient[]
}
@@ -2561,7 +2567,7 @@ void cChunk::BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHandle
-void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2569,7 +2575,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char
{
continue;
}
- (*itr)->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
+ (*itr)->SendEntityHeadLook(a_Entity);
} // for itr - LoadedByClient[]
}
@@ -2577,7 +2583,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char
-void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2585,7 +2591,7 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
{
continue;
}
- (*itr)->SendDestroyEntity(a_Entity);
+ (*itr)->SendEntityLook(a_Entity);
} // for itr - LoadedByClient[]
}
@@ -2593,7 +2599,7 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
-void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2601,7 +2607,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons
{
continue;
}
- (*itr)->SendEntityStatus(a_Entity, a_Status);
+ (*itr)->SendEntityMetadata(a_Entity);
} // for itr - LoadedByClient[]
}
@@ -2609,7 +2615,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons
-void cChunk::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityRelMove(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 )
{
@@ -2617,7 +2623,7 @@ void cChunk::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a
{
continue;
}
- (*itr)->SendMetadata(a_Entity);
+ (*itr)->SendEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
} // for itr - LoadedByClient[]
}
@@ -2625,15 +2631,15 @@ void cChunk::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a
-void cChunk::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- a_Entity.SpawnOn(*(*itr));
+ (*itr)->SendEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
} // for itr - LoadedByClient[]
}
@@ -2641,15 +2647,15 @@ void cChunk::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
-void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendCollectPickup(a_Pickup, a_Player);
+ (*itr)->SendEntityStatus(a_Entity, a_Status);
} // for itr - LoadedByClient[]
}
@@ -2657,15 +2663,15 @@ void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_
-void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
+ (*itr)->SendEntityVelocity(a_Entity);
} // for itr - LoadedByClient[]
}
@@ -2673,15 +2679,15 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons
-void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunk::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ (*itr)->SendPlayerAnimation(a_Player, a_Animation);
} // for itr - LoadedByClient[]
}
@@ -2689,7 +2695,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a
-void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
+void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2697,7 +2703,7 @@ void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY
{
continue;
}
- (*itr)->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
+ (*itr)->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
} // for itr - LoadedByClient[]
}
@@ -2705,7 +2711,7 @@ void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY
-void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
+void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2713,7 +2719,7 @@ void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_bl
{
continue;
}
- (*itr)->SendBlockBreakAnim(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage);
+ (*itr)->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
} // for itr - LoadedByClient[]
}
@@ -2721,11 +2727,15 @@ void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_bl
-void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
- (*itr)->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
+ if (*itr == a_Exclude)
+ {
+ continue;
+ }
+ a_Entity.SpawnOn(*(*itr));
} // for itr - LoadedByClient[]
}
@@ -2733,7 +2743,7 @@ void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_Block
-void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
+void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2741,7 +2751,7 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie
{
continue;
}
- (*itr)->SendChunkData(m_PosX, m_PosZ, a_Serializer);
+ (*itr)->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
} // for itr - LoadedByClient[]
}
@@ -2749,21 +2759,11 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie
-void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
{
- // We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list
- cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
- if (Entity == NULL)
- {
- return;
- }
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
- if (*itr == a_Exclude)
- {
- continue;
- }
- Entity->SendTo(*(*itr));
+ (*itr)->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
} // for itr - LoadedByClient[]
}
diff --git a/source/Chunk.h b/source/Chunk.h
index 07062e71b..c4eeab6ae 100644
--- a/source/Chunk.h
+++ b/source/Chunk.h
@@ -232,27 +232,29 @@ public:
void CalculateLighting(); // Recalculate right now
void CalculateHeightmap();
+ // Broadcast various packets to all clients of this chunk:
+ // (Please keep these alpha-sorted)
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);
- void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL);
- void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
- void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
- void BroadcastMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
- void BroadcastSpawn (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
- void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastPlayerAnimation (const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
- void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
+ void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
- void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp
index 4c181cce5..0db4b898a 100644
--- a/source/ChunkMap.cpp
+++ b/source/ChunkMap.cpp
@@ -337,90 +337,97 @@ void cChunkMap::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity *
-void cChunkMap::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude)
+
+void cChunkMap::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Player.GetChunkX(), ZERO_CHUNK_Y, a_Player.GetChunkZ());
+ int x, y, z, ChunkX, ChunkZ;
+ x = a_BlockX;
+ y = a_BlockY;
+ z = a_BlockZ;
+ cChunkDef::BlockToChunk(x, y, z, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastPlayerAnimation(a_Player, a_Animation, a_Exclude);
+ Chunk->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
}
-void cChunkMap::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
+ int ChunkX, ChunkZ;
+
+ cChunkDef::BlockToChunk(a_blockX, a_blockY, a_blockZ, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntityEquipment(a_Entity, a_SlotNum, a_Item, a_Exclude);
+ Chunk->BroadcastBlockBreakAnimation(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage, a_Exclude);
}
-
-void cChunkMap::BroadcastEntVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
- if (Chunk == NULL)
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
+ if ((Chunk == NULL) || !Chunk->IsValid())
{
return;
}
- // It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntVelocity(a_Entity, a_Exclude);
+ Chunk->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
}
-void cChunkMap::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
+ cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, 0, a_ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
+ Chunk->BroadcastChunkData(a_Serializer, a_Exclude);
}
-
-void cChunkMap::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
+ cChunkPtr Chunk = GetChunkNoGen(a_Pickup.GetChunkX(), ZERO_CHUNK_Y, a_Pickup.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
+ Chunk->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
}
-
-void cChunkMap::BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
@@ -429,15 +436,14 @@ void cChunkMap::BroadcastEntLook(const cEntity & a_Entity, const cClientHandle *
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntLook(a_Entity, a_Exclude);
+ Chunk->BroadcastDestroyEntity(a_Entity, a_Exclude);
}
-
-void cChunkMap::BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
@@ -446,37 +452,30 @@ void cChunkMap::BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHand
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntHeadLook(a_Entity, a_Exclude);
+ Chunk->BroadcastEntityEquipment(a_Entity, a_SlotNum, a_Item, a_Exclude);
}
-
-void cChunkMap::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- int x, y, z, ChunkX, ChunkZ;
- x = a_BlockX;
- y = a_BlockY;
- z = a_BlockZ;
- cChunkDef::BlockToChunk(x, y, z, ChunkX, ChunkZ);
- cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
+ Chunk->BroadcastEntityHeadLook(a_Entity, a_Exclude);
}
-
-void cChunkMap::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
@@ -485,15 +484,14 @@ void cChunkMap::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHa
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastDestroyEntity(a_Entity, a_Exclude);
+ Chunk->BroadcastEntityLook(a_Entity, a_Exclude);
}
-
-void cChunkMap::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
@@ -502,15 +500,14 @@ void cChunkMap::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, c
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastEntityStatus(a_Entity, a_Status, a_Exclude);
+ Chunk->BroadcastEntityMetadata(a_Entity, a_Exclude);
}
-
-void cChunkMap::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
@@ -519,14 +516,14 @@ void cChunkMap::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastMetadata(a_Entity, a_Exclude);
+ Chunk->BroadcastEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
}
-void cChunkMap::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
@@ -535,67 +532,62 @@ void cChunkMap::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclu
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastSpawn(a_Entity, a_Exclude);
+ Chunk->BroadcastEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
}
-void cChunkMap::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Pickup.GetChunkX(), ZERO_CHUNK_Y, a_Pickup.GetChunkZ());
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
+ Chunk->BroadcastEntityStatus(a_Entity, a_Status, a_Exclude);
}
-void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
- cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
+ Chunk->BroadcastEntityVelocity(a_Entity, a_Exclude);
}
-void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- int ChunkX, ChunkZ;
-
- cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcY / 8, a_SrcZ / 8, ChunkX, ChunkZ);
- cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(a_Player.GetChunkX(), ZERO_CHUNK_Y, a_Player.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
+ Chunk->BroadcastPlayerAnimation(a_Player, a_Animation, a_Exclude);
}
-void cChunkMap::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
@@ -607,78 +599,79 @@ void cChunkMap::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_S
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude);
+ Chunk->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
}
-void cChunkMap::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(a_blockX, a_blockY, a_blockZ, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcY / 8, a_SrcZ / 8, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastBlockBreakAnimation(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage, a_Exclude);
+ Chunk->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude);
}
-void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cChunkMap::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- int ChunkX, ChunkZ;
-
- cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
- cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
+ Chunk->BroadcastSpawnEntity(a_Entity, a_Exclude);
}
-void cChunkMap::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, 0, a_ChunkZ);
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastChunkData(a_Serializer, a_Exclude);
+ Chunk->BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
}
-void cChunkMap::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
+
cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if (Chunk == NULL)
{
return;
}
- Chunk->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
+ // It's perfectly legal to broadcast packets even to invalid chunks!
+ Chunk->BroadcastUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
}
diff --git a/source/ChunkMap.h b/source/ChunkMap.h
index de902ba47..899f290c5 100644
--- a/source/ChunkMap.h
+++ b/source/ChunkMap.h
@@ -49,56 +49,29 @@ public:
cChunkMap(cWorld* a_World );
~cChunkMap();
+ // Broadcast respective packets to all clients of the chunk where the event is taking place
+ // (Please keep these alpha-sorted)
void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle);
-
- /// Broadcasts an a_Player's animation to all clients in the chunk where a_Player is
- void BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL);
-
- /// 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);
-
- /// Broadcasts a RelEntMove packet to all clients in the chunk where a_Entity is
- void BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
-
- /// Broadcasts a EntLook packet to all clients in the chunk where a_Entity is
- void BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
-
- /// Broadcasts a EntHeadLook packet to all clients in the chunk where a_Entity is
- void BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
-
- /// Broadcasts a BlockAction packet to all clients who are in the specified chunk
void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL);
-
+ void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
+ void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
+ void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
-
+ void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
-
- void BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
-
- void BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
-
- void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
-
- void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
-
+ void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
-
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
-
- void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
-
+ void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
-
- void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
-
- /// Broadcasts the block entity, if it is at the coords specified, to all clients except a_Exclude
- void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
/// Sends the block entity, if it is at the coords specified, to a_Client
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 4d4f40745..f8bfa5b15 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -262,7 +262,7 @@ void cClientHandle::Authenticate(void)
m_State = csDownloadingWorld;
// Broadcast this player's spawning to all other players in the same chunk
- m_Player->GetWorld()->BroadcastSpawn(*m_Player, this);
+ m_Player->GetWorld()->BroadcastSpawnEntity(*m_Player, this);
cRoot::Get()->GetPluginManager()->CallHookPlayerSpawned(*m_Player);
}
@@ -1347,186 +1347,235 @@ void cClientHandle::Tick(float a_Dt)
-void cClientHandle::SendDisconnect(const AString & a_Reason)
+void cClientHandle::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
- if (!m_HasSentDC)
- {
- LOGD("Sending a DC: \"%s\"", a_Reason.c_str());
- m_Protocol->SendDisconnect(a_Reason);
- m_HasSentDC = true;
- }
+ m_Protocol->SendAttachEntity(a_Entity, a_Vehicle);
}
-void cClientHandle::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
+void cClientHandle::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
- m_Protocol->SendInventorySlot(a_WindowID, a_SlotNum, a_Item);
+ m_Protocol->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
}
-void cClientHandle::SendChat(const AString & a_Message)
+void cClientHandle::SendBlockBreakAnim(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
{
- m_Protocol->SendChat(a_Message);
+ m_Protocol->SendBlockBreakAnim(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage);
}
-void cClientHandle::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
+void cClientHandle::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- m_Protocol->SendPlayerAnimation(a_Player, a_Animation);
+ m_Protocol->SendBlockChange(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
-void cClientHandle::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
+void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
{
- m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
+ m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
}
-void cClientHandle::SendWindowClose(const cWindow & a_Window)
+void cClientHandle::SendChat(const AString & a_Message)
{
- m_Protocol->SendWindowClose(a_Window);
+ m_Protocol->SendChat(a_Message);
}
-void cClientHandle::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
+void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
- m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
+ // Check chunks being sent, erase them from m_ChunksToSend:
+ bool Found = false;
+ {
+ cCSLock Lock(m_CSChunkLists);
+ for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end(); ++itr)
+ {
+ if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkZ == a_ChunkZ))
+ {
+ m_ChunksToSend.erase(itr);
+
+ // Make the tick thread check if all the needed chunks have been downloaded
+ // -- needed to offload this from here due to a deadlock possibility
+ m_ShouldCheckDownloaded = true;
+
+ Found = true;
+ break;
+ }
+ } // for itr - m_ChunksToSend[]
+ }
+ if (!Found)
+ {
+ // This just sometimes happens. If you have a reliably replicatable situation for this, go ahead and fix it
+ // It's not a big issue anyway, just means that some chunks may be compressed several times
+ // LOGD("Refusing to send chunk [%d, %d] to client \"%s\" at [%d, %d].", ChunkX, ChunkZ, m_Username.c_str(), m_Player->GetChunkX(), m_Player->GetChunkZ());
+ return;
+ }
+
+ m_Protocol->SendChunkData(a_ChunkX, a_ChunkZ, a_Serializer);
}
-void cClientHandle::SendWholeInventory(const cInventory & a_Inventory)
+void cClientHandle::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
{
- m_Protocol->SendWholeInventory(a_Inventory);
+ m_Protocol->SendCollectPickup(a_Pickup, a_Player);
}
-void cClientHandle::SendWholeInventory(const cWindow & a_Window)
+void cClientHandle::SendDestroyEntity(const cEntity & a_Entity)
{
- m_Protocol->SendWholeInventory(a_Window);
+ m_Protocol->SendDestroyEntity(a_Entity);
}
-void cClientHandle::SendTeleportEntity(const cEntity & a_Entity)
+void cClientHandle::SendDisconnect(const AString & a_Reason)
{
- m_Protocol->SendTeleportEntity(a_Entity);
+ if (!m_HasSentDC)
+ {
+ LOGD("Sending a DC: \"%s\"", a_Reason.c_str());
+ m_Protocol->SendDisconnect(a_Reason);
+ m_HasSentDC = true;
+ }
}
-void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cClientHandle::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
- m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
+ m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
}
-void cClientHandle::SendPlayerPosition(void)
+void cClientHandle::SendEntityHeadLook(const cEntity & a_Entity)
{
- m_Protocol->SendPlayerPosition();
+ ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
+
+ m_Protocol->SendEntityHeadLook(a_Entity);
}
-void cClientHandle::SendEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cClientHandle::SendEntityLook(const cEntity & a_Entity)
{
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
- m_Protocol->SendEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
+ m_Protocol->SendEntityLook(a_Entity);
}
-void cClientHandle::SendEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cClientHandle::SendEntityMetadata(const cEntity & a_Entity)
{
- ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
-
- m_Protocol->SendEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
+ m_Protocol->SendEntityMetadata(a_Entity);
}
-void cClientHandle::SendEntLook(const cEntity & a_Entity)
+void cClientHandle::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
- m_Protocol->SendEntLook(a_Entity);
+ m_Protocol->SendEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
}
-void cClientHandle::SendEntVelocity(const cEntity & a_Entity)
+void cClientHandle::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
- m_Protocol->SendEntVelocity(a_Entity);
+ m_Protocol->SendEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
+void cClientHandle::SendEntityStatus(const cEntity & a_Entity, char a_Status)
+{
+ m_Protocol->SendEntityStatus(a_Entity, a_Status);
}
-void cClientHandle::SendEntHeadLook(const cEntity & a_Entity)
+void cClientHandle::SendEntityVelocity(const cEntity & a_Entity)
{
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
- m_Protocol->SendEntHeadLook(a_Entity);
+ m_Protocol->SendEntityVelocity(a_Entity);
}
-void cClientHandle::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
+void cClientHandle::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
{
- m_Protocol->SendAttachEntity(a_Entity, a_Vehicle);
+ if (
+ (m_NumExplosionsPerTick[m_CurrentExplosionTick] > MAX_EXPLOSIONS_PER_TICK) || // Too many explosions in this tick
+ (m_RunningSumExplosions > MAX_RUNNING_SUM_EXPLOSIONS) // Too many explosions in the recent history
+ )
+ {
+ LOGD("Dropped %u explosions", a_BlocksAffected.size());
+ return;
+ }
+
+ // Update the statistics:
+ m_NumExplosionsPerTick[m_CurrentExplosionTick] += a_BlocksAffected.size();
+ m_RunningSumExplosions += a_BlocksAffected.size();
+
+ m_Protocol->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_Radius, a_BlocksAffected, a_PlayerMotion);
}
-void cClientHandle::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+void cClientHandle::SendGameMode(eGameMode a_GameMode)
{
- m_Protocol->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
+ m_Protocol->SendGameMode(a_GameMode);
}
@@ -1542,90 +1591,77 @@ void cClientHandle::SendHealth(void)
-void cClientHandle::SendRespawn(void)
+void cClientHandle::SendInventoryProgress(char a_WindowID, short a_ProgressBar, short a_Value)
{
- m_Protocol->SendRespawn();
+ m_Protocol->SendInventoryProgress(a_WindowID, a_ProgressBar, a_Value);
}
-void cClientHandle::SendGameMode(eGameMode a_GameMode)
+void cClientHandle::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
{
- m_Protocol->SendGameMode(a_GameMode);
+ m_Protocol->SendInventorySlot(a_WindowID, a_SlotNum, a_Item);
}
-void cClientHandle::SendDestroyEntity(const cEntity & a_Entity)
+void cClientHandle::SendPickupSpawn(const cPickup & a_Pickup)
{
- m_Protocol->SendDestroyEntity(a_Entity);
+ m_Protocol->SendPickupSpawn(a_Pickup);
}
-void cClientHandle::SendPlayerMoveLook(void)
+void cClientHandle::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
{
- /*
- LOGD("Sending PlayerMoveLook: {%0.2f, %0.2f, %0.2f}, stance %0.2f, OnGround: %d",
- m_Player->GetPosX(), m_Player->GetPosY(), m_Player->GetPosZ(), m_Player->GetStance(), m_Player->IsOnGround() ? 1 : 0
- );
- */
- m_Protocol->SendPlayerMoveLook();
+ m_Protocol->SendPlayerAnimation(a_Player, a_Animation);
}
-void cClientHandle::SendEntityStatus(const cEntity & a_Entity, char a_Status)
+void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
{
- m_Protocol->SendEntityStatus(a_Entity, a_Status);
+ m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
}
-void cClientHandle::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
+void cClientHandle::SendPlayerMaxSpeed(void)
{
- if (
- (m_NumExplosionsPerTick[m_CurrentExplosionTick] > MAX_EXPLOSIONS_PER_TICK) || // Too many explosions in this tick
- (m_RunningSumExplosions > MAX_RUNNING_SUM_EXPLOSIONS) // Too many explosions in the recent history
- )
- {
- LOGD("Dropped %u explosions", a_BlocksAffected.size());
- return;
- }
-
- // Update the statistics:
- m_NumExplosionsPerTick[m_CurrentExplosionTick] += a_BlocksAffected.size();
- m_RunningSumExplosions += a_BlocksAffected.size();
-
- m_Protocol->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_Radius, a_BlocksAffected, a_PlayerMotion);
+ m_Protocol->SendPlayerMaxSpeed();
}
-void cClientHandle::SendMetadata(const cEntity & a_Entity)
+void cClientHandle::SendPlayerMoveLook(void)
{
- m_Protocol->SendMetadata(a_Entity);
+ /*
+ LOGD("Sending PlayerMoveLook: {%0.2f, %0.2f, %0.2f}, stance %0.2f, OnGround: %d",
+ m_Player->GetPosX(), m_Player->GetPosY(), m_Player->GetPosZ(), m_Player->GetStance(), m_Player->IsOnGround() ? 1 : 0
+ );
+ */
+ m_Protocol->SendPlayerMoveLook();
}
-void cClientHandle::SendInventoryProgress(char a_WindowID, short a_ProgressBar, short a_Value)
+void cClientHandle::SendPlayerPosition(void)
{
- m_Protocol->SendInventoryProgress(a_WindowID, a_ProgressBar, a_Value);
+ m_Protocol->SendPlayerPosition();
}
@@ -1651,87 +1687,81 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player)
-void cClientHandle::SendPickupSpawn(const cPickup & a_Pickup)
+void cClientHandle::SendRespawn(void)
{
- m_Protocol->SendPickupSpawn(a_Pickup);
+ m_Protocol->SendRespawn();
}
-void cClientHandle::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
- m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
+ m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
}
-void cClientHandle::SendSpawnMob(const cMonster & a_Mob)
+void cClientHandle::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
{
- m_Protocol->SendSpawnMob(a_Mob);
+ m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
}
-void cClientHandle::SendUpdateSign(
- int a_BlockX, int a_BlockY, int a_BlockZ,
- const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4
-)
+void cClientHandle::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
{
- m_Protocol->SendUpdateSign(
- a_BlockX, a_BlockY, a_BlockZ,
- a_Line1, a_Line2, a_Line3, a_Line4
- );
+ m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
}
-void cClientHandle::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cClientHandle::SendSpawnMob(const cMonster & a_Mob)
{
- m_Protocol->SendCollectPickup(a_Pickup, a_Player);
+ m_Protocol->SendSpawnMob(a_Mob);
}
-void cClientHandle::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
{
- m_Protocol->SendBlockChange(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
+ m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_Yaw, a_Pitch);
}
-void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
+void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
{
- m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
+ m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType);
}
-void cClientHandle::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
+void cClientHandle::SendTeleportEntity(const cEntity & a_Entity)
{
- m_Protocol->SendUnloadChunk(a_ChunkX, a_ChunkZ);
+ m_Protocol->SendTeleportEntity(a_Entity);
}
-void cClientHandle::SendWeather(eWeather a_Weather)
+void cClientHandle::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
{
- m_Protocol->SendWeather(a_Weather);
+ m_Protocol->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -1747,98 +1777,77 @@ void cClientHandle::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
-void cClientHandle::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cClientHandle::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
{
- m_Protocol->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
+ m_Protocol->SendUnloadChunk(a_ChunkX, a_ChunkZ);
}
-void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cClientHandle::SendUpdateSign(
+ int a_BlockX, int a_BlockY, int a_BlockZ,
+ const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4
+)
{
- m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ m_Protocol->SendUpdateSign(
+ a_BlockX, a_BlockY, a_BlockZ,
+ a_Line1, a_Line2, a_Line3, a_Line4
+ );
}
-void cClientHandle::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
{
- m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
+ m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
}
-
-void cClientHandle::SendBlockBreakAnim(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage)
+void cClientHandle::SendWeather(eWeather a_Weather)
{
- m_Protocol->SendBlockBreakAnim(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage);
+ m_Protocol->SendWeather(a_Weather);
}
-void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cClientHandle::SendWindowClose(const cWindow & a_Window)
{
- m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
+ m_Protocol->SendWindowClose(a_Window);
}
-void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
+
+void cClientHandle::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
{
- m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_Yaw, a_Pitch);
+ m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
}
-void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
+void cClientHandle::SendWholeInventory(const cInventory & a_Inventory)
{
- m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType);
+ m_Protocol->SendWholeInventory(a_Inventory);
}
-void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
+void cClientHandle::SendWholeInventory(const cWindow & a_Window)
{
- // Check chunks being sent, erase them from m_ChunksToSend:
- bool Found = false;
- {
- cCSLock Lock(m_CSChunkLists);
- for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end(); ++itr)
- {
- if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkZ == a_ChunkZ))
- {
- m_ChunksToSend.erase(itr);
-
- // Make the tick thread check if all the needed chunks have been downloaded
- // -- needed to offload this from here due to a deadlock possibility
- m_ShouldCheckDownloaded = true;
-
- Found = true;
- break;
- }
- } // for itr - m_ChunksToSend[]
- }
- if (!Found)
- {
- // This just sometimes happens. If you have a reliably replicatable situation for this, go ahead and fix it
- // It's not a big issue anyway, just means that some chunks may be compressed several times
- // LOGD("Refusing to send chunk [%d, %d] to client \"%s\" at [%d, %d].", ChunkX, ChunkZ, m_Username.c_str(), m_Player->GetChunkX(), m_Player->GetChunkZ());
- return;
- }
-
- m_Protocol->SendChunkData(a_ChunkX, a_ChunkZ, a_Serializer);
+ m_Protocol->SendWholeInventory(a_Window);
}
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 053174a56..a06aca39f 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -85,8 +85,11 @@ public:
bool IsDestroyed (void) const { return (m_State == csDestroyed); }
bool IsDestroying(void) const { return (m_State == csDestroying); }
+ // The following functions send the various packets:
+ // (Please keep these alpha-sorted)
void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType);
+ void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage);
void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes);
void SendChat (const AString & a_Message);
@@ -94,29 +97,30 @@ public:
void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player);
void SendDestroyEntity (const cEntity & a_Entity);
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);
+ void SendEntityHeadLook (const cEntity & a_Entity);
+ void SendEntityLook (const cEntity & a_Entity);
+ void SendEntityMetadata (const cEntity & a_Entity);
+ void SendEntityProperties (const cEntity & a_Entity);
+ void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ);
+ void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ);
void SendEntityStatus (const cEntity & a_Entity, char a_Status);
+ void SendEntityVelocity (const cEntity & a_Entity);
void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion);
void SendGameMode (eGameMode a_GameMode);
void SendHealth (void);
void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value);
void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item);
- void SendMetadata (const cEntity & a_Entity);
void SendPickupSpawn (const cPickup & a_Pickup);
void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation);
void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline);
+ void SendPlayerMaxSpeed (void); ///< Informs the client of the maximum player speed (1.6.1+)
void SendPlayerMoveLook (void);
void SendPlayerPosition (void);
void SendPlayerSpawn (const cPlayer & a_Player);
void SendRespawn (void);
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
- void SendBlockBreakAnim (int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage);
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
void SendSpawnMob (const cMonster & a_Mob);
void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch);
@@ -126,12 +130,12 @@ public:
void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay);
void SendUnloadChunk (int a_ChunkX, int a_ChunkZ);
void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
+ void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
void SendWeather (eWeather a_Weather);
void SendWholeInventory (const cInventory & a_Inventory);
void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (const cWindow & a_Window);
void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots);
- void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
const AString & GetUsername(void) const; // tolua_export
void SetUsername( const AString & a_Username ); // tolua_export
diff --git a/source/Entity.cpp b/source/Entity.cpp
index 0d0dac368..d9855afb0 100644
--- a/source/Entity.cpp
+++ b/source/Entity.cpp
@@ -755,7 +755,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
void cEntity::OnStartedBurning(void)
{
// Broadcast the change:
- m_World->BroadcastMetadata(*this);
+ m_World->BroadcastEntityMetadata(*this);
}
@@ -766,7 +766,7 @@ void cEntity::OnStartedBurning(void)
void cEntity::OnFinishedBurning(void)
{
// Broadcast the change:
- m_World->BroadcastMetadata(*this);
+ m_World->BroadcastEntityMetadata(*this);
}
@@ -851,7 +851,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
//We need to keep updating the clients when there is movement or if there was a change in speed and after 2 ticks
if( (m_Speed.SqrLength() > 0.0004f || m_bDirtySpeed) && (m_World->GetWorldAge() - m_TimeLastSpeedPacket >= 2))
{
- m_World->BroadcastEntVelocity(*this,a_Exclude);
+ m_World->BroadcastEntityVelocity(*this,a_Exclude);
m_bDirtySpeed = false;
m_TimeLastSpeedPacket = m_World->GetWorldAge();
}
@@ -887,12 +887,12 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
{
if (m_bDirtyOrientation)
{
- m_World->BroadcastEntRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude);
+ m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude);
m_bDirtyOrientation = false;
}
else
{
- m_World->BroadcastEntRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude);
+ m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude);
}
m_LastPosX = GetPosX();
m_LastPosY = GetPosY();
@@ -904,14 +904,14 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
{
if (m_bDirtyOrientation)
{
- m_World->BroadcastEntLook(*this,a_Exclude);
+ m_World->BroadcastEntityLook(*this,a_Exclude);
m_bDirtyOrientation = false;
}
}
}
if (m_bDirtyHead)
{
- m_World->BroadcastEntHeadLook(*this,a_Exclude);
+ m_World->BroadcastEntityHeadLook(*this,a_Exclude);
m_bDirtyHead = false;
}
}
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
index 8b57b5d57..c3f980303 100644
--- a/source/FallingBlock.cpp
+++ b/source/FallingBlock.cpp
@@ -25,7 +25,7 @@ cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_Block
void cFallingBlock::Initialize(cWorld * a_World)
{
super::Initialize(a_World);
- a_World->BroadcastSpawn(*this);
+ a_World->BroadcastSpawnEntity(*this);
}
diff --git a/source/Minecart.cpp b/source/Minecart.cpp
index 869f93d74..232f44f7d 100644
--- a/source/Minecart.cpp
+++ b/source/Minecart.cpp
@@ -25,7 +25,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
void cMinecart::Initialize(cWorld * a_World)
{
super::Initialize(a_World);
- a_World->BroadcastSpawn(*this);
+ a_World->BroadcastSpawnEntity(*this);
}
diff --git a/source/Pickup.cpp b/source/Pickup.cpp
index efd5f5799..797fb84f6 100644
--- a/source/Pickup.cpp
+++ b/source/Pickup.cpp
@@ -43,7 +43,7 @@ cPickup::cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem
void cPickup::Initialize(cWorld * a_World)
{
super::Initialize(a_World);
- a_World->BroadcastSpawn(*this);
+ a_World->BroadcastSpawnEntity(*this);
}
diff --git a/source/Player.cpp b/source/Player.cpp
index 1a051f95b..4dea1c3d7 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -148,7 +148,7 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
if (m_bVisible && (m_ClientHandle != (&a_Client)))
{
a_Client.SendPlayerSpawn(*this);
- a_Client.SendEntHeadLook(*this);
+ a_Client.SendEntityHeadLook(*this);
a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem() );
a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots() );
a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings() );
@@ -366,7 +366,7 @@ void cPlayer::SetCrouch(bool a_IsCrouched)
return;
}
m_IsCrouched = a_IsCrouched;
- m_World->BroadcastMetadata(*this);
+ m_World->BroadcastEntityMetadata(*this);
}
@@ -622,7 +622,7 @@ void cPlayer::SetVisible(bool a_bVisible)
if (a_bVisible && !m_bVisible) // Make visible
{
m_bVisible = true;
- m_World->BroadcastSpawn(*this);
+ m_World->BroadcastSpawnEntity(*this);
}
if (!a_bVisible && m_bVisible)
{
diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h
index 2dd80fc5f..fe9d4d10e 100644
--- a/source/Protocol/Protocol.h
+++ b/source/Protocol/Protocol.h
@@ -60,13 +60,15 @@ public:
virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) = 0;
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
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;
+ virtual void SendEntityHeadLook (const cEntity & a_Entity) = 0;
+ virtual void SendEntityLook (const cEntity & a_Entity) = 0;
+ virtual void SendEntityMetadata (const cEntity & a_Entity) = 0;
+ virtual void SendEntityProperties (const cEntity & a_Entity) = 0;
+ virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
+ virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) = 0;
+ virtual void SendEntityVelocity (const cEntity & a_Entity) = 0;
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) = 0;
virtual void SendGameMode (eGameMode a_GameMode) = 0;
virtual void SendHealth (void) = 0;
@@ -74,10 +76,10 @@ public:
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) = 0;
virtual void SendKeepAlive (int a_PingID) = 0;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) = 0;
- virtual void SendMetadata (const cEntity & a_Entity) = 0;
virtual void SendPickupSpawn (const cPickup & a_Pickup) = 0;
virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) = 0;
virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) = 0;
+ virtual void SendPlayerMaxSpeed (void) = 0; ///< Informs the client of the maximum player speed (1.6.1+)
virtual void SendPlayerMoveLook (void) = 0;
virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index bce24498a..f4976b9d8 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -277,23 +277,22 @@ void cProtocol125::SendDisconnect(const AString & a_Reason)
-void cProtocol125::SendEntVelocity(const cEntity & a_Entity)
+void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
- 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));
+ WriteByte (PACKET_ENTITY_EQUIPMENT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteShort(a_SlotNum);
+ WriteShort(a_Item.m_ItemType);
+ WriteShort(a_Item.m_ItemDamage);
Flush();
}
-void cProtocol125::SendEntHeadLook(const cEntity & a_Entity)
+
+void cProtocol125::SendEntityHeadLook(const cEntity & a_Entity)
{
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
@@ -308,7 +307,7 @@ void cProtocol125::SendEntHeadLook(const cEntity & a_Entity)
-void cProtocol125::SendEntLook(const cEntity & a_Entity)
+void cProtocol125::SendEntityLook(const cEntity & a_Entity)
{
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
@@ -324,14 +323,13 @@ void cProtocol125::SendEntLook(const cEntity & a_Entity)
-void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
+void cProtocol125::SendEntityMetadata(const cEntity & a_Entity)
{
cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_ENTITY_EQUIPMENT);
- WriteInt (a_Entity.GetUniqueID());
- WriteShort(a_SlotNum);
- WriteShort(a_Item.m_ItemType);
- WriteShort(a_Item.m_ItemDamage);
+ WriteByte(PACKET_METADATA);
+ WriteInt (a_Entity.GetUniqueID());
+ AString MetaData = GetEntityMetaData(a_Entity);
+ SendData(MetaData.data(), MetaData.size());
Flush();
}
@@ -339,37 +337,25 @@ void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum
-void cProtocol125::SendEntityStatus(const cEntity & a_Entity, char a_Status)
+void cProtocol125::SendEntityProperties(const cEntity & a_Entity)
{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_STATUS);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_Status);
- Flush();
+ // Not supported in this protocol version
}
-void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
+void cProtocol125::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
+ ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
+
cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_EXPLOSION);
- WriteDouble (a_BlockX);
- WriteDouble (a_BlockY);
- WriteDouble (a_BlockZ);
- WriteFloat (a_Radius);
- WriteInt (a_BlocksAffected.size());
- for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
- {
- WriteByte ((Byte)(itr->x - a_BlockX));
- WriteByte ((Byte)(itr->y - a_BlockY));
- WriteByte ((Byte)(itr->z - a_BlockZ));
- }
- WriteFloat ((float)a_PlayerMotion.x);
- WriteFloat ((float)a_PlayerMotion.y);
- WriteFloat ((float)a_PlayerMotion.z);
+ WriteByte(PACKET_ENT_REL_MOVE);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_RelX);
+ WriteByte(a_RelY);
+ WriteByte(a_RelZ);
Flush();
}
@@ -377,16 +363,31 @@ void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
-void cProtocol125::SendEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cProtocol125::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_REL_MOVE);
+ WriteByte(PACKET_ENT_REL_MOVE_LOOK);
WriteInt (a_Entity.GetUniqueID());
WriteByte(a_RelX);
WriteByte(a_RelY);
WriteByte(a_RelZ);
+ WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
+ WriteByte((char)((a_Entity.GetPitch() / 360.f) * 256));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityStatus(const cEntity & a_Entity, char a_Status)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENT_STATUS);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_Status);
Flush();
}
@@ -394,18 +395,41 @@ void cProtocol125::SendEntRelMove(const cEntity & a_Entity, char a_RelX, char a_
-void cProtocol125::SendEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cProtocol125::SendEntityVelocity(const cEntity & a_Entity)
{
ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_REL_MOVE_LOOK);
+ WriteByte(PACKET_ENTITY_VELOCITY);
WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_RelX);
- WriteByte(a_RelY);
- WriteByte(a_RelZ);
- WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
- WriteByte((char)((a_Entity.GetPitch() / 360.f) * 256));
+ WriteShort((short) (a_Entity.GetSpeedX() * 400)); //400 = 8000 / 20
+ WriteShort((short) (a_Entity.GetSpeedY() * 400));
+ WriteShort((short) (a_Entity.GetSpeedZ() * 400));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_EXPLOSION);
+ WriteDouble (a_BlockX);
+ WriteDouble (a_BlockY);
+ WriteDouble (a_BlockZ);
+ WriteFloat (a_Radius);
+ WriteInt (a_BlocksAffected.size());
+ for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
+ {
+ WriteByte ((Byte)(itr->x - a_BlockX));
+ WriteByte ((Byte)(itr->y - a_BlockY));
+ WriteByte ((Byte)(itr->z - a_BlockZ));
+ }
+ WriteFloat ((float)a_PlayerMotion.x);
+ WriteFloat ((float)a_PlayerMotion.y);
+ WriteFloat ((float)a_PlayerMotion.z);
Flush();
}
@@ -513,20 +537,6 @@ void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
-void cProtocol125::SendMetadata(const cEntity & a_Entity)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_METADATA);
- WriteInt (a_Entity.GetUniqueID());
- AString MetaData = GetEntityMetaData(a_Entity);
- SendData(MetaData.data(), MetaData.size());
- Flush();
-}
-
-
-
-
-
void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
{
cCSLock Lock(m_CSPacket);
@@ -581,6 +591,15 @@ void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cProtocol125::SendPlayerMaxSpeed(void)
+{
+ // Not supported by this protocol version
+}
+
+
+
+
+
void cProtocol125::SendPlayerMoveLook(void)
{
cCSLock Lock(m_CSPacket);
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index 2e0c04212..07eab3e7a 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -37,13 +37,15 @@ public:
virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
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;
+ virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
+ virtual void SendEntityLook (const cEntity & a_Entity) override;
+ virtual void SendEntityMetadata (const cEntity & a_Entity) override;
+ virtual void SendEntityProperties (const cEntity & a_Entity) override;
+ virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
+ virtual void SendEntityVelocity (const cEntity & a_Entity) override;
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
virtual void SendGameMode (eGameMode a_GameMode) override;
virtual void SendHealth (void) override;
@@ -51,10 +53,10 @@ public:
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
- virtual void SendMetadata (const cEntity & a_Entity) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) override;
virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index f7c3a1670..0b7887f5c 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -200,59 +200,70 @@ void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
-void cProtocolRecognizer::SendEntVelocity(const cEntity & a_Entity)
+void cProtocolRecognizer::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntVelocity(a_Entity);
+ m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
}
-void cProtocolRecognizer::SendEntHeadLook(const cEntity & a_Entity)
+
+void cProtocolRecognizer::SendEntityHeadLook(const cEntity & a_Entity)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntHeadLook(a_Entity);
+ m_Protocol->SendEntityHeadLook(a_Entity);
}
-void cProtocolRecognizer::SendEntLook(const cEntity & a_Entity)
+void cProtocolRecognizer::SendEntityLook(const cEntity & a_Entity)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntLook(a_Entity);
+ m_Protocol->SendEntityLook(a_Entity);
}
-void cProtocolRecognizer::SendEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cProtocolRecognizer::SendEntityMetadata(const cEntity & a_Entity)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
+ m_Protocol->SendEntityMetadata(a_Entity);
}
-void cProtocolRecognizer::SendEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+void cProtocolRecognizer::SendEntityProperties(const cEntity & a_Entity)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
+ m_Protocol->SendEntityProperties(a_Entity);
}
-void cProtocolRecognizer::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
+void cProtocolRecognizer::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
+ m_Protocol->SendEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
}
@@ -269,6 +280,16 @@ void cProtocolRecognizer::SendEntityStatus(const cEntity & a_Entity, char a_Stat
+void cProtocolRecognizer::SendEntityVelocity(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityVelocity(a_Entity);
+}
+
+
+
+
+
void cProtocolRecognizer::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
{
ASSERT(m_Protocol != NULL);
@@ -339,40 +360,40 @@ void cProtocolRecognizer::SendLogin(const cPlayer & a_Player, const cWorld & a_W
-void cProtocolRecognizer::SendMetadata(const cEntity & a_Entity)
+void cProtocolRecognizer::SendPickupSpawn(const cPickup & a_Pickup)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendMetadata(a_Entity);
+ m_Protocol->SendPickupSpawn(a_Pickup);
}
-void cProtocolRecognizer::SendPickupSpawn(const cPickup & a_Pickup)
+void cProtocolRecognizer::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendPickupSpawn(a_Pickup);
+ m_Protocol->SendPlayerAnimation(a_Player, a_Animation);
}
-void cProtocolRecognizer::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
+void cProtocolRecognizer::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerAnimation(a_Player, a_Animation);
+ m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
}
-void cProtocolRecognizer::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+void cProtocolRecognizer::SendPlayerMaxSpeed(void)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
+ m_Protocol->SendPlayerMaxSpeed();
}
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index 38dc3b03e..682ac4b1d 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -66,13 +66,15 @@ public:
virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
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;
+ virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
+ virtual void SendEntityLook (const cEntity & a_Entity) override;
+ virtual void SendEntityMetadata (const cEntity & a_Entity) override;
+ virtual void SendEntityProperties (const cEntity & a_Entity) override;
+ virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
+ virtual void SendEntityVelocity (const cEntity & a_Entity) override;
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
virtual void SendGameMode (eGameMode a_GameMode) override;
virtual void SendHealth (void) override;
@@ -80,10 +82,10 @@ public:
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
- virtual void SendMetadata (const cEntity & a_Entity) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) override;
virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
diff --git a/source/TNTEntity.cpp b/source/TNTEntity.cpp
index fcfd1e0ba..22f343e88 100644
--- a/source/TNTEntity.cpp
+++ b/source/TNTEntity.cpp
@@ -32,7 +32,7 @@ cTNTEntity::cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec) :
void cTNTEntity::Initialize(cWorld * a_World)
{
super::Initialize(a_World);
- a_World->BroadcastSpawn(*this);
+ a_World->BroadcastSpawnEntity(*this);
}
diff --git a/source/World.cpp b/source/World.cpp
index ac7ba42aa..53c60bb69 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -1398,51 +1398,34 @@ void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V
-void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude)
+void cWorld::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
- cCSLock Lock(m_CSPlayers);
- for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- {
- cClientHandle * ch = (*itr)->GetClientHandle();
- if ((ch == a_Exclude) || (ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
- {
- continue;
- }
- ch->SendChat(a_Message);
- }
+ m_ChunkMap->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
}
-void cWorld::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude)
+void cWorld::BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastPlayerAnimation(a_Player, a_Animation, a_Exclude);
+ m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude);
}
-void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
+void cWorld::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastEntityEquipment(a_Entity, a_SlotNum, a_Item, a_Exclude);
+ m_ChunkMap->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
}
-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)
+void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -1452,7 +1435,7 @@ void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHand
{
continue;
}
- ch->SendTeleportEntity(a_Entity);
+ ch->SendChat(a_Message);
}
}
@@ -1460,97 +1443,114 @@ void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHand
-void cWorld::BroadcastEntRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
+void cWorld::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastEntRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
+ m_ChunkMap->BroadcastChunkData(a_ChunkX, a_ChunkZ, a_Serializer, a_Exclude);
}
-void cWorld::BroadcastEntRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
+void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastEntRelMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
+ m_ChunkMap->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
}
-void cWorld::BroadcastEntLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastEntLook(a_Entity, a_Exclude);
+ m_ChunkMap->BroadcastDestroyEntity(a_Entity, a_Exclude);
}
-void cWorld::BroadcastEntHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastEntHeadLook(a_Entity, a_Exclude);
+ m_ChunkMap->BroadcastEntityEquipment(a_Entity, a_SlotNum, a_Item, a_Exclude);
}
-void cWorld::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
+ m_ChunkMap->BroadcastEntityHeadLook(a_Entity, a_Exclude);
}
-void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastDestroyEntity(a_Entity, a_Exclude);
+ m_ChunkMap->BroadcastEntityLook(a_Entity, a_Exclude);
}
-void cWorld::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastEntityStatus(a_Entity, a_Status, a_Exclude);
+ m_ChunkMap->BroadcastEntityMetadata(a_Entity, a_Exclude);
}
-void cWorld::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastMetadata(a_Entity, a_Exclude);
+ m_ChunkMap->BroadcastEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
}
-void cWorld::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastSpawn(a_Entity, a_Exclude);
+ m_ChunkMap->BroadcastEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ, a_Exclude);
}
-void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
+ m_ChunkMap->BroadcastEntityStatus(a_Entity, a_Status, a_Exclude);
}
-void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclude)
+void cWorld::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastEntityVelocity(a_Entity, a_Exclude);
+}
+
+
+
+
+void cWorld::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastPlayerAnimation(a_Player, a_Animation, a_Exclude);
+}
+
+
+
+
+
+void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -1560,7 +1560,7 @@ void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclud
{
continue;
}
- ch->SendWeather(a_Weather);
+ ch->SendPlayerListItem(a_Player, a_IsOnline);
}
}
@@ -1568,43 +1568,34 @@ void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclud
-void cWorld::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
+ m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
}
-void cWorld::BroadcastTimeUpdate(const cClientHandle * a_Exclude)
+void cWorld::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
{
- cCSLock Lock(m_CSPlayers);
- for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- {
- cClientHandle * ch = (*itr)->GetClientHandle();
- if ((ch == a_Exclude) || (ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
- {
- continue;
- }
- ch->SendTimeUpdate(m_WorldAge, m_TimeOfDay);
- }
+ m_ChunkMap->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude);
}
-void cWorld::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
+void cWorld::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastChunkData(a_ChunkX, a_ChunkZ, a_Serializer, a_Exclude);
+ m_ChunkMap->BroadcastSpawnEntity(a_Entity, a_Exclude);
}
-void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude)
+void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -1614,7 +1605,7 @@ void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline,
{
continue;
}
- ch->SendPlayerListItem(a_Player, a_IsOnline);
+ ch->SendTeleportEntity(a_Entity);
}
}
@@ -1622,27 +1613,27 @@ void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline,
-void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
-{
- m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
-}
-
-
-
-
-
-void cWorld::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
+void cWorld::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude);
+ m_ChunkMap->BroadcastThunderbolt(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
}
-void cWorld::BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude)
+void cWorld::BroadcastTimeUpdate(const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude);
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch == a_Exclude) || (ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
+ {
+ continue;
+ }
+ ch->SendTimeUpdate(m_WorldAge, m_TimeOfDay);
+ }
}
@@ -1658,9 +1649,18 @@ void cWorld::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_Block
-void cWorld::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
+void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch == a_Exclude) || (ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
+ {
+ continue;
+ }
+ ch->SendWeather(a_Weather);
+ }
}
@@ -2355,7 +2355,7 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, int a_EntityTy
}
Monster->SetPosition(a_PosX, a_PosY, a_PosZ);
Monster->Initialize(this);
- BroadcastSpawn(*Monster);
+ BroadcastSpawnEntity(*Monster);
return Monster->GetUniqueID();
}
diff --git a/source/World.h b/source/World.h
index 233759589..e455ab682 100644
--- a/source/World.h
+++ b/source/World.h
@@ -120,34 +120,34 @@ public:
/// Retrieves the world height at the specified coords; returns false if chunk not loaded / generated
bool TryGetHeight(int a_BlockX, int a_BlockZ, int & a_Height); // TODO: Export in ManualBindings.cpp
+ // Broadcast respective packets to all clients of the chunk where the event is taking place
+ // (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
- 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);
- void BroadcastEntLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
- void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL);
+ void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
+ void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
+ void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = NULL);
+ void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
- void BroadcastMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
- void BroadcastSpawn (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
- void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
- void BroadcastWeather (eWeather a_Weather, const cClientHandle * a_Exclude = NULL);
- void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
- void BroadcastTimeUpdate (const cClientHandle * a_Exclude = NULL);
- void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastPlayerAnimation (const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
- void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
+ void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastTimeUpdate (const cClientHandle * a_Exclude = NULL);
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
-
- /// If there is a block entity at the specified coods, sends it to all clients except a_Exclude
- void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
+ void BroadcastWeather (eWeather a_Weather, const cClientHandle * a_Exclude = NULL);
/// If there is a block entity at the specified coords, sends it to the client specified
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);