aboutsummaryrefslogtreecommitdiff
path: root/src/aoapplication.cpp
diff options
context:
space:
mode:
authorSalanto <62221668+Salanto@users.noreply.github.com>2022-06-06 10:14:44 -0700
committerGitHub <noreply@github.com>2022-06-06 19:14:44 +0200
commitf0a5e48f5ca6834c0f24b167c904a030894f706e (patch)
tree0e7ae1497d0164e3a1a3c1d61a88e4f719beb5b5 /src/aoapplication.cpp
parentc4f459b6cce6382cbd7c1960a6738a5a8a45ab8c (diff)
Dual-Stack AO2 Client to handle both TCP and Websocket connections seemlessly (#696)
* Replace TCP Serversocket with Websocket * Have TCP sockets live harmoniously with WS "like 5 lines" yeah probably lost a bet. * Update .gitlab-ci.yml * hack to fix favorites * Add support for websockets in the favorites list (serverlist.txt) Make "add_favorite_server" remember the socket type * Preserve old serverlist style This will keep new entries compatible with 2.9 and prior clients. Makes parsing the list easier too. * Add lookup table and correct write code to use lowercase * I have no idea what a lookup table is, but this looks close enough * Fix lookup table * Otherwise backend selection behaviour is inverted * clang-tidy had one job * Yet it did not do it. Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> * const p_data * Switch serverlist.txt to an ini format * Fixes an Omni bug where : would split the servername * Utilises internally QSettings properly for low parsing effort and clear structure * Automatically migrates the legacy serverlist.txt to favorite_servers.ini * Pleases my OCD * Replace sample serverlist. Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> Co-authored-by: stonedDiscord <Tukz@gmx.de> Co-authored-by: Alex Noir <Varsash@gmail.com>
Diffstat (limited to 'src/aoapplication.cpp')
-rw-r--r--src/aoapplication.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp
index 13c995f2..1e70ca93 100644
--- a/src/aoapplication.cpp
+++ b/src/aoapplication.cpp
@@ -144,12 +144,22 @@ void AOApplication::add_favorite_server(int p_server)
return;
server_type fav_server = server_list.at(p_server);
+ QSettings l_favorite_ini(get_base_path() + "favorite_servers.ini", QSettings::IniFormat);
+ QString l_new_group = QString::number(l_favorite_ini.childGroups().size());
+ l_favorite_ini.setIniCodec("UTF-8");
- QString str_port = QString::number(fav_server.port);
+ l_favorite_ini.beginGroup(l_new_group);
+ l_favorite_ini.setValue("name", fav_server.name);
+ l_favorite_ini.setValue("address", fav_server.ip);
+ l_favorite_ini.setValue("port", fav_server.port);
- QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name;
-
- write_to_serverlist_txt(server_line);
+ if (fav_server.socket_type == TCP) {
+ l_favorite_ini.setValue("protocol", "tcp");
+ }
+ else {
+ l_favorite_ini.setValue("protocol", "ws");
+ }
+ l_favorite_ini.sync();
}
void AOApplication::server_disconnected()