change fromPlayer to newAuthority and networkIdentity to shipNetId

This commit is contained in:
Mister_Nebula 2021-06-13 20:50:06 +01:00
parent 8ddc9dd7f2
commit f9a00ef513

View File

@ -77,23 +77,23 @@ namespace QSB.ShipSync.Events
if (QSBCore.IsServer) if (QSBCore.IsServer)
{ {
DebugLog.DebugWrite($"Change ship auth to {id}"); var newAuthority = ShipManager.Instance.CurrentFlyer == uint.MaxValue
var fromPlayer = ShipManager.Instance.CurrentFlyer == uint.MaxValue
? QNetworkServer.connections.First(x => x.GetPlayerId() == QSBPlayerManager.LocalPlayerId) ? QNetworkServer.connections.First(x => x.GetPlayerId() == QSBPlayerManager.LocalPlayerId)
: QNetworkServer.connections.First(x => x.GetPlayerId() == id); : QNetworkServer.connections.First(x => x.GetPlayerId() == id);
var ship = ShipTransformSync.LocalInstance;
var networkIdentity = ship.NetIdentity;
if (networkIdentity.ClientAuthorityOwner == fromPlayer) var ship = ShipTransformSync.LocalInstance;
var shipNetId = ship.NetIdentity;
if (shipNetId.ClientAuthorityOwner == newAuthority)
{ {
return; return;
} }
if (networkIdentity.ClientAuthorityOwner != null && networkIdentity.ClientAuthorityOwner != fromPlayer) if (shipNetId.ClientAuthorityOwner != null && shipNetId.ClientAuthorityOwner != newAuthority)
{ {
networkIdentity.RemoveClientAuthority(networkIdentity.ClientAuthorityOwner); shipNetId.RemoveClientAuthority(shipNetId.ClientAuthorityOwner);
} }
networkIdentity.AssignClientAuthority(fromPlayer); shipNetId.AssignClientAuthority(newAuthority);
} }
} }
} }