diff --git a/src/client/component/network.cpp b/src/client/component/network.cpp index da580bd3..e2d708eb 100644 --- a/src/client/component/network.cpp +++ b/src/client/component/network.cpp @@ -160,6 +160,25 @@ namespace network send_data(address, data.data(), data.size()); } + game::netadr_t address_from_string(const std::string& address) + { + game::netadr_t addr{}; + addr.localNetID = game::NS_SERVER; + + if (!game::NET_StringToAdr(address.data(), &addr)) + { + addr.type = game::NA_BAD; + return addr; + } + + if (addr.type == game::NA_IP) + { + addr.type = game::NA_RAWIP; + } + + return addr; + } + class component final : public component_interface { public: diff --git a/src/client/component/network.hpp b/src/client/component/network.hpp index dfbd3971..6cd70d1e 100644 --- a/src/client/component/network.hpp +++ b/src/client/component/network.hpp @@ -12,4 +12,6 @@ namespace network void send_data(const game::netadr_t& address, const void* data, size_t length); void send_data(const game::netadr_t& address, const std::string& data); + + game::netadr_t address_from_string(const std::string& address); } diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp new file mode 100644 index 00000000..ad073f49 --- /dev/null +++ b/src/client/component/party.cpp @@ -0,0 +1,37 @@ +#include +#include "loader/component_loader.hpp" + +#include "network.hpp" +#include "game/game.hpp" + +#include + +namespace party +{ + namespace + { + void connect_stub(const char* address) + { + auto addr = network::address_from_string(address); + + game::XSESSION_INFO info{}; + game::CL_ConnectFromLobby(0, &info, &addr, 1, 0, "mp_nuketown_x", "tdm"); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + utils::hook::jump(0x141EE6030_g, connect_stub); + + /*network::on("_pong", [](const game::netadr_t& source, const network::data_view& data) + { + + });*/ + } + }; +} + +REGISTER_COMPONENT(party::component) diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 5f4e2ea6..132e2ccf 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -35,6 +35,8 @@ namespace game // NET WEAK symbol NET_SendPacket{0x142332F70_g}; + WEAK symbol NET_StringToAdr{0x1421731E0_g}; + WEAK symbol NetAdr_InitFromString{0x142332F70_g}; // Sys WEAK symbol Sys_ShowConsole{0x142333F80_g};