Many fixes and debug prints removed.

Removed debug prints, as we don't really need them now.

Fixed database updating from cache, until now only inserts was working
fine, updates failing. All because of forgotten comma :(.

Reworked handling of icons in servers lists, now they didn't
recreated, but reused from created on application start. Can also
save us much memory for long runs.

Moved gamemode detector to mainwindow_helpers, where it should be.
This commit is contained in:
2016-10-07 22:21:19 +05:00
parent 1fc5b925f6
commit e46d203a3c
6 changed files with 58 additions and 40 deletions

13
cache/cache_object.go vendored
View File

@@ -84,17 +84,24 @@ func (c *Cache) FlushServers() {
}
}
Database.Unlock()
tx := Database.Db.MustBegin()
fmt.Println("Adding new servers...")
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)
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)
}
}
fmt.Println("Updating cached servers...")
for _, srv := range cached_servers {
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, players_info=:players_info, is_private=:is_private WHERE ip=:ip AND port=:port", &srv)
if err != nil {
fmt.Println(err.Error())
}
}
tx.Commit()
Database.Lock()
fmt.Println("Done")
}