we're so back

This commit is contained in:
Gurge44 committed 2026-06-26 09:57:25 +02:00
1 parent c614f13aae
commit ba5fa77b7b
19 files changed
+110 -75

No files matched your search

+1 -1
View File
@@ -1694,7 +1694,7 @@ public static class BedWars
if (count > 1)
{
sb.Append(vanillaServer ? "X" : "<sub>");
sb.Append(vanillaServer ? "x" : "<sub>");
sb.Append(count);
if (!vanillaServer) sb.Append("</sub>");
}
+1
View File
@@ -982,6 +982,7 @@ public class Main : BasePlugin
IL2CPPChainloader.Instance.Finished += () =>
{
CustomLogger.ClearLog();
BepInEx.Logging.Logger.Listeners.Add(new HtmlLogListener());
StartCoroutine(ModNewsFetcher.FetchNews());
+1 -1
View File
@@ -166,7 +166,7 @@ public static class BanManager
if (Regex.IsMatch(name, line))
{
AmongUsClient.Instance.KickPlayer(player.OwnerId, false);
AmongUsClient.Instance.KickPlayer(player.OwnerId, Options.BanDenyNameListPlayers.GetBool());
Logger.SendInGame(string.Format(GetString("Message.KickedByDenyName"), name, line), Color.yellow);
Logger.Info($"{name} was kicked because their name matched \"{line}\".", "Kick");
return true;
+1 -1
View File
@@ -217,7 +217,7 @@ public static class Camouflage
Logger.Info($"Setting new outfit: {newOutfit.GetString()}", "Camouflage.RpcSetSkin");
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla)
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla && !string.IsNullOrWhiteSpace(newOutfit.PetId))
{
target.RpcChangeOutfitByData(newOutfit);
return;
+18 -15
View File
@@ -241,22 +241,25 @@ namespace EHR
try
{
if (!AmongUsClient.Instance.AmHost) return;
// max ~60 calls per second in total
int updateFrequency;
if (!ConstantlyChangesPosition)
{
updateFrequency = 30;
}
else
{
(int trueCount, int falseCount) = AllObjects.SplitCount(x => x.ConstantlyChangesPosition);
updateFrequency = trueCount / 2 + falseCount;
}
if (++SnapToSendFrameCount < updateFrequency) return;
SnapToSendFrameCount = 0;
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla)
{
// max ~60 calls per second in total
int updateFrequency;
if (!ConstantlyChangesPosition)
{
updateFrequency = 30;
}
else
{
(int trueCount, int falseCount) = AllObjects.SplitCount(x => x.ConstantlyChangesPosition);
updateFrequency = trueCount / 2 + falseCount;
}
if (++SnapToSendFrameCount < updateFrequency) return;
SnapToSendFrameCount = 0;
}
if (AmongUsClient.Instance.AmClient)
{
-2
View File
@@ -104,11 +104,9 @@ internal static class CustomRoleSelector
switch (role)
{
case CustomRoles.Butcher when GameStates.CurrentServerType == GameStates.ServerType.Vanilla:
case CustomRoles.Bargainer when Main.LIMap:
case CustomRoles.AntiAdminer when Main.LIMap:
case CustomRoles.CameraMan when Main.LIMap:
case CustomRoles.Ventriloquist when GameStates.CurrentServerType == GameStates.ServerType.Vanilla:
case CustomRoles.Weatherman when Main.LIMap || GameStates.CurrentServerType == GameStates.ServerType.Vanilla:
case CustomRoles.Doctor when Options.EveryoneSeesDeathReasons.GetBool():
case CustomRoles.LovingCrewmate or CustomRoles.LovingImpostor when !loversData.Spawning:
+28 -1
View File
@@ -5,6 +5,7 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx.Logging;
using EHR.Modules;
using EHR.Patches;
using UnityEngine;
@@ -155,6 +156,30 @@ internal static class Logger
}
}
public sealed class HtmlLogListener : ILogListener
{
public void LogEvent(object sender, LogEventArgs eventArgs)
{
var sb = new StringBuilder();
sb.Append('[');
sb.Append(eventArgs.Source.SourceName);
sb.Append(']');
sb.Append(' ');
sb.Append(System.Net.WebUtility.HtmlEncode(eventArgs.Data.ToString()));
sb.Replace("\r\n", "<br>");
sb.Replace("\n", "<br>");
CustomLogger.Instance.Log(eventArgs.Level.ToString(), sb, multiLine: true);
}
public LogLevel LogLevelFilter => LogLevel.All;
public void Dispose()
{
}
}
public class CustomLogger
{
public static readonly string LOGFilePath = Path.Combine(Main.DataPath, OperatingSystem.IsAndroid() ? "EHR_Logs" : "BepInEx", "log.html");
@@ -192,7 +217,7 @@ public class CustomLogger
""";
private static CustomLogger PrivateInstance;
private float timer = 1f;
private float timer = 0.5f;
private readonly StringBuilder Builder;
@@ -262,6 +287,8 @@ public class CustomLogger
#if DEBUG
Finish(false);
#else
timer = 0.5f;
#endif
}
+8 -3
View File
@@ -1500,7 +1500,7 @@ internal static class ExtendedPlayerControl
if (phantom && Options.CurrentGameMode != CustomGameMode.Standard) return;
if (!Main.Invisible.Add(player.PlayerId)) return;
if (GameStates.CurrentServerType != GameStates.ServerType.Vanilla) player.RpcSetPet("");
player.RpcSetPet("");
if (!(phantom && PlayerControl.LocalPlayer.IsImpostor()))
player.MakeInvisible();
@@ -2392,6 +2392,12 @@ internal static class ExtendedPlayerControl
public void RpcChangePet(string petId)
{
if (player.Data.DefaultOutfit.PetId == petId) return;
if (string.IsNullOrWhiteSpace(petId))
{
player.RpcSetPet(petId);
return;
}
player.Data.DefaultOutfit.PetId = petId;
player.SyncOutfitData();
@@ -2401,8 +2407,7 @@ internal static class ExtendedPlayerControl
{
if (player.Data.DefaultOutfit.ColorId == colorId) return;
player.Data.DefaultOutfit.ColorId = colorId;
player.SyncOutfitData();
player.RpcSetColor(colorId);
}
public bool RpcChangeOutfitByData(NetworkedPlayerInfo.PlayerOutfit outfit, MessageWriter writer = null, SendOption sendOption = SendOption.Reliable, bool revertShapeshiftIfAlreadyShifted = true)
+5
View File
@@ -798,6 +798,7 @@ public static class Options
public static OptionItem AutoKickStopWordsTimes;
public static OptionItem KickMobilePlayer;
public static OptionItem ApplyDenyNameList;
public static OptionItem BanDenyNameListPlayers;
public static OptionItem KickPlayerFriendCodeNotExist;
public static OptionItem KickLowLevelPlayer;
public static OptionItem ApplyBanList;
@@ -1643,6 +1644,10 @@ public static class Options
KickMobilePlayer = new BooleanOptionItem(19301, "KickMobilePlayer", false, TabGroup.SystemSettings);
KickPlayerFriendCodeNotExist = new BooleanOptionItem(19302, "KickPlayerFriendCodeNotExist", false, TabGroup.SystemSettings, true);
ApplyDenyNameList = new BooleanOptionItem(19303, "ApplyDenyNameList", true, TabGroup.SystemSettings, true);
BanDenyNameListPlayers = new BooleanOptionItem(19320, "BanDenyNameListPlayers", false, TabGroup.SystemSettings, true)
.SetParent(ApplyDenyNameList);
ApplyBanList = new BooleanOptionItem(19304, "ApplyBanList", true, TabGroup.SystemSettings, true);
ApplyModeratorList = new BooleanOptionItem(19305, "ApplyModeratorList", true, TabGroup.SystemSettings);
ApplyVIPList = new BooleanOptionItem(19306, "ApplyVIPList", true, TabGroup.SystemSettings);
+1 -1
View File
@@ -14,7 +14,7 @@ public static class PetsHelper
public static void SetPet(PlayerControl pc, string petId)
{
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla)
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla && !string.IsNullOrWhiteSpace(petId))
{
pc.RpcChangePet(petId);
return;
+9 -15
View File
@@ -12,7 +12,6 @@ using System.Text.RegularExpressions;
using AmongUs.Data;
using AmongUs.GameOptions;
using AmongUs.InnerNet.GameDataMessages;
using BepInEx;
using EHR.Gamemodes;
using EHR.Modules;
using EHR.Patches;
@@ -1796,8 +1795,8 @@ public static class Utils
private const int RpcBaseOverhead = 16;
public static bool TempReviveHostRunning;
private static Stopwatch TempReviveHostRevertStopwatch = new();
private static Stopwatch TempReviveHostTimeSinceRevivalStopwatch = new();
/*private static Stopwatch TempReviveHostRevertStopwatch = new();
private static Stopwatch TempReviveHostTimeSinceRevivalStopwatch = new();*/
private static string[] CachedLetterOnlyHexColors = [];
private static readonly Regex ColorTagRegex = new(@"<\s*(?:color\s*=\s*)?#([0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?)\s*>", RegexOptions.Compiled);
private static readonly Dictionary<(int R, int G, int B), string> CachedColorReplacements = [];
@@ -1866,7 +1865,7 @@ public static class Utils
title = "\u27a1" + title.Replace("\u2605", "") + "\u2b05";
}
PlayerControl sender = !addToHistory || vanilla ? PlayerControl.LocalPlayer : Main.EnumerateAlivePlayerControls().MinBy(x => x.PlayerId) ?? Main.EnumeratePlayerControls().MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer;
PlayerControl sender = !addToHistory || Main.AllAlivePlayerControlsCount == 0 ? PlayerControl.LocalPlayer : Main.CachedAlivePlayerControls().MinBy(x => x.PlayerId);
if (sendTo != byte.MaxValue && receiver.AmOwner)
{
@@ -1876,7 +1875,7 @@ public static class Utils
return writer;
}
if (sender.AmOwner && sender.Data.IsDead && (sendTo == byte.MaxValue || !receiver.Data.IsDead))
/*if (sender.AmOwner && sender.Data.IsDead && (sendTo == byte.MaxValue || !receiver.Data.IsDead))
{
bool delayMessage = false;
@@ -1947,7 +1946,7 @@ public static class Utils
TempReviveHostRunning = false;
}
}
}
}*/
if (vanilla && !noSplit && !noNumberSplit)
{
@@ -4311,9 +4310,6 @@ public static class Utils
CustomNetObject.AfterMeeting();
RPCHandlerPatch.RemoveExpiredWhiteList();
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla && !PlayerControl.LocalPlayer.IsAlive())
PlayerControl.LocalPlayer.RpcMakeInvisible();
}
public static void AfterPlayerDeathTasks(PlayerControl target, bool onMeeting = false, bool disconnect = false)
@@ -4545,10 +4541,8 @@ public static class Utils
var f = Path.Combine(basePath, "EHR_Logs", t);
if (!Directory.Exists(f)) Directory.CreateDirectory(f);
var filename = $"{f}/EHR-v{Main.PluginVersion}-LOG";
FileInfo[] files = [new(Path.Combine(Paths.BepInExRootPath, "LogOutput.log")), new(CustomLogger.LOGFilePath)];
files.Do(x => x.CopyTo($"{filename}{x.Extension}"));
var filename = $"{f}/EHR-v{Main.PluginVersion}-LOG.html";
new FileInfo(CustomLogger.LOGFilePath).CopyTo(filename);
if (!open) return;
@@ -5223,7 +5217,7 @@ public static class Utils
deadBodyParent.Data.DefaultOutfit.ColorId = baseColorId;
}
public static void RpcCreateDeadBody(Vector3 position, byte colorId, PlayerControl deadBodyParent, SendOption sendOption = SendOption.Reliable)
public static void RpcCreateDeadBody(Vector3 position, byte colorId, PlayerControl deadBodyParent)
{
if (!deadBodyParent || !Main.IntroDestroyed || !AmongUsClient.Instance.AmHost) return;
@@ -5237,7 +5231,7 @@ public static class Utils
playerControl.notRealPlayer = true;
playerControl.NetTransform.SnapTo(position);
AmongUsClient.Instance.NetIdCnt += 1U;
var sender = CustomRpcSender.Create("Utils.RpcCreateDeadBody", sendOption, true, false);
var sender = CustomRpcSender.Create("Utils.RpcCreateDeadBody", SendOption.Reliable, true, false);
MessageWriter writer = sender.stream;
sender.StartMessage();
writer.StartMessage(4);
+2 -4
View File
@@ -1557,8 +1557,6 @@ internal static class ChatCommands
{
return role switch
{
CustomRoles.Butcher when GameStates.CurrentServerType == GameStates.ServerType.Vanilla => true,
CustomRoles.Ventriloquist when GameStates.CurrentServerType == GameStates.ServerType.Vanilla => true,
CustomRoles.Weatherman when Main.LIMap || GameStates.CurrentServerType == GameStates.ServerType.Vanilla => true,
CustomRoles.RoomRusher when Main.LIMap => true,
CustomRoles.Doctor when Options.EveryoneSeesDeathReasons.GetBool() => true,
@@ -2056,7 +2054,7 @@ internal static class ChatCommands
return;
}
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla || (!player.IsHost() && !Options.PlayerCanSetColor.GetBool() && !IsPlayerVIP(player.FriendCode) && !player.FriendCode.GetDevUser().up))
if (!player.IsHost() && !Options.PlayerCanSetColor.GetBool() && !IsPlayerVIP(player.FriendCode) && !player.FriendCode.GetDevUser().up)
{
Utils.SendMessage(GetString("DisableUseCommand"), player.PlayerId, importance: MessageImportance.Low);
return;
@@ -3520,7 +3518,7 @@ internal static class ChatUpdatePatch
internal static bool SendLastMessages(ref CustomRpcSender sender)
{
PlayerControl player = GameStates.CurrentServerType == GameStates.ServerType.Vanilla ? PlayerControl.LocalPlayer : GameStates.IsLobby ? Main.EnumeratePlayerControls().Without(PlayerControl.LocalPlayer).RandomElement() : Main.EnumerateAlivePlayerControls().MinBy(x => x.PlayerId) ?? Main.EnumeratePlayerControls().MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer;
PlayerControl player = GameStates.IsLobby ? Main.EnumeratePlayerControls().Without(PlayerControl.LocalPlayer).RandomElement() : Main.EnumerateAlivePlayerControls().MinBy(x => x.PlayerId) ?? Main.EnumeratePlayerControls().MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer;
if (player == null) return false;
bool wasCleared = false;
+5 -14
View File
@@ -321,7 +321,7 @@ public static class ChatManager
public static void ClearChat(params IReadOnlyList<PlayerControl> targets)
{
if (!AmongUsClient.Instance.AmHost) return;
PlayerControl player = GameStates.CurrentServerType == GameStates.ServerType.Vanilla ? PlayerControl.LocalPlayer : Main.EnumerateAlivePlayerControls().MinBy(x => x.PlayerId) ?? Main.EnumeratePlayerControls().MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer;
PlayerControl player = Main.AllAlivePlayerControlsCount == 0 ? PlayerControl.LocalPlayer : Main.CachedAlivePlayerControls().MinBy(x => x.PlayerId);
if (!player) return;
if (targets.Count == 0 || targets.Count >= Main.AllAlivePlayerControlsCount) SendEmptyMessage(null);
else targets.Do(SendEmptyMessage);
@@ -333,19 +333,10 @@ public static class ChatManager
bool toLocalPlayer = !toEveryone && receiver.AmOwner;
if (HudManager.InstanceExists && (toLocalPlayer || toEveryone)) HudManager.Instance.Chat.AddChat(player, "<size=32767>.");
if (toLocalPlayer) return;
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla)
{
byte to = toEveryone ? byte.MaxValue : receiver.PlayerId;
Utils.SendMessage("<size=32767>.", to, "\n", force: true, addToHistory: false, importance: MessageImportance.High);
}
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SendChat, SendOption.Reliable, toEveryone ? -1 : receiver.OwnerId);
writer.Write("<size=32767>.");
writer.Write(true);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SendChat, SendOption.Reliable, toEveryone ? -1 : receiver.OwnerId);
writer.Write("<size=32767>.");
writer.Write(true);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
}
@@ -0,0 +1,21 @@
using System;
using HarmonyLib;
namespace EHR.Patches;
// By https://github.com/TouseefX
[HarmonyPatch(typeof(PassiveButton))]
internal static class PassiveButtonClickCrashFixPatch
{
[HarmonyPatch(nameof(PassiveButton.ReceiveClickDown)), HarmonyPrefix]
public static bool ReceiveClickDownPrefix(PassiveButton __instance)
{
return __instance != null && __instance.Pointer != IntPtr.Zero;
}
[HarmonyPatch(nameof(PassiveButton.ReceiveClickUp)), HarmonyPrefix]
public static bool ReceiveClickUpPrefix(PassiveButton __instance)
{
return __instance != null && __instance.Pointer != IntPtr.Zero;
}
}
+1 -1
View File
@@ -1313,7 +1313,7 @@ internal static class ReportDeadBodyPatch
}); }
catch (Exception e) { ThrowException(e); }
try { if (Lovers.PrivateChat.GetBool() && Main.LoversPlayers.Count > 0) LateTask.New(() => ChatManager.ClearChat(Main.EnumerateAlivePlayerControls().ExceptBy(Main.LoversPlayers.ConvertAll(x => x.PlayerId), x => x.PlayerId).ToArray()), GameStates.CurrentServerType == GameStates.ServerType.Vanilla && !PlayerControl.LocalPlayer.IsAlive() ? 1.5f : 0f); }
try { if (Lovers.PrivateChat.GetBool() && Main.LoversPlayers.Count > 0) ChatManager.ClearChat(Main.EnumerateAlivePlayerControls().ExceptBy(Main.LoversPlayers.ConvertAll(x => x.PlayerId), x => x.PlayerId).ToArray()); }
catch (Exception e) { ThrowException(e); }
CustomSabotage.Reset();
+1
View File
@@ -8784,6 +8784,7 @@
"KickMobilePlayer": "Kick mobile players",
"KickPlayerFriendCodeNotExist": "Kick players who are not logged in",
"ApplyDenyNameList": "Apply DenyName List",
"BanDenyNameListPlayers": "Ban instead of kick on trigger",
"ApplyBanList": "Apply BanList",
"ApplyModeratorList": "Apply Moderator List",
"ApplyVIPList": "Apply VIP List",
@@ -45,7 +45,7 @@ public class Exclusionary : RoleBase
LateTask.New(() =>
{
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || GameStates.IsEnded || GameStates.IsLobby || AntiBlackout.SkipTasks || target == null || !target.IsAlive() || ExcludedPlayers.Exists(x => x.ID == target.PlayerId)) return;
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || GameStates.IsEnded || GameStates.IsLobby || AntiBlackout.SkipTasks || !target || !target.IsAlive() || ExcludedPlayers.Exists(x => x.ID == target.PlayerId)) return;
ExcludedPlayers.Add((target.PlayerId, Utils.TimeStamp + ExclusionDuration.GetInt()));
@@ -87,13 +87,10 @@ public class Exclusionary : RoleBase
sender.StartMessage(target.OwnerId);
}
if (GameStates.CurrentServerType != GameStates.ServerType.Vanilla)
{
sender.StartRpc(player.NetId, RpcCalls.SetPetStr)
.Write("")
.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr))
.EndRpc();
}
sender.StartRpc(player.NetId, RpcCalls.SetPetStr)
.Write("")
.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr))
.EndRpc();
sender.StartRpc(player.NetTransform.NetId, RpcCalls.SnapTo)
.WriteVector2(new Vector2(50f, 50f))
.Write(player.NetTransform.lastSequenceId)
@@ -191,7 +188,7 @@ public class Exclusionary : RoleBase
sender.StartMessage(pc.OwnerId);
}
if (Options.UsePets.GetBool() && GameStates.CurrentServerType != GameStates.ServerType.Vanilla)
if (Options.UsePets.GetBool())
{
sender.StartRpc(player.NetId, RpcCalls.SetPetStr)
.Write(PetsHelper.GetPetId())
+1 -6
View File
@@ -1,7 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using EHR.Modules;
using Hazel;
using UnityEngine;
namespace EHR.Roles;
@@ -67,9 +65,6 @@ internal class Butcher : RoleBase
return;
}
RPCHandlerPatch.WhiteListFromRateLimitUntil(target.PlayerId, Utils.TimeStamp + 5);
Vector2 ops = target.Pos();
var rd = IRandom.Instance;
@@ -83,7 +78,7 @@ internal class Butcher : RoleBase
Vector2 location = new(ops.x + ((float)(rd.Next(0, 201) - 100) / 100), ops.y + ((float)(rd.Next(0, 201) - 100) / 100));
location += new Vector2(0, 0.3636f);
Utils.RpcCreateDeadBody(location, (byte)target.CurrentOutfit.ColorId, target, SendOption.None);
Utils.RpcCreateDeadBody(location, (byte)target.CurrentOutfit.ColorId, target);
yield return new WaitForSecondsRealtime(0.2f);
}
@@ -45,7 +45,6 @@ internal class Trapster : RoleBase
public override void Add(byte playerId)
{
On = true;
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla) LegacyTrapster.SetValue(1);
}
public override void Init()