aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/interlocking.html.LyXconv/interlocking.html78
-rw-r--r--assets/interlocking.lyx137
-rw-r--r--assets/interlocking.lyx~180
3 files changed, 301 insertions, 94 deletions
diff --git a/assets/interlocking.html.LyXconv/interlocking.html b/assets/interlocking.html.LyXconv/interlocking.html
index 98f5ac9..33a2d4e 100644
--- a/assets/interlocking.html.LyXconv/interlocking.html
+++ b/assets/interlocking.html.LyXconv/interlocking.html
@@ -443,33 +443,47 @@ of the route. Now:
<ul class="itemize1">
<li class="itemize">Put any turnouts you need to lock in the correct position (e.g. by right-clicking them). This includes flank protection.
</li>
- <li class="itemize">Punch them. This makes a marker saying &#8220;Route Lock Editing&#8221; appear.
+ <li class="itemize">Punch them. This makes a marker with a blue lock symbol appear.
</li>
<li class="itemize">If you punch a turnout again, or punch the marker, you can remove the lock again.
</li>
<li class="itemize">When you&#8217;ve locked all turnouts in the current section, go to and punch the TCB that is the border to the next track
section the train proceeds into.</li></ul>
-<!--l. 364--><p class="noindent" >Once you&#8217;ve done this, the lock markers change to &#8220;Route Lock&#8221;, telling they can&#8217;t be changed anymore. Repeat the above procedure until
-you have punched the final TCB, at which the route should end. As mentioned before, there should be a signal at this place,
-however this is not enforced. Now, run the chat command <span
-class="ectt-1000">/at_rp_set &#x003C;name of route&#x003E; </span>to complete programming the
-route.
-<!--l. 371--><p class="noindent" >A few hints:
+<!--l. 364--><p class="noindent" >Depending on the situation, you are now offered some possibilities to proceed:
+ <ul class="itemize1">
+ <li class="itemize">Click the &#8220;Advance to next section&#8221; button if your route consists of more sections with turnouts to lock, and you need to
+ continue programming. Follow the above steps to set locks for the next section.</li></ul>
+<!--l. 371--><p class="noindent" >Once you&#8217;ve clicked the &#8220;Advance&#8221; button, the lock markers change to a red lock symbol, telling they can&#8217;t be changed anymore. Repeat
+the above procedure until you are ready to complete the programming procedure:
+ <ul class="itemize1">
+ <li class="itemize">Click the &#8220;Finish route HERE&#8221; button when you&#8217;ve set up the locks for the last track section of the route and punched the
+ final TCB (the one with the next signal). You will be asked for a route name and your route will be saved.
+ </li>
+ <li class="itemize">The &#8220;Finish route at end of NEXT section&#8221; button (third button) is an useful quickhand to make the route proceed one
+ more section. Using this button is equivalent to first clicking the &#8220;Advance&#8221; button, then flying to the end of the next track
+ section and finishing the route there. You can not (officially) set turnout locks in the final section using this method.</li></ul>
+<!--l. 387--><p class="noindent" >A few hints:
<ul class="itemize1">
<li class="itemize">If one turnout should be locked by more than one section, set the lock only in the <span
class="ectt-1000">last </span>of those sections. Locking the same
turnout in multiple sections of a single route results in undefined behavior!
</li>
- <li class="itemize">If you accidentally punched a TCB, you can run <span
-class="ectt-1000">/at_rp_back </span>to undo this and return to the previous section. Due to a
- bug, you have to re-set all locks of this section.
+ <li class="itemize">If you accidentally advanced the route wrongly, you can use the &#8220;Step back one section&#8221; button to undo this.
+ </li>
+ <li class="itemize">If you want to stop programming the entire route without saving it, use the &#8220;Cancel route programming&#8221; button.
+ </li>
+ <li class="itemize">The third button is especially useful for programming simple block sections on a main running line, since you can stay at
+ the starting signal (punch starting TCB and select third button).
+ </li>
+ <li class="itemize">If a route should end in a dead end, you MUST use the &#8220;Finish in NEXT section&#8221; button, because there is no final TCB
+ that you could punch.
</li>
- <li class="itemize">If you want to stop programming the entire route without saving it, run <span
-class="ectt-1000">/at_rp_discard</span></li></ul>
-<!--l. 384--><p class="noindent" >
+ <li class="itemize">The third button does NOT work on sections with more than 2 exits, because the system won&#8217;t be able to determine the
+ final TCB of the route then.</li></ul>
+<!--l. 408--><p class="noindent" >
<a
id="x1-47r4"></a>
- <!--l. 384--><p class="noindent" ><span
+ <!--l. 408--><p class="noindent" ><span
class="ecsx-1200">4</span> <span
class="ecsx-1200">Interlocking</span>
<span
@@ -478,15 +492,15 @@ class="ecsx-1200">system</span>
class="ecsx-1200">operation</span>
<a
id="Q1-1-0"></a>
-<!--l. 386--><p class="noindent" >Setting up the interlocking for a portion of a railway network requires some time, experience and planning, but once done, there&#8217;s not
+<!--l. 410--><p class="noindent" >Setting up the interlocking for a portion of a railway network requires some time, experience and planning, but once done, there&#8217;s not
much to do anymore to make trains run on your, now safer, railway. This section covers some useful practices to route trains across your
network.
-<!--l. 391--><p class="noindent" >At the moment, routes can only be set by clicking the signal or via LuaATC, except if you use automatic working. It is planned to control
+<!--l. 415--><p class="noindent" >At the moment, routes can only be set by clicking the signal or via LuaATC, except if you use automatic working. It is planned to control
this via the onboard computer and via a &#8220;signal box&#8221; view based on the currently broken itrainmap.
-<!--l. 396--><p class="noindent" >
+<!--l. 420--><p class="noindent" >
<a
id="x1-48r1"></a>
- <!--l. 396--><p class="noindent" ><span
+ <!--l. 420--><p class="noindent" ><span
class="ecsx-1200">4.1</span> <span
class="ecsx-1200">Simple</span>
<span
@@ -499,44 +513,44 @@ class="ecsx-1200">and</span>
class="ecsx-1200">cancelling</span>
<a
id="Q1-1-0"></a>
-<!--l. 398--><p class="noindent" >To set a route, simply right-click the signal, select a route and click &#8220;set route&#8221;. If there are no conflicts, the signal turns green and the
+<!--l. 422--><p class="noindent" >To set a route, simply right-click the signal, select a route and click &#8220;set route&#8221;. If there are no conflicts, the signal turns green and the
train is allowed to proceed.
-<!--l. 402--><p class="noindent" >It may be possible that the route can not be set, because one or more other routes conflict with the current one, or a section is blocked. In
+<!--l. 426--><p class="noindent" >It may be possible that the route can not be set, because one or more other routes conflict with the current one, or a section is blocked. In
this case, the signal stays red, and the conflicting item is shown in the formspec. As soon as the conflict is resolved (by cancellation
or release of the conflicting route, or the section becoming free), the requested route will be set and the signal turns
green.
-<!--l. 409--><p class="noindent" >If a route is either requested or set, it can be cancelled from the signalling formspec. This means that all turnouts and sections are
+<!--l. 433--><p class="noindent" >If a route is either requested or set, it can be cancelled from the signalling formspec. This means that all turnouts and sections are
released, and the signal reverts back to red. This of course only works when the train has not passed the signal yet. There is no
mechanism for Approach Locking.
-<!--l. 415--><p class="noindent" >
+<!--l. 439--><p class="noindent" >
<a
id="x1-49r2"></a>
- <!--l. 415--><p class="noindent" ><span
+ <!--l. 439--><p class="noindent" ><span
class="ecsx-1200">4.2</span> <span
class="ecsx-1200">Automatic</span>
<span
class="ecsx-1200">Working</span>
<a
id="Q1-1-0"></a>
-<!--l. 417--><p class="noindent" >Block signals on main running lines usually only have a single route to set, the one proceeding along the main line. Their purpose is only
+<!--l. 441--><p class="noindent" >Block signals on main running lines usually only have a single route to set, the one proceeding along the main line. Their purpose is only
to show whether there are trains in the next section. So, it would be convenient if this only route would set itself again after a train
passed.
-<!--l. 423--><p class="noindent" >This is what Automatic Working is for. Set a route, click &#8220;Enable Automatic Working&#8221;, and as soon as a train passes, the route is
+<!--l. 447--><p class="noindent" >This is what Automatic Working is for. Set a route, click &#8220;Enable Automatic Working&#8221;, and as soon as a train passes, the route is
automatically re-set.
-<!--l. 427--><p class="noindent" >This function is nearly identical to SimSig automatic signals. It can also be useful on a line with high traffic, when there&#8217;s a
+<!--l. 451--><p class="noindent" >This function is nearly identical to SimSig automatic signals. It can also be useful on a line with high traffic, when there&#8217;s a
low-frequented access to a siding. You&#8217;d enable automatic working for the main route and cancel it only when you need a train to go into
the siding.
-<!--l. 432--><p class="noindent" >
+<!--l. 456--><p class="noindent" >
<a
id="x1-50r5"></a>
- <!--l. 432--><p class="noindent" ><span
+ <!--l. 456--><p class="noindent" ><span
class="ecsx-1200">5</span> <span
class="ecsx-1200">Final</span>
<span
class="ecsx-1200">notes</span>
<a
id="Q1-1-0"></a>
-<!--l. 434--><p class="noindent" >The interlocking system is mainly finished, though there are still some plans and ideas. They include:
+<!--l. 458--><p class="noindent" >The interlocking system is mainly finished, though there are still some plans and ideas. They include:
<ul class="itemize1">
<li class="itemize">Setting routes from inside a train (via onboard computer)
</li>
@@ -547,11 +561,11 @@ class="ecsx-1200">notes</span>
<li class="itemize">Distant signals
</li>
<li class="itemize">On-Train head-up display for oncoming signals (they have something like this in Czech Republic, I forgot how it&#8217;s called.)</li></ul>
-<!--l. 444--><p class="noindent" >Apart from this, there&#8217;s the large oncoming project of a new timetable-based train automation system, but this will take some time to
+<!--l. 468--><p class="noindent" >Apart from this, there&#8217;s the large oncoming project of a new timetable-based train automation system, but this will take some time to
evolve and is out of the scope of this document.
-<!--l. 448--><p class="noindent" >If you have any suggestions, corrections, improvements, criticism or cute kittens and stuff, you can always contact me by various means
+<!--l. 472--><p class="noindent" >If you have any suggestions, corrections, improvements, criticism or cute kittens and stuff, you can always contact me by various means
(Forum PM, E-Mail (orwell@bleipb.de), Linuxworks server chat a.s.o.). Have fun!
-<!--l. 453--><p class="noindent" >- orwell
+<!--l. 477--><p class="noindent" >- orwell
</body></html>
diff --git a/assets/interlocking.lyx b/assets/interlocking.lyx
index 9e9e94f..08e47da 100644
--- a/assets/interlocking.lyx
+++ b/assets/interlocking.lyx
@@ -933,15 +933,7 @@ Put any turnouts you need to lock in the correct position (e.g.
\begin_layout Itemize
Punch them.
- This makes a marker saying
-\begin_inset Quotes eld
-\end_inset
-
-Route Lock Editing
-\begin_inset Quotes erd
-\end_inset
-
- appear.
+ This makes a marker with a blue lock symbol appear.
\end_layout
\begin_layout Itemize
@@ -956,24 +948,75 @@ When you've locked all turnouts in the current section, go to and punch
\end_layout
\begin_layout Standard
-Once you've done this, the lock markers change to
+Depending on the situation, you are now offered some possibilities to proceed:
+\end_layout
+
+\begin_layout Itemize
+Click the
\begin_inset Quotes eld
\end_inset
-Route Lock
+Advance to next section
\begin_inset Quotes erd
\end_inset
-, telling they can't be changed anymore.
- Repeat the above procedure until you have punched the final TCB, at which
- the route should end.
- As mentioned before, there should be a signal at this place, however this
- is not enforced.
- Now, run the chat command
-\family typewriter
-/at_rp_set <name of route>
-\family default
- to complete programming the route.
+ button if your route consists of more sections with turnouts to lock, and
+ you need to continue programming.
+ Follow the above steps to set locks for the next section.
+\end_layout
+
+\begin_layout Standard
+Once you've clicked the
+\begin_inset Quotes eld
+\end_inset
+
+Advance
+\begin_inset Quotes erd
+\end_inset
+
+ button, the lock markers change to a red lock symbol, telling they can't
+ be changed anymore.
+ Repeat the above procedure until you are ready to complete the programming
+ procedure:
+\end_layout
+
+\begin_layout Itemize
+Click the
+\begin_inset Quotes eld
+\end_inset
+
+Finish route HERE
+\begin_inset Quotes erd
+\end_inset
+
+ button when you've set up the locks for the last track section of the route
+ and punched the final TCB (the one with the next signal).
+ You will be asked for a route name and your route will be saved.
+\end_layout
+
+\begin_layout Itemize
+The
+\begin_inset Quotes eld
+\end_inset
+
+Finish route at end of NEXT section
+\begin_inset Quotes erd
+\end_inset
+
+ button (third button) is an useful quickhand to make the route proceed
+ one more section.
+ Using this button is equivalent to first clicking the
+\begin_inset Quotes eld
+\end_inset
+
+Advance
+\begin_inset Quotes erd
+\end_inset
+
+ button, then flying to the end of the next track section and finishing
+ the route there.
+ You can not (officially) set turnout locks in the final section using this
+ method.
\end_layout
\begin_layout Standard
@@ -994,19 +1037,51 @@ last
\end_layout
\begin_layout Itemize
-If you accidentally punched a TCB, you can run
-\family typewriter
-/at_rp_back
-\family default
- to undo this and return to the previous section.
- Due to a bug, you have to re-set all locks of this section.
+If you accidentally advanced the route wrongly, you can use the
+\begin_inset Quotes eld
+\end_inset
+
+Step back one section
+\begin_inset Quotes erd
+\end_inset
+
+ button to undo this.
\end_layout
\begin_layout Itemize
-If you want to stop programming the entire route without saving it, run
-
-\family typewriter
-/at_rp_discard
+If you want to stop programming the entire route without saving it, use
+ the
+\begin_inset Quotes eld
+\end_inset
+
+Cancel route programming
+\begin_inset Quotes erd
+\end_inset
+
+ button.
+\end_layout
+
+\begin_layout Itemize
+The third button is especially useful for programming simple block sections
+ on a main running line, since you can stay at the starting signal (punch
+ starting TCB and select third button).
+\end_layout
+
+\begin_layout Itemize
+If a route should end in a dead end, you MUST use the
+\begin_inset Quotes eld
+\end_inset
+
+Finish in NEXT section
+\begin_inset Quotes erd
+\end_inset
+
+ button, because there is no final TCB that you could punch.
+\end_layout
+
+\begin_layout Itemize
+The third button does NOT work on sections with more than 2 exits, because
+ the system won't be able to determine the final TCB of the route then.
\end_layout
\begin_layout Section
diff --git a/assets/interlocking.lyx~ b/assets/interlocking.lyx~
index 0a881dc..ea118c0 100644
--- a/assets/interlocking.lyx~
+++ b/assets/interlocking.lyx~
@@ -933,15 +933,7 @@ Put any turnouts you need to lock in the correct position (e.g.
\begin_layout Itemize
Punch them.
- This makes a marker saying
-\begin_inset Quotes eld
-\end_inset
-
-Route Lock Editing
-\begin_inset Quotes erd
-\end_inset
-
- appear.
+ This makes a marker with a blue lock symbol appear.
\end_layout
\begin_layout Itemize
@@ -956,24 +948,75 @@ When you've locked all turnouts in the current section, go to and punch
\end_layout
\begin_layout Standard
-Once you've done this, the lock markers change to
+Depending on the situation, you are now offered some possibilities to proceed:
+\end_layout
+
+\begin_layout Itemize
+Click the
\begin_inset Quotes eld
\end_inset
-Route Lock
+Advance to next section
\begin_inset Quotes erd
\end_inset
-, telling they can't be changed anymore.
- Repeat the above procedure until you have punched the final TCB, at which
- the route should end.
- As mentioned before, there should be a signal at this place, however this
- is not enforced.
- Now, run the chat command
-\family typewriter
-/at_rp_set <name of route>
-\family default
- to complete programming the route.
+ button if your route consists of more sections with turnouts to lock, and
+ you need to continue programming.
+ Follow the above steps to set locks for the next section.
+\end_layout
+
+\begin_layout Standard
+Once you've clicked the
+\begin_inset Quotes eld
+\end_inset
+
+Advance
+\begin_inset Quotes erd
+\end_inset
+
+ button, the lock markers change to a red lock symbol, telling they can't
+ be changed anymore.
+ Repeat the above procedure until you are ready to complete the programming
+ procedure:
+\end_layout
+
+\begin_layout Itemize
+Click the
+\begin_inset Quotes eld
+\end_inset
+
+Finish route HERE
+\begin_inset Quotes erd
+\end_inset
+
+ button when you've set up the locks for the last track section of the route
+ and punched the final TCB (the one with the next signal).
+ You will be asked for a route name and your route will be saved.
+\end_layout
+
+\begin_layout Itemize
+The
+\begin_inset Quotes eld
+\end_inset
+
+Finish route at end of NEXT section
+\begin_inset Quotes erd
+\end_inset
+
+ button (third button) is an useful quickhand to make the route proceed
+ one more section.
+ Using this button is equivalent to first clicking the
+\begin_inset Quotes eld
+\end_inset
+
+Advance
+\begin_inset Quotes erd
+\end_inset
+
+ button, then flying to the end of the next track section and finishing
+ the route there.
+ You can not (officially) set turnout locks in the final section using this
+ method.
\end_layout
\begin_layout Standard
@@ -994,19 +1037,46 @@ last
\end_layout
\begin_layout Itemize
-If you accidentally punched a TCB, you can run
-\family typewriter
-/at_rp_back
-\family default
- to undo this and return to the previous section.
- Due to a bug, you have to re-set all locks of this section.
+If you accidentally advanced the route wrongly, you can use the
+\begin_inset Quotes eld
+\end_inset
+
+Step back one section
+\begin_inset Quotes erd
+\end_inset
+
+ button to undo this.
\end_layout
\begin_layout Itemize
-If you want to stop programming the entire route without saving it, run
-
-\family typewriter
-/at_rp_discard
+If you want to stop programming the entire route without saving it, use
+ the
+\begin_inset Quotes eld
+\end_inset
+
+Cancel route programming
+\begin_inset Quotes erd
+\end_inset
+
+ button.
+\end_layout
+
+\begin_layout Itemize
+The third button is especially useful for programming simple block sections
+ on a main running line, since you can stay at the starting signal (punch
+ starting TCB and select third button).
+\end_layout
+
+\begin_layout Itemize
+If a route should end in a dead end, you MUST use the
+\begin_inset Quotes eld
+\end_inset
+
+Finish in NEXT section
+\begin_inset Quotes erd
+\end_inset
+
+ button, because there is no final TCB that you could punch.
\end_layout
\begin_layout Section
@@ -1105,5 +1175,53 @@ d access to a siding.
you need a train to go into the siding.
\end_layout
+\begin_layout Section
+Final notes
+\end_layout
+
+\begin_layout Standard
+The interlocking system is mainly finished, though there are still some
+ plans and ideas.
+ They include:
+\end_layout
+
+\begin_layout Itemize
+Setting routes from inside a train (via onboard computer)
+\end_layout
+
+\begin_layout Itemize
+Signalbox panels, as revival of itrainmap
+\end_layout
+
+\begin_layout Itemize
+Individual signal aspects for routes
+\end_layout
+
+\begin_layout Itemize
+Distant signals
+\end_layout
+
+\begin_layout Itemize
+On-Train head-up display for oncoming signals (they have something like
+ this in Czech Republic, I forgot how it's called.)
+\end_layout
+
+\begin_layout Standard
+Apart from this, there's the large oncoming project of a new timetable-based
+ train automation system, but this will take some time to evolve and is
+ out of the scope of this document.
+\end_layout
+
+\begin_layout Standard
+If you have any suggestions, corrections, improvements, criticism or cute
+ kittens and stuff, you can always contact me by various means (Forum PM,
+ E-Mail (orwell@bleipb.de), Linuxworks server chat a.s.o.).
+ Have fun!
+\end_layout
+
+\begin_layout Standard
+- orwell
+\end_layout
+
\end_body
\end_document
t">.print_concat_table({t, ...}) advtrains.drb_record(context, text) --atlog("@@",advtrains.atprint_context_tid,t,...) end dofile(advtrains.modpath.."/debugringbuffer.lua") end function assertt(var, typ) if type(var)~=typ then error("Assertion failed, variable has to be of type "..typ) end end dofile(advtrains.modpath.."/helpers.lua"); --dofile(advtrains.modpath.."/debugitems.lua"); advtrains.meseconrules = {{x=0, y=0, z=-1}, {x=1, y=0, z=0}, {x=-1, y=0, z=0}, {x=0, y=0, z=1}, {x=1, y=1, z=0}, {x=1, y=-1, z=0}, {x=-1, y=1, z=0}, {x=-1, y=-1, z=0}, {x=0, y=1, z=1}, {x=0, y=-1, z=1}, {x=0, y=1, z=-1}, {x=0, y=-1, z=-1}, {x=0, y=-2, z=0}} advtrains.fpath=minetest.get_worldpath().."/advtrains" dofile(advtrains.modpath.."/path.lua") dofile(advtrains.modpath.."/trainlogic.lua") dofile(advtrains.modpath.."/trainhud.lua") dofile(advtrains.modpath.."/trackplacer.lua") dofile(advtrains.modpath.."/copytool.lua") dofile(advtrains.modpath.."/tracks.lua") dofile(advtrains.modpath.."/occupation.lua") dofile(advtrains.modpath.."/atc.lua") dofile(advtrains.modpath.."/wagons.lua") dofile(advtrains.modpath.."/protection.lua") dofile(advtrains.modpath.."/trackdb_legacy.lua") dofile(advtrains.modpath.."/nodedb.lua") dofile(advtrains.modpath.."/couple.lua") dofile(advtrains.modpath.."/signals.lua") dofile(advtrains.modpath.."/misc_nodes.lua") dofile(advtrains.modpath.."/crafting.lua") dofile(advtrains.modpath.."/craft_items.lua") dofile(advtrains.modpath.."/log.lua") dofile(advtrains.modpath.."/passive.lua") dofile(advtrains.modpath.."/lzb.lua") --load/save -- backup variables, used if someone should accidentally delete a sub-mod local MDS_interlocking, MDS_lines advtrains.fpath=minetest.get_worldpath().."/advtrains" dofile(advtrains.modpath.."/log.lua") function advtrains.read_component(name) local path = advtrains.fpath.."_"..name minetest.log("action", "[advtrains] loading "..path) local file, err = io.open(path, "r") if not file then minetest.log("warning", " Failed to read advtrains save data from file "..path..": "..(err or "Unknown Error")) minetest.log("warning", " (this is normal when first enabling advtrains on this world)") return end local tbl = minetest.deserialize(file:read("*a")) file:close() return tbl end function advtrains.avt_load() -- check for new, split advtrains save file local version = advtrains.read_component("version") local tbl if version and version == 3 then -- we are dealing with the new, split-up system minetest.log("action", "[advtrains] loading savefiles version 3") local il_save = { tcbs = true, ts = true, signalass = true, rs_locks = true, rs_callbacks = true, influence_points = true, npr_rails = true, } tbl={ trains = true, wagon_save = true, ptmap = true, atc = true, ndb = true, lines = true, version = 2, } for i,k in pairs(il_save) do il_save[i] = advtrains.read_component("interlocking_"..i) end for i,k in pairs(tbl) do tbl[i] = advtrains.read_component(i) end tbl["interlocking"] = il_save else local file, err = io.open(advtrains.fpath, "r") if not file then minetest.log("warning", " Failed to read advtrains save data from file "..advtrains.fpath..": "..(err or "Unknown Error")) minetest.log("warning", " (this is normal when first enabling advtrains on this world)") return else tbl = minetest.deserialize(file:read("*a")) file:close() end end if type(tbl) == "table" then if tbl.version then --congrats, we have the new save format. advtrains.trains = tbl.trains --Save the train id into the train table to avoid having to pass id around for id, train in pairs(advtrains.trains) do train.id = id end advtrains.wagons = tbl.wagon_save advtrains.player_to_train_mapping = tbl.ptmap or {} advtrains.ndb.load_data(tbl.ndb) advtrains.atc.load_data(tbl.atc) if advtrains.interlocking then advtrains.interlocking.db.load(tbl.interlocking) 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 train.id = tid for _, wid in ipairs(train.trainparts) do todel[wid]=nil end end for wid, _ in pairs(todel) do atwarn("Removing unused wagon", wid, "from wagon_save table.") advtrains.wagon_save[wid]=nil end else --oh no, its the old one... advtrains.trains=tbl --load ATC advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" local file, err = io.open(advtrains.fpath_atc, "r") if not file then local er=err or "Unknown Error" atprint("Failed loading advtrains atc save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then advtrains.atc.controllers=tbl.controllers end file:close() end --load wagon saves advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" local file, err = io.open(advtrains.fpath_ws, "r") if not file then local er=err or "Unknown Error" atprint("Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then advtrains.wagon_save=tbl end file:close() end end else minetest.log("error", " Failed to deserialize advtrains save data: Not a table!") end end advtrains.save_component = function (tbl, name) -- Saves each component of the advtrains file separately -- -- required for now to shrink the advtrains db to overcome lua -- limitations. local datastr = minetest.serialize(tbl) if not datastr then minetest.log("error", " Failed to serialize advtrains save data!") return end local path = advtrains.fpath.."_"..name local success = minetest.safe_file_write(path, datastr) if not success then minetest.log("error", " Failed to write advtrains save data to file "..path) end end advtrains.avt_save = function(remove_players_from_wagons) --atprint("saving") if remove_players_from_wagons then for w_id, data in pairs(advtrains.wagons) do data.seatp={} end advtrains.player_to_train_mapping={} end local tmp_trains={} for id, train in pairs(advtrains.trains) do --first, deep_copy the train if #train.trainparts > 0 then local v=advtrains.save_keys(train, { "last_pos", "last_connid", "last_frac", "velocity", "tarvelocity", "trainparts", "recently_collided_with_env", "atc_brake_target", "atc_wait_finish", "atc_command", "atc_delay", "door_open", "text_outside", "text_inside", "line", "routingcode", "il_sections", "speed_restriction", "is_shunt", }) --then save it tmp_trains[id]=v else atwarn("Train",id,"had no wagons left because of some bug. It is being deleted. Wave it goodbye!") advtrains.remove_train(id) end end for id, wdata in pairs(advtrains.wagons) do local _,proto = advtrains.get_wagon_prototype(wdata) if proto.has_inventory then local inv=minetest.get_inventory({type="detached", name="advtrains_wgn_"..id}) if inv then -- inventory is not initialized when wagon was never loaded -- TOOD: What happens with unloading rails when they don't find the inventory? wdata.ser_inv=advtrains.serialize_inventory(inv) end end -- TODO apply save-keys here too -- TODO temp wdata.dcpl_lock = nil end --versions: -- 1 - Initial new save format. -- 2 - version as of tss branch 11-2018+ local il_save if advtrains.interlocking then il_save = advtrains.interlocking.db.save() 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, ptmap = advtrains.player_to_train_mapping, atc = advtrains.atc.save_data(), ndb = advtrains.ndb.save_data(), lines = ln_save, version = 3, } for i,k in pairs(save_tbl) do advtrains.save_component(k,i) end for i,k in pairs(il_save) do advtrains.save_component(k,"interlocking_"..i) end if DUMP_DEBUG_SAVE then local file, err = io.open(advtrains.fpath.."_DUMP", "w") if err then return end file:write(dump(save_tbl)) file:close() end end --## MAIN LOOP ##-- --Calls all subsequent main tasks of both advtrains and atlatc local init_load=false local save_interval=20 local save_timer=save_interval advtrains.mainloop_runcnt=0 local t = 0 minetest.register_globalstep(function(dtime_mt) return advtrains.pcall(function() advtrains.mainloop_runcnt=advtrains.mainloop_runcnt+1 --atprint("Running the main loop, runcnt",advtrains.mainloop_runcnt) --call load once. see advtrains.load() comment if not init_load then advtrains.load() end --[[ local dtime if GENERATE_ATRICIFIAL_LAG then dtime = 0.2 if os.clock()<t then return end t = os.clock()+0.2 else --limit dtime: if trains move too far in one step, automation may cause stuck and wrongly braking trains dtime=dtime_mt if dtime>0.2 then atprint("Limiting dtime to 0.2!") dtime=0.2 end end ]] -- hotfix to prevent bugs related to ATC tracks. while (dtime_mt>0) do local dtime = dtime_mt if dtime > 0.2 then dtime = 0.2 end advtrains.mainloop_trainlogic(dtime) if advtrains_itm_mainloop then advtrains_itm_mainloop(dtime) end if atlatc then atlatc.mainloop_stepcode(dtime) atlatc.interrupt.mainloop(dtime) end if advtrains.lines then advtrains.lines.step(dtime) end dtime_mt = dtime_mt - dtime end --trigger a save when necessary save_timer=save_timer-dtime_mt if save_timer<=0 then local t=os.clock() --save advtrains.save() save_timer=save_interval atprintbm("saving", t) end end) end) --if something goes wrong in these functions, there is no help. no pcall here. --## MAIN LOAD ROUTINE ## -- Causes the loading of everything -- first time called in main loop (after the init phase) because luaautomation has to initialize first. function advtrains.load() advtrains.avt_load() --loading advtrains. includes ndb at advtrains.ndb.load_data() if atlatc then atlatc.load() --includes interrupts end if advtrains_itm_init then advtrains_itm_init() end init_load=true no_action=false atlog("[load_all]Loaded advtrains save files") end --## MAIN SAVE ROUTINE ## -- Causes the saving of everything function advtrains.save(remove_players_from_wagons) if not init_load then --wait... we haven't loaded yet?! atwarn("Instructed to save() but load() was never called!") return end advtrains.avt_save(remove_players_from_wagons) --saving advtrains. includes ndb at advtrains.ndb.save_data() if atlatc then 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) -- 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 -- These players still occupy seats in the trains. minetest.register_chatcommand("at_empty_seats", { params = "", -- Short parameter description description = "Detach all players, especially the offline ones, from all trains. Use only when no one serious is on a train.", -- Full description privs = {train_operator=true, server=true}, -- Require the "privs" privilege to run func = function(name, param) return advtrains.pcall(function() atwarn("Data is being saved. While saving, advtrains will remove the players from trains. Save files will be reloaded afterwards!") advtrains.save(true) reload_saves() end) end, }) -- This chat command solves another problem: Trains getting randomly stuck. minetest.register_chatcommand("at_reroute", { params = "", description = "Delete all train routes, force them to recalculate", privs = {train_operator=true}, -- Only train operator is required, since this is relatively safe. func = function(name, param) return advtrains.pcall(function() advtrains.invalidate_all_paths() return true, "Successfully invalidated train routes" end) end, }) local tot=(os.clock()-lot)*1000 minetest.log("action", "[advtrains] Loaded in "..tot.."ms")