Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,24 @@ private IPluginRealtimeOutputSource FeedOf(PluginResourceBinding<IPluginRealtime
_feed = outputs.State == ResourceBindingState.Blocked ? "none (" + outputs.Diagnostic + ")" : "none (the game reports no real-time outputs)";
return null;
}
if (outputs.Source.Numbering != RealtimeOutputNumbering.PinMame) {
if (!Reads(outputs.Source.Numbering)) {
_feed = $"none (the game's real-time outputs use the {outputs.Source.Numbering} numbering, which DOF does not know)";
return null;
}
_feed = RealtimeFeed;
return outputs.Source;
}

/// <summary>
/// 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.
/// </summary>
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(() => { });
}
Expand Down
24 changes: 24 additions & 0 deletions VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Loading