mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Revert "fix: replacing the player does not mean giving up authority (#1254)"
This reverts commit a2c273ecd1
.
This commit is contained in:
parent
fb26d0023f
commit
b8618d356f
@ -718,6 +718,10 @@ static void CheckForLocalPlayer(NetworkIdentity identity)
|
||||
{
|
||||
if (identity.pendingLocalPlayer)
|
||||
{
|
||||
if (readyConnection.identity != null && readyConnection.identity != identity)
|
||||
{
|
||||
readyConnection.identity.SetNotLocalPlayer();
|
||||
}
|
||||
// supposed to be local player, so make it the local player!
|
||||
|
||||
// Set isLocalPlayer to true on this NetworkIdentity and trigger OnStartLocalPlayer in all scripts on the same GO
|
||||
|
@ -204,6 +204,18 @@ internal void SetClientOwner(NetworkConnection conn)
|
||||
/// </summary>
|
||||
public static void ResetNextNetworkId() => nextNetworkId = 1;
|
||||
|
||||
// used when the player object for a connection changes
|
||||
internal void SetNotLocalPlayer()
|
||||
{
|
||||
if (NetworkServer.active && NetworkServer.localClientActive)
|
||||
{
|
||||
// dont change authority for objects on the host
|
||||
return;
|
||||
}
|
||||
hasAuthority = false;
|
||||
NotifyAuthority();
|
||||
}
|
||||
|
||||
// this is used when a connection is destroyed, since the "observers" property is read-only
|
||||
internal void RemoveObserverInternal(NetworkConnection conn)
|
||||
{
|
||||
|
@ -890,6 +890,13 @@ internal static bool InternalReplacePlayerForConnection(NetworkConnection conn,
|
||||
//NOTE: there can be an existing player
|
||||
if (LogFilter.Debug) Debug.Log("NetworkServer ReplacePlayer");
|
||||
|
||||
// is there already an owner that is a different object??
|
||||
if (conn.identity != null)
|
||||
{
|
||||
conn.identity.SetNotLocalPlayer();
|
||||
conn.identity.connectionToClient = null;
|
||||
}
|
||||
|
||||
conn.identity = identity;
|
||||
|
||||
// Set the connection on the NetworkIdentity on the server, NetworkIdentity.SetLocalPlayer is not called on the server (it is on clients)
|
||||
|
Loading…
Reference in New Issue
Block a user