From 6a6267a77aa82baf3c62896d4477465204d26d70 Mon Sep 17 00:00:00 2001
From: sprunk <gnurps@o2.pl>
Date: Mon, 21 Oct 2024 03:03:55 +0200
Subject: [PATCH] Send pregame timing events to ingame

---
 Shared/LobbyClient/DedicatedServer.cs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Shared/LobbyClient/DedicatedServer.cs b/Shared/LobbyClient/DedicatedServer.cs
index faa163e63..d4c38716f 100644
--- a/Shared/LobbyClient/DedicatedServer.cs
+++ b/Shared/LobbyClient/DedicatedServer.cs
@@ -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> >();
 
@@ -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))
                 {
@@ -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)