mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Fix crash when game starts tick_paused
Check patch number in update_instance step to ensure the clusterio_api is properly initialized if the game started tick paused and no ticks to trigger the patch check have happened yet.
This commit is contained in:
1 parent
475182efd0
commit
17e4b088f1
1 file changed
+7
-4
@@ -1,16 +1,18 @@
|
|||||||
local api = require('modules/clusterio/api')
|
local api = require('modules/clusterio/api')
|
||||||
|
|
||||||
local impl = {}
|
|
||||||
|
|
||||||
|
local function check_patch()
|
||||||
impl.events = {}
|
|
||||||
impl.events[defines.events.on_tick] = function()
|
|
||||||
if global.clusterio_patch_number ~= clusterio_patch_number then
|
if global.clusterio_patch_number ~= clusterio_patch_number then
|
||||||
global.clusterio_patch_number = clusterio_patch_number
|
global.clusterio_patch_number = clusterio_patch_number
|
||||||
script.raise_event(api.events.on_server_startup, {})
|
script.raise_event(api.events.on_server_startup, {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local impl = {}
|
||||||
|
impl.events = {}
|
||||||
|
|
||||||
|
impl.events[defines.events.on_tick] = check_patch
|
||||||
|
|
||||||
impl.events[api.events.on_server_startup] = function()
|
impl.events[api.events.on_server_startup] = function()
|
||||||
if not global.clusterio then
|
if not global.clusterio then
|
||||||
global.clusterio = {
|
global.clusterio = {
|
||||||
@@ -47,6 +49,7 @@ end
|
|||||||
-- Internal API
|
-- Internal API
|
||||||
clusterio_private = {}
|
clusterio_private = {}
|
||||||
function clusterio_private.update_instance(new_id, new_name)
|
function clusterio_private.update_instance(new_id, new_name)
|
||||||
|
check_patch()
|
||||||
global.clusterio.instance_id = new_id
|
global.clusterio.instance_id = new_id
|
||||||
global.clusterio.instance_name = new_name
|
global.clusterio.instance_name = new_name
|
||||||
script.raise_event(api.events.on_instance_updated, {
|
script.raise_event(api.events.on_instance_updated, {
|
||||||
|
|||||||
Reference in new issue
Block a user