forked from Mirrorlandia_minetest/minetest
Use safe_file_write to save forceloaded blocks
This commit is contained in:
parent
f30dcdb504
commit
1bc753f655
@ -86,12 +86,6 @@ local function read_file(filename)
|
|||||||
return core.deserialize(t) or {}
|
return core.deserialize(t) or {}
|
||||||
end
|
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")
|
blocks_forceloaded = read_file(wpath.."/force_loaded.txt")
|
||||||
for _, __ in pairs(blocks_forceloaded) do
|
for _, __ in pairs(blocks_forceloaded) do
|
||||||
total_forceloaded = total_forceloaded + 1
|
total_forceloaded = total_forceloaded + 1
|
||||||
@ -106,7 +100,8 @@ end)
|
|||||||
|
|
||||||
-- persists the currently forceloaded blocks to disk
|
-- persists the currently forceloaded blocks to disk
|
||||||
local function persist_forceloaded_blocks()
|
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
|
end
|
||||||
|
|
||||||
-- periodical forceload persistence
|
-- periodical forceload persistence
|
||||||
|
Loading…
Reference in New Issue
Block a user