2011-10-03 14:41:19 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class cSocket;
|
|
|
|
class cSemaphore;
|
|
|
|
class cEvent;
|
|
|
|
class Game;
|
|
|
|
class cPacket;
|
|
|
|
class cChunk;
|
|
|
|
class cPlayer;
|
2011-11-04 01:01:55 -04:00
|
|
|
class cRedstone;
|
2011-10-03 14:41:19 -04:00
|
|
|
class cClientHandle // tolua_export
|
|
|
|
{ // tolua_export
|
|
|
|
public:
|
|
|
|
enum ENUM_PRIORITY
|
|
|
|
{
|
|
|
|
E_PRIORITY_LOW,
|
|
|
|
E_PRIORITY_NORMAL
|
|
|
|
};
|
|
|
|
|
2011-12-28 06:27:36 -05:00
|
|
|
static const int MAXBLOCKCHANGEINTERACTIONS = 10; // 5 didn't help, 10 seems to have done the trick
|
2011-12-27 11:27:22 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
cClientHandle(const cSocket & a_Socket);
|
|
|
|
~cClientHandle();
|
|
|
|
|
2011-12-24 18:34:30 -05:00
|
|
|
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.
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
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 );
|
2011-12-26 16:54:08 -05:00
|
|
|
void RemoveFromAllChunks();
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
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();
|
2011-12-27 13:39:06 -05:00
|
|
|
|
2011-12-25 21:35:49 -05:00
|
|
|
inline short GetPing() { return m_Ping; }
|
2011-10-03 14:41:19 -04:00
|
|
|
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;
|
|
|
|
|
2011-12-25 21:35:49 -05:00
|
|
|
short m_Ping;
|
2011-12-27 13:39:06 -05:00
|
|
|
int m_PingID;
|
|
|
|
long long m_PingStartTime;
|
|
|
|
long long m_LastPingTime;
|
|
|
|
static const unsigned short PING_TIME_MS = 1000; //minecraft sends 1 per 20 ticks (1 second or every 1000 ms)
|
2011-12-25 21:35:49 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
bool m_bLoggedIn;
|
2012-01-19 13:12:39 -05:00
|
|
|
bool m_bPositionConfirmed;
|
2011-11-01 17:57:08 -04:00
|
|
|
bool m_bSendLoginResponse;
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
bool m_bKeepThreadGoing;
|
|
|
|
}; // tolua_export
|