aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-11-19 23:24:07 -0500
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-11-20 06:12:13 -0500
commitf4fefa65ec1932056082d69d1bd827afbcb88174 (patch)
tree7684148f5819ac53b0dae5c5b8c52ed01b988e8b /pkg
parent7de3d38f77eb341ada29e6ce216d7adfed2750a9 (diff)
downloadAtlas-f4fefa65ec1932056082d69d1bd827afbcb88174.tar.gz
Atlas-f4fefa65ec1932056082d69d1bd827afbcb88174.zip
pkg/api/api0: Add region field to serverlist
If empty, it is omitted from the server list JSON.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/api0/serverlist.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/api/api0/serverlist.go b/pkg/api/api0/serverlist.go
index 710fbf9..170a684 100644
--- a/pkg/api/api0/serverlist.go
+++ b/pkg/api/api0/serverlist.go
@@ -80,6 +80,7 @@ type Server struct {
LauncherVersion string // for metrics
Name string
+ Region string
Description string
Password string // blank for none
@@ -121,6 +122,7 @@ type ServerUpdate struct {
Heartbeat bool
Name *string
+ Region *string
Description *string
PlayerCount *int
MaxPlayers *int
@@ -278,7 +280,7 @@ func csJSON(ss []*Server, est int) ([]byte, int) {
const (
estMin = 256
- estInit = 384
+ estInit = 394
estMax = 512
)
switch {
@@ -309,6 +311,10 @@ func csJSON(ss []*Server, est int) ([]byte, int) {
b = append(b, srv.ID...)
b = append(b, `","name":`...)
b = appendJSONString(b, srv.Name)
+ if srv.Region != "" {
+ b = append(b, `,"region":`...)
+ b = appendJSONString(b, srv.Region)
+ }
b = append(b, `,"description":`...)
b = appendJSONString(b, srv.Description)
b = append(b, `,"playerCount":`...)
@@ -808,6 +814,9 @@ func (s *ServerList) ServerHybridUpdatePut(u *ServerUpdate, c *Server, l ServerL
if u.Name != nil {
esrv.Name, changed = *u.Name, true
}
+ if u.Region != nil {
+ esrv.Region, changed = *u.Region, true
+ }
if u.Description != nil {
esrv.Description, changed = *u.Description, true
}