From 2e21d416ef5799ef580416daa7b259d885784a1f Mon Sep 17 00:00:00 2001 From: maj00r Date: Sat, 22 Aug 2026 23:15:18 +0200 Subject: [PATCH] Track archival vehicles and multi-unit set followers in the vehicle database #13 ResolvedArchived flag; #18 IsSetFollower hides trailing multi-unit cars; missing-asset log lines. --- StarterNG/Classes/VehicleDatabase.cs | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/StarterNG/Classes/VehicleDatabase.cs b/StarterNG/Classes/VehicleDatabase.cs index e9dd68b..34e8b3d 100644 --- a/StarterNG/Classes/VehicleDatabase.cs +++ b/StarterNG/Classes/VehicleDatabase.cs @@ -66,6 +66,9 @@ public class VehicleTexture /// Group's "category" letter, or null when the group is unknown. [JsonIgnore] public string? ResolvedCategory { get; internal set; } + + /// True when the texture's group is marked archival (archived in JSON). + [JsonIgnore] public bool ResolvedArchived { get; internal set; } } /// Alternate mapping from a malformed multi-= legacy line. @@ -297,9 +300,26 @@ public class VehicleDatabase t.ResolvedCategory = category; t.ResolvedClass = mini; + t.ResolvedArchived = g?.Archived ?? false; } } + /// + /// True when the texture is a non-leading member of an auto-consist set + /// (subsequent multi-unit cars that the depot browser should hide). + /// + public bool IsSetFollower(VehicleTexture texture) + { + if (string.IsNullOrEmpty(texture.Uuid)) return false; + if (!SetByTextureUuid.TryGetValue(texture.Uuid!, out var set) || + set.TextureRefs is null || set.TextureRefs.Count < 2) + return false; + + string? lead = set.TextureRefs.FirstOrDefault(r => !string.IsNullOrEmpty(r)); + return lead != null && + !string.Equals(lead, texture.Uuid, StringComparison.OrdinalIgnoreCase); + } + /// /// Miniature name for a texture: the texture_mini property, but if no .bmp /// for it exists, falls back to the mini of the group it belongs to. @@ -332,6 +352,31 @@ public class VehicleDatabase return TextureBySkin.TryGetValue(key, out var tex) ? tex : null; } + /// Lines for starter/bledy.txt (Pascal chLogExt / missing assets). + public List CollectMissingAssetLines() + { + var lines = new List(); + foreach (var t in Textures) + { + string dir = Path.Combine(Directory.GetCurrentDirectory(), "dynamic", + t.Directory.Replace('/', Path.DirectorySeparatorChar).TrimEnd('\\', '/')); + string skin = Path.Combine(dir, t.Skinfile); + if (!string.IsNullOrEmpty(t.Skinfile) && !File.Exists(skin) && + !File.Exists(Path.ChangeExtension(skin, ".mat")) && + !File.Exists(Path.ChangeExtension(skin, ".bmp"))) + lines.Add($"# no file: {t.Directory}{t.Skinfile}"); + + if (!string.IsNullOrEmpty(t.Model)) + { + string model = Path.Combine(dir, t.Model!); + if (!File.Exists(model) && !File.Exists(Path.ChangeExtension(model, ".t3d")) && + !File.Exists(Path.ChangeExtension(model, ".e3d"))) + lines.Add($"# no model: {t.Directory}{t.Model}"); + } + } + return lines; + } + /// Header label for the group a texture belongs to. public string GroupHeader(string? groupId) {