summaryrefslogtreecommitdiffstats
path: root/Tools/ProtoProxy
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r--Tools/ProtoProxy/Connection.cpp26
-rw-r--r--Tools/ProtoProxy/Connection.h6
-rw-r--r--Tools/ProtoProxy/Globals.h1
-rw-r--r--Tools/ProtoProxy/ProtoProxy.vcproj8
4 files changed, 34 insertions, 7 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 4c2b0d4e9..08daf5766 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -201,6 +201,9 @@ enum
PACKET_ENCRYPTION_KEY_REQUEST = 0xfd,
PACKET_PING = 0xfe,
PACKET_KICK = 0xff,
+
+ // Synonyms:
+ PACKET_DISCONNECT = PACKET_KICK,
} ;
@@ -238,7 +241,7 @@ cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
m_Server(a_Server),
m_ClientSocket(a_ClientSocket),
m_ServerSocket(-1),
- m_BeginTick(clock()),
+ m_BeginTick(m_Timer.GetNowTime()),
m_ClientState(csUnencrypted),
m_ServerState(csUnencrypted),
m_Nonce(0),
@@ -475,8 +478,7 @@ bool cConnection::RelayFromClient(void)
double cConnection::GetRelativeTime(void)
{
- return (double)(clock() - m_BeginTick) / CLOCKS_PER_SEC;
-
+ return (double)(m_Timer.GetNowTime() - m_BeginTick) / 1000;
}
@@ -558,9 +560,9 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
while (m_ClientBuffer.CanReadBytes(1))
{
- Log("Decoding client's packets, there are now %d bytes in the queue", m_ClientBuffer.GetReadableSpace());
unsigned char PacketType;
m_ClientBuffer.ReadByte(PacketType);
+ Log("Decoding client's packets, there are now %d bytes in the queue; next packet is 0x%02x", m_ClientBuffer.GetReadableSpace(), PacketType);
switch (PacketType)
{
case PACKET_BLOCK_DIG: HANDLE_CLIENT_READ(HandleClientBlockDig); break;
@@ -568,6 +570,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
case PACKET_CHAT_MESSAGE: HANDLE_CLIENT_READ(HandleClientChatMessage); break;
case PACKET_CLIENT_STATUSES: HANDLE_CLIENT_READ(HandleClientClientStatuses); break;
case PACKET_CREATIVE_INVENTORY_ACTION: HANDLE_CLIENT_READ(HandleClientCreativeInventoryAction); break;
+ case PACKET_DISCONNECT: HANDLE_CLIENT_READ(HandleClientDisconnect); break;
case PACKET_ENCRYPTION_KEY_RESPONSE: HANDLE_CLIENT_READ(HandleClientEncryptionKeyResponse); break;
case PACKET_ENTITY_ACTION: HANDLE_CLIENT_READ(HandleClientEntityAction); break;
case PACKET_HANDSHAKE: HANDLE_CLIENT_READ(HandleClientHandshake); break;
@@ -644,7 +647,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
{
unsigned char PacketType;
m_ServerBuffer.ReadByte(PacketType);
- Log("Decoding server's packets, there are now %d bytes in the queue; next packet is 0x%x", m_ServerBuffer.GetReadableSpace(), PacketType);
+ Log("Decoding server's packets, there are now %d bytes in the queue; next packet is 0x%02x", m_ServerBuffer.GetReadableSpace(), PacketType);
LogFlush();
switch (PacketType)
{
@@ -843,6 +846,19 @@ bool cConnection::HandleClientCreativeInventoryAction(void)
+bool cConnection::HandleClientDisconnect(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Reason);
+ Log("Received a PACKET_DISCONNECT from the client:");
+ Log(" Reason = \"%s\"", Reason.c_str());
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
bool cConnection::HandleClientEncryptionKeyResponse(void)
{
HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, EncKeyLength);
diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h
index 8d466c62d..c30a28727 100644
--- a/Tools/ProtoProxy/Connection.h
+++ b/Tools/ProtoProxy/Connection.h
@@ -9,8 +9,8 @@
#pragma once
-#include <time.h>
#include "ByteBuffer.h"
+#include "../../source/OSSupport/Timer.h"
@@ -35,7 +35,8 @@ class cConnection
SOCKET m_ClientSocket;
SOCKET m_ServerSocket;
- clock_t m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime())
+ cTimer m_Timer;
+ long long m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime())
enum eConnectionState
{
@@ -115,6 +116,7 @@ protected:
bool HandleClientChatMessage(void);
bool HandleClientClientStatuses(void);
bool HandleClientCreativeInventoryAction(void);
+ bool HandleClientDisconnect(void);
bool HandleClientEncryptionKeyResponse(void);
bool HandleClientEntityAction(void);
bool HandleClientHandshake(void);
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
index f2c47e96f..3b154b866 100644
--- a/Tools/ProtoProxy/Globals.h
+++ b/Tools/ProtoProxy/Globals.h
@@ -143,6 +143,7 @@ typedef short Int16;
#include <stdio.h>
#include <math.h>
#include <stdarg.h>
+#include <time.h>
diff --git a/Tools/ProtoProxy/ProtoProxy.vcproj b/Tools/ProtoProxy/ProtoProxy.vcproj
index 695e01e76..926bbe586 100644
--- a/Tools/ProtoProxy/ProtoProxy.vcproj
+++ b/Tools/ProtoProxy/ProtoProxy.vcproj
@@ -256,6 +256,14 @@
RelativePath="..\..\source\StringUtils.h"
>
</File>
+ <File
+ RelativePath="..\..\source\OSSupport\Timer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\Timer.h"
+ >
+ </File>
</Filter>
<File
RelativePath=".\ProtoProxy.txt"