diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 671faf678..b75f0d30a 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -198,7 +198,7 @@ public class LoadoutGenerator entry.design.Price > 0 && entry.product.Manufacturer.IsSet() && // A not-offered product is never a candidate, so the any-manufacturer fallback below cannot reach it either. - IsOffered(entry.product) && + IsOffered(ItemManager.ItemData, entry.product) && (!(entry.design is EquippableItemData equippable) || HasHome(equippable, hulls)) && (filter?.Invoke(entry.design) ?? true)) .ToArray(); @@ -221,7 +221,7 @@ public class LoadoutGenerator // hardpoints never put gear on a shelf. An off-market hull gives no gear a home either: only its pinned Loadout flies it. // The one definition of the hulls HasHome considers. public static HullData[] SoldHulls(CultCache items) => - items.GetAll().Where(IsOffered).Select(product => items.Get(product.Design)).OfType().Distinct().ToArray(); + items.GetAll().Where(product => IsOffered(items, product)).Select(product => items.Get(product.Design)).OfType().Distinct().ToArray(); public static bool HasHome(EquippableItemData design, HullData[] hulls) => design.HardpointType == HardpointType.Tool || design.HardpointType == HardpointType.Hull || @@ -236,12 +236,14 @@ public class LoadoutGenerator // does not matter (operator, 2026-10-06: a faction need not be present for its gear to be available). // A not-offered product is available to nobody, a stage with no faction included. public bool IsAvailable(FactionProductData product) => - IsOffered(product) && ( + IsOffered(ItemManager.ItemData, product) && ( Galaxy == null || Faction == null || ItemManager.ItemData.Get(product.Manufacturer) == Faction || Faction.Allegiance.ContainsKey(product.Manufacturer)); - // Whether a product is on the market at all (ruling off-market-is-unoffered-product). The one reader of NotOffered. - public static bool IsOffered(FactionProductData product) => !product.NotOffered; + // Whether a product is on the market at all (ruling off-market-is-unoffered-product). The one reader of NotOffered. A bin is + // offered only if both it and its line are (ruling bin-inherits-line-offered); the catalog read guarantees a bin's line exists. + public static bool IsOffered(CultCache items, FactionProductData product) => + !product.NotOffered && (product.Bin == null || !items.Get(product.Bin.Line).NotOffered); // How much this outfitter favors a product: its maker's preference times the product's share of it. The one weight of // generation and of ChooseProduct. A bin takes the share of its maker's stock that would pass its floor and its line takes @@ -256,9 +258,10 @@ public class LoadoutGenerator // 1 - Phi(floor): the fraction of a normal draw that lies at least floor deviations above its mean. private static float PassFraction(float floor) => .5f * (1 - erf(floor / sqrt(2f))); - // Each line's key to the sum of its bins' pass fractions: read from the catalog once per weighting pass, never kept. + // Each line's key to the sum of its offered bins' pass fractions: read from the catalog once per weighting pass, never kept. An + // off-market bin takes no share, so its line keeps the whole weight. private Dictionary BinShares() => ItemManager.ItemData.GetAll() - .Where(product => product.Bin != null) + .Where(product => product.Bin != null && IsOffered(ItemManager.ItemData, product)) .GroupBy(product => product.Bin.Line.Key.Value) .ToDictionary(group => group.Key, group => group.Sum(bin => PassFraction(bin.Bin.Floor)));