From 1035389c9e5bcb21fd526816c409851c852ee721 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 12 Sep 2021 00:27:46 +0200 Subject: [PATCH] Hotfix new player sync logic Fix has_data not being checked by sync_player, dialog being stuck open if no data is received by the master and master server refusing to server empty data. --- plugins/inventory_sync/master.js | 7 +------ plugins/inventory_sync/module/download_inventory.lua | 2 ++ plugins/inventory_sync/module/inventory_sync.lua | 5 ++++- plugins/inventory_sync/package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/inventory_sync/master.js b/plugins/inventory_sync/master.js index e30e972d..907102a1 100644 --- a/plugins/inventory_sync/master.js +++ b/plugins/inventory_sync/master.js @@ -160,14 +160,9 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin { this.logger.warn(`${instanceName} downloaded ${player_name} while another instance has acquired it`); } - let playerData = this.playerDatastore.get(player_name); - if (!playerData) { - throw new libErrors.RequestError(`No player data exists for ${player_name}`); - } - this.logger.verbose(`Sending player data for ${player_name} to ${instanceName}`); return { - player_data: playerData || null, + player_data: this.playerDatastore.get(player_name) || null, }; } diff --git a/plugins/inventory_sync/module/download_inventory.lua b/plugins/inventory_sync/module/download_inventory.lua index e8fd3a93..4f4b3897 100644 --- a/plugins/inventory_sync/module/download_inventory.lua +++ b/plugins/inventory_sync/module/download_inventory.lua @@ -28,6 +28,8 @@ local function download_inventory(player_name, data, number, total) log("ERROR: Inventory sync failed, got empty player data for " .. player.name .. " from the master") player.print("ERROR: Inventory sync failed, got empty player data from the master") + progress_dialog.remove(player) + -- Give the player a character and pretend that's the synced player data ensure_character(player) diff --git a/plugins/inventory_sync/module/inventory_sync.lua b/plugins/inventory_sync/module/inventory_sync.lua index 0ee154d5..ef7af9c1 100644 --- a/plugins/inventory_sync/module/inventory_sync.lua +++ b/plugins/inventory_sync/module/inventory_sync.lua @@ -194,7 +194,10 @@ function inventory_sync.sync_player(acquire_response) return end - if not player_record.sync or acquire_response.generation > player_record.generation then + if + acquire_response.has_data + and (not player_record.sync or acquire_response.generation > player_record.generation) + then inventory_sync.initiate_inventory_download(player, player_record, acquire_response.generation) else diff --git a/plugins/inventory_sync/package.json b/plugins/inventory_sync/package.json index 277a13d8..81433942 100644 --- a/plugins/inventory_sync/package.json +++ b/plugins/inventory_sync/package.json @@ -1,6 +1,6 @@ { "name": "@clusterio/plugin-inventory_sync", - "version": "2.0.0-alpha.9", + "version": "2.0.0-alpha.9.b", "description": "Clusterio plugin forwarding between Factorio servers", "author": "Danielv ", "homepage": "https://github.com/clusterio/factorioClusterio#readme",