Resolve issue caused by quests pulling loose ammo from magazines (!218)
If the item handed in for a quest has a numeric `location` property, this indicates it's inside a magazine or other "sequential" container. Re-calculate the `location` property of all children in the items parent in this case, to avoid gaps which break the profile Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/455 Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/218 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
74ea69ffe6
commit
cc6061b885
@ -835,7 +835,22 @@ export class QuestController
|
|||||||
{
|
{
|
||||||
if (toRemove.includes(pmcData.Inventory.items[index]._id))
|
if (toRemove.includes(pmcData.Inventory.items[index]._id))
|
||||||
{
|
{
|
||||||
pmcData.Inventory.items.splice(index, 1);
|
// Remove the item
|
||||||
|
const removedItem = pmcData.Inventory.items.splice(index, 1)[0];
|
||||||
|
|
||||||
|
// If the removed item has a numeric `location` property, re-calculate all the child
|
||||||
|
// element `location` properties of the parent so they are sequential, while retaining order
|
||||||
|
if (typeof removedItem.location === "number")
|
||||||
|
{
|
||||||
|
const childItems = this.itemHelper.findAndReturnChildrenAsItems(pmcData.Inventory.items, removedItem.parentId);
|
||||||
|
childItems.shift(); // Remove the parent
|
||||||
|
|
||||||
|
// Sort by the current `location` and update
|
||||||
|
childItems.sort((a, b) => a.location > b.location ? 1 : -1).forEach((item, index) =>
|
||||||
|
{
|
||||||
|
item.location = index;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user