aboutsummaryrefslogtreecommitdiff
path: root/advtrains/init.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2020-12-27 18:04:42 +0100
committerorwell96 <orwell@bleipb.de>2021-02-10 16:39:45 +0100
commit080b8fb27342827965bab2567dde14e57433b55e (patch)
treec66ee6fb80a191b09ca9ba4a658c2d5a0b3f533b /advtrains/init.lua
parent9a775eff5b7a49c322119feb4c8248791edab501 (diff)
downloadadvtrains-080b8fb27342827965bab2567dde14e57433b55e.tar.gz
advtrains-080b8fb27342827965bab2567dde14e57433b55e.tar.bz2
advtrains-080b8fb27342827965bab2567dde14e57433b55e.zip
Add IGNORE_WORLD mode to test using only the advtrains save data
Diffstat (limited to 'advtrains/init.lua')
-rw-r--r--advtrains/init.lua35
1 files changed, 30 insertions, 5 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index fd56d6d..d21a887 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -26,17 +26,33 @@ minetest.log("action", "[advtrains] Loading...")
attrans = minetest.get_translator ("advtrains")
--advtrains
+advtrains = {trains={}, player_to_train_mapping={}}
+-- =======================Development/debugging settings=====================
+-- DO NOT USE FOR NORMAL OPERATION
local DUMP_DEBUG_SAVE = false
+-- dump the save files in human-readable format into advtrains_DUMP
+
local GENERATE_ATRICIFIAL_LAG = false
local HOW_MANY_LAG = 1.0
+-- Simulate a higher server step interval, as it occurs when the server is on high load
+
+advtrains.IGNORE_WORLD = false
+-- Run advtrains without respecting the world map
+-- - No world collision checks occur
+-- - The NDB forcibly places all nodes stored in it into the world regardless of the world's content.
+-- - Rails do not set the 'attached_node' group
+-- This mode can be useful for debugging/testing a world without the map data available
+-- In this case, choose 'singlenode' as mapgen
+
+local NO_SAVE = false
+-- Do not save any data to advtrains save files
+-- ==========================================================================
--Constant for maximum connection value/division of the circle
AT_CMAX = 16
-advtrains = {trains={}, player_to_train_mapping={}}
-
-- get wagon loading range
advtrains.wagon_load_range = tonumber(minetest.settings:get("advtrains_wagon_load_range"))
if not advtrains.wagon_load_range then
@@ -622,6 +638,18 @@ function advtrains.save(remove_players_from_wagons)
atwarn("Instructed to save() but load() was never called!")
return
end
+
+ -- Cleanup actions
+ --TODO very simple yet hacky workaround for the "green signals" bug
+ advtrains.invalidate_all_paths()
+
+ if advtrains.IGNORE_WORLD then
+ advtrains.ndb.restore_all()
+ end
+
+ if NO_SAVE then
+ return
+ end
if no_action then
atlog("[save] Saving requested externally, but Advtrains step is disabled. Not saving any data as state may be inconsistent.")
return
@@ -632,9 +660,6 @@ function advtrains.save(remove_players_from_wagons)
atlatc.save()
end
atprint("[save_all]Saved advtrains save files")
-
- --TODO very simple yet hacky workaround for the "green signals" bug
- advtrains.invalidate_all_paths()
end
minetest.register_on_shutdown(advtrains.save)