Guard daemon playable run generation
This commit is contained in:
parent
41e0b96a78
commit
2e622ead78
2 changed files with 62 additions and 13 deletions
|
|
@ -18,6 +18,7 @@ RequireTypedPendingCommitKeys(root);
|
|||
RequireTypedRuntimeFactionKeys(root);
|
||||
RequireTypedGalaxyFactionRelationships(root);
|
||||
RequireRuntimeCatalogKeyOnlyLookups(root);
|
||||
RequireDaemonPlayableRunGenerationAuthority(root);
|
||||
RequireTypedBehaviorBodyKeys(root);
|
||||
RequireTypedOrbitTaskKeys(root);
|
||||
RequireTypedAgentTaskKeys(root);
|
||||
|
|
@ -1210,6 +1211,67 @@ static void RequireRuntimeCatalogKeyOnlyLookups(string root)
|
|||
}
|
||||
}
|
||||
|
||||
static void RequireDaemonPlayableRunGenerationAuthority(string root)
|
||||
{
|
||||
var daemonProgramPath = Path.Combine(root, "Aetheria.State.Daemon", "Program.cs");
|
||||
var daemonZoneGeneratorPath = Path.Combine(root, "Aetheria.State.Daemon", "AetheriaDaemonZoneGenerator.cs");
|
||||
var sharedLoadoutGeneratorPath = Path.Combine(root, "Assets", "Scripts", "ServerShared", "LoadoutGenerator.cs");
|
||||
|
||||
var daemonProgram = File.Exists(daemonProgramPath)
|
||||
? File.ReadAllText(daemonProgramPath)
|
||||
: throw new InvalidOperationException("Cannot verify daemon playable-run generation authority; daemon Program.cs is missing.");
|
||||
var daemonZoneGenerator = File.Exists(daemonZoneGeneratorPath)
|
||||
? File.ReadAllText(daemonZoneGeneratorPath)
|
||||
: throw new InvalidOperationException("Cannot verify daemon playable-run generation authority; daemon zone generator is missing.");
|
||||
var sharedLoadoutGenerator = File.Exists(sharedLoadoutGeneratorPath)
|
||||
? File.ReadAllText(sharedLoadoutGeneratorPath)
|
||||
: throw new InvalidOperationException("Cannot verify daemon playable-run generation authority; legacy Unity LoadoutGenerator.cs is missing.");
|
||||
|
||||
var requiredDaemonSymbols = new[]
|
||||
{
|
||||
"await AetheriaDaemonZoneGenerator.WritePlayableRunAsync(",
|
||||
"internal static class AetheriaDaemonZoneGenerator",
|
||||
"private sealed class DaemonLoadoutGenerator",
|
||||
"var loadouts = new DaemonLoadoutGenerator(catalog);",
|
||||
"GenerateEntities(loadouts)"
|
||||
};
|
||||
|
||||
var daemonText = daemonProgram + "\n" + daemonZoneGenerator;
|
||||
var missingDaemonSymbols = requiredDaemonSymbols
|
||||
.Where(symbol => !daemonText.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (missingDaemonSymbols.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Playable run and loadout generation must be daemon-owned, not recovered through Unity ServerShared generators: " +
|
||||
string.Join(", ", missingDaemonSymbols));
|
||||
}
|
||||
|
||||
var forbiddenDaemonSymbols = new[]
|
||||
{
|
||||
"new LoadoutGenerator(",
|
||||
"ZoneGenerator.Generate(",
|
||||
"Assets.Scripts.ServerShared",
|
||||
"ServerShared.LoadoutGenerator"
|
||||
};
|
||||
var survivingDaemonSymbols = forbiddenDaemonSymbols
|
||||
.Where(symbol => daemonText.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (survivingDaemonSymbols.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Daemon generation must not call the legacy Unity ServerShared loadout/zone generators: " +
|
||||
string.Join(", ", survivingDaemonSymbols));
|
||||
}
|
||||
|
||||
if (sharedLoadoutGenerator.Contains("// public LoadoutGenerator", StringComparison.Ordinal) ||
|
||||
sharedLoadoutGenerator.Contains("// ref Random random", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Legacy Unity LoadoutGenerator must not carry commented constructor scars; Git history owns removed APIs.");
|
||||
}
|
||||
}
|
||||
|
||||
static void RequireTypedBehaviorBodyKeys(string root)
|
||||
{
|
||||
var checkedFiles = new[]
|
||||
|
|
|
|||
|
|
@ -40,19 +40,6 @@ public class LoadoutGenerator
|
|||
Faction = faction;
|
||||
PriceExponent = priceExponent;
|
||||
}
|
||||
//
|
||||
// public LoadoutGenerator(
|
||||
// ref Random random,
|
||||
// ItemManager itemManager,
|
||||
// Faction faction,
|
||||
// float priceExponent)
|
||||
// {
|
||||
// Random = random;
|
||||
// ItemManager = itemManager;
|
||||
// Faction = faction;
|
||||
// PriceExponent = priceExponent;
|
||||
// }
|
||||
|
||||
public EntityConstructionBlueprint GenerateShipLoadout(Predicate<AetheriaRuntimeCatalogItem> hullFilter = null)
|
||||
{
|
||||
var hullRow = RandomHull(HullType.Ship, hullFilter);
|
||||
|
|
|
|||
Loading…
Reference in a new issue