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
This commit is contained in:
parent
be37a649f7
commit
ee6b7494bb
10
wagons.lua
10
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)
|
||||
|
|
Loading…
Reference in New Issue