Skip to content

Commit

Permalink
add an ugly launcher reference
Browse files Browse the repository at this point in the history
idk how else to do it.
  • Loading branch information
lionkor committed Mar 3, 2024
1 parent c74967e commit 342b3c3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 30 deletions.
5 changes: 3 additions & 2 deletions src/ClientNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ void ClientNetwork::run() {
} while (!*m_shutdown);
}

ClientNetwork::ClientNetwork(uint16_t port)
: m_listen_port(port) {
ClientNetwork::ClientNetwork(Launcher& launcher, uint16_t port)
: m_listen_port(port)
, launcher(launcher) {
spdlog::debug("Client network created");
}

Expand Down
4 changes: 3 additions & 1 deletion src/ClientNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace boost::asio;

class ClientNetwork {
public:
ClientNetwork(uint16_t port);
ClientNetwork(Launcher& launcher, uint16_t port);

~ClientNetwork();

Expand Down Expand Up @@ -56,4 +56,6 @@ class ClientNetwork {
ip::tcp::socket m_game_socket { m_io };
Sync<bool> m_shutdown { false };
bmp::ClientState m_client_state;

Launcher& launcher;
};
8 changes: 2 additions & 6 deletions src/Launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ using namespace boost::asio;

namespace fs = std::filesystem;

Launcher::Launcher()
: m_game_socket(m_io)
, m_core_socket(m_io)
, m_tcp_socket(m_io)
, m_udp_socket(m_io) {
Launcher::Launcher() {
spdlog::debug("Launcher startup");
m_config = Config {};
if (!m_config->is_valid) {
Expand Down Expand Up @@ -194,7 +190,7 @@ void Launcher::pre_game() {

if (FileHash != 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";
Expand Down
20 changes: 2 additions & 18 deletions src/Launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,11 @@ class Launcher {

boost::scoped_thread<> m_proxy_thread { &Launcher::proxy_main, this };
boost::scoped_thread<> m_game_thread;
boost::scoped_thread<> m_client_thread;
boost::scoped_thread<> m_tcp_game_thread;
boost::scoped_thread<> m_udp_thread;
boost::scoped_thread<> m_ping_thread;
boost::scoped_thread<> m_client_network_thread;
boost::scoped_thread<> m_server_network_thread;

Sync<std::string> m_exe_name;
Sync<std::filesystem::path> m_exe_path;
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<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 {};
};
5 changes: 3 additions & 2 deletions src/ServerNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <nlohmann/json.hpp>
#include <spdlog/spdlog.h>

ServerNetwork::ServerNetwork(const ip::tcp::endpoint& ep)
: m_tcp_ep(ep) {
ServerNetwork::ServerNetwork(Launcher& launcher, const ip::tcp::endpoint& ep)
: m_tcp_ep(ep)
, launcher(launcher) {
spdlog::debug("Server network created");
}

Expand Down
4 changes: 3 additions & 1 deletion src/ServerNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Launcher;

class ServerNetwork {
public:
ServerNetwork(const ip::tcp::endpoint& ep);
ServerNetwork(Launcher& launcher, const ip::tcp::endpoint& ep);
~ServerNetwork();

/// Starts and runs the connection to the server.
Expand Down Expand Up @@ -46,4 +46,6 @@ class ServerNetwork {

ip::tcp::endpoint m_tcp_ep;
ip::udp::endpoint m_udp_ep;

Launcher& launcher;
};

0 comments on commit 342b3c3

Please sign in to comment.