go fmt and support monthly/yearly commands

This commit is contained in:
Justin Hawkins 2020-11-19 15:13:30 +10:30
parent 8abf5c7af3
commit 2a715ac172

View File

@ -14,7 +14,6 @@ import (
"time"
)
type OpenTTDServer struct {
connection net.Conn
rconDaily []string
@ -154,9 +153,25 @@ func ( server *OpenTTDServer ) RegisterDateChange (period string, command string
}
func (server *OpenTTDServer) dateChanged(dt time.Time) {
// do every daily one
for _, rconCommand := range server.rconDaily {
server.rconCommand(rconCommand)
}
// monthly ones on the 1st
if dt.Day() == 1 {
for _, rconCommand := range server.rconMonthly {
server.rconCommand(rconCommand)
}
}
// yearly on the 1st of jan
if dt.Day() == 1 && dt.Month() == 1 {
for _, rconCommand := range server.rconYearly {
server.rconCommand(rconCommand)
}
}
}
func (server OpenTTDServer) rconCommand(command string) {