mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 08:30:44 -05:00
Fixed processItemsBeforeAddingToMail
compile error
This commit is contained in:
parent
91f12715fb
commit
7a9a06e6e3
@ -451,13 +451,14 @@ export class MailSendService {
|
|||||||
parentItem.parentId = this.hashUtil.generate();
|
parentItem.parentId = this.hashUtil.generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prep return object
|
||||||
itemsToSendToPlayer = { stash: parentItem.parentId, data: [] };
|
itemsToSendToPlayer = { stash: parentItem.parentId, data: [] };
|
||||||
|
|
||||||
// Ensure Ids are unique and cont collide with items in player inventory later
|
// Ensure Ids are unique and cont collide with items in player inventory later
|
||||||
messageDetails.items = this.itemHelper.replaceIDs(messageDetails.items);
|
messageDetails.items = this.itemHelper.replaceIDs(messageDetails.items);
|
||||||
|
|
||||||
|
// Ensure item exits in items db
|
||||||
for (const reward of messageDetails.items) {
|
for (const reward of messageDetails.items) {
|
||||||
// Ensure item exists in items db
|
|
||||||
const itemTemplate = items[reward._tpl];
|
const itemTemplate = items[reward._tpl];
|
||||||
if (!itemTemplate) {
|
if (!itemTemplate) {
|
||||||
// Can happen when modded items are insured + mod is removed
|
// Can happen when modded items are insured + mod is removed
|
||||||
@ -481,15 +482,19 @@ export class MailSendService {
|
|||||||
// Ammo boxes should 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 childItems = itemsToSendToPlayer.data?.filter((x) => x.parentId === reward._id);
|
const childItems = itemsToSendToPlayer.data?.filter((x) => x.parentId === reward._id);
|
||||||
if (childItems.length > 0) {
|
if (childItems?.length === 0) {
|
||||||
// Ammo box reward already has ammo, don't add
|
// No cartridges found, generate and add to rewards
|
||||||
itemsToSendToPlayer.data.push(reward);
|
|
||||||
} else {
|
|
||||||
const boxAndCartridges: IItem[] = [reward];
|
const boxAndCartridges: IItem[] = [reward];
|
||||||
this.itemHelper.addCartridgesToAmmoBox(boxAndCartridges, itemTemplate);
|
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);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ammo box reward already has ammo, don't do anything extra
|
||||||
|
itemsToSendToPlayer.data.push(reward);
|
||||||
} else {
|
} else {
|
||||||
if ("StackSlots" in itemTemplate._props) {
|
if ("StackSlots" in itemTemplate._props) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user