summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-05-30 11:15:02 +0200
committersfan5 <sfan5@live.de>2021-05-30 11:40:14 +0200
commit1bc753f655db4c7de030f2700361011e1c0278a5 (patch)
treee5cd1b8f8d12cdb316e1ccf2c5b0d4740051a902 /builtin
parentf30dcdb504adb02724e3a5faa30a951eb907b33f (diff)
downloadminetest-1bc753f655db4c7de030f2700361011e1c0278a5.tar.gz
minetest-1bc753f655db4c7de030f2700361011e1c0278a5.tar.bz2
minetest-1bc753f655db4c7de030f2700361011e1c0278a5.zip
Use safe_file_write to save forceloaded blocks
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/forceloading.lua9
1 files changed, 2 insertions, 7 deletions
diff --git a/builtin/game/forceloading.lua b/builtin/game/forceloading.lua
index e1e00920c..8043e5dea 100644
--- a/builtin/game/forceloading.lua
+++ b/builtin/game/forceloading.lua
@@ -86,12 +86,6 @@ local function read_file(filename)
return core.deserialize(t) or {}
end
-local function write_file(filename, table)
- local f = io.open(filename, "w")
- f:write(core.serialize(table))
- f:close()
-end
-
blocks_forceloaded = read_file(wpath.."/force_loaded.txt")
for _, __ in pairs(blocks_forceloaded) do
total_forceloaded = total_forceloaded + 1
@@ -106,7 +100,8 @@ end)
-- persists the currently forceloaded blocks to disk
local function persist_forceloaded_blocks()
- write_file(wpath.."/force_loaded.txt", blocks_forceloaded)
+ local data = core.serialize(blocks_forceloaded)
+ core.safe_file_write(wpath.."/force_loaded.txt", data)
end
-- periodical forceload persistence