Fix the "Unable to transfer stack" exception on scav post-raid screen (!230)
Switched `transferItem` to use the `getOwnerInventoryItems` method, so that it properly handles transfer events on the scav inventory Bit of cleanup and consistency changes made to the `transferItem` method Testing instructions in issue: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/483 Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/230 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
8853ff9aad
commit
b84531bb27
@ -324,7 +324,6 @@ export class InventoryController
|
||||
|
||||
/**
|
||||
* TODO: Adds no data to output to send to client, is this by design?
|
||||
* TODO: should make use of getOwnerInventoryItems(), stack being transferred may not always be on pmc
|
||||
* Transfer items from one stack into another while keeping original stack
|
||||
* Used to take items from scav inventory into stash or to insert ammo into mags (shotgun ones) and reloading weapon by clicking "Reload"
|
||||
* @param pmcData Player profile
|
||||
@ -340,28 +339,9 @@ export class InventoryController
|
||||
output: IItemEventRouterResponse,
|
||||
): IItemEventRouterResponse
|
||||
{
|
||||
let sourceItem: Item = null;
|
||||
let destinationItem: Item = null;
|
||||
|
||||
for (const iterItem of pmcData.Inventory.items)
|
||||
{
|
||||
if (iterItem._id === body.item)
|
||||
{
|
||||
// Found source item
|
||||
sourceItem = iterItem;
|
||||
}
|
||||
else if (iterItem._id === body.with)
|
||||
{
|
||||
// Found destination item
|
||||
destinationItem = iterItem;
|
||||
}
|
||||
|
||||
if (sourceItem !== null && destinationItem !== null)
|
||||
{
|
||||
// Both items found, exit loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
const inventoryItems = this.inventoryHelper.getOwnerInventoryItems(body, sessionID);
|
||||
const sourceItem = inventoryItems.from.find(item => item._id == body.item);
|
||||
const destinationItem = inventoryItems.to.find(item => item._id == body.with);
|
||||
|
||||
if (sourceItem === null)
|
||||
{
|
||||
@ -383,13 +363,12 @@ export class InventoryController
|
||||
return output;
|
||||
}
|
||||
|
||||
let sourceStackCount = 1;
|
||||
if (!sourceItem.upd)
|
||||
{
|
||||
sourceItem.upd = { StackObjectsCount: 1 };
|
||||
}
|
||||
sourceStackCount = sourceItem.upd.StackObjectsCount;
|
||||
|
||||
const sourceStackCount = sourceItem.upd.StackObjectsCount;
|
||||
if (sourceStackCount > body.count)
|
||||
{
|
||||
// Source items stack count greater than new desired count
|
||||
@ -401,16 +380,11 @@ export class InventoryController
|
||||
sourceItem.upd.StackObjectsCount = sourceStackCount - 1;
|
||||
}
|
||||
|
||||
let destinationStackCount = 1;
|
||||
if (destinationItem.upd)
|
||||
if (!destinationItem.upd)
|
||||
{
|
||||
destinationStackCount = destinationItem.upd.StackObjectsCount;
|
||||
destinationItem.upd = { StackObjectsCount: 1 };
|
||||
}
|
||||
else
|
||||
{
|
||||
Object.assign(destinationItem, { upd: { StackObjectsCount: 1 } });
|
||||
}
|
||||
|
||||
const destinationStackCount = destinationItem.upd.StackObjectsCount;
|
||||
destinationItem.upd.StackObjectsCount = destinationStackCount + body.count;
|
||||
|
||||
return output;
|
||||
|
@ -11,13 +11,14 @@ import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
||||
import { Inventory } from "@spt-aki/models/eft/common/tables/IBotBase";
|
||||
import { Item, Location, Upd } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { IAddItemDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemDirectRequest";
|
||||
import { AddItem, IAddItemRequestData } from "@spt-aki/models/eft/inventory/IAddItemRequestData";
|
||||
import { AddItem } from "@spt-aki/models/eft/inventory/IAddItemRequestData";
|
||||
import { IAddItemTempObject } from "@spt-aki/models/eft/inventory/IAddItemTempObject";
|
||||
import { IAddItemsDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemsDirectRequest";
|
||||
import { IInventoryMergeRequestData } from "@spt-aki/models/eft/inventory/IInventoryMergeRequestData";
|
||||
import { IInventoryMoveRequestData } from "@spt-aki/models/eft/inventory/IInventoryMoveRequestData";
|
||||
import { IInventoryRemoveRequestData } from "@spt-aki/models/eft/inventory/IInventoryRemoveRequestData";
|
||||
import { IInventorySplitRequestData } from "@spt-aki/models/eft/inventory/IInventorySplitRequestData";
|
||||
import { IInventoryTransferRequestData } from "@spt-aki/models/eft/inventory/IInventoryTransferRequestData";
|
||||
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
@ -840,7 +841,7 @@ export class InventoryHelper
|
||||
* @returns OwnerInventoryItems with inventory of player/scav to adjust
|
||||
*/
|
||||
public getOwnerInventoryItems(
|
||||
request: IInventoryMoveRequestData | IInventorySplitRequestData | IInventoryMergeRequestData,
|
||||
request: IInventoryMoveRequestData | IInventorySplitRequestData | IInventoryMergeRequestData | IInventoryTransferRequestData,
|
||||
sessionId: string,
|
||||
): IOwnerInventoryItems
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user