From 98b0a579b3383313fd452567de5fa680b84f127c Mon Sep 17 00:00:00 2001 From: Terkoiz Date: Tue, 9 Jan 2024 11:57:27 +0000 Subject: [PATCH] Fixed achievement counters getting mistakenly cleaned up as stale quest counters (!189) Fixes #273 Co-authored-by: Terkoiz Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/189 Co-authored-by: Terkoiz Co-committed-by: Terkoiz --- project/src/services/ProfileFixerService.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 2ca7b608..617b14c6 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -515,15 +515,18 @@ export class ProfileFixerService { const counterKeysToRemove: string[] = []; const activeQuests = this.getActiveRepeatableQuests(pmcProfile.RepeatableQuests); + const achievements = this.databaseServer.getTables().templates.achievements; + for (const [key, backendCounter] of Object.entries(pmcProfile.TaskConditionCounters)) { if (pmcProfile.RepeatableQuests && activeQuests.length > 0) { const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.sourceId); const existsInQuests = pmcProfile.Quests.some((q) => q.qid === backendCounter.sourceId); + const isAchievementTracker = achievements.some((a) => a.id === backendCounter.sourceId); - // if BackendCounter's quest is neither in activeQuests nor Quests it's stale - if (!(existsInActiveRepeatableQuests || existsInQuests)) + // if BackendCounter is neither in activeQuests, quests or achievements - it's stale and should be cleaned up + if (!(existsInActiveRepeatableQuests || existsInQuests || isAchievementTracker)) { counterKeysToRemove.push(key); }