diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-03-10 22:34:47 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-03-10 22:34:47 +0100 |
commit | e7731242c1315df230bffbf0593e1a608aa791a3 (patch) | |
tree | 803b09ea2e4485d979f2ed13b231e62237191861 | |
parent | Fixed mob spawn packet for 1.2 client, now client doesn't bail out when mobs are turned on (diff) | |
download | cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.tar cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.tar.gz cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.tar.bz2 cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.tar.lz cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.tar.xz cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.tar.zst cuberite-e7731242c1315df230bffbf0593e1a608aa791a3.zip |
-rw-r--r-- | source/cBlockEntity.h | 2 | ||||
-rw-r--r-- | source/cChunk.cpp | 2 | ||||
-rw-r--r-- | source/cClientHandle.cpp | 30 | ||||
-rw-r--r-- | source/cClientHandle.h | 3 | ||||
-rw-r--r-- | source/cEntity.cpp | 6 | ||||
-rw-r--r-- | source/cPickup.cpp | 2 | ||||
-rw-r--r-- | source/cServer.cpp | 2 | ||||
-rw-r--r-- | source/cServer.h | 3 |
8 files changed, 24 insertions, 26 deletions
diff --git a/source/cBlockEntity.h b/source/cBlockEntity.h index ab0a6c6ca..3f0190c77 100644 --- a/source/cBlockEntity.h +++ b/source/cBlockEntity.h @@ -66,7 +66,7 @@ public: }
if ( a_Client != NULL )
{
- a_Client->Send(Packet.get());
+ a_Client->Send(*(Packet.get()));
}
else // broadcast to all chunk clients
{
diff --git a/source/cChunk.cpp b/source/cChunk.cpp index f56584cbf..1b181f575 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -1373,7 +1373,7 @@ void cChunk::Broadcast( const cPacket * a_Packet, cClientHandle* a_Exclude) {
continue;
}
- (*itr)->Send( a_Packet );
+ (*itr)->Send(*a_Packet);
} // for itr - LoadedByClient[]
}
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index cf6c3fb5f..58bfad7dc 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -1703,14 +1703,14 @@ void cClientHandle::Tick(float a_Dt) -void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = E_PRIORITY_NORMAL */)
+void cClientHandle::Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* = E_PRIORITY_NORMAL */)
{
if (m_bKicking) return; // Don't add more packets if player is getting kicked anyway
// If it is the packet spawning myself for myself, drop it silently:
- if (a_Packet->m_PacketID == E_NAMED_ENTITY_SPAWN)
+ if (a_Packet.m_PacketID == E_NAMED_ENTITY_SPAWN)
{
- if (((cPacket_NamedEntitySpawn *)a_Packet)->m_UniqueID == m_Player->GetUniqueID())
+ if (((cPacket_NamedEntitySpawn &)a_Packet).m_UniqueID == m_Player->GetUniqueID())
{
return;
}
@@ -1719,7 +1719,7 @@ void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = // Filter out packets that don't belong to a csDownloadingWorld state:
if (m_State == csDownloadingWorld)
{
- switch (a_Packet->m_PacketID)
+ switch (a_Packet.m_PacketID)
{
case E_PLAYERMOVELOOK:
case E_KEEP_ALIVE:
@@ -1734,14 +1734,14 @@ void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = }
// Check chunks being sent, erase them from m_ChunksToSend:
- if (a_Packet->m_PacketID == E_MAP_CHUNK)
+ if (a_Packet.m_PacketID == E_MAP_CHUNK)
{
#if (MINECRAFT_1_2_2 == 1)
- int ChunkX = ((cPacket_MapChunk *)a_Packet)->m_PosX;
- int ChunkZ = ((cPacket_MapChunk *)a_Packet)->m_PosZ;
+ int ChunkX = ((cPacket_MapChunk &)a_Packet).m_PosX;
+ int ChunkZ = ((cPacket_MapChunk &)a_Packet).m_PosZ;
#else
- int ChunkX = ((cPacket_MapChunk *)a_Packet)->m_PosX / cChunk::c_ChunkWidth;
- int ChunkZ = ((cPacket_MapChunk *)a_Packet)->m_PosZ / cChunk::c_ChunkWidth;
+ int ChunkX = ((cPacket_MapChunk &)a_Packet).m_PosX / cChunk::c_ChunkWidth;
+ int ChunkZ = ((cPacket_MapChunk &)a_Packet).m_PosZ / cChunk::c_ChunkWidth;
#endif
cCSLock Lock(m_CSChunkLists);
for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end(); ++itr)
@@ -1759,9 +1759,10 @@ void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = cCSLock Lock(m_CSPackets);
if (a_Priority == E_PRIORITY_NORMAL)
{
- if (a_Packet->m_PacketID == E_REL_ENT_MOVE_LOOK)
+ if (a_Packet.m_PacketID == E_REL_ENT_MOVE_LOOK)
{
PacketList & Packets = m_PendingNrmSendPackets;
+ const cPacket_RelativeEntityMoveLook & ThisPacketData = reinterpret_cast< const cPacket_RelativeEntityMoveLook &>(a_Packet);
for (PacketList::iterator itr = Packets.begin(); itr != Packets.end(); ++itr)
{
bool bBreak = false;
@@ -1769,9 +1770,8 @@ void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = {
case E_REL_ENT_MOVE_LOOK:
{
- const cPacket_RelativeEntityMoveLook* ThisPacketData = reinterpret_cast< const cPacket_RelativeEntityMoveLook* >(a_Packet);
- cPacket_RelativeEntityMoveLook* PacketData = reinterpret_cast< cPacket_RelativeEntityMoveLook* >(*itr);
- if (ThisPacketData->m_UniqueID == PacketData->m_UniqueID)
+ cPacket_RelativeEntityMoveLook * PacketData = reinterpret_cast< cPacket_RelativeEntityMoveLook *>(*itr);
+ if (ThisPacketData.m_UniqueID == PacketData->m_UniqueID)
{
Packets.erase(itr);
bBreak = true;
@@ -1787,11 +1787,11 @@ void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = }
} // for itr - Packets[]
} // if (E_REL_ENT_MOVE_LOOK
- m_PendingNrmSendPackets.push_back(a_Packet->Clone());
+ m_PendingNrmSendPackets.push_back(a_Packet.Clone());
}
else if (a_Priority == E_PRIORITY_LOW)
{
- m_PendingLowSendPackets.push_back(a_Packet->Clone());
+ m_PendingLowSendPackets.push_back(a_Packet.Clone());
}
Lock.Unlock();
diff --git a/source/cClientHandle.h b/source/cClientHandle.h index 65a4e5db8..2a9833de4 100644 --- a/source/cClientHandle.h +++ b/source/cClientHandle.h @@ -97,8 +97,7 @@ public: bool IsPlaying(void) const {return (m_State == csPlaying); }
- void Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL) { Send(&a_Packet, a_Priority); }
- void Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL);
+ void Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL);
const AString & GetUsername(void) const; //tolua_export
diff --git a/source/cEntity.cpp b/source/cEntity.cpp index ba1ca836a..f9e9d4e82 100644 --- a/source/cEntity.cpp +++ b/source/cEntity.cpp @@ -120,7 +120,7 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk) {
m_Destroy = new cPacket_DestroyEntity(m_Entity);
}
- a_Client->Send(m_Destroy);
+ a_Client->Send(*m_Destroy);
}
virtual void Added(cClientHandle * a_Client) override
@@ -131,7 +131,7 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk) }
if (m_Spawn != NULL)
{
- a_Client->Send(m_Spawn);
+ a_Client->Send(*m_Spawn);
}
}
@@ -218,7 +218,7 @@ void cEntity::SpawnOn(cClientHandle * a_Client) }
else
{
- a_Client->Send(SpawnPacket.get());
+ a_Client->Send(*(SpawnPacket.get()));
}
}
diff --git a/source/cPickup.cpp b/source/cPickup.cpp index cf71abab0..e8c0b80db 100644 --- a/source/cPickup.cpp +++ b/source/cPickup.cpp @@ -54,7 +54,7 @@ cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX std::auto_ptr<cPacket> PickupSpawn(GetSpawnPacket());
if (PickupSpawn.get() != NULL)
{
- cRoot::Get()->GetServer()->Broadcast( PickupSpawn.get() );
+ cRoot::Get()->GetServer()->Broadcast(*(PickupSpawn.get()));
}
}
diff --git a/source/cServer.cpp b/source/cServer.cpp index 5412e4be5..b36d353cb 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -285,7 +285,7 @@ cServer::~cServer() // TODO - Need to modify this or something, so it broadcasts to all worlds? And move this to cWorld?
-void cServer::Broadcast( const cPacket * a_Packet, cClientHandle* a_Exclude /* = 0 */ )
+void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ )
{
cCSLock Lock(m_CSClients);
for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
diff --git a/source/cServer.h b/source/cServer.h index 22c4d7ef6..dc1de96cd 100644 --- a/source/cServer.h +++ b/source/cServer.h @@ -38,8 +38,7 @@ public: //tolua_export bool IsConnected(){return m_bIsConnected;} // returns connection status
void StartListenClient(); // Listen to client
- void Broadcast(const cPacket & a_Packet, cClientHandle* a_Exclude = NULL) { Broadcast(&a_Packet, a_Exclude); }
- void Broadcast(const cPacket * a_Packet, cClientHandle* a_Exclude = NULL);
+ void Broadcast(const cPacket & a_Packet, cClientHandle* a_Exclude = NULL);
bool Tick(float a_Dt);
|