fix: #3362 BootstrapIdentity now initializes isClient/isLocalPlayer flags before calling OnStartAuthority

This commit is contained in:
vis2k 2023-01-28 13:20:21 +09:00
parent 25ef55413c
commit 0312bf7103

View File

@ -1351,13 +1351,15 @@ internal static void ChangeOwner(NetworkIdentity identity, ChangeOwnerMessage me
// used to happen in multiple places, so let's have this in one function.
static void BootstrapIdentity(NetworkIdentity identity)
{
identity.NotifyAuthority(); // calls OnStart/StopAuthority
// initialize flags.
// after NotifyAuthority for compatibility with old behaviour.
// initialize flags before invoking callbacks.
// this way isClient/isLocalPlayer is correct during callbacks.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3362
identity.isClient = true;
identity.isLocalPlayer = localPlayer == identity;
// invoke OnStartAuthority
identity.NotifyAuthority();
// invoke OnStartClient
identity.OnStartClient();