From ee6b7494bb8ec88accb6243437d81b0bbecdb9eb Mon Sep 17 00:00:00 2001 From: orwell96 Date: Sat, 29 Oct 2016 21:08:26 +0200 Subject: 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 --- wagons.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'wagons.lua') 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) -- cgit v1.2.3