FillNetworkData uses NetBuffer instead of OutgoingMessage
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//protected Structure lastStructurePicked;
|
//protected Structure lastStructurePicked;
|
||||||
|
|
||||||
public virtual void FillNetworkData(NetOutgoingMessage message) { }
|
public virtual void FillNetworkData(NetBuffer message) { }
|
||||||
public virtual void ReadNetworkData(NetIncomingMessage message) { }
|
public virtual void ReadNetworkData(NetIncomingMessage message) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ namespace Barotrauma
|
|||||||
spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red);
|
spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(NetOutgoingMessage message)
|
public override void FillNetworkData(NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write((byte)state);
|
message.Write((byte)state);
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1186,7 +1186,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 5; i++ )
|
for (int i = 0; i < 5; i++ )
|
||||||
{
|
{
|
||||||
@@ -371,7 +371,7 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
public override void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
for (int i = 0; i<5; i++)
|
for (int i = 0; i<5; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -263,13 +263,13 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(item.SimPosition.X);
|
message.Write(item.SimPosition.X);
|
||||||
message.Write(item.SimPosition.Y);
|
message.Write(item.SimPosition.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
Vector2 newPos = Vector2.Zero;
|
Vector2 newPos = Vector2.Zero;
|
||||||
|
|
||||||
|
|||||||
@@ -701,11 +701,11 @@ namespace Barotrauma.Items.Components
|
|||||||
return ic;
|
return ic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void FillNetworkData(NetworkEventType type, NetOutgoingMessage message)
|
public virtual void FillNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,14 +166,14 @@ namespace Barotrauma.Items.Components
|
|||||||
if (!IsActive) currPowerConsumption = 0.0f;
|
if (!IsActive) currPowerConsumption = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.WriteRangedInteger(-10,10,(int)(flowPercentage/10.0f));
|
message.WriteRangedInteger(-10,10,(int)(flowPercentage/10.0f));
|
||||||
message.Write(IsActive);
|
message.Write(IsActive);
|
||||||
message.WritePadBits();
|
message.WritePadBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
float newFlow = 0.0f;
|
float newFlow = 0.0f;
|
||||||
bool newActive;
|
bool newActive;
|
||||||
|
|||||||
@@ -296,12 +296,12 @@ namespace Barotrauma.Items.Components
|
|||||||
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(IsActive);
|
message.Write(IsActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message)
|
public override void FillNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(autoTemp);
|
message.Write(autoTemp);
|
||||||
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16);
|
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16);
|
||||||
@@ -433,7 +433,7 @@ namespace Barotrauma.Items.Components
|
|||||||
message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8);
|
message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
public override void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
bool newAutoTemp;
|
bool newAutoTemp;
|
||||||
float newTemperature, newShutDownTemp;
|
float newTemperature, newShutDownTemp;
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(targetVelocity.X);
|
message.Write(targetVelocity.X);
|
||||||
message.Write(targetVelocity.Y);
|
message.Write(targetVelocity.Y);
|
||||||
@@ -217,7 +217,7 @@ namespace Barotrauma.Items.Components
|
|||||||
message.Write(autoPilot);
|
message.Write(autoPilot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
Vector2 newTargetVelocity = Vector2.Zero;
|
Vector2 newTargetVelocity = Vector2.Zero;
|
||||||
bool newAutoPilot = false;
|
bool newAutoPilot = false;
|
||||||
|
|||||||
@@ -196,13 +196,13 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(rechargeSpeed/MaxRechargeSpeed, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(rechargeSpeed/MaxRechargeSpeed, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(charge/capacity,0.0f, 1.0f), 0.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(charge/capacity,0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
float newRechargeSpeed = 0f;
|
float newRechargeSpeed = 0f;
|
||||||
float newCharge = 0.0f;
|
float newCharge = 0.0f;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace Barotrauma.Items.Components
|
|||||||
base.Remove();
|
base.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
foreach (Connection c in connections)
|
foreach (Connection c in connections)
|
||||||
{
|
{
|
||||||
@@ -137,7 +137,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("connectionpanel update");
|
System.Diagnostics.Debug.WriteLine("connectionpanel update");
|
||||||
foreach (Connection c in connections)
|
foreach (Connection c in connections)
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ namespace Barotrauma.Items.Components
|
|||||||
base.Remove();
|
base.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write((byte)Math.Min(Nodes.Count, 10));
|
message.Write((byte)Math.Min(Nodes.Count, 10));
|
||||||
for (int i = 0; i < Math.Min(Nodes.Count,10); i++)
|
for (int i = 0; i < Math.Min(Nodes.Count,10); i++)
|
||||||
@@ -438,7 +438,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
Nodes.Clear();
|
Nodes.Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ namespace Barotrauma
|
|||||||
spriteBatch.DrawString(GUI.Font, (int)item.Condition + " %", new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), Color.Red);
|
spriteBatch.DrawString(GUI.Font, (int)item.Condition + " %", new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public virtual bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
for (int i = 0; i<capacity; i++)
|
for (int i = 0; i<capacity; i++)
|
||||||
{
|
{
|
||||||
@@ -306,7 +306,7 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
List<ushort> newItemIDs = new List<ushort>();
|
List<ushort> newItemIDs = new List<ushort>();
|
||||||
|
|
||||||
|
|||||||
@@ -1223,7 +1223,7 @@ namespace Barotrauma
|
|||||||
NetworkEventType.ImportantComponentUpdate : NetworkEventType.ComponentUpdate, ID, isClient, index);
|
NetworkEventType.ImportantComponentUpdate : NetworkEventType.ComponentUpdate, ID, isClient, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
message.Write((byte)MathHelper.Clamp(condition*2.55f,0.0f,255.0f));
|
message.Write((byte)MathHelper.Clamp(condition*2.55f,0.0f,255.0f));
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
|||||||
dictionary.Add(id, this);
|
dictionary.Add(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public virtual bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Xml.Linq;
|
|||||||
using FarseerPhysics;
|
using FarseerPhysics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Lidgren.Network;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -471,7 +472,7 @@ namespace Barotrauma
|
|||||||
h.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
h.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(Networking.NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(volume/FullVolume, 0.0f, 1.5f), 0.0f, 1.5f, 6);
|
message.WriteRangedSingle(MathHelper.Clamp(volume/FullVolume, 0.0f, 1.5f), 0.0f, 1.5f, 6);
|
||||||
|
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
message.Write((float)NetTime.Now);
|
message.Write((float)NetTime.Now);
|
||||||
|
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ namespace Barotrauma
|
|||||||
Level.Loaded.Move(-amount);
|
Level.Loaded.Move(-amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(Networking.NetworkEventType type, NetOutgoingMessage message, object data)
|
public override bool FillNetworkData(Networking.NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
if (subBody == null) return false;
|
if (subBody == null) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -645,14 +645,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
NetOutgoingMessage message = server.CreateMessage();
|
NetOutgoingMessage message = server.CreateMessage();
|
||||||
message.Write((byte)PacketTypes.NetworkEvent);
|
message.Write((byte)PacketTypes.NetworkEvent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<byte[]> msgBytes = new List<byte[]>();
|
List<byte[]> msgBytes = new List<byte[]>();
|
||||||
|
|
||||||
foreach (NetworkEvent unreliableEvent in unreliableEvents)
|
foreach (NetworkEvent unreliableEvent in unreliableEvents)
|
||||||
{
|
{
|
||||||
NetOutgoingMessage tempMessage = server.CreateMessage();
|
NetBuffer tempMessage = new NetBuffer();// server.CreateMessage();
|
||||||
if (!unreliableEvent.FillData(tempMessage)) continue;
|
if (!unreliableEvent.FillData(tempMessage)) continue;
|
||||||
tempMessage.WritePadBits();
|
tempMessage.WritePadBits();
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ namespace Barotrauma.Networking
|
|||||||
ItemFixed = 9,
|
ItemFixed = 9,
|
||||||
|
|
||||||
UpdateProperty = 10,
|
UpdateProperty = 10,
|
||||||
WallDamage = 11,
|
WallDamage = 11
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class NetworkEvent
|
class NetworkEvent
|
||||||
@@ -123,7 +121,7 @@ namespace Barotrauma.Networking
|
|||||||
events.Add(this);
|
events.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FillData(NetOutgoingMessage message)
|
public bool FillData(NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write((byte)eventType);
|
message.Write((byte)eventType);
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user