remove logfilter

This commit is contained in:
Mister_Nebula 2020-12-18 20:20:54 +00:00
parent 89625a5610
commit c2d7cb10a9
11 changed files with 155 additions and 539 deletions

View File

@ -12,7 +12,6 @@ using QSB.Utility;
using QuantumUNET; using QuantumUNET;
using QuantumUNET.Components; using QuantumUNET.Components;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking;
/* /*
Copyright (C) 2020 Henry Pointer (_nebula / misternebula), Aleksander Waage (AmazingAlek), Ricardo Lopes (Raicuparta) 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..."; "<color=orange>Quantum Space Buddies</color> is best experienced with friends...";
ModBehaviour = this; ModBehaviour = this;
LogFilter.currentLogLevel = LogFilter.Debug;
} }
public void Start() public void Start()

View File

@ -45,18 +45,12 @@ namespace QuantumUNET
bool result; bool result;
if (playerControllerId >= localPlayers.Count) 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; result = false;
} }
else if (localPlayers[playerControllerId] == null) 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; result = false;
} }
else else
@ -69,16 +63,10 @@ namespace QuantumUNET
internal static void InternalAddPlayer(QSBNetworkIdentity view, short playerControllerId) 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 (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) while (playerControllerId >= localPlayers.Count)
{ {
localPlayers.Add(new QSBPlayerController()); localPlayers.Add(new QSBPlayerController());
@ -121,10 +109,7 @@ namespace QuantumUNET
{ {
if (playerControllerId > 16) 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) while (playerControllerId >= localPlayers.Count)
{ {
@ -134,10 +119,7 @@ namespace QuantumUNET
{ {
if (!ready) 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; return false;
} }
} }
@ -150,24 +132,18 @@ namespace QuantumUNET
{ {
if (playerController.IsValid && playerController.Gameobject != null) 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; return false;
} }
} }
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"ClientScene::AddPlayer() for ID ", "ClientScene::AddPlayer() for ID ",
playerControllerId, playerControllerId,
" called with connection [", " called with connection [",
readyConnection, readyConnection,
"]" "]"
})); }));
}
var addPlayerMessage = new QSBAddPlayerMessage var addPlayerMessage = new QSBAddPlayerMessage
{ {
playerControllerId = playerControllerId playerControllerId = playerControllerId
@ -187,17 +163,14 @@ namespace QuantumUNET
public static bool RemovePlayer(short playerControllerId) 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 ", "ClientScene::RemovePlayer() for ID ",
playerControllerId, playerControllerId,
" called with connection [", " called with connection [",
readyConnection, readyConnection,
"]" "]"
})); }));
}
bool result; bool result;
if (readyConnection.GetPlayerController(playerControllerId, out var playerController)) if (readyConnection.GetPlayerController(playerControllerId, out var playerController))
{ {
@ -213,10 +186,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logError) Debug.LogError("Failed to find player ID " + playerControllerId);
{
Debug.LogError("Failed to find player ID " + playerControllerId);
}
result = false; result = false;
} }
return result; return result;
@ -227,18 +197,12 @@ namespace QuantumUNET
bool result; bool result;
if (ready) 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; result = false;
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
{
Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
}
if (conn != null) if (conn != null)
{ {
var msg = new QSBReadyMessage(); var msg = new QSBReadyMessage();
@ -250,10 +214,7 @@ namespace QuantumUNET
} }
else 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; result = false;
} }
} }
@ -299,10 +260,7 @@ namespace QuantumUNET
if (!networkIdentity.SceneId.IsEmpty()) if (!networkIdentity.SceneId.IsEmpty())
{ {
SpawnableObjects[networkIdentity.SceneId] = networkIdentity; 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); var networkIdentity2 = SpawnSceneObject(s_ObjectSpawnSceneMessage.SceneId);
if (networkIdentity2 == null) 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 else
{ {
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"Client spawn for [netId:", "Client spawn for [netId:",
s_ObjectSpawnSceneMessage.NetId, s_ObjectSpawnSceneMessage.NetId,
"] [sceneId:", "] [sceneId:",
s_ObjectSpawnSceneMessage.SceneId, s_ObjectSpawnSceneMessage.SceneId,
"] obj:", "] obj:",
networkIdentity2.gameObject.name networkIdentity2.gameObject.name
})); }));
}
ApplySpawnPayload(networkIdentity2, s_ObjectSpawnSceneMessage.Position, s_ObjectSpawnSceneMessage.Payload, s_ObjectSpawnSceneMessage.NetId, networkIdentity2.gameObject); 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) private static void OnObjectSpawnFinished(QSBNetworkMessage netMsg)
{ {
netMsg.ReadMessage<QSBObjectSpawnFinishedMessage>(s_ObjectSpawnFinishedMessage); 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) if (s_ObjectSpawnFinishedMessage.State == 0U)
{ {
PrepareToSpawnSceneObjects(); PrepareToSpawnSceneObjects();
@ -544,10 +493,7 @@ namespace QuantumUNET
private static void OnObjectDestroy(QSBNetworkMessage netMsg) private static void OnObjectDestroy(QSBNetworkMessage netMsg)
{ {
netMsg.ReadMessage<QSBObjectDestroyMessage>(s_ObjectDestroyMessage); 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)) if (s_NetworkScene.GetNetworkIdentity(s_ObjectDestroyMessage.NetId, out var networkIdentity))
{ {
networkIdentity.OnNetworkDestroy(); networkIdentity.OnNetworkDestroy();
@ -566,7 +512,7 @@ namespace QuantumUNET
s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.NetId); s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.NetId);
networkIdentity.MarkForReset(); networkIdentity.MarkForReset();
} }
else if (LogFilter.logDebug) else
{ {
Debug.LogWarning("Did not find target for destroy message for " + s_ObjectDestroyMessage.NetId); 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) private static void OnLocalClientObjectDestroy(QSBNetworkMessage netMsg)
{ {
netMsg.ReadMessage<QSBObjectDestroyMessage>(s_ObjectDestroyMessage); 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); s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.NetId);
} }
private static void OnLocalClientObjectHide(QSBNetworkMessage netMsg) private static void OnLocalClientObjectHide(QSBNetworkMessage netMsg)
{ {
netMsg.ReadMessage<QSBObjectDestroyMessage>(s_ObjectDestroyMessage); 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)) if (s_NetworkScene.GetNetworkIdentity(s_ObjectDestroyMessage.NetId, out var networkIdentity))
{ {
networkIdentity.OnSetLocalVisibility(false); networkIdentity.OnSetLocalVisibility(false);
@ -620,7 +560,7 @@ namespace QuantumUNET
{ {
networkIdentity.OnUpdateVars(netMsg.Reader, false); networkIdentity.OnUpdateVars(netMsg.Reader, false);
} }
else if (LogFilter.logWarn) else
{ {
Debug.LogWarning("Did not find target for sync message for " + networkInstanceId); Debug.LogWarning("Did not find target for sync message for " + networkInstanceId);
} }
@ -630,21 +570,18 @@ namespace QuantumUNET
{ {
var num = (int)netMsg.Reader.ReadPackedUInt32(); var num = (int)netMsg.Reader.ReadPackedUInt32();
var networkInstanceId = netMsg.Reader.ReadNetworkId(); var networkInstanceId = netMsg.Reader.ReadNetworkId();
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"ClientScene::OnRPCMessage hash:", "ClientScene::OnRPCMessage hash:",
num, num,
" netId:", " netId:",
networkInstanceId networkInstanceId
})); }));
}
if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity)) if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity))
{ {
networkIdentity.HandleRPC(num, netMsg.Reader); networkIdentity.HandleRPC(num, netMsg.Reader);
} }
else if (LogFilter.logWarn) else
{ {
var cmdHashHandlerName = QSBNetworkBehaviour.GetCmdHashHandlerName(num); var cmdHashHandlerName = QSBNetworkBehaviour.GetCmdHashHandlerName(num);
Debug.LogWarningFormat("Could not find target object with netId:{0} for RPC call {1}", new object[] 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 cmdHash = (int)netMsg.Reader.ReadPackedUInt32();
var networkInstanceId = netMsg.Reader.ReadNetworkId(); 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)) if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity))
{ {
networkIdentity.HandleSyncEvent(cmdHash, netMsg.Reader); networkIdentity.HandleSyncEvent(cmdHash, netMsg.Reader);
} }
else if (LogFilter.logWarn) else
{ {
Debug.LogWarning("Did not find target for SyncEvent message for " + networkInstanceId); Debug.LogWarning("Did not find target for SyncEvent message for " + networkInstanceId);
} }
@ -677,15 +611,12 @@ namespace QuantumUNET
{ {
var networkInstanceId = netMsg.Reader.ReadNetworkId(); var networkInstanceId = netMsg.Reader.ReadNetworkId();
var cmdHash = (int)netMsg.Reader.ReadPackedUInt32(); 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)) if (s_NetworkScene.GetNetworkIdentity(networkInstanceId, out var networkIdentity))
{ {
networkIdentity.HandleSyncList(cmdHash, netMsg.Reader); networkIdentity.HandleSyncList(cmdHash, netMsg.Reader);
} }
else if (LogFilter.logWarn) else
{ {
Debug.LogWarning("Did not find target for SyncList message for " + networkInstanceId); Debug.LogWarning("Did not find target for SyncList message for " + networkInstanceId);
} }
@ -694,16 +625,13 @@ namespace QuantumUNET
private static void OnClientAuthority(QSBNetworkMessage netMsg) private static void OnClientAuthority(QSBNetworkMessage netMsg)
{ {
netMsg.ReadMessage<QSBClientAuthorityMessage>(s_ClientAuthorityMessage); netMsg.ReadMessage<QSBClientAuthorityMessage>(s_ClientAuthorityMessage);
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"ClientScene::OnClientAuthority for connectionId=", "ClientScene::OnClientAuthority for connectionId=",
netMsg.Connection.connectionId, netMsg.Connection.connectionId,
" netId: ", " netId: ",
s_ClientAuthorityMessage.netId s_ClientAuthorityMessage.netId
})); }));
}
if (s_NetworkScene.GetNetworkIdentity(s_ClientAuthorityMessage.netId, out var networkIdentity)) if (s_NetworkScene.GetNetworkIdentity(s_ClientAuthorityMessage.netId, out var networkIdentity))
{ {
networkIdentity.HandleClientAuthority(s_ClientAuthorityMessage.authority); networkIdentity.HandleClientAuthority(s_ClientAuthorityMessage.authority);
@ -713,16 +641,13 @@ namespace QuantumUNET
private static void OnOwnerMessage(QSBNetworkMessage netMsg) private static void OnOwnerMessage(QSBNetworkMessage netMsg)
{ {
netMsg.ReadMessage<QSBOwnerMessage>(s_OwnerMessage); netMsg.ReadMessage<QSBOwnerMessage>(s_OwnerMessage);
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"ClientScene::OnOwnerMessage - connectionId=", "ClientScene::OnOwnerMessage - connectionId=",
netMsg.Connection.connectionId, netMsg.Connection.connectionId,
" netId: ", " netId: ",
s_OwnerMessage.NetId s_OwnerMessage.NetId
})); }));
}
if (netMsg.Connection.GetPlayerController(s_OwnerMessage.PlayerControllerId, out var playerController)) if (netMsg.Connection.GetPlayerController(s_OwnerMessage.PlayerControllerId, out var playerController))
{ {
playerController.UnetView.SetNotLocalPlayer(); playerController.UnetView.SetNotLocalPlayer();
@ -757,10 +682,7 @@ namespace QuantumUNET
Debug.Log("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name); Debug.Log("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name);
if (readyConnection.connectionId < 0) 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; break;
} }
InternalAddPlayer(uv, pendingOwner.playerControllerId); InternalAddPlayer(uv, pendingOwner.playerControllerId);

View File

@ -71,11 +71,8 @@ namespace QuantumUNET
{ {
if (!IsServer) 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(); writer.FinishMessage();
QSBNetworkServer.SendWriterToReady(gameObject, writer, channelId); QSBNetworkServer.SendWriterToReady(gameObject, writer, channelId);
@ -418,10 +415,7 @@ namespace QuantumUNET
networkInstanceId = component.NetId; networkInstanceId = component.NetId;
if (networkInstanceId.IsEmpty()) 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?");
}
} }
} }
} }

View File

@ -94,32 +94,23 @@ namespace QuantumUNET
bool result; bool result;
if (!active) if (!active)
{ {
if (LogFilter.logError) Debug.LogError("Reconnect - NetworkClient must be active");
{
Debug.LogError("Reconnect - NetworkClient must be active");
}
result = false; result = false;
} }
else if (m_Connection == null) else if (m_Connection == null)
{ {
if (LogFilter.logError) Debug.LogError("Reconnect - no old connection exists");
{
Debug.LogError("Reconnect - no old connection exists");
}
result = false; result = false;
} }
else else
{ {
if (LogFilter.logInfo) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"NetworkClient Reconnect ", "NetworkClient Reconnect ",
serverIp, serverIp,
":", ":",
serverPort serverPort
})); }));
}
QSBClientScene.HandleClientDisconnect(m_Connection); QSBClientScene.HandleClientDisconnect(m_Connection);
QSBClientScene.ClearLocalPlayers(); QSBClientScene.ClearLocalPlayers();
m_Connection.Disconnect(); m_Connection.Disconnect();
@ -138,10 +129,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log("Async DNS START:" + serverIp);
{
Debug.Log("Async DNS START:" + serverIp);
}
m_AsyncConnect = ConnectState.Resolving; m_AsyncConnect = ConnectState.Resolving;
Dns.BeginGetHostAddresses(serverIp, new AsyncCallback(GetHostAddressesCallback), this); Dns.BeginGetHostAddresses(serverIp, new AsyncCallback(GetHostAddressesCallback), this);
} }
@ -155,26 +143,17 @@ namespace QuantumUNET
bool result; bool result;
if (!active) if (!active)
{ {
if (LogFilter.logError) Debug.LogError("Reconnect - NetworkClient must be active");
{
Debug.LogError("Reconnect - NetworkClient must be active");
}
result = false; result = false;
} }
else if (m_Connection == null) else if (m_Connection == null)
{ {
if (LogFilter.logError) Debug.LogError("Reconnect - no old connection exists");
{
Debug.LogError("Reconnect - no old connection exists");
}
result = false; result = false;
} }
else else
{ {
if (LogFilter.logInfo) Debug.Log("NetworkClient Reconnect to remoteSockAddr");
{
Debug.Log("NetworkClient Reconnect to remoteSockAddr");
}
QSBClientScene.HandleClientDisconnect(m_Connection); QSBClientScene.HandleClientDisconnect(m_Connection);
QSBClientScene.ClearLocalPlayers(); QSBClientScene.ClearLocalPlayers();
m_Connection.Disconnect(); m_Connection.Disconnect();
@ -182,19 +161,13 @@ namespace QuantumUNET
hostId = NetworkTransport.AddHost(hostTopology, m_HostPort); hostId = NetworkTransport.AddHost(hostTopology, m_HostPort);
if (secureTunnelEndPoint == null) 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; m_AsyncConnect = ConnectState.Failed;
result = false; result = false;
} }
else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6) 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; m_AsyncConnect = ConnectState.Failed;
result = false; result = false;
} }
@ -209,10 +182,7 @@ namespace QuantumUNET
} }
else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint") 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; m_AsyncConnect = ConnectState.Failed;
result = false; result = false;
} }
@ -227,19 +197,13 @@ namespace QuantumUNET
} }
catch (Exception arg) 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; m_AsyncConnect = ConnectState.Failed;
return false; return false;
} }
if (m_ClientConnectionId == 0) 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; m_AsyncConnect = ConnectState.Failed;
result = false; result = false;
} }
@ -316,24 +280,15 @@ namespace QuantumUNET
//bool usePlatformSpecificProtocols = NetworkTransport.DoesEndPointUsePlatformProtocols(secureTunnelEndPoint); //bool usePlatformSpecificProtocols = NetworkTransport.DoesEndPointUsePlatformProtocols(secureTunnelEndPoint);
var usePlatformSpecificProtocols = false; var usePlatformSpecificProtocols = false;
PrepareForConnect(usePlatformSpecificProtocols); PrepareForConnect(usePlatformSpecificProtocols);
if (LogFilter.logDebug) Debug.Log("Client Connect to remoteSockAddr");
{
Debug.Log("Client Connect to remoteSockAddr");
}
if (secureTunnelEndPoint == null) 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; m_AsyncConnect = ConnectState.Failed;
} }
else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6) 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; m_AsyncConnect = ConnectState.Failed;
} }
else else
@ -346,10 +301,7 @@ namespace QuantumUNET
} }
else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint" && fullName != "UnityEngine.PSVita.SceEndPoint") 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; m_AsyncConnect = ConnectState.Failed;
} }
else else
@ -363,19 +315,13 @@ namespace QuantumUNET
} }
catch (Exception arg) 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; m_AsyncConnect = ConnectState.Failed;
return; return;
} }
if (m_ClientConnectionId == 0) 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; m_AsyncConnect = ConnectState.Failed;
} }
else else
@ -512,10 +458,7 @@ namespace QuantumUNET
{ {
if (m_AsyncConnect != ConnectState.Connected) 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; result = false;
} }
else else
@ -525,10 +468,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logError) Debug.LogError("NetworkClient Send with no connection");
{
Debug.LogError("NetworkClient Send with no connection");
}
result = false; result = false;
} }
return result; return result;
@ -541,10 +481,7 @@ namespace QuantumUNET
{ {
if (m_AsyncConnect != ConnectState.Connected) 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; result = false;
} }
else else
@ -554,10 +491,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logError) Debug.LogError("NetworkClient SendWriter with no connection");
{
Debug.LogError("NetworkClient SendWriter with no connection");
}
result = false; result = false;
} }
return result; return result;
@ -570,10 +504,7 @@ namespace QuantumUNET
{ {
if (m_AsyncConnect != ConnectState.Connected) 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; result = false;
} }
else else
@ -583,10 +514,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logError) Debug.LogError("NetworkClient SendBytes with no connection");
{
Debug.LogError("NetworkClient SendBytes with no connection");
}
result = false; result = false;
} }
return result; return result;
@ -599,10 +527,7 @@ namespace QuantumUNET
{ {
if (m_AsyncConnect != ConnectState.Connected) 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; result = false;
} }
else else
@ -612,10 +537,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logError) Debug.LogError("NetworkClient SendUnreliable with no connection");
{
Debug.LogError("NetworkClient SendUnreliable with no connection");
}
result = false; result = false;
} }
return result; return result;
@ -628,10 +550,7 @@ namespace QuantumUNET
{ {
if (m_AsyncConnect != ConnectState.Connected) 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; result = false;
} }
else else
@ -641,10 +560,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logError) Debug.LogError("NetworkClient SendByChannel with no connection");
{
Debug.LogError("NetworkClient SendByChannel with no connection");
}
result = false; result = false;
} }
return result; return result;
@ -654,10 +570,7 @@ namespace QuantumUNET
{ {
if (m_Connection == null) if (m_Connection == null)
{ {
if (LogFilter.logWarn) Debug.LogWarning("SetMaxDelay failed, not connected.");
{
Debug.LogWarning("SetMaxDelay failed, not connected.");
}
} }
else else
{ {
@ -667,10 +580,7 @@ namespace QuantumUNET
public void Shutdown() public void Shutdown()
{ {
if (LogFilter.logDebug) Debug.Log("Shutting down client " + hostId);
{
Debug.Log("Shutting down client " + hostId);
}
if (hostId != -1) if (hostId != -1)
{ {
NetworkTransport.RemoveHost(hostId); NetworkTransport.RemoveHost(hostId);
@ -693,12 +603,10 @@ namespace QuantumUNET
case ConnectState.Resolving: case ConnectState.Resolving:
case ConnectState.Disconnected: case ConnectState.Disconnected:
return; return;
case ConnectState.Resolved: case ConnectState.Resolved:
m_AsyncConnect = ConnectState.Connecting; m_AsyncConnect = ConnectState.Connecting;
ContinueConnect(); ContinueConnect();
return; return;
case ConnectState.Failed: case ConnectState.Failed:
GenerateConnectError(11); GenerateConnectError(11);
m_AsyncConnect = ConnectState.Disconnected; m_AsyncConnect = ConnectState.Disconnected;
@ -733,10 +641,7 @@ namespace QuantumUNET
break; break;
case NetworkEventType.ConnectEvent: case NetworkEventType.ConnectEvent:
if (LogFilter.logDebug) Debug.Log("Client connected");
{
Debug.Log("Client connected");
}
if (b != 0) if (b != 0)
{ {
goto Block_10; goto Block_10;
@ -746,10 +651,7 @@ namespace QuantumUNET
break; break;
case NetworkEventType.DisconnectEvent: case NetworkEventType.DisconnectEvent:
if (LogFilter.logDebug) Debug.Log("Client disconnected");
{
Debug.Log("Client disconnected");
}
m_AsyncConnect = ConnectState.Disconnected; m_AsyncConnect = ConnectState.Disconnected;
if (b != 0) if (b != 0)
{ {
@ -769,10 +671,7 @@ namespace QuantumUNET
break; break;
default: default:
if (LogFilter.logError) Debug.LogError("Unknown network message type received: " + networkEventType);
{
Debug.LogError("Unknown network message type received: " + networkEventType);
}
break; break;
} }
if (++num >= 500) if (++num >= 500)
@ -795,10 +694,7 @@ namespace QuantumUNET
GenerateDataError(b); GenerateDataError(b);
return; return;
Block_17: Block_17:
if (LogFilter.logDebug) Debug.Log("MaxEventsPerFrame hit (" + 500 + ")");
{
Debug.Log("MaxEventsPerFrame hit (" + 500 + ")");
}
Block_19: Block_19:
IL_2C6: IL_2C6:
if (m_Connection != null && m_AsyncConnect == ConnectState.Connected) if (m_Connection != null && m_AsyncConnect == ConnectState.Connected)
@ -810,28 +706,19 @@ namespace QuantumUNET
private void GenerateConnectError(int error) 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); GenerateError(error);
} }
private void GenerateDataError(int 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); GenerateError(error);
} }
private void GenerateDisconnectError(int 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); GenerateError(error);
} }

View File

@ -199,11 +199,8 @@ namespace QuantumUNET
return; 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) internal bool GetPlayerController(short playerControllerId, out QSBPlayerController playerController)
@ -299,24 +296,18 @@ namespace QuantumUNET
bool result; bool result;
if (m_Channels == null) 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; result = false;
} }
else if (channelId < 0 || channelId >= m_Channels.Length) 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, '", "Invalid channel when sending buffered data, '",
channelId, channelId,
"'. Current channel count is ", "'. Current channel count is ",
m_Channels.Length m_Channels.Length
})); }));
}
result = false; result = false;
} }
else else

View File

@ -100,7 +100,7 @@ namespace QuantumUNET
component.SetDynamicAssetId(newAssetId); component.SetDynamicAssetId(newAssetId);
guidToPrefab[component.AssetId] = prefab; guidToPrefab[component.AssetId] = prefab;
} }
else if (LogFilter.logError) else
{ {
Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component"); Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
} }
@ -115,13 +115,10 @@ namespace QuantumUNET
var componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>(); var componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>();
if (componentsInChildren.Length > 1) 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"); 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 (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 else
{ {
@ -182,10 +176,7 @@ namespace QuantumUNET
var component = prefab.GetComponent<QSBNetworkIdentity>(); var component = prefab.GetComponent<QSBNetworkIdentity>();
if (component == null) 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 else
{ {

View File

@ -596,16 +596,10 @@ namespace QuantumUNET
{ {
if (conn.PlayerControllers[i].Gameobject != null) 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.RemoveObservers();
conn.Dispose(); conn.Dispose();
} }
@ -614,36 +608,27 @@ namespace QuantumUNET
private void GenerateConnectError(int error) 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); GenerateError(null, error);
} }
private void GenerateDataError(QSBNetworkConnection conn, int 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); GenerateError(conn, error);
} }
private void GenerateDisconnectError(QSBNetworkConnection conn, int 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: ", "UNet Server Disconnect Error: ",
(NetworkError)error, (NetworkError)error,
" conn:[", " conn:[",
conn, conn,
"]:", "]:",
conn.connectionId conn.connectionId
})); }));
}
GenerateError(conn, error); 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) public static void SendToClient(int connectionId, short msgType, QSBMessageBase msg)
@ -741,10 +723,7 @@ namespace QuantumUNET
return; 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); public static bool AddPlayerForConnection(QSBNetworkConnection conn, GameObject player, short playerControllerId) => instance.InternalAddPlayerForConnection(conn, player, playerControllerId);
@ -754,10 +733,7 @@ namespace QuantumUNET
bool result; bool result;
if (!GetNetworkIdentity(playerGameObject, out var networkIdentity)) 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; result = false;
} }
else else
@ -776,10 +752,7 @@ namespace QuantumUNET
} }
if (x != null) 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; result = false;
} }
else else
@ -794,16 +767,13 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"Adding new playerGameObject object netId: ", "Adding new playerGameObject object netId: ",
playerGameObject.GetComponent<QSBNetworkIdentity>().NetId, playerGameObject.GetComponent<QSBNetworkIdentity>().NetId,
" asset ID ", " asset ID ",
playerGameObject.GetComponent<QSBNetworkIdentity>().AssetId playerGameObject.GetComponent<QSBNetworkIdentity>().AssetId
})); }));
}
FinishPlayerForConnection(conn, networkIdentity, playerGameObject); FinishPlayerForConnection(conn, networkIdentity, playerGameObject);
if (networkIdentity.LocalPlayerAuthority) if (networkIdentity.LocalPlayerAuthority)
{ {
@ -822,34 +792,25 @@ namespace QuantumUNET
bool result; bool result;
if (playerControllerId < 0) if (playerControllerId < 0)
{ {
if (LogFilter.logError) Debug.LogError("AddPlayer: playerControllerId of " + playerControllerId + " is negative");
{
Debug.LogError("AddPlayer: playerControllerId of " + playerControllerId + " is negative");
}
result = false; result = false;
} }
else if (playerControllerId > 32) else if (playerControllerId > 32)
{ {
if (LogFilter.logError) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"AddPlayer: playerControllerId of ", "AddPlayer: playerControllerId of ",
playerControllerId, playerControllerId,
" is too high. max is ", " is too high. max is ",
32 32
})); }));
}
result = false; result = false;
} }
else else
{ {
if (playerControllerId > 16) 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; result = true;
} }
@ -900,10 +861,7 @@ namespace QuantumUNET
bool result; bool result;
if (!GetNetworkIdentity(playerGameObject, out var networkIdentity)) 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; result = false;
} }
else if (!CheckPlayerControllerIdForConnection(conn, playerControllerId)) else if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
@ -928,16 +886,13 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"Replacing playerGameObject object netId: ", "Replacing playerGameObject object netId: ",
playerGameObject.GetComponent<NetworkIdentity>().netId, playerGameObject.GetComponent<NetworkIdentity>().netId,
" asset ID ", " asset ID ",
playerGameObject.GetComponent<NetworkIdentity>().assetId playerGameObject.GetComponent<NetworkIdentity>().assetId
})); }));
}
FinishPlayerForConnection(conn, networkIdentity, playerGameObject); FinishPlayerForConnection(conn, networkIdentity, playerGameObject);
if (networkIdentity.LocalPlayerAuthority) if (networkIdentity.LocalPlayerAuthority)
{ {
@ -969,25 +924,16 @@ namespace QuantumUNET
internal void SetClientReadyInternal(QSBNetworkConnection conn) 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 (conn.isReady)
{ {
if (LogFilter.logDebug) Debug.Log("SetClientReady conn " + conn.connectionId + " already ready");
{
Debug.Log("SetClientReady conn " + conn.connectionId + " already ready");
}
} }
else else
{ {
if (conn.PlayerControllers.Count == 0) 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; conn.isReady = true;
if (conn is QSBULocalConnectionToClient ulocalConnectionToClient) if (conn is QSBULocalConnectionToClient ulocalConnectionToClient)
@ -1012,16 +958,13 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"Spawning ", "Spawning ",
objects.Count, objects.Count,
" objects for conn ", " objects for conn ",
conn.connectionId conn.connectionId
})); }));
}
var objectSpawnFinishedMessage = new QSBObjectSpawnFinishedMessage var objectSpawnFinishedMessage = new QSBObjectSpawnFinishedMessage
{ {
State = 0U State = 0U
@ -1031,23 +974,17 @@ namespace QuantumUNET
{ {
if (networkIdentity2 == null) 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) 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='", "Sending spawn message for current server objects name='",
networkIdentity2.gameObject.name, networkIdentity2.gameObject.name,
"' netId=", "' netId=",
networkIdentity2.NetId networkIdentity2.NetId
})); }));
}
var flag2 = networkIdentity2.OnCheckObserver(conn); var flag2 = networkIdentity2.OnCheckObserver(conn);
if (flag2) if (flag2)
{ {
@ -1095,10 +1032,7 @@ namespace QuantumUNET
{ {
if (conn.isReady) if (conn.isReady)
{ {
if (LogFilter.logDebug) Debug.Log("PlayerNotReady " + conn);
{
Debug.Log("PlayerNotReady " + conn);
}
conn.isReady = false; conn.isReady = false;
conn.RemoveObservers(); conn.RemoveObservers();
var msg = new QSBNotReadyMessage(); var msg = new QSBNotReadyMessage();
@ -1108,10 +1042,7 @@ namespace QuantumUNET
private static void OnClientReadyMessage(QSBNetworkMessage netMsg) 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); SetClientReady(netMsg.Connection);
} }
@ -1124,7 +1055,7 @@ namespace QuantumUNET
netMsg.Connection.RemovePlayerController(s_RemovePlayerMessage.PlayerControllerId); netMsg.Connection.RemovePlayerController(s_RemovePlayerMessage.PlayerControllerId);
Destroy(playerController.Gameobject); Destroy(playerController.Gameobject);
} }
else if (LogFilter.logError) else
{ {
Debug.LogError("Received remove player message but could not find the player ID: " + s_RemovePlayerMessage.PlayerControllerId); 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); var gameObject = FindLocalObject(networkInstanceId);
if (gameObject == null) 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 else
{ {
var component = gameObject.GetComponent<QSBNetworkIdentity>(); var component = gameObject.GetComponent<QSBNetworkIdentity>();
if (component == null) 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 else
{ {
@ -1168,10 +1093,7 @@ namespace QuantumUNET
{ {
if (component.ClientAuthorityOwner != netMsg.Connection) 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; return;
} }
} }
@ -1269,10 +1191,7 @@ namespace QuantumUNET
{ {
if (conn.PlayerControllers.Count == 0) 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 else
{ {
@ -1332,10 +1251,7 @@ namespace QuantumUNET
private static void DestroyObject(QSBNetworkIdentity uv, bool destroyServerObject) 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)) if (objects.ContainsKey(uv.NetId))
{ {
objects.Remove(uv.NetId); objects.Remove(uv.NetId);
@ -1484,16 +1400,13 @@ namespace QuantumUNET
} }
else 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=", "Local invoke: Failed to find local connection to invoke handler on [connectionId=",
conn.connectionId, conn.connectionId,
"] for MsgId:", "] for MsgId:",
msgType msgType
})); }));
}
result = false; result = false;
} }
return result; return result;
@ -1517,16 +1430,13 @@ namespace QuantumUNET
{ {
if (ValidateSceneObject(networkIdentity)) if (ValidateSceneObject(networkIdentity))
{ {
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"SpawnObjects sceneId:", "SpawnObjects sceneId:",
networkIdentity.SceneId, networkIdentity.SceneId,
" name:", " name:",
networkIdentity.gameObject.name networkIdentity.gameObject.name
})); }));
}
networkIdentity.Reset(); networkIdentity.Reset();
networkIdentity.gameObject.SetActive(true); networkIdentity.gameObject.SetActive(true);
} }

View File

@ -51,10 +51,7 @@ namespace QuantumUNET
connectionConfig.AddChannel(QosType.Unreliable); connectionConfig.AddChannel(QosType.Unreliable);
hostTopology = new HostTopology(connectionConfig, 8); hostTopology = new HostTopology(connectionConfig, 8);
} }
if (LogFilter.logDebug) Debug.Log("NetworkServerSimple initialize.");
{
Debug.Log("NetworkServerSimple initialize.");
}
} }
} }
@ -89,16 +86,13 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log(string.Concat(new object[]
{ {
Debug.Log(string.Concat(new object[]
{
"NetworkServerSimple listen: ", "NetworkServerSimple listen: ",
ipAddress, ipAddress,
":", ":",
listenPort listenPort
})); }));
}
result = true; result = true;
} }
return result; return result;
@ -126,10 +120,7 @@ namespace QuantumUNET
} }
else else
{ {
if (LogFilter.logDebug) Debug.Log("NetworkServerSimple listen " + listenPort);
{
Debug.Log("NetworkServerSimple listen " + listenPort);
}
result = true; result = true;
} }
return result; return result;
@ -139,25 +130,16 @@ namespace QuantumUNET
{ {
Initialize(); Initialize();
serverHostId = NetworkTransport.AddHost(hostTopology, listenPort); serverHostId = NetworkTransport.AddHost(hostTopology, listenPort);
if (LogFilter.logDebug) Debug.Log("Server Host Slot Id: " + serverHostId);
{
Debug.Log("Server Host Slot Id: " + serverHostId);
}
Update(); Update();
NetworkTransport.ConnectAsNetworkHost(serverHostId, relayIp, relayPort, netGuid, sourceId, nodeId, out var b); NetworkTransport.ConnectAsNetworkHost(serverHostId, relayIp, relayPort, netGuid, sourceId, nodeId, out var b);
m_RelaySlotId = 0; m_RelaySlotId = 0;
if (LogFilter.logDebug) Debug.Log("Relay Slot Id: " + m_RelaySlotId);
{
Debug.Log("Relay Slot Id: " + m_RelaySlotId);
}
} }
public void Stop() public void Stop()
{ {
if (LogFilter.logDebug) Debug.Log("NetworkServerSimple stop ");
{
Debug.Log("NetworkServerSimple stop ");
}
NetworkTransport.RemoveHost(serverHostId); NetworkTransport.RemoveHost(serverHostId);
serverHostId = -1; serverHostId = -1;
} }
@ -192,24 +174,15 @@ namespace QuantumUNET
networkEventType = NetworkTransport.ReceiveRelayEventFromHost(serverHostId, out var b); networkEventType = NetworkTransport.ReceiveRelayEventFromHost(serverHostId, out var b);
if (networkEventType != NetworkEventType.Nothing) if (networkEventType != NetworkEventType.Nothing)
{ {
if (LogFilter.logDebug) Debug.Log("NetGroup event:" + networkEventType);
{
Debug.Log("NetGroup event:" + networkEventType);
}
} }
if (networkEventType == NetworkEventType.ConnectEvent) if (networkEventType == NetworkEventType.ConnectEvent)
{ {
if (LogFilter.logDebug) Debug.Log("NetGroup server connected");
{
Debug.Log("NetGroup server connected");
}
} }
if (networkEventType == NetworkEventType.DisconnectEvent) if (networkEventType == NetworkEventType.DisconnectEvent)
{ {
if (LogFilter.logDebug) Debug.Log("NetGroup server disconnected");
{
Debug.Log("NetGroup server disconnected");
}
} }
} }
do do
@ -245,10 +218,7 @@ namespace QuantumUNET
break; break;
default: default:
if (LogFilter.logError) Debug.LogError("Unknown network message type received: " + networkEventType);
{
Debug.LogError("Unknown network message type received: " + networkEventType);
}
break; break;
} }
} }
@ -308,10 +278,7 @@ namespace QuantumUNET
private void HandleConnect(int connectionId, byte error) 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) if (error != 0)
{ {
OnConnectError(connectionId, error); OnConnectError(connectionId, error);
@ -334,10 +301,7 @@ namespace QuantumUNET
private void HandleDisconnect(int connectionId, byte error) 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); var networkConnection = FindConnection(connectionId);
if (networkConnection != null) if (networkConnection != null)
{ {
@ -347,26 +311,20 @@ namespace QuantumUNET
if (error != 6) if (error != 6)
{ {
m_Connections[connectionId] = null; m_Connections[connectionId] = null;
if (LogFilter.logError) Debug.LogError(string.Concat(new object[]
{ {
Debug.LogError(string.Concat(new object[]
{
"Server client disconnect error, connectionId: ", "Server client disconnect error, connectionId: ",
connectionId, connectionId,
" error: ", " error: ",
(NetworkError)error (NetworkError)error
})); }));
}
OnDisconnectError(networkConnection, error); OnDisconnectError(networkConnection, error);
return; return;
} }
} }
networkConnection.Disconnect(); networkConnection.Disconnect();
m_Connections[connectionId] = null; m_Connections[connectionId] = null;
if (LogFilter.logDebug) Debug.Log("Server lost client:" + connectionId);
{
Debug.Log("Server lost client:" + connectionId);
}
OnDisconnected(networkConnection); OnDisconnected(networkConnection);
} }
} }
@ -376,10 +334,7 @@ namespace QuantumUNET
var networkConnection = FindConnection(connectionId); var networkConnection = FindConnection(connectionId);
if (networkConnection == null) if (networkConnection == null)
{ {
if (LogFilter.logError) Debug.LogError("HandleData Unknown connectionId:" + connectionId);
{
Debug.LogError("HandleData Unknown connectionId:" + connectionId);
}
} }
else else
{ {

View File

@ -1,7 +1,6 @@
using QuantumUNET.Messages; using QuantumUNET.Messages;
using QuantumUNET.Transport; using QuantumUNET.Transport;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking;
namespace QuantumUNET namespace QuantumUNET
{ {
@ -27,10 +26,7 @@ namespace QuantumUNET
bool result; bool result;
if (numBytes <= 0) if (numBytes <= 0)
{ {
if (LogFilter.logError) Debug.LogError("LocalConnection:SendBytes cannot send zero bytes");
{
Debug.LogError("LocalConnection:SendBytes cannot send zero bytes");
}
result = false; result = false;
} }
else else

View File

@ -398,10 +398,7 @@ namespace QuantumUNET.Transport
var gameObject = QSBClientScene.FindLocalObject(networkInstanceId); var gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
if (gameObject == null) if (gameObject == null)
{ {
if (LogFilter.logDebug) Debug.Log("ReadTransform netId:" + networkInstanceId);
{
Debug.Log("ReadTransform netId:" + networkInstanceId);
}
result = null; result = null;
} }
else else
@ -433,10 +430,7 @@ namespace QuantumUNET.Transport
} }
if (gameObject == null) if (gameObject == null)
{ {
if (LogFilter.logDebug) Debug.Log("ReadGameObject netId:" + networkInstanceId + "go: null");
{
Debug.Log("ReadGameObject netId:" + networkInstanceId + "go: null");
}
} }
result = gameObject; result = gameObject;
} }
@ -464,10 +458,7 @@ namespace QuantumUNET.Transport
} }
if (gameObject == null) if (gameObject == null)
{ {
if (LogFilter.logDebug) Debug.Log("ReadNetworkIdentity netId:" + networkInstanceId + "go: null");
{
Debug.Log("ReadNetworkIdentity netId:" + networkInstanceId + "go: null");
}
result = null; result = null;
} }
else else

View File

@ -222,10 +222,7 @@ namespace QuantumUNET.Transport
{ {
if (count > 65535) 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 else
{ {
@ -237,10 +234,7 @@ namespace QuantumUNET.Transport
{ {
if (count > 65535) 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 else
{ {
@ -256,10 +250,7 @@ namespace QuantumUNET.Transport
} }
else if (count > 65535) 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 else
{ {
@ -276,10 +267,7 @@ namespace QuantumUNET.Transport
} }
else if (buffer.Length > 65535) 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 else
{ {
@ -420,10 +408,7 @@ namespace QuantumUNET.Transport
} }
else else
{ {
if (LogFilter.logWarn) Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
{
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
}
WritePackedUInt32(0U); WritePackedUInt32(0U);
} }
} }
@ -444,10 +429,7 @@ namespace QuantumUNET.Transport
} }
else else
{ {
if (LogFilter.logWarn) Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
{
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
}
WritePackedUInt32(0U); WritePackedUInt32(0U);
} }
} }