more fixes

This commit is contained in:
Gurge44 committed 2026-06-16 11:36:06 +02:00
1 parent bba5a7eaaa
commit 54f1fbaadb
7 files changed
+89 -14

No files matched your search

+2 -3
View File
@@ -50,9 +50,8 @@ internal static class GhostRolesManager
if (AssignedGhostRoles.Any(x => x.Key == id || x.Value.Role == role)) return;
PlayerControl pc = Utils.GetPlayerById(id);
if (set) pc.RpcSetRole(RoleTypes.GuardianAngel);
IGhostRole instance = CreateGhostRoleInstance(role);
if (set) pc.RpcSetRoleDesync(instance.RoleTypes, pc.OwnerId);
instance.OnAssign(pc);
Main.ResetCamPlayerList.Add(pc.PlayerId);
AssignedGhostRoles[id] = (role, instance);
@@ -65,7 +64,7 @@ internal static class GhostRolesManager
if (!first && pc.IsModdedClient()) return;
CustomRoles role = ghostRole.Role;
(string Split, string Message) info = GetMessage(Translator.GetString($"{role}InfoLong").Split("\n")[1..].Join(delimiter: "\n"));
(string Split, string Message) info = GetMessage(Translator.GetString($"{role}InfoLong").FixRoleName(role).Split("\n")[1..].Join(delimiter: "\n"));
var text = $"{Translator.GetString("GotGhostRoleNotify")}\n<size=80%>{info.Message}</size>";
var notifyText = $"{Translator.GetString("GotGhostRoleNotify")}\n<size=80%>{info.Split}</size>";
Utils.SendMessage(title: text, sendTo: pc.PlayerId, text: "\n");
+40 -1
View File
@@ -1213,7 +1213,7 @@ public static class Utils
if (Options.SyncButtonMode.GetBool()) messages.Add(new(GetString("SyncButtonModeInfo"), playerId));
if (Options.SabotageTimeControl.GetBool()) messages.Add(new(GetString("SabotageTimeControlInfo"), playerId));
if (Options.RandomMapsMode.GetBool()) messages.Add(new(GetString("RandomMapsModeInfo"), playerId));
if (Main.GM.Value) messages.Add(new(GetRoleName(CustomRoles.GM) + GetString("GMInfoLong"), playerId));
if (Main.GM.Value) messages.Add(new(GetRoleName(CustomRoles.GM) + GetString("GMInfoLong").FixRoleName(CustomRoles.GM), playerId));
messages.AddRange(from role in Main.CustomRoleValues where role.IsEnable() && !role.IsVanilla() select new Message(GetRoleName(role) + GetRoleMode(role) + GetString($"{role}InfoLong").FixRoleName(role), playerId));
if (Options.NoGameEnd.GetBool()) messages.Add(new(GetString("NoGameEndInfo"), playerId));
messages.SendMultipleMessages();
@@ -3845,6 +3845,45 @@ public static class Utils
return true;
}
public static IEnumerator SendGameData()
{
int messages = 0;
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
writer.StartMessage(5);
writer.Write(AmongUsClient.Instance.GameId);
foreach (NetworkedPlayerInfo playerinfo in GameData.Instance.AllPlayers)
{
if (writer.Length > 500 || messages >= AmongUsClient.Instance.GetMaxMessagePackingLimit())
{
messages = 0;
writer.EndMessage();
var qa = DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(writer));
yield return qa.Wait();
if (qa.Dropped)
{
writer.Recycle();
yield break;
}
writer.Clear(SendOption.Reliable);
writer.StartMessage(5);
writer.Write(AmongUsClient.Instance.GameId);
}
writer.StartMessage(1);
writer.WritePacked(playerinfo.NetId);
playerinfo.Serialize(writer, false);
writer.EndMessage();
messages++;
}
writer.EndMessage();
yield return DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(writer)).Wait();
writer.Recycle();
}
public static void SendGameDataTo(int targetClientId)
{
+19
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using AmongUs.Data;
using EHR.Patches;
using EHR.Roles;
@@ -100,6 +101,24 @@ internal static class UrlFinderPatch
}
}
[HarmonyPatch(typeof(ChatController), nameof(ChatController.ForceClosed))]
static class ChatControllerForceClosedPatch
{
public static bool Prefix()
{
return !Utils.TempReviveHostRunning || GameStates.IsEnded || !GameStates.InGame;
}
}
[HarmonyPatch(typeof(ChatController), nameof(ChatController.SetVisible))]
static class ChatControllerSetVisiblePatch
{
public static bool Prefix([HarmonyArgument(0)] bool visible)
{
return visible || !Utils.TempReviveHostRunning || GameStates.IsEnded || !GameStates.InGame;
}
}
public static class ChatManager
{
private const int MaxHistorySize = 20;
+8 -1
View File
@@ -219,9 +219,16 @@ internal static class ExileControllerWrapUpPatch
Utils.MarkEveryoneDirtySettings();
Utils.CheckAndSetVentInteractions();
Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync());
Main.Instance.StartCoroutine(Coroutine());
Stopwatch.Reset();
return;
System.Collections.IEnumerator Coroutine()
{
yield return Utils.NotifyEveryoneAsync();
yield return Utils.SendGameData();
}
}
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))]
+14 -6
View File
@@ -344,10 +344,6 @@ internal static class ChangeRoleSettings
GameStates.AlreadyDied = false;
Main.Instance.StartCoroutine(PopulateSkinItems());
GC.Collect();
Resources.UnloadUnusedAssets();
GC.Collect();
}
catch (Exception ex)
{
@@ -507,6 +503,16 @@ internal static class StartGameHostPatch
try
{
loadingBarManager.SetLoadingPercent(10f, StringNames.LoadingBarGameStart);
loadingBarManager.loadingBar.loadingText.text = GetString("LoadingBarText.3");
}
catch (Exception e) { Utils.ThrowException(e); }
try
{
GC.Collect();
Resources.UnloadUnusedAssets();
GC.Collect();
loadingBarManager.loadingBar.loadingText.text = loadingTextText1;
}
catch (Exception e) { Utils.ThrowException(e); }
@@ -1045,8 +1051,9 @@ internal static class StartGameHostPatch
}
string loadingText = GetString("LoadingBarText.4");
LoadingBarManager loadingBarManager = LoadingBarManager.Instance;
yield return loadingBarManager.WaitAndSmoothlyUpdate(90f, 95f, 1f, GetString("LoadingBarText.1"));
yield return loadingBarManager.WaitAndSmoothlyUpdate(90f, 95f, 1f, loadingText);
foreach (PlayerControl pc in PlayerControl.AllPlayerControls)
{
@@ -1063,7 +1070,8 @@ internal static class StartGameHostPatch
Logger.Info("Successfully set everyone's data as Disconnected", "StartGameHost");
yield return loadingBarManager.WaitAndSmoothlyUpdate(95f, 100f, 1f, GetString("LoadingBarText.1"));
if (GameOptionsManager.Instance.CurrentGameOptions.MapId is 2 or 5) loadingText = GetString("LoadingBarText.5");
yield return loadingBarManager.WaitAndSmoothlyUpdate(95f, 100f, 1f, loadingText);
loadingBarManager.ToggleLoadingBar(false);
Main.EnumeratePlayerControls().Do(SetRoleSelf);
+1 -1
View File
@@ -778,7 +778,7 @@ internal static class ShipStatusFixedUpdatePatch
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks)
{
Stopwatch.Reset();
yield return new WaitForSecondsRealtime(AntiBlackout.SkipTasks ? 2f : 5f);
yield return new WaitForSecondsRealtime(5f);
Stopwatch.Start();
continue;
}
+5 -2
View File
@@ -10401,8 +10401,11 @@
Loading Hints
============================== */
"Loading": "<b><color=#ffff00>Loading....</color></b>\\n<size=2>This may take a minute.</size>",
"LoadingBarText.1": "Setting up your game....",
"LoadingBarText.2": "{0}/{1} Clients Ready ({2})",
"LoadingBarText.1": "Docking The Ship....",
"LoadingBarText.2": "Boarding: {0}/{1} ({2}s left)",
"LoadingBarText.3": "Opening The Gate....",
"LoadingBarText.4": "Heading Off....",
"LoadingBarText.5": "Landing....",
"LoadingHint.0": "Did you know?\nYou can put roles of your choice into custom teams!\nView instructions on our website (link on main menu)!",
"LoadingHint.1": "Did you know?\nYou can force or ban certain role and add-on combos using /combo in lobby!\nGive it a try after this game!",
"LoadingHint.2": "Did you know?\nYou can change roles', add-ons', settings', etc. names using custom translation files!",