From f04cdc00a69e96d7e6253a70c8ff8e0862856acf Mon Sep 17 00:00:00 2001 From: 1F616EMO~nya Date: Mon, 12 Aug 2024 02:19:53 +0800 Subject: [PATCH] Optionally hide player names on the serverlist (#14820) This commit adds a setting to anonymize player names when sending data to the server list. --- builtin/settingtypes.txt | 3 +++ src/defaultsettings.cpp | 1 + src/server/serverlist.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 87c7444da..eb7eda0d7 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -825,6 +825,9 @@ server_url (Server URL) string https://minetest.net # Automatically report to the serverlist. 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. serverlist_url (Serverlist URL) string servers.minetest.net diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 9c2ade975..5fce1b0a8 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -535,6 +535,7 @@ void set_default_settings() settings->setDefault("server_address", ""); settings->setDefault("server_name", ""); settings->setDefault("server_description", ""); + settings->setDefault("server_announce_send_players", "true"); settings->setDefault("enable_console", "false"); settings->setDefault("display_density_factor", "1"); diff --git a/src/server/serverlist.cpp b/src/server/serverlist.cpp index e702ba73d..0586a1979 100644 --- a/src/server/serverlist.cpp +++ b/src/server/serverlist.cpp @@ -65,9 +65,10 @@ void sendAnnounce(AnnounceAction action, 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 (const std::string &clients_name : clients_names) { - server["clients_list"].append(clients_name); + if (g_settings->getBool("server_announce_send_players")) { + server["clients_list"] = Json::Value(Json::arrayValue); + for (const std::string &clients_name : clients_names) + server["clients_list"].append(clients_name); } if (!gameid.empty()) server["gameid"] = gameid;