mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 15:04:52 +09:00
Be more defensive with global table initialization
When upgrading or downgrading the inventory_sync plugin it's possible an different structure of the global.inventory_sync table is left behind which could cause the code to crash when certain sub tables are not present. Be more defensive in the initialization of the table to make sure all sub-tables are present on startup.
This commit is contained in:
1 parent
f72995ec8b
commit
ecbce16c99
1 file changed
+17
-8
@@ -29,15 +29,24 @@ inventory_sync.upload_inventory = upload_inventory
|
||||
inventory_sync.add_commands = add_commands
|
||||
inventory_sync.events = {}
|
||||
inventory_sync.events[clusterio_api.events.on_server_startup] = function(event)
|
||||
-- set up global table
|
||||
-- Set up global table
|
||||
if not global.inventory_sync then
|
||||
global.inventory_sync = {
|
||||
download_start_tick = {},
|
||||
saved_crafting_queue = {},
|
||||
download_cache = {},
|
||||
players_waiting_for_download = {},
|
||||
players = {},
|
||||
}
|
||||
global.inventory_sync = {}
|
||||
end
|
||||
if not global.inventory_sync.download_start_tick then
|
||||
global.inventory_sync.download_start_tick = {}
|
||||
end
|
||||
if not global.inventory_sync.saved_crafting_queue then
|
||||
global.inventory_sync.saved_crafting_queue = {}
|
||||
end
|
||||
if not global.inventory_sync.download_cache then
|
||||
global.inventory_sync.download_cache = {}
|
||||
end
|
||||
if not global.inventory_sync.players_waiting_for_download then
|
||||
global.inventory_sync.players_waiting_for_download = {}
|
||||
end
|
||||
if not global.inventory_sync.players then
|
||||
global.inventory_sync.players = {}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user