Resolves Insurance Attachment Return Issue

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. ♥️
This commit is contained in:
Refringe 2024-03-28 00:26:40 -04:00
parent 7939e39945
commit 8a20da7e08
No known key found for this signature in database
GPG Key ID: 7715B85B4A6306ED

View File

@ -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);