Move stuff around to better conform with standard structures. Improve docs.

This commit is contained in:
Justin Hawkins 2020-11-21 23:17:51 +10:30
parent 46fe9b66c4
commit 207d5b32e0
2 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/tardisx/openttd-admin/pkg" "github.com/tardisx/openttd-admin/pkg/admin"
"flag" "flag"
"strings" "strings"
"os" "os"

View File

@ -1,3 +1,5 @@
// Package admin provides an interface to connect to and manage a running
// OpenTTD dedicated server.
package admin package admin
// references // references
@ -88,7 +90,9 @@ const (
adminFrequencyAUTOMATIC = 0x40 ///< The admin gets information about this when it changes. adminFrequencyAUTOMATIC = 0x40 ///< The admin gets information about this when it changes.
) )
// Connect to the OpenTTD server on the admin port // Connect to the OpenTTD server on the admin port. Requires that the server
// is listening on the admin port (admin_password must be specified in the config).
// This method will block, and automatically attempt to reconnect if disconnected.
func (server *OpenTTDServer) Connect(host string, port int, password string, botName string, botVersion string) { func (server *OpenTTDServer) Connect(host string, port int, password string, botName string, botVersion string) {
for { for {
@ -160,7 +164,11 @@ func (server *OpenTTDServer) Connect(host string, port int, password string, bot
} }
// RegisterDateChange to send a command periodically // RegisterDateChange sends an arbitrary number of rcon commands when certain
// (game time) date changes occur. The possible periods are 'daily', 'monthly'
// and 'yearly'.
//
// Note that this must be called before Connect.
func (server *OpenTTDServer) RegisterDateChange(period string, command string) { func (server *OpenTTDServer) RegisterDateChange(period string, command string) {
if period == "daily" { if period == "daily" {
server.rconDaily = append(server.rconDaily, command) server.rconDaily = append(server.rconDaily, command)