commit ccacceb16a184f00ecd384eede64ca9c4fab08a0 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 14:05:59 2019 +0200 NetEntityEventManager checks the length of the event data (and logs an error if it's too long) before checking if there's still room to keep writing events in the packet. Checking the available room first could lead to situations where an excessively large event can't fit to any packet, "soft-locking" the EventManager without any error messages. commit 5ac8259372aa900adc724aa4da1fd81af41ca195 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 13:41:52 2019 +0200 Don't display disabled limbs on sonar (i.e. severed limbs that have "faded out") commit 5f84df73ad86be96f3678c450351b3905e7317a4 Merge: b981f1635 dc429d6c4 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 13:41:16 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev commit b981f163575b2bfc9a83b9925c94eca19b9d4554 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 13:36:19 2019 +0200 Multiplayer campaign fixes: - Server uses a different temp folder to decompress save/sub files into than the clients. Should fix files occasionally getting corrupted and exceptions when trying to read the files when hosting a server from the main executable. - Some additional debug logging. - Use the base names of the adjacent locations as level seeds (i.e. "Vorta" instead of "Vorta Outpost"). The levels should not change when the type (and full name) of the location changes. commit 42c5d18df77fc7acd5873d8e25f20bdd31b1ed76 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 13:31:06 2019 +0200 Don't transfer files through the network when sending them to the owner of the server (i.e. a client hosting directly from the main executable), but simply tell the client where the file is located. commit dc429d6c450f4893fe29c51d3c830527e587a871 Author: Daniel Asteljoki <daniel.asteljoki@gmail.com> Date: Mon Mar 25 13:30:26 2019 +0200 Added labels next to periscopes in Humpback and Dugong commit 789f02a87a2917dd2ae378f136cbe8dd3236c60d Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 13:29:29 2019 +0200 If loading a submarine fails, wait a bit and retry up to 4 times. Fixes loading occasionally failing when running multiple instances of the game from the same directory. commit be9ea3a58832992b6226917117247e1bf1efeff9 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 11:03:36 2019 +0200 Fixed a bunch of disconnection messages being in an incorrect format & DisconnectUnauthClient not getting the messages from the xml commit c6f744b4d6b3520720010f5cd4f22a25b42bfc8b Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Mon Mar 25 10:43:10 2019 +0200 Log entity event errors into server logs when verbose logging is enabled
88 lines
3.9 KiB
C#
88 lines
3.9 KiB
C#
using Lidgren.Network;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Barotrauma.Networking
|
|
{
|
|
abstract class NetEntityEventManager
|
|
{
|
|
public const int MaxEventBufferLength = 1024;
|
|
|
|
/// <summary>
|
|
/// Write the events to the outgoing message. The recipient parameter is only needed for ServerEntityEventManager
|
|
/// </summary>
|
|
protected void Write(NetOutgoingMessage msg, List<NetEntityEvent> eventsToSync, out List<NetEntityEvent> sentEvents, Client recipient = null)
|
|
{
|
|
//write into a temporary buffer so we can write the number of events before the actual data
|
|
NetBuffer tempBuffer = new NetBuffer();
|
|
|
|
sentEvents = new List<NetEntityEvent>();
|
|
|
|
int eventCount = 0;
|
|
foreach (NetEntityEvent e in eventsToSync)
|
|
{
|
|
//write into a temporary buffer so we can write the length before the actual data
|
|
NetBuffer tempEventBuffer = new NetBuffer();
|
|
try
|
|
{
|
|
WriteEvent(tempEventBuffer, e, recipient);
|
|
}
|
|
|
|
catch (Exception exception)
|
|
{
|
|
DebugConsole.ThrowError("Failed to write an event for the entity \"" + e.Entity + "\"", exception);
|
|
GameAnalyticsManager.AddErrorEventOnce("NetEntityEventManager.Write:WriteFailed" + e.Entity.ToString(),
|
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
|
"Failed to write an event for the entity \"" + e.Entity + "\"\n" + exception.StackTrace);
|
|
|
|
//write an empty event to avoid messing up IDs
|
|
//(otherwise the clients might read the next event in the message and think its ID
|
|
//is consecutive to the previous one, even though we skipped over this broken event)
|
|
tempBuffer.Write(Entity.NullEntityID);
|
|
tempBuffer.WritePadBits();
|
|
eventCount++;
|
|
continue;
|
|
}
|
|
|
|
//the length of the data is written as a byte, so the data needs to be less than 255 bytes long
|
|
if (tempEventBuffer.LengthBytes > 255)
|
|
{
|
|
DebugConsole.ThrowError("Too much data in network event for entity \"" + e.Entity.ToString() + "\" (" + tempEventBuffer.LengthBytes + " bytes");
|
|
GameAnalyticsManager.AddErrorEventOnce("NetEntityEventManager.Write:TooLong" + e.Entity.ToString(),
|
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
|
"Too much data in network event for entity \"" + e.Entity.ToString() + "\" (" + tempEventBuffer.LengthBytes + " bytes");
|
|
|
|
//write an empty event to prevent breaking the event syncing
|
|
tempBuffer.Write(Entity.NullEntityID);
|
|
tempBuffer.WritePadBits();
|
|
eventCount++;
|
|
continue;
|
|
}
|
|
|
|
if (msg.LengthBytes + tempBuffer.LengthBytes + tempEventBuffer.LengthBytes > MaxEventBufferLength)
|
|
{
|
|
//no more room in this packet
|
|
break;
|
|
}
|
|
|
|
tempBuffer.Write((UInt16)e.Entity.ID);
|
|
tempBuffer.Write((byte)tempEventBuffer.LengthBytes);
|
|
tempBuffer.Write(tempEventBuffer);
|
|
tempBuffer.WritePadBits();
|
|
sentEvents.Add(e);
|
|
|
|
eventCount++;
|
|
}
|
|
|
|
if (eventCount > 0)
|
|
{
|
|
msg.Write(eventsToSync[0].ID);
|
|
msg.Write((byte)eventCount);
|
|
msg.Write(tempBuffer);
|
|
}
|
|
}
|
|
|
|
protected abstract void WriteEvent(NetBuffer buffer, NetEntityEvent entityEvent, Client recipient = null);
|
|
}
|
|
}
|