From fd4b9dae93b8d848c0dda23a4b2be181306b46aa Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:45:55 +0200 Subject: [PATCH] Fix connect bug when host loads too fast --- Fika.Core/Coop/GameMode/CoopGame.cs | 24 +++++++------------ ...arkovApplication_LocalGameCreator_Patch.cs | 10 -------- ...rkovApplication_LocalGamePreparer_Patch.cs | 5 ---- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 74275183..f93e22f3 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -717,14 +717,6 @@ private IEnumerator WaitForOtherPlayers() DynamicAI.AddHumans(); } - SetStatusModel status = new(coopHandler.MyPlayer.ProfileId, LobbyEntry.ELobbyStatus.IN_GAME); - Task updateStatus = FikaRequestHandler.UpdateSetStatus(status); - - while (!updateStatus.IsCompleted) - { - yield return null; - } - Singleton.Instance.ReadyClients++; yield break; } @@ -736,14 +728,6 @@ private IEnumerator WaitForOtherPlayers() if (isServer) { - SetStatusModel status = new(coopHandler.MyPlayer.ProfileId, LobbyEntry.ELobbyStatus.IN_GAME); - Task updateStatus = FikaRequestHandler.UpdateSetStatus(status); - - while (!updateStatus.IsCompleted) - { - yield return null; - } - do { yield return null; @@ -1362,6 +1346,14 @@ public override IEnumerator vmethod_4(BotControllerSettings controllerSettings, FikaPlugin.DynamicAI.SettingChanged += DynamicAI_SettingChanged; FikaPlugin.DynamicAIRate.SettingChanged += DynamicAIRate_SettingChanged; + + SetStatusModel status = new(FikaBackendUtils.GetGroupId(), LobbyEntry.ELobbyStatus.IN_GAME); + Task updateStatus = FikaRequestHandler.UpdateSetStatus(status); + + while (!updateStatus.IsCompleted) + { + yield return null; + } } else { diff --git a/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs b/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs index 25e3ba0d..b9570431 100644 --- a/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs +++ b/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs @@ -32,11 +32,6 @@ public static bool Prefix(ref Task __result, TarkovApplication __instance, TimeA { Logger.LogDebug("TarkovApplication_LocalGameCreator_Patch:Prefix"); - if (FikaBackendUtils.IsSinglePlayer) - { - return true; - } - __result = CreateFikaGame(__instance, timeAndWeather, timeHasComeScreenController, ____raidSettings, ____inputTree, ____localGameDateTime, ____fixedDeltaTime, ____backendUrl); return false; } @@ -44,11 +39,6 @@ public static bool Prefix(ref Task __result, TarkovApplication __instance, TimeA public static async Task CreateFikaGame(TarkovApplication instance, TimeAndWeatherSettings timeAndWeather, MatchmakerTimeHasCome.TimeHasComeScreenClass timeHasComeScreenController, RaidSettings raidSettings, InputTree inputTree, GameDateTime localGameDateTime, float fixedDeltaTime, string backendUrl) { - if (FikaBackendUtils.IsSinglePlayer) - { - return; - } - if (raidSettings == null) { Logger.LogError("RaidSettings is Null"); diff --git a/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGamePreparer_Patch.cs b/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGamePreparer_Patch.cs index 04541717..154550cf 100644 --- a/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGamePreparer_Patch.cs +++ b/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGamePreparer_Patch.cs @@ -19,11 +19,6 @@ public static async void Prefix() { Logger.LogDebug("TarkovApplication_LocalGamePreparer_Patch:Prefix"); - if (FikaBackendUtils.IsSinglePlayer) - { - return; - } - bool isServer = FikaBackendUtils.IsServer; NetManagerUtils.CreateNetManager(FikaBackendUtils.IsServer); if (isServer)