Clean up passing IItemEventRouterResponse around and then returning it in same function

This commit is contained in:
Dev 2024-02-14 14:59:43 +00:00
parent b294766304
commit 99df88ec24
8 changed files with 128 additions and 120 deletions

View File

@ -145,9 +145,12 @@ export class HideoutCallbacks implements OnUpdate
pmcData: IPmcData, pmcData: IPmcData,
request: IHandleQTEEventRequestData, request: IHandleQTEEventRequestData,
sessionId: string, sessionId: string,
output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.hideoutController.handleQTEEventOutcome(sessionId, pmcData, request); this.hideoutController.handleQTEEventOutcome(sessionId, pmcData, request, output);
return output;
} }
/** /**

View File

@ -55,7 +55,9 @@ export class InventoryCallbacks
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.discardItem(pmcData, body, sessionID, output); this.inventoryController.discardItem(pmcData, body, sessionID, output);
return output;
} }
/** Handle Split event */ /** Handle Split event */
@ -81,12 +83,12 @@ export class InventoryCallbacks
public transferItem( public transferItem(
pmcData: IPmcData, pmcData: IPmcData,
body: IInventoryTransferRequestData, request: IInventoryTransferRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.transferItem(pmcData, body, sessionID, output); return this.inventoryController.transferItem(pmcData, request, sessionID, output);
} }
/** Handle Swap */ /** Handle Swap */
@ -111,14 +113,28 @@ export class InventoryCallbacks
return this.inventoryController.tagItem(pmcData, body, sessionID); return this.inventoryController.tagItem(pmcData, body, sessionID);
} }
public bindItem(pmcData: IPmcData, body: IInventoryBindRequestData, sessionID: string): IItemEventRouterResponse public bindItem(
pmcData: IPmcData,
body: IInventoryBindRequestData,
sessionID: string,
output: IItemEventRouterResponse,
): IItemEventRouterResponse
{ {
return this.inventoryController.bindItem(pmcData, body, sessionID); this.inventoryController.bindItem(pmcData, body, sessionID);
return output;
} }
public unbindItem(pmcData: IPmcData, body: IInventoryBindRequestData, sessionID: string): IItemEventRouterResponse public unbindItem(
pmcData: IPmcData,
body: IInventoryBindRequestData,
sessionID: string,
output: IItemEventRouterResponse,
): IItemEventRouterResponse
{ {
return this.inventoryController.unbindItem(pmcData, body, sessionID); this.inventoryController.unbindItem(pmcData, body, sessionID, output);
return output;
} }
public examineItem( public examineItem(
@ -146,9 +162,12 @@ export class InventoryCallbacks
pmcData: IPmcData, pmcData: IPmcData,
body: IInventorySortRequestData, body: IInventorySortRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.sortInventory(pmcData, body, sessionID); this.inventoryController.sortInventory(pmcData, body, sessionID);
return output;
} }
public createMapMarker( public createMapMarker(
@ -158,7 +177,9 @@ export class InventoryCallbacks
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.createMapMarker(pmcData, body, sessionID, output); this.inventoryController.createMapMarker(pmcData, body, sessionID, output);
return output;
} }
public deleteMapMarker( public deleteMapMarker(
@ -168,7 +189,9 @@ export class InventoryCallbacks
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.deleteMapMarker(pmcData, body, sessionID, output); this.inventoryController.deleteMapMarker(pmcData, body, sessionID, output);
return output;
} }
public editMapMarker( public editMapMarker(
@ -178,7 +201,9 @@ export class InventoryCallbacks
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.editMapMarker(pmcData, body, sessionID, output); this.inventoryController.editMapMarker(pmcData, body, sessionID, output);
return output;
} }
/** Handle OpenRandomLootContainer */ /** Handle OpenRandomLootContainer */
@ -189,21 +214,33 @@ export class InventoryCallbacks
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.openRandomLootContainer(pmcData, body, sessionID, output); this.inventoryController.openRandomLootContainer(pmcData, body, sessionID, output);
return output;
} }
public redeemProfileReward( public redeemProfileReward(
pmcData: IPmcData, pmcData: IPmcData,
body: IRedeemProfileRequestData, body: IRedeemProfileRequestData,
sessionId: string, sessionId: string,
output: IItemEventRouterResponse,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
return this.inventoryController.redeemProfileReward(pmcData, body, sessionId); this.inventoryController.redeemProfileReward(pmcData, body, sessionId);
return output;
} }
public setFavoriteItem(pmcData: IPmcData, body: ISetFavoriteItems, sessionId: string): IItemEventRouterResponse public setFavoriteItem(
pmcData: IPmcData,
body: ISetFavoriteItems,
sessionId: string,
output: IItemEventRouterResponse,
): IItemEventRouterResponse
{ {
return this.inventoryController.setFavoriteItem(pmcData, body, sessionId); this.inventoryController.setFavoriteItem(pmcData, body, sessionId);
return output;
} }
/** /**

View File

@ -1099,7 +1099,8 @@ export class HideoutController
sessionId: string, sessionId: string,
pmcData: IPmcData, pmcData: IPmcData,
request: IHandleQTEEventRequestData, request: IHandleQTEEventRequestData,
): IItemEventRouterResponse output: IItemEventRouterResponse,
): void
{ {
// { // {
// "Action": "HideoutQuickTimeEvent", // "Action": "HideoutQuickTimeEvent",
@ -1122,8 +1123,6 @@ export class HideoutController
{ {
pmcData.Health.Hydration.Current = 1; pmcData.Health.Hydration.Current = 1;
} }
return this.eventOutputHolder.getOutput(sessionId);
} }
/** /**

View File

@ -81,7 +81,7 @@ export class InventoryController
* @param pmcData Profile * @param pmcData Profile
* @param moveRequest Move request data * @param moveRequest Move request data
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse * @param output Client response
*/ */
public moveItem( public moveItem(
pmcData: IPmcData, pmcData: IPmcData,
@ -102,7 +102,7 @@ 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)
{ {
this.getTraderExploitErrorResponse(output); this.appendTraderExploitErrorResponse(output);
return; return;
} }
@ -111,7 +111,7 @@ 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
this.getTraderExploitErrorResponse(output); this.appendTraderExploitErrorResponse(output);
return; return;
} }
@ -141,29 +141,15 @@ export class InventoryController
* @param output Item event router response * @param output Item event router response
* @returns Item event router response * @returns Item event router response
*/ */
protected getTraderExploitErrorResponse(output: IItemEventRouterResponse): IItemEventRouterResponse protected appendTraderExploitErrorResponse(output: IItemEventRouterResponse): void
{ {
return this.httpResponseUtil.appendErrorToOutput( this.httpResponseUtil.appendErrorToOutput(
output, output,
this.localisationService.getText("inventory-edit_trader_item"), this.localisationService.getText("inventory-edit_trader_item"),
<BackendErrorCodes>228, <BackendErrorCodes>228,
); );
} }
/**
* Remove Item from Profile
* Deep tree item deletion, also removes items from insurance list
*/
public removeItem(
pmcData: IPmcData,
itemId: string,
sessionID: string,
output: IItemEventRouterResponse = undefined,
): IItemEventRouterResponse
{
return this.inventoryHelper.removeItem(pmcData, itemId, sessionID, output);
}
/** /**
* Handle Remove event * Handle Remove event
* Implements functionality "Discard" from Main menu (Stash etc.) * Implements functionality "Discard" from Main menu (Stash etc.)
@ -171,23 +157,23 @@ export class InventoryController
*/ */
public discardItem( public discardItem(
pmcData: IPmcData, pmcData: IPmcData,
body: IInventoryRemoveRequestData, request: IInventoryRemoveRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
if (body.fromOwner?.type === "Mail") if (request.fromOwner?.type === "Mail")
{ {
this.inventoryHelper.removeItemAndChildrenFromMailRewards(sessionID, body, output); this.inventoryHelper.removeItemAndChildrenFromMailRewards(sessionID, request, output);
return output; return;
} }
const profileToRemoveItemFrom = (!body.fromOwner || body.fromOwner.id === pmcData._id) const profileToRemoveItemFrom = (!request.fromOwner || request.fromOwner.id === pmcData._id)
? pmcData ? pmcData
: this.profileHelper.getFullProfile(sessionID).characters.scav; : this.profileHelper.getFullProfile(sessionID).characters.scav;
return this.inventoryHelper.removeItem(profileToRemoveItemFrom, body.item, sessionID, output); this.inventoryHelper.removeItem(profileToRemoveItemFrom, request.item, sessionID, output);
} }
/** /**
@ -196,6 +182,7 @@ export class InventoryController
* @param pmcData Player profile (unused, getOwnerInventoryItems() gets profile) * @param pmcData Player profile (unused, getOwnerInventoryItems() gets profile)
* @param request Split request * @param request Split request
* @param sessionID Session/player id * @param sessionID Session/player id
* @param output Client response
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
public splitItem( public splitItem(
@ -258,6 +245,7 @@ export class InventoryController
* @param pmcData Player profile (unused, getOwnerInventoryItems() gets profile) * @param pmcData Player profile (unused, getOwnerInventoryItems() gets profile)
* @param body Merge request * @param body Merge request
* @param sessionID Player id * @param sessionID Player id
* @param output Client response
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
public mergeItem( public mergeItem(
@ -277,7 +265,9 @@ export class InventoryController
const errorMessage = `Unable to merge stacks as source item: ${body.with} cannot be found`; const errorMessage = `Unable to merge stacks as source item: ${body.with} cannot be found`;
this.logger.error(errorMessage); this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage); this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return output;
} }
// Get item being merged into // Get item being merged into
@ -287,7 +277,9 @@ export class InventoryController
const errorMessage = `Unable to merge stacks as destination item: ${body.with} cannot be found`; const errorMessage = `Unable to merge stacks as destination item: ${body.with} cannot be found`;
this.logger.error(errorMessage); this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage); this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return output;
} }
if (!(destinationItem.upd?.StackObjectsCount)) if (!(destinationItem.upd?.StackObjectsCount))
@ -321,7 +313,9 @@ export class InventoryController
const errorMessage = `Unable to find item: ${sourceItem._id} to remove from sender inventory`; const errorMessage = `Unable to find item: ${sourceItem._id} to remove from sender inventory`;
this.logger.error(errorMessage); this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage); this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return output;
} }
inventoryItems.from.splice(indexOfItemToRemove, 1); // remove source item from 'from' inventory inventoryItems.from.splice(indexOfItemToRemove, 1); // remove source item from 'from' inventory
@ -336,6 +330,7 @@ export class InventoryController
* @param pmcData Player profile * @param pmcData Player profile
* @param body Transfer request * @param body Transfer request
* @param sessionID Session id * @param sessionID Session id
* @param output Client response
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
public transferItem( public transferItem(
@ -347,6 +342,7 @@ export class InventoryController
{ {
let sourceItem: Item = null; let sourceItem: Item = null;
let destinationItem: Item = null; let destinationItem: Item = null;
for (const iterItem of pmcData.Inventory.items) for (const iterItem of pmcData.Inventory.items)
{ {
if (iterItem._id === body.item) if (iterItem._id === body.item)
@ -372,7 +368,9 @@ export class InventoryController
const errorMessage = `Unable to transfer stack, cannot find source: ${body.item}`; const errorMessage = `Unable to transfer stack, cannot find source: ${body.item}`;
this.logger.error(errorMessage); this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage); this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return output;
} }
if (destinationItem === null) if (destinationItem === null)
@ -380,7 +378,9 @@ export class InventoryController
const errorMessage = `Unable to transfer stack, cannot find destination: ${body.with} `; const errorMessage = `Unable to transfer stack, cannot find destination: ${body.with} `;
this.logger.error(errorMessage); this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage); this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return output;
} }
let sourceStackCount = 1; let sourceStackCount = 1;
@ -479,6 +479,7 @@ export class InventoryController
playerData = this.profileHelper.getScavProfile(sessionID); playerData = this.profileHelper.getScavProfile(sessionID);
} }
// TODO - replace with single .find() call
for (const item of playerData.Inventory.items) for (const item of playerData.Inventory.items)
{ {
if (item._id && item._id === body.item) if (item._id && item._id === body.item)
@ -500,6 +501,7 @@ export class InventoryController
*/ */
public toggleItem(pmcData: IPmcData, body: IInventoryToggleRequestData, sessionID: string): IItemEventRouterResponse public toggleItem(pmcData: IPmcData, body: IInventoryToggleRequestData, sessionID: string): IItemEventRouterResponse
{ {
// May need to reassign to scav profile
let playerData = pmcData; let playerData = pmcData;
// Fix for toggling items while on they're in the Scav inventory // Fix for toggling items while on they're in the Scav inventory
@ -538,6 +540,7 @@ export class InventoryController
*/ */
public tagItem(pmcData: IPmcData, body: IInventoryTagRequestData, sessionID: string): IItemEventRouterResponse public tagItem(pmcData: IPmcData, body: IInventoryTagRequestData, sessionID: string): IItemEventRouterResponse
{ {
// TODO - replace with single .find() call
for (const item of pmcData.Inventory.items) for (const item of pmcData.Inventory.items)
{ {
if (item._id === body.item) if (item._id === body.item)
@ -566,12 +569,9 @@ export class InventoryController
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
public bindItem( public bindItem(pmcData: IPmcData, bindRequest: IInventoryBindRequestData, sessionID: string): void
pmcData: IPmcData,
bindRequest: IInventoryBindRequestData,
sessionID: string,
): IItemEventRouterResponse
{ {
// TODO - replace with single .find() call
for (const index in pmcData.Inventory.fastPanel) for (const index in pmcData.Inventory.fastPanel)
{ {
// Find item with existing item in it and remove existing binding, you cant have same item bound to more than 1 slot // Find item with existing item in it and remove existing binding, you cant have same item bound to more than 1 slot
@ -585,8 +585,6 @@ export class InventoryController
// Create link between fast panel slot and requested item // Create link between fast panel slot and requested item
pmcData.Inventory.fastPanel[bindRequest.index] = bindRequest.item; pmcData.Inventory.fastPanel[bindRequest.index] = bindRequest.item;
return this.eventOutputHolder.getOutput(sessionID);
} }
/** /**
@ -595,18 +593,17 @@ export class InventoryController
* @param pmcData Player profile * @param pmcData Player profile
* @param bindRequest Request object * @param bindRequest Request object
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse * @param output Client response
*/ */
public unbindItem( public unbindItem(
pmcData: IPmcData, pmcData: IPmcData,
request: IInventoryBindRequestData, request: IInventoryBindRequestData,
sessionID: string, sessionID: string,
): IItemEventRouterResponse output: IItemEventRouterResponse,
): void
{ {
// Remove kvp from requested fast panel index // Remove kvp from requested fast panel index
delete pmcData.Inventory.fastPanel[request.index]; delete pmcData.Inventory.fastPanel[request.index];
return this.eventOutputHolder.getOutput(sessionID);
} }
/** /**
@ -614,6 +611,7 @@ export class InventoryController
* @param pmcData player profile * @param pmcData player profile
* @param body request object * @param body request object
* @param sessionID session id * @param sessionID session id
* @param output Client response
* @returns response * @returns response
*/ */
public examineItem( public examineItem(
@ -776,13 +774,8 @@ export class InventoryController
* @param pmcData Player profile * @param pmcData Player profile
* @param request sort request * @param request sort request
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse
*/ */
public sortInventory( public sortInventory(pmcData: IPmcData, request: IInventorySortRequestData, sessionID: string): void
pmcData: IPmcData,
request: IInventorySortRequestData,
sessionID: string,
): IItemEventRouterResponse
{ {
for (const change of request.changedItems) for (const change of request.changedItems)
{ {
@ -807,8 +800,6 @@ export class InventoryController
delete inventoryItem.location; delete inventoryItem.location;
} }
} }
return this.eventOutputHolder.getOutput(sessionID);
} }
/** /**
@ -816,6 +807,7 @@ export class InventoryController
* @param pmcData Player profile * @param pmcData Player profile
* @param request Add marker request * @param request Add marker request
* @param sessionID Session id * @param sessionID Session id
* @param output Client response
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
public createMapMarker( public createMapMarker(
@ -823,7 +815,7 @@ export class InventoryController
request: IInventoryCreateMarkerRequestData, request: IInventoryCreateMarkerRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
// Get map from inventory // Get map from inventory
const mapItem = pmcData.Inventory.items.find((i) => i._id === request.item); const mapItem = pmcData.Inventory.items.find((i) => i._id === request.item);
@ -835,8 +827,6 @@ export class InventoryController
// sync with client // sync with client
output.profileChanges[sessionID].items.change.push(mapItem); output.profileChanges[sessionID].items.change.push(mapItem);
return output;
} }
/** /**
@ -844,14 +834,14 @@ export class InventoryController
* @param pmcData Player profile * @param pmcData Player profile
* @param request Delete marker request * @param request Delete marker request
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse * @param output Client response
*/ */
public deleteMapMarker( public deleteMapMarker(
pmcData: IPmcData, pmcData: IPmcData,
request: IInventoryDeleteMarkerRequestData, request: IInventoryDeleteMarkerRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
// Get map from inventory // Get map from inventory
const mapItem = pmcData.Inventory.items.find((i) => i._id === request.item); const mapItem = pmcData.Inventory.items.find((i) => i._id === request.item);
@ -865,7 +855,6 @@ export class InventoryController
// sync with client // sync with client
output.profileChanges[sessionID].items.change.push(mapItem); output.profileChanges[sessionID].items.change.push(mapItem);
return output;
} }
/** /**
@ -873,14 +862,14 @@ export class InventoryController
* @param pmcData Player profile * @param pmcData Player profile
* @param request Edit marker request * @param request Edit marker request
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse * @param output Client response
*/ */
public editMapMarker( public editMapMarker(
pmcData: IPmcData, pmcData: IPmcData,
request: IInventoryEditMarkerRequestData, request: IInventoryEditMarkerRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
// Get map from inventory // Get map from inventory
const mapItem = pmcData.Inventory.items.find((i) => i._id === request.item); const mapItem = pmcData.Inventory.items.find((i) => i._id === request.item);
@ -892,8 +881,6 @@ export class InventoryController
// sync with client // sync with client
output.profileChanges[sessionID].items.change.push(mapItem); output.profileChanges[sessionID].items.change.push(mapItem);
return output;
} }
/** /**
@ -910,16 +897,16 @@ export class InventoryController
* Handle OpenRandomLootContainer event * Handle OpenRandomLootContainer event
* Handle event fired when a container is unpacked (currently only the halloween pumpkin) * Handle event fired when a container is unpacked (currently only the halloween pumpkin)
* @param pmcData Profile data * @param pmcData Profile data
* @param body open loot container request data * @param body Open loot container request data
* @param sessionID Session id * @param sessionID Session id
* @returns IItemEventRouterResponse * @param output Client response
*/ */
public openRandomLootContainer( public openRandomLootContainer(
pmcData: IPmcData, pmcData: IPmcData,
body: IOpenRandomLootContainerRequestData, body: IOpenRandomLootContainerRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
/** Container player opened in their inventory */ /** Container player opened in their inventory */
const openedItem = pmcData.Inventory.items.find((item) => item._id === body.item); const openedItem = pmcData.Inventory.items.find((item) => item._id === body.item);
@ -958,23 +945,15 @@ export class InventoryController
this.inventoryHelper.addItemsToStash(sessionID, addItemsRequest, pmcData, output); this.inventoryHelper.addItemsToStash(sessionID, addItemsRequest, pmcData, output);
if (output.warnings.length > 0) if (output.warnings.length > 0)
{ {
return output; return;
} }
// Find and delete opened container item from player inventory // Find and delete opened container item from player inventory
this.inventoryHelper.removeItem(pmcData, body.item, sessionID, output); this.inventoryHelper.removeItem(pmcData, body.item, sessionID, output);
return output;
} }
public redeemProfileReward( public redeemProfileReward(pmcData: IPmcData, request: IRedeemProfileRequestData, sessionId: string): void
pmcData: IPmcData,
request: IRedeemProfileRequestData,
sessionId: string,
): IItemEventRouterResponse
{ {
const output = this.eventOutputHolder.getOutput(sessionId);
const fullProfile = this.profileHelper.getFullProfile(sessionId); const fullProfile = this.profileHelper.getFullProfile(sessionId);
for (const event of request.events) for (const event of request.events)
{ {
@ -1022,14 +1001,10 @@ export class InventoryController
break; break;
} }
} }
return output;
} }
public setFavoriteItem(pmcData: IPmcData, request: ISetFavoriteItems, sessionId: string): IItemEventRouterResponse public setFavoriteItem(pmcData: IPmcData, request: ISetFavoriteItems, sessionId: string): void
{ {
const output = this.eventOutputHolder.getOutput(sessionId);
if (!pmcData.Inventory.favoriteItems) if (!pmcData.Inventory.favoriteItems)
{ {
pmcData.Inventory.favoriteItems = []; pmcData.Inventory.favoriteItems = [];
@ -1048,7 +1023,5 @@ export class InventoryController
pmcData.Inventory.favoriteItems.push(itemId); pmcData.Inventory.favoriteItems.push(itemId);
} }
} }
return output;
} }
} }

View File

@ -512,10 +512,10 @@ export class RagfairController
this.ragfairTaxService.clearStoredOfferTaxById(offerRequest.items[0]); this.ragfairTaxService.clearStoredOfferTaxById(offerRequest.items[0]);
const buyTradeRequest = this.createBuyTradeRequestObject("RUB", tax); const buyTradeRequest = this.createBuyTradeRequestObject("RUB", tax);
output = this.paymentService.payMoney(pmcData, buyTradeRequest, sessionID, output); this.paymentService.payMoney(pmcData, buyTradeRequest, sessionID, output);
if (output.warnings.length > 0) if (output.warnings.length > 0)
{ {
output = this.httpResponse.appendErrorToOutput( this.httpResponse.appendErrorToOutput(
output, output,
this.localisationService.getText("ragfair-unable_to_pay_commission_fee", tax), this.localisationService.getText("ragfair-unable_to_pay_commission_fee", tax),
); );

View File

@ -472,21 +472,20 @@ export class InventoryHelper
* @param profile Profile to remove item from (pmc or scav) * @param profile Profile to remove item from (pmc or scav)
* @param itemId Items id to remove * @param itemId Items id to remove
* @param sessionID Session id * @param sessionID Session id
* @param output Existing IItemEventRouterResponse object to append data to, creates new one by default if not supplied * @param output OPTIONAL - IItemEventRouterResponse
* @returns IItemEventRouterResponse
*/ */
public removeItem( public removeItem(
profile: IPmcData, profile: IPmcData,
itemId: string, itemId: string,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse = undefined, output: IItemEventRouterResponse = undefined,
): IItemEventRouterResponse ): void
{ {
if (!itemId) if (!itemId)
{ {
this.logger.warning("No itemId supplied, unable to remove item from inventory"); this.logger.warning("No itemId supplied, unable to remove item from inventory");
return output; return;
} }
// Get children of item, they get deleted too // Get children of item, they get deleted too
@ -523,8 +522,6 @@ export class InventoryHelper
insuredItems.splice(insuredIndex, 1); insuredItems.splice(insuredIndex, 1);
} }
} }
return output;
} }
public removeItemAndChildrenFromMailRewards( public removeItemAndChildrenFromMailRewards(

View File

@ -75,15 +75,15 @@ export class InventoryItemEventRouter extends ItemEventRouterDefinition
case ItemEventActions.TAG: case ItemEventActions.TAG:
return this.inventoryCallbacks.tagItem(pmcData, body, sessionID); return this.inventoryCallbacks.tagItem(pmcData, body, sessionID);
case ItemEventActions.BIND: case ItemEventActions.BIND:
return this.inventoryCallbacks.bindItem(pmcData, body, sessionID); return this.inventoryCallbacks.bindItem(pmcData, body, sessionID, output);
case ItemEventActions.UNBIND: case ItemEventActions.UNBIND:
return this.inventoryCallbacks.unbindItem(pmcData, body, sessionID); return this.inventoryCallbacks.unbindItem(pmcData, body, sessionID, output);
case ItemEventActions.EXAMINE: case ItemEventActions.EXAMINE:
return this.inventoryCallbacks.examineItem(pmcData, body, sessionID, output); return this.inventoryCallbacks.examineItem(pmcData, body, sessionID, output);
case ItemEventActions.READ_ENCYCLOPEDIA: case ItemEventActions.READ_ENCYCLOPEDIA:
return this.inventoryCallbacks.readEncyclopedia(pmcData, body, sessionID); return this.inventoryCallbacks.readEncyclopedia(pmcData, body, sessionID);
case ItemEventActions.APPLY_INVENTORY_CHANGES: case ItemEventActions.APPLY_INVENTORY_CHANGES:
return this.inventoryCallbacks.sortInventory(pmcData, body, sessionID); return this.inventoryCallbacks.sortInventory(pmcData, body, sessionID, output);
case ItemEventActions.CREATE_MAP_MARKER: case ItemEventActions.CREATE_MAP_MARKER:
return this.inventoryCallbacks.createMapMarker(pmcData, body, sessionID, output); return this.inventoryCallbacks.createMapMarker(pmcData, body, sessionID, output);
case ItemEventActions.DELETE_MAP_MARKER: case ItemEventActions.DELETE_MAP_MARKER:
@ -93,11 +93,11 @@ export class InventoryItemEventRouter extends ItemEventRouterDefinition
case ItemEventActions.OPEN_RANDOM_LOOT_CONTAINER: case ItemEventActions.OPEN_RANDOM_LOOT_CONTAINER:
return this.inventoryCallbacks.openRandomLootContainer(pmcData, body, sessionID, output); return this.inventoryCallbacks.openRandomLootContainer(pmcData, body, sessionID, output);
case ItemEventActions.HIDEOUT_QTE_EVENT: case ItemEventActions.HIDEOUT_QTE_EVENT:
return this.hideoutCallbacks.handleQTEEvent(pmcData, body, sessionID); return this.hideoutCallbacks.handleQTEEvent(pmcData, body, sessionID, output);
case ItemEventActions.REDEEM_PROFILE_REWARD: case ItemEventActions.REDEEM_PROFILE_REWARD:
return this.inventoryCallbacks.redeemProfileReward(pmcData, body, sessionID); return this.inventoryCallbacks.redeemProfileReward(pmcData, body, sessionID, output);
case ItemEventActions.SET_FAVORITE_ITEMS: case ItemEventActions.SET_FAVORITE_ITEMS:
return this.inventoryCallbacks.setFavoriteItem(pmcData, body, sessionID); return this.inventoryCallbacks.setFavoriteItem(pmcData, body, sessionID, output);
case ItemEventActions.QUEST_FAIL: case ItemEventActions.QUEST_FAIL:
return this.inventoryCallbacks.failQuest(pmcData, body, sessionID, output); return this.inventoryCallbacks.failQuest(pmcData, body, sessionID, output);
default: default:

View File

@ -37,17 +37,17 @@ export class PaymentService
/** /**
* Take money and insert items into return to server request * Take money and insert items into return to server request
* @param {IPmcData} pmcData Player profile * @param pmcData Pmc profile
* @param {IProcessBuyTradeRequestData} request * @param request Buy item request
* @param {string} sessionID * @param sessionID Session id
* @returns IItemEventRouterResponse * @param output Client response
*/ */
public payMoney( public payMoney(
pmcData: IPmcData, pmcData: IPmcData,
request: IProcessBuyTradeRequestData, request: IProcessBuyTradeRequestData,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
// May need to convert to trader currency // May need to convert to trader currency
const trader = this.traderHelper.getTrader(request.tid, sessionID); const trader = this.traderHelper.getTrader(request.tid, sessionID);
@ -100,7 +100,7 @@ export class PaymentService
// If there are warnings, exit early. // If there are warnings, exit early.
if (output.warnings.length > 0) if (output.warnings.length > 0)
{ {
return output; return;
} }
// Convert the amount to the trader's currency and update the sales sum. // Convert the amount to the trader's currency and update the sales sum.
@ -128,7 +128,6 @@ export class PaymentService
this.traderHelper.lvlUp(request.tid, pmcData); this.traderHelper.lvlUp(request.tid, pmcData);
this.logger.debug("Item(s) taken. Status OK."); this.logger.debug("Item(s) taken. Status OK.");
return output;
} }
/** /**