From 207d5b32e03a4abd2ac969bb5fb8d3d112bdb40a Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Sat, 21 Nov 2020 23:17:51 +1030 Subject: [PATCH] Move stuff around to better conform with standard structures. Improve docs. --- cmd/openttd_multitool/openttd_multitool.go | 2 +- pkg/{ => admin}/admin.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) rename pkg/{ => admin}/admin.go (96%) diff --git a/cmd/openttd_multitool/openttd_multitool.go b/cmd/openttd_multitool/openttd_multitool.go index 1982c7a..0fd536f 100644 --- a/cmd/openttd_multitool/openttd_multitool.go +++ b/cmd/openttd_multitool/openttd_multitool.go @@ -1,7 +1,7 @@ package main import ( - "github.com/tardisx/openttd-admin/pkg" + "github.com/tardisx/openttd-admin/pkg/admin" "flag" "strings" "os" diff --git a/pkg/admin.go b/pkg/admin/admin.go similarity index 96% rename from pkg/admin.go rename to pkg/admin/admin.go index e10be39..ec7aa0d 100644 --- a/pkg/admin.go +++ b/pkg/admin/admin.go @@ -1,3 +1,5 @@ +// Package admin provides an interface to connect to and manage a running +// OpenTTD dedicated server. package admin // references @@ -88,7 +90,9 @@ const ( 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) { 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) { if period == "daily" { server.rconDaily = append(server.rconDaily, command)