diff --git a/Assets/Scripts/ServerShared/StationWants.cs b/Assets/Scripts/ServerShared/StationWants.cs index 3fd6077db..00e5248a2 100644 --- a/Assets/Scripts/ServerShared/StationWants.cs +++ b/Assets/Scripts/ServerShared/StationWants.cs @@ -166,7 +166,8 @@ public static class StationWants return holding; } - private static int Stack(CultCache catalog, CultRecordKey good) => catalog.Get(good)?.MaxStack ?? 1; + private static int Stack(CultCache catalog, CultRecordKey good) => + catalog.Get(good) is CompoundCommodityData compound ? compound.MaxStack : catalog.Get(good)?.MaxStack ?? 1; // The cells the floors take: each good's one-cycle floor in MaxStack units. A hull whose floors exceed its stock room cannot start a cycle // of every slot at once. diff --git a/tests/Aetheria.Shared.Tests/DemoLoopTests.cs b/tests/Aetheria.Shared.Tests/DemoLoopTests.cs index f70f6b074..f5ae35a98 100644 --- a/tests/Aetheria.Shared.Tests/DemoLoopTests.cs +++ b/tests/Aetheria.Shared.Tests/DemoLoopTests.cs @@ -82,9 +82,12 @@ public sealed partial class RunStartTests var oreGood = zenithWants.OrderBy(good => good.Value, StringComparer.Ordinal).First(); var fresh = new SimpleCommodity { Data = new CultRecordRef(oreGood), Quantity = 5 }; Assert.True(player.CargoBays[0].TryStore(fresh)); - var atZenith = StationServices.TrySellPart(player.CargoBays[0], zenith, fresh, ref credits); - Assert.Equal((5, SaleRefusal.None), (atZenith.Sold, atZenith.Refusal)); - Assert.Equal(5, silo.Count(oreGood)); + // The refinery takes only its shares of the ore, so the hold may still carry this good and the five units merge into its stack: sell the stack the hold holds. + var offered = player.CargoBays[0].Cargo.Keys.OfType().First(stack => stack.Data.Key.Equals(oreGood)); + var atZenith = StationServices.TrySellPart(player.CargoBays[0], zenith, offered, ref credits); + Assert.Equal((atZenith.Offered, SaleRefusal.None), (atZenith.Sold, atZenith.Refusal)); + Assert.True(atZenith.Sold >= 5); + Assert.Equal(atZenith.Sold, silo.Count(oreGood)); var cell = Enumerable.Range(0, player.MaxArmor.GetLength(0)).SelectMany(x => Enumerable.Range(0, player.MaxArmor.GetLength(1)).Select(y => (x, y))) .First(c => player.MaxArmor[c.x, c.y] > 0);