From 69fccc170d9b44498658dd325426f3df9a6fa68b Mon Sep 17 00:00:00 2001 From: Distortions81 Date: Sat, 23 Mar 2024 23:05:13 -0600 Subject: [PATCH] only give warning if server not empty. --- support/supportUtil.go | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/support/supportUtil.go b/support/supportUtil.go index 5700b740..799b578d 100755 --- a/support/supportUtil.go +++ b/support/supportUtil.go @@ -21,28 +21,53 @@ func checkHours() { shouldPlay := WithinHours() if !shouldPlay && fact.FactIsRunning { - buf := fmt.Sprintf("It is now past %v GMT, server will stop in 10 minutes.", + buf := fmt.Sprintf("It no longer between %v - %v GMT. Server will stop in 10 minutes.", + cfg.Local.Options.PlayStartHour, cfg.Local.Options.PlayEndHour) - fact.CMS(cfg.Local.Channel.ChatChannel, buf) - fact.CMS(cfg.Local.Channel.ChatChannel, buf) + + fact.FactChat(buf) + fact.FactChat(buf) + fact.FactChat(buf) fact.CMS(cfg.Local.Channel.ChatChannel, buf) - time.Sleep(time.Minute * 10) + shutTime := time.Now() + shutTime = shutTime.Add(time.Minute * 10) + + if fact.NumPlayers > 0 { + for { + if time.Until(shutTime) <= time.Second { + break + } + if WithinHours() { + buf := fmt.Sprintf("Time was adjusted to %v - %v GMT, shutdown timer aborted.", + cfg.Local.Options.PlayStartHour, + cfg.Local.Options.PlayEndHour) + + fact.FactChat(buf) + fact.CMS(cfg.Local.Channel.ChatChannel, buf) + return + } + time.Sleep(time.Second) + } + } if !WithinHours() { fact.FactAutoStart = false fact.QuitFactorio("Time is up...") + fact.CMS(cfg.Local.Channel.ChatChannel, "Server shutting down.") } } else if shouldPlay && !fact.FactIsRunning { - buf := fmt.Sprintf("It is now past %v GMT, server will now start.", - cfg.Local.Options.PlayStartHour) + buf := fmt.Sprintf("It is now within %v - %v GMT. Server will now start.", + cfg.Local.Options.PlayStartHour, + cfg.Local.Options.PlayEndHour) + + fact.FactChat(buf) fact.CMS(cfg.Local.Channel.ChatChannel, buf) fact.FactAutoStart = true - time.Sleep(time.Minute) } } - time.Sleep(time.Second * 15) + time.Sleep(time.Second * 5) } }