Skip to content

Commit

Permalink
Fix handshake in host syncing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
miniduikboot committed Jun 27, 2024
1 parent 9486591 commit d3a9c20
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Reactor/Networking/Patches/ClientPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ public static bool Prefix(InnerNetClient._CoSendSceneChange_d__32 __instance, re

var innerNetClient = __instance.__4__this;

if (__instance.__1__state == 2)
// Check for the conditions when the scene change message should be sent
if (!innerNetClient.AmHost &&
innerNetClient.connection.State == ConnectionState.Connected &&
innerNetClient.ClientId >= 0)
{
if (!innerNetClient.AmHost && innerNetClient.connection.State == ConnectionState.Connected)
var clientData = innerNetClient.FindClientById(innerNetClient.ClientId);
if (clientData != null)
{
var writer = MessageWriter.Get(SendOption.Reliable);
writer.StartMessage(Tags.GameData);
Expand All @@ -154,11 +158,15 @@ public static bool Prefix(InnerNetClient._CoSendSceneChange_d__32 __instance, re
writer.EndMessage();
innerNetClient.SendOrDisconnect(writer);
writer.Recycle();
}

__instance.__1__state = -1;
__result = false;
return false;
// Create a new coroutine to let AmongUsClient handle scene changes too
innerNetClient.StartCoroutine(innerNetClient.CoOnPlayerChangedScene(clientData, __instance.sceneName));

// Cancel this coroutine
__instance.__1__state = -1;
__result = false;
return false;
}
}

return true;
Expand Down

0 comments on commit d3a9c20

Please sign in to comment.