diff options
author | orwell96 <mono96.mml@gmail.com> | 2016-10-29 21:08:26 +0200 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2016-10-29 21:08:26 +0200 |
commit | ee6b7494bb8ec88accb6243437d81b0bbecdb9eb (patch) | |
tree | fd5adeaabb23d6c6d6ebda20a04fccbdda0df2cd /wagons.lua | |
parent | be37a649f7ea83007ee15effed0a474fb8d00f59 (diff) | |
download | advtrains-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
Diffstat (limited to 'wagons.lua')
-rw-r--r-- | wagons.lua | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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)
|