[Oxyd] desync/crash with mod gui and Enter to leave vehicle
Posted: Wed Aug 12, 2015 9:45 pm
It seems like using Enter to leave a vehicle can cause issues when that vehicle has a mod gui and a gui element (checkbox in that case) was used before. Causing (my guess) Factorio trying to toggle that element when it has already been destroyed and leading to a desync/crash. The user that reported the error couldn't reproduce it in SP.
The relevant parts of the mod:
It simply destroys the mod gui for the vehicle 1 tick after the player exited it. The crash also happened when GUI.destroy was called in the same tick.
mod: https://github.com/Choumiko/FARL/releas ... _0.3.3.zip
Error log attached
The relevant parts of the mod:
Code: Select all
local function onTick(event)
if global.destroyNextTick[event.tick] then
local pis = global.destroyNextTick[event.tick]
for _, pi in pairs(pis) do
GUI.destroyGui(game.players[pi])
end
global.destroyNextTick[event.tick] = nil
end
for i, farl in pairs(global.farl) do
farl:update(event)
if farl.driver and farl.driver.name ~= "farl_player" then
GUI.updateGui(farl)
end
end
end
--snip
function onPlayerDrivingChangedState(event)
local player = game.players[event.player_index]
if (player.vehicle ~= nil and player.vehicle.name == "farl") then
if player.gui.left.farl == nil then
FARL.onPlayerEnter(player)
GUI.createGui(player)
end
end
if player.vehicle == nil and player.gui.left.farl ~= nil then
FARL.onPlayerLeave(player)
local tick = event.tick + 1
if not global.destroyNextTick[tick] then
global.destroyNextTick[tick] = {}
end
table.insert(global.destroyNextTick[tick], event.player_index)
end
end
--snip
game.on_event(defines.events.on_tick, onTick)
game.on_event(defines.events.on_player_driving_changed_state, onPlayerDrivingChangedState)
mod: https://github.com/Choumiko/FARL/releas ... _0.3.3.zip
Error log attached