diff --git a/Modules/GameOptionsSender/GameOptionsSender.cs b/Modules/GameOptionsSender/GameOptionsSender.cs index 358cb9eb2..44c91a10f 100644 --- a/Modules/GameOptionsSender/GameOptionsSender.cs +++ b/Modules/GameOptionsSender/GameOptionsSender.cs @@ -19,7 +19,7 @@ public abstract class GameOptionsSender private Il2CppStructArray BuildOptionArray() { - IGameOptions opt = BuildSendableGameOptions(); + IGameOptions opt = BuildGameOptions(); var currentGameMode = AprilFoolsMode.IsAprilFoolsModeToggledOn ? opt.AprilFoolsOnMode : opt.GameMode; // option => byte[] @@ -109,59 +109,6 @@ public abstract class GameOptionsSender } public abstract IGameOptions BuildGameOptions(); - - protected IGameOptions BuildSendableGameOptions() - { - return SanitizeForOfficialServer(BuildGameOptions()); - } - - protected static IGameOptions SanitizeForOfficialServer(IGameOptions opt) - { - if (CurrentServerType != ServerType.Vanilla || opt == null || !opt.TryCast(out NormalGameOptionsV10 normalOpt)) - return opt; - - int originalMaxPlayers = normalOpt.MaxPlayers; - int originalImpostors = normalOpt.NumImpostors; - int originalKillDistance = normalOpt.KillDistance; - float originalPlayerSpeed = normalOpt.PlayerSpeedMod; - bool changed = false; - - if (normalOpt.MaxPlayers > 15) - { - normalOpt.SetInt(Int32OptionNames.MaxPlayers, 15); - changed = true; - } - - int impostors = Mathf.Clamp(normalOpt.NumImpostors, 1, 3); - if (impostors != normalOpt.NumImpostors) - { - normalOpt.SetInt(Int32OptionNames.NumImpostors, impostors); - changed = true; - } - - int killDistance = Mathf.Clamp(normalOpt.KillDistance, 0, 2); - if (killDistance != normalOpt.KillDistance) - { - normalOpt.SetInt(Int32OptionNames.KillDistance, killDistance); - changed = true; - } - - float playerSpeed = Mathf.Clamp(normalOpt.PlayerSpeedMod, Main.MinSpeed, 3f); - if (!Mathf.Approximately(playerSpeed, normalOpt.PlayerSpeedMod)) - { - normalOpt.SetFloat(FloatOptionNames.PlayerSpeedMod, playerSpeed); - changed = true; - } - - if (changed) - { - Logger.Warn( - $"Clamped outgoing official game options: MaxPlayers={originalMaxPlayers}->{normalOpt.MaxPlayers}, NumImpostors={originalImpostors}->{normalOpt.NumImpostors}, KillDistance={originalKillDistance}->{normalOpt.KillDistance}, PlayerSpeedMod={originalPlayerSpeed:0.###}->{normalOpt.PlayerSpeedMod:0.###}", - nameof(GameOptionsSender)); - } - - return normalOpt.CastFast(); - } protected virtual bool AmValid() { diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index dca0d6453..9d147e811 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -110,7 +110,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS { if (player.AmOwner) { - IGameOptions opt = BuildSendableGameOptions(); + IGameOptions opt = BuildGameOptions(); if (GameManager.Instance?.LogicComponents != null) { @@ -131,7 +131,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS { if (player.AmOwner) { - IGameOptions opt = BuildSendableGameOptions(); + IGameOptions opt = BuildGameOptions(); if (GameManager.Instance?.LogicComponents != null) { diff --git a/Patches/Crowded.cs b/Patches/Crowded.cs index a7e527297..32bea3448 100644 --- a/Patches/Crowded.cs +++ b/Patches/Crowded.cs @@ -98,7 +98,7 @@ internal static class Crowded playerButton.OnClick.AddListener((Action)(() => { byte maxPlayers = byte.Parse(text.text); - int maxImp = Math.Clamp(Mathf.Min(__instance.GetTargetOptions().NumImpostors, maxPlayers / 2), 1, 3); + int maxImp = Mathf.Min(__instance.GetTargetOptions().NumImpostors, maxPlayers / 2); __instance.GetTargetOptions().SetInt(Int32OptionNames.NumImpostors, maxImp); __instance.ImpostorButtons[1].TextMesh.text = maxImp.ToString(); __instance.SetMaxPlayersButtons(maxPlayers); @@ -379,10 +379,7 @@ internal static class Crowded if (CurrentGameOptions.MaxPlayers > 15) CurrentGameOptions.SetInt(Int32OptionNames.MaxPlayers, 15); - if (CurrentGameOptions.NumImpostors > 3) - CurrentGameOptions.SetInt(Int32OptionNames.NumImpostors, 3); - - if (CurrentGameOptions.NumImpostors < 1) + if (CurrentGameOptions.NumImpostors < 0) CurrentGameOptions.SetInt(Int32OptionNames.NumImpostors, 1); } } diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index aed36237f..720764d0f 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -635,7 +635,7 @@ public static class ToggleOptionPatch [HarmonyPatch(typeof(NumberOption))] public static class NumberOptionPatch { - private static bool IsVanillaServer => GameStates.CurrentServerType == GameStates.ServerType.Vanilla; + //private static bool IsVanillaServer => GameStates.CurrentServerType == GameStates.ServerType.Vanilla; private static int IncrementMultiplier { @@ -669,9 +669,6 @@ public static class NumberOptionPatch __instance.Value = (float)Math.Round(__instance.Value, 2); break; case StringNames.GamePlayerSpeed: - if (IsVanillaServer) - __instance.ValidRange = new(Main.MinSpeed, 3f); - __instance.Increment = 0.05f; __instance.Value = Mathf.Clamp((float)Math.Round(__instance.Value, 2), __instance.ValidRange.min, __instance.ValidRange.max); break; @@ -681,13 +678,12 @@ public static class NumberOptionPatch __instance.Value = (float)Math.Round(__instance.Value, 2); break; case StringNames.GameNumImpostors: - __instance.ValidRange = GameStates.CurrentServerType != GameStates.ServerType.Vanilla - ? new(0, Crowded.MaxImpostors) : new(1, 3); + __instance.ValidRange = new(0, Crowded.MaxImpostors); __instance.Value = Mathf.Clamp((float)Math.Round(__instance.Value, 2), __instance.ValidRange.min, __instance.ValidRange.max); if (DebugModeManager.AmDebugger) __instance.ValidRange.min = 0; break; case StringNames.CapacityLabel: - __instance.ValidRange = IsVanillaServer ? new(4, 15) : new(4, 127); + __instance.ValidRange = new(4, 127); __instance.Value = Mathf.Clamp(__instance.Value, __instance.ValidRange.min, __instance.ValidRange.max); break; } @@ -816,27 +812,12 @@ public static class StringOptionPatch { private static long HelpShowEndTS; - private static bool IsVanillaServer => GameStates.CurrentServerType == GameStates.ServerType.Vanilla; - - private static void ClampOfficialStringOption(StringOption option) - { - if (!IsVanillaServer) return; - - switch (option.Title) - { - case StringNames.GameKillDistance: - option.Value = Mathf.Clamp(option.Value, 0, Math.Min(2, option.Values.Length - 1)); - break; - } - } - [HarmonyPatch(nameof(StringOption.Initialize))] [HarmonyPrefix] private static bool InitializePrefix(StringOption __instance) { - if (__instance.name.StartsWith(nameof(OnlinePresetsManager))) return true; - ClampOfficialStringOption(__instance); - + if (__instance.name.StartsWith(nameof(OnlinePresetsManager))) return true; + if (ModGameOptionsMenu.OptionList.TryGetValue(__instance, out int index)) { OptionItem item = OptionItem.AllOptions[index]; @@ -1040,8 +1021,6 @@ public static class StringOptionPatch return false; } - ClampOfficialStringOption(__instance); - if (ModGameOptionsMenu.OptionList.TryGetValue(__instance, out int index)) { __instance.MinusBtn.SetInteractable(true); diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index 924d2bda5..06c3a77c8 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -613,7 +613,6 @@ internal static class UnrestrictedNumImpostorsPatch { public static bool Prefix(ref int __result) { - if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla) return true; __result = Main.NormalOptions.NumImpostors; return false; } diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index ab093af6d..23054ed6b 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -289,7 +289,6 @@ internal static class ChangeRoleSettings { (OptionItem MinSetting, OptionItem MaxSetting) impLimits = Options.FactionMinMaxSettings[Team.Impostor]; int optImpNum = IRandom.Instance.Next(impLimits.MinSetting.GetInt(), impLimits.MaxSetting.GetInt() + 1); - if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla) optImpNum = Math.Clamp(optImpNum, 1, 3); GameOptionsManager.Instance.currentNormalGameOptions.NumImpostors = optImpNum; GameOptionsManager.Instance.CurrentGameOptions.SetInt(Int32OptionNames.NumImpostors, optImpNum); } @@ -395,12 +394,12 @@ internal static class ChangeRoleSettings Damocles.Initialize(); Stressed.Init(); Asthmatic.Init(); - DoubleShot.Init(); - Circumvent.Init(); - Commited.Init(); - Reroll.Init(); - } - catch (Exception ex) { Logger.Exception(ex, "Init Roles"); } + DoubleShot.Init(); + Circumvent.Init(); + Commited.Init(); + Reroll.Init(); + } + catch (Exception ex) { Logger.Exception(ex, "Init Roles"); } try {