void Status::getInfo(NetworkMessage &nm)
{
// the client selects which information may be
// sent back, so we'll save some bandwidth and
// make many
bool bserverinfo0 = nm.GetByte() == 1;
bool bserverinfo1 = nm.GetByte() == 1;
bool bserverinfo2 = nm.GetByte() == 1;
bool bplayersinfo = nm.GetByte() == 1;
bool bmapinfo = nm.GetByte() == 1;
nm.Reset();
uint64_t running = (OTSYS_TIME() - this->start) / 1000;
// since we haven't all the things on the right place like map's
// creator/info and other things, i'll put the info chunked into
// operators, so the httpd server will only receive the existing
// properties of the server, such serverinfo, playersinfo and so
if(bserverinfo0){
nm.AddByte(0x10); // server info
nm.AddString(g_config.SERVER_NAME.c_str());
nm.AddString(g_config.IP.c_str());
std::stringstream ss;
ss << g_config.PORT;
nm.AddString(ss.str().c_str());
}
if(bserverinfo1){
nm.AddByte(0x11); // server info - owner info
nm.AddString(g_config.OWNER_NAME.c_str());
nm.AddString(g_config.OWNER_MAIL.c_str());
}
if(bserverinfo2){
nm.AddByte(0x12); // server info - misc
nm.AddString(g_config.MOTD.c_str());
nm.AddString(g_config.LOCATION.c_str());
nm.AddString(g_config.URL.c_str());
nm.AddU32((uint32_t)(running >> 32)); // this method prevents a big number parsing
nm.AddU32((uint32_t)(running)); // since servers can be online for months ;)
nm.AddString(YUR_VERSION);
}
if(bplayersinfo){
nm.AddByte(0x20); // players info
nm.AddU32(this->playersonline);
nm.AddU32(this->playersmax);
nm.AddU32(this->playerspeak);
}
if(bmapinfo){
nm.AddByte(0x30); // map info
nm.AddString(this->mapname.c_str());
nm.AddString(this->mapauthor.c_str());
int mw, mh;
g_game.getMapDimensions(mw, mh);
nm.AddU16(mw);
nm.AddU16(mh);
}
return;
// just one thing, I'm good with monospaced text, right?
// if you haven't undertood the joke, look at the top ^^
}