mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
String interpolation (#2930)
* Use String Interpolation * Update Assets/Mirror/Editor/Weaver/EntryPointILPostProcessor/ILPostProcessorFromFile.cs * Proper case in comments * Add a constructor overload for creating a SyncDictionary from an IDictionary (#2933) * Add a constructor overload for creating SyncDictionary from Dictionary * Use IDictionary and directly use the passed in value * Use passed in value directly * Nope: SyncDictionary should specifically use a Dictionary under the hood Reread the docs * comment * syntax * Weaver: PropertySiteProcessor renamed to SyncVarAccessReplacer and updated comments/syntax to make it easier to understand * Weaver: WeaverLists renamed to SyncVarAccessLists because that's what it's for * comment * Weaver: GetSyncVarStart simplified * comment * fix: Obsolete SyncObject Flush method (#2931) * fix: Obsolete SyncObject Flush method * fixed test Co-authored-by: vis2k <info@noobtuts.com> Co-authored-by: Gabriel Elkind <pixelpax@users.noreply.github.com>
This commit is contained in:
parent
185a6c3815
commit
9cab21921f
@ -67,7 +67,7 @@ void OnLog(string message, string stackTrace, LogType type)
|
||||
// seeing it in the console directly is way easier to deal with.)
|
||||
// => only add \n if stack trace is available (only in debug builds)
|
||||
if (isImportant && !string.IsNullOrWhiteSpace(stackTrace))
|
||||
message += "\n" + stackTrace;
|
||||
message += $"\n{stackTrace}";
|
||||
|
||||
// add to queue
|
||||
log.Enqueue(new LogEntry(message, type));
|
||||
|
@ -524,7 +524,7 @@ void CmdOnAnimationServerMessage(int stateHash, float normalizedTime, int layerI
|
||||
if (!clientAuthority)
|
||||
return;
|
||||
|
||||
// Debug.Log("OnAnimationMessage for netId=" + netId);
|
||||
//Debug.Log($"OnAnimationMessage for netId {netId}");
|
||||
|
||||
// handle and broadcast
|
||||
using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(parameters))
|
||||
|
@ -126,7 +126,7 @@ public static void OnCompilationFinished(string assemblyPath, CompilerMessage[]
|
||||
{
|
||||
// Set false...will be checked in \Editor\EnterPlayModeSettingsCheck.CheckSuccessfulWeave()
|
||||
SessionState.SetBool("MIRROR_WEAVE_SUCCESS", false);
|
||||
if (UnityLogEnabled) Debug.LogError("Weaving failed for: " + assemblyPath);
|
||||
if (UnityLogEnabled) Debug.LogError($"Weaving failed for {assemblyPath}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public static void ILPostProcessFile(string assemblyPath, string[] references, A
|
||||
ILPostProcessorHook ilpp = new ILPostProcessorHook();
|
||||
if (ilpp.WillProcess(assembly))
|
||||
{
|
||||
//Debug.Log("Will Process: " + assembly.Name);
|
||||
//Debug.Log($"Will Process: {assembly.Name}");
|
||||
|
||||
// process it like Unity would
|
||||
ILPostProcessResult result = ilpp.Process(assembly);
|
||||
|
@ -496,7 +496,7 @@ void GenerateSerialization(ref bool WeavingFailed)
|
||||
}
|
||||
|
||||
// add a log message if needed for debugging
|
||||
//worker.Emit(OpCodes.Ldstr, "Injected Serialize " + netBehaviourSubclass.Name);
|
||||
//worker.Emit(OpCodes.Ldstr, $"Injected Serialize {netBehaviourSubclass.Name}");
|
||||
//worker.Emit(OpCodes.Call, WeaverTypes.logErrorReference);
|
||||
|
||||
// generate: return dirtyLocal
|
||||
@ -883,7 +883,7 @@ void GenerateDeSerialization(ref bool WeavingFailed)
|
||||
}
|
||||
|
||||
// add a log message if needed for debugging
|
||||
//serWorker.Append(serWorker.Create(OpCodes.Ldstr, "Injected Deserialize " + netBehaviourSubclass.Name));
|
||||
//serWorker.Append(serWorker.Create(OpCodes.Ldstr, $"Injected Deserialize {netBehaviourSubclass.Name}"));
|
||||
//serWorker.Append(serWorker.Create(OpCodes.Call, WeaverTypes.logErrorReference));
|
||||
|
||||
serWorker.Append(serWorker.Create(OpCodes.Ret));
|
||||
|
@ -65,7 +65,7 @@ public static MethodDefinition ProcessRpcCall(WeaverTypes weaverTypes, Writers w
|
||||
NetworkBehaviourProcessor.WriteSetupLocals(worker, weaverTypes);
|
||||
|
||||
// add a log message if needed for debugging
|
||||
//worker.Emit(OpCodes.Ldstr, "Call ClientRpc function " + md.Name);
|
||||
//worker.Emit(OpCodes.Ldstr, $"Call ClientRpc function {md.Name}");
|
||||
//worker.Emit(OpCodes.Call, WeaverTypes.logErrorReference);
|
||||
|
||||
NetworkBehaviourProcessor.WriteCreateWriter(worker, weaverTypes);
|
||||
|
@ -37,8 +37,8 @@ public Guid GetMatchId()
|
||||
public void SetMatchInfo(MatchInfo infos)
|
||||
{
|
||||
matchId = infos.matchId;
|
||||
matchName.text = "Match " + infos.matchId.ToString().Substring(0, 8);
|
||||
playerCount.text = infos.players + " / " + infos.maxPlayers;
|
||||
matchName.text = $"Match {infos.matchId.ToString().Substring(0, 8)}";
|
||||
playerCount.text = $"{infos.players} / {infos.maxPlayers}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class PlayerGUI : MonoBehaviour
|
||||
|
||||
public void SetPlayerInfo(PlayerInfo info)
|
||||
{
|
||||
playerName.text = "Player " + info.playerIndex;
|
||||
playerName.text = $"Player {info.playerIndex}";
|
||||
playerName.color = info.ready ? Color.green : Color.red;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ internal override void Send(ArraySegment<byte> segment, int channelId = Channels
|
||||
// => pooled writer will be returned to pool when dequeuing.
|
||||
// => WriteBytes instead of WriteArraySegment because the latter
|
||||
// includes a 4 bytes header. we just want to write raw.
|
||||
//Debug.Log("Enqueue " + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));
|
||||
//Debug.Log($"Enqueue {BitConverter.ToString(segment.Array, segment.Offset, segment.Count)}");
|
||||
PooledNetworkWriter writer = NetworkWriterPool.GetWriter();
|
||||
writer.WriteBytes(segment.Array, segment.Offset, segment.Count);
|
||||
connectionToServer.queue.Enqueue(writer);
|
||||
|
@ -356,7 +356,7 @@ protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gam
|
||||
}
|
||||
}
|
||||
|
||||
// Debug.Log("SetSyncVar GameObject " + GetType().Name + " bit [" + dirtyBit + "] netfieldId:" + netIdField + "->" + newNetId);
|
||||
//Debug.Log($"SetSyncVar GameObject {GetType().Name} bit:{dirtyBit} netfieldId:{netIdField} -> {newNetId}");
|
||||
SetSyncVarDirtyBit(dirtyBit);
|
||||
// assign new one on the server, and in case we ever need it on client too
|
||||
gameObjectField = newGameObject;
|
||||
@ -416,7 +416,7 @@ protected void SetSyncVarNetworkIdentity(NetworkIdentity newIdentity, ref Networ
|
||||
}
|
||||
}
|
||||
|
||||
// Debug.Log("SetSyncVarNetworkIdentity NetworkIdentity " + GetType().Name + " bit [" + dirtyBit + "] netIdField:" + netIdField + "->" + newNetId);
|
||||
//Debug.Log($"SetSyncVarNetworkIdentity NetworkIdentity {GetType().Name} bit:{dirtyBit} netIdField:{netIdField} -> {newNetId}");
|
||||
SetSyncVarDirtyBit(dirtyBit);
|
||||
netIdField = newNetId;
|
||||
// assign new one on the server, and in case we ever need it on client too
|
||||
@ -545,7 +545,7 @@ protected bool SyncVarEqual<T>(T value, ref T fieldValue)
|
||||
// dirtyBit is a mask like 00010
|
||||
protected void SetSyncVar<T>(T value, ref T fieldValue, ulong dirtyBit)
|
||||
{
|
||||
// Debug.Log("SetSyncVar " + GetType().Name + " bit [" + dirtyBit + "] " + fieldValue + "->" + value);
|
||||
//Debug.Log($"SetSyncVar {GetType().Name} bit:{dirtyBit} fieldValue:{value}");
|
||||
SetSyncVarDirtyBit(dirtyBit);
|
||||
fieldValue = value;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ internal static void RegisterSystemHandlers(bool hostMode)
|
||||
/// <summary>Connect client to a NetworkServer by address.</summary>
|
||||
public static void Connect(string address)
|
||||
{
|
||||
// Debug.Log("Client Connect: " + address);
|
||||
// Debug.Log($"Client Connect: {address}");
|
||||
Debug.Assert(Transport.activeTransport != null, "There was no active transport when calling NetworkClient.Connect, If you are calling Connect manually then make sure to set 'Transport.activeTransport' first");
|
||||
|
||||
RegisterSystemHandlers(false);
|
||||
@ -158,7 +158,7 @@ public static void Connect(string address)
|
||||
/// <summary>Connect client to a NetworkServer by Uri.</summary>
|
||||
public static void Connect(Uri uri)
|
||||
{
|
||||
// Debug.Log("Client Connect: " + uri);
|
||||
// Debug.Log($"Client Connect: {uri}");
|
||||
Debug.Assert(Transport.activeTransport != null, "There was no active transport when calling NetworkClient.Connect, If you are calling Connect manually then make sure to set 'Transport.activeTransport' first");
|
||||
|
||||
RegisterSystemHandlers(false);
|
||||
@ -708,7 +708,7 @@ public static void RegisterPrefab(GameObject prefab, Guid newAssetId, SpawnHandl
|
||||
Debug.LogError($"Prefab '{prefab.name}' has multiple NetworkIdentity components. There should only be one NetworkIdentity on a prefab, and it must be on the root object.");
|
||||
}
|
||||
|
||||
// Debug.Log("Registering custom prefab '" + prefab.name + "' as asset:" + assetId + " " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName());
|
||||
//Debug.Log($"Registering custom prefab {prefab.name} as asset:{assetId} {spawnHandler.GetMethodName()}/{unspawnHandler.GetMethodName()}");
|
||||
|
||||
spawnHandlers[assetId] = spawnHandler;
|
||||
unspawnHandlers[assetId] = unspawnHandler;
|
||||
@ -774,7 +774,7 @@ public static void RegisterPrefab(GameObject prefab, SpawnHandlerDelegate spawnH
|
||||
Debug.LogError($"Prefab '{prefab.name}' has multiple NetworkIdentity components. There should only be one NetworkIdentity on a prefab, and it must be on the root object.");
|
||||
}
|
||||
|
||||
// Debug.Log("Registering custom prefab '" + prefab.name + "' as asset:" + assetId + " " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName());
|
||||
//Debug.Log($"Registering custom prefab {prefab.name} as asset:{assetId} {spawnHandler.GetMethodName()}/{unspawnHandler.GetMethodName()}");
|
||||
|
||||
spawnHandlers[assetId] = spawnHandler;
|
||||
unspawnHandlers[assetId] = unspawnHandler;
|
||||
@ -859,7 +859,7 @@ public static void RegisterSpawnHandler(Guid assetId, SpawnHandlerDelegate spawn
|
||||
Debug.LogError($"assetId '{assetId}' is already used by prefab '{prefabs[assetId].name}'");
|
||||
}
|
||||
|
||||
// Debug.Log("RegisterSpawnHandler asset '" + assetId + "' " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName());
|
||||
// Debug.Log("RegisterSpawnHandler asset {assetId} {spawnHandler.GetMethodName()}/{unspawnHandler.GetMethodName()}");
|
||||
|
||||
spawnHandlers[assetId] = spawnHandler;
|
||||
unspawnHandlers[assetId] = unspawnHandler;
|
||||
@ -898,7 +898,7 @@ internal static bool InvokeUnSpawnHandler(Guid assetId, GameObject obj)
|
||||
// the players object for example.
|
||||
public static bool Ready()
|
||||
{
|
||||
// Debug.Log("NetworkClient.Ready() called with connection [" + conn + "]");
|
||||
// Debug.Log($"NetworkClient.Ready() called with connection {conn}");
|
||||
if (ready)
|
||||
{
|
||||
Debug.LogError("NetworkClient is already ready. It shouldn't be called twice.");
|
||||
@ -970,7 +970,7 @@ public static bool AddPlayer()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Debug.Log("NetworkClient.AddPlayer() called with connection [" + readyConnection + "]");
|
||||
// Debug.Log($"NetworkClient.AddPlayer() called with connection {readyConnection}");
|
||||
connection.Send(new AddPlayerMessage());
|
||||
return true;
|
||||
}
|
||||
@ -1057,7 +1057,7 @@ static NetworkIdentity SpawnPrefab(SpawnMessage message)
|
||||
if (GetPrefab(message.assetId, out GameObject prefab))
|
||||
{
|
||||
GameObject obj = GameObject.Instantiate(prefab, message.position, message.rotation);
|
||||
//Debug.Log("Client spawn handler instantiating [netId:" + msg.netId + " asset ID:" + msg.assetId + " pos:" + msg.position + " rotation: " + msg.rotation + "]");
|
||||
//Debug.Log($"Client spawn handler instantiating [netId{message.netId} asset ID:{message.assetId} pos:{message.position} rotation:{message.rotation}]");
|
||||
return obj.GetComponent<NetworkIdentity>();
|
||||
}
|
||||
if (spawnHandlers.TryGetValue(message.assetId, out SpawnHandlerDelegate handler))
|
||||
@ -1235,7 +1235,7 @@ internal static void OnHostClientSpawn(SpawnMessage message)
|
||||
// client-only mode callbacks //////////////////////////////////////////
|
||||
static void OnEntityStateMessage(EntityStateMessage message)
|
||||
{
|
||||
// Debug.Log("NetworkClient.OnUpdateVarsMessage " + msg.netId);
|
||||
// Debug.Log($"NetworkClient.OnUpdateVarsMessage {msg.netId}");
|
||||
if (spawned.TryGetValue(message.netId, out NetworkIdentity localObject) && localObject != null)
|
||||
{
|
||||
using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(message.payload))
|
||||
@ -1246,7 +1246,7 @@ static void OnEntityStateMessage(EntityStateMessage message)
|
||||
|
||||
static void OnRPCMessage(RpcMessage message)
|
||||
{
|
||||
// Debug.Log("NetworkClient.OnRPCMessage hash:" + msg.functionHash + " netId:" + msg.netId);
|
||||
// Debug.Log($"NetworkClient.OnRPCMessage hash:{msg.functionHash} netId:{msg.netId}");
|
||||
if (spawned.TryGetValue(message.netId, out NetworkIdentity identity))
|
||||
{
|
||||
using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(message.payload))
|
||||
@ -1275,14 +1275,14 @@ internal static void CheckForLocalPlayer(NetworkIdentity identity)
|
||||
// OnStartLocalPlayer in all scripts on the same GO
|
||||
identity.connectionToServer = connection;
|
||||
identity.OnStartLocalPlayer();
|
||||
// Debug.Log("NetworkClient.OnOwnerMessage - player=" + identity.name);
|
||||
// Debug.Log($"NetworkClient.OnOwnerMessage player:{identity.name}");
|
||||
}
|
||||
}
|
||||
|
||||
// destroy /////////////////////////////////////////////////////////////
|
||||
static void DestroyObject(uint netId)
|
||||
{
|
||||
// Debug.Log("NetworkClient.OnObjDestroy netId:" + netId);
|
||||
// Debug.Log($"NetworkClient.OnObjDestroy netId: {netId}");
|
||||
if (spawned.TryGetValue(netId, out NetworkIdentity localObject) && localObject != null)
|
||||
{
|
||||
localObject.OnStopClient();
|
||||
@ -1311,7 +1311,7 @@ static void DestroyObject(uint netId)
|
||||
// remove from dictionary no matter how it is unspawned
|
||||
spawned.Remove(netId);
|
||||
}
|
||||
//else Debug.LogWarning("Did not find target for destroy message for " + netId);
|
||||
//else Debug.LogWarning($"Did not find target for destroy message for {netId}");
|
||||
}
|
||||
|
||||
// update //////////////////////////////////////////////////////////////
|
||||
|
@ -141,7 +141,7 @@ public void Send<T>(T message, int channelId = Channels.Reliable)
|
||||
// the client. they would be detected as a message. send messages instead.
|
||||
internal virtual void Send(ArraySegment<byte> segment, int channelId = Channels.Reliable)
|
||||
{
|
||||
//Debug.Log("ConnectionSend " + this + " bytes:" + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));
|
||||
//Debug.Log($"ConnectionSend {this} bytes:{BitConverter.ToString(segment.Array, segment.Offset, segment.Count)}");
|
||||
|
||||
// add to batch no matter what.
|
||||
// batching will try to fit as many as possible into MTU.
|
||||
|
@ -438,7 +438,7 @@ void AssignSceneID()
|
||||
if (!duplicate)
|
||||
{
|
||||
sceneId = randomId;
|
||||
//Debug.Log(name + " in scene=" + gameObject.scene.name + " sceneId assigned to: " + m_SceneId.ToString("X"));
|
||||
//Debug.Log($"{name} in scene {gameObject.scene.name} sceneId assigned to:{sceneId:X}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ public void SetSceneIdSceneHashPartInternal()
|
||||
sceneId = (sceneId & 0xFFFFFFFF) | shiftedHash;
|
||||
|
||||
// log it. this is incredibly useful to debug sceneId issues.
|
||||
// Debug.Log(name + " in scene=" + gameObject.scene.name + " scene index hash(" + pathHash.ToString("X") + ") copied into sceneId: " + sceneId.ToString("X"));
|
||||
//Debug.Log($"{name} in scene {gameObject.scene.name} scene index hash {pathHash:X} copied into sceneId {sceneId:X}");
|
||||
}
|
||||
|
||||
void SetupIDs()
|
||||
@ -513,7 +513,7 @@ void SetupIDs()
|
||||
{
|
||||
// force 0 for prefabs
|
||||
sceneId = 0;
|
||||
//Debug.Log(name + " @ scene: " + gameObject.scene.name + " sceneid reset to 0 because CurrentPrefabStage=" + PrefabStageUtility.GetCurrentPrefabStage() + " PrefabStage=" + PrefabStageUtility.GetPrefabStage(gameObject));
|
||||
//Debug.Log($"{name} scene:{gameObject.scene.name} sceneid reset to 0 because CurrentPrefabStage={PrefabStageUtility.GetCurrentPrefabStage()} PrefabStage={PrefabStageUtility.GetPrefabStage(gameObject)}");
|
||||
|
||||
// get path from PrefabStage for this prefab
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
@ -637,7 +637,7 @@ internal void OnStartServer()
|
||||
netId = GetNextNetworkId();
|
||||
observers = new Dictionary<int, NetworkConnection>();
|
||||
|
||||
// Debug.Log("OnStartServer " + this + " NetId:" + netId + " SceneId:" + sceneId.ToString("X"));
|
||||
//Debug.Log($"OnStartServer {this} NetId:{netId} SceneId:{sceneId:X}");
|
||||
|
||||
// add to spawned (note: the original EnableIsServer isn't needed
|
||||
// because we already set m_isServer=true above)
|
||||
@ -706,7 +706,7 @@ internal void OnStartClient()
|
||||
isLocalPlayer = true;
|
||||
}
|
||||
|
||||
// Debug.Log("OnStartClient " + gameObject + " netId:" + netId);
|
||||
// Debug.Log($"OnStartClient {gameObject} netId:{netId}");
|
||||
foreach (NetworkBehaviour comp in NetworkBehaviours)
|
||||
{
|
||||
// an exception in OnStartClient should be caught, so that one
|
||||
@ -874,7 +874,7 @@ bool OnSerializeSafely(NetworkBehaviour comp, NetworkWriter writer, bool initial
|
||||
writer.WriteInt(endPosition - contentPosition);
|
||||
writer.Position = endPosition;
|
||||
|
||||
// Debug.Log("OnSerializeSafely written for object=" + comp.name + " component=" + comp.GetType() + " sceneId=" + sceneId.ToString("X") + "header@" + headerPosition + " content@" + contentPosition + " end@" + endPosition + " contentSize=" + (endPosition - contentPosition));
|
||||
//Debug.Log($"OnSerializeSafely written for object {comp.name} component:{comp.GetType()} sceneId:{sceneId:X} header:{headerPosition} content:{contentPosition} end:{endPosition} contentSize:{endPosition - contentPosition}");
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -900,7 +900,7 @@ internal void OnSerializeAllSafely(bool initialState, NetworkWriter ownerWriter,
|
||||
NetworkBehaviour comp = components[i];
|
||||
if (initialState || comp.IsDirty())
|
||||
{
|
||||
// Debug.Log("OnSerializeAllSafely: " + name + " -> " + comp.GetType() + " initial=" + initialState);
|
||||
//Debug.Log($"OnSerializeAllSafely: {name} -> {comp.GetType()} initial:{ initialState}");
|
||||
|
||||
// remember start position in case we need to copy it into
|
||||
// observers writer too
|
||||
@ -969,7 +969,7 @@ void OnDeserializeSafely(NetworkBehaviour comp, NetworkReader reader, bool initi
|
||||
// way to mess up another component's deserialization
|
||||
try
|
||||
{
|
||||
// Debug.Log("OnDeserializeSafely: " + comp.name + " component=" + comp.GetType() + " sceneId=" + sceneId.ToString("X") + " length=" + contentSize);
|
||||
//Debug.Log($"OnDeserializeSafely: {comp.name} component:{comp.GetType()} sceneId:{sceneId:X} length:{contentSize}");
|
||||
comp.OnDeserialize(reader, initialState);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -1083,7 +1083,7 @@ internal void AddObserver(NetworkConnection conn)
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log("Added observer " + conn.address + " added for " + gameObject);
|
||||
// Debug.Log($"Added observer: {conn.address} added for {gameObject}");
|
||||
|
||||
// if we previously had no observers, then clear all dirty bits once.
|
||||
// a monster's health may have changed while it had no observers.
|
||||
|
@ -181,7 +181,7 @@ static void RuntimeInitializeOnLoad()
|
||||
|
||||
static void NetworkEarlyUpdate()
|
||||
{
|
||||
//Debug.Log("NetworkEarlyUpdate @ " + Time.time);
|
||||
//Debug.Log($"NetworkEarlyUpdate {Time.time}");
|
||||
NetworkServer.NetworkEarlyUpdate();
|
||||
NetworkClient.NetworkEarlyUpdate();
|
||||
// invoke event after mirror has done it's early updating.
|
||||
@ -190,7 +190,7 @@ static void NetworkEarlyUpdate()
|
||||
|
||||
static void NetworkLateUpdate()
|
||||
{
|
||||
//Debug.Log("NetworkLateUpdate @ " + Time.time);
|
||||
//Debug.Log($"NetworkLateUpdate {Time.time}");
|
||||
// invoke event before mirror does its final late updating.
|
||||
OnLateUpdate?.Invoke();
|
||||
NetworkServer.NetworkLateUpdate();
|
||||
|
@ -339,7 +339,7 @@ public void StartClient()
|
||||
Debug.LogError("Must set the Network Address field in the manager");
|
||||
return;
|
||||
}
|
||||
// Debug.Log("NetworkManager StartClient address:" + networkAddress);
|
||||
// Debug.Log($"NetworkManager StartClient address:{networkAddress}");
|
||||
|
||||
NetworkClient.Connect(networkAddress);
|
||||
|
||||
@ -370,7 +370,7 @@ public void StartClient(Uri uri)
|
||||
|
||||
RegisterClientMessages();
|
||||
|
||||
// Debug.Log("NetworkManager StartClient address:" + uri);
|
||||
// Debug.Log($"NetworkManager StartClient address:{uri}");
|
||||
networkAddress = uri.Host;
|
||||
|
||||
NetworkClient.Connect(uri);
|
||||
@ -643,7 +643,7 @@ public virtual void ConfigureHeadlessFrameRate()
|
||||
{
|
||||
#if UNITY_SERVER
|
||||
Application.targetFrameRate = serverTickRate;
|
||||
// Debug.Log("Server Tick Rate set to: " + Application.targetFrameRate + " Hz.");
|
||||
// Debug.Log($"Server Tick Rate set to {Application.targetFrameRate} Hz.");
|
||||
#endif
|
||||
|
||||
// call the obsolete function in case someone did anything important
|
||||
@ -756,7 +756,7 @@ public virtual void ServerChangeScene(string newSceneName)
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log("ServerChangeScene " + newSceneName);
|
||||
// Debug.Log($"ServerChangeScene {newSceneName}");
|
||||
NetworkServer.SetAllClientsNotReady();
|
||||
networkSceneName = newSceneName;
|
||||
|
||||
@ -794,7 +794,7 @@ internal void ClientChangeScene(string newSceneName, SceneOperation sceneOperati
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log("ClientChangeScene newSceneName:" + newSceneName + " networkSceneName:" + networkSceneName);
|
||||
//Debug.Log($"ClientChangeScene newSceneName: {newSceneName} networkSceneName{networkSceneName}");
|
||||
|
||||
// Let client prepare for scene change
|
||||
OnClientChangeScene(newSceneName, sceneOperation, customHandling);
|
||||
@ -877,12 +877,12 @@ void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
// TODO only respawn the server objects from that scene later!
|
||||
NetworkServer.SpawnObjects();
|
||||
// Debug.Log("Respawned Server objects after additive scene load: " + scene.name);
|
||||
// Debug.Log($"Respawned Server objects after additive scene load: {scene.name}");
|
||||
}
|
||||
if (NetworkClient.active)
|
||||
{
|
||||
NetworkClient.PrepareToSpawnSceneObjects();
|
||||
// Debug.Log("Rebuild Client spawnableObjects after additive scene load: " + scene.name);
|
||||
// Debug.Log($"Rebuild Client spawnableObjects after additive scene load: {scene.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -891,7 +891,7 @@ void UpdateScene()
|
||||
{
|
||||
if (loadingSceneAsync != null && loadingSceneAsync.isDone)
|
||||
{
|
||||
// Debug.Log("ClientChangeScene done readyCon:" + clientReadyConnection);
|
||||
//Debug.Log($"ClientChangeScene done readyConn {clientReadyConnection}");
|
||||
|
||||
// try-finally to guarantee loadingSceneAsync being cleared.
|
||||
// fixes https://github.com/vis2k/Mirror/issues/2517 where if
|
||||
@ -1029,7 +1029,7 @@ void FinishLoadSceneClientOnly()
|
||||
/// <param name="start">Transform to register.</param>
|
||||
public static void RegisterStartPosition(Transform start)
|
||||
{
|
||||
// Debug.Log("RegisterStartPosition: (" + start.gameObject.name + ") " + start.position);
|
||||
// Debug.Log($"RegisterStartPosition: {start.gameObject.name} {start.position}");
|
||||
startPositions.Add(start);
|
||||
|
||||
// reorder the list so that round-robin spawning uses the start positions
|
||||
@ -1043,7 +1043,7 @@ public static void RegisterStartPosition(Transform start)
|
||||
// TODO why is this static?
|
||||
public static void UnRegisterStartPosition(Transform start)
|
||||
{
|
||||
// Debug.Log("UnRegisterStartPosition: (" + start.gameObject.name + ") " + start.position);
|
||||
//Debug.Log($"UnRegisterStartPosition: {start.name} {start.position}");
|
||||
startPositions.Remove(start);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ static void Initialize()
|
||||
return;
|
||||
|
||||
initialized = true;
|
||||
// Debug.Log("NetworkServer Created version " + Version.Current);
|
||||
// Debug.Log($"NetworkServer Created version {Version.Current}");
|
||||
|
||||
//Make sure connections are cleared in case any old connections references exist from previous sessions
|
||||
connections.Clear();
|
||||
@ -89,7 +89,7 @@ public static void ActivateHostScene()
|
||||
{
|
||||
if (!identity.isClient)
|
||||
{
|
||||
// Debug.Log("ActivateHostScene " + identity.netId + " " + identity);
|
||||
// Debug.Log($"ActivateHostScene {identity.netId} {identity}");
|
||||
identity.OnStartClient();
|
||||
}
|
||||
}
|
||||
@ -245,7 +245,7 @@ public static void SendToAll<T>(T message, int channelId = Channels.Reliable, bo
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log("Server.SendToAll id:" + typeof(T));
|
||||
// Debug.Log($"Server.SendToAll {typeof(T)}");
|
||||
using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter())
|
||||
{
|
||||
// pack message only once
|
||||
@ -288,7 +288,7 @@ public static void SendToReady<T>(T message, int channelId = Channels.Reliable)
|
||||
static void SendToObservers<T>(NetworkIdentity identity, T message, int channelId = Channels.Reliable)
|
||||
where T : struct, NetworkMessage
|
||||
{
|
||||
// Debug.Log("Server.SendToObservers id:" + typeof(T));
|
||||
// Debug.Log($"Server.SendToObservers {typeof(T)}");
|
||||
if (identity == null || identity.observers == null || identity.observers.Count == 0)
|
||||
return;
|
||||
|
||||
@ -312,7 +312,7 @@ static void SendToObservers<T>(NetworkIdentity identity, T message, int channelI
|
||||
public static void SendToReadyObservers<T>(NetworkIdentity identity, T message, bool includeOwner = true, int channelId = Channels.Reliable)
|
||||
where T : struct, NetworkMessage
|
||||
{
|
||||
// Debug.Log("Server.SendToReady msgType:" + typeof(T));
|
||||
// Debug.Log($"Server.SendToReady {typeof(T)}");
|
||||
if (identity == null || identity.observers == null || identity.observers.Count == 0)
|
||||
return;
|
||||
|
||||
@ -361,7 +361,7 @@ public static void SendToReady<T>(NetworkIdentity identity, T message, int chann
|
||||
// called by transport
|
||||
static void OnTransportConnected(int connectionId)
|
||||
{
|
||||
// Debug.Log("Server accepted client:" + connectionId);
|
||||
// Debug.Log($"Server accepted client:{connectionId}");
|
||||
|
||||
// connectionId needs to be != 0 because 0 is reserved for local player
|
||||
// note that some transports like kcp generate connectionId by
|
||||
@ -377,7 +377,7 @@ static void OnTransportConnected(int connectionId)
|
||||
if (connections.ContainsKey(connectionId))
|
||||
{
|
||||
Transport.activeTransport.ServerDisconnect(connectionId);
|
||||
// Debug.Log("Server connectionId " + connectionId + " already in use. kicked client:" + connectionId);
|
||||
// Debug.Log($"Server connectionId {connectionId} already in use...kicked client");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -396,13 +396,13 @@ static void OnTransportConnected(int connectionId)
|
||||
{
|
||||
// kick
|
||||
Transport.activeTransport.ServerDisconnect(connectionId);
|
||||
// Debug.Log("Server full, kicked client:" + connectionId);
|
||||
// Debug.Log($"Server full, kicked client {connectionId}");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void OnConnected(NetworkConnectionToClient conn)
|
||||
{
|
||||
// Debug.Log("Server accepted client:" + conn);
|
||||
// Debug.Log($"Server accepted client:{conn}");
|
||||
|
||||
// add connection and invoke connected event
|
||||
AddConnection(conn);
|
||||
@ -535,11 +535,11 @@ internal static void OnTransportData(int connectionId, ArraySegment<byte> data,
|
||||
// => which we do by removing the connection!
|
||||
internal static void OnTransportDisconnected(int connectionId)
|
||||
{
|
||||
// Debug.Log("Server disconnect client:" + connectionId);
|
||||
// Debug.Log($"Server disconnect client:{connectionId}");
|
||||
if (connections.TryGetValue(connectionId, out NetworkConnectionToClient conn))
|
||||
{
|
||||
RemoveConnection(connectionId);
|
||||
// Debug.Log("Server lost client:" + connectionId);
|
||||
// Debug.Log($"Server lost client:{connectionId}");
|
||||
|
||||
// NetworkManager hooks into OnDisconnectedEvent to make
|
||||
// DestroyPlayerForConnection(conn) optional, e.g. for PvP MMOs
|
||||
@ -694,7 +694,7 @@ public static bool AddPlayerForConnection(NetworkConnection conn, GameObject pla
|
||||
// set ready if not set yet
|
||||
SetClientReady(conn);
|
||||
|
||||
// Debug.Log("Adding new playerGameObject object netId: " + identity.netId + " asset ID " + identity.assetId);
|
||||
// Debug.Log($"Adding new playerGameObject object netId: {identity.netId} asset ID: {identity.assetId}");
|
||||
|
||||
Respawn(identity);
|
||||
return true;
|
||||
@ -758,7 +758,7 @@ public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject
|
||||
// IMPORTANT: do this in AddPlayerForConnection & ReplacePlayerForConnection!
|
||||
SpawnObserversForConnection(conn);
|
||||
|
||||
// Debug.Log("Replacing playerGameObject object netId: " + player.GetComponent<NetworkIdentity>().netId + " asset ID " + player.GetComponent<NetworkIdentity>().assetId);
|
||||
//Debug.Log($"Replacing playerGameObject object netId:{player.GetComponent<NetworkIdentity>().netId} asset ID {player.GetComponent<NetworkIdentity>().assetId}");
|
||||
|
||||
Respawn(identity);
|
||||
|
||||
@ -790,7 +790,7 @@ public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject
|
||||
// is probably fine, so this call wont be needed.
|
||||
public static void SetClientReady(NetworkConnection conn)
|
||||
{
|
||||
// Debug.Log("SetClientReadyInternal for conn:" + conn);
|
||||
// Debug.Log($"SetClientReadyInternal for conn:{conn}");
|
||||
|
||||
// set ready
|
||||
conn.isReady = true;
|
||||
@ -808,7 +808,7 @@ public static void SetClientNotReady(NetworkConnection conn)
|
||||
{
|
||||
if (conn.isReady)
|
||||
{
|
||||
// Debug.Log("PlayerNotReady " + conn);
|
||||
// Debug.Log($"PlayerNotReady {conn}");
|
||||
conn.isReady = false;
|
||||
conn.RemoveFromObservingsObservers();
|
||||
|
||||
@ -831,7 +831,7 @@ public static void SetAllClientsNotReady()
|
||||
// default ready handler.
|
||||
static void OnClientReadyMessage(NetworkConnection conn, ReadyMessage msg)
|
||||
{
|
||||
// Debug.Log("Default handler for ready message from " + conn);
|
||||
// Debug.Log($"Default handler for ready message from {conn}");
|
||||
SetClientReady(conn);
|
||||
}
|
||||
|
||||
@ -890,7 +890,7 @@ static void OnCommandMessage(NetworkConnection conn, CommandMessage msg)
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log("OnCommandMessage for netId=" + msg.netId + " conn=" + conn);
|
||||
// Debug.Log($"OnCommandMessage for netId:{msg.netId} conn:{conn}");
|
||||
|
||||
using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(msg.payload))
|
||||
identity.HandleRemoteCall(msg.componentIndex, msg.functionHash, MirrorInvokeType.Command, networkReader, conn as NetworkConnectionToClient);
|
||||
@ -925,7 +925,7 @@ internal static void SendSpawnMessage(NetworkIdentity identity, NetworkConnectio
|
||||
{
|
||||
if (identity.serverOnly) return;
|
||||
|
||||
// Debug.Log("Server SendSpawnMessage: name=" + identity.name + " sceneId=" + identity.sceneId.ToString("X") + " netid=" + identity.netId);
|
||||
//Debug.Log($"Server SendSpawnMessage: name:{identity.name} sceneId:{identity.sceneId:X} netid:{identity.netId}");
|
||||
|
||||
// one writer for owner, one for observers
|
||||
using (PooledNetworkWriter ownerWriter = NetworkWriterPool.GetWriter(), observersWriter = NetworkWriterPool.GetWriter())
|
||||
@ -987,7 +987,7 @@ static void SpawnObject(GameObject obj, NetworkConnection ownerConnection)
|
||||
|
||||
identity.OnStartServer();
|
||||
|
||||
// Debug.Log("SpawnObject instance ID " + identity.netId + " asset ID " + identity.assetId);
|
||||
// Debug.Log($"SpawnObject instance ID {identity.netId} asset ID {identity.assetId}");
|
||||
|
||||
if (aoi)
|
||||
{
|
||||
@ -1077,7 +1077,7 @@ public static bool SpawnObjects()
|
||||
{
|
||||
if (ValidateSceneObject(identity))
|
||||
{
|
||||
// Debug.Log("SpawnObjects sceneId:" + identity.sceneId.ToString("X") + " name:" + identity.gameObject.name);
|
||||
// Debug.Log($"SpawnObjects sceneId:{identity.sceneId:X} name:{identity.gameObject.name}");
|
||||
identity.gameObject.SetActive(true);
|
||||
|
||||
// fix https://github.com/vis2k/Mirror/issues/2778:
|
||||
@ -1118,7 +1118,7 @@ static void Respawn(NetworkIdentity identity)
|
||||
|
||||
static void SpawnObserversForConnection(NetworkConnection conn)
|
||||
{
|
||||
// Debug.Log("Spawning " + spawned.Count + " objects for conn " + conn);
|
||||
//Debug.Log($"Spawning {spawned.Count} objects for conn {conn}");
|
||||
|
||||
if (!conn.isReady)
|
||||
{
|
||||
@ -1137,7 +1137,7 @@ static void SpawnObserversForConnection(NetworkConnection conn)
|
||||
// try with far away ones in ummorpg!
|
||||
if (identity.gameObject.activeSelf) //TODO this is different
|
||||
{
|
||||
// Debug.Log("Sending spawn message for current server objects name='" + identity.name + "' netId=" + identity.netId + " sceneId=" + identity.sceneId.ToString("X"));
|
||||
//Debug.Log($"Sending spawn message for current server objects name:{identity.name} netId:{identity.netId} sceneId:{identity.sceneId:X}");
|
||||
|
||||
// we need to support three cases:
|
||||
// - legacy system (identity has .visibility)
|
||||
@ -1239,7 +1239,7 @@ static void DestroyObject(NetworkIdentity identity, DestroyMode mode)
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
// Debug.Log("DestroyObject instance:" + identity.netId);
|
||||
// Debug.Log($"DestroyObject instance:{identity.netId}");
|
||||
spawned.Remove(identity.netId);
|
||||
|
||||
identity.connectionToClient?.RemoveOwnedObject(identity);
|
||||
@ -1377,7 +1377,7 @@ static void RebuildObserversCustom(NetworkIdentity identity, bool initialize)
|
||||
{
|
||||
// new observer
|
||||
conn.AddToObserving(identity);
|
||||
// Debug.Log("New Observer for " + gameObject + " " + conn);
|
||||
// Debug.Log($"New Observer for {gameObject} {conn}");
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@ -1390,7 +1390,7 @@ static void RebuildObserversCustom(NetworkIdentity identity, bool initialize)
|
||||
{
|
||||
// removed observer
|
||||
conn.RemoveFromObserving(identity, false);
|
||||
// Debug.Log("Removed Observer for " + gameObject + " " + conn);
|
||||
// Debug.Log($"Removed Observer for {gameObjec} {conn}");
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ internal static void UpdateClient()
|
||||
// and time from the server
|
||||
internal static void OnServerPing(NetworkConnection conn, NetworkPingMessage message)
|
||||
{
|
||||
// Debug.Log("OnPingServerMessage conn=" + conn);
|
||||
// Debug.Log($"OnPingServerMessage conn:{conn}");
|
||||
NetworkPongMessage pongMessage = new NetworkPongMessage
|
||||
{
|
||||
clientTime = message.clientTime,
|
||||
|
@ -111,7 +111,7 @@ static bool GetInvokerForHash(int cmdHash, MirrorInvokeType invokeType, out Invo
|
||||
// debug message if not found, or null, or mismatched type
|
||||
// (no need to throw an error, an attacker might just be trying to
|
||||
// call an cmd with an rpc's hash)
|
||||
// Debug.Log("GetInvokerForHash hash:" + cmdHash + " not found");
|
||||
// Debug.Log($"GetInvokerForHash hash {cmdHash} not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user