Updated clientActiveSessionStorage inside EventOutputHolder to store data by sessionId

This commit is contained in:
Dev 2024-05-31 23:10:18 +01:00
parent f20ffe286b
commit 97efad0a79

View File

@ -10,8 +10,11 @@ import { TimeUtil } from "@spt/utils/TimeUtil";
@injectable() @injectable()
export class EventOutputHolder export class EventOutputHolder
{ {
/** What has client been informed of this game session */ /**
protected clientActiveSessionStorage: Record<string, { clientInformed: boolean }> = {}; * What has client been informed of this game session
* Key = sessionId, then second key is prod id
*/
protected clientActiveSessionStorage: Record<string, Record<string, { clientInformed: boolean }>> = {};
constructor( constructor(
@inject("ProfileHelper") protected profileHelper: ProfileHelper, @inject("ProfileHelper") protected profileHelper: ProfileHelper,
@ -79,6 +82,7 @@ export class EventOutputHolder
// Clone productions to ensure we preseve the profile jsons data // Clone productions to ensure we preseve the profile jsons data
profileChanges.production = this.getProductionsFromProfileAndFlagComplete( profileChanges.production = this.getProductionsFromProfileAndFlagComplete(
this.cloner.clone(pmcData.Hideout.Production), this.cloner.clone(pmcData.Hideout.Production),
sessionId,
); );
profileChanges.improvements = this.cloner.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData)); profileChanges.improvements = this.cloner.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData));
profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo); profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo);
@ -144,6 +148,7 @@ export class EventOutputHolder
*/ */
protected getProductionsFromProfileAndFlagComplete( protected getProductionsFromProfileAndFlagComplete(
productions: Record<string, Productive>, productions: Record<string, Productive>,
sessionId: string,
): Record<string, Productive> | undefined ): Record<string, Productive> | undefined
{ {
for (const productionKey in productions) for (const productionKey in productions)
@ -168,7 +173,8 @@ export class EventOutputHolder
} }
// Client informed of craft, remove from data returned // Client informed of craft, remove from data returned
if (this.clientActiveSessionStorage[productionKey]?.clientInformed) const storageForSessionId = this.clientActiveSessionStorage[sessionId];
if (storageForSessionId[productionKey]?.clientInformed)
{ {
delete productions[productionKey]; delete productions[productionKey];
@ -176,9 +182,9 @@ export class EventOutputHolder
} }
// Flag started craft as having been seen by client // Flag started craft as having been seen by client
if (production.Progress > 0 && !this.clientActiveSessionStorage[productionKey]?.clientInformed) if (production.Progress > 0 && !storageForSessionId[productionKey]?.clientInformed)
{ {
this.clientActiveSessionStorage[productionKey] = { clientInformed: true }; storageForSessionId[productionKey] = { clientInformed: true };
} }
} }