Unstable 0.15.15.0 (and the one before it I forgor)

This commit is contained in:
Markus Isberg
2021-11-18 21:34:30 +09:00
parent 10e5fd5f3e
commit 80f39cd2a3
257 changed files with 4916 additions and 2582 deletions

View File

@@ -27,7 +27,6 @@ namespace Barotrauma.Networking
{
WriteEvent(tempEventBuffer, e, recipient);
}
catch (Exception exception)
{
DebugConsole.ThrowError("Failed to write an event for the entity \"" + e.Entity + "\"", exception);
@@ -55,7 +54,7 @@ namespace Barotrauma.Networking
tempBuffer.WriteVariableUInt32((uint)tempEventBuffer.LengthBytes);
tempBuffer.Write(tempEventBuffer.Buffer, 0, tempEventBuffer.LengthBytes);
tempBuffer.WritePadBits();
sentEvents.Add(e);
sentEvents.Add(e);
eventCount++;
}
@@ -68,6 +67,32 @@ namespace Barotrauma.Networking
}
}
protected static bool ValidateEntity(INetSerializable entity)
{
void error(string reason)
=> DebugConsole.ThrowError($"Can't create an entity event for {entity} - {reason}.\n{Environment.StackTrace.CleanupStackTrace()}");
if (entity is Entity { Removed: var removed, IdFreed: var idFreed })
{
if (removed)
{
error("the entity has been removed");
return false;
}
if (idFreed)
{
error("the ID of the entity has been freed");
return false;
}
}
else
{
error($"input is not of type {nameof(Entity)}");
return false;
}
return true;
}
protected abstract void WriteEvent(IWriteMessage buffer, NetEntityEvent entityEvent, Client recipient = null);
}
}