chore: fix QuestDefinitionCatalogLoader analyzer warnings
parent
fbb248770f
commit
39805ef8e6
|
|
@ -260,33 +260,25 @@ public static class QuestDefinitionCatalogLoader
|
|||
objectiveIdsSeen = new HashSet<string>(StringComparer.Ordinal);
|
||||
var parsedSteps = new List<QuestStepDefRow>();
|
||||
|
||||
var stepsNode = rowObj["steps"] as JsonArray;
|
||||
if (stepsNode is null)
|
||||
var stepsNode = rowObj["steps"];
|
||||
if (stepsNode is not JsonArray stepsArray)
|
||||
{
|
||||
steps = parsedSteps;
|
||||
return errors;
|
||||
}
|
||||
|
||||
for (var si = 0; si < stepsNode.Count; si++)
|
||||
for (var si = 0; si < stepsArray.Count; si++)
|
||||
{
|
||||
if (stepsNode[si] is not JsonObject stepObj)
|
||||
if (stepsArray[si] is not JsonObject stepObj)
|
||||
continue;
|
||||
|
||||
var sid = (stepObj["id"] as JsonValue)?.GetValue<string>();
|
||||
if (sid is not null)
|
||||
{
|
||||
if (stepIdsSeen.Contains(sid))
|
||||
if (sid is not null && !stepIdsSeen.Add(sid))
|
||||
{
|
||||
errors.Add($"error: {path} quests[{questIndex}] steps[{si}]: duplicate step id '{sid}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
stepIdsSeen.Add(sid);
|
||||
}
|
||||
}
|
||||
|
||||
var objectivesNode = stepObj["objectives"] as JsonArray;
|
||||
if (objectivesNode is null)
|
||||
if (stepObj["objectives"] is not JsonArray objectivesNode)
|
||||
continue;
|
||||
|
||||
for (var oi = 0; oi < objectivesNode.Count; oi++)
|
||||
|
|
@ -295,25 +287,18 @@ public static class QuestDefinitionCatalogLoader
|
|||
continue;
|
||||
|
||||
var oid = (objObj["id"] as JsonValue)?.GetValue<string>();
|
||||
if (oid is not null)
|
||||
{
|
||||
if (objectiveIdsSeen.Contains(oid))
|
||||
if (oid is not null && !objectiveIdsSeen.Add(oid))
|
||||
{
|
||||
errors.Add(
|
||||
$"error: {path} quests[{questIndex}] steps[{si}] objectives[{oi}]: " +
|
||||
$"duplicate objective id '{oid}' within quest");
|
||||
}
|
||||
else
|
||||
{
|
||||
objectiveIdsSeen.Add(oid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var si = 0; si < stepsNode.Count; si++)
|
||||
for (var si = 0; si < stepsArray.Count; si++)
|
||||
{
|
||||
if (stepsNode[si] is JsonObject stepObj)
|
||||
if (stepsArray[si] is JsonObject stepObj)
|
||||
parsedSteps.Add(ParseStep(stepObj));
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +316,7 @@ public static class QuestDefinitionCatalogLoader
|
|||
return new QuestDefRow(id, displayName, prerequisiteQuestIds, steps, completionRewardBundle, factionGateRules);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<FactionGateRuleRow> ParseFactionGateRules(JsonArray? array)
|
||||
private static List<FactionGateRuleRow> ParseFactionGateRules(JsonArray? array)
|
||||
{
|
||||
if (array is null || array.Count == 0)
|
||||
return [];
|
||||
|
|
@ -361,7 +346,7 @@ public static class QuestDefinitionCatalogLoader
|
|||
return new QuestRewardBundleRow(itemGrants, skillXpGrants, reputationGrants);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<ReputationGrantRow> ParseReputationGrantRows(JsonArray? array)
|
||||
private static List<ReputationGrantRow> ParseReputationGrantRows(JsonArray? array)
|
||||
{
|
||||
if (array is null || array.Count == 0)
|
||||
return [];
|
||||
|
|
@ -380,7 +365,7 @@ public static class QuestDefinitionCatalogLoader
|
|||
return rows;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<RewardGrantRow> ParseItemGrantRows(JsonArray? array)
|
||||
private static List<RewardGrantRow> ParseItemGrantRows(JsonArray? array)
|
||||
{
|
||||
if (array is null || array.Count == 0)
|
||||
return [];
|
||||
|
|
@ -399,7 +384,7 @@ public static class QuestDefinitionCatalogLoader
|
|||
return rows;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<QuestSkillXpGrantRow> ParseSkillXpGrantRows(JsonArray? array)
|
||||
private static List<QuestSkillXpGrantRow> ParseSkillXpGrantRows(JsonArray? array)
|
||||
{
|
||||
if (array is null || array.Count == 0)
|
||||
return [];
|
||||
|
|
@ -457,7 +442,7 @@ public static class QuestDefinitionCatalogLoader
|
|||
return new QuestObjectiveDefRow(id, kind, itemId, quantity, recipeId, encounterId);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<string> ParseStringArray(JsonArray? array)
|
||||
private static List<string> ParseStringArray(JsonArray? array)
|
||||
{
|
||||
if (array is null)
|
||||
return [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue