I got this on the chat log some time ago:
[advtrains] -!- train_ensure_init: Called with id = 224782 but a nil
train!
2019-12-07 11:36:48: ACTION[Main]: [advtrains] -!- stack traceback:
...server/.minetest/mods/advtrains/advtrains/trainlogic.lua:239: in
function 'train_ensure_init'
...server/.minetest/mods/advtrains/advtrains/trainlogic.lua:983: in
function 'train_check_couples'
...server/.minetest/mods/advtrains/advtrains/trainlogic.lua:532: in
function 'train_step_c'
...server/.minetest/mods/advtrains/advtrains/trainlogic.lua:97: in
function 'mainloop_trainlogic'
...etest-server/.minetest/mods/advtrains/advtrains/init.lua:490: in
function
<...etest-server/.minetest/mods/advtrains/advtrains/init.lua:465>
[C]: in function 'xpcall'
...etest-server/.minetest/mods/advtrains/advtrains/init.lua:56: in
function 'func'
...hare/games/minetest/builtin/profiler/instrumentation.lua:106: in
function
<...hare/games/minetest/builtin/profiler/instrumentation.lua:100>
/usr/share/games/minetest/builtin/game/register.lua:420: in function
</usr/share/games/minetest/builtin/game/register.lua:400>
[advtrains] -!- Train 224782 is not initialized! Couldn't check couples!
Hi,
does this warning appear often, or only a single time? In theory, it
should go away after a server restart.
(it is caused by an inconsistency, where a train that doesn't exist
anymore is still registered in the occupation table.)
The message kept appearing until server crash.
But it did not reappear after the server restarted?
No, it didn't.
While writing the train copy tool, I had to implement the check for train
length so that it wouldn't end up with the end of the train off the rails.
If the back of the train ended up off the rails and into the terrain, I
would get a very similar "Train xxxxxx is not initialized! Couldn't check
couples!" message. This was with the JR-E231 train in a 3-car set with 2
control cars and a pantogrpah car.
I could enter the front control car and drive the train at 1 m/s forward
(this restriction is imposed when the train is off track in
trainlogic.lua). Trying to set ATC to full speed (Sneak+W) wouldn't work in
this state. The rear two wagons would be completely dark, and trying to
de-couple them would give the "Train not initialized! Couldn't check
couples!" error. I'm fairly sure trying to destroy the wagons directly,
since it checks if the wagon is coupled, would give the same error.
After a long time holding W, the train could escape onto the tracks. After
the train escaped, the other 2 carriages would be lit and their couples
would work properly without giving the error message, so I could then
destroy the train properly.
Suggested way to reproduce: Check out the copytrain branch (or master if it
is merged by the time you read this). Comment out the code in the paste
function that checks if the train would end up off-track. Place a train so
that the back goes off the end of the rails.