Implement favicon for 1.7.2
Favicon data is a png encoded in base64 which is stored in the server and sent in the server response packet
This commit is contained in:
parent
db978fc687
commit
913841f501
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -107,6 +107,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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user