Skip to content

Commit

Permalink
Send pregame timing events to ingame
Browse files Browse the repository at this point in the history
  • Loading branch information
sprunk authored Oct 21, 2024
1 parent fd2f559 commit 6a6267a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Shared/LobbyClient/DedicatedServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class DedicatedServer : IDisposable
public static EventHandler<SpringBattleContext> AnyDedicatedExited;

private readonly SpringPaths paths;
private readonly Timer timer = new Timer(20000);
private readonly Timer timer = new Timer(1000);

private Dictionary<string, HashSet<byte> > gamePrivateMessages = new Dictionary<string, HashSet<byte> >();

Expand Down Expand Up @@ -514,8 +514,7 @@ private void timer_Elapsed(object sender, ElapsedEventArgs e)
try
{
var timeSinceStart = DateTime.UtcNow.Subtract(Context.StartTime).TotalSeconds;
const int timeToWait = 160; // force start after 180s
const int timeToWarn = 100; // warn people after 120s
const int timeToWait = 160; // force start after this many seconds

if (Context.IsHosting && IsRunning && (Context.IngameStartTime == null))
{
Expand All @@ -524,7 +523,10 @@ private void timer_Elapsed(object sender, ElapsedEventArgs e)
Context.IsTimeoutForceStarted = true;
ForceStart();
}
else if (timeSinceStart > timeToWarn) SayGame($"Game will be force started in {Math.Max(20, timeToWait - Math.Round(timeSinceStart))} seconds");
else
{
talker.SendText($"/luarules pregame_timer_seconds {Convert.ToInt32(timeToWait - timeSinceStart)}");
}
}
}
catch (Exception ex)
Expand Down

0 comments on commit 6a6267a

Please sign in to comment.