mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-03 17:53:57 +00:00
remove logfilter
This commit is contained in:
parent
89625a5610
commit
c2d7cb10a9
@ -12,7 +12,6 @@ using QSB.Utility;
|
||||
using QuantumUNET;
|
||||
using QuantumUNET.Components;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
/*
|
||||
Copyright (C) 2020 Henry Pointer (_nebula / misternebula), Aleksander Waage (AmazingAlek), Ricardo Lopes (Raicuparta)
|
||||
@ -54,8 +53,6 @@ namespace QSB
|
||||
"<color=orange>Quantum Space Buddies</color> is best experienced with friends...";
|
||||
|
||||
ModBehaviour = this;
|
||||
|
||||
LogFilter.currentLogLevel = LogFilter.Debug;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
|
@ -45,18 +45,12 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.Log("ClientScene::GetPlayer: no local player found for: " + playerControllerId);
|
||||
}
|
||||
Debug.Log("ClientScene::GetPlayer: no local player found for: " + playerControllerId);
|
||||
result = false;
|
||||
}
|
||||
else if (localPlayers[playerControllerId] == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::GetPlayer: local player is null for: " + playerControllerId);
|
||||
}
|
||||
Debug.LogWarning("ClientScene::GetPlayer: local player is null for: " + playerControllerId);
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -69,16 +63,10 @@ namespace QuantumUNET
|
||||
|
||||
internal static void InternalAddPlayer(QSBNetworkIdentity view, short playerControllerId)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::InternalAddPlayer: playerControllerId : " + playerControllerId);
|
||||
}
|
||||
Debug.LogWarning("ClientScene::InternalAddPlayer: playerControllerId : " + playerControllerId);
|
||||
if (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::InternalAddPlayer: playerControllerId higher than expected: " + playerControllerId);
|
||||
}
|
||||
Debug.LogWarning("ClientScene::InternalAddPlayer: playerControllerId higher than expected: " + playerControllerId);
|
||||
while (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
localPlayers.Add(new QSBPlayerController());
|
||||
@ -121,10 +109,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (playerControllerId > 16)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::AddPlayer: playerControllerId of " + playerControllerId + " is unusually high");
|
||||
}
|
||||
Debug.LogWarning("ClientScene::AddPlayer: playerControllerId of " + playerControllerId + " is unusually high");
|
||||
}
|
||||
while (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
@ -134,10 +119,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (!ready)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Must call AddPlayer() with a connection the first time to become ready.");
|
||||
}
|
||||
Debug.LogError("Must call AddPlayer() with a connection the first time to become ready.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -150,24 +132,18 @@ namespace QuantumUNET
|
||||
{
|
||||
if (playerController.IsValid && playerController.Gameobject != null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("ClientScene::AddPlayer: playerControllerId of " + playerControllerId + " already in use.");
|
||||
}
|
||||
Debug.LogError("ClientScene::AddPlayer: playerControllerId of " + playerControllerId + " already in use.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::AddPlayer() for ID ",
|
||||
playerControllerId,
|
||||
" called with connection [",
|
||||
readyConnection,
|
||||
"]"
|
||||
}));
|
||||
}
|
||||
}));
|
||||
var addPlayerMessage = new QSBAddPlayerMessage
|
||||
{
|
||||
playerControllerId = playerControllerId
|
||||
@ -187,17 +163,14 @@ namespace QuantumUNET
|
||||
|
||||
public static bool RemovePlayer(short playerControllerId)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::RemovePlayer() for ID ",
|
||||
playerControllerId,
|
||||
" called with connection [",
|
||||
readyConnection,
|
||||
"]"
|
||||
}));
|
||||
}
|
||||
}));
|
||||
bool result;
|
||||
if (readyConnection.GetPlayerController(playerControllerId, out var playerController))
|
||||
{
|
||||
@ -213,10 +186,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Failed to find player ID " + playerControllerId);
|
||||
}
|
||||
Debug.LogError("Failed to find player ID " + playerControllerId);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -227,18 +197,12 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (ready)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("A connection has already been set as ready. There can only be one.");
|
||||
}
|
||||
Debug.LogError("A connection has already been set as ready. There can only be one.");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
|
||||
}
|
||||
Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
|
||||
if (conn != null)
|
||||
{
|
||||
var msg = new QSBReadyMessage();
|
||||
@ -250,10 +214,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Ready() called with invalid connection object: conn=null");
|
||||
}
|
||||
Debug.LogError("Ready() called with invalid connection object: conn=null");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
@ -299,10 +260,7 @@ namespace QuantumUNET
|
||||
if (!networkIdentity.SceneId.IsEmpty())
|
||||
{
|
||||
SpawnableObjects[networkIdentity.SceneId] = networkIdentity;
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::PrepareSpawnObjects sceneId:" + networkIdentity.SceneId);
|
||||
}
|
||||
Debug.Log("ClientScene::PrepareSpawnObjects sceneId:" + networkIdentity.SceneId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -491,25 +449,19 @@ namespace QuantumUNET
|
||||
var networkIdentity2 = SpawnSceneObject(s_ObjectSpawnSceneMessage.SceneId);
|
||||
if (networkIdentity2 == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Spawn scene object not found for " + s_ObjectSpawnSceneMessage.SceneId);
|
||||
}
|
||||
Debug.LogError("Spawn scene object not found for " + s_ObjectSpawnSceneMessage.SceneId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"Client spawn for [netId:",
|
||||
s_ObjectSpawnSceneMessage.NetId,
|
||||
"] [sceneId:",
|
||||
s_ObjectSpawnSceneMessage.SceneId,
|
||||
"] obj:",
|
||||
networkIdentity2.gameObject.name
|
||||
}));
|
||||
}
|
||||
}));
|
||||
ApplySpawnPayload(networkIdentity2, s_ObjectSpawnSceneMessage.Position, s_ObjectSpawnSceneMessage.Payload, s_ObjectSpawnSceneMessage.NetId, networkIdentity2.gameObject);
|
||||
}
|
||||
}
|
||||
@ -518,10 +470,7 @@ namespace QuantumUNET
|
||||
private static void OnObjectSpawnFinished(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBObjectSpawnFinishedMessage>(s_ObjectSpawnFinishedMessage);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("SpawnFinished:" + s_ObjectSpawnFinishedMessage.State);
|
||||
}
|
||||
Debug.Log("SpawnFinished:" + s_ObjectSpawnFinishedMessage.State);
|
||||
if (s_ObjectSpawnFinishedMessage.State == 0U)
|
||||
{
|
||||
PrepareToSpawnSceneObjects();
|
||||
@ -544,10 +493,7 @@ namespace QuantumUNET
|
||||
private static void OnObjectDestroy(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBObjectDestroyMessage>(s_ObjectDestroyMessage);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::OnObjDestroy netId:" + s_ObjectDestroyMessage.NetId);
|
||||
}
|
||||
Debug.Log("ClientScene::OnObjDestroy netId:" + s_ObjectDestroyMessage.NetId);
|
||||
if (s_NetworkScene.GetNetworkIdentity(s_ObjectDestroyMessage.NetId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.OnNetworkDestroy();
|
||||
@ -566,7 +512,7 @@ namespace QuantumUNET
|
||||
s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.NetId);
|
||||
networkIdentity.MarkForReset();
|
||||
}
|
||||
else if (LogFilter.logDebug)
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Did not find target for destroy message for " + s_ObjectDestroyMessage.NetId);
|
||||
}
|
||||
@ -575,20 +521,14 @@ namespace QuantumUNET
|
||||
private static void OnLocalClientObjectDestroy(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBObjectDestroyMessage>(s_ObjectDestroyMessage);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::OnLocalObjectObjDestroy netId:" + s_ObjectDestroyMessage.NetId);
|
||||
}
|
||||
Debug.Log("ClientScene::OnLocalObjectObjDestroy netId:" + s_ObjectDestroyMessage.NetId);
|
||||
s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.NetId);
|
||||
}
|
||||
|
||||
private static void OnLocalClientObjectHide(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBObjectDestroyMessage>(s_ObjectDestroyMessage);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::OnLocalObjectObjHide netId:" + s_ObjectDestroyMessage.NetId);
|
||||
}
|
||||
Debug.Log("ClientScene::OnLocalObjectObjHide netId:" + s_ObjectDestroyMessage.NetId);
|
||||
if (s_NetworkScene.GetNetworkIdentity(s_ObjectDestroyMessage.NetId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.OnSetLocalVisibility(false);
|
||||
@ -620,7 +560,7 @@ namespace QuantumUNET
|
||||
{
|
||||
networkIdentity.OnUpdateVars(netMsg.Reader, false);
|
||||
}
|
||||
else if (LogFilter.logWarn)
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Did not find target for sync message for " + networkInstanceId);
|
||||
}
|
||||
@ -630,21 +570,18 @@ namespace QuantumUNET
|
||||
{
|
||||
var num = (int)netMsg.Reader.ReadPackedUInt32();
|
||||
var networkInstanceId = netMsg.Reader.ReadNetworkId();
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::OnRPCMessage hash:",
|
||||
num,
|
||||
" netId:",
|
||||
networkInstanceId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.HandleRPC(num, netMsg.Reader);
|
||||
}
|
||||
else if (LogFilter.logWarn)
|
||||
else
|
||||
{
|
||||
var cmdHashHandlerName = QSBNetworkBehaviour.GetCmdHashHandlerName(num);
|
||||
Debug.LogWarningFormat("Could not find target object with netId:{0} for RPC call {1}", new object[]
|
||||
@ -659,15 +596,12 @@ namespace QuantumUNET
|
||||
{
|
||||
var cmdHash = (int)netMsg.Reader.ReadPackedUInt32();
|
||||
var networkInstanceId = netMsg.Reader.ReadNetworkId();
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::OnSyncEventMessage " + networkInstanceId);
|
||||
}
|
||||
Debug.Log("ClientScene::OnSyncEventMessage " + networkInstanceId);
|
||||
if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.HandleSyncEvent(cmdHash, netMsg.Reader);
|
||||
}
|
||||
else if (LogFilter.logWarn)
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Did not find target for SyncEvent message for " + networkInstanceId);
|
||||
}
|
||||
@ -677,15 +611,12 @@ namespace QuantumUNET
|
||||
{
|
||||
var networkInstanceId = netMsg.Reader.ReadNetworkId();
|
||||
var cmdHash = (int)netMsg.Reader.ReadPackedUInt32();
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::OnSyncListMessage " + networkInstanceId);
|
||||
}
|
||||
Debug.Log("ClientScene::OnSyncListMessage " + networkInstanceId);
|
||||
if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.HandleSyncList(cmdHash, netMsg.Reader);
|
||||
}
|
||||
else if (LogFilter.logWarn)
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Did not find target for SyncList message for " + networkInstanceId);
|
||||
}
|
||||
@ -694,16 +625,13 @@ namespace QuantumUNET
|
||||
private static void OnClientAuthority(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBClientAuthorityMessage>(s_ClientAuthorityMessage);
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::OnClientAuthority for connectionId=",
|
||||
netMsg.Connection.connectionId,
|
||||
" netId: ",
|
||||
s_ClientAuthorityMessage.netId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
if (s_NetworkScene.GetNetworkIdentity(s_ClientAuthorityMessage.netId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.HandleClientAuthority(s_ClientAuthorityMessage.authority);
|
||||
@ -713,16 +641,13 @@ namespace QuantumUNET
|
||||
private static void OnOwnerMessage(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBOwnerMessage>(s_OwnerMessage);
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::OnOwnerMessage - connectionId=",
|
||||
netMsg.Connection.connectionId,
|
||||
" netId: ",
|
||||
s_OwnerMessage.NetId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
if (netMsg.Connection.GetPlayerController(s_OwnerMessage.PlayerControllerId, out var playerController))
|
||||
{
|
||||
playerController.UnetView.SetNotLocalPlayer();
|
||||
@ -757,10 +682,7 @@ namespace QuantumUNET
|
||||
Debug.Log("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name);
|
||||
if (readyConnection.connectionId < 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Owner message received on a local client.");
|
||||
}
|
||||
Debug.LogError("Owner message received on a local client.");
|
||||
break;
|
||||
}
|
||||
InternalAddPlayer(uv, pendingOwner.playerControllerId);
|
||||
|
@ -71,11 +71,8 @@ namespace QuantumUNET
|
||||
{
|
||||
if (!IsServer)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientRpc call on un-spawned object");
|
||||
return;
|
||||
}
|
||||
Debug.LogWarning("ClientRpc call on un-spawned object");
|
||||
return;
|
||||
}
|
||||
writer.FinishMessage();
|
||||
QSBNetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
@ -418,10 +415,7 @@ namespace QuantumUNET
|
||||
networkInstanceId = component.NetId;
|
||||
if (networkInstanceId.IsEmpty())
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("SetSyncVarGameObject GameObject " + newGameObject + " has a zero netId. Maybe it is not spawned yet?");
|
||||
}
|
||||
Debug.LogWarning("SetSyncVarGameObject GameObject " + newGameObject + " has a zero netId. Maybe it is not spawned yet?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,32 +94,23 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (!active)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - NetworkClient must be active");
|
||||
}
|
||||
Debug.LogError("Reconnect - NetworkClient must be active");
|
||||
result = false;
|
||||
}
|
||||
else if (m_Connection == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - no old connection exists");
|
||||
}
|
||||
Debug.LogError("Reconnect - no old connection exists");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logInfo)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"NetworkClient Reconnect ",
|
||||
serverIp,
|
||||
":",
|
||||
serverPort
|
||||
}));
|
||||
}
|
||||
}));
|
||||
QSBClientScene.HandleClientDisconnect(m_Connection);
|
||||
QSBClientScene.ClearLocalPlayers();
|
||||
m_Connection.Disconnect();
|
||||
@ -138,10 +129,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Async DNS START:" + serverIp);
|
||||
}
|
||||
Debug.Log("Async DNS START:" + serverIp);
|
||||
m_AsyncConnect = ConnectState.Resolving;
|
||||
Dns.BeginGetHostAddresses(serverIp, new AsyncCallback(GetHostAddressesCallback), this);
|
||||
}
|
||||
@ -155,26 +143,17 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (!active)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - NetworkClient must be active");
|
||||
}
|
||||
Debug.LogError("Reconnect - NetworkClient must be active");
|
||||
result = false;
|
||||
}
|
||||
else if (m_Connection == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - no old connection exists");
|
||||
}
|
||||
Debug.LogError("Reconnect - no old connection exists");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logInfo)
|
||||
{
|
||||
Debug.Log("NetworkClient Reconnect to remoteSockAddr");
|
||||
}
|
||||
Debug.Log("NetworkClient Reconnect to remoteSockAddr");
|
||||
QSBClientScene.HandleClientDisconnect(m_Connection);
|
||||
QSBClientScene.ClearLocalPlayers();
|
||||
m_Connection.Disconnect();
|
||||
@ -182,19 +161,13 @@ namespace QuantumUNET
|
||||
hostId = NetworkTransport.AddHost(hostTopology, m_HostPort);
|
||||
if (secureTunnelEndPoint == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect failed: null endpoint passed in");
|
||||
}
|
||||
Debug.LogError("Reconnect failed: null endpoint passed in");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
result = false;
|
||||
}
|
||||
else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
|
||||
}
|
||||
Debug.LogError("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
result = false;
|
||||
}
|
||||
@ -209,10 +182,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint")
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
|
||||
}
|
||||
Debug.LogError("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
result = false;
|
||||
}
|
||||
@ -227,19 +197,13 @@ namespace QuantumUNET
|
||||
}
|
||||
catch (Exception arg)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect failed: Exception when trying to connect to EndPoint: " + arg);
|
||||
}
|
||||
Debug.LogError("Reconnect failed: Exception when trying to connect to EndPoint: " + arg);
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
return false;
|
||||
}
|
||||
if (m_ClientConnectionId == 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect failed: Unable to connect to EndPoint (" + b + ")");
|
||||
}
|
||||
Debug.LogError("Reconnect failed: Unable to connect to EndPoint (" + b + ")");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
result = false;
|
||||
}
|
||||
@ -316,24 +280,15 @@ namespace QuantumUNET
|
||||
//bool usePlatformSpecificProtocols = NetworkTransport.DoesEndPointUsePlatformProtocols(secureTunnelEndPoint);
|
||||
var usePlatformSpecificProtocols = false;
|
||||
PrepareForConnect(usePlatformSpecificProtocols);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Client Connect to remoteSockAddr");
|
||||
}
|
||||
Debug.Log("Client Connect to remoteSockAddr");
|
||||
if (secureTunnelEndPoint == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Connect failed: null endpoint passed in");
|
||||
}
|
||||
Debug.LogError("Connect failed: null endpoint passed in");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
|
||||
}
|
||||
Debug.LogError("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else
|
||||
@ -346,10 +301,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint" && fullName != "UnityEngine.PSVita.SceEndPoint")
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
|
||||
}
|
||||
Debug.LogError("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else
|
||||
@ -363,19 +315,13 @@ namespace QuantumUNET
|
||||
}
|
||||
catch (Exception arg)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Connect failed: Exception when trying to connect to EndPoint: " + arg);
|
||||
}
|
||||
Debug.LogError("Connect failed: Exception when trying to connect to EndPoint: " + arg);
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
return;
|
||||
}
|
||||
if (m_ClientConnectionId == 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Connect failed: Unable to connect to EndPoint (" + b + ")");
|
||||
}
|
||||
Debug.LogError("Connect failed: Unable to connect to EndPoint (" + b + ")");
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else
|
||||
@ -512,10 +458,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient Send when not connected to a server");
|
||||
}
|
||||
Debug.LogError("NetworkClient Send when not connected to a server");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -525,10 +468,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient Send with no connection");
|
||||
}
|
||||
Debug.LogError("NetworkClient Send with no connection");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -541,10 +481,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendWriter when not connected to a server");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendWriter when not connected to a server");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -554,10 +491,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendWriter with no connection");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendWriter with no connection");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -570,10 +504,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendBytes when not connected to a server");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendBytes when not connected to a server");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -583,10 +514,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendBytes with no connection");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendBytes with no connection");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -599,10 +527,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendUnreliable when not connected to a server");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendUnreliable when not connected to a server");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -612,10 +537,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendUnreliable with no connection");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendUnreliable with no connection");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -628,10 +550,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendByChannel when not connected to a server");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendByChannel when not connected to a server");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -641,10 +560,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendByChannel with no connection");
|
||||
}
|
||||
Debug.LogError("NetworkClient SendByChannel with no connection");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -654,10 +570,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (m_Connection == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("SetMaxDelay failed, not connected.");
|
||||
}
|
||||
Debug.LogWarning("SetMaxDelay failed, not connected.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -667,10 +580,7 @@ namespace QuantumUNET
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Shutting down client " + hostId);
|
||||
}
|
||||
Debug.Log("Shutting down client " + hostId);
|
||||
if (hostId != -1)
|
||||
{
|
||||
NetworkTransport.RemoveHost(hostId);
|
||||
@ -693,12 +603,10 @@ namespace QuantumUNET
|
||||
case ConnectState.Resolving:
|
||||
case ConnectState.Disconnected:
|
||||
return;
|
||||
|
||||
case ConnectState.Resolved:
|
||||
m_AsyncConnect = ConnectState.Connecting;
|
||||
ContinueConnect();
|
||||
return;
|
||||
|
||||
case ConnectState.Failed:
|
||||
GenerateConnectError(11);
|
||||
m_AsyncConnect = ConnectState.Disconnected;
|
||||
@ -733,10 +641,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
|
||||
case NetworkEventType.ConnectEvent:
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Client connected");
|
||||
}
|
||||
Debug.Log("Client connected");
|
||||
if (b != 0)
|
||||
{
|
||||
goto Block_10;
|
||||
@ -746,10 +651,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
|
||||
case NetworkEventType.DisconnectEvent:
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Client disconnected");
|
||||
}
|
||||
Debug.Log("Client disconnected");
|
||||
m_AsyncConnect = ConnectState.Disconnected;
|
||||
if (b != 0)
|
||||
{
|
||||
@ -769,10 +671,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
|
||||
default:
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Unknown network message type received: " + networkEventType);
|
||||
}
|
||||
Debug.LogError("Unknown network message type received: " + networkEventType);
|
||||
break;
|
||||
}
|
||||
if (++num >= 500)
|
||||
@ -795,10 +694,7 @@ namespace QuantumUNET
|
||||
GenerateDataError(b);
|
||||
return;
|
||||
Block_17:
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("MaxEventsPerFrame hit (" + 500 + ")");
|
||||
}
|
||||
Debug.Log("MaxEventsPerFrame hit (" + 500 + ")");
|
||||
Block_19:
|
||||
IL_2C6:
|
||||
if (m_Connection != null && m_AsyncConnect == ConnectState.Connected)
|
||||
@ -810,28 +706,19 @@ namespace QuantumUNET
|
||||
|
||||
private void GenerateConnectError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("UNet Client Error Connect Error: " + error);
|
||||
}
|
||||
Debug.LogError("UNet Client Error Connect Error: " + error);
|
||||
GenerateError(error);
|
||||
}
|
||||
|
||||
private void GenerateDataError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("UNet Client Data Error: " + (NetworkError)error);
|
||||
}
|
||||
Debug.LogError("UNet Client Data Error: " + (NetworkError)error);
|
||||
GenerateError(error);
|
||||
}
|
||||
|
||||
private void GenerateDisconnectError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("UNet Client Disconnect Error: " + (NetworkError)error);
|
||||
}
|
||||
Debug.LogError("UNet Client Disconnect Error: " + (NetworkError)error);
|
||||
GenerateError(error);
|
||||
}
|
||||
|
||||
|
@ -199,11 +199,8 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("RemovePlayer player at playerControllerId " + playerControllerId + " not found");
|
||||
return;
|
||||
}
|
||||
Debug.LogError("RemovePlayer player at playerControllerId " + playerControllerId + " not found");
|
||||
return;
|
||||
}
|
||||
|
||||
internal bool GetPlayerController(short playerControllerId, out QSBPlayerController playerController)
|
||||
@ -299,24 +296,18 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (m_Channels == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Channels not initialized sending on id '" + channelId);
|
||||
}
|
||||
Debug.LogWarning("Channels not initialized sending on id '" + channelId);
|
||||
result = false;
|
||||
}
|
||||
else if (channelId < 0 || channelId >= m_Channels.Length)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
"Invalid channel when sending buffered data, '",
|
||||
channelId,
|
||||
"'. Current channel count is ",
|
||||
m_Channels.Length
|
||||
}));
|
||||
}
|
||||
}));
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
|
@ -100,7 +100,7 @@ namespace QuantumUNET
|
||||
component.SetDynamicAssetId(newAssetId);
|
||||
guidToPrefab[component.AssetId] = prefab;
|
||||
}
|
||||
else if (LogFilter.logError)
|
||||
else
|
||||
{
|
||||
Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
|
||||
}
|
||||
@ -115,13 +115,10 @@ namespace QuantumUNET
|
||||
var componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>();
|
||||
if (componentsInChildren.Length > 1)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("The prefab '" + prefab.name + "' has multiple NetworkIdentity components. There can only be one NetworkIdentity on a prefab, and it must be on the root object.");
|
||||
}
|
||||
Debug.LogWarning("The prefab '" + prefab.name + "' has multiple NetworkIdentity components. There can only be one NetworkIdentity on a prefab, and it must be on the root object.");
|
||||
}
|
||||
}
|
||||
else if (LogFilter.logError)
|
||||
else
|
||||
{
|
||||
Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
|
||||
}
|
||||
@ -165,10 +162,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (spawnHandler == null || unspawnHandler == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("RegisterSpawnHandler custom spawn function null for " + assetId);
|
||||
}
|
||||
Debug.LogError("RegisterSpawnHandler custom spawn function null for " + assetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -182,10 +176,7 @@ namespace QuantumUNET
|
||||
var component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
if (component == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Could not unregister '" + prefab.name + "' since it contains no NetworkIdentity component");
|
||||
}
|
||||
Debug.LogError("Could not unregister '" + prefab.name + "' since it contains no NetworkIdentity component");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -596,16 +596,10 @@ namespace QuantumUNET
|
||||
{
|
||||
if (conn.PlayerControllers[i].Gameobject != null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Player not destroyed when connection disconnected.");
|
||||
}
|
||||
Debug.LogWarning("Player not destroyed when connection disconnected.");
|
||||
}
|
||||
}
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Server lost client:" + conn.connectionId);
|
||||
}
|
||||
Debug.Log("Server lost client:" + conn.connectionId);
|
||||
conn.RemoveObservers();
|
||||
conn.Dispose();
|
||||
}
|
||||
@ -614,36 +608,27 @@ namespace QuantumUNET
|
||||
|
||||
private void GenerateConnectError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("UNet Server Connect Error: " + error);
|
||||
}
|
||||
Debug.LogError("UNet Server Connect Error: " + error);
|
||||
GenerateError(null, error);
|
||||
}
|
||||
|
||||
private void GenerateDataError(QSBNetworkConnection conn, int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("UNet Server Data Error: " + (NetworkError)error);
|
||||
}
|
||||
Debug.LogError("UNet Server Data Error: " + (NetworkError)error);
|
||||
GenerateError(conn, error);
|
||||
}
|
||||
|
||||
private void GenerateDisconnectError(QSBNetworkConnection conn, int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
"UNet Server Disconnect Error: ",
|
||||
(NetworkError)error,
|
||||
" conn:[",
|
||||
conn,
|
||||
"]:",
|
||||
conn.connectionId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
GenerateError(conn, error);
|
||||
}
|
||||
|
||||
@ -723,11 +708,8 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Failed to send message to player object '" + player.name + ", not found in connection list");
|
||||
return;
|
||||
}
|
||||
Debug.LogError("Failed to send message to player object '" + player.name + ", not found in connection list");
|
||||
return;
|
||||
}
|
||||
|
||||
public static void SendToClient(int connectionId, short msgType, QSBMessageBase msg)
|
||||
@ -741,10 +723,7 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Failed to send message to connection ID '" + connectionId + ", not found in connection list");
|
||||
}
|
||||
Debug.LogError("Failed to send message to connection ID '" + connectionId + ", not found in connection list");
|
||||
}
|
||||
|
||||
public static bool AddPlayerForConnection(QSBNetworkConnection conn, GameObject player, short playerControllerId) => instance.InternalAddPlayerForConnection(conn, player, playerControllerId);
|
||||
@ -754,10 +733,7 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (!GetNetworkIdentity(playerGameObject, out var networkIdentity))
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.Log("AddPlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
|
||||
}
|
||||
Debug.Log("AddPlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -776,10 +752,7 @@ namespace QuantumUNET
|
||||
}
|
||||
if (x != null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.Log("AddPlayer: player object already exists for playerControllerId of " + playerControllerId);
|
||||
}
|
||||
Debug.Log("AddPlayer: player object already exists for playerControllerId of " + playerControllerId);
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -794,16 +767,13 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"Adding new playerGameObject object netId: ",
|
||||
playerGameObject.GetComponent<QSBNetworkIdentity>().NetId,
|
||||
" asset ID ",
|
||||
playerGameObject.GetComponent<QSBNetworkIdentity>().AssetId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
FinishPlayerForConnection(conn, networkIdentity, playerGameObject);
|
||||
if (networkIdentity.LocalPlayerAuthority)
|
||||
{
|
||||
@ -822,34 +792,25 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (playerControllerId < 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("AddPlayer: playerControllerId of " + playerControllerId + " is negative");
|
||||
}
|
||||
Debug.LogError("AddPlayer: playerControllerId of " + playerControllerId + " is negative");
|
||||
result = false;
|
||||
}
|
||||
else if (playerControllerId > 32)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"AddPlayer: playerControllerId of ",
|
||||
playerControllerId,
|
||||
" is too high. max is ",
|
||||
32
|
||||
}));
|
||||
}
|
||||
}));
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerControllerId > 16)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("AddPlayer: playerControllerId of " + playerControllerId + " is unusually high");
|
||||
}
|
||||
Debug.LogWarning("AddPlayer: playerControllerId of " + playerControllerId + " is unusually high");
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
@ -900,10 +861,7 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (!GetNetworkIdentity(playerGameObject, out var networkIdentity))
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
|
||||
}
|
||||
Debug.LogError("ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
|
||||
result = false;
|
||||
}
|
||||
else if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
|
||||
@ -928,16 +886,13 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"Replacing playerGameObject object netId: ",
|
||||
playerGameObject.GetComponent<NetworkIdentity>().netId,
|
||||
" asset ID ",
|
||||
playerGameObject.GetComponent<NetworkIdentity>().assetId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
FinishPlayerForConnection(conn, networkIdentity, playerGameObject);
|
||||
if (networkIdentity.LocalPlayerAuthority)
|
||||
{
|
||||
@ -969,25 +924,16 @@ namespace QuantumUNET
|
||||
|
||||
internal void SetClientReadyInternal(QSBNetworkConnection conn)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("SetClientReadyInternal for conn:" + conn.connectionId);
|
||||
}
|
||||
Debug.Log("SetClientReadyInternal for conn:" + conn.connectionId);
|
||||
if (conn.isReady)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("SetClientReady conn " + conn.connectionId + " already ready");
|
||||
}
|
||||
Debug.Log("SetClientReady conn " + conn.connectionId + " already ready");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conn.PlayerControllers.Count == 0)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.LogWarning("Ready with no player object");
|
||||
}
|
||||
Debug.LogWarning("Ready with no player object");
|
||||
}
|
||||
conn.isReady = true;
|
||||
if (conn is QSBULocalConnectionToClient ulocalConnectionToClient)
|
||||
@ -1012,16 +958,13 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"Spawning ",
|
||||
objects.Count,
|
||||
" objects for conn ",
|
||||
conn.connectionId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
var objectSpawnFinishedMessage = new QSBObjectSpawnFinishedMessage
|
||||
{
|
||||
State = 0U
|
||||
@ -1031,23 +974,17 @@ namespace QuantumUNET
|
||||
{
|
||||
if (networkIdentity2 == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Invalid object found in server local object list (null NetworkIdentity).");
|
||||
}
|
||||
Debug.LogWarning("Invalid object found in server local object list (null NetworkIdentity).");
|
||||
}
|
||||
else if (networkIdentity2.gameObject.activeSelf)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"Sending spawn message for current server objects name='",
|
||||
networkIdentity2.gameObject.name,
|
||||
"' netId=",
|
||||
networkIdentity2.NetId
|
||||
}));
|
||||
}
|
||||
}));
|
||||
var flag2 = networkIdentity2.OnCheckObserver(conn);
|
||||
if (flag2)
|
||||
{
|
||||
@ -1095,10 +1032,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (conn.isReady)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("PlayerNotReady " + conn);
|
||||
}
|
||||
Debug.Log("PlayerNotReady " + conn);
|
||||
conn.isReady = false;
|
||||
conn.RemoveObservers();
|
||||
var msg = new QSBNotReadyMessage();
|
||||
@ -1108,10 +1042,7 @@ namespace QuantumUNET
|
||||
|
||||
private static void OnClientReadyMessage(QSBNetworkMessage netMsg)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Default handler for ready message from " + netMsg.Connection);
|
||||
}
|
||||
Debug.Log("Default handler for ready message from " + netMsg.Connection);
|
||||
SetClientReady(netMsg.Connection);
|
||||
}
|
||||
|
||||
@ -1124,7 +1055,7 @@ namespace QuantumUNET
|
||||
netMsg.Connection.RemovePlayerController(s_RemovePlayerMessage.PlayerControllerId);
|
||||
Destroy(playerController.Gameobject);
|
||||
}
|
||||
else if (LogFilter.logError)
|
||||
else
|
||||
{
|
||||
Debug.LogError("Received remove player message but could not find the player ID: " + s_RemovePlayerMessage.PlayerControllerId);
|
||||
}
|
||||
@ -1137,20 +1068,14 @@ namespace QuantumUNET
|
||||
var gameObject = FindLocalObject(networkInstanceId);
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Instance not found when handling Command message [netId=" + networkInstanceId + "]");
|
||||
}
|
||||
Debug.LogWarning("Instance not found when handling Command message [netId=" + networkInstanceId + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
var component = gameObject.GetComponent<QSBNetworkIdentity>();
|
||||
if (component == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("NetworkIdentity deleted when handling Command message [netId=" + networkInstanceId + "]");
|
||||
}
|
||||
Debug.LogWarning("NetworkIdentity deleted when handling Command message [netId=" + networkInstanceId + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1168,10 +1093,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (component.ClientAuthorityOwner != netMsg.Connection)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Command for object without authority [netId=" + networkInstanceId + "]");
|
||||
}
|
||||
Debug.LogWarning("Command for object without authority [netId=" + networkInstanceId + "]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1269,10 +1191,7 @@ namespace QuantumUNET
|
||||
{
|
||||
if (conn.PlayerControllers.Count == 0)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
|
||||
}
|
||||
Debug.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1332,10 +1251,7 @@ namespace QuantumUNET
|
||||
|
||||
private static void DestroyObject(QSBNetworkIdentity uv, bool destroyServerObject)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("DestroyObject instance:" + uv.NetId);
|
||||
}
|
||||
Debug.Log("DestroyObject instance:" + uv.NetId);
|
||||
if (objects.ContainsKey(uv.NetId))
|
||||
{
|
||||
objects.Remove(uv.NetId);
|
||||
@ -1484,16 +1400,13 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
"Local invoke: Failed to find local connection to invoke handler on [connectionId=",
|
||||
conn.connectionId,
|
||||
"] for MsgId:",
|
||||
msgType
|
||||
}));
|
||||
}
|
||||
}));
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -1517,16 +1430,13 @@ namespace QuantumUNET
|
||||
{
|
||||
if (ValidateSceneObject(networkIdentity))
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"SpawnObjects sceneId:",
|
||||
networkIdentity.SceneId,
|
||||
" name:",
|
||||
networkIdentity.gameObject.name
|
||||
}));
|
||||
}
|
||||
}));
|
||||
networkIdentity.Reset();
|
||||
networkIdentity.gameObject.SetActive(true);
|
||||
}
|
||||
|
@ -51,10 +51,7 @@ namespace QuantumUNET
|
||||
connectionConfig.AddChannel(QosType.Unreliable);
|
||||
hostTopology = new HostTopology(connectionConfig, 8);
|
||||
}
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple initialize.");
|
||||
}
|
||||
Debug.Log("NetworkServerSimple initialize.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,16 +86,13 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"NetworkServerSimple listen: ",
|
||||
ipAddress,
|
||||
":",
|
||||
listenPort
|
||||
}));
|
||||
}
|
||||
}));
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
@ -126,10 +120,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple listen " + listenPort);
|
||||
}
|
||||
Debug.Log("NetworkServerSimple listen " + listenPort);
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
@ -139,25 +130,16 @@ namespace QuantumUNET
|
||||
{
|
||||
Initialize();
|
||||
serverHostId = NetworkTransport.AddHost(hostTopology, listenPort);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Server Host Slot Id: " + serverHostId);
|
||||
}
|
||||
Debug.Log("Server Host Slot Id: " + serverHostId);
|
||||
Update();
|
||||
NetworkTransport.ConnectAsNetworkHost(serverHostId, relayIp, relayPort, netGuid, sourceId, nodeId, out var b);
|
||||
m_RelaySlotId = 0;
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Relay Slot Id: " + m_RelaySlotId);
|
||||
}
|
||||
Debug.Log("Relay Slot Id: " + m_RelaySlotId);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple stop ");
|
||||
}
|
||||
Debug.Log("NetworkServerSimple stop ");
|
||||
NetworkTransport.RemoveHost(serverHostId);
|
||||
serverHostId = -1;
|
||||
}
|
||||
@ -192,24 +174,15 @@ namespace QuantumUNET
|
||||
networkEventType = NetworkTransport.ReceiveRelayEventFromHost(serverHostId, out var b);
|
||||
if (networkEventType != NetworkEventType.Nothing)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetGroup event:" + networkEventType);
|
||||
}
|
||||
Debug.Log("NetGroup event:" + networkEventType);
|
||||
}
|
||||
if (networkEventType == NetworkEventType.ConnectEvent)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetGroup server connected");
|
||||
}
|
||||
Debug.Log("NetGroup server connected");
|
||||
}
|
||||
if (networkEventType == NetworkEventType.DisconnectEvent)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetGroup server disconnected");
|
||||
}
|
||||
Debug.Log("NetGroup server disconnected");
|
||||
}
|
||||
}
|
||||
do
|
||||
@ -245,10 +218,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
|
||||
default:
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Unknown network message type received: " + networkEventType);
|
||||
}
|
||||
Debug.LogError("Unknown network message type received: " + networkEventType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -308,10 +278,7 @@ namespace QuantumUNET
|
||||
|
||||
private void HandleConnect(int connectionId, byte error)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple accepted client:" + connectionId);
|
||||
}
|
||||
Debug.Log("NetworkServerSimple accepted client:" + connectionId);
|
||||
if (error != 0)
|
||||
{
|
||||
OnConnectError(connectionId, error);
|
||||
@ -334,10 +301,7 @@ namespace QuantumUNET
|
||||
|
||||
private void HandleDisconnect(int connectionId, byte error)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple disconnect client:" + connectionId);
|
||||
}
|
||||
Debug.Log("NetworkServerSimple disconnect client:" + connectionId);
|
||||
var networkConnection = FindConnection(connectionId);
|
||||
if (networkConnection != null)
|
||||
{
|
||||
@ -347,26 +311,20 @@ namespace QuantumUNET
|
||||
if (error != 6)
|
||||
{
|
||||
m_Connections[connectionId] = null;
|
||||
if (LogFilter.logError)
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
"Server client disconnect error, connectionId: ",
|
||||
connectionId,
|
||||
" error: ",
|
||||
(NetworkError)error
|
||||
}));
|
||||
}
|
||||
}));
|
||||
OnDisconnectError(networkConnection, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
networkConnection.Disconnect();
|
||||
m_Connections[connectionId] = null;
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Server lost client:" + connectionId);
|
||||
}
|
||||
Debug.Log("Server lost client:" + connectionId);
|
||||
OnDisconnected(networkConnection);
|
||||
}
|
||||
}
|
||||
@ -376,10 +334,7 @@ namespace QuantumUNET
|
||||
var networkConnection = FindConnection(connectionId);
|
||||
if (networkConnection == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("HandleData Unknown connectionId:" + connectionId);
|
||||
}
|
||||
Debug.LogError("HandleData Unknown connectionId:" + connectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using QuantumUNET.Messages;
|
||||
using QuantumUNET.Transport;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace QuantumUNET
|
||||
{
|
||||
@ -27,10 +26,7 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (numBytes <= 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("LocalConnection:SendBytes cannot send zero bytes");
|
||||
}
|
||||
Debug.LogError("LocalConnection:SendBytes cannot send zero bytes");
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
|
@ -398,10 +398,7 @@ namespace QuantumUNET.Transport
|
||||
var gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ReadTransform netId:" + networkInstanceId);
|
||||
}
|
||||
Debug.Log("ReadTransform netId:" + networkInstanceId);
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
@ -433,10 +430,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ReadGameObject netId:" + networkInstanceId + "go: null");
|
||||
}
|
||||
Debug.Log("ReadGameObject netId:" + networkInstanceId + "go: null");
|
||||
}
|
||||
result = gameObject;
|
||||
}
|
||||
@ -464,10 +458,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ReadNetworkIdentity netId:" + networkInstanceId + "go: null");
|
||||
}
|
||||
Debug.Log("ReadNetworkIdentity netId:" + networkInstanceId + "go: null");
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
|
@ -222,10 +222,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
if (count > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -237,10 +234,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
if (count > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -256,10 +250,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
else if (count > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter WriteBytesAndSize: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
Debug.LogError("NetworkWriter WriteBytesAndSize: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -276,10 +267,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
else if (buffer.Length > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter WriteBytes: buffer is too large (" + buffer.Length + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
Debug.LogError("NetworkWriter WriteBytes: buffer is too large (" + buffer.Length + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -420,10 +408,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
|
||||
}
|
||||
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
|
||||
WritePackedUInt32(0U);
|
||||
}
|
||||
}
|
||||
@ -444,10 +429,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
|
||||
}
|
||||
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
|
||||
WritePackedUInt32(0U);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user