some fixes

This commit is contained in:
Gurge44 committed 2026-06-02 11:45:23 +02:00
1 parent 47df8e7dbd
commit ed58912391
10 files changed
+47 -75

No files matched your search

+1 -1
View File
@@ -532,7 +532,7 @@ public class CustomRpcSender
public static class CustomRpcSenderExtensions
{
public static void RpcSetName(ref CustomRpcSender sender, PlayerControl player, string name, PlayerControl seer = null)
public static void RpcSetName(ref CustomRpcSender sender, PlayerControl player, PlayerControl seer, string name)
{
bool seerIsNull = !seer;
int targetClientId = seerIsNull ? -1 : seer.OwnerId;
-3
View File
@@ -144,7 +144,6 @@ internal static class CustomTeamManager
msg.WritePacked(EnabledCustomTeams.Count);
EnabledCustomTeams.Do(x => x.Serialize(msg));
AmongUsClient.Instance.FinishRpcImmediately(msg);
msg.Recycle();
msg = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CTA, SendOption.Reliable);
msg.WritePacked(2);
@@ -158,7 +157,6 @@ internal static class CustomTeamManager
}
AmongUsClient.Instance.FinishRpcImmediately(msg);
msg.Recycle();
msg = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CTA, SendOption.Reliable);
msg.WritePacked(3);
@@ -172,7 +170,6 @@ internal static class CustomTeamManager
}
AmongUsClient.Instance.FinishRpcImmediately(msg);
msg.Recycle();
}
return;
@@ -262,6 +262,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
{
if (PackedWriter == null) // Single write
{
Logger.Info("Enqueue complete for single write", "SendOptionsArray");
DataFlagRateLimiter.Enqueue(() =>
{
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
@@ -289,7 +290,6 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
writer.Recycle();
Logger.Info("Queue finished and sent for single write", "SendOptionsArray");
});
Logger.Info("Enqueue complete for single write", "SendOptionsArray");
return;
}
+1 -1
View File
@@ -7,7 +7,7 @@ public static class PetsHelper
public static void RpcRemovePet(PlayerControl pc)
{
const string petId = "";
if (!GameStates.IsInGame || !Options.RemovePetsAtDeadPlayers.GetBool() || pc == null || !pc.Data.IsDead || pc.IsAlive() || pc.CurrentOutfit.PetId == petId) return;
if (!GameStates.IsInGame || !Options.RemovePetsAtDeadPlayers.GetBool() || !pc || !pc.Data.IsDead || pc.IsAlive() || pc.CurrentOutfit.PetId == petId) return;
SetPet(pc, petId);
}
+13 -36
View File
@@ -2793,7 +2793,7 @@ public static class Utils
var hasValue = false;
var sender = CustomRpcSender.Create("NotifyRoles", SendOption, log: false);
sender.StartPackedMessage();
if (!ForMeeting || !Magistrate.CallCourtNextMeeting) sender.StartPackedMessage();
for (byte seerIndex = 0; seerIndex < SeerList.Count; seerIndex++)
{
@@ -2830,40 +2830,23 @@ public static class Utils
sender ??= CustomRpcSender.Create("NotifyRoles", sendOption);
// During the intro scene, set the team name for non-modded clients and skip the rest.
string selfName;
Team seerTeam = seer.GetTeam();
CustomRoles seerRole = seer.GetCustomRole();
if (SetUpRoleTextPatch.IsInIntro && (seerRole.IsDesyncRole() || seer.Is(CustomRoles.Bloodlust)) && Options.CurrentGameMode == CustomGameMode.Standard)
{
const string iconTextLeft = "<color=#ffffff>\u21e8</color>";
const string iconTextRight = "<color=#ffffff>\u21e6</color>";
const string roleNameUp = "</size><size=1450%>\n \n</size>";
var selfTeamName = $"<size=450%>{iconTextLeft} <font=\"VCR SDF\" material=\"VCR Black Outline\">{ColorString(seerTeam.GetColor(), $"{seerTeam}")}</font> {iconTextRight}</size><size=500%>\n \n</size>";
selfName = $"{selfTeamName}\r\n<size=150%>{seerRole.ToColoredString()}</size>{roleNameUp}";
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, selfName, seer);
return true;
}
if (SetUpRoleTextPatch.IsInIntro)
return false;
if (seer.Is(CustomRoles.Car) && !forMeeting && !GameStates.IsEnded)
{
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, Car.Name);
return true;
}
return false;
if (Main.PlayerStates.TryGetValue(seer.PlayerId, out var seerState) && seerState.Role is Tree { TreeSpriteActive: true } && !forMeeting && !GameStates.IsEnded)
{
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, Tree.Sprite);
return true;
}
if (Main.PlayerStates.TryGetValue(seer.PlayerId, out var seerState) && seerState.Role is Tree { TreeSpriteActive: true } && !forMeeting && !GameStates.IsEnded)
return false;
if (forMeeting && Magistrate.CallCourtNextMeeting)
{
selfName = seer.Is(CustomRoles.Magistrate) ? GetString("Magistrate.CourtName") : GetString("Magistrate.JuryName");
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, selfName);
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, null, selfName);
return true;
}
@@ -3189,7 +3172,7 @@ public static class Utils
if (selfName.EndsWith("</size>")) selfName = selfName.Remove(selfName.Length - 7);
if (selfName.EndsWith("</color>")) selfName = selfName.Remove(selfName.Length - 8);
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, selfName, seer);
CustomRpcSenderExtensions.RpcSetName(ref sender, seer, seer, selfName);
hasValue = true;
bool onlySelfNameUpdateRequired = Options.CurrentGameMode switch
@@ -3220,25 +3203,19 @@ public static class Utils
if (target.PlayerId == seer.PlayerId) continue;
if ((IsActive(SystemTypes.MushroomMixupSabotage) || mushroomMixup) && !forMeeting && target.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && seer.HasDesyncRole())
CustomRpcSenderExtensions.RpcSetName(ref sender, target, "<size=0%>", seer);
CustomRpcSenderExtensions.RpcSetName(ref sender, target, seer, "<size=0%>");
else
{
if (target.Is(CustomRoles.Car) && !forMeeting && !GameStates.IsEnded)
{
CustomRpcSenderExtensions.RpcSetName(ref sender, target, Car.Name, seer);
continue;
}
if (Main.PlayerStates.TryGetValue(target.PlayerId, out var targetState) && targetState.Role is Tree { TreeSpriteActive: true } && !forMeeting && !GameStates.IsEnded)
{
CustomRpcSenderExtensions.RpcSetName(ref sender, target, Tree.Sprite, seer);
if (Main.PlayerStates.TryGetValue(target.PlayerId, out var targetState) && targetState.Role is Tree { TreeSpriteActive: true } && !forMeeting && !GameStates.IsEnded)
continue;
}
if (forMeeting && Magistrate.CallCourtNextMeeting)
{
CustomRpcSenderExtensions.RpcSetName(ref sender, target, GetString(target.Is(CustomRoles.Magistrate) ? "Magistrate.CourtName" : "Magistrate.JuryName"), seer);
return true;
CustomRpcSenderExtensions.RpcSetName(ref sender, target, seer, GetString(target.Is(CustomRoles.Magistrate) ? "Magistrate.CourtName" : "Magistrate.JuryName"));
continue;
}
TargetMark.Clear();
@@ -3506,7 +3483,7 @@ public static class Utils
if (targetName.EndsWith("</size>")) targetName = targetName.Remove(targetName.Length - 7);
if (targetName.EndsWith("</color>")) targetName = targetName.Remove(targetName.Length - 8);
CustomRpcSenderExtensions.RpcSetName(ref sender, target, targetName, seer);
CustomRpcSenderExtensions.RpcSetName(ref sender, target, seer, targetName);
hasValue = true;
senderWasCleared = false;
}
+13 -17
View File
@@ -1149,6 +1149,19 @@ internal static class IntroCutsceneDestroyPatch
if (AmongUsClient.Instance.AmHost)
{
LateTask.New(() => apc.DoIf(x => x && ((x.AmOwner && Main.GM.Value) || ChatCommands.Spectators.Contains(x.PlayerId)), x => x.RpcSetCustomRole(CustomRoles.GM)), 8f);
try
{
System.Collections.Generic.List<PlayerControl> spectators = ChatCommands.Spectators.ToValidPlayers().ToList();
if (Main.GM.Value) spectators.Add(PlayerControl.LocalPlayer);
spectators.ForEach(x =>
{
x.RpcExileV2();
Main.PlayerStates[x.PlayerId].SetDead();
});
}
catch (Exception e) { Utils.ThrowException(e); }
var aapc = Main.AllAlivePlayerControlsToList;
@@ -1244,8 +1257,6 @@ internal static class IntroCutsceneDestroyPatch
}
}
Main.ProcessShapeshifts = false;
LateTask.New(GrantPetForEveryone, 3f, "Grant Pet For Everyone");
LateTask.New(() =>
@@ -1276,23 +1287,8 @@ internal static class IntroCutsceneDestroyPatch
sender.SendMessage(dispose: !hasValue);
}, 4f, "Show Pet For Everyone");
LateTask.New(() => Main.ProcessShapeshifts = true, 2f, "Enable SS Processing");
}
try
{
System.Collections.Generic.List<PlayerControl> spectators = ChatCommands.Spectators.ToValidPlayers().ToList();
if (Main.GM.Value) spectators.Add(PlayerControl.LocalPlayer);
spectators.ForEach(x =>
{
x.RpcExileV2();
Main.PlayerStates[x.PlayerId].SetDead();
});
}
catch (Exception e) { Utils.ThrowException(e); }
if (Options.RandomSpawn.GetBool() && Main.CurrentMap != MapNames.Airship && !Main.LIMap && AmongUsClient.Instance.AmHost && Options.CurrentGameMode is not CustomGameMode.CaptureTheFlag and not CustomGameMode.KingOfTheZones and not CustomGameMode.BedWars and not CustomGameMode.Deathrace)
{
var map = RandomSpawn.SpawnMap.GetSpawnMap();
+6 -1
View File
@@ -73,6 +73,11 @@ internal static class NotificationPopperPatch
private static void SendRpc(byte typeId, int optionId, CustomRoles customRole = CustomRoles.NotAssigned, bool playSound = true)
{
if (Options.HideGameSettings.GetBool()) return;
Utils.SendRPC(CustomRPC.NotificationPopper, typeId, optionId, (int)customRole, playSound);
var msg = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.NotificationPopper, Hazel.SendOption.None);
msg.Write(typeId);
msg.Write(optionId);
msg.Write((int)customRole);
msg.Write(playSound);
AmongUsClient.Instance.FinishRpcImmediately(msg);
}
}
-12
View File
@@ -2640,18 +2640,6 @@ public static class PlayerControlFixMixedUpOutfitPatch
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.ShouldProcessRpc))]
internal static class ShouldProcessRpcPatch
{
// Since the stupid AU code added a check for RPC processing for outfit players, we need to patch this
// Always return true because the check is absolutely pointless
public static bool Prefix(ref bool __result)
{
__result = true;
return false;
}
}
[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.RpcBootFromVent))]
internal static class BootFromVentPatch
{
+9
View File
@@ -15,6 +15,7 @@ public class Car : RoleBase
private int Count;
private HashSet<byte> CurrentlyPropelling;
private Vector2 LastPosition;
private byte CarId;
public static string Name => "<voffset=7em><alpha=#00>.</alpha></voffset><size=150%><line-height=97%><cspace=0.16em><#0000>W</color><mark=#628d85>WWWWW</mark><#0000>WW</color>\n<mark=#586874>WW</mark><mark=#547a96>WW</mark><mark=#6894b6>WW</mark><mark=#586874>W</mark><#0000>W</color>\n<mark=#586874>WWW</mark><mark=#547a96>WW</mark><mark=#586874>WW</mark><mark=#f5ee2e>W</mark>\n<mark=#000000>W</mark><mark=#0d233f>W</mark><mark=#586874>WWW</mark><mark=#f5ee2e>W</mark><mark=#586874>W</mark><mark=#517a9a>W</mark>\n<mark=#000000>WW</mark><#0000>W</color><mark=#000000>W</mark><mark=#0d233f>W</mark><mark=#586874>W</mark><mark=#517a9a>W</mark><#0000>W\nWWW</color><mark=#000000>WW</mark><#0000>WWW";
@@ -40,6 +41,7 @@ public class Car : RoleBase
LastPosition = Utils.GetPlayerById(playerId).Pos();
Count = 0;
CurrentlyPropelling = [];
CarId = playerId;
}
public override void OnFixedUpdate(PlayerControl pc)
@@ -120,6 +122,13 @@ public class Car : RoleBase
CurrentlyPropelling.Remove(target.PlayerId);
}
public override void AfterMeetingTasks()
{
var pc = CarId.GetPlayer();
if (!pc || !pc.IsAlive()) return;
pc.RpcSetName(Name);
}
private enum Direction
{
Left,
+3 -3
View File
@@ -61,7 +61,7 @@ public class Tree : RoleBase
if (treeSpriteVisible)
{
TreeSpriteActive = true;
Utils.NotifyRoles(SpecifyTarget: pc);
pc.RpcSetName(Sprite);
}
else
pc.RpcMakeInvisible();
@@ -69,7 +69,7 @@ public class Tree : RoleBase
LateTask.New(() =>
{
Main.AllPlayerSpeed[pc.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
if (!GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || pc == null || !pc.IsAlive()) return;
if (!GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || !pc || !pc.IsAlive()) return;
pc.MarkDirtySettings();
if (treeSpriteVisible)
@@ -97,7 +97,7 @@ public class Tree : RoleBase
LateTask.New(() =>
{
Main.AllPlayerSpeed[x.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
if (!GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || pc == null || !pc.IsAlive()) return;
if (!GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || !pc || !pc.IsAlive()) return;
x.MarkDirtySettings();
}, FallStunDuration.GetFloat(), log: false);
}