From be96afc5dd58b1a56cc7e4c2cfa5addd9f8fe2c3 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 7 Apr 2019 21:44:02 +0300 Subject: [PATCH] (4ddf8b0b2) Fixed power not working correctly in some grids with chained relays and junction boxes. Closes #1385 --- .../Source/Items/Components/Power/PowerTransfer.cs | 11 ++++++----- .../Source/Items/Components/Signal/Connection.cs | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs index 3bd5416bb..157e5f8c8 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs @@ -354,11 +354,12 @@ namespace Barotrauma.Items.Components else { if (!powerTransfer.CanTransfer) continue; - powerTransfer.CheckJunctions( - deltaTime, - false, - (thisRelayComponent != null && c.IsOutput) ? 0.0f : clampPower, - (thisRelayComponent != null && !c.IsOutput) ? 0.0f : clampLoad); + float maxPowerIn = (thisRelayComponent != null && c.IsOutput) ? 0.0f : clampPower; + float maxPowerOut = (thisRelayComponent != null && !c.IsOutput) ? 0.0f : clampLoad; + if (maxPowerIn > 0.0f || maxPowerOut > 0.0f) + { + powerTransfer.CheckJunctions(deltaTime, false, maxPowerIn, maxPowerOut); + } } continue; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs index 27335ef0c..0765f40c0 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs @@ -55,6 +55,11 @@ namespace Barotrauma.Items.Components private set; } + public override string ToString() + { + return "Connection (" + item.Name + ", " + Name + ")"; + } + public Connection(XElement element, ConnectionPanel connectionPanel) {