aboutsummaryrefslogtreecommitdiff
path: root/advtrains/init.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2020-12-21 22:26:43 +0100
committerorwell96 <orwell@bleipb.de>2021-01-12 13:27:00 +0100
commitce4631dbeebe3911cd5241ade9f750063c2cc9cb (patch)
treeae86e4d5c9c73ea4cadcde43933a2e5cb9713dc5 /advtrains/init.lua
parente42fbf9dcc2697ebda1a8fdd9cbedecbee92a6bb (diff)
downloadadvtrains-ce4631dbeebe3911cd5241ade9f750063c2cc9cb.tar.gz
advtrains-ce4631dbeebe3911cd5241ade9f750063c2cc9cb.tar.bz2
advtrains-ce4631dbeebe3911cd5241ade9f750063c2cc9cb.zip
Backport ndb format from cellworld to also store the cids in the ndb file; integrate ndb in serialize_lib atomic system
Diffstat (limited to 'advtrains/init.lua')
-rw-r--r--advtrains/init.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index cccb2da..3c3e47b 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -307,7 +307,7 @@ function advtrains.avt_load()
end
advtrains.wagons = tbl.wagon_save
advtrains.player_to_train_mapping = tbl.ptmap or {}
- advtrains.ndb.load_data(tbl.ndb)
+ advtrains.ndb.load_data_pre_v4(tbl.ndb)
advtrains.atc.load_data(tbl.atc)
if advtrains.interlocking then
advtrains.interlocking.db.load(tbl.interlocking)
@@ -382,7 +382,6 @@ function advtrains.load_version_4()
end
advtrains.wagons = at_save.wagons
advtrains.player_to_train_mapping = at_save.ptmap or {}
- advtrains.ndb.load_data(at_save.ndb)
advtrains.atc.load_data(at_save.atc)
--remove wagon_save entries that are not part of a train
@@ -398,6 +397,9 @@ function advtrains.load_version_4()
advtrains.wagon_save[wid]=nil
end
end
+ --== load ndb
+ serialize_lib.load_atomic(advtrains.fpath.."_ndb4.ls", advtrains.ndb.load_callback)
+
--== load interlocking ==
if advtrains.interlocking then
local il_save = serialize_lib.load_atomic(advtrains.fpath.."_interlocking.ls")
@@ -498,7 +500,6 @@ advtrains.avt_save = function(remove_players_from_wagons)
wagons = advtrains.wagons,
ptmap = advtrains.player_to_train_mapping,
atc = advtrains.atc.save_data(),
- ndb = advtrains.ndb.save_data(),-- side effect: this saves advtrains_ndb file
}
--save of interlocking
@@ -530,10 +531,14 @@ advtrains.avt_save = function(remove_players_from_wagons)
["interlocking.ls"] = il_save,
["lines.ls"] = ln_save,
["atlatc.ls"] = la_save,
+ ["ndb4.ls"] = true, -- data not used
+ }
+ local callbacks_table = {
+ ["ndb4.ls"] = advtrains.ndb.save_callback
}
--THE MAGIC HAPPENS HERE
- local succ, err = serialize_lib.save_atomic_multiple(parts_table, advtrains.fpath.."_")
+ local succ, err = serialize_lib.save_atomic_multiple(parts_table, advtrains.fpath.."_", callbacks_table)
if not succ then
atwarn("Saving failed: "..err)