Finish network component

This commit is contained in:
Federico Cecchetto 2022-05-28 17:08:55 +02:00
parent d23d2f090d
commit 38803022ba
5 changed files with 53 additions and 4 deletions

View File

@ -291,8 +291,8 @@ namespace network
utils::hook::nop(0x54E168_b, 4); // this crashes when reconnecting for some reason
// allow server owner to modify net_port before the socket bind
// utils::hook::call(0x5BD2B5_b, register_netport_stub);
// utils::hook::call(0x5BD3F0_b, register_netport_stub);
utils::hook::call(0x5BD2B5_b, register_netport_stub);
utils::hook::call(0x5BD3F0_b, register_netport_stub);
// increase allowed packet size
const auto max_packet_size = 0x20000;

View File

@ -65,6 +65,33 @@ namespace game
}
}
void Cmd_TokenizeString(const char* text)
{
if (game::environment::is_sp())
{
sp::Cmd_TokenizeString(text);
}
else
{
const auto a2 = 512 - *reinterpret_cast<int*>(0x3516F40_b);
mp::Cmd_TokenizeStringWithLimit(text, a2);
}
}
void Cmd_EndTokenizeString()
{
if (game::environment::is_sp())
{
return sp::Cmd_EndTokenizeString();
}
const auto nesting = cmd_args->nesting;
const auto argc = cmd_args->argc[nesting];
--cmd_args->nesting;
cmd_argsPrivate->totalUsedArgvPool -= argc;
cmd_argsPrivate->totalUsedTextPool -= cmd_argsPrivate->usedTextPool[nesting];
}
namespace environment
{
launcher::mode mode = launcher::mode::none;

View File

@ -72,6 +72,9 @@ namespace game
void SV_GameSendServerCommand(int clientNum, svscmd_type type, const char* text);
void Cbuf_AddText(int local_client_num, int controller_index, const char* cmd);
void Cmd_TokenizeString(const char* text);
void Cmd_EndTokenizeString();
}
uintptr_t operator"" _b(const uintptr_t ptr);

View File

@ -850,6 +850,15 @@ namespace game
const char** argv[8];
};
struct CmdArgsPrivate
{
char textPool[8192];
const char* argvPool[512];
int usedTextPool[8];
int totalUsedArgvPool;
int totalUsedTextPool;
};
struct cmd_function_s
{
cmd_function_s* next;

View File

@ -32,8 +32,17 @@ namespace game
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x376FF0, 0x156E90};
WEAK symbol<void(const char* cmdName, void(), cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{0x376A40, 0x156880};
WEAK symbol<void(const char*)> Cmd_RemoveCommand{0x377670, 0x157690};
WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x377790, 0x0}; // not a function
WEAK symbol<void()> Cmd_EndTokenizeString{0x0, 0x0}; // not a function
namespace sp
{
WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x377790, 0x0};
WEAK symbol<void()> Cmd_EndTokenizeString{0x376C90, 0x0};
}
namespace mp
{
WEAK symbol<void(const char* text_in, int limit)> Cmd_TokenizeStringWithLimit{0x0, 0x157A40};
}
WEAK symbol<void(void*, void*)> AimAssist_AddToTargetList{0x0, 0xE66C0};
@ -230,6 +239,7 @@ namespace game
WEAK symbol<const char*> command_whitelist{0x115ADF0, 0x10ACB70};
WEAK symbol<cmd_function_s*> cmd_functions{0xB490038, 0x344DF18};
WEAK symbol<CmdArgs> cmd_args{0xB48FEE0, 0x2ED1E00};
WEAK symbol<CmdArgsPrivate> cmd_argsPrivate{0, 0x3513F20};
WEAK symbol<int> g_poolSize{0x0, 0x0};