From fcbd39c6b004f3180266b435152f43b504092c17 Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Thu, 11 Jan 2024 08:13:27 +0000 Subject: [PATCH] Remove delivered items from player insured items (!191) This stops players from duplicating insured items via the BTR delivery service Note: This does un-insure the item, I don't have any proof one way or the other for whether live causes the items to no longer be insured, but this was the easier solution to implement. Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/191 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/src/controllers/InraidController.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index c2ebc64e..d18b33f3 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -525,10 +525,19 @@ export class InraidController */ public itemDelivery(sessionId: string, traderId: string, items: Item[]): void { + const serverProfile = this.saveServer.getProfile(sessionId); + const pmcData = serverProfile.characters.pmc; + const dialogueTemplates = this.databaseServer.getTables().traders[traderId].dialogue; const messageId = this.randomUtil.getArrayValue(dialogueTemplates.itemsDelivered); const messageStoreTime = this.timeUtil.getHoursAsSeconds(this.traderConfig.fence.btrDeliveryExpireHours); + + // Remove any items that were returned by the item delivery, but also insured, from the player's insurance list + // This is to stop items being duplicated by being returned from both the item delivery, and insurance + const deliveredItemIds = items.map(x => x._id); + pmcData.InsuredItems = pmcData.InsuredItems.filter(x => !deliveredItemIds.includes(x.itemId)); + // Send the items to the player this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionId, this.traderHelper.getTraderById(traderId),