ChunkSender: Chunks are now compressed and sent to clients from a separate threads, proper passive waiting between threads. Not much tested, just appears to work :)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@365 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cClientHandle.h"
|
||||
#include "cWorld.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "BlockID.h"
|
||||
#else
|
||||
@@ -16,9 +23,9 @@ namespace Json
|
||||
class Value;
|
||||
};
|
||||
|
||||
class cClientHandle;
|
||||
class cPlayer;
|
||||
class cWorld;
|
||||
class cPacket;
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +56,26 @@ public:
|
||||
virtual void SaveToJson (Json::Value & a_Value ) = 0;
|
||||
|
||||
virtual void UsedBy( cPlayer * a_Player ) = 0;
|
||||
virtual void SendTo( cClientHandle* a_Client ) { (void)a_Client; }
|
||||
|
||||
void SendTo( cClientHandle* a_Client )
|
||||
{
|
||||
std::auto_ptr<cPacket> Packet(GetPacket());
|
||||
if (Packet.get() == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( a_Client != NULL )
|
||||
{
|
||||
a_Client->Send(Packet.get());
|
||||
}
|
||||
else // broadcast to all chunk clients
|
||||
{
|
||||
m_World->BroadcastToChunkOfBlock(m_PosX, m_PosY, m_PosZ, Packet.get());
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the packet to send to clients to represent this entity; NULL if no packet needed; caller is supposed to delete the packet
|
||||
virtual cPacket * GetPacket(void) {return NULL; }
|
||||
|
||||
protected:
|
||||
int m_PosX; // Position in block coordinates
|
||||
|
||||
Reference in New Issue
Block a user