2012-08-30 05:56:59 -04:00
|
|
|
|
|
|
|
// Protocol132.h
|
|
|
|
|
|
|
|
// Interfaces to the cProtocol132 class representing the release 1.3.2 protocol (#39)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Protocol125.h"
|
2012-09-23 16:03:26 -04:00
|
|
|
#include "../../CryptoPP/modes.h"
|
|
|
|
#include "../../CryptoPP/aes.h"
|
2012-08-30 05:56:59 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cProtocol132 :
|
|
|
|
public cProtocol125
|
|
|
|
{
|
|
|
|
typedef cProtocol125 super;
|
|
|
|
public:
|
|
|
|
|
|
|
|
cProtocol132(cClientHandle * a_Client);
|
2012-08-31 17:59:57 -04:00
|
|
|
virtual ~cProtocol132();
|
2012-08-30 05:56:59 -04:00
|
|
|
|
|
|
|
/// Called when client sends some data:
|
|
|
|
virtual void DataReceived(const char * a_Data, int a_Size) override;
|
2012-08-31 17:59:57 -04:00
|
|
|
|
2012-10-21 04:01:59 -04:00
|
|
|
// Sending commands (alphabetically sorted):
|
2012-10-21 03:46:28 -04:00
|
|
|
virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
|
2012-10-21 04:01:59 -04:00
|
|
|
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
|
2012-10-21 03:46:28 -04:00
|
|
|
virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
|
|
|
|
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
|
|
|
virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
|
|
|
|
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
|
|
|
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
|
|
|
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
|
|
|
|
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
|
|
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
|
|
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
|
|
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
|
|
|
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
|
|
|
|
virtual void SendWholeInventory (const cWindow & a_Window) override;
|
2012-09-11 08:01:34 -04:00
|
|
|
|
2012-09-06 13:36:59 -04:00
|
|
|
virtual AString GetAuthServerID(void) override;
|
2012-08-31 17:59:57 -04:00
|
|
|
|
2012-08-30 17:06:13 -04:00
|
|
|
/// Handling of the additional packets:
|
|
|
|
virtual int ParsePacket(unsigned char a_PacketType) override;
|
|
|
|
|
2012-08-30 05:56:59 -04:00
|
|
|
// Modified packets:
|
2012-08-31 17:59:57 -04:00
|
|
|
virtual int ParseBlockPlace (void) override;
|
|
|
|
virtual int ParseHandshake (void) override;
|
|
|
|
virtual int ParseLogin (void) override;
|
|
|
|
virtual int ParsePlayerAbilities(void) override;
|
2012-08-30 17:06:13 -04:00
|
|
|
|
|
|
|
// New packets:
|
|
|
|
virtual int ParseClientStatuses (void);
|
|
|
|
virtual int ParseEncryptionKeyResponse(void);
|
2012-08-31 17:59:57 -04:00
|
|
|
virtual int ParseLocaleViewDistance (void);
|
2012-08-30 17:06:13 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_IsEncrypted;
|
2012-08-31 17:59:57 -04:00
|
|
|
CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption m_Decryptor;
|
2012-08-30 17:06:13 -04:00
|
|
|
CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption m_Encryptor;
|
2012-08-31 17:59:57 -04:00
|
|
|
AString m_DataToSend;
|
|
|
|
|
2012-09-06 13:36:59 -04:00
|
|
|
/// The ServerID used for session authentication; set in StartEncryption(), used in GetAuthServerID()
|
|
|
|
AString m_AuthServerID;
|
|
|
|
|
|
|
|
/// The server's public key, as used by SendEncryptionKeyRequest() and StartEncryption()
|
|
|
|
AString m_ServerPublicKey;
|
|
|
|
|
2012-08-31 17:59:57 -04:00
|
|
|
virtual void SendData(const char * a_Data, int a_Size) override;
|
|
|
|
|
|
|
|
// DEBUG:
|
|
|
|
virtual void Flush(void) override;
|
|
|
|
|
|
|
|
// Items in slots are sent differently
|
|
|
|
virtual void WriteItem(const cItem & a_Item) override;
|
2012-09-02 08:09:58 -04:00
|
|
|
virtual int ParseItem(cItem & a_Item) override;
|
|
|
|
|
|
|
|
virtual void SendCompass(const cWorld & a_World);
|
2012-09-06 13:36:59 -04:00
|
|
|
virtual void SendEncryptionKeyRequest(void);
|
2012-08-31 17:59:57 -04:00
|
|
|
|
2012-08-30 17:06:13 -04:00
|
|
|
/// Decrypts the key and nonce, checks nonce, starts the symmetric encryption
|
|
|
|
void HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce);
|
|
|
|
|
2012-09-06 13:36:59 -04:00
|
|
|
/// Starts the symmetric encryption with the specified key; also sets m_AuthServerID
|
2012-08-30 17:06:13 -04:00
|
|
|
void StartEncryption(const byte * a_Key);
|
2012-08-30 05:56:59 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|