From a8e5b90aebc0fae02c8ccd88fe3399d5e48d4b6f Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 4 Feb 2014 15:11:02 -0500 Subject: [PATCH] Don't overwrite area file if serialization fails --- internal.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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