1
0
cuberite-2a/source/cClientHandle.h
faketruth 2892a844d4 Chunks are generated in a separate thread allowing players to keep on playing and chatting while chunks are generated. This means, however, that cWorld::GetChunk() does not always return a chunk and is something you need to be aware of. I am not entirely sure if all this is completely stable, but I think so :O
Chunks are now generated before the player is able to see them. This is done because after a chunks is done generating, some blocks might still need to be set (parts of trees from neighboring chunk), causing more bandwidth to be used (each changed block needs to be sent to clients again) and (fps) lagging the clients when changing a lot of blocks. Calculating ahead fixes these issues.

Separated the placing of foliage (trees and stuff) when generated chunks into a new function GenerateFoliage()
Cleaned up the VS2010 project, now using some VS2010 specific functions like dependencies on projects (no need for setting library dependencies manually). VS2010 project now compiles way faster in Release by using multi threading.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@103 0a769ca7-a7f5-676a-18bf-c427514a06d6
2011-12-24 23:34:30 +00:00

74 lines
1.7 KiB
C++

#pragma once
class cSocket;
class cSemaphore;
class cEvent;
class Game;
class cPacket;
class cChunk;
class cPlayer;
class cRedstone;
class cClientHandle // tolua_export
{ // tolua_export
public:
enum ENUM_PRIORITY
{
E_PRIORITY_LOW,
E_PRIORITY_NORMAL
};
cClientHandle(const cSocket & a_Socket);
~cClientHandle();
static const int VIEWDISTANCE = 13; // MUST be odd number or CRASH!
static const int GENERATEDISTANCE = 2; // Server generates this many chunks AHEAD of player sight.
const cSocket & GetSocket();
cPlayer* GetPlayer() { return m_Player; } // tolua_export
void Kick( const char* a_Reason ); //tolua_export
void AddPacket( cPacket * a_Packet );
void HandlePendingPackets();
void StreamChunks();
void StreamChunksSmart( cChunk** a_Chunks, unsigned int a_NumChunks );
inline void SetLoggedIn( bool a_bLoggedIn ) { m_bLoggedIn = a_bLoggedIn; }
inline bool IsLoggedIn() { return m_bLoggedIn; }
void Tick(float a_Dt);
bool IsDestroyed() { return m_bDestroyed; }
void Destroy();
cChunk* m_LoadedChunks[VIEWDISTANCE*VIEWDISTANCE];
void Send( const cPacket & a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL );
static void SendThread( void *lpParam );
static void ReceiveThread( void *lpParam );
static void AuthenticateThread( void* a_Param );
const char* GetUsername();
private:
void HandlePacket( cPacket* a_Packet );
void RemovePacket( cPacket * a_Packet );
void SendLoginResponse();
struct sClientHandleState;
sClientHandleState* m_pState;
bool m_bDestroyed;
cPlayer* m_Player;
bool m_bKicking;
float m_TimeLastPacket;
bool m_bLoggedIn;
bool m_bSendLoginResponse;
bool m_bKeepThreadGoing;
}; // tolua_export