Pin the mine-layer gate exemption and Solve's target argument (Soul s1 findings)

AMineLayerLaysWithTheAimOutsideItsArc: an unfused mine layer passes ArcPermitsFire and lays with the aim outside
its arc. SolveFliesToTheTargetItIsGiven: Solve flies to the decoy it is passed, not the designated target.
ATargetOutOfArcGivesNoSolution also asserts the subject of a designated target out of arc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-08 15:21:20 +02:00
commit b38589a1b4
2 changed files with 46 additions and 0 deletions

View file

@ -446,6 +446,22 @@ public sealed class MineTests : IDisposable
Assert.True(shipsA[4].Hull.Durability < 1000000f);
}
// The trigger gate never arcs a mine layer (FireControl.ArcPermitsFire): it lays a body, not a round, so a cursor
// outside its arc still lays. The layer is unfused (no Fuse), so the fused exemption cannot cover it and only the
// mine-layer exemption can; the fixture checks the aim is outside the arc and the gate would hold any other gun.
[Fact]
public void AMineLayerLaysWithTheAimOutsideItsArc()
{
var lab = Build(fuseKind: null);
Assert.Null(FireControl.FuseOf(lab.WeaponItem, out _));
var mount = FireControl.MountDirection(lab.WeaponItem);
lab.Layer.Aim = -mount;
Assert.False(FireControl.InArc(lab.WeaponItem, lab.Layer.Aim), "fixture: the aim must be outside the arc");
Assert.True(FireControl.ArcPermitsFire(lab.Weapon, lab.Layer));
LayOne(lab);
}
[Fact]
public void LayingFiresNoShot()
{

View file

@ -71,6 +71,7 @@ public sealed partial class FireControlCut124Tests
Assert.True(solution.Free);
Assert.True(FireControl.ArcPermitsFire(e.Weapon, e.Shooter));
Near(float2(0, 1), solution.Direction);
Assert.Same(e.Target, solution.Subject);
Assert.Equal(0f, FireControl.HitProbability(e.Weapon, e.Shooter, e.Target));
}
@ -177,4 +178,33 @@ public sealed partial class FireControlCut124Tests
Assert.True(FireControl.AgentFires(e.Weapon, e.Shooter, e.Target));
Near(intercept, solution.Direction);
}
// Solve flies along the solution against the target it is given, not the shooter's designated one (the HUD forecast
// and an agent's burst ask about other entities). A decoy 40 degrees off, in the same zone, is passed while the
// designated target sits dead ahead; the round goes to the decoy's intercept. Kills a Solve that reads the shooter's
// target, a constant, or a swapped argument; the fixture checks the two intercepts differ.
[Fact]
public void SolveFliesToTheTargetItIsGiven()
{
var e = Build(TestSettings(), SolidShape(5, 4), hardpointArc: SolutionArc, weaponRange: 200f);
var hull = e.Items.ItemData.RefOf<ItemData>(e.HullData);
var decoy = new Ship(e.Items, e.Zone, new EquippableItem { Data = hull, Durability = 1000000, Lot = 9000 }, new EntitySettings());
e.Zone.Entities.Add(decoy);
decoy.Activate();
var at = radians(40f);
decoy.Position = e.Shooter.Position + float3(sin(at), 0, cos(at)) * 100f;
e.Shooter.VisibleEntities.Add(decoy);
e.Shooter.EntityInfoGathered[decoy] = 1f;
e.Shooter.SetIff(decoy, true);
Aim(e, float2(0, -1));
var designated = FireControl.Solution(e.Weapon, e.Shooter, e.Target).Direction;
var other = FireControl.Solution(e.Weapon, e.Shooter, decoy).Direction;
Assert.True(FireControl.Bears(e.Weapon, e.Shooter, decoy, out _));
Assert.True(length(designated - other) > .3f, "fixture: the two intercepts must differ");
Assert.Same(e.Target, e.Shooter.Target.Value.Entity);
Near(other, FireControl.Solve(e.Weapon, e.WeaponItem, e.Shooter, decoy).TravelDirection);
Near(designated, FireControl.Solve(e.Weapon, e.WeaponItem, e.Shooter, e.Target).TravelDirection);
}
}