nihilistzsche / LtnManager

A GUI for managing your Logistic Train Network. A mod for Factorio.
https://mods.factorio.com/mod/LtnManager
MIT License
49 stars 13 forks source link

LTN Manager crashes if Locomotive is destroyed while in transit #186

Closed Blackclaws closed 2 years ago

Blackclaws commented 2 years ago

Describe the Bug

LTN Manager crashes if locomotive is destroyed while trying to access it.

Error while running event LtnManager::on_tick (ID 0)
__LtnManager__/scripts/ltn-data.lua:419: attempt to index field 'main_locomotive' (a nil value)
stack traceback:
    __LtnManager__/scripts/ltn-data.lua:419: in function 'callback'
    __flib__/table.lua:249: in function <__flib__/table.lua:221>
    (...tail calls...)
    __LtnManager__/scripts/ltn-data.lua:1077: in function 'iterate'
    __LtnManager__/control.lua:212: in function <__LtnManager__/control.lua:197>
1779.064 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The mod LTN Manager (0.4.12) caused a non-recoverable error.
Please report this error to the mod author.

A simple fix should be to just check the field for nil before access.