diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-02-04 15:11:02 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-02-04 15:11:02 -0500 |
commit | a8e5b90aebc0fae02c8ccd88fe3399d5e48d4b6f (patch) | |
tree | 6220fbe1375a1063308ea757f8cf602a28e41074 | |
parent | 72d26dad251148629e5e5221bec04cd17c090425 (diff) |
Don't overwrite area file if serialization fails
-rw-r--r-- | internal.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/internal.lua b/internal.lua index 338187a..deba856 100644 --- a/internal.lua +++ b/internal.lua @@ -5,11 +5,16 @@ end -- Save the areas table to a file function areas:save() + local datastr = minetest.serialize(self.areas) + if not datastr then + minetest.log("error", "[areas] Failed to serialize area data!") + return + end local file, err = io.open(self.filename, "w") if err then return err end - file:write(minetest.serialize(self.areas)) + file:write(datastr) file:close() end |