From 2141a2c15fa4fd91bab2a2aae141c40f69ca8eac Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sat, 27 Jul 2024 23:24:42 -0500 Subject: [PATCH] Revert "null checks and error fixes" This reverts commit 0c590ad26382ecd3d99a189222824c50355f7105. --- Patches/PlayerControlPatch.cs | 4 +-- Patches/PlayerJoinAndLeftPatch.cs | 48 ++++++++++++++----------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index c183cd5..e75b017 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -70,7 +70,7 @@ class PlayerControlPatch public static void SetPlayerInfo(PlayerControl player) { - if (player == null || player.Data == null) return; + if (player == null) return; // Set player text info if (player.DataIsCollected() != true) @@ -203,7 +203,7 @@ class PlayerControlPatch string Role = $"{player.GetRoleName()}"; if (!player.IsImpostorTeammate()) { - if (PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.IsAlive() && player != PlayerControl.LocalPlayer) + if (PlayerControl.LocalPlayer.IsAlive() && player != PlayerControl.LocalPlayer) { if (!DebugMenu.RevealRoles) { diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 197e046..82d86d9 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -10,34 +10,30 @@ class OnGameJoinedPatch { public static void Postfix(/*AmongUsClient __instance*/) { - try + PlayerControlPatch.infotime = 0f; + + AntiCheat.PauseAntiCheat(); + + // Fix host icon in lobby on modded servers + if (!GameStates.IsVanillaServer) { - PlayerControlPatch.infotime = 0f; - - AntiCheat.PauseAntiCheat(); - - // Fix host icon in lobby on modded servers - if (!GameStates.IsVanillaServer) - { - var host = AmongUsClient.Instance.GetHost().Character; - host.SetColor(-2); - host.SetColor(host.CurrentOutfit.ColorId); - } - - _ = new LateTask(() => - { - // Send Better Among Us Check RPC - if (GameStates.IsInGame) - { - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.BetterCheck, SendOption.None, -1); - messageWriter.Write((byte)PlayerControl.LocalPlayer.NetId); - AmongUsClient.Instance.FinishRpcImmediately(messageWriter); - } - }, 1.5f, "OnGameJoinedPatch"); - - Logger.Log($"Successfully joined {GameCode.IntToGameName(AmongUsClient.Instance.GameId)}", "OnGameJoinedPatch"); + var host = AmongUsClient.Instance.GetHost().Character; + host.SetColor(-2); + host.SetColor(host.CurrentOutfit.ColorId); } - catch { }; + + _ = new LateTask(() => + { + // Send Better Among Us Check RPC + if (GameStates.IsInGame) + { + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.BetterCheck, SendOption.None, -1); + messageWriter.Write((byte)PlayerControl.LocalPlayer.NetId); + AmongUsClient.Instance.FinishRpcImmediately(messageWriter); + } + }, 1.5f, "OnGameJoinedPatch"); + + Logger.Log($"Successfully joined {GameCode.IntToGameName(AmongUsClient.Instance.GameId)}", "OnGameJoinedPatch"); } } [HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnPlayerJoined))]