Favorites and database fixes, players info and extended server config.

Adding a favorite server now requires created valid profile. It will
not allow to create favorite server without proper profile.

Fixed servers updating database, now they put all fields there.

Added stubs for players info and extended server config things in
database.
This commit is contained in:
2016-10-05 02:47:13 +05:00
parent dbf5b60ead
commit c22744765b
5 changed files with 38 additions and 4 deletions

View File

@@ -195,7 +195,7 @@ func (r *Requester) UpdateServer(server *datamodels.Server) error {
ddl = ddl.Add(time.Second * 2)
conn.SetDeadline(ddl)
msg := []byte(r.pp + "getinfo")
msg := []byte(r.pp + "getstatus")
conn.Write(msg)
// UDP Buffer.
@@ -218,10 +218,10 @@ func (r *Requester) UpdateServer(server *datamodels.Server) error {
srv_config := strings.Split(received_lines[1], "\\")
// Parse server configuration into passed server's datamodel.
for i := 0; i < len(srv_config); i = i + 1 {
if srv_config[i] == "modversion" {
if srv_config[i] == "g_modversion" {
server.Version = srv_config[i + 1]
}
if srv_config[i] == "gametype" {
if srv_config[i] == "g_gametype" {
server.Gamemode = srv_config[i + 1]
}
if srv_config[i] == "sv_maxclients" {
@@ -233,14 +233,22 @@ func (r *Requester) UpdateServer(server *datamodels.Server) error {
if srv_config[i] == "mapname" {
server.Map = srv_config[i + 1]
}
if srv_config[i] == "hostname" {
if srv_config[i] == "sv_hostname" {
server.Name = srv_config[i + 1]
}
}
if len(received_lines) >= 2 {
// Here we go, players information.
players := received_lines[2:]
server.Players = strconv.Itoa(len(players))
}
}
// ToDo: Calculate ping. 0 for now.
server.Ping = "0"
// ToDo: put this info.
server.ExtendedConfig = ""
server.PlayersInfo = ""
return nil
}