aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-03-02 09:02:29 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-03-02 09:02:29 +0100
commit142a749edbef2027bbe2baa1c11e1a037f0b1f7c (patch)
tree858c6480d127e6086e019b2099702b74625ab75f
parent39166c4b4c1972be5e4875e130ae9d25a6f95008 (diff)
downloadminetest-142a749edbef2027bbe2baa1c11e1a037f0b1f7c.tar.xz
Add setting to re-enable sending all item metadata fields to clients
-rw-r--r--builtin/settingtypes.txt7
-rw-r--r--minetest.conf.example7
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/server.cpp6
4 files changed, 18 insertions, 3 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index f800f71ab..bb6f648af 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -1062,6 +1062,13 @@ max_packets_per_iteration (Max. packets per iteration) int 1024
# (levels 1-3 use Zlib's "fast" method, 4-9 use the normal method)
map_compression_level_net (Map Compression Level for Network Transfer) int -1 -1 9
+# When this is enbled, all item metadata will be sent to all clients. This
+# might be useful to allow for local map saving, but it also increases
+# lag, and malicious players could abuse it to crash the server or prevent
+# other players from logging in by making the server crash automatically
+# when they log in.
+send_all_item_metadata (Send all Item metadata to clients) bool false
+
[*Game]
# Default game when creating a new world.
diff --git a/minetest.conf.example b/minetest.conf.example
index 47c03ff80..56a744581 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -1269,6 +1269,13 @@
# type: int min: -1 max: 9
# map_compression_level_net = -1
+# When this is enbled, all item metadata will be sent to all clients. This
+# might be useful to allow for local map saving, but it also increases
+# lag, and malicious players could abuse it to crash the server or prevent
+# other players from logging in by making the server crash automatically
+# when they log in.
+# send_all_item_metadata = false
+
## Game
# Default game when creating a new world.
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index cda953082..b1001e0ff 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -391,6 +391,7 @@ void set_default_settings()
settings->setDefault("sqlite_synchronous", "2");
settings->setDefault("map_compression_level_disk", "3");
settings->setDefault("map_compression_level_net", "-1");
+ settings->setDefault("send_all_item_metadata", "false");
settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
settings->setDefault("dedicated_server_step", "0.09");
settings->setDefault("active_block_mgmt_interval", "2.0");
diff --git a/src/server.cpp b/src/server.cpp
index 8f0bfb4e9..13aad1dbf 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1471,7 +1471,7 @@ void Server::SendInventory(PlayerSAO *sao, bool incremental)
NetworkPacket pkt(TOCLIENT_INVENTORY, 0, sao->getPeerID());
std::ostringstream os(std::ios::binary);
- sao->getInventory()->serialize(os, incremental, false);
+ sao->getInventory()->serialize(os, incremental, g_settings->getBool("send_all_item_metadata"));
sao->getInventory()->setModified(false);
player->setModified(true);
@@ -2335,7 +2335,7 @@ void Server::SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver,
*/
thread_local const int net_compression_level = rangelim(g_settings->getS16("map_compression_level_net"), -1, 9);
std::ostringstream os(std::ios_base::binary);
- block->serialize(os, ver, false, net_compression_level, false);
+ block->serialize(os, ver, false, net_compression_level, g_settings->getBool("send_all_item_metadata"));
block->serializeNetworkSpecific(os);
std::string s = os.str();
@@ -2692,7 +2692,7 @@ void Server::sendDetachedInventory(Inventory *inventory, const std::string &name
// Serialization & NetworkPacket isn't a love story
std::ostringstream os(std::ios_base::binary);
- inventory->serialize(os, false, false);
+ inventory->serialize(os, false, g_settings->getBool("send_all_item_metadata"));
inventory->setModified(false);
const std::string &os_str = os.str();