Skip to content

Commit 5da5eea

Browse files
committed
Build template manager bugfix (#1472)
1 parent fd9d893 commit 5da5eea

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Daybreak.Shared/Services/BuildTemplates/BuildTemplateManager.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,25 +678,25 @@ private SingleBuildEntry PopulateSingleBuild(SingleBuildEntry singleBuildEntry,
678678
if (primaryProfession != Profession.None)
679679
{
680680
build.Attributes.Add(new AttributeEntry { Attribute = primaryProfession.PrimaryAttribute });
681-
build.Attributes.AddRange(primaryProfession.Attributes!.Select(a => new AttributeEntry { Attribute = a }));
681+
build.Attributes.AddRange(primaryProfession.Attributes?.Select(a => new AttributeEntry { Attribute = a }) ?? []);
682682
}
683683

684684
if (secondaryProfession != Profession.None)
685685
{
686-
build.Attributes.AddRange(secondaryProfession.Attributes!.Select(a => new AttributeEntry { Attribute = a }));
686+
build.Attributes.AddRange(secondaryProfession.Attributes?.Select(a => new AttributeEntry { Attribute = a }) ?? []);
687687
}
688688

689689
for(int i = 0; i < buildMetadata.AttributeCount; i++)
690690
{
691691
var attributeId = buildMetadata.AttributesIds[i];
692-
var maybeAttribute = build.Attributes.FirstOrDefault(a => a.Attribute!.Id == attributeId);
692+
var maybeAttribute = build.Attributes.FirstOrDefault(a => a.Attribute?.Id == attributeId);
693693
if (maybeAttribute is null)
694694
{
695695
scopedLogger.LogError("Failed to parse attribute with id {attributeId} for professions {primaryProfession.Name}/{secondaryProfession.Name}", attributeId, primaryProfession.Name ?? string.Empty, secondaryProfession.Name ?? string.Empty);
696696
return default;
697697
}
698698

699-
maybeAttribute!.Points = buildMetadata.AttributePoints[i];
699+
maybeAttribute.Points = buildMetadata.AttributePoints[i];
700700
}
701701

702702
for(int i = 0; i < 8; i++)
@@ -725,9 +725,9 @@ private string EncodeTemplateInner(Build build)
725725
Header = 14,
726726
PrimaryProfessionId = build.Primary.Id,
727727
SecondaryProfessionId = build.Secondary.Id,
728-
AttributeCount = build.Attributes.Where(attrEntry => attrEntry.Points > 0).Count(),
729-
AttributesIds = [.. build.Attributes.Where(attrEntry => attrEntry.Points > 0).OrderBy(attrEntry => attrEntry.Attribute!.Id).Select(attrEntry => attrEntry.Attribute!.Id)],
730-
AttributePoints = [.. build.Attributes.Where(attrEntry => attrEntry.Points > 0).OrderBy(attrEntry => attrEntry.Attribute!.Id).Select(attrEntry => attrEntry.Points)],
728+
AttributeCount = build.Attributes.Count(attrEntry => attrEntry.Points > 0),
729+
AttributesIds = [.. build.Attributes.Where(attrEntry => attrEntry.Points > 0).OrderBy(attrEntry => attrEntry.Attribute?.Id).Select(attrEntry => attrEntry.Attribute?.Id ?? -1)],
730+
AttributePoints = [.. build.Attributes.Where(attrEntry => attrEntry.Points > 0).OrderBy(attrEntry => attrEntry.Attribute?.Id).Select(attrEntry => attrEntry.Points)],
731731
SkillIds = [.. build.Skills.Select(skill => skill.Id)],
732732
TailPresent = true
733733
};

0 commit comments

Comments
 (0)