From 4253e258f8bf02e98d2d2c45b6872c3b1d06cb9e Mon Sep 17 00:00:00 2001 From: freezy Date: Mon, 30 Nov 2026 11:38:16 +0100 Subject: [PATCH] feed: follow games numbered by their service manual DOF now also follows real-time outputs in the service-manual numbering, which gamelogic engines other than PinMAME use. DOF takes the numbers as they come, so a configuration's rows for such a game use the manual's driver, switch, light and motor numbers. --- .../Runtime/Player/DofPlugin.cs | 11 +++++++-- .../Tests/DofPluginTests.cs | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs b/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs index 970a408..ade2e75 100644 --- a/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs +++ b/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs @@ -244,7 +244,7 @@ private IPluginRealtimeOutputSource FeedOf(PluginResourceBinding + /// Whether DOF can follow a feed in this numbering. DOF takes the numbers as they come, so the configuration's rows + /// must use the same: VPinMAME's for PinMAME games, the service manual's for games numbered that way. + /// + private static bool Reads(string numbering) + => numbering == RealtimeOutputNumbering.PinMame || numbering == RealtimeOutputNumbering.ServiceManual; + private IDisposable Subscribe(IPluginRealtimeOutputSource source, DofGameSession session) { - if (source.Numbering != RealtimeOutputNumbering.PinMame) { + if (!Reads(source.Numbering)) { // A replacement DOF cannot follow; the source it replaced already faulted the session when it went. return new Subscription(() => { }); } diff --git a/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs b/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs index fa0e802..f7bf812 100644 --- a/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs +++ b/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs @@ -681,6 +681,30 @@ public IEnumerator IgnoresAnAbandonedSnapshotAttempt() yield return host.Await(host.Plugin.Quiescence, "quiescence"); } + [UnityTest] + public IEnumerator FollowsAFeedInServiceManualNumbers() + { + const int universe = 350; + var host = Host(); + host.Import(universe, "vpetest,S12,L160"); + var feed = host.PublishFeed(RealtimeOutputNumbering.ServiceManual); + yield return host.Await(host.Plugin.PrepareGameAsync(host.Game(), CancellationToken.None), "prepare"); + Assert.That(host.Plugin.FollowsFeed, Is.True); + Assert.That(feed.HasReceivers, Is.True); + yield return host.Await(host.Plugin.StartGameAsync(CancellationToken.None), "start"); + + Assert.That(feed.BeginSnapshot(), Is.True); + feed.PublishSnapshot(RealtimeOutputKind.Solenoid, 12, 0); + feed.PublishSnapshot(RealtimeOutputKind.Lamp, 160, 0); + feed.EndSnapshot(); + feed.Publish(RealtimeOutputKind.Solenoid, 12, 255); + feed.Publish(RealtimeOutputKind.Lamp, 160, 255); + Expect(universe, f => f[0] == 255 && f[1] == 255, "the manual's numbers reach the configuration's rows"); + + yield return host.Await(host.Plugin.StopGameAsync(CancellationToken.None), "stop"); + yield return host.Await(host.Plugin.Quiescence, "quiescence"); + } + [UnityTest] public IEnumerator FollowsOnlyTheTriggersOfAFeedItCannotRead() {