Fix quest statusTimers ending up with named keys (!254)
- Don't depend on status being non-numeric to fix statusTimers - Cleaner tracking of fix counts in `updateProfileQuestDataValues` - Better number checking for quest status, since `0` is a valid status, but fails the `!Number()` check - Cleanup of quest status setting in `processAlteredQuests` Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/254 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
75a8007842
commit
f95ed922a4
@ -433,7 +433,7 @@ export class InraidController
|
|||||||
pmcQuest.statusTimers = quest.statusTimers;
|
pmcQuest.statusTimers = quest.statusTimers;
|
||||||
for (const statusTimerKey in quest.statusTimers)
|
for (const statusTimerKey in quest.statusTimers)
|
||||||
{
|
{
|
||||||
if (!Number(statusTimerKey))
|
if (Number.isNaN(parseInt(statusTimerKey)))
|
||||||
{
|
{
|
||||||
quest.statusTimers[QuestStatus[statusTimerKey]] = quest.statusTimers[statusTimerKey];
|
quest.statusTimers[QuestStatus[statusTimerKey]] = quest.statusTimers[statusTimerKey];
|
||||||
delete quest.statusTimers[statusTimerKey];
|
delete quest.statusTimers[statusTimerKey];
|
||||||
|
@ -467,8 +467,8 @@ export class InRaidHelper
|
|||||||
// Set quest as AvailableAfter and set timer
|
// Set quest as AvailableAfter and set timer
|
||||||
const timestamp = this.timeUtil.getTimestamp() + afsRequirement.availableAfter;
|
const timestamp = this.timeUtil.getTimestamp() + afsRequirement.availableAfter;
|
||||||
lockedQuest.availableAfter = timestamp;
|
lockedQuest.availableAfter = timestamp;
|
||||||
lockedQuest.statusTimers.AvailableAfter = timestamp;
|
lockedQuest.statusTimers[QuestStatus.AvailableAfter] = this.timeUtil.getTimestamp();
|
||||||
lockedQuest.status = 9;
|
lockedQuest.status = QuestStatus.AvailableAfter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,8 @@ export class ProfileFixerService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixes = new Map<any, number>();
|
const fixes: Record<any, number> = {};
|
||||||
|
const timerFixes: Record<string, number> = {};
|
||||||
const questsToDelete: IQuestStatus[] = [];
|
const questsToDelete: IQuestStatus[] = [];
|
||||||
const fullProfile = this.profileHelper.getFullProfile(profile.sessionId);
|
const fullProfile = this.profileHelper.getFullProfile(profile.sessionId);
|
||||||
const isDevProfile = fullProfile?.info.edition.toLowerCase() === "spt developer";
|
const isDevProfile = fullProfile?.info.edition.toLowerCase() === "spt developer";
|
||||||
@ -559,28 +560,23 @@ export class ProfileFixerService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quest.status && !Number(quest.status))
|
if (quest.status && Number.isNaN(parseInt(<string><unknown>quest.status)))
|
||||||
{
|
{
|
||||||
if (fixes.has(quest.status))
|
fixes[quest.status] = (fixes[quest.status] ?? 0) + 1;
|
||||||
{
|
|
||||||
fixes.set(quest.status, fixes.get(quest.status) + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fixes.set(quest.status, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const newQuestStatus = QuestStatus[quest.status];
|
const newQuestStatus = QuestStatus[quest.status];
|
||||||
quest.status = <QuestStatus><unknown>newQuestStatus;
|
quest.status = <QuestStatus><unknown>newQuestStatus;
|
||||||
|
}
|
||||||
|
|
||||||
for (const statusTimer in quest.statusTimers)
|
for (const statusTimer in quest.statusTimers)
|
||||||
|
{
|
||||||
|
if (Number.isNaN(parseInt(statusTimer)))
|
||||||
{
|
{
|
||||||
if (!Number(statusTimer))
|
timerFixes[statusTimer] = (timerFixes[statusTimer] ?? 0) + 1;
|
||||||
{
|
|
||||||
const newKey = QuestStatus[statusTimer];
|
const newKey = QuestStatus[statusTimer];
|
||||||
quest.statusTimers[newKey] = quest.statusTimers[statusTimer];
|
quest.statusTimers[newKey] = quest.statusTimers[statusTimer];
|
||||||
delete quest.statusTimers[statusTimer];
|
delete quest.statusTimers[statusTimer];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,11 +586,18 @@ export class ProfileFixerService
|
|||||||
profile.Quests.splice(profile.Quests.indexOf(questToDelete), 1);
|
profile.Quests.splice(profile.Quests.indexOf(questToDelete), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fixes.size > 0)
|
if (Object.keys(fixes).length > 0)
|
||||||
{
|
{
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Updated quests values: ${
|
`Updated quests values: ${Object.entries(fixes).map(([k, v]) => `(${k}: ${v} times)`).join(", ")}`,
|
||||||
Array.from(fixes.entries()).map(([k, v]) => `(${k}: ${v} times)`).join(", ")
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(timerFixes).length > 0)
|
||||||
|
{
|
||||||
|
this.logger.debug(
|
||||||
|
`Updated statusTimers values: ${
|
||||||
|
Object.entries(timerFixes).map(([k, v]) => `(${k}: ${v} times)`).join(", ")
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user