Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Source/Common/MultiplayerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using HarmonyLib;
using Multiplayer.Common.Networking.Packet;

namespace Multiplayer.Common
Expand Down Expand Up @@ -98,6 +99,7 @@ public void Run()
Stopwatch tickTime = Stopwatch.StartNew();
double realTime = 0;

List<ServerPlayer> playersBehind = [];
while (running)
{
try
Expand All @@ -117,13 +119,20 @@ public void Run()
int ticked = 0;
while (realTime > 0 && ticked < 2)
{
playersBehind.Clear();
playersBehind.AddRange(PlayingIngamePlayers.Where(p => p.ExtrapolatedTicksBehind > 90));
if (!freezeManager.Frozen &&
PlayingPlayers.Any(p => p.ExtrapolatedTicksBehind < 40) &&
!PlayingIngamePlayers.Any(p => p.ExtrapolatedTicksBehind > 90))
!playersBehind.Any())
{
gameTimer++;
sentCmdsSnapshot = commands.SentCmds;
}
else if (playersBehind.Any())
{
var text = playersBehind.Join(p => $"{p.Username}");
ServerLog.Log($"Simulation paused because some players are too far behind: {text}");
}

// Run up to three times slower depending on max ticksBehind
var slowdown = Math.Min(
Expand Down
Loading