From 5a2f6b7581391ceeb09de7584b84f2d364f5ac8b Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 24 Nov 2023 15:35:19 +0000 Subject: [PATCH] Optimisation: `addAmmoIntoEquipmentSlots()`, if it fails because of lack of space, break out of loop and skip trying to add remaining ammo --- project/src/helpers/BotWeaponGeneratorHelper.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/project/src/helpers/BotWeaponGeneratorHelper.ts b/project/src/helpers/BotWeaponGeneratorHelper.ts index 885e7f97..5875187f 100644 --- a/project/src/helpers/BotWeaponGeneratorHelper.ts +++ b/project/src/helpers/BotWeaponGeneratorHelper.ts @@ -132,9 +132,15 @@ export class BotWeaponGeneratorHelper ammoItem, ], inventory); - if (result === ItemAddedResult.NO_SPACE) + if (result !== ItemAddedResult.SUCCESS) { - this.logger.debug(`Unable to add ammo: ${ammoItem._tpl} to bot equipment`); + this.logger.debug(`Unable to add ammo: ${ammoItem._tpl} to bot equipment, ${ItemAddedResult[result]}`); + + if (result === ItemAddedResult.NO_SPACE) + { + // If there's no space for 1 stack, there's no space for the others + break; + } } } }