From b8b537981c27518c4a499a557da3ed1ba9cb39fe Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Wed, 15 Apr 2026 11:45:16 +0200 Subject: [PATCH] Fix kicking, Update Privacy Policy for EOS UserIdToken validation check --- Modules/LobbySharingAPI.cs | 8 ++++---- Modules/OptionHolder.cs | 4 ---- Patches/Crowded.cs | 4 ++-- Patches/GameOptionsMenuPatch.cs | 6 +++--- Patches/GameStartManagerPatch.cs | 1 + Patches/OnGameStartedPatch.cs | 1 + README.md | 4 +++- Resources/Lang/en_US.jsonc | 1 - 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Modules/LobbySharingAPI.cs b/Modules/LobbySharingAPI.cs index 56494f69c..302f25c70 100644 --- a/Modules/LobbySharingAPI.cs +++ b/Modules/LobbySharingAPI.cs @@ -34,18 +34,17 @@ public static class LobbySharingAPI string hostName = Main.AllPlayerNames[PlayerControl.LocalPlayer.PlayerId].RemoveHtmlTags(); string map = Options.RandomMapsMode.GetBool() ? "Random" : SubmergedCompatibility.Loaded && Main.NormalOptions.MapId == 6 ? "Submerged" : Main.CurrentMap.ToString(); string gameMode = Options.EnableAutoGMRotation.GetBool() ? "Rotating" : Options.CurrentGameMode.ToString(); - string hostHashedPuid = Options.SendHashedPuidToUseLinkedAccount.GetBool() ? PlayerControl.LocalPlayer.GetClient().GetHashedPuid() : string.Empty; const string version = $"EHR v{Main.PluginDisplayVersion}"; - Main.Instance.StartCoroutine(SendLobbyCreatedRequest(roomCode, serverName, language, version, gameId, hostName, map, gameMode, hostHashedPuid)); + Main.Instance.StartCoroutine(SendLobbyCreatedRequest(roomCode, serverName, language, version, gameId, hostName, map, gameMode)); } - private static IEnumerator SendLobbyCreatedRequest(string roomCode, string serverName, string language, string version, int gameId, string hostName, string map, string gameMode, string hostHashedPuid) + private static IEnumerator SendLobbyCreatedRequest(string roomCode, string serverName, string language, string version, int gameId, string hostName, string map, string gameMode) { long timeSinceLastRequest = Utils.TimeStamp - LastRequestTimeStamp; if (timeSinceLastRequest < BufferTime) yield return new WaitForSecondsRealtime(BufferTime); LastRequestTimeStamp = Utils.TimeStamp; - var jsonData = $"{{\"roomCode\":\"{roomCode}\",\"serverName\":\"{serverName}\",\"language\":\"{language}\",\"version\":\"{version}\",\"gameId\":\"{gameId}\",\"hostName\":\"{hostName}\",\"map\":\"{map}\",\"gameMode\":\"{gameMode}\",\"hostHashedPuid\":\"{hostHashedPuid}\"}}"; + var jsonData = $"{{\"roomCode\":\"{roomCode}\",\"serverName\":\"{serverName}\",\"language\":\"{language}\",\"version\":\"{version}\",\"gameId\":\"{gameId}\",\"hostName\":\"{hostName}\",\"map\":\"{map}\",\"gameMode\":\"{gameMode}\"}}"; byte[] jsonToSend = new UTF8Encoding().GetBytes(jsonData); var request = new UnityWebRequest("https://app.gurge44.eu/lobby_created", "POST") @@ -56,6 +55,7 @@ public static class LobbySharingAPI request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("User-Agent", $"{Main.ModName} v{Main.PluginVersion} - {Regex.Replace(hostName, @"[^\x20-\x7E]", "")}"); + request.SetRequestHeader("Authorization", "Bearer " + EOSManager.Instance.UserIDToken); yield return request.SendWebRequest(); LastRequestTimeStamp = Utils.TimeStamp; diff --git a/Modules/OptionHolder.cs b/Modules/OptionHolder.cs index 772ed3a69..74aeb248e 100644 --- a/Modules/OptionHolder.cs +++ b/Modules/OptionHolder.cs @@ -737,7 +737,6 @@ public static class Options public static OptionItem PhantomCanGuess; public static OptionItem PostLobbyCodeToEHRWebsite; - public static OptionItem SendHashedPuidToUseLinkedAccount; public static OptionItem LobbyUpdateInterval; public static OptionItem StoreCompletedAchievementsOnEHRDatabase; public static OptionItem AllCrewRolesHaveVanillaColor; @@ -1764,9 +1763,6 @@ public static class Options PostLobbyCodeToEHRWebsite = new BooleanOptionItem(19422, "PostLobbyCodeToEHRDiscordServer", true, TabGroup.SystemSettings) .SetHeader(true); - - SendHashedPuidToUseLinkedAccount = new BooleanOptionItem(19501, "SendHashedPuidToUseLinkedAccount", true, TabGroup.SystemSettings) - .SetParent(PostLobbyCodeToEHRWebsite); LobbyUpdateInterval = new IntegerOptionItem(19502, "LobbyUpdateInterval", new(10, 30, 5), 30, TabGroup.SystemSettings) .SetParent(PostLobbyCodeToEHRWebsite) diff --git a/Patches/Crowded.cs b/Patches/Crowded.cs index 80eee9381..8c65dd762 100644 --- a/Patches/Crowded.cs +++ b/Patches/Crowded.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Il2CppInterop.Runtime.InteropTypes.Arrays; using System.Linq; using AmongUs.GameOptions; using HarmonyLib; using Il2CppInterop.Runtime.Attributes; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using TMPro; using UnityEngine; @@ -97,7 +97,7 @@ internal static class Crowded playerButton.OnClick.AddListener((Action)(() => { byte maxPlayers = byte.Parse(text.text); - int maxImp = Mathf.Min(__instance.GetTargetOptions().NumImpostors, maxPlayers / 2); + int maxImp = Math.Clamp(Mathf.Min(__instance.GetTargetOptions().NumImpostors, maxPlayers / 2), 1, 3); __instance.GetTargetOptions().SetInt(Int32OptionNames.NumImpostors, maxImp); __instance.ImpostorButtons[1].TextMesh.text = maxImp.ToString(); __instance.SetMaxPlayersButtons(maxPlayers); diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 5de1381c0..3dc3b1aad 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -2,15 +2,15 @@ using System; using System.Collections; using System.Linq; using BepInEx.Unity.IL2CPP.Utils.Collections; +using EHR.Gamemodes; using EHR.Modules; using EHR.Patches; +using EHR.Roles; using HarmonyLib; using Il2CppSystem.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.Events; -using EHR.Roles; -using EHR.Gamemodes; // ReSharper disable PossibleLossOfFraction @@ -672,7 +672,7 @@ public static class NumberOptionPatch __instance.Increment = 0.05f; __instance.Value = (float)Math.Round(__instance.Value, 2); break; - case StringNames.GameNumImpostors: + case StringNames.GameNumImpostors when GameStates.CurrentServerType != GameStates.ServerType.Vanilla: __instance.ValidRange = new(0, Crowded.MaxImpostors); __instance.Value = (float)Math.Round(__instance.Value, 2); if (DebugModeManager.AmDebugger) __instance.ValidRange.min = 0; diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index 06c3a77c8..924d2bda5 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -613,6 +613,7 @@ 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 f5c1483b0..1e20b46d5 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -287,6 +287,7 @@ 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); } diff --git a/README.md b/README.md index 900038a19..9131bdd4b 100644 --- a/README.md +++ b/README.md @@ -650,7 +650,7 @@ When using this integration, we collect the following non-personal information: - **Map Name:** The name of the map selected for the game (e.g., Skeld, Polus, Submerged). - **Game Mode:** The selected game mode (e.g., Standard, Room Rush, Free For All, Bed Wars). - **Lobby Status:** The current status of the lobby (e.g., In Lobby, In Game, Ended). -- **Hashed PUID of the Host:** An encrypted version of the host's product user ID (see below), if `I have an EHR account linked to my discord account, send my hashed PUID to let discord users identify me` is enabled in System Settings, otherwise this field is left empty. +- **EOS UserIdToken:** The user's EOS User ID Token. Furthermore, the following information is collected to enhance the user experience: @@ -666,7 +666,9 @@ Furthermore, the following information is collected to enhance the user experien The collected information is used solely for the following purposes: - To notify players about available lobbies via the designated Discord server. +- To make sure, that only genuine players can create lobbies on our server (prevent DDoS and fake data spam). - To update the status of the lobby in real time, enhancing coordination among players. +- To provide lobby-management features for hosts, and track hosting statistics on Discord. - To ensure, that progress in custom achievements isn't lost when updating or reinstalling the mod. **No personal data** or any other information beyond what is listed above is collected or processed. diff --git a/Resources/Lang/en_US.jsonc b/Resources/Lang/en_US.jsonc index 615574e0b..7d5040dd3 100644 --- a/Resources/Lang/en_US.jsonc +++ b/Resources/Lang/en_US.jsonc @@ -11402,7 +11402,6 @@ "SeeMedicAndTarget": "Medic+Shielded", "SeeNoone": "Nothing", "SeeTarget": "Shielded", - "SendHashedPuidToUseLinkedAccount": "I have an EHR account linked to my discord account, send my hashed PUID to let discord users identify me", "SewedBySeamstress": "<#ffff44>You were sewed together with someone by the {0}!", "Shapeshifter": "Shapeshifter", "ShareLobby": "Allow EHR-Chan Shares Lobby Code To Discord",