From b62215b3b82a94d6a797a2562af319890959a5f3 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Fri, 6 Dec 2024 08:38:35 -0600 Subject: [PATCH] fix host name color --- .../AntiCheat/RPCHandlers/SetNameHandler.cs | 5 +++++ .../RPCHandlers/UpdateSystemHandler.cs | 18 +++++++----------- Patches/PlayerControlPatch.cs | 6 ++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Modules/AntiCheat/RPCHandlers/SetNameHandler.cs b/Modules/AntiCheat/RPCHandlers/SetNameHandler.cs index e8e6871..54dbccb 100644 --- a/Modules/AntiCheat/RPCHandlers/SetNameHandler.cs +++ b/Modules/AntiCheat/RPCHandlers/SetNameHandler.cs @@ -8,6 +8,11 @@ public class SetNameHandler : RPCHandler { public override byte CallId => (byte)RpcCalls.SetName; + public override void Handle(PlayerControl? sender, MessageReader reader) + { + Utils.DirtyAllNames(); + } + public override bool HandleAntiCheatCancel(PlayerControl? sender, MessageReader reader) { var name = reader.ReadString(); diff --git a/Modules/AntiCheat/RPCHandlers/UpdateSystemHandler.cs b/Modules/AntiCheat/RPCHandlers/UpdateSystemHandler.cs index f761520..03a1dd5 100644 --- a/Modules/AntiCheat/RPCHandlers/UpdateSystemHandler.cs +++ b/Modules/AntiCheat/RPCHandlers/UpdateSystemHandler.cs @@ -34,16 +34,14 @@ public class UpdateSystemHandler : RPCHandler public static bool CheckConsoleDistance(PlayerControl? player, float distance = 2f) where T : PlayerTask, new() { bool isClose = false; - Console[]? consoles = new T().FindConsoles().ToArray(); - foreach (var console in consoles) + Vector2[] consolesPos = new T().FindConsolesPos().ToArray(); + if (consolesPos != null) { - if (console == null) + foreach (var consolePos in consolesPos) { - isClose = true; - break; + isClose = Vector2.Distance(consolePos, player.GetCustomPosition()) < distance; + if (isClose) break; } - isClose = Vector2.Distance(console.transform.position, player.GetCustomPosition()) < distance; - if (isClose) break; } return isClose; @@ -141,7 +139,6 @@ public class UpdateSystemHandler : RPCHandler private static bool HandleHqHudSystem(PlayerControl? sender, HqHudSystemType hqHudSystem, byte count) { - Logger.InGame("TEST"); if ((count & 128) > 0) // Direct sabotage call from client, which is not possible, only the host should have this count when HandleSabotageSystem it's called { return false; @@ -162,7 +159,6 @@ public class UpdateSystemHandler : RPCHandler private static bool HandleHudOverrideSystem(PlayerControl? sender, HudOverrideSystemType hudOverrideSystem, byte count) { - Logger.InGame("TEST"); if (count == 128) // Direct sabotage call from client, which is not possible, only the host should have this count when HandleSabotageSystem it's called { return false; @@ -208,7 +204,6 @@ public class UpdateSystemHandler : RPCHandler private static bool HandleReactorSystem(PlayerControl? sender, ReactorSystemType reactorSystem, byte count) { - Logger.InGame(count.ToString()); if (count == 128 || count == 16) // Direct sabotage call from client, which is not possible, only the host should have this count when HandleSabotageSystem it's called { return false; @@ -230,7 +225,6 @@ public class UpdateSystemHandler : RPCHandler { if (tuple.Item1 == sender.PlayerId) { - Logger.InGame("TEST 1"); return false; } } @@ -271,10 +265,12 @@ public class UpdateSystemHandler : RPCHandler return false; } + /* if (!CheckConsoleDistance(sender)) { return false; } + */ return true; } diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 5626ee7..3da6885 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -228,10 +228,8 @@ class PlayerControlPatch [HarmonyPrefix] public static bool RpcSetName_Prefix(PlayerControl __instance, [HarmonyArgument(0)] string name) { - if (!GameState.IsVanillaServer && Utils.IsHtmlText(name)) - { - return false; - } + + Utils.DirtyAllNames(); return true; }