diff --git a/src/Helldivers-2-Core/Mapping/V1/PlanetMapper.cs b/src/Helldivers-2-Core/Mapping/V1/PlanetMapper.cs index bea89bc..c6343b3 100644 --- a/src/Helldivers-2-Core/Mapping/V1/PlanetMapper.cs +++ b/src/Helldivers-2-Core/Mapping/V1/PlanetMapper.cs @@ -94,13 +94,19 @@ private Planet MapToV1(MappingContext context, PlanetInfo info, PlanetStatus sta private Region MapToV1(Models.ArrowHead.Info.PlanetRegion region, Models.ArrowHead.Status.PlanetRegionStatus? status, MappingContext context) { string? owner = null; + (string Name, string? Description)? planetRegion = null; if (status is { Owner: var faction }) Static.Factions.TryGetValue(faction, out owner); - Static.PlanetRegion.TryGetValue(region.SettingsHash, out var planetRegion); + if (Static.PlanetRegion.ContainsKey(region.SettingsHash)) + planetRegion = Static.PlanetRegion[region.SettingsHash]; + return new Region( - Name: planetRegion.Name, - Description: planetRegion.Description, + Id: region.RegionIndex, + Hash: region.SettingsHash, + Name: planetRegion?.Name, + Description: planetRegion?.Description, + Health: status?.Health, MaxHealth: region.MaxHealth, Size: (RegionSize)region.RegionSize, RegenPerSecond: status?.RegerPerSecond, diff --git a/src/Helldivers-2-Models/V1/Planets/Region.cs b/src/Helldivers-2-Models/V1/Planets/Region.cs index ab0cd51..3c0b6d6 100644 --- a/src/Helldivers-2-Models/V1/Planets/Region.cs +++ b/src/Helldivers-2-Models/V1/Planets/Region.cs @@ -2,9 +2,17 @@ /// /// A region on a planet. +/// +/// The Name and Description fields may be empty when the underlying data store doesn't contain information on them. +/// This is typically when ArrowHead adds new regions that aren't updated in the data store (helldivers-2/json) yet. +/// +/// Note that some properties may be unavailable when the region is inactive. /// +/// The identifier of this region. +/// The underlying hash identifier of ArrowHead. /// The name of the region. /// A long-form description of the region. +/// The current health of the region. /// The maximum health of this region. /// The size of this region. /// The amount of health this region generates when left alone. @@ -12,8 +20,11 @@ /// Whether the region is currently playable(?). /// The amount of helldivers currently active in this region. public record struct Region( - string Name, - string Description, + int Id, + ulong Hash, + string? Name, + string? Description, + long? Health, ulong MaxHealth, RegionSize Size, double? RegenPerSecond, diff --git a/src/Helldivers-2-Models/json b/src/Helldivers-2-Models/json index 5d08918..ca7a5d2 160000 --- a/src/Helldivers-2-Models/json +++ b/src/Helldivers-2-Models/json @@ -1 +1 @@ -Subproject commit 5d08918c6ada366f755dacdb0644308fcf88b1be +Subproject commit ca7a5d2d34d6ac124b6952409ce28da91597a1e6 diff --git a/src/Helldivers-2-SourceGen/Parsers/BaseJsonParser.cs b/src/Helldivers-2-SourceGen/Parsers/BaseJsonParser.cs index a4ad984..6ff839a 100644 --- a/src/Helldivers-2-SourceGen/Parsers/BaseJsonParser.cs +++ b/src/Helldivers-2-SourceGen/Parsers/BaseJsonParser.cs @@ -11,6 +11,7 @@ namespace Helldivers.SourceGen.Parsers; public abstract class BaseJsonParser : IJsonParser { private const string TEMPLATE = @"// +#nullable enable #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member using global::System.Collections.Generic; using global::Helldivers.Models.Domain.Localization; diff --git a/src/Helldivers-2-SourceGen/Parsers/PlanetRegionsParser.cs b/src/Helldivers-2-SourceGen/Parsers/PlanetRegionsParser.cs index 3a2e09a..bb5eaf6 100644 --- a/src/Helldivers-2-SourceGen/Parsers/PlanetRegionsParser.cs +++ b/src/Helldivers-2-SourceGen/Parsers/PlanetRegionsParser.cs @@ -12,7 +12,7 @@ public class PlanetRegionsParser : BaseJsonParser /// protected override (string Type, string Source) Parse(string json) { - var builder = new StringBuilder("new Dictionary()\n\t{\n"); + var builder = new StringBuilder("new Dictionary()\n\t{\n"); var document = JsonDocument.Parse(json); foreach (var property in document.RootElement.EnumerateObject()) { @@ -28,6 +28,6 @@ protected override (string Type, string Source) Parse(string json) } builder.Append("\t}"); - return ("IReadOnlyDictionary", builder.ToString()); + return ("IReadOnlyDictionary", builder.ToString()); } }