From f35e2f1808f784698f80b3181912414820058fba Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Sat, 18 Jan 2025 02:47:43 -0800 Subject: [PATCH] Add nil check after reading world data file Closes: https://github.com/AntumMT/mod-cleaner/issues/3 --- changelog.txt | 1 + misc_functions.lua | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 14adc71..7b7aedd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ v1.2.1 ---- - use sounds mod for sounds +- added nil check after reading world data file v1.2 diff --git a/misc_functions.lua b/misc_functions.lua index 67460b1..27c8654 100644 --- a/misc_functions.lua +++ b/misc_functions.lua @@ -28,8 +28,13 @@ local function get_world_data() local wdata = {} local buffer = io.open(world_file, "r") if buffer then - wdata = core.parse_json(buffer:read("*a")) + local err + wdata, err = core.parse_json(buffer:read("*a"), nil, true) buffer:close() + if wdata == nil then + cleaner.log("warning", "reading world data file failed: " .. world_file) + wdata = {} + end end local rem_types = {"entities", "nodes", "ores",}