mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 02:10:44 -05:00
Ensure verifyQuestProductionUnlocks()
skips quests that cannot be found in db
This commit is contained in:
parent
e5067b09e5
commit
016fc2a51e
@ -280,26 +280,30 @@ export class ProfileFixerService {
|
|||||||
const quests = this.databaseService.getQuests();
|
const quests = this.databaseService.getQuests();
|
||||||
const profileQuests = pmcProfile.Quests;
|
const profileQuests = pmcProfile.Quests;
|
||||||
|
|
||||||
for (const profileQuest of profileQuests)
|
for (const profileQuest of profileQuests) {
|
||||||
{
|
|
||||||
const quest = quests[profileQuest.qid];
|
const quest = quests[profileQuest.qid];
|
||||||
|
if (!quest) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// For started or successful quests, check for unlocks in the `Started` rewards
|
// For started or successful quests, check for unlocks in the `Started` rewards
|
||||||
if (profileQuest.status == QuestStatus.Started || profileQuest.status == QuestStatus.Success)
|
if (profileQuest.status == QuestStatus.Started || profileQuest.status == QuestStatus.Success) {
|
||||||
{
|
const productionRewards = quest.rewards.Started?.filter(
|
||||||
const productionRewards = quest.rewards.Started?.filter(reward => reward.type == QuestRewardType.PRODUCTIONS_SCHEME);
|
(reward) => reward.type == QuestRewardType.PRODUCTIONS_SCHEME,
|
||||||
productionRewards?.forEach(reward => this.verifyQuestProductionUnlock(pmcProfile, reward, quest));
|
);
|
||||||
|
productionRewards?.forEach((reward) => this.verifyQuestProductionUnlock(pmcProfile, reward, quest));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For successful quests, check for unlocks in the `Success` rewards
|
// For successful quests, check for unlocks in the `Success` rewards
|
||||||
if (profileQuest.status == QuestStatus.Success)
|
if (profileQuest.status == QuestStatus.Success) {
|
||||||
{
|
const productionRewards = quest.rewards.Success?.filter(
|
||||||
const productionRewards = quest.rewards.Success?.filter(reward => reward.type == QuestRewardType.PRODUCTIONS_SCHEME);
|
(reward) => reward.type == QuestRewardType.PRODUCTIONS_SCHEME,
|
||||||
productionRewards?.forEach(reward => this.verifyQuestProductionUnlock(pmcProfile, reward, quest));
|
);
|
||||||
|
productionRewards?.forEach((reward) => this.verifyQuestProductionUnlock(pmcProfile, reward, quest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const validateTime = performance.now() - start
|
const validateTime = performance.now() - start;
|
||||||
this.logger.debug(`Quest Production Unlock validation took: ${validateTime.toFixed(2)}ms`);
|
this.logger.debug(`Quest Production Unlock validation took: ${validateTime.toFixed(2)}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +317,7 @@ export class ProfileFixerService {
|
|||||||
protected verifyQuestProductionUnlock(
|
protected verifyQuestProductionUnlock(
|
||||||
pmcProfile: IPmcData,
|
pmcProfile: IPmcData,
|
||||||
productionUnlockReward: IQuestReward,
|
productionUnlockReward: IQuestReward,
|
||||||
questDetails: IQuest
|
questDetails: IQuest,
|
||||||
): void {
|
): void {
|
||||||
const matchingProductions = this.questHelper.getRewardProductionMatch(productionUnlockReward, questDetails);
|
const matchingProductions = this.questHelper.getRewardProductionMatch(productionUnlockReward, questDetails);
|
||||||
if (matchingProductions.length !== 1) {
|
if (matchingProductions.length !== 1) {
|
||||||
@ -329,10 +333,11 @@ export class ProfileFixerService {
|
|||||||
|
|
||||||
// Add above match to pmc profile
|
// Add above match to pmc profile
|
||||||
const matchingProductionId = matchingProductions[0]._id;
|
const matchingProductionId = matchingProductions[0]._id;
|
||||||
if (!pmcProfile.UnlockedInfo.unlockedProductionRecipe.includes(matchingProductionId))
|
if (!pmcProfile.UnlockedInfo.unlockedProductionRecipe.includes(matchingProductionId)) {
|
||||||
{
|
|
||||||
pmcProfile.UnlockedInfo.unlockedProductionRecipe.push(matchingProductionId);
|
pmcProfile.UnlockedInfo.unlockedProductionRecipe.push(matchingProductionId);
|
||||||
this.logger.debug(`Added production ${matchingProductionId} to unlocked production recipes for ${questDetails.QuestName}`);
|
this.logger.debug(
|
||||||
|
`Added production ${matchingProductionId} to unlocked production recipes for ${questDetails.QuestName}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user