From fc1f3bd077afbe866e7bc79d118915c041439c75 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Sat, 28 Apr 2018 14:47:53 +0200 Subject: [PATCH] Attempted fix for command corruption --- client.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/client.js b/client.js index 5247ae95..d78140f3 100644 --- a/client.js +++ b/client.js @@ -831,11 +831,21 @@ function instanceManagement() { } // if we got some confirmed orders // console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders)); - sadas = JSON.stringify(confirmedOrders); - confirmedOrders = []; - // send our RCON command with whatever we got - messageInterface("/silent-command remote.call('clusterio', 'importMany', '" + sadas + "')"); - sadas = null; + let itemCount = confirmedOrders.length; + if(itemCount > 0){ + let numberOfFragments = Math.floor(itemCount*20/2000); // 20 is approximate length of items, 2000 is maximum length we want to send at a time + let exportedCount = 0; + let exportFragment = []; + while(exportedCount < itemCount){ + exportFragment[exportFragment.length] = confirmedOrders[exportedCount]; + exportedCount++; + if(exportFragment.length > 100 || exportedCount >= itemCount){ + messageInterface("/silent-command remote.call('clusterio', 'importMany', '" + JSON.stringify(exportFragment) + "')"); + exportFragment = []; + } + } + confirmedOrders = []; + } } }, 1000); // COMBINATOR SIGNALS ---------------------------------------------------------