From ce0e89f5b3c5ae718793c110779586592f839380 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Sun, 28 Jan 2024 16:13:09 +0100 Subject: [PATCH] improved turtle defrag --- src/lib/turtle/InvManager.hx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/turtle/InvManager.hx b/src/lib/turtle/InvManager.hx index 4fb55c9..84e29ca 100644 --- a/src/lib/turtle/InvManager.hx +++ b/src/lib/turtle/InvManager.hx @@ -128,7 +128,7 @@ class InvManager { var topIndex = slots.length - 1; for (k => slot in slots) { - if (topIndex <= k) { + if (topIndex < k) { return; } @@ -138,8 +138,11 @@ class InvManager { return; } - while (true) { - if (topIndex <= k) { + var loopProtect = 20; + + while (loopProtect > 0) { + loopProtect--; + if (topIndex < k) { return; }