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:
@@ -286,42 +286,6 @@ namespace Barotrauma.Items.Components
|
||||
Msg = "";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||
{
|
||||
message.Write(item.SimPosition.X);
|
||||
message.Write(item.SimPosition.Y);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
Vector2 newPos = Vector2.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
newPos = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
item.SetTransform(newPos, 0.0f);
|
||||
if (!attached)
|
||||
{
|
||||
Use(1.0f);
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null && sender.Character != null)
|
||||
{
|
||||
Networking.GameServer.Log(sender.characterInfo.Name+" attached a "+item.Name+" on a wall", Color.Orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user