diff options
-rw-r--r-- | src/Protocol/Protocol17x.cpp | 13 | ||||
-rw-r--r-- | src/Protocol/Protocol17x.h | 1 | ||||
-rw-r--r-- | src/Server.cpp | 11 | ||||
-rw-r--r-- | src/Server.h | 3 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index bbbd5e973..c75fc9878 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -383,6 +383,16 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc +void cProtocol172::SendFavicon(void) +{ + cPacketizer Pkt(*this, 0x0); // Favicon packet + Pkt.WriteString(cRoot::Get()->GetServer()->GetFaviconData()); +} + + + + + void cProtocol172::SendGameMode(eGameMode a_GameMode) { cPacketizer Pkt(*this, 0x2b); // Change Game State packet @@ -1116,6 +1126,9 @@ void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) AppendPrintf(Response, "\"description\":{\"text\":\"%s\"}", cRoot::Get()->GetServer()->GetDescription().c_str() ); + AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + cRoot::Get()->GetServer()->GetFaviconData() + ); Response.append("}"); cPacketizer Pkt(*this, 0x00); // Response packet diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 23ff2365d..29fc75ee4 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -72,6 +72,7 @@ public: virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override; virtual void SendEntityVelocity (const cEntity & a_Entity) override; virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override; + virtual void SendFavicon (void); virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override; diff --git a/src/Server.cpp b/src/Server.cpp index 7dedc3904..e5050f321 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -203,6 +203,8 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_PlayerCount = 0; m_PlayerCountDiff = 0; + if (cFile::Exists("favicon.png")) m_Favicon = Base64Encode(cFile::ReadWholeFile("favicon.png")); + if (m_bIsConnected) { LOGERROR("ERROR: Trying to initialize server while server is already running!"); @@ -289,6 +291,15 @@ int cServer::GetNumPlayers(void) +AString cServer::GetFaviconData(void) +{ + return m_Favicon; +} + + + + + void cServer::PrepareKeys(void) { // TODO: Save and load key for persistence across sessions diff --git a/src/Server.h b/src/Server.h index e62c4c7b7..e33264277 100644 --- a/src/Server.h +++ b/src/Server.h @@ -106,6 +106,8 @@ public: // tolua_export /// Notifies the server that a player is being destroyed; the server uses this to adjust the number of players void PlayerDestroying(const cPlayer * a_Player); + + AString GetFaviconData(void); CryptoPP::RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; } CryptoPP::RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; } @@ -183,6 +185,7 @@ private: cRCONServer m_RCONServer; AString m_Description; + AString m_Favicon; int m_MaxPlayers; bool m_bIsHardcore; |