Open the 2 files required in the current save format

This commit is contained in:
Montandalar 2020-03-04 20:55:25 +11:00
parent a986d0478d
commit 49a47330b3

View File

@ -128,20 +128,21 @@ end
datapath, mappath, no_trains, worldimage = parse_args(arg)
-- Load saves
local file, err = io.open(datapath.."advtrains", "r")
local file, err = io.open(datapath.."advtrains_trains", "r")
local tbl = minetest.deserialize(file:read("*a"))
if type(tbl) ~= "table" then
error("not a table")
end
if tbl.version then
advtrains.trains = tbl.trains
if not mappath then
advtrains.ndb.load_data(tbl.ndb)
error("Trains file: not a table")
end
advtrains.trains = tbl
file:close()
else
error("Incompatible save format!")
--ndb contains the defs, while ndb2 is the actual contents
file, err = io.open(datapath.."advtrains_ndb", "r")
tbl = minetest.deserialize(file:read("*a"))
if type(tbl) ~= "table" then
error("Node database file: not a table")
end
advtrains.ndb.load_data(tbl)
file:close()
-- open svg file