From cfdf39a75f68c902e78f78bf3396ce94104903b5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 20 Aug 2014 16:12:05 +0200 Subject: Added "HOOK_SERVER_PING" call to older protocols --- src/Protocol/ProtocolRecognizer.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/Protocol/ProtocolRecognizer.cpp') diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index a7fb7bcc2..b197cd384 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -1013,6 +1013,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) { AString Reply; cServer * Server = cRoot::Get()->GetServer(); + + AString Motd = Server->GetDescription(); + int NumPlayers = Server->GetNumPlayers(); + int MaxPlayers = Server->GetMaxPlayers(); + switch (cRoot::Get()->GetPrimaryServerVersion()) { case PROTO_VERSION_1_2_5: @@ -1020,11 +1025,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) { // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29 Printf(Reply, "%s%s%i%s%i", - Server->GetDescription().c_str(), + Motd.c_str(), cChatColor::Delimiter, - Server->GetNumPlayers(), + NumPlayers, cChatColor::Delimiter, - Server->GetMaxPlayers() + MaxPlayers ); break; } @@ -1051,13 +1056,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) m_Buffer.ReadByte(val); // 0x01 magic value ASSERT(val == 0x01); } - - // http://wiki.vg/wiki/index.php?title=Server_List_Ping&oldid=3100 - AString NumPlayers; - Printf(NumPlayers, "%d", Server->GetNumPlayers()); - AString MaxPlayers; - Printf(MaxPlayers, "%d", Server->GetMaxPlayers()); - + AString ProtocolVersionNum; Printf(ProtocolVersionNum, "%d", cRoot::Get()->GetPrimaryServerVersion()); AString ProtocolVersionTxt(GetVersionTextFromInt(cRoot::Get()->GetPrimaryServerVersion())); @@ -1070,11 +1069,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) Reply.push_back(0); Reply.append(ProtocolVersionTxt); Reply.push_back(0); - Reply.append(Server->GetDescription()); + Reply.append(Motd); Reply.push_back(0); - Reply.append(NumPlayers); + Reply.append(Printf("%d", NumPlayers)); Reply.push_back(0); - Reply.append(MaxPlayers); + Reply.append(Printf("%d", MaxPlayers)); break; } } // switch (m_PrimaryServerVersion) -- cgit v1.2.3 From cf5ab14ca59904e208bf6cb9d87134f01803eeed Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 20 Aug 2014 22:19:50 +0200 Subject: Added a_ClientHandle to the HOOK_SERVER_PING hook. --- src/Protocol/ProtocolRecognizer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Protocol/ProtocolRecognizer.cpp') diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index b197cd384..af5a8a416 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -18,6 +18,7 @@ #include "../Server.h" #include "../World.h" #include "../ChatColor.h" +#include "Bindings/PluginManager.h" @@ -1017,6 +1018,8 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) AString Motd = Server->GetDescription(); int NumPlayers = Server->GetNumPlayers(); int MaxPlayers = Server->GetMaxPlayers(); + AString Favicon = Server->GetFaviconData(); + cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, Motd, NumPlayers, MaxPlayers, Favicon); switch (cRoot::Get()->GetPrimaryServerVersion()) { -- cgit v1.2.3 From 4da61e67d7638c46dc56fe451e81a5b4b0f134db Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 20 Aug 2014 22:22:38 +0200 Subject: Renamed a_Motd to a_ServerDescription. --- src/Protocol/ProtocolRecognizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Protocol/ProtocolRecognizer.cpp') diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index af5a8a416..6e6cb3caf 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -1015,11 +1015,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) AString Reply; cServer * Server = cRoot::Get()->GetServer(); - AString Motd = Server->GetDescription(); + AString ServerDescription = Server->GetDescription(); int NumPlayers = Server->GetNumPlayers(); int MaxPlayers = Server->GetMaxPlayers(); AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, Motd, NumPlayers, MaxPlayers, Favicon); + cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); switch (cRoot::Get()->GetPrimaryServerVersion()) { @@ -1028,7 +1028,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) { // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29 Printf(Reply, "%s%s%i%s%i", - Motd.c_str(), + ServerDescription.c_str(), cChatColor::Delimiter, NumPlayers, cChatColor::Delimiter, @@ -1072,7 +1072,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) Reply.push_back(0); Reply.append(ProtocolVersionTxt); Reply.push_back(0); - Reply.append(Motd); + Reply.append(ServerDescription); Reply.push_back(0); Reply.append(Printf("%d", NumPlayers)); Reply.push_back(0); -- cgit v1.2.3