From c0c47d33c571bde4cfb45043b645b3d45c3223e6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Apr 2014 13:16:48 +0100 Subject: Entities handle chunks properly again * Entities properly handle chunks * Changed EntityStatus enums to be less shouty --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 5876e55c7..06091cae4 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2101,7 +2101,7 @@ void cClientHandle::SendExplosion(double a_BlockX, double a_BlockY, double a_Blo } // Update the statistics: - m_NumExplosionsThisTick += 1; + m_NumExplosionsThisTick++; m_Protocol->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_Radius, a_BlocksAffected, a_PlayerMotion); } -- cgit v1.2.3 From b506a7407661c0527255466cf8b315824b0003c0 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sun, 13 Apr 2014 13:04:56 +0200 Subject: Added Yggdrasil Authentication System Code by Howaner. Fixes/Changes by me. --- src/ClientHandle.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 5876e55c7..615039949 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -24,7 +24,7 @@ #include "Root.h" -#include "Authenticator.h" +#include "Protocol/Authenticator.h" #include "MersenneTwister.h" #include "Protocol/ProtocolRecognizer.h" @@ -188,7 +188,7 @@ void cClientHandle::Kick(const AString & a_Reason) -void cClientHandle::Authenticate(void) +void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) { if (m_State != csAuthenticating) { @@ -197,6 +197,9 @@ void cClientHandle::Authenticate(void) ASSERT( m_Player == NULL ); + m_Username = a_Name; + m_UUID = a_UUID; + // Spawn player (only serversided, so data is loaded) m_Player = new cPlayer(this, GetUsername()); -- cgit v1.2.3 From d505ffc704d85cc1b31ae87647ba979fda84f46f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Apr 2014 20:21:00 +0200 Subject: A client UUID is generated when the server is in offline mode. 1.7.9 client works with these changes in offline mode. --- src/ClientHandle.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 615039949..7e8c11d67 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -31,6 +31,8 @@ #include "CompositeChat.h" #include "Items/ItemSword.h" +#include "md5/md5.h" + /** Maximum number of explosions to send this tick, server will start dropping if exceeded */ @@ -175,6 +177,28 @@ void cClientHandle::Destroy(void) +void cClientHandle::GenerateOfflineUUID(void) +{ + // Proper format for a version 3 UUID is: + // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B + + // Generate an md5 checksum, and use it as base for the ID: + MD5 Checksum(m_Username); + m_UUID = Checksum.hexdigest(); + m_UUID[12] = '3'; // Version 3 UUID + m_UUID[16] = '8'; // Variant 1 UUID + + // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions: + m_UUID.insert(8, "-"); + m_UUID.insert(13, "-"); + m_UUID.insert(18, "-"); + m_UUID.insert(23, "-"); +} + + + + + void cClientHandle::Kick(const AString & a_Reason) { if (m_State >= csAuthenticating) // Don't log pings -- cgit v1.2.3 From d12d7b671523f79f760403f3f4c0ef4efb497c79 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Apr 2014 22:52:59 +0200 Subject: Implemented the 1.7.6 protocol and authenticator. Server works both in online and offline modes with 1.7.9. --- src/ClientHandle.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 7e8c11d67..79738ff0b 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -178,21 +178,32 @@ void cClientHandle::Destroy(void) void cClientHandle::GenerateOfflineUUID(void) +{ + m_UUID = GenerateOfflineUUID(m_Username); +} + + + + + +AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) { // Proper format for a version 3 UUID is: // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B // Generate an md5 checksum, and use it as base for the ID: - MD5 Checksum(m_Username); - m_UUID = Checksum.hexdigest(); - m_UUID[12] = '3'; // Version 3 UUID - m_UUID[16] = '8'; // Variant 1 UUID + MD5 Checksum(a_Username); + AString UUID = Checksum.hexdigest(); + UUID[12] = '3'; // Version 3 UUID + UUID[16] = '8'; // Variant 1 UUID // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions: - m_UUID.insert(8, "-"); - m_UUID.insert(13, "-"); - m_UUID.insert(18, "-"); - m_UUID.insert(23, "-"); + UUID.insert(8, "-"); + UUID.insert(13, "-"); + UUID.insert(18, "-"); + UUID.insert(23, "-"); + + return UUID; } @@ -223,6 +234,9 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) m_Username = a_Name; m_UUID = a_UUID; + + // Send login success (if the protocol supports it): + m_Protocol->SendLoginSuccess(); // Spawn player (only serversided, so data is loaded) m_Player = new cPlayer(this, GetUsername()); -- cgit v1.2.3 From 99e4225269776d4e79b7d0d14dc8bbe11a2ad32d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Apr 2014 23:40:06 +0200 Subject: Attempted fix for the client crash with the new protocols. --- src/ClientHandle.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 79738ff0b..9ab32d6ec 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1718,13 +1718,16 @@ void cClientHandle::Tick(float a_Dt) } // Send a ping packet: - cTimer t1; - if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= t1.GetNowTime())) + if (m_State == csPlaying) { - m_PingID++; - m_PingStartTime = t1.GetNowTime(); - m_Protocol->SendKeepAlive(m_PingID); - m_LastPingTime = m_PingStartTime; + cTimer t1; + if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= t1.GetNowTime())) + { + m_PingID++; + m_PingStartTime = t1.GetNowTime(); + m_Protocol->SendKeepAlive(m_PingID); + m_LastPingTime = m_PingStartTime; + } } // Handle block break animation: -- cgit v1.2.3