mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Reset client output object data at end of function, instead of at start - fixes issue where old profile change data persists in memory after player logs out and into another profile
Pass output into failquest function
This commit is contained in:
parent
4232ba6db1
commit
f7a16e15f9
@ -206,8 +206,13 @@ export class InventoryCallbacks
|
|||||||
* TODO - MOVE INTO QUEST CODE
|
* TODO - MOVE INTO QUEST CODE
|
||||||
* Handle game/profile/items/moving - QuestFail
|
* Handle game/profile/items/moving - QuestFail
|
||||||
*/
|
*/
|
||||||
public failQuest(pmcData: IPmcData, request: IFailQuestRequestData, sessionID: string): IItemEventRouterResponse
|
public failQuest(
|
||||||
|
pmcData: IPmcData,
|
||||||
|
request: IFailQuestRequestData,
|
||||||
|
sessionID: string,
|
||||||
|
output: IItemEventRouterResponse,
|
||||||
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
return this.questController.failQuest(pmcData, request, sessionID);
|
return this.questController.failQuest(pmcData, request, sessionID, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,7 +842,10 @@ export class QuestController
|
|||||||
// element `location` properties of the parent so they are sequential, while retaining order
|
// element `location` properties of the parent so they are sequential, while retaining order
|
||||||
if (typeof removedItem.location === "number")
|
if (typeof removedItem.location === "number")
|
||||||
{
|
{
|
||||||
const childItems = this.itemHelper.findAndReturnChildrenAsItems(pmcData.Inventory.items, removedItem.parentId);
|
const childItems = this.itemHelper.findAndReturnChildrenAsItems(
|
||||||
|
pmcData.Inventory.items,
|
||||||
|
removedItem.parentId,
|
||||||
|
);
|
||||||
childItems.shift(); // Remove the parent
|
childItems.shift(); // Remove the parent
|
||||||
|
|
||||||
// Sort by the current `location` and update
|
// Sort by the current `location` and update
|
||||||
@ -948,8 +951,13 @@ export class QuestController
|
|||||||
* @param sessionID Session id
|
* @param sessionID Session id
|
||||||
* @returns IItemEventRouterResponse
|
* @returns IItemEventRouterResponse
|
||||||
*/
|
*/
|
||||||
public failQuest(pmcData: IPmcData, request: IFailQuestRequestData, sessionID: string): IItemEventRouterResponse
|
public failQuest(
|
||||||
|
pmcData: IPmcData,
|
||||||
|
request: IFailQuestRequestData,
|
||||||
|
sessionID: string,
|
||||||
|
output: IItemEventRouterResponse,
|
||||||
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
return this.questHelper.failQuest(pmcData, request, sessionID);
|
return this.questHelper.failQuest(pmcData, request, sessionID, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,14 @@ import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEve
|
|||||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||||
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
|
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
|
||||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||||
|
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ItemEventRouter
|
export class ItemEventRouter
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
@inject("WinstonLogger") protected logger: ILogger,
|
@inject("WinstonLogger") protected logger: ILogger,
|
||||||
|
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||||
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||||
@injectAll("IERouters") protected itemEventRouters: ItemEventRouterDefinition[],
|
@injectAll("IERouters") protected itemEventRouters: ItemEventRouterDefinition[],
|
||||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||||
@ -27,8 +29,6 @@ export class ItemEventRouter
|
|||||||
*/
|
*/
|
||||||
public handleEvents(info: IItemEventRouterRequest, sessionID: string): IItemEventRouterResponse
|
public handleEvents(info: IItemEventRouterRequest, sessionID: string): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
this.eventOutputHolder.resetOutput(sessionID);
|
|
||||||
|
|
||||||
const output = this.eventOutputHolder.getOutput(sessionID);
|
const output = this.eventOutputHolder.getOutput(sessionID);
|
||||||
|
|
||||||
for (const body of info.data)
|
for (const body of info.data)
|
||||||
@ -54,6 +54,10 @@ export class ItemEventRouter
|
|||||||
|
|
||||||
this.eventOutputHolder.updateOutputProperties(sessionID);
|
this.eventOutputHolder.updateOutputProperties(sessionID);
|
||||||
|
|
||||||
return output;
|
// Clone output before resetting the output object ready for use next time
|
||||||
|
const outputClone = this.jsonUtil.clone(output);
|
||||||
|
this.eventOutputHolder.resetOutput(sessionID);
|
||||||
|
|
||||||
|
return outputClone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ export class InventoryItemEventRouter extends ItemEventRouterDefinition
|
|||||||
case ItemEventActions.SET_FAVORITE_ITEMS:
|
case ItemEventActions.SET_FAVORITE_ITEMS:
|
||||||
return this.inventoryCallbacks.setFavoriteItem(pmcData, body, sessionID);
|
return this.inventoryCallbacks.setFavoriteItem(pmcData, body, sessionID);
|
||||||
case ItemEventActions.QUEST_FAIL:
|
case ItemEventActions.QUEST_FAIL:
|
||||||
return this.inventoryCallbacks.failQuest(pmcData, body, sessionID);
|
return this.inventoryCallbacks.failQuest(pmcData, body, sessionID, output);
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled event ${url} request: ${JSON.stringify(body)}`);
|
throw new Error(`Unhandled event ${url} request: ${JSON.stringify(body)}`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user