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/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index dabea03d..4a4be2fe 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -61,6 +61,7 @@ public bool WaitingForCallback } protected string lastWeaponId; + private bool shouldSendSideEffect; public ClientMovementContext ClientMovementContext { @@ -1344,6 +1345,10 @@ public virtual void HandleDamagePacket(ref DamagePacket packet) if (item != null) { damageInfo.Weapon = item; + (damageInfo.Player.iPlayer as CoopPlayer).shouldSendSideEffect = true; +#if DEBUG + FikaPlugin.Instance.FikaLogger.LogWarning("Found weapon for knife damage: " + item.Name.Localized()); +#endif } } @@ -1354,13 +1359,19 @@ public virtual void HandleDamagePacket(ref DamagePacket packet) public override void OnSideEffectApplied(SideEffectComponent sideEffect) { + if (!shouldSendSideEffect) + { + return; + } + SideEffectPacket packet = new() { ItemId = sideEffect.Item.Id, Value = sideEffect.Value }; - PacketSender.SendPacket(ref packet); + PacketSender.SendPacket(ref packet, true); + shouldSendSideEffect = false; } public void HandleArmorDamagePacket(ref ArmorDamagePacket packet) diff --git a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs index 0e88a788..b9a8b934 100644 --- a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs +++ b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs @@ -1112,11 +1112,6 @@ public void InitObservedPlayer(bool isDedicatedHost) } } - public override void OnSideEffectApplied(SideEffectComponent sideEffect) - { - // Do nothing - } - private IEnumerator CreateHealthBar() { CoopGame coopGame = (CoopGame)Singleton.Instance; diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index 75bd9d35..d68a5cab 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -455,12 +455,14 @@ public IEnumerator WaitForLocales(Task __result) private string CleanConfigString(string header) { + string original = string.Copy(header); string[] forbiddenChars = ["\n", "\t", "\\", "\"", "'", "[", "]"]; - foreach (string item in forbiddenChars) + foreach (string character in forbiddenChars) { - if (header.Contains(item)) + if (header.Contains(character)) { - header.Replace(item, ""); + FikaLogger.LogWarning($"Header {original} contains an illegal character: {character}\nReport this to the developers!"); + header.Replace(character, ""); } } @@ -483,29 +485,29 @@ private void SetupConfig() string coopHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP.Localized()); - ShowNotifications = Instance.Config.Bind(coopHeader, LocaleUtils.BEPINEX_SHOW_FEED_T.Localized(), true, + ShowNotifications = Instance.Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_SHOW_FEED_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_SHOW_FEED_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 7 })); - AutoExtract = Config.Bind(coopHeader, LocaleUtils.BEPINEX_AUTO_EXTRACT_T.Localized(), false, + AutoExtract = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_AUTO_EXTRACT_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_AUTO_EXTRACT_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 6 })); - ShowExtractMessage = Config.Bind(coopHeader, LocaleUtils.BEPINEX_SHOW_EXTRACT_MESSAGE_T.Localized(), true, + ShowExtractMessage = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_SHOW_EXTRACT_MESSAGE_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_SHOW_EXTRACT_MESSAGE_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 5 })); - ExtractKey = Config.Bind(coopHeader, LocaleUtils.BEPINEX_EXTRACT_KEY_T.Localized(), new KeyboardShortcut(KeyCode.F8), + ExtractKey = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_EXTRACT_KEY_T.Localized()), new KeyboardShortcut(KeyCode.F8), new ConfigDescription(LocaleUtils.BEPINEX_EXTRACT_KEY_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 4 })); - EnableChat = Config.Bind(coopHeader, LocaleUtils.BEPINEX_ENABLE_CHAT_T.Localized(), false, + EnableChat = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_ENABLE_CHAT_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_ENABLE_CHAT_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 3 })); - ChatKey = Config.Bind(coopHeader, LocaleUtils.BEPINEX_CHAT_KEY_T.Localized(), new KeyboardShortcut(KeyCode.RightControl), + ChatKey = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_CHAT_KEY_T.Localized()), new KeyboardShortcut(KeyCode.RightControl), new ConfigDescription(LocaleUtils.BEPINEX_CHAT_KEY_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 2 })); - EnableOnlinePlayers = Config.Bind(coopHeader, LocaleUtils.BEPINEX_ENABLE_ONLINE_PLAYER_T.Localized(), true, + EnableOnlinePlayers = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_ENABLE_ONLINE_PLAYER_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_ENABLE_ONLINE_PLAYER_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 1 })); - OnlinePlayersScale = Config.Bind(coopHeader, LocaleUtils.BEPINEX_ONLINE_PLAYERS_SCALE_T.Localized(), 1f, + OnlinePlayersScale = Config.Bind(coopHeader, CleanConfigString(LocaleUtils.BEPINEX_ONLINE_PLAYERS_SCALE_T.Localized()), 1f, new ConfigDescription(LocaleUtils.BEPINEX_ONLINE_PLAYERS_SCALE_D.Localized(), new AcceptableValueRange(0.5f, 1.5f), new ConfigurationManagerAttributes() { Order = 0 })); @@ -513,222 +515,233 @@ private void SetupConfig() string coopNameplatesHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP_NAME_PLATES.Localized()); - UseNamePlates = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_USE_NAME_PLATES_T.Localized(), false, + UseNamePlates = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_USE_NAME_PLATES_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_USE_NAME_PLATES_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 13 })); - HideHealthBar = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_HIDE_HEALTH_BAR_T.Localized(), false, + HideHealthBar = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_HIDE_HEALTH_BAR_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_HIDE_HEALTH_BAR_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 12 })); - UseHealthNumber = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_USE_PERCENT_T.Localized(), false, + UseHealthNumber = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_USE_PERCENT_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_USE_PERCENT_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 11 })); - ShowEffects = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_SHOW_EFFECTS_T.Localized(), true, + ShowEffects = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_SHOW_EFFECTS_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_SHOW_EFFECTS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 10 })); - UsePlateFactionSide = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_SHOW_FACTION_ICON_T.Localized(), true, + UsePlateFactionSide = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_SHOW_FACTION_ICON_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_SHOW_FACTION_ICON_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 9 })); - HideNamePlateInOptic = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_HIDE_IN_OPTIC_T.Localized(), true, + HideNamePlateInOptic = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_HIDE_IN_OPTIC_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_HIDE_IN_OPTIC_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 8 })); - NamePlateUseOpticZoom = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_OPTIC_USE_ZOOM_T.Localized(), true, + NamePlateUseOpticZoom = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_OPTIC_USE_ZOOM_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_OPTIC_USE_ZOOM_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 7, IsAdvanced = true })); - DecreaseOpacityNotLookingAt = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_DEC_OPAC_PERI_T.Localized(), true, + DecreaseOpacityNotLookingAt = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_DEC_OPAC_PERI_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_DEC_OPAC_PERI_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 6 })); - NamePlateScale = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_NAME_PLATE_SCALE_T.Localized(), 0.22f, + NamePlateScale = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_NAME_PLATE_SCALE_T.Localized()), 0.22f, new ConfigDescription(LocaleUtils.BEPINEX_NAME_PLATE_SCALE_D.Localized(), new AcceptableValueRange(0.05f, 1f), new ConfigurationManagerAttributes() { Order = 5 })); - OpacityInADS = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_ADS_OPAC_T.Localized(), 0.75f, + OpacityInADS = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_ADS_OPAC_T.Localized()), 0.75f, new ConfigDescription(LocaleUtils.BEPINEX_ADS_OPAC_D.Localized(), new AcceptableValueRange(0.1f, 1f), new ConfigurationManagerAttributes() { Order = 4 })); - MaxDistanceToShow = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_MAX_DISTANCE_T.Localized(), 500f, + MaxDistanceToShow = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_MAX_DISTANCE_T.Localized()), 500f, new ConfigDescription(LocaleUtils.BEPINEX_MAX_DISTANCE_D.Localized(), new AcceptableValueRange(10f, 1000f), new ConfigurationManagerAttributes() { Order = 3 })); - MinimumOpacity = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_MIN_OPAC_T.Localized(), 0.1f, + MinimumOpacity = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_MIN_OPAC_T.Localized()), 0.1f, new ConfigDescription(LocaleUtils.BEPINEX_MIN_OPAC_D.Localized(), new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 2 })); - MinimumNamePlateScale = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_MIN_PLATE_SCALE_T.Localized(), 0.01f, + MinimumNamePlateScale = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_MIN_PLATE_SCALE_T.Localized()), 0.01f, new ConfigDescription(LocaleUtils.BEPINEX_MIN_PLATE_SCALE_D.Localized(), new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 1 })); - UseOcclusion = Config.Bind(coopNameplatesHeader, LocaleUtils.BEPINEX_USE_OCCLUSION_T.Localized(), false, + UseOcclusion = Config.Bind(coopNameplatesHeader, CleanConfigString(LocaleUtils.BEPINEX_USE_OCCLUSION_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_USE_OCCLUSION_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 0 })); // Coop | Quest Sharing string coopQuestSharingHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP_QUEST_SHARING.Localized()); - QuestTypesToShareAndReceive = Config.Bind(coopQuestSharingHeader, LocaleUtils.BEPINEX_QUEST_TYPES_T.Localized(), EQuestSharingTypes.All, + QuestTypesToShareAndReceive = Config.Bind(coopQuestSharingHeader, CleanConfigString(LocaleUtils.BEPINEX_QUEST_TYPES_T.Localized()), EQuestSharingTypes.All, new ConfigDescription(LocaleUtils.BEPINEX_QUEST_TYPES_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 4 })); - QuestSharingNotifications = Config.Bind(coopQuestSharingHeader, LocaleUtils.BEPINEX_QS_NOTIFICATIONS_T.Localized(), true, + QuestSharingNotifications = Config.Bind(coopQuestSharingHeader, CleanConfigString(LocaleUtils.BEPINEX_QS_NOTIFICATIONS_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_QS_NOTIFICATIONS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 3 })); - EasyKillConditions = Config.Bind(coopQuestSharingHeader, LocaleUtils.BEPINEX_EASY_KILL_CONDITIONS_T.Localized(), false, + EasyKillConditions = Config.Bind(coopQuestSharingHeader, CleanConfigString(LocaleUtils.BEPINEX_EASY_KILL_CONDITIONS_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_EASY_KILL_CONDITIONS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 2 })); - SharedKillExperience = Config.Bind(coopQuestSharingHeader, LocaleUtils.BEPINEX_SHARED_KILL_XP_T.Localized(), false, + SharedKillExperience = Config.Bind(coopQuestSharingHeader, CleanConfigString(LocaleUtils.BEPINEX_SHARED_KILL_XP_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_SHARED_KILL_XP_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 1 })); - SharedBossExperience = Config.Bind(coopQuestSharingHeader, LocaleUtils.BEPINEX_SHARED_BOSS_XP_T.Localized(), false, + SharedBossExperience = Config.Bind(coopQuestSharingHeader, CleanConfigString(LocaleUtils.BEPINEX_SHARED_BOSS_XP_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_SHARED_BOSS_XP_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 0 })); // Coop | Pinging string coopPingingHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP_PINGING.Localized()); - UsePingSystem = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_SYSTEM_T.Localized(), true, + UsePingSystem = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_SYSTEM_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_PING_SYSTEM_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 11 })); - PingButton = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_BUTTON_T.Localized(), new KeyboardShortcut(KeyCode.Semicolon), + PingButton = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_BUTTON_T.Localized()), new KeyboardShortcut(KeyCode.Semicolon), new ConfigDescription(LocaleUtils.BEPINEX_PING_BUTTON_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 10 })); - PingColor = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_COLOR_T.Localized(), Color.white, + PingColor = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_COLOR_T.Localized()), Color.white, new ConfigDescription(LocaleUtils.BEPINEX_PING_COLOR_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 9 })); - PingSize = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_SIZE_T.Localized(), 1f, + PingSize = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_SIZE_T.Localized()), 1f, new ConfigDescription(LocaleUtils.BEPINEX_PING_SIZE_D.Localized(), new AcceptableValueRange(0.1f, 2f), new ConfigurationManagerAttributes() { Order = 8 })); - PingTime = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_TIME_T.Localized(), 3, + PingTime = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_TIME_T.Localized()), 3, new ConfigDescription(LocaleUtils.BEPINEX_PING_TIME_D.Localized(), new AcceptableValueRange(2, 10), new ConfigurationManagerAttributes() { Order = 7 })); - PlayPingAnimation = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_ANIMATION_T.Localized(), false, + PlayPingAnimation = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_ANIMATION_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_PING_ANIMATION_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 6 })); - ShowPingDuringOptics = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_OPTICS_T.Localized(), false, + ShowPingDuringOptics = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_OPTICS_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_PING_OPTICS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 5 })); - PingUseOpticZoom = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_OPTIC_ZOOM_T.Localized(), true, + PingUseOpticZoom = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_OPTIC_ZOOM_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_PING_OPTIC_ZOOM_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 4, IsAdvanced = true })); - PingScaleWithDistance = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_SCALE_DISTANCE_T.Localized(), true, + PingScaleWithDistance = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_SCALE_DISTANCE_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_PING_SCALE_DISTANCE_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 3, IsAdvanced = true })); - PingMinimumOpacity = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_MIN_OPAC_T.Localized(), 0.05f, + PingMinimumOpacity = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_MIN_OPAC_T.Localized()), 0.05f, new ConfigDescription(LocaleUtils.BEPINEX_PING_MIN_OPAC_D.Localized(), new AcceptableValueRange(0f, 0.5f), new ConfigurationManagerAttributes() { Order = 2, IsAdvanced = true })); - ShowPingRange = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_RANGE_T.Localized(), false, + ShowPingRange = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_RANGE_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_PING_RANGE_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 1 })); - PingSound = Config.Bind(coopPingingHeader, LocaleUtils.BEPINEX_PING_SOUND_T.Localized(), EPingSound.SubQuestComplete, + PingSound = Config.Bind(coopPingingHeader, CleanConfigString(LocaleUtils.BEPINEX_PING_SOUND_T.Localized()), EPingSound.SubQuestComplete, new ConfigDescription(LocaleUtils.BEPINEX_PING_SOUND_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 0 })); // Coop | Debug string coopDebugHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP_DEBUG.Localized()); - FreeCamButton = Config.Bind(coopDebugHeader, LocaleUtils.BEPINEX_FREE_CAM_BUTTON_T.Localized(), new KeyboardShortcut(KeyCode.F9), - LocaleUtils.BEPINEX_FREE_CAM_BUTTON_D.Localized()); + FreeCamButton = Config.Bind(coopDebugHeader, CleanConfigString(LocaleUtils.BEPINEX_FREE_CAM_BUTTON_T.Localized()), new KeyboardShortcut(KeyCode.F9), + CleanConfigString(LocaleUtils.BEPINEX_FREE_CAM_BUTTON_D.Localized())); - AllowSpectateBots = Config.Bind(coopDebugHeader, LocaleUtils.BEPINEX_SPECTATE_BOTS_T.Localized(), true, - LocaleUtils.BEPINEX_SPECTATE_BOTS_D.Localized()); + AllowSpectateBots = Config.Bind(coopDebugHeader, CleanConfigString(LocaleUtils.BEPINEX_SPECTATE_BOTS_T.Localized()), true, + CleanConfigString(LocaleUtils.BEPINEX_SPECTATE_BOTS_D.Localized())); - AZERTYMode = Config.Bind(coopDebugHeader, LocaleUtils.BEPINEX_AZERTY_MODE_T.Localized(), false, - LocaleUtils.BEPINEX_AZERTY_MODE_D.Localized()); + AZERTYMode = Config.Bind(coopDebugHeader, CleanConfigString(LocaleUtils.BEPINEX_AZERTY_MODE_T.Localized()), false, + CleanConfigString(LocaleUtils.BEPINEX_AZERTY_MODE_D.Localized())); - DroneMode = Config.Bind(coopDebugHeader, LocaleUtils.BEPINEX_DRONE_MODE_T.Localized(), false, + DroneMode = Config.Bind(coopDebugHeader, CleanConfigString(LocaleUtils.BEPINEX_DRONE_MODE_T.Localized()), false, LocaleUtils.BEPINEX_DRONE_MODE_D.Localized()); - KeybindOverlay = Config.Bind(coopDebugHeader, LocaleUtils.BEPINEX_KEYBIND_OVERLAY_T.Localized(), true, + KeybindOverlay = Config.Bind(coopDebugHeader, CleanConfigString(LocaleUtils.BEPINEX_KEYBIND_OVERLAY_T.Localized()), true, LocaleUtils.BEPINEX_KEYBIND_OVERLAY_T.Localized()); // Performance string performanceHeader = CleanConfigString(LocaleUtils.BEPINEX_H_PERFORMANCE.Localized()); - DynamicAI = Config.Bind(performanceHeader, LocaleUtils.BEPINEX_DYNAMIC_AI_T.Localized(), false, + DynamicAI = Config.Bind(performanceHeader, CleanConfigString(LocaleUtils.BEPINEX_DYNAMIC_AI_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_DYNAMIC_AI_T.Localized(), tags: new ConfigurationManagerAttributes() { Order = 3 })); - DynamicAIRange = Config.Bind(performanceHeader, LocaleUtils.BEPINEX_DYNAMIC_AI_RANGE_T.Localized(), 100f, + DynamicAIRange = Config.Bind(performanceHeader, CleanConfigString(LocaleUtils.BEPINEX_DYNAMIC_AI_RANGE_T.Localized()), 100f, new ConfigDescription(LocaleUtils.BEPINEX_DYNAMIC_AI_RANGE_D.Localized(), new AcceptableValueRange(150f, 1000f), new ConfigurationManagerAttributes() { Order = 2 })); - DynamicAIRate = Config.Bind(performanceHeader, LocaleUtils.BEPINEX_DYNAMIC_AI_RATE_T.Localized(), EDynamicAIRates.Medium, + DynamicAIRate = Config.Bind(performanceHeader, CleanConfigString(LocaleUtils.BEPINEX_DYNAMIC_AI_RATE_T.Localized()), EDynamicAIRates.Medium, new ConfigDescription(LocaleUtils.BEPINEX_DYNAMIC_AI_RATE_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 1 })); - DynamicAIIgnoreSnipers = Config.Bind(performanceHeader, LocaleUtils.BEPINEX_DYNAMIC_AI_NO_SNIPERS_T.Localized(), true, + DynamicAIIgnoreSnipers = Config.Bind(performanceHeader, CleanConfigString(LocaleUtils.BEPINEX_DYNAMIC_AI_NO_SNIPERS_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_DYNAMIC_AI_NO_SNIPERS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 0 })); // Performance | Max Bots string performanceBotsHeader = CleanConfigString(LocaleUtils.BEPINEX_H_PERFORMANCE_BOTS.Localized()); - EnforcedSpawnLimits = Config.Bind(performanceBotsHeader, LocaleUtils.BEPINEX_ENFORCED_SPAWN_LIMITS_T.Localized(), false, + EnforcedSpawnLimits = Config.Bind(performanceBotsHeader, CleanConfigString(LocaleUtils.BEPINEX_ENFORCED_SPAWN_LIMITS_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_ENFORCED_SPAWN_LIMITS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 14 })); - DespawnFurthest = Config.Bind(performanceBotsHeader, LocaleUtils.BEPINEX_DESPAWN_FURTHEST_T.Localized(), false, + DespawnFurthest = Config.Bind(performanceBotsHeader, CleanConfigString(LocaleUtils.BEPINEX_DESPAWN_FURTHEST_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_DESPAWN_FURTHEST_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 13 })); - DespawnMinimumDistance = Config.Bind(performanceBotsHeader, LocaleUtils.BEPINEX_DESPAWN_MIN_DISTANCE_T.Localized(), 200.0f, + DespawnMinimumDistance = Config.Bind(performanceBotsHeader, CleanConfigString(LocaleUtils.BEPINEX_DESPAWN_MIN_DISTANCE_T.Localized()), 200.0f, new ConfigDescription(LocaleUtils.BEPINEX_DESPAWN_MIN_DISTANCE_D.Localized(), new AcceptableValueRange(50f, 3000f), new ConfigurationManagerAttributes() { Order = 12 })); - string maxBotsHeader = LocaleUtils.BEPINEX_MAX_BOTS_T.Localized(); + string maxBotsHeader = CleanConfigString(LocaleUtils.BEPINEX_MAX_BOTS_T.Localized()); string maxBotsDescription = LocaleUtils.BEPINEX_MAX_BOTS_D.Localized(); - MaxBotsFactory = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Factory"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Factory"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 11 })); + string factory = "factory4_day".Localized(); + MaxBotsFactory = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, factory), 0, + new ConfigDescription(string.Format(maxBotsDescription, factory), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 11 })); - MaxBotsCustoms = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Customs"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Customs"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 10 })); + string customs = "bigmap".Localized(); + MaxBotsCustoms = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, customs), 0, + new ConfigDescription(string.Format(maxBotsDescription, customs), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 10 })); - MaxBotsInterchange = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Interchange"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Interchange"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 8 })); + string interchange = "interchange".Localized(); + MaxBotsInterchange = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, interchange), 0, + new ConfigDescription(string.Format(maxBotsDescription, interchange), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 8 })); - MaxBotsReserve = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Reserve"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Reserve"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 7 })); + string reserve = "rezervbase".Localized(); + MaxBotsReserve = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, reserve), 0, + new ConfigDescription(string.Format(maxBotsDescription, reserve), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 7 })); - MaxBotsWoods = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Woods"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Woods"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 6 })); + string woods = "woods".Localized(); + MaxBotsWoods = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, woods), 0, + new ConfigDescription(string.Format(maxBotsDescription, woods), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 6 })); - MaxBotsShoreline = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Shoreline"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Shoreline"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 5 })); + string shoreline = "shoreline".Localized(); + MaxBotsShoreline = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, shoreline), 0, + new ConfigDescription(string.Format(maxBotsDescription, shoreline), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 5 })); - MaxBotsStreets = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Streets"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Streets"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 4 })); + string streets = "tarkovstreets".Localized(); + MaxBotsStreets = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, streets), 0, + new ConfigDescription(string.Format(maxBotsDescription, streets), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 4 })); - MaxBotsGroundZero = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Ground Zero"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Ground Zero"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 3 })); + string groundZero = "sandbox".Localized(); + MaxBotsGroundZero = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, groundZero), 0, + new ConfigDescription(string.Format(maxBotsDescription, groundZero), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 3 })); - MaxBotsLabs = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Labs"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Labs"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 2 })); + string labs = "laboratory".Localized(); + MaxBotsLabs = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, labs), 0, + new ConfigDescription(string.Format(maxBotsDescription, labs), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 2 })); - MaxBotsLighthouse = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, "Lighthouse"), 0, - new ConfigDescription(string.Format(maxBotsDescription, "Lighthouse"), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 1 })); + string lighthouse = "lighthouse".Localized(); + MaxBotsLighthouse = Config.Bind(performanceBotsHeader, string.Format(maxBotsHeader, lighthouse), 0, + new ConfigDescription(string.Format(maxBotsDescription, lighthouse), new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 1 })); // Network string networkHeader = CleanConfigString(LocaleUtils.BEPINEX_H_NETWORK.Localized()); - NativeSockets = Config.Bind(networkHeader, LocaleUtils.BEPINEX_NATIVE_SOCKETS_T.Localized(), true, + NativeSockets = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_NATIVE_SOCKETS_T.Localized()), true, new ConfigDescription(LocaleUtils.BEPINEX_NATIVE_SOCKETS_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 9 })); - ForceIP = Config.Bind(networkHeader, LocaleUtils.BEPINEX_FORCE_IP_T.Localized(), "", + ForceIP = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_FORCE_IP_T.Localized()), "", new ConfigDescription(LocaleUtils.BEPINEX_FORCE_IP_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 8 })); - ForceBindIP = Config.Bind(networkHeader, LocaleUtils.BEPINEX_FORCE_BIND_IP_T.Localized(), "0.0.0.0", + ForceBindIP = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_FORCE_BIND_IP_T.Localized()), "0.0.0.0", new ConfigDescription(LocaleUtils.BEPINEX_FORCE_BIND_IP_D.Localized(), new AcceptableValueList(GetLocalAddresses()), new ConfigurationManagerAttributes() { Order = 7 })); - UDPPort = Config.Bind(networkHeader, LocaleUtils.BEPINEX_UDP_PORT_T.Localized(), 25565, + UDPPort = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_UDP_PORT_T.Localized()), 25565, new ConfigDescription(LocaleUtils.BEPINEX_UDP_PORT_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 5 })); - UseUPnP = Config.Bind(networkHeader, LocaleUtils.BEPINEX_USE_UPNP_T.Localized(), false, + UseUPnP = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_USE_UPNP_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_USE_UPNP_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 4 })); - UseNatPunching = Config.Bind(networkHeader, LocaleUtils.BEPINEX_USE_NAT_PUNCH_T.Localized(), false, + UseNatPunching = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_USE_NAT_PUNCH_T.Localized()), false, new ConfigDescription(LocaleUtils.BEPINEX_USE_NAT_PUNCH_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 3 })); - ConnectionTimeout = Config.Bind(networkHeader, LocaleUtils.BEPINEX_CONNECTION_TIMEOUT_T.Localized(), 15, + ConnectionTimeout = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_CONNECTION_TIMEOUT_T.Localized()), 15, new ConfigDescription(LocaleUtils.BEPINEX_CONNECTION_TIMEOUT_D.Localized(), new AcceptableValueRange(5, 60), new ConfigurationManagerAttributes() { Order = 2 })); - SendRate = Config.Bind(networkHeader, LocaleUtils.BEPINEX_SEND_RATE_T.Localized(), ESendRate.Medium, + SendRate = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_SEND_RATE_T.Localized()), ESendRate.Medium, new ConfigDescription(LocaleUtils.BEPINEX_SEND_RATE_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 1 })); - SmoothingRate = Config.Bind(networkHeader, LocaleUtils.BEPINEX_SMOOTHING_RATE_T.Localized(), ESmoothingRate.Medium, + SmoothingRate = Config.Bind(networkHeader, CleanConfigString(LocaleUtils.BEPINEX_SMOOTHING_RATE_T.Localized()), ESmoothingRate.Medium, new ConfigDescription(LocaleUtils.BEPINEX_SMOOTHING_RATE_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 0 })); // Gameplay - DisableBotMetabolism = Config.Bind(CleanConfigString(LocaleUtils.BEPINEX_H_GAMEPLAY.Localized()), LocaleUtils.BEPINEX_DISABLE_BOT_METABOLISM_T.Localized(), false, - new ConfigDescription(LocaleUtils.BEPINEX_DISABLE_BOT_METABOLISM_D.Localized(), tags: new ConfigurationManagerAttributes() { Order = 1 })); + DisableBotMetabolism = Config.Bind(CleanConfigString(LocaleUtils.BEPINEX_H_GAMEPLAY.Localized()), CleanConfigString(LocaleUtils.BEPINEX_DISABLE_BOT_METABOLISM_T.Localized()), + false, new ConfigDescription(LocaleUtils.BEPINEX_DISABLE_BOT_METABOLISM_D.Localized(), + tags: new ConfigurationManagerAttributes() { Order = 1 })); SetupConfigEventHandlers(); } diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 91bc7400..2d2e1a6f 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -213,6 +213,9 @@ public async void Init() private void OnSideEffectPacketReceived(SideEffectPacket packet) { +#if DEBUG + logger.LogWarning("OnSideEffectPacketReceived: Received"); +#endif GameWorld gameWorld = Singleton.Instance; if (gameWorld == null) { @@ -231,7 +234,9 @@ private void OnSideEffectPacketReceived(SideEffectPacket packet) { sideEffectComponent.Value = packet.Value; item.RaiseRefreshEvent(false, false); + return; } + logger.LogError("OnSideEffectPacketReceived: SideEffectComponent was not found!"); } private void OnCorpsePositionPacketReceived(CorpsePositionPacket packet) @@ -1086,11 +1091,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..5358424c 100644 --- a/Fika.Core/Networking/FikaServer.cs +++ b/Fika.Core/Networking/FikaServer.cs @@ -298,6 +298,9 @@ public async Task Init() private void OnSideEffectPacketReceived(SideEffectPacket packet, NetPeer peer) { +#if DEBUG + logger.LogWarning("OnSideEffectPacketReceived: Received"); +#endif SendDataToAll(ref packet, DeliveryMethod.ReliableOrdered, peer); GameWorld gameWorld = Singleton.Instance; @@ -316,9 +319,14 @@ private void OnSideEffectPacketReceived(SideEffectPacket packet, NetPeer peer) Item item = gstruct2.Value; if (item.TryGetItemComponent(out SideEffectComponent sideEffectComponent)) { +#if DEBUG + logger.LogInfo("Setting value to: " + packet.Value + ", original: " + sideEffectComponent.Value); +#endif sideEffectComponent.Value = packet.Value; item.RaiseRefreshEvent(false, false); + return; } + logger.LogError("OnSideEffectPacketReceived: SideEffectComponent was not found!"); } private void OnLoadingProfilePacketReceived(LoadingProfilePacket packet, NetPeer peer) 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) { diff --git a/Fika.Core/UI/Patches/MenuTaskBar_Patch.cs b/Fika.Core/UI/Patches/MenuTaskBar_Patch.cs index ffeda5dc..1d6c0226 100644 --- a/Fika.Core/UI/Patches/MenuTaskBar_Patch.cs +++ b/Fika.Core/UI/Patches/MenuTaskBar_Patch.cs @@ -74,7 +74,7 @@ public static void Postfix(Dictionary ____toggleButto { Singleton.Instance.PlayUISound(EUISoundType.ButtonBottomBarClick); string installDir = Environment.CurrentDirectory; - string fikaDir = Path.Combine(installDir, @"\user\fika"); + string fikaDir = installDir + @"\user\fika"; if (!string.IsNullOrEmpty(installDir)) {