EXPERIMENTAL - pass output object into handleItemEvent and into move function
This commit is contained in:
parent
d436534ea0
commit
9fe739debb
@ -35,9 +35,16 @@ export class InventoryCallbacks
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
/** Handle client/game/profile/items/moving Move event */
|
/** Handle client/game/profile/items/moving Move event */
|
||||||
public moveItem(pmcData: IPmcData, body: IInventoryMoveRequestData, sessionID: string): IItemEventRouterResponse
|
public moveItem(
|
||||||
|
pmcData: IPmcData,
|
||||||
|
body: IInventoryMoveRequestData,
|
||||||
|
sessionID: string,
|
||||||
|
output: IItemEventRouterResponse,
|
||||||
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
return this.inventoryController.moveItem(pmcData, body, sessionID);
|
this.inventoryController.moveItem(pmcData, body, sessionID, output);
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle Remove event */
|
/** Handle Remove event */
|
||||||
|
@ -86,13 +86,12 @@ export class InventoryController
|
|||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
moveRequest: IInventoryMoveRequestData,
|
moveRequest: IInventoryMoveRequestData,
|
||||||
sessionID: string,
|
sessionID: string,
|
||||||
): IItemEventRouterResponse
|
output: IItemEventRouterResponse,
|
||||||
|
): void
|
||||||
{
|
{
|
||||||
const output = this.eventOutputHolder.getOutput(sessionID);
|
|
||||||
|
|
||||||
if (output.warnings.length > 0)
|
if (output.warnings.length > 0)
|
||||||
{
|
{
|
||||||
return output;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes made to result apply to character inventory
|
// Changes made to result apply to character inventory
|
||||||
@ -102,7 +101,8 @@ export class InventoryController
|
|||||||
// Dont move items from trader to profile, this can happen when editing a traders preset weapons
|
// Dont move items from trader to profile, this can happen when editing a traders preset weapons
|
||||||
if (moveRequest.fromOwner?.type === "Trader" && !ownerInventoryItems.isMail)
|
if (moveRequest.fromOwner?.type === "Trader" && !ownerInventoryItems.isMail)
|
||||||
{
|
{
|
||||||
return this.getTraderExploitErrorResponse(output);
|
this.getTraderExploitErrorResponse(output);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for item in inventory before allowing internal transfer
|
// Check for item in inventory before allowing internal transfer
|
||||||
@ -111,13 +111,15 @@ export class InventoryController
|
|||||||
if (!originalItemLocation)
|
if (!originalItemLocation)
|
||||||
{
|
{
|
||||||
// Internal item move but item never existed, possible dupe glitch
|
// Internal item move but item never existed, possible dupe glitch
|
||||||
return this.getTraderExploitErrorResponse(output);
|
this.getTraderExploitErrorResponse(output);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const moveResult = this.inventoryHelper.moveItemInternal(pmcData, ownerInventoryItems.from, moveRequest);
|
const moveResult = this.inventoryHelper.moveItemInternal(pmcData, ownerInventoryItems.from, moveRequest);
|
||||||
if (!moveResult.success)
|
if (!moveResult.success)
|
||||||
{
|
{
|
||||||
return this.httpResponseUtil.appendErrorToOutput(output, moveResult.errorMessage);
|
this.httpResponseUtil.appendErrorToOutput(output, moveResult.errorMessage);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item is moving into or out of place of fame dogtag slot
|
// Item is moving into or out of place of fame dogtag slot
|
||||||
@ -130,7 +132,6 @@ export class InventoryController
|
|||||||
{
|
{
|
||||||
this.inventoryHelper.moveItemToProfile(ownerInventoryItems.from, ownerInventoryItems.to, moveRequest);
|
this.inventoryHelper.moveItemToProfile(ownerInventoryItems.from, ownerInventoryItems.to, moveRequest);
|
||||||
}
|
}
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +75,13 @@ export class DynamicRouter extends Router
|
|||||||
// So instead I added the definition
|
// So instead I added the definition
|
||||||
export class ItemEventRouterDefinition extends Router
|
export class ItemEventRouterDefinition extends Router
|
||||||
{
|
{
|
||||||
public handleItemEvent(url: string, pmcData: IPmcData, body: any, sessionID: string): IItemEventRouterResponse
|
public handleItemEvent(
|
||||||
|
url: string,
|
||||||
|
pmcData: IPmcData,
|
||||||
|
body: any,
|
||||||
|
sessionID: string,
|
||||||
|
output: IItemEventRouterResponse,
|
||||||
|
): void
|
||||||
{
|
{
|
||||||
throw new Error("This method needs to be overrode by the router classes");
|
throw new Error("This method needs to be overrode by the router classes");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ export class ItemEventRouter
|
|||||||
{
|
{
|
||||||
this.eventOutputHolder.resetOutput(sessionID);
|
this.eventOutputHolder.resetOutput(sessionID);
|
||||||
|
|
||||||
let result = this.eventOutputHolder.getOutput(sessionID);
|
const output = this.eventOutputHolder.getOutput(sessionID);
|
||||||
|
|
||||||
for (const body of info.data)
|
for (const body of info.data)
|
||||||
{
|
{
|
||||||
@ -39,7 +39,11 @@ export class ItemEventRouter
|
|||||||
if (eventRouter)
|
if (eventRouter)
|
||||||
{
|
{
|
||||||
this.logger.debug(`event: ${body.Action}`);
|
this.logger.debug(`event: ${body.Action}`);
|
||||||
result = eventRouter.handleItemEvent(body.Action, pmcData, body, sessionID);
|
eventRouter.handleItemEvent(body.Action, pmcData, body, sessionID, output);
|
||||||
|
if (output.warnings.length > 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -50,6 +54,6 @@ export class ItemEventRouter
|
|||||||
|
|
||||||
this.eventOutputHolder.updateOutputProperties(sessionID);
|
this.eventOutputHolder.updateOutputProperties(sessionID);
|
||||||
|
|
||||||
return result;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,13 @@ export class InventoryItemEventRouter extends ItemEventRouterDefinition
|
|||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
body: any,
|
body: any,
|
||||||
sessionID: string,
|
sessionID: string,
|
||||||
|
output: IItemEventRouterResponse,
|
||||||
): IItemEventRouterResponse
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
switch (url)
|
switch (url)
|
||||||
{
|
{
|
||||||
case ItemEventActions.MOVE:
|
case ItemEventActions.MOVE:
|
||||||
return this.inventoryCallbacks.moveItem(pmcData, body, sessionID);
|
return this.inventoryCallbacks.moveItem(pmcData, body, sessionID, output);
|
||||||
case ItemEventActions.REMOVE:
|
case ItemEventActions.REMOVE:
|
||||||
return this.inventoryCallbacks.removeItem(pmcData, body, sessionID);
|
return this.inventoryCallbacks.removeItem(pmcData, body, sessionID);
|
||||||
case ItemEventActions.SPLIT:
|
case ItemEventActions.SPLIT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user