From d88e705c861095081d63fcd347efc4b7ec659387 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 14 Nov 2024 14:01:54 +0000 Subject: [PATCH] Fixed `questConfig.profileWhitelist` causing quests to not be shown when accepting a quest reversed `questConfig.profileWhitelist` to have quest id as key and allowed game versions as value --- project/assets/configs/quest.json | 2 +- project/src/controllers/QuestController.ts | 8 ++++++-- project/src/helpers/QuestHelper.ts | 11 ++++++----- project/src/models/spt/config/IQuestConfig.ts | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/project/assets/configs/quest.json b/project/assets/configs/quest.json index 87f7c9a9..f481b10e 100644 --- a/project/assets/configs/quest.json +++ b/project/assets/configs/quest.json @@ -19,7 +19,7 @@ "unheard_edition": ["666314a50aa5c7436c00908a"] }, "profileWhitelist": { - "edge_of_darkness": ["666314b4d7f171c4c20226c3"] + "666314b4d7f171c4c20226c3": ["edge_of_darkness"] }, "questTemplateIds": { "pmc": { diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index 328e804f..a7a94eff 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -131,9 +131,13 @@ export class QuestController { ); // Having accepted new quest, look for newly unlocked quests and inform client of them - acceptQuestResponse.profileChanges[sessionID].quests.push( - ...this.questHelper.getNewlyAccessibleQuestsWhenStartingQuest(acceptedQuest.qid, sessionID), + const newlyAccessibleQuests = this.questHelper.getNewlyAccessibleQuestsWhenStartingQuest( + acceptedQuest.qid, + sessionID, ); + if (newlyAccessibleQuests.length > 0) { + acceptQuestResponse.profileChanges[sessionID].quests.push(...newlyAccessibleQuests); + } return acceptQuestResponse; } diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index 48ca636f..230c2767 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -580,13 +580,14 @@ export class QuestHelper { * @returns True Quest should be visible to game version */ protected questIsProfileWhitelisted(gameVersion: string, questId: string) { - const questWhitelist = this.questConfig.profileWhitelist[gameVersion]; - if (!questWhitelist) { - // Not on whitelist for this profile - return false; + const gameVersionWhitelist = this.questConfig.profileWhitelist[questId]; + if (!gameVersionWhitelist) { + // Quest not found in whitelist dict, assume quest is good + return true; } - return questWhitelist.includes(questId); + // Quest in dict, return if game version is on whitelist + return gameVersionWhitelist.includes(gameVersion); } /** diff --git a/project/src/models/spt/config/IQuestConfig.ts b/project/src/models/spt/config/IQuestConfig.ts index aa9f08d4..b538e502 100644 --- a/project/src/models/spt/config/IQuestConfig.ts +++ b/project/src/models/spt/config/IQuestConfig.ts @@ -17,7 +17,7 @@ export interface IQuestConfig extends IBaseConfig { usecOnlyQuests: string[]; /** Quests that the keyed game version do not see/access */ profileBlacklist: Record; - /** Quests that only the keyed game version can see/access */ + /** key=questid, gameversions that can see/access quest */ profileWhitelist: Record; }