aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-12-03 10:41:34 -0500
committerGitHub <noreply@github.com>2022-12-03 10:41:34 -0500
commitf80ea73bfb668b1999bcc134aaa7fc126724e6d6 (patch)
tree956a750a4bf25285805fe9a8dcf19526e644f96c /builtin
parentb3ffc4b327622bec63793476191b95bc174bf33c (diff)
downloadminetest-f80ea73bfb668b1999bcc134aaa7fc126724e6d6.tar.xz
Let mods choose a forceload limit (#13002)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/forceloading.lua5
-rw-r--r--builtin/settingtypes.txt5
2 files changed, 6 insertions, 4 deletions
diff --git a/builtin/game/forceloading.lua b/builtin/game/forceloading.lua
index 8043e5dea..52049af16 100644
--- a/builtin/game/forceloading.lua
+++ b/builtin/game/forceloading.lua
@@ -33,7 +33,7 @@ local function get_relevant_tables(transient)
end
end
-function core.forceload_block(pos, transient)
+function core.forceload_block(pos, transient, limit)
-- set changed flag
forceload_blocks_changed = true
@@ -46,7 +46,8 @@ function core.forceload_block(pos, transient)
elseif other_table[hash] ~= nil then
relevant_table[hash] = 1
else
- if total_forceloaded >= (tonumber(core.settings:get("max_forceloaded_blocks")) or 16) then
+ limit = limit or tonumber(core.settings:get("max_forceloaded_blocks")) or 16
+ if limit >= 0 and total_forceloaded >= limit then
return false
end
total_forceloaded = total_forceloaded+1
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 845564264..8a8425ca0 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -1875,8 +1875,9 @@ active_block_range (Active block range) int 4 1 65535
# From how far blocks are sent to clients, stated in mapblocks (16 nodes).
max_block_send_distance (Max block send distance) int 12 1 65535
-# Maximum number of forceloaded mapblocks.
-max_forceloaded_blocks (Maximum forceloaded blocks) int 16 0
+# Default maximum number of forceloaded mapblocks.
+# Set this to -1 to disable the limit.
+max_forceloaded_blocks (Maximum forceloaded blocks) int 16 -1
# Interval of sending time of day to clients, stated in seconds.
time_send_interval (Time send interval) float 5.0 0.001