From 0743cecb05eee51e3e7e8853071dc3835df8a046 Mon Sep 17 00:00:00 2001 From: Mihaly Barasz Date: Fri, 27 Oct 2023 21:54:30 +0200 Subject: [PATCH] Round up in the launch product recipes when calculating input size This prevents it from being set to zero and resulting in invalid recipe. Fixes #76 --- Foreman/DataCache/DataCache.cs | 2 +- Foreman/DataCache/PresetProcessor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Foreman/DataCache/DataCache.cs b/Foreman/DataCache/DataCache.cs index 5bad4ad2..17985eab 100644 --- a/Foreman/DataCache/DataCache.cs +++ b/Foreman/DataCache/DataCache.cs @@ -1306,7 +1306,7 @@ private void ProcessRocketLaunch(JToken objJToken) if (amount != 0) { if (inputSize * amount > product.StackSize) - inputSize = (int)(product.StackSize / amount); + inputSize = (int)Math.Ceiling(product.StackSize / amount); amount = inputSize * amount; diff --git a/Foreman/DataCache/PresetProcessor.cs b/Foreman/DataCache/PresetProcessor.cs index becf5a91..a70c733b 100644 --- a/Foreman/DataCache/PresetProcessor.cs +++ b/Foreman/DataCache/PresetProcessor.cs @@ -282,7 +282,7 @@ private static async Task TestPresetStreamlined(Preset prese double amount = (double)productJToken["amount"]; int productStack = (int)(jsonData["items"].First(t => (string)t["name"] == (string)productJToken["name"])["stack"]?? 1); if (amount != 0 && inputSize * amount > productStack) - inputSize = (int)(productStack / amount); + inputSize = (int)Math.Ceiling(productStack / amount); } foreach (var productJToken in objJToken["launch_products"]) {