Fixed favicons
This commit is contained in:
parent
a87daa969e
commit
1d96a615b5
@ -1112,7 +1112,7 @@ void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
|||||||
cRoot::Get()->GetServer()->GetMaxPlayers(),
|
cRoot::Get()->GetServer()->GetMaxPlayers(),
|
||||||
cRoot::Get()->GetServer()->GetNumPlayers()
|
cRoot::Get()->GetServer()->GetNumPlayers()
|
||||||
);
|
);
|
||||||
AppendPrintf(Response, "\"description\":{\"text\":\"%s\"}",
|
AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},",
|
||||||
cRoot::Get()->GetServer()->GetDescription().c_str()
|
cRoot::Get()->GetServer()->GetDescription().c_str()
|
||||||
);
|
);
|
||||||
AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"",
|
AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"",
|
||||||
|
@ -203,10 +203,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
|
|||||||
m_PlayerCount = 0;
|
m_PlayerCount = 0;
|
||||||
m_PlayerCountDiff = 0;
|
m_PlayerCountDiff = 0;
|
||||||
|
|
||||||
if (cFile::Exists("favicon.png"))
|
m_FaviconData = Base64Encode(cFile::ReadWholeFile("favicon.png")); // Will return empty string if file nonexistant; client doesn't mind
|
||||||
{
|
|
||||||
m_FaviconData = Base64Encode(cFile::ReadWholeFile("favicon.png"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_bIsConnected)
|
if (m_bIsConnected)
|
||||||
{
|
{
|
||||||
@ -294,15 +291,6 @@ int cServer::GetNumPlayers(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const AString & cServer::GetFaviconData(void) const
|
|
||||||
{
|
|
||||||
return m_FaviconData;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cServer::PrepareKeys(void)
|
void cServer::PrepareKeys(void)
|
||||||
{
|
{
|
||||||
// TODO: Save and load key for persistence across sessions
|
// TODO: Save and load key for persistence across sessions
|
||||||
|
@ -107,7 +107,8 @@ public: // tolua_export
|
|||||||
/// Notifies the server that a player is being destroyed; the server uses this to adjust the number of players
|
/// 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);
|
void PlayerDestroying(const cPlayer * a_Player);
|
||||||
|
|
||||||
const AString & GetFaviconData(void) const;
|
/* Returns base64 encoded favicon data (obtained from favicon.png) */
|
||||||
|
const AString & GetFaviconData(void) const { return m_FaviconData; }
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
|
CryptoPP::RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
|
||||||
CryptoPP::RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; }
|
CryptoPP::RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; }
|
||||||
|
@ -759,7 +759,8 @@ AString Base64Decode(const AString & a_Base64String)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.resize(o >> 3);
|
res.resize(o >> 3);
|
||||||
return res;}
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -774,7 +775,7 @@ AString Base64Encode(const AString & a_Input)
|
|||||||
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
|
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string output;
|
AString output;
|
||||||
output.resize(((a_Input.size() + 2) / 3) * 4);
|
output.resize(((a_Input.size() + 2) / 3) * 4);
|
||||||
|
|
||||||
size_t output_index = 0;
|
size_t output_index = 0;
|
||||||
@ -804,7 +805,7 @@ AString Base64Encode(const AString & a_Input)
|
|||||||
|
|
||||||
output[output_index++] = '=';
|
output[output_index++] = '=';
|
||||||
}
|
}
|
||||||
assert(output_index == output.size());
|
ASSERT(output_index == output.size());
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user