diff --git a/Assets/Scripts/ServerShared/ThrustAllocator.cs b/Assets/Scripts/ServerShared/ThrustAllocator.cs index 09b37aebf..f2be04f3e 100644 --- a/Assets/Scripts/ServerShared/ThrustAllocator.cs +++ b/Assets/Scripts/ServerShared/ThrustAllocator.cs @@ -40,7 +40,6 @@ public sealed class ThrustAllocator var vars = n + ErrorVariables; var rows = FixedRows + n; Array.Clear(_a, 0, rows * vars); - Array.Clear(_b, 0, rows); // Rows 0 and 1 are the translation axes (starboard, forward), row 2 the yaw. for (var axis = 0; axis < 3; axis++) diff --git a/tests/Aetheria.Shared.Tests/ThrustAllocatorTests.cs b/tests/Aetheria.Shared.Tests/ThrustAllocatorTests.cs index 0b0e5be18..26c50e35d 100644 --- a/tests/Aetheria.Shared.Tests/ThrustAllocatorTests.cs +++ b/tests/Aetheria.Shared.Tests/ThrustAllocatorTests.cs @@ -290,4 +290,25 @@ public class ThrustAllocatorTests for (var i = 0; i < columns.Length; i++) Assert.True(MathF.Abs(warm[i] - fresh[i]) <= 1e-5f, $"{columns.Length} columns: throttle {i}"); } } + + [Fact] + public void AShipWithOneThrusterIsFlownFromItsFirstCall() + { + var throttle = Solve(new[] { Col(0, 50, 0) }, 0, 1, 0); + Assert.True(throttle[0] > .99f, $"{throttle[0]}"); + } + + [Fact] + public void ChangedColumnsOfTheSameCountLeaveNothingBehind() + { + // Thruster 1 first strafes, then only pushes forward: the strafe row it left must not shape the second answer. + var strafing = new[] { Col(0, 60, 0), Col(30, 0, 0), Col(-20, 0, 0) }; + var forwardOnly = new[] { Col(0, 60, 0), Col(0, 40, 0), Col(0, -20, 0) }; + var allocator = new ThrustAllocator(); + Solve(allocator, strafing, 1, 1, .5f); + var warm = Solve(allocator, forwardOnly, 0, 1, 0); + var fresh = Solve(forwardOnly, 0, 1, 0); + for (var i = 0; i < warm.Length; i++) Assert.True(MathF.Abs(warm[i] - fresh[i]) <= 1e-5f, $"throttle {i}: {warm[i]} vs {fresh[i]}"); + Assert.True(warm[1] > .9f, $"{warm[1]}"); + } }