mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 01:30:44 -05:00
Added nullgaurd to getQuestRewardItems()
to protect against invalid custom quests
This commit is contained in:
parent
a16aaf270f
commit
9b7c31e36f
@ -358,9 +358,16 @@ export class QuestHelper {
|
|||||||
* @returns array of items with the correct maxStack
|
* @returns array of items with the correct maxStack
|
||||||
*/
|
*/
|
||||||
public getQuestRewardItems(quest: IQuest, status: QuestStatus, gameVersion: string): IItem[] {
|
public getQuestRewardItems(quest: IQuest, status: QuestStatus, gameVersion: string): IItem[] {
|
||||||
|
if (!quest.rewards[QuestStatus[status]]) {
|
||||||
|
this.logger.warning(`Unable to find: ${status} reward for quest: ${quest.QuestName}`);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate over all rewards with the desired status, flatten out items that have a type of Item
|
// Iterate over all rewards with the desired status, flatten out items that have a type of Item
|
||||||
const questRewards = quest.rewards[QuestStatus[status]].flatMap((reward: IQuestReward) =>
|
const questRewards = quest.rewards[QuestStatus[status]].flatMap((reward: IQuestReward) =>
|
||||||
reward.type === "Item" && this.questRewardIsForGameEdition(reward, gameVersion) ? this.processReward(reward) : [],
|
reward.type === "Item" && this.questRewardIsForGameEdition(reward, gameVersion)
|
||||||
|
? this.processReward(reward)
|
||||||
|
: [],
|
||||||
);
|
);
|
||||||
|
|
||||||
return questRewards;
|
return questRewards;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user