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:
parent
01e63118c6
commit
98b0a579b3
@ -515,15 +515,18 @@ export class ProfileFixerService
|
|||||||
{
|
{
|
||||||
const counterKeysToRemove: string[] = [];
|
const counterKeysToRemove: string[] = [];
|
||||||
const activeQuests = this.getActiveRepeatableQuests(pmcProfile.RepeatableQuests);
|
const activeQuests = this.getActiveRepeatableQuests(pmcProfile.RepeatableQuests);
|
||||||
|
const achievements = this.databaseServer.getTables().templates.achievements;
|
||||||
|
|
||||||
for (const [key, backendCounter] of Object.entries(pmcProfile.TaskConditionCounters))
|
for (const [key, backendCounter] of Object.entries(pmcProfile.TaskConditionCounters))
|
||||||
{
|
{
|
||||||
if (pmcProfile.RepeatableQuests && activeQuests.length > 0)
|
if (pmcProfile.RepeatableQuests && activeQuests.length > 0)
|
||||||
{
|
{
|
||||||
const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.sourceId);
|
const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.sourceId);
|
||||||
const existsInQuests = pmcProfile.Quests.some((q) => q.qid === 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 BackendCounter is neither in activeQuests, quests or achievements - it's stale and should be cleaned up
|
||||||
if (!(existsInActiveRepeatableQuests || existsInQuests))
|
if (!(existsInActiveRepeatableQuests || existsInQuests || isAchievementTracker))
|
||||||
{
|
{
|
||||||
counterKeysToRemove.push(key);
|
counterKeysToRemove.push(key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user