Shutdown callback: don't save advtrains save files when MT crashed within advtrains's main step
parent
30f4e342fd
commit
c623a33860
|
@ -569,11 +569,13 @@ advtrains.mainloop_runcnt=0
|
||||||
advtrains.global_slowdown = 1
|
advtrains.global_slowdown = 1
|
||||||
|
|
||||||
local t = 0
|
local t = 0
|
||||||
|
local within_mainstep = false
|
||||||
minetest.register_globalstep(function(dtime_mt)
|
minetest.register_globalstep(function(dtime_mt)
|
||||||
if no_action then
|
if no_action then
|
||||||
-- the advtrains globalstep is skipped by command. Return immediately
|
-- the advtrains globalstep is skipped by command. Return immediately
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
within_mainstep = true
|
||||||
|
|
||||||
advtrains.mainloop_runcnt=advtrains.mainloop_runcnt+1
|
advtrains.mainloop_runcnt=advtrains.mainloop_runcnt+1
|
||||||
--atprint("Running the main loop, runcnt",advtrains.mainloop_runcnt)
|
--atprint("Running the main loop, runcnt",advtrains.mainloop_runcnt)
|
||||||
|
@ -586,6 +588,7 @@ minetest.register_globalstep(function(dtime_mt)
|
||||||
if GENERATE_ATRICIFIAL_LAG then
|
if GENERATE_ATRICIFIAL_LAG then
|
||||||
dtime = HOW_MANY_LAG
|
dtime = HOW_MANY_LAG
|
||||||
if os.clock()<t then
|
if os.clock()<t then
|
||||||
|
within_mainstep = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -616,7 +619,7 @@ minetest.register_globalstep(function(dtime_mt)
|
||||||
if advtrains.lines then
|
if advtrains.lines then
|
||||||
advtrains.lines.step(dtime)
|
advtrains.lines.step(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
--trigger a save when necessary
|
--trigger a save when necessary
|
||||||
save_timer=save_timer-dtime
|
save_timer=save_timer-dtime
|
||||||
if save_timer<=0 then
|
if save_timer<=0 then
|
||||||
|
@ -626,6 +629,9 @@ minetest.register_globalstep(function(dtime_mt)
|
||||||
save_timer = advtrains.SAVE_INTERVAL
|
save_timer = advtrains.SAVE_INTERVAL
|
||||||
atprintbm("saving", t)
|
atprintbm("saving", t)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
within_mainstep = false
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--if something goes wrong in these functions, there is no help. no pcall here.
|
--if something goes wrong in these functions, there is no help. no pcall here.
|
||||||
|
@ -678,7 +684,13 @@ function advtrains.save(remove_players_from_wagons)
|
||||||
--TODO very simple yet hacky workaround for the "green signals" bug
|
--TODO very simple yet hacky workaround for the "green signals" bug
|
||||||
advtrains.invalidate_all_paths()
|
advtrains.invalidate_all_paths()
|
||||||
end
|
end
|
||||||
minetest.register_on_shutdown(advtrains.save)
|
minetest.register_on_shutdown(function()
|
||||||
|
if within_mainstep then
|
||||||
|
atwarn("Crash during advtrains main step - skipping the shutdown save operation to not save inconsistent data!")
|
||||||
|
else
|
||||||
|
advtrains.save()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- This chat command provides a solution to the problem known on the LinuxWorks server
|
-- This chat command provides a solution to the problem known on the LinuxWorks server
|
||||||
-- There are many players that joined a single time, got on a train and then left forever
|
-- There are many players that joined a single time, got on a train and then left forever
|
||||||
|
|
Loading…
Reference in New Issue