- if(server["action"] == "start")
- actionstream << "announcing to " << g_settings->get("serverlist_url") << std::endl;
- Json::StyledWriter writer;
- CURL *curl;
- curl = curl_easy_init();
- if (curl)
- {
- CURLcode res;
- curl_easy_setopt(curl, CURLOPT_URL, (g_settings->get("serverlist_url")+std::string("/announce?json=")+curl_easy_escape(curl, writer.write( server ).c_str(), 0)).c_str());
- //curl_easy_setopt(curl, CURLOPT_USERAGENT, "minetest");
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ServerList::ServerAnnounceCallback);
- //curl_easy_setopt(curl, CURLOPT_WRITEDATA, &liststring);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1);
- curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1);
- res = curl_easy_perform(curl);
- //if (res != CURLE_OK)
- // errorstream<<"Serverlist at url "<<g_settings->get("serverlist_url")<<" not found (internet connection?)"<<std::endl;
- curl_easy_cleanup(curl);
+ if (action != "delete") {
+ bool strict_checking = g_settings->getBool("strict_protocol_version_checking");
+ server["name"] = g_settings->get("server_name");
+ server["description"] = g_settings->get("server_description");
+ server["version"] = g_version_string;
+ server["proto_min"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MIN;
+ server["proto_max"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MAX;
+ server["url"] = g_settings->get("server_url");
+ server["creative"] = g_settings->getBool("creative_mode");
+ server["damage"] = g_settings->getBool("enable_damage");
+ server["password"] = g_settings->getBool("disallow_empty_password");
+ server["pvp"] = g_settings->getBool("enable_pvp");
+ server["uptime"] = (int) uptime;
+ server["game_time"] = game_time;
+ server["clients"] = (int) clients_names.size();
+ server["clients_max"] = g_settings->getU16("max_users");
+ server["clients_list"] = Json::Value(Json::arrayValue);
+ for (std::vector<std::string>::const_iterator it = clients_names.begin();
+ it != clients_names.end();
+ ++it) {
+ server["clients_list"].append(*it);
+ }
+ if (gameid != "") server["gameid"] = gameid;
+ }
+
+ if (action == "start") {
+ server["dedicated"] = g_settings->getBool("server_dedicated");
+ server["rollback"] = g_settings->getBool("enable_rollback_recording");
+ server["mapgen"] = mg_name;
+ server["privs"] = g_settings->get("default_privs");
+ server["can_see_far_names"] = g_settings->getS16("player_transfer_distance") <= 0;
+ server["mods"] = Json::Value(Json::arrayValue);
+ for (std::vector<ModSpec>::const_iterator it = mods.begin();
+ it != mods.end();
+ ++it) {
+ server["mods"].append(it->name);
+ }
+ actionstream << "Announcing to " << g_settings->get("serverlist_url") << std::endl;
+ } else {
+ if (lag)
+ server["lag"] = lag;