Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send pregame timing events to ingame #2995

Merged
merged 1 commit into from
Oct 23, 2024
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
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
Loading