Skip to content

Commit

Permalink
fix(upgrade): Mirror73
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqunaga committed Mar 9, 2023
1 parent 6501e26 commit 54787c9
Show file tree
Hide file tree
Showing 629 changed files with 15,672 additions and 9,033 deletions.
9 changes: 4 additions & 5 deletions Assets/Mirror/Authenticators/BasicAuthenticator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Expand Down Expand Up @@ -51,7 +50,7 @@ public override void OnStartServer()

/// <summary>
/// Called on server from StopServer to reset the Authenticator
/// <para>Server message handlers should be registered in this method.</para>
/// <para>Server message handlers should be unregistered in this method.</para>
/// </summary>
public override void OnStopServer()
{
Expand All @@ -60,7 +59,7 @@ public override void OnStopServer()
}

/// <summary>
/// Called on server from OnServerAuthenticateInternal when a client needs to authenticate
/// Called on server from OnServerConnectInternal when a client needs to authenticate
/// </summary>
/// <param name="conn">Connection to client.</param>
public override void OnServerAuthenticate(NetworkConnectionToClient conn)
Expand Down Expand Up @@ -153,7 +152,7 @@ public override void OnStopClient()
}

/// <summary>
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
/// Called on client from OnClientConnectInternal when a client needs to authenticate
/// </summary>
public override void OnClientAuthenticate()
{
Expand All @@ -163,7 +162,7 @@ public override void OnClientAuthenticate()
authPassword = password
};

NetworkClient.connection.Send(authRequestMessage);
NetworkClient.Send(authRequestMessage);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Assets/Mirror/Authenticators/DeviceAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Mirror.Authenticators
{
/// <summary>
/// An authenicator that identifies the user by their device.
/// An authenticator that identifies the user by their device.
/// <para>A GUID is used as a fallback when the platform doesn't support SystemInfo.deviceUniqueIdentifier.</para>
/// <para>Note: deviceUniqueIdentifier can be spoofed, so security is not guaranteed.</para>
/// <para>See https://docs.unity3d.com/ScriptReference/SystemInfo-deviceUniqueIdentifier.html for details.</para>
Expand Down Expand Up @@ -47,7 +47,7 @@ public override void OnStopServer()
}

/// <summary>
/// Called on server from OnServerAuthenticateInternal when a client needs to authenticate
/// Called on server from OnServerConnectInternal when a client needs to authenticate
/// </summary>
/// <param name="conn">Connection to client.</param>
public override void OnServerAuthenticate(NetworkConnectionToClient conn)
Expand Down Expand Up @@ -94,7 +94,7 @@ public override void OnStopClient()
}

/// <summary>
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
/// Called on client from OnClientConnectInternal when a client needs to authenticate
/// </summary>
public override void OnClientAuthenticate()
{
Expand All @@ -111,7 +111,7 @@ public override void OnClientAuthenticate()
}

// send the deviceUniqueIdentifier to the server
NetworkClient.connection.Send(new AuthRequestMessage { clientDeviceID = deviceUniqueIdentifier } );
NetworkClient.Send(new AuthRequestMessage { clientDeviceID = deviceUniqueIdentifier } );
}

