aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-10-29 21:08:26 +0200
committerorwell96 <mono96.mml@gmail.com>2016-10-29 21:08:26 +0200
commitee6b7494bb8ec88accb6243437d81b0bbecdb9eb (patch)
treefd5adeaabb23d6c6d6ebda20a04fccbdda0df2cd
parentbe37a649f7ea83007ee15effed0a474fb8d00f59 (diff)
downloadadvtrains-ee6b7494bb8ec88accb6243437d81b0bbecdb9eb.tar.gz
advtrains-ee6b7494bb8ec88accb6243437d81b0bbecdb9eb.tar.bz2
advtrains-ee6b7494bb8ec88accb6243437d81b0bbecdb9eb.zip
add 2 value sanity checks which should not be needed but are for any reason
game crashed because of these values being nil, I don't know how these values could even become nil, but whatever. Interestingly, I never found the wagon entity that was causing the crashs
-rw-r--r--wagons.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/wagons.lua b/wagons.lua
index 6944e76..287b723 100644
--- a/wagons.lua
+++ b/wagons.lua
@@ -174,6 +174,12 @@ end
function wagon:on_step(dtime)
local t=os.clock()
local pos = self.object:getpos()
+
+ if not pos then
+ print("["..self.unique_id.."][fatal] missing position (object:getpos() returned nil)")
+ return
+ end
+
if not self.initialized_pre then
print("[advtrains] wagon stepping while not yet initialized_pre, returning")
self.object:setvelocity({x=0,y=0,z=0})
@@ -269,6 +275,10 @@ function wagon:on_step(dtime)
self.object:setvelocity({x=0, y=0, z=0})
return
end
+ if not self.pos_in_train then
+ print("["..self.unique_id.."][fatal] no pos_in_train set.")
+ return
+ end
local index=advtrains.get_real_path_index(self:train(), self.pos_in_train)
--print("trainindex "..gp.index.." wagonindex "..index)