Fixes for modded protocol

This commit is contained in:
D1GQ committed 2024-07-30 23:29:28 -05:00
1 parent 56bc238cdc
commit c109c9489c
3 files changed
+32 -28

No files matched your search

+19 -12
View File
@@ -117,7 +117,7 @@ class AntiCheat
MessageReader reader = Oldreader;
try
{
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || reader == null || !IsEnabled || !Main.AntiCheat.Value) return;
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.GetIsBetterHost() || reader == null || !IsEnabled || !Main.AntiCheat.Value) return;
RoleTypes? Role = player?.Data?.RoleType;
Role ??= RoleTypes.Crewmate;
@@ -125,6 +125,23 @@ class AntiCheat
bool IsCrewmate = !player.IsImpostorTeam();
string hashPuid = Utils.GetHashPuid(player);
/*
if (callId is (byte)RpcCalls.SendChat)
{
if (player.IsAlive() && GameStates.IsInGamePlay && !GameStates.IsMeeting && !GameStates.IsExilling)
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
var text = reader.ReadString();
if (text.Contains('<') || text.Contains('>') || text.Length > 120)
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
}
return;
}
*/
if (callId is (byte)RpcCalls.EnterVent or (byte)RpcCalls.ExitVent)
{
if ((IsCrewmate && Role != RoleTypes.Engineer) || player.Data.IsDead)
@@ -157,16 +174,6 @@ class AntiCheat
return;
}
/*
if (callId is (byte)RpcCalls.SendChat or (byte)RpcCalls.SendQuickChat)
{
if (player.IsAlive() && GameStates.IsInGamePlay && !GameStates.IsMeeting && !GameStates.IsExilling)
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
return;
}
*/
if (callId is (byte)RpcCalls.SetLevel)
{
if (reader.BytesRemaining > 0)
@@ -242,7 +249,7 @@ class AntiCheat
MessageReader reader = Oldreader;
try
{
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || reader == null || !IsEnabled || !Main.AntiCheat.Value) return true;
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.GetIsBetterHost() || reader == null || !IsEnabled || !Main.AntiCheat.Value) return true;
RoleTypes Role = player.Data.RoleType;
bool IsImpostor = player.IsImpostorTeam();
+4 -2
View File
@@ -37,14 +37,16 @@ class BetterHostManager
LastPlayeridealSpeed[player] = idealSpeed;
var lastPos = player.GetCustomPosition();
// Get delayed position
_ = new LateTask(() =>
{
if (player != null)
{
LastPlayerPosDelay[player] = player.GetCustomPosition();
LastPlayerPosDelay[player] = lastPos;
}
}, 1.25f, shoudLog: false);
}, 1.8f, shoudLog: false);
// Prevent player from moving in certain States
if (player.CanMove)
+9 -14
View File
@@ -77,15 +77,7 @@ internal static class RPC
player.Exiled();
}
public static async Task WaitForChatCooldown()
{
while (3f - HudManager.Instance.Chat.timeSinceLastMessage > 0f)
{
await Task.Delay(100);
}
}
public static async void SendHostChatToPlayer(PlayerControl player, string text, string? title = "", bool sendToBetterUser = true)
public static void SendHostChatToPlayer(PlayerControl player, string text, string? title = "", bool sendToBetterUser = true)
{
if (!GameStates.IsHost) return;
@@ -117,12 +109,15 @@ internal static class RPC
messageWriter.Write(text);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(asPlayer.NetId, (byte)RpcCalls.SetName, SendOption.None, player.GetClientId());
writer2.Write(asPlayer.Data.NetId);
writer2.Write(oldName);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
_ = new LateTask(() =>
{
MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(asPlayer.NetId, (byte)RpcCalls.SetName, SendOption.None, player.GetClientId());
writer2.Write(asPlayer.Data.NetId);
writer2.Write(oldName);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
SyncAllNames();
SyncAllNames(force: true);
}, 0.08f, shoudLog: false);
}
public static void HandleRPC(PlayerControl player, byte callId, MessageReader reader)