Require typed faction keys in runtime state
This commit is contained in:
parent
a16b0559d4
commit
d496d2d04b
6 changed files with 55 additions and 43 deletions
Binary file not shown.
|
|
@ -10,6 +10,7 @@ var statePath = args.Length > 1
|
|||
RequireGameplaySourcePurity(root);
|
||||
RequirePackageSerializerBoundary(root);
|
||||
RequireTypedPendingCommitKeys(root);
|
||||
RequireTypedRuntimeFactionKeys(root);
|
||||
RequireEveRuntimeBootstrap(root);
|
||||
RequireNoRendererLocalConsole(root);
|
||||
RequireNoRendererLocalDebugPanels(root);
|
||||
|
|
@ -622,6 +623,45 @@ static void RequireTypedPendingCommitKeys(string root)
|
|||
}
|
||||
}
|
||||
|
||||
static void RequireTypedRuntimeFactionKeys(string root)
|
||||
{
|
||||
var checkedFiles = new[]
|
||||
{
|
||||
Path.Combine(root, "Assets", "Scripts", "ServerShared", "EntityConstructionBlueprintProjector.cs"),
|
||||
Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs")
|
||||
};
|
||||
|
||||
var forbiddenSymbols = new[]
|
||||
{
|
||||
"public Guid Faction",
|
||||
"blueprint.Faction =",
|
||||
"blueprint.Faction)",
|
||||
"blueprint.Faction,",
|
||||
"blueprint.Faction;",
|
||||
"ResolveFaction(blueprint.Faction",
|
||||
"LegacyId(blueprint.Faction",
|
||||
"ReferenceKey(blueprint.FactionKey",
|
||||
"CorporationKey(entity.Faction?.ID",
|
||||
"CorporationKey(pair.Key.ID",
|
||||
"private static string CorporationKey"
|
||||
};
|
||||
|
||||
var hits = checkedFiles
|
||||
.Where(File.Exists)
|
||||
.SelectMany(path => File.ReadLines(path)
|
||||
.Select((line, index) => new { Path = path, LineNumber = index + 1, Line = line }))
|
||||
.Where(line => forbiddenSymbols.Any(symbol => line.Line.Contains(symbol, StringComparison.Ordinal)))
|
||||
.Select(line => $"{Path.GetRelativePath(root, line.Path)}:{line.LineNumber}: {line.Line.Trim()}")
|
||||
.ToArray();
|
||||
|
||||
if (hits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime faction commits must use typed FactionKey authority, not legacy GUID fallback: " +
|
||||
string.Join("; ", hits));
|
||||
}
|
||||
}
|
||||
|
||||
static void RequireEveRuntimeBootstrap(string root)
|
||||
{
|
||||
var bootstrapPath = Path.Combine(
|
||||
|
|
|
|||
|
|
@ -105,10 +105,9 @@ item GUID fields.
|
|||
Unity runtime commit DTOs now carry typed `FactionKey` only for loadout
|
||||
entities, run entity snapshots, and faction relationship state. The old
|
||||
pending-command `CorporationLegacyId` fallback fields are deleted.
|
||||
`EntityConstructionBlueprint` also carries `FactionKey` now. Loadout restore and
|
||||
entity construction resolve factions by typed key first, with the old GUID
|
||||
field kept as compatibility for construction callers that have not yet been
|
||||
lowered.
|
||||
`EntityConstructionBlueprint` also carries `FactionKey` only. Loadout restore,
|
||||
entity construction, run entity snapshots, and faction relationship commits no
|
||||
longer rebuild corporation references from legacy `Faction.ID` GUIDs.
|
||||
Run checkpoint commit DTOs carry typed `OrbitKey`, `ParentOrbitKey`, and
|
||||
`BodyKey` only for zone orbit/body snapshots. The old pending-command
|
||||
`OrbitLegacyId`, `ParentLegacyId`, and `BodyLegacyId` fallback fields are
|
||||
|
|
|
|||
|
|
@ -235,7 +235,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
blueprint.Name = entity.Name;
|
||||
blueprint.FactionKey = entity.FactionKey ?? "";
|
||||
blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation");
|
||||
blueprint.Hull = hull;
|
||||
blueprint.Equipment = CreateEquippableSlots(entity.Equipment);
|
||||
blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays);
|
||||
|
|
@ -277,7 +276,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
blueprint.Name = entity.Name ?? "";
|
||||
blueprint.FactionKey = entity.FactionKey ?? "";
|
||||
blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation");
|
||||
blueprint.Hull = hull;
|
||||
blueprint.Equipment = CreateEquippableSlots(entity.Equipment);
|
||||
blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays);
|
||||
|
|
@ -559,7 +557,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
Name = blueprint.Name ?? "",
|
||||
Kind = blueprint is ShipConstructionBlueprint ? "ship" : blueprint is OrbitalEntityConstructionBlueprint ? "orbital" : "entity",
|
||||
FactionKey = ReferenceKey(blueprint.FactionKey ?? "", "aetheria.corporation", LegacyId(blueprint.Faction)),
|
||||
FactionKey = blueprint.FactionKey ?? "",
|
||||
Hull = ProjectLoadoutItem(blueprint.Hull),
|
||||
Equipment = ProjectSlots(blueprint.Equipment),
|
||||
CargoBays = ProjectSlots(blueprint.CargoBays),
|
||||
|
|
@ -687,7 +685,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
.OrderBy(pair => pair.Key.ID)
|
||||
.Select(pair => new AetheriaRuntimeFactionRelationshipCommit
|
||||
{
|
||||
FactionKey = CorporationKey(pair.Key.ID),
|
||||
FactionKey = pair.Key.FactionKey ?? "",
|
||||
Relationship = pair.Value.ToString(),
|
||||
Standing = (int)pair.Value
|
||||
})
|
||||
|
|
@ -958,7 +956,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
TractorPower = entity.TractorPower,
|
||||
Heatstroke = entity.Heatstroke,
|
||||
Hypothermia = entity.Hypothermia,
|
||||
FactionKey = CorporationKey(entity.Faction?.ID ?? Guid.Empty),
|
||||
FactionKey = entity.Faction?.FactionKey ?? "",
|
||||
HullItemKey = entity.Hull?.ItemKey ?? "",
|
||||
Equipment = ProjectEquippedSlots(entity.Equipment),
|
||||
CargoBays = ProjectEquippedSlots(entity.CargoBays),
|
||||
|
|
@ -1396,16 +1394,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
.ToArray() ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
|
||||
}
|
||||
|
||||
private static string LegacyId(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : id.ToString("D");
|
||||
}
|
||||
|
||||
private static string CorporationKey(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}";
|
||||
}
|
||||
|
||||
private static string OrbitKey(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : $"aetheria.orbit:legacy:{id:D}";
|
||||
|
|
@ -1559,18 +1547,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static string ReferenceKey(string prefix, string legacyId)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(legacyId) ? "" : $"{prefix}:legacy:{legacyId}";
|
||||
}
|
||||
|
||||
private static string ReferenceKey(string typedKey, string prefix, string legacyId)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(typedKey)
|
||||
? typedKey
|
||||
: ReferenceKey(prefix, legacyId);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit() => QueueRunCheckpoint("application-quit");
|
||||
|
||||
private void QueueRunCheckpoint(string reason)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ public static class EntityConstructionBlueprintProjector
|
|||
|
||||
blueprint.Hull = entity.Hull;
|
||||
blueprint.Name = entity.Name;
|
||||
blueprint.Faction = entity.Faction?.ID ?? Guid.Empty;
|
||||
blueprint.FactionKey = entity.Faction?.FactionKey ?? CorporationKey(blueprint.Faction);
|
||||
blueprint.FactionKey = entity.Faction?.FactionKey ?? "";
|
||||
blueprint.Equipment = entity.Equipment.Select(e => (e.Position, e.EquippableItem)).ToArray();
|
||||
blueprint.CargoBays = entity.CargoBays.Select(e => (e.Position, e.EquippableItem)).ToArray();
|
||||
blueprint.DockingBays = entity.DockingBays.Select(e => (e.Position, e.EquippableItem)).ToArray();
|
||||
|
|
@ -116,12 +115,7 @@ public static class EntityConstructionBlueprintProjector
|
|||
{
|
||||
return galaxy == null
|
||||
? null
|
||||
: galaxy.ResolveFactionByKey(blueprint.FactionKey) ?? galaxy.ResolveFaction(blueprint.Faction);
|
||||
}
|
||||
|
||||
private static string CorporationKey(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}";
|
||||
: galaxy.ResolveFactionByKey(blueprint.FactionKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +146,6 @@ public abstract class EntityConstructionBlueprint
|
|||
public (int2 position, ItemInstance item)[][] DockingBayContents;
|
||||
public EntityConstructionBlueprint[] Children;
|
||||
public EntitySettings Settings;
|
||||
public Guid Faction;
|
||||
public string FactionKey;
|
||||
public int[][] WeaponGroups;
|
||||
|
||||
|
|
|
|||
|
|
@ -1007,9 +1007,10 @@ First Aetheria surfaces to publish:
|
|||
decide generated sector factions or zone names.
|
||||
- Done: move entity faction restore to `Galaxy.ResolveFactionByKey` through
|
||||
`EntityConstructionBlueprint.FactionKey`, so typed loadout readback and
|
||||
entity construction resolve corporation identity by typed key first. The
|
||||
old blueprint `Faction` GUID remains compatibility/fallback for callers
|
||||
that have not yet been lowered.
|
||||
entity construction resolve corporation identity by typed key only. The
|
||||
old blueprint `Faction` GUID compatibility field is deleted, and runtime
|
||||
entity/faction-relationship commits no longer rebuild faction keys from
|
||||
legacy `Faction.ID` GUIDs.
|
||||
- Done: move package and canonical manufacturer/corporation/name-file lookup
|
||||
to typed keys (`ManufacturerKey`, `CorporationKey`, `GeonameFileKey`,
|
||||
and `NameFileKey`), and move loadout manufacturer-distance weighting to
|
||||
|
|
@ -1731,6 +1732,9 @@ First Aetheria surfaces to publish:
|
|||
`AetheriaRuntimePendingCultCacheStore`, `AetheriaRuntimeStateCommitDocument`,
|
||||
and `AetheriaRuntimeEveCommandDocument` until CultLib generated serializers
|
||||
become the Unity runtime owner.
|
||||
- `Aetheria.State.Verify` also guards runtime faction identity ownership:
|
||||
construction blueprints cannot carry a legacy faction GUID, and runtime
|
||||
entity/faction commits cannot rebuild `FactionKey` from `Faction.ID`.
|
||||
- Unity batchmode compile returned cleanly after the runtime blueprint rename;
|
||||
live Unity source has no `EntityPack`, `ShipPack`, `OrbitalEntityPack`,
|
||||
`ZonePack`, `PackedContents`, `PackZone`, `EntitySerializer.Pack`, or
|
||||
|
|
|
|||
Loading…
Reference in a new issue