Fixed
This commit is contained in:
@@ -157,7 +157,6 @@ namespace MegaKoop.Game.Networking
|
||||
networkManager = SteamCoopNetworkManager.Instance;
|
||||
}
|
||||
|
||||
bool isHost = networkManager != null && networkManager.IsHost;
|
||||
ulong localSteamId = SteamBootstrap.IsInitialized ? SteamUser.GetSteamID().m_SteamID : 0UL;
|
||||
|
||||
if (!localOverrideSet && autoAssignOwnerToLocalPlayer && ownerSteamId == 0 && localSteamId != 0)
|
||||
@@ -170,7 +169,7 @@ namespace MegaKoop.Game.Networking
|
||||
isLocalPlayer = ownerSteamId != 0 && ownerSteamId == localSteamId;
|
||||
}
|
||||
|
||||
isAuthority = isHost; // Host drives authoritative simulation.
|
||||
isAuthority = isLocalPlayer; // Each player has authority over their own character.
|
||||
}
|
||||
|
||||
private void ConfigureController()
|
||||
@@ -218,7 +217,7 @@ namespace MegaKoop.Game.Networking
|
||||
|
||||
private void HandlePlayerInputMessage(NetworkMessage message)
|
||||
{
|
||||
if (!isAuthority)
|
||||
if (isAuthority)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -253,29 +252,17 @@ namespace MegaKoop.Game.Networking
|
||||
|
||||
public void SendLocalInput(Vector2 moveInput, bool jump)
|
||||
{
|
||||
if (networkManager == null || identity == null)
|
||||
if (networkManager == null || identity == null || !isAuthority)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = new PlayerInputMessage(identity.NetworkId, moveInput, jump);
|
||||
byte[] payload = PlayerInputMessage.Serialize(message);
|
||||
if (!networkManager.IsConnected || networkManager.IsHost)
|
||||
if (!networkManager.IsConnected)
|
||||
{
|
||||
// If we are host, feed directly.
|
||||
HandlePlayerInputMessage(new NetworkMessage(NetworkMessageType.PlayerInput, payload, SteamUser.GetSteamID().m_SteamID));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSteamID lobby = networkManager.ActiveLobby;
|
||||
CSteamID lobbyOwner = lobby != CSteamID.Nil ? SteamMatchmaking.GetLobbyOwner(lobby) : CSteamID.Nil;
|
||||
if (lobbyOwner == CSteamID.Nil)
|
||||
{
|
||||
lobbyOwner = SteamUser.GetSteamID();
|
||||
}
|
||||
|
||||
networkManager.SendToPlayer(lobbyOwner, NetworkMessageType.PlayerInput, payload, EP2PSend.k_EP2PSendUnreliableNoDelay);
|
||||
}
|
||||
networkManager.SendToAll(NetworkMessageType.PlayerInput, PlayerInputMessage.Serialize(new PlayerInputMessage(identity.NetworkId, moveInput, jump)), EP2PSend.k_EP2PSendUnreliableNoDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user