From 8f70b032844beaac3485b6053c719e5cca6e6e11 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 5 Nov 2023 12:37:17 +0000 Subject: [PATCH] Fix hasBuyRestrictions erroring on bad input data Fix isItemTplStackable erroring on bad input data --- project/src/helpers/ItemHelper.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index 23d1d372..a77a268b 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -465,7 +465,8 @@ class ItemHelper */ public hasBuyRestrictions(itemToCheck: Item): boolean { - if (itemToCheck.upd.BuyRestrictionCurrent !== undefined && itemToCheck.upd.BuyRestrictionMax !== undefined) + if (itemToCheck.upd?.BuyRestrictionCurrent !== undefined + && itemToCheck.upd?.BuyRestrictionMax !== undefined) { return true; } @@ -505,7 +506,13 @@ class ItemHelper */ public isItemTplStackable(tpl: string): boolean { - return this.databaseServer.getTables().templates.items[tpl]._props.StackMaxSize > 1; + const item = this.databaseServer.getTables().templates.items[tpl]; + if (!item) + { + return undefined; + } + + return item._props.StackMaxSize > 1; } /**