Fixed client error caused by server providing an invalid mongo_id for nameTaskConditionCountersCraftingId

This commit is contained in:
Dev 2024-11-21 16:21:19 +00:00
parent 88208c6334
commit 2749be9a4b

View File

@ -56,7 +56,7 @@ import { inject, injectable } from "tsyringe";
@injectable() @injectable()
export class HideoutController { export class HideoutController {
/** Key used in TaskConditionCounters array */ /** Key used in TaskConditionCounters array */
protected static nameTaskConditionCountersCrafting = "CounterHoursCrafting"; protected static nameTaskConditionCountersCraftingId = "673f5d6fdd6ed700c703afdc";
protected hideoutConfig: IHideoutConfig; protected hideoutConfig: IHideoutConfig;
constructor( constructor(
@ -1051,16 +1051,16 @@ export class HideoutController {
pmcData: IPmcData, pmcData: IPmcData,
recipe: IHideoutProduction, recipe: IHideoutProduction,
): ITaskConditionCounter { ): ITaskConditionCounter {
let counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting]; let counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCraftingId];
if (!counterHoursCrafting) { if (!counterHoursCrafting) {
// Doesn't exist, create // Doesn't exist, create
pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting] = { pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCraftingId] = {
id: recipe._id, id: recipe._id,
type: HideoutController.nameTaskConditionCountersCrafting, type: HideoutController.nameTaskConditionCountersCraftingId,
sourceId: "CounterCrafting", sourceId: "CounterCrafting",
value: 0, value: 0,
}; };
counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting]; counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCraftingId];
} }
return counterHoursCrafting; return counterHoursCrafting;
} }