From f0a5e48f5ca6834c0f24b167c904a030894f706e Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Mon, 6 Jun 2022 10:14:44 -0700 Subject: 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 * 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 Co-authored-by: stonedDiscord Co-authored-by: Alex Noir --- src/aoapplication.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/aoapplication.cpp') 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() -- cgit