From d6b5278cdc69fa70b4c2a0e195fb34ecf20e096b Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Thu, 19 Mar 2026 11:29:34 +0100 Subject: [PATCH] some fixes --- Gamemodes/Mingle.cs | 70 ++++++++++++++++++-------------- Modules/ExtendedPlayerControl.cs | 4 +- Patches/ChatCommandPatch.cs | 2 + Patches/ChatControlPatch.cs | 1 + Patches/PlayerControlPatch.cs | 3 -- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/Gamemodes/Mingle.cs b/Gamemodes/Mingle.cs index 88ac1a128..94baab8cb 100644 --- a/Gamemodes/Mingle.cs +++ b/Gamemodes/Mingle.cs @@ -18,6 +18,7 @@ public static class Mingle public static long TimeEndTS; public static long LastUpdateTS; public static int Time; + public static bool DontEndGame; public static int TimeLimit; public static int TimeDecreaseOnNoDeath; @@ -124,7 +125,7 @@ public static class Mingle CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Error); Logger.Warn("No players alive. Force ending the game", "Mingle"); return true; - case var p when p <= MaxWinningPlayers: + case var p when p <= MaxWinningPlayers && !DontEndGame: CustomWinnerHolder.WinnerIds = aapc.Select(x => x.PlayerId).ToHashSet(); Logger.Info($"Winners: {string.Join(", ", aapc.Select(x => x.GetRealName().RemoveHtmlTags()))}", "Mingle"); Main.DoBlockNameChange = true; @@ -295,40 +296,49 @@ public static class Mingle private static void KillPlayers() { - var aapc = Main.AllAlivePlayerControls; - Dictionary playerRooms = aapc.Select(x => (pc: x, room: x.GetPlainShipRoom())).ToDictionary(x => x.pc, x => !x.room ? SystemTypes.Outside : x.room.RoomId); - Dictionary playerCount = []; - HashSet toKill = []; + DontEndGame = true; - foreach ((PlayerControl pc, SystemTypes room) in playerRooms) + try { - if (room == SystemTypes.Outside || !RequiredPlayerCount.ContainsKey(room)) - toKill.Add(pc); - else if (!playerCount.TryAdd(room, 1)) - playerCount[room]++; - } + var aapc = Main.AllAlivePlayerControls; + Dictionary playerRooms = aapc.Select(x => (pc: x, room: x.GetPlainShipRoom())).ToDictionary(x => x.pc, x => !x.room ? SystemTypes.Outside : x.room.RoomId); + Dictionary playerCount = []; + HashSet toKill = []; - foreach ((SystemTypes room, int required) in RequiredPlayerCount) - { - int count = playerCount.GetValueOrDefault(room, 0); - if (count == 0 || required == count) continue; - playerRooms.DoIf(x => x.Value == room, x => toKill.Add(x.Key)); - } + foreach ((PlayerControl pc, SystemTypes room) in playerRooms) + { + if (room == SystemTypes.Outside || !RequiredPlayerCount.ContainsKey(room)) + toKill.Add(pc); + else if (!playerCount.TryAdd(room, 1)) + playerCount[room]++; + } + + foreach ((SystemTypes room, int required) in RequiredPlayerCount) + { + int count = playerCount.GetValueOrDefault(room, 0); + if (count == 0 || required == count) continue; + playerRooms.DoIf(x => x.Value == room, x => toKill.Add(x.Key)); + } - switch (toKill.Count) + switch (toKill.Count) + { + case 0: + Time = Math.Max(Time - TimeDecreaseOnNoDeath, MinTime); + break; + case var x when x == aapc.Count: + Main.AllPlayerSpeed.SetAllValues(Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod)); + Main.PlayerStates.Values.DoIf(s => !s.IsDead, s => s.RealKiller.TimeStamp = DateTime.Now); + CustomWinnerHolder.ResetAndSetWinner(CustomWinner.None); + GameGoing = false; + break; + default: + toKill.Do(x => x.Suicide()); + break; + } + } + finally { - case 0: - Time = Math.Max(Time - TimeDecreaseOnNoDeath, MinTime); - break; - case var x when x == aapc.Count: - Main.AllPlayerSpeed.SetAllValues(Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod)); - Main.PlayerStates.Values.DoIf(s => !s.IsDead, s => s.RealKiller.TimeStamp = DateTime.Now); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.None); - GameGoing = false; - break; - default: - toKill.Do(x => x.Suicide()); - break; + DontEndGame = false; } } diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index c29ab52da..a9f81a459 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -2316,8 +2316,8 @@ internal static class ExtendedPlayerControl // Rooms that aren't rectangular-shaped and overlap walkable areas outside the room private static readonly Dictionary> ProblematicRooms = new() { - [MapNames.Skeld] = [SystemTypes.MedBay, SystemTypes.Cafeteria, SystemTypes.LifeSupp], - [MapNames.Dleks] = [SystemTypes.MedBay, SystemTypes.Cafeteria, SystemTypes.LifeSupp], + [MapNames.Skeld] = [SystemTypes.MedBay, SystemTypes.Cafeteria, SystemTypes.LifeSupp, SystemTypes.Electrical], + [MapNames.Dleks] = [SystemTypes.MedBay, SystemTypes.Cafeteria, SystemTypes.LifeSupp, SystemTypes.Electrical], [MapNames.Polus] = [SystemTypes.LifeSupp, SystemTypes.Storage, SystemTypes.Laboratory, SystemTypes.Comms, SystemTypes.Weapons, SystemTypes.Admin, SystemTypes.Decontamination2, SystemTypes.Decontamination3], [MapNames.Airship] = [SystemTypes.Electrical, SystemTypes.Security, SystemTypes.Engine, SystemTypes.Showers, SystemTypes.MainHall], [MapNames.Fungle] = [SystemTypes.Dropship] diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index dd54f93da..25a588ae6 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -495,6 +495,8 @@ internal static class ChatCommands if (HudManager.InstanceExists) HudManager.Instance.Chat.SendChat(); } } + + if (!canceled) ChatManager.SendMessage(PlayerControl.LocalPlayer, text); return !canceled; } diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index 14565cbc8..8f8f8fd8d 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -112,6 +112,7 @@ public static class ChatManager private static bool CheckCommand(ref string msg, string command, bool exact = true) { + Utils.CheckServerCommand(ref msg, out _); string[] comList = command.Split('|'); foreach (string str in comList) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index d5272ba41..fb3a062a5 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -1215,9 +1215,6 @@ internal static class ReportDeadBodyPatch { try { - try { cno.playerControl.Shapeshift(cno.playerControl, false); } - catch (Exception e) { ThrowException(e); } - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(cno.playerControl.NetId, (byte)RpcCalls.Shapeshift, SendOption.Reliable); writer.WriteNetObject(cno.playerControl); writer.Write(false);