some fixes

This commit is contained in:
Gurge44 committed 2026-03-19 11:29:34 +01:00
1 parent 0f63f6fc75
commit d6b5278cdc
5 files changed
+45 -35

No files matched your search

+40 -30
View File
@@ -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<PlayerControl, SystemTypes> playerRooms = aapc.Select(x => (pc: x, room: x.GetPlainShipRoom())).ToDictionary(x => x.pc, x => !x.room ? SystemTypes.Outside : x.room.RoomId);
Dictionary<SystemTypes, int> playerCount = [];
HashSet<PlayerControl> 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<PlayerControl, SystemTypes> playerRooms = aapc.Select(x => (pc: x, room: x.GetPlainShipRoom())).ToDictionary(x => x.pc, x => !x.room ? SystemTypes.Outside : x.room.RoomId);
Dictionary<SystemTypes, int> playerCount = [];
HashSet<PlayerControl> 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;
}
}
+2 -2
View File
@@ -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<MapNames, List<SystemTypes>> 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]
+2
View File
@@ -495,6 +495,8 @@ internal static class ChatCommands
if (HudManager.InstanceExists) HudManager.Instance.Chat.SendChat();
}
}
if (!canceled) ChatManager.SendMessage(PlayerControl.LocalPlayer, text);
return !canceled;
}
+1
View File
@@ -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)
-3
View File
@@ -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);