From 7d346c1437d74c0c6e6bacf058e9813fe8b3ed48 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 15 Feb 2018 14:23:39 +0200 Subject: [PATCH] Fixed wires dropping when a client moves them from a connection to another in the same connection panel, fixed wires becoming disconnected client-side if they're moved from a connection to another connection that's upper in the connection panel. (See #252) --- .../Source/Items/Components/Signal/ConnectionPanel.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs index f82c732d3..f01912854 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs @@ -235,7 +235,7 @@ namespace Barotrauma.Items.Components //wires that are not in anyone's inventory (i.e. not currently being rewired) //can never be connected to only one connection // -> the client must have dropped the wire from the connection panel - if (existingWire.Item.ParentInventory == null) + if (existingWire.Item.ParentInventory == null && !wires.Any(w => w.Contains(existingWire))) { //let other clients know the item was also disconnected from the other connection existingWire.Connections[0].Item.CreateServerEvent(existingWire.Connections[0].Item.GetComponent()); @@ -247,7 +247,7 @@ namespace Barotrauma.Items.Components GameServer.Log(c.Character.LogName + " disconnected a wire from " + Connections[i].Item.Name + " (" + Connections[i].Name + ") to " + existingWire.Connections[1].Item.Name + " (" + existingWire.Connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); - if (existingWire.Item.ParentInventory == null) + if (existingWire.Item.ParentInventory == null && !wires.Any(w => w.Contains(existingWire))) { //let other clients know the item was also disconnected from the other connection existingWire.Connections[1].Item.CreateServerEvent(existingWire.Connections[1].Item.GetComponent()); @@ -304,6 +304,10 @@ namespace Barotrauma.Items.Components foreach (Connection connection in Connections) { connection.ClearConnections(); + } + + foreach (Connection connection in Connections) + { int wireCount = msg.ReadRangedInteger(0, Connection.MaxLinked); for (int i = 0; i < wireCount; i++) {