Unstable 0.17.1.0
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
@@ -41,16 +42,16 @@ namespace Barotrauma.Networking
|
||||
thisClient = client;
|
||||
}
|
||||
|
||||
public void CreateEvent(IClientSerializable entity, object[] extraData = null)
|
||||
public void CreateEvent(IClientSerializable entity, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
if (GameMain.Client?.Character == null) { return; }
|
||||
|
||||
if (!ValidateEntity(entity)) { return; }
|
||||
|
||||
var newEvent = new ClientEntityEvent(entity, (UInt16)(ID + 1))
|
||||
{
|
||||
CharacterStateID = GameMain.Client.Character.LastNetworkUpdateID
|
||||
};
|
||||
var newEvent = new ClientEntityEvent(
|
||||
entity,
|
||||
eventId: (UInt16)(ID + 1),
|
||||
characterStateId: GameMain.Client.Character.LastNetworkUpdateID);
|
||||
if (extraData != null) { newEvent.SetData(extraData); }
|
||||
|
||||
for (int i = events.Count - 1; i >= 0; i--)
|
||||
@@ -144,6 +145,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
entities.Clear();
|
||||
|
||||
msg.ReadPadBits();
|
||||
UInt16 firstEventID = msg.ReadUInt16();
|
||||
int eventCount = msg.ReadByte();
|
||||
|
||||
@@ -172,7 +174,6 @@ namespace Barotrauma.Networking
|
||||
DebugConsole.NewMessage("received msg " + thisEventID + " (null entity)",
|
||||
Microsoft.Xna.Framework.Color.Orange);
|
||||
}
|
||||
msg.ReadPadBits();
|
||||
entities.Add(null);
|
||||
if (thisEventID == (UInt16)(lastReceivedID + 1)) { lastReceivedID++; }
|
||||
continue;
|
||||
@@ -207,7 +208,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
msg.BitPosition += msgLength * 8;
|
||||
msg.ReadPadBits();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,22 +239,22 @@ namespace Barotrauma.Networking
|
||||
//msg.BitPosition = (int)(msgPosition + msgLength * 8);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
string errorMsg = "Failed to read event for entity \"" + entity.ToString() + "\" (" + e.Message + ")! (MidRoundSyncing: " + thisClient.MidRoundSyncing + ")\n" + e.StackTrace.CleanupStackTrace();
|
||||
string errorMsg = $"Failed to read event {thisEventID} for entity \"{entity}\"" +
|
||||
$"{(entity is Entity { ID: var entityId } ? $", id {entityId}" : "")} ";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
|
||||
errorMsg += $"({e.Message})! (MidRoundSyncing: {thisClient.MidRoundSyncing})\n{e.StackTrace.CleanupStackTrace()}";
|
||||
errorMsg += "\nPrevious entities:";
|
||||
for (int j = entities.Count - 2; j >= 0; j--)
|
||||
{
|
||||
errorMsg += "\n" + (entities[j] == null ? "NULL" : entities[j].ToString());
|
||||
}
|
||||
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "\"!", e);
|
||||
|
||||
GameAnalyticsManager.AddErrorEventOnce("ClientEntityEventManager.Read:ReadFailed" + entity.ToString(),
|
||||
GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
msg.BitPosition = (int)(msgPosition + msgLength * 8);
|
||||
msg.ReadPadBits();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
protected void ReadEvent(IReadMessage buffer, IServerSerializable entity, float sendingTime)
|
||||
{
|
||||
entity.ClientRead(ServerNetObject.ENTITY_EVENT, buffer, sendingTime);
|
||||
entity.ClientEventRead(buffer, sendingTime);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
|
||||
Reference in New Issue
Block a user