/// <summary>
Expand Down
8 changes: 5 additions & 3 deletions Assets/Mirror/Authenticators/Mirror.Authenticators.asmdef
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "Mirror.Authenticators",
"rootNamespace": "",
"references": [
"Mirror"
"GUID:30817c1a0e6d646d99c048fc403f5979"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
36 changes: 9 additions & 27 deletions Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,20 @@ public static void AddDefineSymbols()
HashSet<string> defines = new HashSet<string>(currentDefines.Split(';'))
{
"MIRROR",
"MIRROR_17_0_OR_NEWER",
"MIRROR_18_0_OR_NEWER",
"MIRROR_24_0_OR_NEWER",
"MIRROR_26_0_OR_NEWER",
"MIRROR_27_0_OR_NEWER",
"MIRROR_28_0_OR_NEWER",
"MIRROR_29_0_OR_NEWER",
"MIRROR_30_0_OR_NEWER",
"MIRROR_30_5_2_OR_NEWER",
"MIRROR_32_1_2_OR_NEWER",
"MIRROR_32_1_4_OR_NEWER",
"MIRROR_35_0_OR_NEWER",
"MIRROR_35_1_OR_NEWER",
"MIRROR_37_0_OR_NEWER",
"MIRROR_38_0_OR_NEWER",
"MIRROR_39_0_OR_NEWER",
"MIRROR_40_0_OR_NEWER",
"MIRROR_41_0_OR_NEWER",
"MIRROR_42_0_OR_NEWER",
"MIRROR_43_0_OR_NEWER",
"MIRROR_44_0_OR_NEWER",
"MIRROR_46_0_OR_NEWER",
"MIRROR_47_0_OR_NEWER",
"MIRROR_53_0_OR_NEWER",
"MIRROR_55_0_OR_NEWER",
"MIRROR_57_0_OR_NEWER",
"MIRROR_58_0_OR_NEWER",
"MIRROR_65_0_OR_NEWER",
"MIRROR_66_0_OR_NEWER"
"MIRROR_66_0_OR_NEWER",
"MIRROR_2022_9_OR_NEWER",
"MIRROR_2022_10_OR_NEWER",
"MIRROR_70_0_OR_NEWER",
"MIRROR_71_0_OR_NEWER",
"MIRROR_73_OR_NEWER"
// Remove oldest when adding next month's symbol.
// Keep a rolling 12 months of symbols.
};

// only touch PlayerSettings if we actually modified it.
// only touch PlayerSettings if we actually modified it,
// otherwise it shows up as changed in git each time.
string newDefines = string.Join(";", defines);
if (newDefines != currentDefines)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Assets/Mirror/Components/Discovery/NetworkDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Start()
// so make sure we set it here in Start() (after awakes)
// Or just let the user assign it in the inspector
if (transport == null)
transport = Transport.activeTransport;
transport = Transport.active;

base.Start();
}
Expand Down Expand Up @@ -68,11 +68,9 @@ protected override ServerResponse ProcessRequest(ServerRequest request, IPEndPoi
throw;
}
}

#endregion

#region Client

/// <summary>
/// Create a message that will be broadcasted on the network to discover servers
/// </summary>
Expand Down Expand Up @@ -108,7 +106,6 @@ protected override void ProcessResponse(ServerResponse response, IPEndPoint endp

OnServerFound.Invoke(response);
}

#endregion
}
}
16 changes: 16 additions & 0 deletions Assets/Mirror/Components/Discovery/NetworkDiscoveryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public abstract class NetworkDiscoveryBase<Request, Response> : MonoBehaviour
[Tooltip("Time in seconds between multi-cast messages")]
[Range(1, 60)]
float ActiveDiscoveryInterval = 3;

// broadcast address needs to be configurable on iOS:
// https://github.com/vis2k/Mirror/pull/3255
public string BroadcastAddress = "";

protected UdpClient serverUdpClient;
protected UdpClient clientUdpClient;
Expand Down Expand Up @@ -368,6 +372,18 @@ public void BroadcastDiscoveryRequest()
}

IPEndPoint endPoint = new IPEndPoint(IPAddress.Broadcast, serverBroadcastListenPort);

if (!string.IsNullOrWhiteSpace(BroadcastAddress))
{
try
{
endPoint = new IPEndPoint(IPAddress.Parse(BroadcastAddress), serverBroadcastListenPort);
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}

using (NetworkWriterPooled writer = NetworkWriterPool.Get())
{
Expand Down
16 changes: 5 additions & 11 deletions Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ public class NetworkLerpRigidbody : NetworkBehaviour
{
[Header("Settings")]
[SerializeField] internal Rigidbody target = null;

[Tooltip("How quickly current velocity approaches target velocity")]
[SerializeField] float lerpVelocityAmount = 0.5f;

[Tooltip("How quickly current position approaches target position")]
[SerializeField] float lerpPositionAmount = 0.5f;

[Tooltip("Set to true if moves come from owner client, set to false if moves always come from server")]
[SerializeField] bool clientAuthority = false;

float nextSyncTime;

double nextSyncTime;

[SyncVar()]
Vector3 targetVelocity;
Expand All @@ -28,29 +29,22 @@ public class NetworkLerpRigidbody : NetworkBehaviour
/// <summary>
/// Ignore value if is host or client with Authority
/// </summary>
/// <returns></returns>
bool IgnoreSync => isServer || ClientWithAuthority;

bool ClientWithAuthority => clientAuthority && hasAuthority;
bool ClientWithAuthority => clientAuthority && isOwned;

void OnValidate()
{
if (target == null)
{
target = GetComponent<Rigidbody>();
}
}

void Update()
{
if (isServer)
{
SyncToClients();
}
else if (ClientWithAuthority)
{
SendToServer();
}
}

void SyncToClients()
Expand All @@ -61,7 +55,7 @@ void SyncToClients()

void SendToServer()
{
float now = Time.time;
double now = NetworkTime.localTime; // Unity 2019 doesn't have Time.timeAsDouble yet
if (now > nextSyncTime)
{
nextSyncTime = now + syncInterval;
Expand Down
Loading

0 comments on commit 54787c9

Please sign in to comment.