mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
ConnectHost moved into FinishStartHost
This commit is contained in:
parent
f33d90a4ca
commit
7776049526
@ -454,6 +454,34 @@ void StartHostClient()
|
||||
bool finishStartHostPending;
|
||||
void FinishStartHost()
|
||||
{
|
||||
// ConnectHost needs to be called BEFORE SpawnObjects:
|
||||
// https://github.com/vis2k/Mirror/pull/1249/
|
||||
// -> this sets NetworkServer.localConnection.
|
||||
// -> localConnection needs to be set before SpawnObjects because:
|
||||
// -> SpawnObjects calls OnStartServer in all NetworkBehaviours
|
||||
// -> OnStartServer might spawn an object and set [SyncVar(hook="OnColorChanged")] object.color = green;
|
||||
// -> this calls SyncVar.set (generated by Weaver), which has
|
||||
// a custom case for host mode (because host mode doesn't
|
||||
// get OnDeserialize calls, where SyncVar hooks are usually
|
||||
// called):
|
||||
//
|
||||
// if (!SyncVarEqual(value, ref color))
|
||||
// {
|
||||
// if (NetworkServer.localClientActive && !getSyncVarHookGuard(1uL))
|
||||
// {
|
||||
// setSyncVarHookGuard(1uL, value: true);
|
||||
// OnColorChangedHook(value);
|
||||
// setSyncVarHookGuard(1uL, value: false);
|
||||
// }
|
||||
// SetSyncVar(value, ref color, 1uL);
|
||||
// }
|
||||
//
|
||||
// -> localClientActive needs to be true, otherwise the hook
|
||||
// isn't called in host mode!
|
||||
//
|
||||
// TODO call this after spawnobjects and worry about the syncvar hook fix later?
|
||||
NetworkClient.ConnectHost();
|
||||
|
||||
// server scene was loaded. now spawn all the objects
|
||||
NetworkServer.SpawnObjects();
|
||||
|
||||
@ -502,34 +530,6 @@ public virtual void StartHost()
|
||||
// is called after the server is actually properly started.
|
||||
OnStartHost();
|
||||
|
||||
// TODO move this into FinishStartHost! (and test if it still works)
|
||||
//
|
||||
// ConnectHost needs to be called BEFORE SpawnObjects:
|
||||
// https://github.com/vis2k/Mirror/pull/1249/
|
||||
// -> this sets NetworkServer.localConnection.
|
||||
// -> localConnection needs to be set before SpawnObjects because:
|
||||
// -> SpawnObjects calls OnStartServer in all NetworkBehaviours
|
||||
// -> OnStartServer might spawn an object and set [SyncVar(hook="OnColorChanged")] object.color = green;
|
||||
// -> this calls SyncVar.set (generated by Weaver), which has
|
||||
// a custom case for host mode (because host mode doesn't
|
||||
// get OnDeserialize calls, where SyncVar hooks are usually
|
||||
// called):
|
||||
//
|
||||
// if (!SyncVarEqual(value, ref color))
|
||||
// {
|
||||
// if (NetworkServer.localClientActive && !getSyncVarHookGuard(1uL))
|
||||
// {
|
||||
// setSyncVarHookGuard(1uL, value: true);
|
||||
// OnColorChangedHook(value);
|
||||
// setSyncVarHookGuard(1uL, value: false);
|
||||
// }
|
||||
// SetSyncVar(value, ref color, 1uL);
|
||||
// }
|
||||
//
|
||||
// -> localClientActive needs to be true, otherwise the hook
|
||||
// isn't called in host mode!
|
||||
NetworkClient.ConnectHost();
|
||||
|
||||
// scene change needed? then change scene and spawn afterwards.
|
||||
// => BEFORE host client connects. if client auth succeeds then the
|
||||
// server tells it to load 'onlineScene'. we can't do that if
|
||||
|
Loading…
Reference in New Issue
Block a user