mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
remove unnecessary HostMode.ActivateHostScene function.
this would call OnStartClient for scene objects if .isClient was false. however, NetworkManager.FinishStartHost calls NetworkServer.SpawnObjects first. which always sets isClient = true for all scene objects.
This commit is contained in:
parent
bb6c0de495
commit
b6cee2aae2
@ -1,6 +1,8 @@
|
||||
// host mode related helper functions.
|
||||
// usually they set up both server & client.
|
||||
// it's cleaner to keep them in one place, instead of only in server / client.
|
||||
using System;
|
||||
|
||||
namespace Mirror
|
||||
{
|
||||
public static class HostMode
|
||||
@ -39,19 +41,8 @@ public static void InvokeOnConnected()
|
||||
((LocalConnectionToServer)NetworkClient.connection).QueueConnectedEvent();
|
||||
}
|
||||
|
||||
// calls OnStartClient for all SERVER objects in host mode once.
|
||||
// client doesn't get spawn messages for those, so need to call manually.
|
||||
// public because NetworkServer.ActivateHostScene was public before too.
|
||||
public static void ActivateHostScene()
|
||||
{
|
||||
foreach (NetworkIdentity identity in NetworkServer.spawned.Values)
|
||||
{
|
||||
if (!identity.isClient)
|
||||
{
|
||||
// Debug.Log($"ActivateHostScene {identity.netId} {identity}");
|
||||
NetworkClient.CheckForStartClient(identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
// DEPRECATED 2023-01-28
|
||||
[Obsolete("ActivateHostScene did nothing, since identities all had .isClient set in NetworkServer.SpawnObjects.")]
|
||||
public static void ActivateHostScene() {}
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +523,6 @@ void FinishStartHost()
|
||||
SetupClient();
|
||||
|
||||
networkAddress = "localhost";
|
||||
HostMode.ActivateHostScene();
|
||||
RegisterClientMessages();
|
||||
|
||||
// call OnConencted needs to be called AFTER RegisterClientMessages
|
||||
|
@ -839,28 +839,6 @@ public void SendCommand_RequiresAuthority()
|
||||
Assert.That(comp.called, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ActivateHostSceneCallsOnStartClient()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticatedAndReady(out _);
|
||||
|
||||
// spawn identity with a networkbehaviour.
|
||||
// (needs to be in .spawned for ActivateHostScene)
|
||||
CreateNetworkedAndSpawn(
|
||||
out _, out NetworkIdentity serverIdentity, out OnStartClientTestNetworkBehaviour serverComp,
|
||||
out _, out _, out _);
|
||||
|
||||
// ActivateHostScene calls OnStartClient for spawned objects where
|
||||
// isClient is still false. set it to false first.
|
||||
serverIdentity.isClient = false;
|
||||
HostMode.ActivateHostScene();
|
||||
|
||||
// was OnStartClient called for all .spawned networkidentities?
|
||||
Assert.That(serverComp.called, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendToAll()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user