This commit is contained in:
shoopea 2020-06-21 21:14:36 +02:00
parent 9796ec9a47
commit b441028e15

18
main.go
View File

@ -24,6 +24,7 @@ var (
clients map[uint32]*Client clients map[uint32]*Client
paused bool = true paused bool = true
forcePaused bool = true forcePaused bool = true
forcePausedBy string
githash string githash string
buildstamp string buildstamp string
@ -203,11 +204,11 @@ func main() {
if sp.Message == "!unpause" { if sp.Message == "!unpause" {
logInfoDebug("AdminPacketServerChat : Unpausing") logInfoDebug("AdminPacketServerChat : Unpausing")
forcePaused = false forcePaused = false
sendChat(-436055948, fmt.Sprintf("Game unpaused by %s", clients[sp.ClientID].Name)) forcePausedBy = clients[sp.ClientID].Name
} else if sp.Message == "!pause" { } else if sp.Message == "!pause" {
logInfoDebug("AdminPacketServerChat : Pausing") logInfoDebug("AdminPacketServerChat : Pausing")
forcePaused = true forcePaused = true
sendChat(-436055948, fmt.Sprintf("Game paused by %s", clients[sp.ClientID].Name)) forcePausedBy = clients[sp.ClientID].Name
} else { } else {
logInfoDebug("AdminPacketServerChat :\n- ActionID: %d\n- DestinationID: %d\n- ClientID: %d\n- Message: %s\n- Amount: %d", sp.ActionID, sp.DestinationID, sp.ClientID, sp.Message, sp.Amount) logInfoDebug("AdminPacketServerChat :\n- ActionID: %d\n- DestinationID: %d\n- ClientID: %d\n- Message: %s\n- Amount: %d", sp.ActionID, sp.DestinationID, sp.ClientID, sp.Message, sp.Amount)
} }
@ -282,6 +283,11 @@ func main() {
Command: "pause", Command: "pause",
} }
_, err = conn.Write(px.Bytes()) _, err = conn.Write(px.Bytes())
logInfoDebug("Force pausing")
if pausedBy != "" {
sendChat(-436055948, fmt.Sprintf("Game paused by %s", pausedBy))
pausedBy = ""
}
} }
if paused && !forcePaused && len(clients) > 1 { // server is client #1 if paused && !forcePaused && len(clients) > 1 { // server is client #1
paused = false paused = false
@ -290,7 +296,11 @@ func main() {
Command: "unpause", Command: "unpause",
} }
_, err = conn.Write(px.Bytes()) _, err = conn.Write(px.Bytes())
sendChat(-436055948, "Game unpaused.") logInfoDebug("Force unpausing")
if pausedBy != "" {
sendChat(-436055948, fmt.Sprintf("Game unpaused by %s", pausedBy))
pausedBy = ""
}
} }
if !paused && len(clients) == 1 { // server is client #1 if !paused && len(clients) == 1 { // server is client #1
paused = true paused = true
@ -300,6 +310,8 @@ func main() {
} }
_, err = conn.Write(px.Bytes()) _, err = conn.Write(px.Bytes())
logInfoDebug("Pausing") logInfoDebug("Pausing")
sendChat(-436055948, "No players. Game paused.")
} }
} }