cClientHandle: split packet handling into separate functions for clarity
git-svn-id: http://mc-server.googlecode.com/svn/trunk@229 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
f86d796295
commit
b8be8a4df0
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,33 @@
|
|||||||
#include "Packets/cPacket.h"
|
#include "Packets/cPacket.h"
|
||||||
#include "Vector3d.h"
|
#include "Vector3d.h"
|
||||||
|
|
||||||
|
#include "packets/cPacket_KeepAlive.h"
|
||||||
|
#include "packets/cPacket_PlayerPosition.h"
|
||||||
|
#include "packets/cPacket_Respawn.h"
|
||||||
|
#include "packets/cPacket_RelativeEntityMoveLook.h"
|
||||||
|
#include "packets/cPacket_Chat.h"
|
||||||
|
#include "packets/cPacket_Login.h"
|
||||||
|
#include "packets/cPacket_WindowClick.h"
|
||||||
|
#include "packets/cPacket_PlayerMoveLook.h"
|
||||||
|
#include "packets/cPacket_TimeUpdate.h"
|
||||||
|
#include "packets/cPacket_BlockDig.h"
|
||||||
|
#include "packets/cPacket_Handshake.h"
|
||||||
|
#include "packets/cPacket_PlayerLook.h"
|
||||||
|
#include "packets/cPacket_ArmAnim.h"
|
||||||
|
#include "packets/cPacket_BlockPlace.h"
|
||||||
|
#include "packets/cPacket_Flying.h"
|
||||||
|
#include "packets/cPacket_Disconnect.h"
|
||||||
|
#include "packets/cPacket_PickupSpawn.h"
|
||||||
|
#include "packets/cPacket_ItemSwitch.h"
|
||||||
|
#include "packets/cPacket_EntityEquipment.h"
|
||||||
|
#include "packets/cPacket_CreativeInventoryAction.h"
|
||||||
|
#include "packets/cPacket_NewInvalidState.h"
|
||||||
|
#include "packets/cPacket_UseEntity.h"
|
||||||
|
#include "packets/cPacket_WindowClose.h"
|
||||||
|
#include "packets/cPacket_UpdateSign.h"
|
||||||
|
#include "packets/cPacket_Ping.h"
|
||||||
|
#include "packets/cPacket_PlayerListItem.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -75,33 +102,30 @@ public:
|
|||||||
const AString & GetUsername(void) const;
|
const AString & GetUsername(void) const;
|
||||||
|
|
||||||
inline short GetPing() { return m_Ping; }
|
inline short GetPing() { return m_Ping; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void HandlePacket( cPacket* a_Packet );
|
|
||||||
void RemovePacket( cPacket * a_Packet );
|
|
||||||
|
|
||||||
void SendLoginResponse();
|
int m_ProtocolVersion;
|
||||||
|
AString m_Username;
|
||||||
|
AString m_Password;
|
||||||
|
|
||||||
int mProtocolVersion;
|
PacketList m_PendingParsePackets;
|
||||||
AString mUsername;
|
PacketList m_PendingNrmSendPackets;
|
||||||
AString mPassword;
|
PacketList m_PendingLowSendPackets;
|
||||||
|
|
||||||
PacketList mPendingParsePackets;
|
cThread * m_pReceiveThread;
|
||||||
PacketList mPendingNrmSendPackets;
|
cThread * m_pSendThread;
|
||||||
PacketList mPendingLowSendPackets;
|
|
||||||
|
|
||||||
cThread* pReceiveThread;
|
cSocket m_Socket;
|
||||||
cThread* pSendThread;
|
|
||||||
|
|
||||||
cSocket mSocket;
|
cCriticalSection m_CriticalSection;
|
||||||
|
cCriticalSection m_SendCriticalSection;
|
||||||
|
cCriticalSection m_SocketCriticalSection;
|
||||||
|
cSemaphore m_Semaphore;
|
||||||
|
|
||||||
cCriticalSection mCriticalSection;
|
Vector3d m_ConfirmPosition;
|
||||||
cCriticalSection mSendCriticalSection;
|
|
||||||
cCriticalSection mSocketCriticalSection;
|
|
||||||
cSemaphore mSemaphore;
|
|
||||||
|
|
||||||
Vector3d mConfirmPosition;
|
cPacket * m_PacketMap[256];
|
||||||
|
|
||||||
cPacket * mPacketMap[256];
|
|
||||||
|
|
||||||
bool m_bDestroyed;
|
bool m_bDestroyed;
|
||||||
cPlayer * m_Player;
|
cPlayer * m_Player;
|
||||||
@ -120,6 +144,42 @@ private:
|
|||||||
bool m_bSendLoginResponse;
|
bool m_bSendLoginResponse;
|
||||||
|
|
||||||
bool m_bKeepThreadGoing;
|
bool m_bKeepThreadGoing;
|
||||||
|
|
||||||
|
void HandlePacket(cPacket * a_Packet);
|
||||||
|
|
||||||
|
// Packets handled while !m_bLoggedIn:
|
||||||
|
void HandlePing (void);
|
||||||
|
void HandleHandshake (cPacket_Handshake * a_Packet);
|
||||||
|
void HandleLogin (cPacket_Login * a_Packet);
|
||||||
|
void HandleMoveLookLogin(cPacket_PlayerMoveLook * a_Packet); // While !m_bLoggedIn
|
||||||
|
void HandleDefaultLogin (cPacket * a_Packet); // the default case
|
||||||
|
|
||||||
|
// Packets handled while !m_bPositionConfirmed:
|
||||||
|
void HandleMoveLookConfirm(cPacket_PlayerMoveLook * a_Packet); // While !m_bPositionConfirmed
|
||||||
|
|
||||||
|
// Packets handled while m_bPositionConfirmed (normal gameplay):
|
||||||
|
void HandleCreativeInventory(cPacket_CreativeInventoryAction * a_Packet);
|
||||||
|
void HandlePlayerPos (cPacket_PlayerPosition * a_Packet);
|
||||||
|
void HandleBlockDig (cPacket_BlockDig * a_Packet);
|
||||||
|
void HandleBlockPlace (cPacket_BlockPlace * a_Packet);
|
||||||
|
void HandlePickupSpawn (cPacket_PickupSpawn * a_Packet);
|
||||||
|
void HandleChat (cPacket_Chat * a_Packet);
|
||||||
|
void HandlePlayerLook (cPacket_PlayerLook * a_Packet);
|
||||||
|
void HandlePlayerMoveLook (cPacket_PlayerMoveLook * a_Packet); // While m_bPositionConfirmed (normal gameplay)
|
||||||
|
void HandleAnimation (cPacket_ArmAnim * a_Packet);
|
||||||
|
void HandleItemSwitch (cPacket_ItemSwitch * a_Packet);
|
||||||
|
void HandleWindowClose (cPacket_WindowClose * a_Packet);
|
||||||
|
void HandleWindowClick (cPacket_WindowClick * a_Packet);
|
||||||
|
void HandleUpdateSign (cPacket_UpdateSign * a_Packet);
|
||||||
|
void HandleUseEntity (cPacket_UseEntity * a_Packet);
|
||||||
|
void HandleRespawn (void);
|
||||||
|
void HandleDisconnect (cPacket_Disconnect * a_Packet);
|
||||||
|
void HandleKeepAlive (cPacket_KeepAlive * a_Packet);
|
||||||
|
|
||||||
|
/// Returns true if the rate block interactions is within a reasonable limit (bot protection)
|
||||||
|
bool CheckBlockInteractionsRate(void);
|
||||||
|
|
||||||
|
void SendLoginResponse();
|
||||||
}; // tolua_export
|
}; // tolua_export
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user