Added nullguards to giveProfileMoney()

(cherry picked from commit f7a617d621)
This commit is contained in:
Dev 2024-07-12 09:48:30 +01:00
parent 201684d200
commit a3b97ff3ef

View File

@ -180,9 +180,22 @@ export class PaymentService
): void ): void
{ {
const trader = this.traderHelper.getTrader(request.tid, sessionID); const trader = this.traderHelper.getTrader(request.tid, sessionID);
if (!trader)
{
this.logger.error(`Unable to add currency to profile as trader: ${request.tid} does not exist`);
return;
}
const currencyTpl = this.paymentHelper.getCurrency(trader.currency); const currencyTpl = this.paymentHelper.getCurrency(trader.currency);
let calcAmount = this.handbookHelper.fromRUB(this.handbookHelper.inRUB(amountToSend, currencyTpl), currencyTpl); let calcAmount = this.handbookHelper.fromRUB(this.handbookHelper.inRUB(amountToSend, currencyTpl), currencyTpl);
const currencyMaxStackSize = this.itemHelper.getItem(currencyTpl)[1]._props.StackMaxSize!; const currencyMaxStackSize = this.itemHelper.getItem(currencyTpl)[1]._props?.StackMaxSize;
if (!currencyMaxStackSize)
{
this.logger.error(`Unable to add currency: ${currencyTpl} to profile as it lacks a _props property`);
return;
}
let skipSendingMoneyToStash = false; let skipSendingMoneyToStash = false;
for (const item of pmcData.Inventory.items) for (const item of pmcData.Inventory.items)