diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index fe3013ef..a6e30075 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -650,10 +650,10 @@ private void SyncTransitControllers() /// This task ensures that all players are joined and loaded before continuing /// /// - private async Task WaitForOtherPlayers() + private async Task WaitForOtherPlayersToLoad() { #if DEBUG - Logger.LogWarning("Starting " + nameof(WaitForOtherPlayers)); + Logger.LogWarning("Starting " + nameof(WaitForOtherPlayersToLoad)); #endif if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler)) { @@ -955,7 +955,7 @@ private GameObject CreateStartButton() if (isServer) { RaidStarted = true; - FikaBackendUtils.HostExpectedNumberOfPlayers = Singleton.Instance.NetServer.ConnectedPeersCount; + FikaBackendUtils.HostExpectedNumberOfPlayers = Singleton.Instance.NetServer.ConnectedPeersCount + 1; return; } @@ -1410,6 +1410,11 @@ private async Task WaitForHostToStart() Destroy(startButton); } + InformationPacket continuePacket = new() + { + AmountOfPeers = server.NetServer.ConnectedPeersCount + 1 + }; + server.SendDataToAll(ref continuePacket, DeliveryMethod.ReliableOrdered); SetStatusModel status = new(FikaBackendUtils.GroupId, LobbyEntry.ELobbyStatus.IN_GAME); await FikaRequestHandler.UpdateSetStatus(status); return; @@ -1523,7 +1528,7 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I DynamicAI = gameObject.AddComponent(); } - await WaitForOtherPlayers(); + await WaitForOtherPlayersToLoad(); SetMatchmakerStatus(LocaleUtils.UI_FINISHING_RAID_INIT.Localized()); Logger.LogInfo("All players are loaded, continuing..."); diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 91bc7400..6e80ede3 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -1086,11 +1086,14 @@ private void OnInformationPacketReceived(InformationPacket packet) if (coopGame != null) { coopGame.RaidStarted = packet.RaidStarted; - FikaBackendUtils.HostExpectedNumberOfPlayers = packet.ReadyPlayers; } ReadyClients = packet.ReadyPlayers; HostReady = packet.HostReady; HostLoaded = packet.HostLoaded; + if (packet.AmountOfPeers > 0) + { + FikaBackendUtils.HostExpectedNumberOfPlayers = packet.AmountOfPeers; + } if (packet.HostReady) { diff --git a/Fika.Core/Networking/FikaServer.cs b/Fika.Core/Networking/FikaServer.cs index b0ebccf9..58dfe809 100644 --- a/Fika.Core/Networking/FikaServer.cs +++ b/Fika.Core/Networking/FikaServer.cs @@ -317,7 +317,7 @@ private void OnSideEffectPacketReceived(SideEffectPacket packet, NetPeer peer) if (item.TryGetItemComponent(out SideEffectComponent sideEffectComponent)) { sideEffectComponent.Value = packet.Value; - item.RaiseRefreshEvent(false, false); + item.RaiseRefreshEvent(true, false); } } diff --git a/Fika.Core/Networking/Packets/Backend/InformationPacket.cs b/Fika.Core/Networking/Packets/Backend/InformationPacket.cs index 41ad5932..93db9ebb 100644 --- a/Fika.Core/Networking/Packets/Backend/InformationPacket.cs +++ b/Fika.Core/Networking/Packets/Backend/InformationPacket.cs @@ -10,6 +10,7 @@ public struct InformationPacket : INetSerializable public bool RaidStarted; public bool RequestStart; public int ReadyPlayers; + public int AmountOfPeers; public bool HostReady; public bool HostLoaded; public DateTime GameTime; @@ -20,6 +21,7 @@ public void Deserialize(NetDataReader reader) RaidStarted = reader.GetBool(); RequestStart = reader.GetBool(); ReadyPlayers = reader.GetInt(); + AmountOfPeers = reader.GetInt(); HostReady = reader.GetBool(); if (HostReady) { @@ -34,6 +36,7 @@ public void Serialize(NetDataWriter writer) writer.Put(RaidStarted); writer.Put(RequestStart); writer.Put(ReadyPlayers); + writer.Put(AmountOfPeers); writer.Put(HostReady); if (HostReady) {