Skip to content

Commit

Permalink
v1.4.0b6
Browse files Browse the repository at this point in the history
Improvements and support for Mirror 37+ (tested on Mirror 40)
  • Loading branch information
SoftwareGuy committed Jun 14, 2021
1 parent 3b9d198 commit f1b39e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
25 changes: 21 additions & 4 deletions Assets/Mirror/Runtime/Transport/Ignorance/Ignorance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ public override void ClientDisconnect()
ClientState = ConnectionState.Disconnected;
}

#if !MIRROR_37_0_OR_NEWER
public override void ClientSend(int channelId, ArraySegment<byte> segment)
#else
// v1.4.0b6: Mirror rearranged the ClientSend params, so we need to apply a fix for that or
// we end up using the obsoleted version. The obsolete version isn't a fatal error, but
// it's best to stick with the new structures.
public override void ClientSend(ArraySegment<byte> segment, int channelId)
#endif
{
if (Client == null)
{
Expand All @@ -153,7 +160,7 @@ public override void ClientSend(int channelId, ArraySegment<byte> segment)
bool flagsSet = (desiredFlags & ReliableOrUnreliableFragmented) > 0;

if (LogType != IgnoranceLogType.Nothing && byteCount > 1200 && !flagsSet)
Debug.LogWarning($"Warning: Server trying to send a Unreliable packet bigger than the recommended ENet 1200 byte MTU ({byteCount} > 1200). ENet will force Reliable Fragmented delivery.");
Debug.LogWarning($"Warning: Client trying to send a Unreliable packet bigger than the recommended ENet 1200 byte MTU ({byteCount} > 1200). ENet will force Reliable Fragmented delivery.");

// Create the packet.
clientOutgoingPacket.Create(segment.Array, byteOffset, byteCount + byteOffset, desiredFlags);
Expand All @@ -180,7 +187,9 @@ public override void ServerDisconnect(int connectionId)
{
if (Server == null)
{
Debug.LogError("Server object is null, this shouldn't really happen but it did...");
Debug.LogError("Cannot enqueue kick packet; our Server object is null. Something has gone wrong.");
// Return here because otherwise we will get a NRE when trying to enqueue the kick packet.
return;
}

IgnoranceCommandPacket kickPacket = new IgnoranceCommandPacket
Expand All @@ -201,13 +210,20 @@ public override string ServerGetClientAddress(int connectionId)
return "(unavailable)";
}

#if !MIRROR_37_0_OR_NEWER
public override void ServerSend(int connectionId, int channelId, ArraySegment<byte> segment)
#else
// v1.4.0b6: Mirror rearranged the ServerSend params, so we need to apply a fix for that or
// we end up using the obsoleted version. The obsolete version isn't a fatal error, but
// it's best to stick with the new structures.
public override void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId)
#endif
{
// Debug.Log($"ServerSend({connectionId}, {channelId}, <{segment.Count} byte segment>)");

if (Server == null)
{
Debug.LogError("Server object is null, this shouldn't really happen but it did...");
Debug.LogError("Cannot enqueue data packet; our Server object is null. Something has gone wrong.");
return;
}

Expand Down Expand Up @@ -313,7 +329,8 @@ private void OnValidate()
}

// ENet only supports a maximum of 32MB packet size.
if (MaxAllowedPacketSize > 33554432) MaxAllowedPacketSize = 33554432;
if (MaxAllowedPacketSize > 33554432)
MaxAllowedPacketSize = 33554432;
}

private void InitializeServerBackend()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum IgnoranceChannelTypes

public class IgnoranceInternals
{
public const string Version = "1.4.0b5";
public const string Version = "1.4.0b6";
public const string Scheme = "enet";
public const string BindAllIPv4 = "0.0.0.0";
public const string BindAllMacs = "::0";
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Runtime/Transport/Ignorance/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0b5
1.4.0b6

0 comments on commit f1b39e7

Please sign in to comment.