Sending NetTime at the start of a combined networkevent instead of individual networkevents, syncing itemcomponents for spectators, AICharacter importantentityupdates are sent again, misc bugfixes, some new heads

This commit is contained in:
Regalis
2015-11-20 17:12:33 +02:00
parent 8ec7fd44ff
commit cddf4f1bde
37 changed files with 269 additions and 130 deletions

View File

@@ -69,7 +69,7 @@ namespace Barotrauma
{
return false;
}
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
{
data = null;
}

View File

@@ -559,7 +559,7 @@ namespace Barotrauma
return true;
}
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, out object data)
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime, out object data)
{
data = null;

View File

@@ -639,8 +639,6 @@ namespace Barotrauma
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
{
message.Write((float)NetTime.Now);
//var updateSections = Array.FindAll(sections, s => s != null && Math.Abs(s.damage - s.lastSentDamage) > 0.01f);
//if (updateSections.Length == 0) return false;
@@ -662,12 +660,11 @@ namespace Barotrauma
return true;
}
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
{
data = null;
float updateTime = message.ReadFloat();
if (updateTime < lastUpdate) return;
if (sendingTime < lastUpdate) return;
// int sectionCount = message.ReadByte();
@@ -681,7 +678,7 @@ namespace Barotrauma
SetDamage(i, damage);
}
lastUpdate = updateTime;
lastUpdate = sendingTime;
}
}

View File

@@ -391,7 +391,6 @@ namespace Barotrauma
{
if (subBody == null) return false;
message.Write((float)NetTime.Now);
message.Write(Position.X);
message.Write(Position.Y);
@@ -401,16 +400,13 @@ namespace Barotrauma
return true;
}
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message, out object data)
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
{
data = null;
float sendingTime;
Vector2 newTargetPosition, newSpeed;
try
{
sendingTime = message.ReadFloat();
if (sendingTime <= lastNetworkUpdate) return;
newTargetPosition = new Vector2(message.ReadFloat(), message.ReadFloat());

View File

@@ -195,9 +195,19 @@ namespace Barotrauma
Vector2 translateAmount = speed * deltaTime;
translateAmount += ConvertUnits.ToDisplayUnits(body.Position) * collisionRigidness;
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, sub.Position) > 50.0f)
if (targetPosition != Vector2.Zero && targetPosition != sub.Position)
{
translateAmount += (targetPosition - sub.Position) * 0.01f;
float dist = Vector2.Distance(targetPosition, sub.Position);
if (dist>1000.0f)
{
sub.SetPosition(targetPosition);
targetPosition = Vector2.Zero;
}
else if (dist>50.0f)
{
translateAmount += (targetPosition - sub.Position) * 0.01f;
}
}
else
{