Fixed achievement counters getting mistakenly cleaned up as stale quest counters (!189)

Fixes #273

Co-authored-by: Terkoiz <terkoiz@spt.dev>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/189
Co-authored-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-committed-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
This commit is contained in:
Terkoiz 2024-01-09 11:57:27 +00:00 committed by chomp
parent 01e63118c6
commit 98b0a579b3

View File

@ -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);
}