Prepare connecting

This commit is contained in:
momo5502 2022-10-28 20:34:10 +02:00
parent 5c1fe422e4
commit 1f525186e9
4 changed files with 60 additions and 0 deletions

View File

@ -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:

View File

@ -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);
}

View File

@ -0,0 +1,37 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "network.hpp"
#include "game/game.hpp"
#include <utils/hook.hpp>
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)

View File

@ -35,6 +35,8 @@ namespace game
// NET
WEAK symbol<bool(netsrc_t sock, int length, const void* data, const netadr_t* to)> NET_SendPacket{0x142332F70_g};
WEAK symbol<bool(char const*, netadr_t*)> NET_StringToAdr{0x1421731E0_g};
WEAK symbol<bool(netadr_t*, char const*)> NetAdr_InitFromString{0x142332F70_g};
// Sys
WEAK symbol<void()> Sys_ShowConsole{0x142333F80_g};