aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/helpers.lua1
-rw-r--r--advtrains/init.lua14
2 files changed, 14 insertions, 1 deletions
diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua
index 511d32e..3514f55 100644
--- a/advtrains/helpers.lua
+++ b/advtrains/helpers.lua
@@ -381,6 +381,7 @@ end
-- decodes a position encoded with encode_pos
function advtrains.decode_pos(pts)
+ if not pts or not #pts==6 then return nil end
local stry = string.sub(pts, 1,4)
local strx = string.sub(pts, 5,8)
local strz = string.sub(pts, 9,12)
diff --git a/advtrains/init.lua b/advtrains/init.lua
index 21b414e..8173a22 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -196,7 +196,7 @@ dofile(advtrains.modpath.."/passive.lua")
--load/save
-- backup variables, used if someone should accidentally delete a sub-mod
-local MDS_interlocking
+local MDS_interlocking, MDS_lines
advtrains.fpath=minetest.get_worldpath().."/advtrains"
@@ -226,6 +226,11 @@ function advtrains.avt_load()
else
MDS_interlocking = tbl.interlocking
end
+ if advtrains.lines then
+ advtrains.lines.load(tbl.lines)
+ else
+ MDS_lines = tbl.lines
+ end
--remove wagon_save entries that are not part of a train
local todel=advtrains.merge_tables(advtrains.wagon_save)
for tid, train in pairs(advtrains.trains) do
@@ -327,6 +332,12 @@ advtrains.avt_save = function(remove_players_from_wagons)
else
il_save = MDS_interlocking
end
+ local ln_save
+ if advtrains.lines then
+ ln_save = advtrains.lines.save()
+ else
+ ln_save = MDS_lines
+ end
local save_tbl={
trains = tmp_trains,
wagon_save = advtrains.wagons,
@@ -334,6 +345,7 @@ advtrains.avt_save = function(remove_players_from_wagons)
atc = advtrains.atc.save_data(),
ndb = advtrains.ndb.save_data(),
interlocking = il_save,
+ lines = ln_save,
version = 2,
}
local datastr = minetest.serialize(save_tbl)