Some more serializer fixes (backported from new_lzb):
- Move DUMP_DEBUG_SAVE block before the actual saving so it can be used to trace serializer errors - Don't crash on functions in data, ignore them silently - Increase the save interval
This commit is contained in:
parent
9d12c72499
commit
0ba5874b4f
@ -537,6 +537,15 @@ advtrains.avt_save = function(remove_players_from_wagons)
|
|||||||
["ndb4.ls"] = advtrains.ndb.save_callback
|
["ndb4.ls"] = advtrains.ndb.save_callback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if DUMP_DEBUG_SAVE then
|
||||||
|
local file, err = io.open(advtrains.fpath.."_DUMP", "w")
|
||||||
|
if err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
file:write(dump(parts_table))
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
--THE MAGIC HAPPENS HERE
|
--THE MAGIC HAPPENS HERE
|
||||||
local succ, err = serialize_lib.save_atomic_multiple(parts_table, advtrains.fpath.."_", callbacks_table)
|
local succ, err = serialize_lib.save_atomic_multiple(parts_table, advtrains.fpath.."_", callbacks_table)
|
||||||
|
|
||||||
@ -546,21 +555,12 @@ advtrains.avt_save = function(remove_players_from_wagons)
|
|||||||
-- store version
|
-- store version
|
||||||
advtrains.save_component(4, "version")
|
advtrains.save_component(4, "version")
|
||||||
end
|
end
|
||||||
|
|
||||||
if DUMP_DEBUG_SAVE then
|
|
||||||
local file, err = io.open(advtrains.fpath.."_DUMP", "w")
|
|
||||||
if err then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
file:write(dump(parts_table))
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--## MAIN LOOP ##--
|
--## MAIN LOOP ##--
|
||||||
--Calls all subsequent main tasks of both advtrains and atlatc
|
--Calls all subsequent main tasks of both advtrains and atlatc
|
||||||
local init_load=false
|
local init_load=false
|
||||||
local save_interval=20
|
local save_interval=60
|
||||||
local save_timer=save_interval
|
local save_timer=save_interval
|
||||||
advtrains.mainloop_runcnt=0
|
advtrains.mainloop_runcnt=0
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ function value_to_string(t)
|
|||||||
elseif type(t)=="string" then
|
elseif type(t)=="string" then
|
||||||
return "S"..escape_chars(t)
|
return "S"..escape_chars(t)
|
||||||
else
|
else
|
||||||
file:close()
|
--error("Can not serialize '"..type(t).."' type!")
|
||||||
error("Can not serialize '"..type(t).."' type!")
|
return "S<function>"
|
||||||
end
|
end
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user