Clients can't send wire positions to the server
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user