Optionally hide player names on the serverlist (#14820)

This commit adds a setting to anonymize player names when sending data to the server list.
This commit is contained in:
1F616EMO~nya 2024-08-12 02:19:53 +08:00 committed by GitHub
parent cfa9c83d33
commit f04cdc00a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

@ -825,6 +825,9 @@ server_url (Server URL) string https://minetest.net
# Automatically report to the serverlist. # Automatically report to the serverlist.
server_announce (Announce server) bool false server_announce (Announce server) bool false
# Send names of online players to the serverlist. If disabled only the player count is revealed.
server_announce_send_players (Send player names to the server list) bool true
# Announce to this serverlist. # Announce to this serverlist.
serverlist_url (Serverlist URL) string servers.minetest.net serverlist_url (Serverlist URL) string servers.minetest.net

@ -535,6 +535,7 @@ void set_default_settings()
settings->setDefault("server_address", ""); settings->setDefault("server_address", "");
settings->setDefault("server_name", ""); settings->setDefault("server_name", "");
settings->setDefault("server_description", ""); settings->setDefault("server_description", "");
settings->setDefault("server_announce_send_players", "true");
settings->setDefault("enable_console", "false"); settings->setDefault("enable_console", "false");
settings->setDefault("display_density_factor", "1"); settings->setDefault("display_density_factor", "1");

@ -65,9 +65,10 @@ void sendAnnounce(AnnounceAction action,
server["game_time"] = game_time; server["game_time"] = game_time;
server["clients"] = (int) clients_names.size(); server["clients"] = (int) clients_names.size();
server["clients_max"] = g_settings->getU16("max_users"); server["clients_max"] = g_settings->getU16("max_users");
server["clients_list"] = Json::Value(Json::arrayValue); if (g_settings->getBool("server_announce_send_players")) {
for (const std::string &clients_name : clients_names) { server["clients_list"] = Json::Value(Json::arrayValue);
server["clients_list"].append(clients_name); for (const std::string &clients_name : clients_names)
server["clients_list"].append(clients_name);
} }
if (!gameid.empty()) if (!gameid.empty())
server["gameid"] = gameid; server["gameid"] = gameid;