Merged master

This commit is contained in:
MrGadget1024 2023-03-20 03:07:07 -04:00
commit 32015cd9c5
4 changed files with 26 additions and 14 deletions

View File

@ -35,7 +35,7 @@ public class NetworkTransformReliable : NetworkTransformBase
[Header("Snapshot Interpolation")]
[Tooltip("Add a small timeline offset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots.\nfixes: https://github.com/MirrorNetworking/Mirror/issues/3427")]
public float timelineOffset = 0.015f;
public bool timelineOffset = false;
// delta compression needs to remember 'last' to compress against
protected Vector3Long lastSerializedPosition = Vector3Long.zero;
@ -302,7 +302,13 @@ protected virtual void OnClientToServerSync(Vector3? position, Quaternion? rotat
// Debug.Log($"{name}: corrected history on server to fix initial stutter after not sending for a while.");
}
AddSnapshot(serverSnapshots, connectionToClient.remoteTimeStamp + timelineOffset, position, rotation, scale);
// add a small timeline offset to account for decoupled arrival of
// NetworkTime and NetworkTransform snapshots.
// needs to be sendInterval. half sendInterval doesn't solve it.
// https://github.com/MirrorNetworking/Mirror/issues/3427
// remove this after LocalWorldState.
double offset = timelineOffset ? NetworkServer.sendInterval : 0;
AddSnapshot(serverSnapshots, connectionToClient.remoteTimeStamp + offset, position, rotation, scale);
}
// server broadcasts sync message to all clients
@ -326,7 +332,13 @@ protected virtual void OnServerToClientSync(Vector3? position, Quaternion? rotat
// Debug.Log($"{name}: corrected history on client to fix initial stutter after not sending for a while.");
}
AddSnapshot(clientSnapshots, NetworkClient.connection.remoteTimeStamp + timelineOffset, position, rotation, scale);
// add a small timeline offset to account for decoupled arrival of
// NetworkTime and NetworkTransform snapshots.
// needs to be sendInterval. half sendInterval doesn't solve it.
// https://github.com/MirrorNetworking/Mirror/issues/3427
// remove this after LocalWorldState.
double offset = timelineOffset ? NetworkServer.sendInterval : 0;
AddSnapshot(clientSnapshots, NetworkClient.connection.remoteTimeStamp + offset, position, rotation, scale);
}
// only sync on change /////////////////////////////////////////////////

View File

@ -17,7 +17,7 @@ public class KcpClient
public EndPoint remoteEndPoint;
// config
readonly KcpConfig config;
protected readonly KcpConfig config;
// raw receive buffer always needs to be of 'MTU' size, even if
// MaxMessageSize is larger. kcp always sends in MTU segments and having
@ -35,10 +35,10 @@ public class KcpClient
// events are readonly, set in constructor.
// this ensures they are always initialized when used.
// fixes https://github.com/MirrorNetworking/Mirror/issues/3337 and more
readonly Action OnConnected;
readonly Action<ArraySegment<byte>, KcpChannel> OnData;
readonly Action OnDisconnected;
readonly Action<ErrorCode, string> OnError;
protected readonly Action OnConnected;
protected readonly Action<ArraySegment<byte>, KcpChannel> OnData;
protected readonly Action OnDisconnected;
protected readonly Action<ErrorCode, string> OnError;
// state
public bool connected;

View File

@ -554,7 +554,7 @@ void OnRawInputUnreliable(ArraySegment<byte> message)
// invalid unreliable messages may be random internet noise.
// show a warning, but don't disconnect.
// otherwise attackers could disconnect someone with random noise.
Log.Warning($"KcpPeer: received unreliable message while not authenticated. Disconnecting the connection.");
Log.Warning($"KcpPeer: received unreliable message while not authenticated.");
}
}

View File

@ -18,13 +18,13 @@ public class KcpServer
// events are readonly, set in constructor.
// this ensures they are always initialized when used.
// fixes https://github.com/MirrorNetworking/Mirror/issues/3337 and more
readonly Action<int> OnConnected;
readonly Action<int, ArraySegment<byte>, KcpChannel> OnData;
readonly Action<int> OnDisconnected;
readonly Action<int, ErrorCode, string> OnError;
protected readonly Action<int> OnConnected;
protected readonly Action<int, ArraySegment<byte>, KcpChannel> OnData;
protected readonly Action<int> OnDisconnected;
protected readonly Action<int, ErrorCode, string> OnError;
// configuration
readonly KcpConfig config;
protected readonly KcpConfig config;
// state
protected Socket socket;