From 464078e565629574568ce58bcbfa44342dc3a383 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 3 May 2017 21:28:09 +0300 Subject: [PATCH] Clients can't send wire positions to the server --- .../Components/Signal/ConnectionPanel.cs | 2 +- .../Source/Items/Components/Signal/Wire.cs | 37 +++---------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index 8b12ec07c..0e2b2c4ef 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -227,7 +227,7 @@ namespace Barotrauma.Items.Components if (wires[i, j] == null) continue; Connections[i].Wires[j] = wires[i,j]; - wires[i, j].Connect(Connections[i], false); + wires[i, j].Connect(Connections[i], true); var otherConnection = Connections[i].Wires[j].OtherConnection(Connections[i]); diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index ceadb317a..a92b9aba8 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -11,7 +11,7 @@ using System.Xml.Linq; namespace Barotrauma.Items.Components { - class Wire : ItemComponent, IDrawableComponent, IServerSerializable, IClientSerializable + class Wire : ItemComponent, IDrawableComponent, IServerSerializable { class WireSection { @@ -202,10 +202,6 @@ namespace Barotrauma.Items.Components { item.CreateServerEvent(this); } - else if (GameMain.Client != null) - { - item.CreateClientEvent(this); - } //the wire is active if only one end has been connected IsActive = connections[0] == null ^ connections[1] == null; } @@ -715,8 +711,8 @@ namespace Barotrauma.Items.Components base.RemoveComponentSpecific(); } - - public void ClientWrite(NetBuffer msg, object[] extraData = null) + + public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null) { msg.Write((byte)Math.Min(nodes.Count, 255)); for (int i = 0; i < Math.Min(nodes.Count, 255); i++) @@ -726,7 +722,7 @@ namespace Barotrauma.Items.Components } } - public void ServerRead(ClientNetObject type, NetBuffer msg, Client c) + public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) { nodes.Clear(); @@ -735,10 +731,9 @@ namespace Barotrauma.Items.Components for (int i = 0; i < nodeCount; i++) { - nodePositions[i] = new Vector2(msg.ReadFloat(), msg.ReadFloat()); + nodePositions[i] = new Vector2(msg.ReadFloat(), msg.ReadFloat()); } - - if (!item.CanClientAccess(c)) return; + if (nodePositions.Any(n => !MathUtils.IsValid(n))) return; nodes = nodePositions.ToList(); @@ -746,26 +741,6 @@ namespace Barotrauma.Items.Components UpdateSections(); Drawable = nodes.Any(); } - - public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null) - { - ClientWrite(msg, extraData); - } - - public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) - { - nodes.Clear(); - - int nodeCount = msg.ReadByte(); - for (int i = 0; i < nodeCount; i++) - { - Vector2 newNode = new Vector2(msg.ReadFloat(), msg.ReadFloat()); - if (MathUtils.IsValid(newNode)) nodes.Add(newNode); - } - - UpdateSections(); - Drawable = nodes.Any(); - } } }