From 8a20da7e08aeb446da8403244d95d0309ad5330a Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 28 Mar 2024 00:26:40 -0400 Subject: [PATCH 1/2] Resolves Insurance Attachment Return Issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update resolves an issue that was causing items that were not in-raid moddable to be rolled for insurance. We were checking to see if the item is in-raid moddable within the context of the main-parent item (the gun), but not the immediate parent item (upper receiver). This update resolves this by checking to see if the immediate parent is set on the attachment, and if it is, checking within that context instead of the main-parent context. Thank you to Roselyn Cristal for the report. ♥️ --- .../src/controllers/InsuranceController.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index fe681f3f..844acb29 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -307,15 +307,31 @@ export class InsuranceController for (const [parentId, attachmentItems] of parentAttachmentsMap) { const parentItem = itemsMap.get(parentId); - const moddableAttachments = []; + const moddableAttachments: Item[] = []; for (const attachment of attachmentItems) { - if (this.itemHelper.isRaidModdable(attachment, parentItem)) + // By default, assume the parent of the current attachment is the main-parent included in the map. + let attachmentParentItem = parentItem; + + // If the attachment includes a parentId, use it to find its direct parent item, even if it's another + // attachment on the main-parent. For example, if the attachment is a stock, we need to check to see if + // it's moddable in the upper receiver (attachment/parent), which is attached to the gun (main-parent). + if (attachment.parentId) + { + const directParentItem = itemsMap.get(attachment.parentId); + if (directParentItem) + { + attachmentParentItem = directParentItem; + } + } + + if (this.itemHelper.isRaidModdable(attachment, attachmentParentItem)) { moddableAttachments.push(attachment); } } - // Only set the parentId and its attachments in the updatedMap if there are moddable attachments. + + // If any moddable attachments remain, add them to the updated map. if (moddableAttachments.length > 0) { updatedMap.set(parentId, moddableAttachments); From 41ef66298e5948f43b141e742d34f1d158f85d30 Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 28 Mar 2024 00:29:46 -0400 Subject: [PATCH 2/2] Skip Processing Deleted Insurance Attachments This check simply skips over rolling for insurance for attachment items that have already been deleted due to their main-parent item being previously rolled for deletion. --- project/src/controllers/InsuranceController.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index 844acb29..6e903a5c 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -413,6 +413,13 @@ export class InsuranceController { for (const [parentId, attachmentItems] of mainParentToAttachmentsMap) { + // Skip processing if parentId is already marked for deletion, as all attachments for that parent will + // already be marked for deletion as well. + if (toDelete.has(parentId)) + { + continue; + } + // Log the parent item's name. const parentItem = itemsMap.get(parentId); const parentName = this.itemHelper.getItemName(parentItem._tpl);