From ac259c6259262ddef8bdb29fa5151c6efbe8d61b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 22:14:22 +0200 Subject: [PATCH] Place names: one validity rule (FactionPlace.IsValidName) for NamePlaces and the place-names command NamePlaces treats an invalid entry as absent; the command refuses a table holding one. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Corporations.cs | 5 +++++ Assets/Scripts/ServerShared/Galaxy.cs | 2 +- tools/AetherDb/PlaceNamesCommand.cs | 6 ++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index 0b9be208d..4c38b60fc 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -75,5 +75,10 @@ public class FactionPlace { [Inspectable, JsonProperty("name"), Key(1)] public string Name; + + // The one rule for a valid place name: trimmed, non-empty and not a catalogue designation (EAC-, any case). Galaxy.NamePlaces + // treats an invalid entry as absent; AetherDb place-names refuses a table that holds one. + public static bool IsValidName(string name) => + !string.IsNullOrEmpty(name) && name == name.Trim() && !name.StartsWith("EAC-", StringComparison.OrdinalIgnoreCase); } diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs index 504f419b7..0b2f71387 100644 --- a/Assets/Scripts/ServerShared/Galaxy.cs +++ b/Assets/Scripts/ServerShared/Galaxy.cs @@ -358,7 +358,7 @@ public class Galaxy foreach (var faction in Factions) { if (!HomeZones.TryGetValue(faction, out var home)) continue; - var places = (faction.Places ?? Array.Empty()).Select(p => p?.Name).Where(n => !string.IsNullOrEmpty(n)).ToArray(); + var places = (faction.Places ?? Array.Empty()).Select(p => p?.Name).Where(FactionPlace.IsValidName).ToArray(); var next = 0; var owned = Zones.Select((zone, index) => (zone, index)).Where(z => z.zone.Owner == faction) .OrderBy(z => z.zone.Distance[home]).ThenBy(z => z.index); diff --git a/tools/AetherDb/PlaceNamesCommand.cs b/tools/AetherDb/PlaceNamesCommand.cs index 55348de64..0bb0700b9 100644 --- a/tools/AetherDb/PlaceNamesCommand.cs +++ b/tools/AetherDb/PlaceNamesCommand.cs @@ -80,10 +80,8 @@ public static class PlaceNamesCommand throw new InvalidOperationException("Place names row: its ShortName differs from the faction under its key (conflict)."); foreach (var name in row.Names) { - if (string.IsNullOrEmpty(name) || name != name.Trim()) - throw new InvalidOperationException("Place names row: a name is empty or untrimmed (invalid)."); - if (name.StartsWith("EAC-", StringComparison.OrdinalIgnoreCase)) - throw new InvalidOperationException("Place names row: a name is a catalogue designation (invalid)."); + if (!FactionPlace.IsValidName(name)) + throw new InvalidOperationException("Place names row: a name is empty, untrimmed or a catalogue designation (invalid)."); if (!seen.Add(name)) throw new InvalidOperationException("Place names table: a name is repeated (conflict)."); }