diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server.cpp | 7 | ||||
-rw-r--r-- | src/server.h | 2 | ||||
-rw-r--r-- | src/serverlist.cpp | 19 | ||||
-rw-r--r-- | src/serverlist.h | 4 |
4 files changed, 19 insertions, 13 deletions
diff --git a/src/server.cpp b/src/server.cpp index c144be1ba..8350b7013 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -673,7 +673,6 @@ Server::Server( m_objectdata_timer = 0.0; m_emergethread_trigger_timer = 0.0; m_savemap_timer = 0.0; - m_clients_number = 0; m_env_mutex.Init(); m_con_mutex.Init(); @@ -1244,7 +1243,7 @@ void Server::AsyncRunStep() counter = 0.0; JMutexAutoLock lock2(m_con_mutex); - m_clients_number = 0; + m_clients_names.clear(); if(m_clients.size() != 0) infostream<<"Players:"<<std::endl; for(std::map<u16, RemoteClient*>::iterator @@ -1258,7 +1257,7 @@ void Server::AsyncRunStep() continue; infostream<<"* "<<player->getName()<<"\t"; client->PrintInfo(infostream); - ++m_clients_number; + m_clients_names.push_back(player->getName()); } } } @@ -1270,7 +1269,7 @@ void Server::AsyncRunStep() float &counter = m_masterserver_timer; if(!isSingleplayer() && (!counter || counter >= 300.0) && g_settings->getBool("server_announce") == true) { - ServerList::sendAnnounce(!counter ? "start" : "update", m_clients_number, m_uptime.get(), m_gamespec.id, m_mods); + ServerList::sendAnnounce(!counter ? "start" : "update", m_clients_names, m_uptime.get(), m_env->getGameTime(), m_gamespec.id, m_mods); counter = 0.01; } counter += dtime; diff --git a/src/server.h b/src/server.h index bc7829f74..b52ae02dc 100644 --- a/src/server.h +++ b/src/server.h @@ -685,7 +685,7 @@ private: JMutex m_con_mutex; // Connected clients (behind the con mutex) std::map<u16, RemoteClient*> m_clients; - u16 m_clients_number; //for announcing masterserver + std::vector<std::string> m_clients_names; //for announcing masterserver // Ban checking BanManager *m_banmanager; diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 908f048cb..fb5bc9c87 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -194,11 +194,11 @@ static size_t ServerAnnounceCallback(void *contents, size_t size, size_t nmemb, //((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; } -void sendAnnounce(std::string action, u16 clients, double uptime, std::string gameid, std::vector<ModSpec> m_mods) { +void sendAnnounce(std::string action, const std::vector<std::string> & clients_names, double uptime, u32 game_time, std::string gameid, std::vector<ModSpec> mods) { Json::Value server; if (action.size()) server["action"] = action; - server["port"] = g_settings->get("port"); + server["port"] = g_settings->get("port"); server["address"] = g_settings->get("server_address"); if (action != "delete") { server["name"] = g_settings->get("server_name"); @@ -209,10 +209,15 @@ void sendAnnounce(std::string action, u16 clients, double uptime, std::string ga server["damage"] = g_settings->get("enable_damage"); server["password"] = g_settings->getBool("disallow_empty_password"); server["pvp"] = g_settings->getBool("enable_pvp"); - server["clients"] = clients; + server["clients"] = (int)clients_names.size(); server["clients_max"] = g_settings->get("max_users"); - if (uptime >=1) server["uptime"] = (int)uptime; - if (gameid!="") server["gameid"] = gameid; + server["clients_list"] = Json::Value(Json::arrayValue); + for(u32 i = 0; i < clients_names.size(); ++i) { + server["clients_list"].append(clients_names[i]); + } + if (uptime >= 1) server["uptime"] = (int)uptime; + if (gameid != "") server["gameid"] = gameid; + if (game_time >= 1) server["game_time"] = game_time; } if(server["action"] == "start") { @@ -220,8 +225,8 @@ void sendAnnounce(std::string action, u16 clients, double uptime, std::string ga server["rollback"] = g_settings->getBool("enable_rollback_recording"); server["liquid_finite"] = g_settings->getBool("liquid_finite"); server["mapgen"] = g_settings->get("mg_name"); - server["mods"] = Json::Value(Json::arrayValue); - for(std::vector<ModSpec>::iterator m = m_mods.begin(); m != m_mods.end(); m++) { + server["mods"] = Json::Value(Json::arrayValue); + for(std::vector<ModSpec>::iterator m = mods.begin(); m != mods.end(); m++) { server["mods"].append(m->name); } actionstream << "announcing to " << g_settings->get("serverlist_url") << std::endl; diff --git a/src/serverlist.h b/src/serverlist.h index 365e86beb..77eb29b14 100644 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -40,7 +40,9 @@ namespace ServerList std::vector<ServerListSpec> deSerializeJson(std::string liststring); std::string serializeJson(std::vector<ServerListSpec>); #if USE_CURL - void sendAnnounce(std::string action = "", u16 clients = 0, double uptime = 0, std::string gameid = "", std::vector<ModSpec> m_mods = std::vector<ModSpec>()); + void sendAnnounce(std::string action = "", const std::vector<std::string> & clients_names = std::vector<std::string>(), + double uptime = 0, u32 game_time = 0,std::string gameid = "", + std::vector<ModSpec> mods = std::vector<ModSpec>()); #endif } //ServerList namespace |