fix: Don't call RegisterClientMessages every scene change (#1865)

This commit is contained in:
MrGadget 2020-05-14 07:40:57 -04:00 committed by GitHub
parent a245e37a28
commit 05c119f505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -995,19 +995,14 @@ void FinishLoadSceneHost()
// call OnServerSceneChanged
OnServerSceneChanged(networkSceneName);
if (NetworkClient.isConnected)
{
RegisterClientMessages();
// DO NOT call OnClientSceneChanged here.
// the scene change happened because StartHost loaded the
// server's online scene. it has nothing to do with the client.
// this was not meant as a client scene load, so don't call it.
//
// otherwise AddPlayer would be called twice:
// -> once for client OnConnected
// -> once in OnClientSceneChanged
}
// DO NOT call OnClientSceneChanged here.
// the scene change happened because StartHost loaded the
// server's online scene. it has nothing to do with the client.
// this was not meant as a client scene load, so don't call it.
//
// otherwise AddPlayer would be called twice:
// -> once for client OnConnected
// -> once in OnClientSceneChanged
}
// otherwise we just changed a scene in host mode
else
@ -1020,8 +1015,6 @@ void FinishLoadSceneHost()
if (NetworkClient.isConnected)
{
RegisterClientMessages();
// let client know that we changed scene
OnClientSceneChanged(NetworkClient.connection);
}