tried to fix desyncs

This commit is contained in:
MCRcortex authored and GitHub committed 2018-04-29 10:29:35 +10:00
1 parent 1184e64467
commit f10d6bbfb5
1 file changed
+11 -14
+11 -14
View File
@@ -831,21 +831,18 @@ function instanceManagement() {
} }
// if we got some confirmed orders // if we got some confirmed orders
// console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders)); // console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
let itemCount = confirmedOrders.length; let cmd="{";
if(itemCount > 0){ for(let i=0;i<confirmedOrders.length;i++)
let numberOfFragments = Math.floor(itemCount*50/2000); // 50 is approximate length of items, 2000 is maximum length we want to send at a time {
let exportedCount = 0; cmd+='"'+confirmedOrders[i].name+'"'+":"+confirmedOrders[i].count+",";
let exportFragment = []; if(cmd.length>1000)
while(exportedCount < itemCount){ {
exportFragment[exportFragment.length] = confirmedOrders[exportedCount]; messageInterface("/silent-command remote.call('clusterio', 'importMany', '"+cmd.slice(0, -1)+"}"+ "')");
exportedCount++; cmd="{";
if(exportFragment.length > 100 || exportedCount >= itemCount){ }
messageInterface("/silent-command remote.call('clusterio', 'importMany', '" + JSON.stringify(exportFragment) + "')");
exportFragment = [];
}
}
confirmedOrders = [];
} }
messageInterface("/silent-command remote.call('clusterio', 'importMany', '"+cmd.slice(0, -1)+"}"+ "')");
confirmedOrders=[];
} }
}, 1000); }, 1000);
// COMBINATOR SIGNALS --------------------------------------------------------- // COMBINATOR SIGNALS ---------------------------------------------------------