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

Check for child items of ammo boxes before adding more prior to mailing

This commit is contained in:
Chomp 2025-01-16 00:48:27 +00:00
parent 24fb4e0578
commit e8a589a2f8

View File

@ -393,7 +393,7 @@ export class MailSendService {
dt: dialogueMessage.dt, dt: dialogueMessage.dt,
type: dialogueMessage.type, type: dialogueMessage.type,
uid: dialogueMessage.uid, uid: dialogueMessage.uid,
text: dialogueMessage.text text: dialogueMessage.text,
}; };
break; break;
} }
@ -478,11 +478,16 @@ export class MailSendService {
reward.slotId = "main"; reward.slotId = "main";
} }
// Boxes can contain sub-items // Ammo boxes should contain sub-items
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.AMMO_BOX)) { if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.AMMO_BOX)) {
const boxAndCartridges: IItem[] = [reward]; const childItems = itemsToSendToPlayer.data?.filter((x) => x.parentId === reward._id);
this.itemHelper.addCartridgesToAmmoBox(boxAndCartridges, itemTemplate); if (childItems.length > 0) {
// Ammo box reward already has ammo, don't add
itemsToSendToPlayer.data.push(reward);
} else {
const boxAndCartridges: IItem[] = [reward];
this.itemHelper.addCartridgesToAmmoBox(boxAndCartridges, itemTemplate);
}
// Push box + cartridge children into array // Push box + cartridge children into array
itemsToSendToPlayer.data.push(...boxAndCartridges); itemsToSendToPlayer.data.push(...boxAndCartridges);
} else { } else {