Fixed favorite server addition and saving.
This commit is contained in:
parent
1b3b7bccf8
commit
e12bcdd386
6
cache/cache_servers.go
vendored
6
cache/cache_servers.go
vendored
@ -63,6 +63,7 @@ func (c *Cache) FlushServers(data map[string]string) {
|
||||
new_servers[mapping_item_name].ExtendedConfig = s.Server.ExtendedConfig
|
||||
new_servers[mapping_item_name].PlayersInfo = s.Server.PlayersInfo
|
||||
new_servers[mapping_item_name].IsPrivate = s.Server.IsPrivate
|
||||
new_servers[mapping_item_name].Favorite = s.Server.Favorite
|
||||
} else {
|
||||
cached_servers[mapping_item_name].Ip = s.Server.Ip
|
||||
cached_servers[mapping_item_name].Port = s.Server.Port
|
||||
@ -76,6 +77,7 @@ func (c *Cache) FlushServers(data map[string]string) {
|
||||
cached_servers[mapping_item_name].ExtendedConfig = s.Server.ExtendedConfig
|
||||
cached_servers[mapping_item_name].PlayersInfo = s.Server.PlayersInfo
|
||||
cached_servers[mapping_item_name].IsPrivate = s.Server.IsPrivate
|
||||
cached_servers[mapping_item_name].Favorite = s.Server.Favorite
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,12 +86,12 @@ func (c *Cache) FlushServers(data map[string]string) {
|
||||
fmt.Println("Adding new servers...")
|
||||
if len(new_servers) > 0 {
|
||||
for _, srv := range new_servers {
|
||||
tx.NamedExec("INSERT INTO servers (ip, port, name, ping, players, maxplayers, gamemode, map, version, extended_config, players_info, is_private) VALUES (:ip, :port, :name, :ping, :players, :maxplayers, :gamemode, :map, :version, :extended_config, :players_info, :is_private)", srv)
|
||||
tx.NamedExec("INSERT INTO servers (ip, port, name, ping, players, maxplayers, gamemode, map, version, extended_config, players_info, is_private, favorite) VALUES (:ip, :port, :name, :ping, :players, :maxplayers, :gamemode, :map, :version, :extended_config, :players_info, :is_private, :favorite)", srv)
|
||||
}
|
||||
}
|
||||
fmt.Println("Updating cached servers...")
|
||||
for _, srv := range cached_servers {
|
||||
_, err := tx.NamedExec("UPDATE servers SET name=:name, players=:players, maxplayers=:maxplayers, gamemode=:gamemode, map=:map, ping=:ping, version=:version, extended_config=:extended_config, players_info=:players_info, is_private=:is_private WHERE ip=:ip AND port=:port", &srv)
|
||||
_, err := tx.NamedExec("UPDATE servers SET name=:name, players=:players, maxplayers=:maxplayers, gamemode=:gamemode, map=:map, ping=:ping, version=:version, extended_config=:extended_config, favorite=:favorite, password=:password, players_info=:players_info, is_private=:is_private WHERE ip=:ip AND port=:port", &srv)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
@ -245,6 +245,7 @@ func (f *FavoriteDialog) saveFavorite() error {
|
||||
ctx.Cache.Servers[key].Server.ExtendedConfig = f.server.ExtendedConfig
|
||||
ctx.Cache.Servers[key].Server.PlayersInfo = f.server.PlayersInfo
|
||||
|
||||
ctx.Eventer.LaunchEvent("flushServers", map[string]string{})
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
|
||||
f.window.Destroy()
|
||||
|
||||
|
@ -135,7 +135,10 @@ func (m *MainWindow) addToFavorites() {
|
||||
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
|
||||
server_address := m.getIpFromServersList(current_tab)
|
||||
server_address := ""
|
||||
if !strings.Contains(current_tab, "Favorites") {
|
||||
server_address = m.getIpFromServersList(current_tab)
|
||||
}
|
||||
|
||||
// Getting server from database.
|
||||
m.favorite_dialog = &FavoriteDialog{}
|
||||
|
Reference in New Issue
Block a user