mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
just more fixes
This commit is contained in:
1 parent
d4cb9ed675
commit
62ec0a25eb
5 files changed
+59
-36
No files matched your search
+56
-27
@@ -3846,43 +3846,72 @@ public static class Utils
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IEnumerator SendGameData()
|
||||
public static IEnumerator SendGameDataContinuously()
|
||||
{
|
||||
int messages = 0;
|
||||
|
||||
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
|
||||
writer.StartMessage(5);
|
||||
writer.Write(AmongUsClient.Instance.GameId);
|
||||
|
||||
foreach (NetworkedPlayerInfo playerinfo in GameData.Instance.AllPlayers)
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
|
||||
while (GameStates.InGame && !GameStates.IsEnded && ShipStatus.Instance)
|
||||
{
|
||||
if (writer.Length > 500 || messages >= AmongUsClient.Instance.GetMaxMessagePackingLimit())
|
||||
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks)
|
||||
{
|
||||
messages = 0;
|
||||
writer.EndMessage();
|
||||
var qa = DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(writer));
|
||||
yield return qa.Wait();
|
||||
if (qa.Dropped)
|
||||
stopwatch.Reset();
|
||||
yield return new WaitForSecondsRealtime(10f);
|
||||
stopwatch.Start();
|
||||
continue;
|
||||
}
|
||||
|
||||
int messages = 0;
|
||||
|
||||
MessageWriter writer = MessageWriter.Get();
|
||||
writer.StartMessage(5);
|
||||
writer.Write(AmongUsClient.Instance.GameId);
|
||||
|
||||
for (var index = 0; index < GameData.Instance.AllPlayers.Count; index++)
|
||||
{
|
||||
NetworkedPlayerInfo playerinfo = GameData.Instance.AllPlayers[index];
|
||||
|
||||
if (writer.Length > 500 || messages >= AmongUsClient.Instance.GetMaxMessagePackingLimit())
|
||||
{
|
||||
writer.Recycle();
|
||||
yield break;
|
||||
messages = 0;
|
||||
writer.EndMessage();
|
||||
var qa = DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(writer), channel: SendOption.None);
|
||||
yield return qa.Wait();
|
||||
yield return new WaitForSecondsRealtime(1f);
|
||||
|
||||
if (qa.Dropped || !GameStates.InGame || GameStates.IsEnded || !ShipStatus.Instance)
|
||||
{
|
||||
writer.Recycle();
|
||||
Logger.Msg("Coroutine finished", nameof(SendGameDataContinuously));
|
||||
yield break;
|
||||
}
|
||||
|
||||
writer.Clear(SendOption.None);
|
||||
writer.StartMessage(5);
|
||||
writer.Write(AmongUsClient.Instance.GameId);
|
||||
}
|
||||
writer.Clear(SendOption.Reliable);
|
||||
writer.StartMessage(5);
|
||||
writer.Write(AmongUsClient.Instance.GameId);
|
||||
|
||||
if (!playerinfo || (SoulCollector.On && Main.PlayerStates.Values.Any(x => x.Role is SoulCollector sc && sc.ToExile.Contains(playerinfo.PlayerId)))) continue;
|
||||
|
||||
playerinfo.IsDead = !playerinfo.Object.IsAlive();
|
||||
|
||||
writer.StartMessage(1);
|
||||
writer.WritePacked(playerinfo.NetId);
|
||||
playerinfo.Serialize(writer, false);
|
||||
writer.EndMessage();
|
||||
|
||||
messages++;
|
||||
}
|
||||
|
||||
writer.StartMessage(1);
|
||||
writer.WritePacked(playerinfo.NetId);
|
||||
playerinfo.Serialize(writer, false);
|
||||
writer.EndMessage();
|
||||
if (messages > 0) yield return DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(writer), channel: SendOption.None).Wait();
|
||||
writer.Recycle();
|
||||
|
||||
messages++;
|
||||
stopwatch.Reset();
|
||||
yield return new WaitForSecondsRealtime(5f);
|
||||
stopwatch.Start();
|
||||
}
|
||||
|
||||
writer.EndMessage();
|
||||
yield return DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(writer)).Wait();
|
||||
writer.Recycle();
|
||||
|
||||
Logger.Msg("Coroutine finished", nameof(SendGameDataContinuously));
|
||||
}
|
||||
|
||||
public static void SendGameDataTo(int targetClientId)
|
||||
|
||||
@@ -232,11 +232,6 @@ internal static class ExileControllerWrapUpPatch
|
||||
if (GameStates.IsEnded) yield break;
|
||||
|
||||
yield return Utils.NotifyEveryoneAsync();
|
||||
|
||||
foreach (NetworkedPlayerInfo playerinfo in GameData.Instance.AllPlayers)
|
||||
playerinfo.IsDead = !playerinfo.Object.IsAlive();
|
||||
|
||||
yield return Utils.SendGameData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1369,6 +1369,7 @@ internal static class IntroCutsceneDestroyPatch
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync()), 3f, "NotifyEveryoneAsync On Game Start");
|
||||
LateTask.New(Utils.MarkEveryoneDirtySettings, 0.5f, "SyncAllSettings On Game Start");
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(ShipStatusFixedUpdatePatch.Postfix()), 5f, "ShipStatusFixedUpdatePatch Postfix Start");
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(Utils.SendGameDataContinuously()), 10f, "SendGameDataContinuously Start");
|
||||
|
||||
Utils.CheckAndSetVentInteractions();
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ internal static class ShipStatusFixedUpdatePatch
|
||||
{
|
||||
Stopwatch = Stopwatch.StartNew();
|
||||
|
||||
while (ShipStatus.Instance)
|
||||
while (GameStates.InGame && !GameStates.IsEnded && ShipStatus.Instance)
|
||||
{
|
||||
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks)
|
||||
{
|
||||
@@ -831,7 +831,6 @@ internal static class ShipStatusFixedUpdatePatch
|
||||
Stopwatch.Start();
|
||||
}
|
||||
|
||||
if (ShipStatus.Instance)
|
||||
Main.Instance.StartCoroutine(Postfix());
|
||||
Logger.Msg("Coroutine finished", nameof(ShipStatusFixedUpdatePatch));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using Hazel;
|
||||
|
||||
|
||||
Reference in new issue
Block a user