Removed Fill/ReadNetworkData

These functions needed to be replaced because they rely heavily on reliability.

Instead, new functions called (Write/Read)Data(Server/Client) will be added. 

Separating client and server code into completely separate functions will help ensure that proper security checks are performed.
This commit is contained in:
juanjp600
2016-08-29 20:02:46 -03:00
parent a00ceb5b9f
commit af220dbc2a
28 changed files with 29 additions and 2297 deletions
@@ -525,35 +525,6 @@ namespace Barotrauma.Items.Components
base.RemoveComponentSpecific();
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
{
message.Write((byte)Math.Min(Nodes.Count, 10));
for (int i = 0; i < Math.Min(Nodes.Count,10); i++)
{
message.Write(Nodes[i].X);
message.Write(Nodes[i].Y);
}
return true;
}
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
{
Nodes.Clear();
List<Vector2> newNodes = new List<Vector2>();
int nodeCount = message.ReadByte();
for (int i = 0; i<nodeCount; i++)
{
Vector2 newNode = new Vector2(message.ReadFloat(), message.ReadFloat());
if (!MathUtils.IsValid(newNode)) return;
newNodes.Add(newNode);
}
Nodes = newNodes;
Drawable = Nodes.Any();
}
}
}