/// Adds the chunk specified to the list of chunks wanted for sending (m_ChunksToSend)
voidAddWantedChunk(inta_ChunkX,inta_ChunkZ);
private:
intm_ViewDistance;// Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 )
staticconstintGENERATEDISTANCE=2;// Server generates this many chunks AHEAD of player sight. 2 is the minimum, since foliage is generated 1 step behind chunk terrain generation
cChunkCoordsListm_LoadedChunks;// Chunks that the player belongs to
cChunkCoordsListm_ChunksToSend;// Chunks that need to be sent to the player (queued because they weren't generated yet or there's not enough time to send them)
cSocketm_Socket;
cCriticalSectionm_CriticalSection;
Vector3dm_ConfirmPosition;
cPacket*m_PacketMap[256];
boolm_bDestroyed;
cPlayer*m_Player;
boolm_bKicking;
// Chunk position when the last StreamChunks() was called; used to avoid re-streaming while in the same chunk
intm_LastStreamedChunkX;
intm_LastStreamedChunkZ;
floatm_TimeLastPacket;
shortm_Ping;
intm_PingID;
longlongm_PingStartTime;
longlongm_LastPingTime;
staticconstunsignedshortPING_TIME_MS=1000;//minecraft sends 1 per 20 ticks (1 second or every 1000 ms)
enumeState
{
csConnected,// The client has just connected, waiting for their handshake / login
csAuthenticating,// The client has logged in, waiting for external authentication
csDownloadingWorld,// The client is waiting for chunks, we're waiting for the loader to provide and send them
csConfirmingPos,// The client has been sent the position packet, waiting for them to repeat the position back
csPlaying,// Normal gameplay
// TODO: Add Kicking and Destroyed here as well
};
eStatem_State;
boolm_bKeepThreadGoing;
voidHandlePacket(cPacket*a_Packet);
// Packets handled in csConnected:
voidHandlePing(void);
voidHandleHandshake(cPacket_Handshake*a_Packet);
voidHandleLogin(cPacket_Login*a_Packet);
voidHandleUnexpectedPacket(cPacket*a_Packet);// the default case -> kick
// Packets handled while in csConfirmingPos:
voidHandleMoveLookConfirm(cPacket_PlayerMoveLook*a_Packet);// While !m_bPositionConfirmed