Add scav profile support to InventoryController.swapItem (!341)
Resolves https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/664 Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/341 Co-authored-by: Tyfon <tyfon7@outlook.com> Co-committed-by: Tyfon <tyfon7@outlook.com>
This commit is contained in:
parent
5b5bf8bd7c
commit
66cac910c3
@ -401,13 +401,20 @@ export class InventoryController
|
||||
sessionID: string,
|
||||
): IItemEventRouterResponse
|
||||
{
|
||||
const itemOne = pmcData.Inventory.items.find((x) => x._id === request.item);
|
||||
// During post-raid scav transfer, the swap may be in the scav inventory
|
||||
let playerData = pmcData;
|
||||
if (request.fromOwner?.type === "Profile" && request.fromOwner.id !== playerData._id)
|
||||
{
|
||||
playerData = this.profileHelper.getScavProfile(sessionID);
|
||||
}
|
||||
|
||||
const itemOne = playerData.Inventory.items.find((x) => x._id === request.item);
|
||||
if (!itemOne)
|
||||
{
|
||||
this.logger.error(`Unable to find item: ${request.item} to swap positions with: ${request.item2}`);
|
||||
}
|
||||
|
||||
const itemTwo = pmcData.Inventory.items.find((x) => x._id === request.item2);
|
||||
const itemTwo = playerData.Inventory.items.find((x) => x._id === request.item2);
|
||||
if (!itemTwo)
|
||||
{
|
||||
this.logger.error(`Unable to find item: ${request.item2} to swap positions with: ${request.item}`);
|
||||
@ -457,7 +464,7 @@ export class InventoryController
|
||||
let playerData = pmcData;
|
||||
|
||||
// We may be folding data on scav profile, get that profile instead
|
||||
if (request.fromOwner && request.fromOwner.type === "Profile" && request.fromOwner.id !== playerData._id)
|
||||
if (request.fromOwner?.type === "Profile" && request.fromOwner.id !== playerData._id)
|
||||
{
|
||||
playerData = this.profileHelper.getScavProfile(sessionID);
|
||||
}
|
||||
@ -495,7 +502,7 @@ export class InventoryController
|
||||
let playerData = pmcData;
|
||||
|
||||
// Fix for toggling items while on they're in the Scav inventory
|
||||
if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== playerData._id)
|
||||
if (body.fromOwner?.type === "Profile" && body.fromOwner.id !== playerData._id)
|
||||
{
|
||||
playerData = this.profileHelper.getScavProfile(sessionID);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user