More debug output and servers refresh fix.
Fixed servers lists refresh. Despite on what list we're updating (all servers or only favorites) server item should be updated in both.
This commit is contained in:
parent
baf733f171
commit
51b23fa68f
2
cache/cache_object.go
vendored
2
cache/cache_object.go
vendored
@ -101,6 +101,7 @@ func (c *Cache) initializeStorages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache) LoadServers() {
|
func (c *Cache) LoadServers() {
|
||||||
|
fmt.Println("Loading servers into cache...")
|
||||||
c.Servers = make(map[string]*cachemodels.Server)
|
c.Servers = make(map[string]*cachemodels.Server)
|
||||||
// Getting servers from database.
|
// Getting servers from database.
|
||||||
raw_servers := []datamodels.Server{}
|
raw_servers := []datamodels.Server{}
|
||||||
@ -129,4 +130,5 @@ func (c *Cache) LoadServers() {
|
|||||||
c.Servers[key].Server.ExtendedConfig = server.ExtendedConfig
|
c.Servers[key].Server.ExtendedConfig = server.ExtendedConfig
|
||||||
c.Servers[key].Server.PlayersInfo = server.PlayersInfo
|
c.Servers[key].Server.PlayersInfo = server.PlayersInfo
|
||||||
}
|
}
|
||||||
|
fmt.Println("Load completed.")
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@ type Colorizer struct {
|
|||||||
|
|
||||||
func (c *Colorizer) Fix(data string) string {
|
func (c *Colorizer) Fix(data string) string {
|
||||||
result := ""
|
result := ""
|
||||||
|
|
||||||
|
data = html.EscapeString(data)
|
||||||
|
|
||||||
data_splitted := strings.Split(data, "^")
|
data_splitted := strings.Split(data, "^")
|
||||||
if len(data_splitted) > 1 {
|
if len(data_splitted) > 1 {
|
||||||
for item := range data_splitted {
|
for item := range data_splitted {
|
||||||
@ -32,7 +35,7 @@ func (c *Colorizer) Fix(data string) string {
|
|||||||
if !ok {
|
if !ok {
|
||||||
colorcode = "#000000"
|
colorcode = "#000000"
|
||||||
}
|
}
|
||||||
result += "<span foreground=\"" + colorcode + "\">" + html.EscapeString(string([]rune(data_splitted[item])[1:])) + "</span>"
|
result += "<span foreground=\"" + colorcode + "\">" + string([]rune(data_splitted[item])[1:]) + "</span>"
|
||||||
} else {
|
} else {
|
||||||
result += data_splitted[item]
|
result += data_splitted[item]
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
//"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -34,8 +34,9 @@ type Pooler struct {
|
|||||||
func (p *Pooler) Initialize() {
|
func (p *Pooler) Initialize() {
|
||||||
fmt.Println("Initializing requester goroutine pooler...")
|
fmt.Println("Initializing requester goroutine pooler...")
|
||||||
// ToDo: figure out how to make this work nice.
|
// ToDo: figure out how to make this work nice.
|
||||||
p.maxrequests = runtime.NumCPU() * 2000
|
p.maxrequests = 500
|
||||||
p.pp = "\377\377\377\377"
|
p.pp = "\377\377\377\377"
|
||||||
|
fmt.Println("Pooler initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Servers pinging pooler. Should be started as goroutine to prevent
|
// Servers pinging pooler. Should be started as goroutine to prevent
|
||||||
@ -119,16 +120,12 @@ func (p *Pooler) UpdateServers(servers_type string) {
|
|||||||
}(server.Server)
|
}(server.Server)
|
||||||
}
|
}
|
||||||
wait.Wait()
|
wait.Wait()
|
||||||
Eventer.LaunchEvent("flushServers")
|
|
||||||
p.PingServers(servers_type)
|
p.PingServers(servers_type)
|
||||||
|
Eventer.LaunchEvent("flushServers")
|
||||||
|
|
||||||
if servers_type == "all" {
|
Eventer.LaunchEvent("loadAllServers")
|
||||||
Eventer.LaunchEvent("loadAllServers")
|
Eventer.LaunchEvent("loadFavoriteServers")
|
||||||
Eventer.LaunchEvent("serversUpdateCompleted")
|
Eventer.LaunchEvent("serversUpdateCompleted")
|
||||||
} else if servers_type == "favorites" {
|
|
||||||
Eventer.LaunchEvent("loadFavoriteServers")
|
|
||||||
Eventer.LaunchEvent("serversUpdateCompleted")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates information about specific server.
|
// Updates information about specific server.
|
||||||
|
@ -293,6 +293,16 @@ func (m *MainWindow) editFavorite() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MainWindow) getGameModeName(name string) string {
|
||||||
|
val, ok := m.gamemodes[name]
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return "Unknown or custom"
|
||||||
|
}
|
||||||
|
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
// Executes when "Hide offline servers" checkbox changed it's state on
|
// Executes when "Hide offline servers" checkbox changed it's state on
|
||||||
// "Servers" tab.
|
// "Servers" tab.
|
||||||
func (m *MainWindow) hideOfflineAllServers() {
|
func (m *MainWindow) hideOfflineAllServers() {
|
||||||
@ -423,8 +433,6 @@ func (m *MainWindow) Initialize() {
|
|||||||
profile_and_launch_hbox.PackStart(profiles_label, false, true, 5)
|
profile_and_launch_hbox.PackStart(profiles_label, false, true, 5)
|
||||||
profile_and_launch_hbox.PackStart(m.profiles, false, true, 5)
|
profile_and_launch_hbox.PackStart(m.profiles, false, true, 5)
|
||||||
|
|
||||||
ctx.Eventer.AddEventHandler("loadProfiles", m.loadProfiles)
|
|
||||||
|
|
||||||
// One more separator.
|
// One more separator.
|
||||||
sepp := gtk.NewVSeparator()
|
sepp := gtk.NewVSeparator()
|
||||||
profile_and_launch_hbox.PackStart(sepp, false, true, 5)
|
profile_and_launch_hbox.PackStart(sepp, false, true, 5)
|
||||||
@ -433,7 +441,7 @@ func (m *MainWindow) Initialize() {
|
|||||||
m.launch_button = gtk.NewButtonWithLabel("Launch!")
|
m.launch_button = gtk.NewButtonWithLabel("Launch!")
|
||||||
m.launch_button.SetTooltipText("Launch Urban Terror")
|
m.launch_button.SetTooltipText("Launch Urban Terror")
|
||||||
m.launch_button.Clicked(m.launchGame)
|
m.launch_button.Clicked(m.launchGame)
|
||||||
launch_button_image := gtk.NewImageFromStock(gtk.STOCK_APPLY, 32)
|
launch_button_image := gtk.NewImageFromStock(gtk.STOCK_APPLY, 24)
|
||||||
m.launch_button.SetImage(launch_button_image)
|
m.launch_button.SetImage(launch_button_image)
|
||||||
profile_and_launch_hbox.PackStart(m.launch_button, false, true, 5)
|
profile_and_launch_hbox.PackStart(m.launch_button, false, true, 5)
|
||||||
|
|
||||||
@ -461,6 +469,7 @@ func (m *MainWindow) initializeEvents() {
|
|||||||
fmt.Println("Initializing events...")
|
fmt.Println("Initializing events...")
|
||||||
ctx.Eventer.AddEventHandler("loadAllServers", m.loadAllServers)
|
ctx.Eventer.AddEventHandler("loadAllServers", m.loadAllServers)
|
||||||
ctx.Eventer.AddEventHandler("loadFavoriteServers", m.loadFavoriteServers)
|
ctx.Eventer.AddEventHandler("loadFavoriteServers", m.loadFavoriteServers)
|
||||||
|
ctx.Eventer.AddEventHandler("loadProfiles", m.loadProfiles)
|
||||||
ctx.Eventer.AddEventHandler("serversUpdateCompleted", m.serversUpdateCompleted)
|
ctx.Eventer.AddEventHandler("serversUpdateCompleted", m.serversUpdateCompleted)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,11 +605,11 @@ func (m *MainWindow) initializeStorages() {
|
|||||||
// Servers tab list view storage.
|
// Servers tab list view storage.
|
||||||
// Structure:
|
// Structure:
|
||||||
// Server status icon|Server name|Mode|Map|Players|Ping|Version
|
// Server status icon|Server name|Mode|Map|Players|Ping|Version
|
||||||
m.all_servers_store = gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
m.all_servers_store = gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
||||||
m.all_servers_store_sortable = gtk.NewTreeSortable(m.all_servers_store)
|
m.all_servers_store_sortable = gtk.NewTreeSortable(m.all_servers_store)
|
||||||
|
|
||||||
// Same as above, but for favorite servers.
|
// Same as above, but for favorite servers.
|
||||||
m.fav_servers_store = gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
m.fav_servers_store = gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
||||||
|
|
||||||
// Server's information store. Used for quick preview in main window.
|
// Server's information store. Used for quick preview in main window.
|
||||||
m.server_info_store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
m.server_info_store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
||||||
@ -972,13 +981,13 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if server.Server.Name == "" && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
if server.Server.Name == "" && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
m.all_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.all_servers_store.SetValue(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
m.all_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
m.all_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
||||||
} else {
|
} else {
|
||||||
m.all_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.all_servers_store.SetValue(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
||||||
m.all_servers_store.SetValue(iter, 1, server_name)
|
m.all_servers_store.SetValue(iter, 1, server_name)
|
||||||
m.all_servers_store.SetValue(iter, 2, m.gamemodes[server.Server.Gamemode])
|
m.all_servers_store.SetValue(iter, 2, m.getGameModeName(server.Server.Gamemode))
|
||||||
m.all_servers_store.SetValue(iter, 3, server.Server.Map)
|
m.all_servers_store.SetValue(iter, 3, server.Server.Map)
|
||||||
m.all_servers_store.SetValue(iter, 4, server.Server.Players + "/" + server.Server.Maxplayers)
|
m.all_servers_store.SetValue(iter, 4, server.Server.Players + "/" + server.Server.Maxplayers)
|
||||||
m.all_servers_store.SetValue(iter, 5, server.Server.Ping)
|
m.all_servers_store.SetValue(iter, 5, server.Server.Ping)
|
||||||
@ -1016,13 +1025,13 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if server.Server.Name == "" && server.Server.Players == "" {
|
if server.Server.Name == "" && server.Server.Players == "" {
|
||||||
m.fav_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.fav_servers_store.SetValue(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
m.fav_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
m.fav_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
||||||
} else {
|
} else {
|
||||||
m.fav_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.fav_servers_store.SetValue(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
||||||
m.fav_servers_store.SetValue(iter, 1, server_name)
|
m.fav_servers_store.SetValue(iter, 1, server_name)
|
||||||
m.fav_servers_store.SetValue(iter, 2, m.gamemodes[server.Server.Gamemode])
|
m.fav_servers_store.SetValue(iter, 2, m.getGameModeName(server.Server.Gamemode))
|
||||||
m.fav_servers_store.SetValue(iter, 3, server.Server.Map)
|
m.fav_servers_store.SetValue(iter, 3, server.Server.Map)
|
||||||
m.fav_servers_store.SetValue(iter, 4, server.Server.Players + "/" + server.Server.Maxplayers)
|
m.fav_servers_store.SetValue(iter, 4, server.Server.Players + "/" + server.Server.Maxplayers)
|
||||||
m.fav_servers_store.SetValue(iter, 5, server.Server.Ping)
|
m.fav_servers_store.SetValue(iter, 5, server.Server.Ping)
|
||||||
@ -1167,8 +1176,9 @@ func (m *MainWindow) showShortServerInformation() {
|
|||||||
|
|
||||||
for _, value := range parsed_players_info {
|
for _, value := range parsed_players_info {
|
||||||
iter = new(gtk.TreeIter)
|
iter = new(gtk.TreeIter)
|
||||||
|
nick := ctx.Colorizer.Fix(value["nick"])
|
||||||
m.server_info_store.Append(iter)
|
m.server_info_store.Append(iter)
|
||||||
m.server_info_store.SetValue(iter, 0, value["nick"])
|
m.server_info_store.SetValue(iter, 0, nick)
|
||||||
m.server_info_store.SetValue(iter, 1, "(frags: " + value["frags"] + " | ping: " + value["ping"] + ")")
|
m.server_info_store.SetValue(iter, 1, "(frags: " + value["frags"] + " | ping: " + value["ping"] + ")")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user