Networking bugfixes & improvements:

- fixed server not sending kill-events when a monster dies
- some interpolation when correcting character positions
- physicsbody position lerping improvements
- sending AICharacter Dir instead of TargetDir
This commit is contained in:
Regalis
2016-03-09 16:49:56 +02:00
parent 37f70a1028
commit a1c728d207
13 changed files with 126 additions and 95 deletions

View File

@@ -778,7 +778,7 @@ namespace Barotrauma.Networking
Vector2 position = new Vector2(message.ReadFloat(), message.ReadFloat());
var character = Character.Create(configPath, position);
var character = Character.Create(configPath, position, null, true);
if (character != null) character.ID = id;
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Lidgren.Network;
using System;
using System.Linq;
namespace Barotrauma.Networking
{
@@ -101,31 +102,24 @@ namespace Barotrauma.Networking
get { return eventType; }
}
public NetworkEvent(ushort id, bool isClient)
: this(NetworkEventType.EntityUpdate, id, isClient)
public NetworkEvent(ushort id, bool allowClientSend)
: this(NetworkEventType.EntityUpdate, id, allowClientSend)
{
}
public NetworkEvent(NetworkEventType type, ushort id, bool isClient, object data = null)
public NetworkEvent(NetworkEventType type, ushort id, bool allowClientSend, object data = null)
{
if (isClient)
{
if (GameMain.Server != null && GameMain.Server.Character == null) return;
}
else
{
if (GameMain.Server == null) return;
}
if (!allowClientSend && GameMain.Server != null) return;
eventType = type;
if (overridePrevious[(int)type])
{
if (Events.Find(e => e.id == id && e.eventType == type) != null) return;
if (Events.Any(e => e.id == id && e.eventType == type)) return;
}
this.id = id;
isClientEvent = isClient;
isClientEvent = allowClientSend;
this.data = data;

View File

@@ -355,10 +355,10 @@ namespace Barotrauma.Networking.ReliableMessages
return;
}
if (lastMessageID > messageId && Math.Abs((int)lastMessageID - (int)messageId) < ushort.MaxValue / 2)
if (messageId < lastMessageID && Math.Abs((int)lastMessageID - (int)messageId) < ushort.MaxValue / 2)
{
//shouldn't happen: we have somehow received messages that the other end hasn't sent
Debug.WriteLine("Reliable message error - recipient last sent: " + messageId + " (current count " + lastMessageID + ")");
Debug.WriteLine("Received id update message: " + messageId + ": ignoring, already received (" + lastMessageID + ")");
return;
}