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()
|
||||
|
@ -44,19 +44,13 @@ namespace QuantumUNET
|
||||
player = null;
|
||||
bool result;
|
||||
if (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
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);
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -68,17 +62,11 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
internal static void InternalAddPlayer(QSBNetworkIdentity view, short playerControllerId)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::InternalAddPlayer: playerControllerId : " + playerControllerId);
|
||||
}
|
||||
if (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::InternalAddPlayer: playerControllerId higher than expected: " + playerControllerId);
|
||||
}
|
||||
while (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
localPlayers.Add(new QSBPlayerController());
|
||||
@ -120,12 +108,9 @@ namespace QuantumUNET
|
||||
else
|
||||
{
|
||||
if (playerControllerId > 16)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientScene::AddPlayer: playerControllerId of " + playerControllerId + " is unusually high");
|
||||
}
|
||||
}
|
||||
while (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
localPlayers.Add(new QSBPlayerController());
|
||||
@ -133,11 +118,8 @@ namespace QuantumUNET
|
||||
if (readyConn == null)
|
||||
{
|
||||
if (!ready)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Must call AddPlayer() with a connection the first time to become ready.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -149,16 +131,11 @@ namespace QuantumUNET
|
||||
if (readyConnection.GetPlayerController(playerControllerId, out var playerController))
|
||||
{
|
||||
if (playerController.IsValid && playerController.Gameobject != null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("ClientScene::AddPlayer: playerControllerId of " + playerControllerId + " already in use.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::AddPlayer() for ID ",
|
||||
@ -167,7 +144,6 @@ namespace QuantumUNET
|
||||
readyConnection,
|
||||
"]"
|
||||
}));
|
||||
}
|
||||
var addPlayerMessage = new QSBAddPlayerMessage
|
||||
{
|
||||
playerControllerId = playerControllerId
|
||||
@ -186,8 +162,6 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
public static bool RemovePlayer(short playerControllerId)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -197,7 +171,6 @@ namespace QuantumUNET
|
||||
readyConnection,
|
||||
"]"
|
||||
}));
|
||||
}
|
||||
bool result;
|
||||
if (readyConnection.GetPlayerController(playerControllerId, out var playerController))
|
||||
{
|
||||
@ -212,11 +185,8 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Failed to find player ID " + playerControllerId);
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -226,19 +196,13 @@ namespace QuantumUNET
|
||||
{
|
||||
bool result;
|
||||
if (ready)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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 + "]");
|
||||
}
|
||||
if (conn != null)
|
||||
{
|
||||
var msg = new QSBReadyMessage();
|
||||
@ -249,11 +213,8 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Ready() called with invalid connection object: conn=null");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
@ -299,15 +260,12 @@ namespace QuantumUNET
|
||||
if (!networkIdentity.SceneId.IsEmpty())
|
||||
{
|
||||
SpawnableObjects[networkIdentity.SceneId] = networkIdentity;
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ClientScene::PrepareSpawnObjects sceneId:" + networkIdentity.SceneId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static QSBNetworkIdentity SpawnSceneObject(NetworkSceneId sceneId)
|
||||
{
|
||||
@ -490,15 +448,10 @@ 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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -509,7 +462,6 @@ namespace QuantumUNET
|
||||
"] 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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,8 +570,6 @@ namespace QuantumUNET
|
||||
{
|
||||
var num = (int)netMsg.Reader.ReadPackedUInt32();
|
||||
var networkInstanceId = netMsg.Reader.ReadNetworkId();
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::OnRPCMessage hash:",
|
||||
@ -639,12 +577,11 @@ namespace QuantumUNET
|
||||
" 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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,8 +625,6 @@ namespace QuantumUNET
|
||||
private static void OnClientAuthority(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBClientAuthorityMessage>(s_ClientAuthorityMessage);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::OnClientAuthority for connectionId=",
|
||||
@ -703,7 +632,6 @@ namespace QuantumUNET
|
||||
" netId: ",
|
||||
s_ClientAuthorityMessage.netId
|
||||
}));
|
||||
}
|
||||
if (s_NetworkScene.GetNetworkIdentity(s_ClientAuthorityMessage.netId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.HandleClientAuthority(s_ClientAuthorityMessage.authority);
|
||||
@ -713,8 +641,6 @@ namespace QuantumUNET
|
||||
private static void OnOwnerMessage(QSBNetworkMessage netMsg)
|
||||
{
|
||||
netMsg.ReadMessage<QSBOwnerMessage>(s_OwnerMessage);
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
"ClientScene::OnOwnerMessage - connectionId=",
|
||||
@ -722,7 +648,6 @@ namespace QuantumUNET
|
||||
" netId: ",
|
||||
s_OwnerMessage.NetId
|
||||
}));
|
||||
}
|
||||
if (netMsg.Connection.GetPlayerController(s_OwnerMessage.PlayerControllerId, out var playerController))
|
||||
{
|
||||
playerController.UnetView.SetNotLocalPlayer();
|
||||
@ -756,11 +681,8 @@ namespace QuantumUNET
|
||||
uv.SetLocalPlayer(pendingOwner.playerControllerId);
|
||||
Debug.Log("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name);
|
||||
if (readyConnection.connectionId < 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Owner message received on a local client.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
InternalAddPlayer(uv, pendingOwner.playerControllerId);
|
||||
|
@ -70,13 +70,10 @@ namespace QuantumUNET
|
||||
protected void SendRPCInternal(QSBNetworkWriter writer, int channelId, string rpcName)
|
||||
{
|
||||
if (!IsServer)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("ClientRpc call on un-spawned object");
|
||||
return;
|
||||
}
|
||||
}
|
||||
writer.FinishMessage();
|
||||
QSBNetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
}
|
||||
@ -417,14 +414,11 @@ 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?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NetworkInstanceId networkInstanceId2 = default;
|
||||
if (gameObjectField != null)
|
||||
{
|
||||
|
@ -93,24 +93,16 @@ namespace QuantumUNET
|
||||
{
|
||||
bool result;
|
||||
if (!active)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - NetworkClient must be active");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else if (m_Connection == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - no old connection exists");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logInfo)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -119,7 +111,6 @@ namespace QuantumUNET
|
||||
":",
|
||||
serverPort
|
||||
}));
|
||||
}
|
||||
QSBClientScene.HandleClientDisconnect(m_Connection);
|
||||
QSBClientScene.ClearLocalPlayers();
|
||||
m_Connection.Disconnect();
|
||||
@ -137,11 +128,8 @@ namespace QuantumUNET
|
||||
m_AsyncConnect = ConnectState.Resolved;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Async DNS START:" + serverIp);
|
||||
}
|
||||
m_AsyncConnect = ConnectState.Resolving;
|
||||
Dns.BeginGetHostAddresses(serverIp, new AsyncCallback(GetHostAddressesCallback), this);
|
||||
}
|
||||
@ -154,47 +142,32 @@ namespace QuantumUNET
|
||||
{
|
||||
bool result;
|
||||
if (!active)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - NetworkClient must be active");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else if (m_Connection == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Reconnect - no old connection exists");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logInfo)
|
||||
{
|
||||
Debug.Log("NetworkClient Reconnect to remoteSockAddr");
|
||||
}
|
||||
QSBClientScene.HandleClientDisconnect(m_Connection);
|
||||
QSBClientScene.ClearLocalPlayers();
|
||||
m_Connection.Disconnect();
|
||||
m_Connection = null;
|
||||
hostId = NetworkTransport.AddHost(hostTopology, m_HostPort);
|
||||
if (secureTunnelEndPoint == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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");
|
||||
}
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
result = false;
|
||||
}
|
||||
@ -208,11 +181,8 @@ namespace QuantumUNET
|
||||
result = (m_AsyncConnect != ConnectState.Failed);
|
||||
}
|
||||
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)");
|
||||
}
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
result = false;
|
||||
}
|
||||
@ -226,20 +196,14 @@ namespace QuantumUNET
|
||||
m_ClientConnectionId = NetworkTransport.ConnectEndPoint(hostId, m_RemoteEndPoint, 0, out b);
|
||||
}
|
||||
catch (Exception arg)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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 + ")");
|
||||
}
|
||||
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");
|
||||
}
|
||||
if (secureTunnelEndPoint == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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");
|
||||
}
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else
|
||||
@ -345,11 +300,8 @@ namespace QuantumUNET
|
||||
Connect(ipendPoint.Address.ToString(), ipendPoint.Port);
|
||||
}
|
||||
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)");
|
||||
}
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else
|
||||
@ -362,20 +314,14 @@ namespace QuantumUNET
|
||||
m_ClientConnectionId = NetworkTransport.ConnectEndPoint(hostId, m_RemoteEndPoint, 0, out b);
|
||||
}
|
||||
catch (Exception arg)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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 + ")");
|
||||
}
|
||||
m_AsyncConnect = ConnectState.Failed;
|
||||
}
|
||||
else
|
||||
@ -511,11 +457,8 @@ namespace QuantumUNET
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient Send when not connected to a server");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -524,11 +467,8 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient Send with no connection");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -540,11 +480,8 @@ namespace QuantumUNET
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendWriter when not connected to a server");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -553,11 +490,8 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendWriter with no connection");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -569,11 +503,8 @@ namespace QuantumUNET
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendBytes when not connected to a server");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -582,11 +513,8 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendBytes with no connection");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -598,11 +526,8 @@ namespace QuantumUNET
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendUnreliable when not connected to a server");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -611,11 +536,8 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendUnreliable with no connection");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -627,11 +549,8 @@ namespace QuantumUNET
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendByChannel when not connected to a server");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -640,11 +559,8 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkClient SendByChannel with no connection");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -653,12 +569,9 @@ namespace QuantumUNET
|
||||
public void SetMaxDelay(float seconds)
|
||||
{
|
||||
if (m_Connection == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("SetMaxDelay failed, not connected.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Connection.SetMaxDelay(seconds);
|
||||
@ -666,11 +579,8 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
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");
|
||||
}
|
||||
if (b != 0)
|
||||
{
|
||||
goto Block_10;
|
||||
@ -746,10 +651,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
|
||||
case NetworkEventType.DisconnectEvent:
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (++num >= 500)
|
||||
@ -795,10 +694,7 @@ namespace QuantumUNET
|
||||
GenerateDataError(b);
|
||||
return;
|
||||
Block_17:
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("MaxEventsPerFrame hit (" + 500 + ")");
|
||||
}
|
||||
Block_19:
|
||||
IL_2C6:
|
||||
if (m_Connection != null && m_AsyncConnect == ConnectState.Connected)
|
||||
@ -809,29 +705,20 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
private void GenerateConnectError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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);
|
||||
}
|
||||
GenerateError(error);
|
||||
}
|
||||
|
||||
private void GenerateDisconnectError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("UNet Client Disconnect Error: " + (NetworkError)error);
|
||||
}
|
||||
GenerateError(error);
|
||||
}
|
||||
|
||||
|
@ -199,12 +199,9 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("RemovePlayer player at playerControllerId " + playerControllerId + " not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool GetPlayerController(short playerControllerId, out QSBPlayerController playerController)
|
||||
{
|
||||
@ -298,16 +295,11 @@ namespace QuantumUNET
|
||||
{
|
||||
bool result;
|
||||
if (m_Channels == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
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[]
|
||||
{
|
||||
@ -316,7 +308,6 @@ namespace QuantumUNET
|
||||
"'. 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");
|
||||
}
|
||||
@ -114,14 +114,11 @@ namespace QuantumUNET
|
||||
guidToPrefab[component.AssetId] = prefab;
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (LogFilter.logError)
|
||||
else
|
||||
{
|
||||
Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
|
||||
}
|
||||
@ -164,12 +161,9 @@ namespace QuantumUNET
|
||||
internal static void RegisterSpawnHandler(NetworkHash128 assetId, QSBSpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
|
||||
{
|
||||
if (spawnHandler == null || unspawnHandler == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("RegisterSpawnHandler custom spawn function null for " + assetId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnHandlers[assetId] = spawnHandler;
|
||||
@ -181,12 +175,9 @@ 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");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnHandlers.Remove(component.AssetId);
|
||||
|
@ -595,17 +595,11 @@ namespace QuantumUNET
|
||||
for (var i = 0; i < conn.PlayerControllers.Count; i++)
|
||||
{
|
||||
if (conn.PlayerControllers[i].Gameobject != null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Player not destroyed when connection disconnected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Server lost client:" + conn.connectionId);
|
||||
}
|
||||
conn.RemoveObservers();
|
||||
conn.Dispose();
|
||||
}
|
||||
@ -613,26 +607,18 @@ namespace QuantumUNET
|
||||
private void OnData(QSBNetworkConnection conn, int receivedSize, int channelId) => conn.TransportReceive(m_SimpleServerSimple.messageBuffer, receivedSize, channelId);
|
||||
|
||||
private void GenerateConnectError(int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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);
|
||||
}
|
||||
GenerateError(conn, error);
|
||||
}
|
||||
|
||||
private void GenerateDisconnectError(QSBNetworkConnection conn, int error)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
@ -643,7 +629,6 @@ namespace QuantumUNET
|
||||
"]:",
|
||||
conn.connectionId
|
||||
}));
|
||||
}
|
||||
GenerateError(conn, error);
|
||||
}
|
||||
|
||||
@ -723,12 +708,9 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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,11 +723,8 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
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);
|
||||
|
||||
@ -753,11 +732,8 @@ 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);
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -775,11 +751,8 @@ namespace QuantumUNET
|
||||
x = playerController.Gameobject;
|
||||
}
|
||||
if (x != null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.Log("AddPlayer: player object already exists for playerControllerId of " + playerControllerId);
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
@ -793,8 +766,6 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -803,7 +774,6 @@ namespace QuantumUNET
|
||||
" asset ID ",
|
||||
playerGameObject.GetComponent<QSBNetworkIdentity>().AssetId
|
||||
}));
|
||||
}
|
||||
FinishPlayerForConnection(conn, networkIdentity, playerGameObject);
|
||||
if (networkIdentity.LocalPlayerAuthority)
|
||||
{
|
||||
@ -821,16 +791,11 @@ namespace QuantumUNET
|
||||
{
|
||||
bool result;
|
||||
if (playerControllerId < 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("AddPlayer: playerControllerId of " + playerControllerId + " is negative");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else if (playerControllerId > 32)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -839,18 +804,14 @@ namespace QuantumUNET
|
||||
" is too high. max is ",
|
||||
32
|
||||
}));
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerControllerId > 16)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("AddPlayer: playerControllerId of " + playerControllerId + " is unusually high");
|
||||
}
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
@ -899,11 +860,8 @@ 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);
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
|
||||
@ -927,8 +885,6 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -937,7 +893,6 @@ namespace QuantumUNET
|
||||
" asset ID ",
|
||||
playerGameObject.GetComponent<NetworkIdentity>().assetId
|
||||
}));
|
||||
}
|
||||
FinishPlayerForConnection(conn, networkIdentity, playerGameObject);
|
||||
if (networkIdentity.LocalPlayerAuthority)
|
||||
{
|
||||
@ -968,27 +923,18 @@ namespace QuantumUNET
|
||||
public static void SetClientReady(QSBNetworkConnection conn) => instance.SetClientReadyInternal(conn);
|
||||
|
||||
internal void SetClientReadyInternal(QSBNetworkConnection conn)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("SetClientReadyInternal for conn:" + conn.connectionId);
|
||||
}
|
||||
if (conn.isReady)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("SetClientReady conn " + conn.connectionId + " already ready");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conn.PlayerControllers.Count == 0)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.LogWarning("Ready with no player object");
|
||||
}
|
||||
}
|
||||
conn.isReady = true;
|
||||
if (conn is QSBULocalConnectionToClient ulocalConnectionToClient)
|
||||
{
|
||||
@ -1011,8 +957,6 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -1021,7 +965,6 @@ namespace QuantumUNET
|
||||
" objects for conn ",
|
||||
conn.connectionId
|
||||
}));
|
||||
}
|
||||
var objectSpawnFinishedMessage = new QSBObjectSpawnFinishedMessage
|
||||
{
|
||||
State = 0U
|
||||
@ -1030,15 +973,10 @@ namespace QuantumUNET
|
||||
foreach (var networkIdentity2 in objects.Values)
|
||||
{
|
||||
if (networkIdentity2 == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
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[]
|
||||
{
|
||||
@ -1047,7 +985,6 @@ namespace QuantumUNET
|
||||
"' netId=",
|
||||
networkIdentity2.NetId
|
||||
}));
|
||||
}
|
||||
var flag2 = networkIdentity2.OnCheckObserver(conn);
|
||||
if (flag2)
|
||||
{
|
||||
@ -1094,11 +1031,8 @@ namespace QuantumUNET
|
||||
internal void InternalSetClientNotReady(QSBNetworkConnection conn)
|
||||
{
|
||||
if (conn.isReady)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("PlayerNotReady " + conn);
|
||||
}
|
||||
conn.isReady = false;
|
||||
conn.RemoveObservers();
|
||||
var msg = new QSBNotReadyMessage();
|
||||
@ -1107,11 +1041,8 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
private static void OnClientReadyMessage(QSBNetworkMessage netMsg)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -1136,22 +1067,16 @@ namespace QuantumUNET
|
||||
var networkInstanceId = netMsg.Reader.ReadNetworkId();
|
||||
var gameObject = FindLocalObject(networkInstanceId);
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
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 + "]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag = false;
|
||||
@ -1167,11 +1092,8 @@ namespace QuantumUNET
|
||||
if (!flag)
|
||||
{
|
||||
if (component.ClientAuthorityOwner != netMsg.Connection)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Command for object without authority [netId=" + networkInstanceId + "]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1268,12 +1190,9 @@ namespace QuantumUNET
|
||||
public static void DestroyPlayersForConnection(QSBNetworkConnection conn)
|
||||
{
|
||||
if (conn.PlayerControllers.Count == 0)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conn.ClientOwnedObjects != null)
|
||||
@ -1331,11 +1250,8 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
private static void DestroyObject(QSBNetworkIdentity uv, bool destroyServerObject)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("DestroyObject instance:" + uv.NetId);
|
||||
}
|
||||
if (objects.ContainsKey(uv.NetId))
|
||||
{
|
||||
objects.Remove(uv.NetId);
|
||||
@ -1483,8 +1399,6 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
@ -1493,7 +1407,6 @@ namespace QuantumUNET
|
||||
"] for MsgId:",
|
||||
msgType
|
||||
}));
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@ -1516,8 +1429,6 @@ namespace QuantumUNET
|
||||
foreach (var networkIdentity in objectsOfTypeAll)
|
||||
{
|
||||
if (ValidateSceneObject(networkIdentity))
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -1526,7 +1437,6 @@ namespace QuantumUNET
|
||||
" name:",
|
||||
networkIdentity.gameObject.name
|
||||
}));
|
||||
}
|
||||
networkIdentity.Reset();
|
||||
networkIdentity.gameObject.SetActive(true);
|
||||
}
|
||||
|
@ -51,12 +51,9 @@ namespace QuantumUNET
|
||||
connectionConfig.AddChannel(QosType.Unreliable);
|
||||
hostTopology = new HostTopology(connectionConfig, 8);
|
||||
}
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple initialize.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Configure(ConnectionConfig config, int maxConnections)
|
||||
{
|
||||
@ -88,8 +85,6 @@ namespace QuantumUNET
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
{
|
||||
@ -98,7 +93,6 @@ namespace QuantumUNET
|
||||
":",
|
||||
listenPort
|
||||
}));
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
@ -125,11 +119,8 @@ namespace QuantumUNET
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple stop ");
|
||||
}
|
||||
NetworkTransport.RemoveHost(serverHostId);
|
||||
serverHostId = -1;
|
||||
}
|
||||
@ -191,27 +173,18 @@ namespace QuantumUNET
|
||||
{
|
||||
networkEventType = NetworkTransport.ReceiveRelayEventFromHost(serverHostId, out var b);
|
||||
if (networkEventType != NetworkEventType.Nothing)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetGroup event:" + networkEventType);
|
||||
}
|
||||
}
|
||||
if (networkEventType == NetworkEventType.ConnectEvent)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetGroup server connected");
|
||||
}
|
||||
}
|
||||
if (networkEventType == NetworkEventType.DisconnectEvent)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetGroup server disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
do
|
||||
{
|
||||
networkEventType = NetworkTransport.ReceiveFromHost(serverHostId, out var connectionId, out var channelId, messageBuffer, messageBuffer.Length, out var receivedSize, out var b);
|
||||
@ -245,10 +218,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
|
||||
default:
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("Unknown network message type received: " + networkEventType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -307,11 +277,8 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
private void HandleConnect(int connectionId, byte error)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple accepted client:" + connectionId);
|
||||
}
|
||||
if (error != 0)
|
||||
{
|
||||
OnConnectError(connectionId, error);
|
||||
@ -333,11 +300,8 @@ namespace QuantumUNET
|
||||
}
|
||||
|
||||
private void HandleDisconnect(int connectionId, byte error)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("NetworkServerSimple disconnect client:" + connectionId);
|
||||
}
|
||||
var networkConnection = FindConnection(connectionId);
|
||||
if (networkConnection != null)
|
||||
{
|
||||
@ -347,8 +311,6 @@ namespace QuantumUNET
|
||||
if (error != 6)
|
||||
{
|
||||
m_Connections[connectionId] = null;
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError(string.Concat(new object[]
|
||||
{
|
||||
"Server client disconnect error, connectionId: ",
|
||||
@ -356,17 +318,13 @@ namespace QuantumUNET
|
||||
" error: ",
|
||||
(NetworkError)error
|
||||
}));
|
||||
}
|
||||
OnDisconnectError(networkConnection, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
networkConnection.Disconnect();
|
||||
m_Connections[connectionId] = null;
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("Server lost client:" + connectionId);
|
||||
}
|
||||
OnDisconnected(networkConnection);
|
||||
}
|
||||
}
|
||||
@ -375,12 +333,9 @@ namespace QuantumUNET
|
||||
{
|
||||
var networkConnection = FindConnection(connectionId);
|
||||
if (networkConnection == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("HandleData Unknown connectionId:" + connectionId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
networkConnection.LastError = (NetworkError)error;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using QuantumUNET.Messages;
|
||||
using QuantumUNET.Transport;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace QuantumUNET
|
||||
{
|
||||
@ -26,11 +25,8 @@ namespace QuantumUNET
|
||||
{
|
||||
bool result;
|
||||
if (numBytes <= 0)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("LocalConnection:SendBytes cannot send zero bytes");
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
|
@ -397,11 +397,8 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
var gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ReadTransform netId:" + networkInstanceId);
|
||||
}
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
@ -432,12 +429,9 @@ namespace QuantumUNET.Transport
|
||||
gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
|
||||
}
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ReadGameObject netId:" + networkInstanceId + "go: null");
|
||||
}
|
||||
}
|
||||
result = gameObject;
|
||||
}
|
||||
return result;
|
||||
@ -463,11 +457,8 @@ namespace QuantumUNET.Transport
|
||||
gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
|
||||
}
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
{
|
||||
Debug.Log("ReadNetworkIdentity netId:" + networkInstanceId + "go: null");
|
||||
}
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
|
@ -221,12 +221,9 @@ namespace QuantumUNET.Transport
|
||||
public void Write(byte[] buffer, int count)
|
||||
{
|
||||
if (count > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Buffer.WriteBytes(buffer, (ushort)count);
|
||||
@ -236,12 +233,9 @@ namespace QuantumUNET.Transport
|
||||
public void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (count > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Buffer.WriteBytesAtOffset(buffer, (ushort)offset, (ushort)count);
|
||||
@ -255,12 +249,9 @@ namespace QuantumUNET.Transport
|
||||
Write(0);
|
||||
}
|
||||
else if (count > 65535)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
Debug.LogError("NetworkWriter WriteBytesAndSize: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write((ushort)count);
|
||||
@ -275,12 +266,9 @@ namespace QuantumUNET.Transport
|
||||
Write(0);
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write((ushort)buffer.Length);
|
||||
@ -419,11 +407,8 @@ namespace QuantumUNET.Transport
|
||||
Write(component.NetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
|
||||
}
|
||||
WritePackedUInt32(0U);
|
||||
}
|
||||
}
|
||||
@ -443,11 +428,8 @@ namespace QuantumUNET.Transport
|
||||
Write(component.NetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
{
|
||||
Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity");
|
||||
}
|
||||
WritePackedUInt32(0U);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user