add an ugly launcher reference

idk how else to do it.
This commit is contained in:
Lion Kortlepel
2024-03-03 13:50:04 +01:00
parent c74967e513
commit 342b3c3075
6 changed files with 16 additions and 30 deletions
+3 -2
View File
@@ -54,8 +54,9 @@ void ClientNetwork::run() {
} while (!*m_shutdown); } while (!*m_shutdown);
} }
ClientNetwork::ClientNetwork(uint16_t port) ClientNetwork::ClientNetwork(Launcher& launcher, uint16_t port)
: m_listen_port(port) { : m_listen_port(port)
, launcher(launcher) {
spdlog::debug("Client network created"); spdlog::debug("Client network created");
} }
+3 -1
View File
@@ -13,7 +13,7 @@ using namespace boost::asio;
class ClientNetwork { class ClientNetwork {
public: public:
ClientNetwork(uint16_t port); ClientNetwork(Launcher& launcher, uint16_t port);
~ClientNetwork(); ~ClientNetwork();
@@ -56,4 +56,6 @@ private:
ip::tcp::socket m_game_socket { m_io }; ip::tcp::socket m_game_socket { m_io };
Sync<bool> m_shutdown { false }; Sync<bool> m_shutdown { false };
bmp::ClientState m_client_state; bmp::ClientState m_client_state;
Launcher& launcher;
}; };
+2 -6
View File
@@ -22,11 +22,7 @@ using namespace boost::asio;
namespace fs = std::filesystem; namespace fs = std::filesystem;
Launcher::Launcher() Launcher::Launcher() {
: m_game_socket(m_io)
, m_core_socket(m_io)
, m_tcp_socket(m_io)
, m_udp_socket(m_io) {
spdlog::debug("Launcher startup"); spdlog::debug("Launcher startup");
m_config = Config {}; m_config = Config {};
if (!m_config->is_valid) { if (!m_config->is_valid) {
@@ -194,7 +190,7 @@ void Launcher::pre_game() {
if (FileHash != LatestHash) { if (FileHash != LatestHash) {
spdlog::info("Downloading BeamMP Update " + LatestHash); spdlog::info("Downloading BeamMP Update " + LatestHash);
HTTP::Download(fmt::format("https://backend.beammp.com/builds/client?download=true&pk={}&branch={}", m_identity->PublicKey, m_config->branch), ZipPath.generic_string()); HTTP::Download(fmt::format("https://backend.beammp.com/builds/client?download=true&pk={}&branch={}", identity->PublicKey, m_config->branch), ZipPath.generic_string());
} }
auto Target = std::filesystem::path(m_config->game_dir) / "mods/unpacked/beammp"; auto Target = std::filesystem::path(m_config->game_dir) / "mods/unpacked/beammp";
+2 -18
View File
@@ -52,27 +52,11 @@ private:
boost::scoped_thread<> m_proxy_thread { &Launcher::proxy_main, this }; boost::scoped_thread<> m_proxy_thread { &Launcher::proxy_main, this };
boost::scoped_thread<> m_game_thread; boost::scoped_thread<> m_game_thread;
boost::scoped_thread<> m_client_thread; boost::scoped_thread<> m_client_network_thread;
boost::scoped_thread<> m_tcp_game_thread; boost::scoped_thread<> m_server_network_thread;
boost::scoped_thread<> m_udp_thread;
boost::scoped_thread<> m_ping_thread;
Sync<std::string> m_exe_name; Sync<std::string> m_exe_name;
Sync<std::filesystem::path> m_exe_path; Sync<std::filesystem::path> m_exe_path;
boost::asio::io_context m_io {}; boost::asio::io_context m_io {};
boost::asio::ip::tcp::socket m_game_socket;
boost::asio::ip::tcp::socket m_core_socket;
boost::asio::ip::tcp::socket m_tcp_socket;
boost::asio::ip::udp::socket m_udp_socket;
boost::asio::ip::udp::endpoint m_udp_endpoint;
Sync<bool> m_shutdown { false }; Sync<bool> m_shutdown { false };
Sync<std::chrono::high_resolution_clock::time_point> m_ping_start;
Sync<std::chrono::high_resolution_clock::time_point> m_ping_end;
Sync<std::string> m_m_status {};
Sync<std::string> m_ul_status {};
Sync<std::set<std::string>> m_conf_list;
Sync<std::string> m_list_of_mods {};
}; };
+3 -2
View File
@@ -9,8 +9,9 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
ServerNetwork::ServerNetwork(const ip::tcp::endpoint& ep) ServerNetwork::ServerNetwork(Launcher& launcher, const ip::tcp::endpoint& ep)
: m_tcp_ep(ep) { : m_tcp_ep(ep)
, launcher(launcher) {
spdlog::debug("Server network created"); spdlog::debug("Server network created");
} }
+3 -1
View File
@@ -10,7 +10,7 @@ class Launcher;
class ServerNetwork { class ServerNetwork {
public: public:
ServerNetwork(const ip::tcp::endpoint& ep); ServerNetwork(Launcher& launcher, const ip::tcp::endpoint& ep);
~ServerNetwork(); ~ServerNetwork();
/// Starts and runs the connection to the server. /// Starts and runs the connection to the server.
@@ -46,4 +46,6 @@ private:
ip::tcp::endpoint m_tcp_ep; ip::tcp::endpoint m_tcp_ep;
ip::udp::endpoint m_udp_ep; ip::udp::endpoint m_udp_ep;
Launcher& launcher;
}; };