0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 05:30:43 -05:00

Fixed processItemsBeforeAddingToMail compile error

This commit is contained in:
Chomp 2025-01-16 10:35:21 +00:00
parent 91f12715fb
commit 7a9a06e6e3

View File

@ -451,13 +451,14 @@ export class MailSendService {
parentItem.parentId = this.hashUtil.generate();
}
// Prep return object
itemsToSendToPlayer = { stash: parentItem.parentId, data: [] };
// Ensure Ids are unique and cont collide with items in player inventory later
messageDetails.items = this.itemHelper.replaceIDs(messageDetails.items);
// Ensure item exits in items db
for (const reward of messageDetails.items) {
// Ensure item exists in items db
const itemTemplate = items[reward._tpl];
if (!itemTemplate) {
// Can happen when modded items are insured + mod is removed
@ -481,15 +482,19 @@ export class MailSendService {
// Ammo boxes should contain sub-items
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.AMMO_BOX)) {
const childItems = itemsToSendToPlayer.data?.filter((x) => x.parentId === reward._id);
if (childItems.length > 0) {
// Ammo box reward already has ammo, don't add
itemsToSendToPlayer.data.push(reward);
} else {
if (childItems?.length === 0) {
// No cartridges found, generate and add to rewards
const boxAndCartridges: IItem[] = [reward];
this.itemHelper.addCartridgesToAmmoBox(boxAndCartridges, itemTemplate);
}
// Push box + cartridge children into array
itemsToSendToPlayer.data.push(...boxAndCartridges);
continue;
}
// Ammo box reward already has ammo, don't do anything extra
itemsToSendToPlayer.data.push(reward);
} else {
if ("StackSlots" in itemTemplate._props) {
this.logger.error(