Add command stuff

not finished
This commit is contained in:
quaK 2022-05-18 16:39:04 +03:00
parent a1da1f744c
commit dc43b02a52
4 changed files with 35 additions and 25 deletions

View File

@ -63,8 +63,8 @@ namespace command
static std::string comand_line_buffer = GetCommandLineA(); static std::string comand_line_buffer = GetCommandLineA();
auto* command_line = comand_line_buffer.data(); auto* command_line = comand_line_buffer.data();
auto& com_num_console_lines = *reinterpret_cast<int*>(0x142623FB4); auto& com_num_console_lines = *reinterpret_cast<int*>(0x35634B8_b);
auto* com_console_lines = reinterpret_cast<char**>(0x142623FC0); auto* com_console_lines = reinterpret_cast<char**>(0x35634C0_b);
auto inq = false; auto inq = false;
com_console_lines[0] = command_line; com_console_lines[0] = command_line;
@ -96,7 +96,7 @@ namespace command
void parse_commandline_stub() void parse_commandline_stub()
{ {
parse_command_line(); parse_command_line();
utils::hook::invoke<void>(0x1400D8210); utils::hook::invoke<void>(0x15A4F0_b);
} }
game::dvar_t* dvar_command_stub() game::dvar_t* dvar_command_stub()
@ -127,9 +127,9 @@ namespace command
} }
else else
{ {
char command[0x1000] = { 0 }; //char command[0x1000] = { 0 }; <-- CRASHES??!?!?!?!
game::Dvar_GetCombinedString(command, 1); //game::Dvar_GetCombinedString(command, 1);
game::Dvar_SetCommand(dvar->hash, "", command); //game::Dvar_SetCommand(dvar->hash, "", command);
} }
return dvar; return dvar;
@ -340,12 +340,12 @@ namespace command
// parse the commandline if it's not parsed // parse the commandline if it's not parsed
parse_command_line(); parse_command_line();
auto& com_num_console_lines = *reinterpret_cast<int*>(0x142623FB4); auto& com_num_console_lines = *reinterpret_cast<int*>(0x35634B8_b);
auto* com_console_lines = reinterpret_cast<char**>(0x142623FC0); auto* com_console_lines = reinterpret_cast<char**>(0x35634C0_b);
for (int i = 0; i < com_num_console_lines; i++) for (int i = 0; i < com_num_console_lines; i++)
{ {
game::Cmd_TokenizeString(com_console_lines[i]); game::Cmd_TokenizeString(com_console_lines[i]); // need to re-create this function
// only +set dvar value // only +set dvar value
if (game::Cmd_Argc() >= 3 && game::Cmd_Argv(0) == "set"s && game::Cmd_Argv(1) == dvar) if (game::Cmd_Argc() >= 3 && game::Cmd_Argv(0) == "set"s && game::Cmd_Argv(1) == dvar)
@ -353,7 +353,7 @@ namespace command
game::Dvar_SetCommand(game::generateHashValue(game::Cmd_Argv(1)), "", game::Cmd_Argv(2)); game::Dvar_SetCommand(game::generateHashValue(game::Cmd_Argv(1)), "", game::Cmd_Argv(2));
} }
game::Cmd_EndTokenizeString(); game::Cmd_EndTokenizeString(); // need to re-create this function
} }
} }
@ -508,8 +508,8 @@ namespace command
} }
else else
{ {
utils::hook::call(0x1400D728F, parse_commandline_stub); utils::hook::call(0x157D8F_b, parse_commandline_stub);
utils::hook::jump(0x14041D750, dvar_command_stub); //utils::hook::jump(0x4E9F40_b, dvar_command_stub);
add_commands_mp(); add_commands_mp();
} }
@ -723,7 +723,7 @@ namespace command
static void add_commands_mp() static void add_commands_mp()
{ {
client_command_hook.create(0x140336000, &client_command); client_command_hook.create(0x4132E0_b, &client_command);
add_sv("god", [](const int client_num, const params_sv&) add_sv("god", [](const int client_num, const params_sv&)
{ {
@ -818,4 +818,4 @@ namespace command
}; };
} }
//REGISTER_COMPONENT(command::component) REGISTER_COMPONENT(command::component)

View File

@ -36,6 +36,14 @@ namespace game
return !game::environment::is_sp() && *mp::virtualLobby_loaded == 1; return !game::environment::is_sp() && *mp::virtualLobby_loaded == 1;
} }
void SV_GameSendServerCommand(int clientNum, svscmd_type type, const char* text)
{
if (clientNum == -1)
SV_SendServerCommand(0, type, "%s", text);
else
SV_SendServerCommand(&mp::svs_clients[clientNum], type, "%s", text);
}
namespace environment namespace environment
{ {
launcher::mode mode = launcher::mode::none; launcher::mode mode = launcher::mode::none;

View File

@ -68,6 +68,8 @@ namespace game
const char* SV_Cmd_Argv(int index); const char* SV_Cmd_Argv(int index);
bool VirtualLobby_Loaded(); bool VirtualLobby_Loaded();
void SV_GameSendServerCommand(int clientNum, svscmd_type type, const char* text);
} }
uintptr_t operator"" _b(const uintptr_t ptr); uintptr_t operator"" _b(const uintptr_t ptr);

View File

@ -20,11 +20,11 @@ namespace game
void (int, int, const char*))> Cbuf_ExecuteBufferInternal{0x0, 0x155BC0}; void (int, int, const char*))> Cbuf_ExecuteBufferInternal{0x0, 0x155BC0};
WEAK symbol<void(const char* message)> Conbuf_AppendText{0x0, 0x0}; WEAK symbol<void(const char* message)> Conbuf_AppendText{0x0, 0x0};
WEAK symbol<char*(int start)> ConcatArgs{0x0, 0x413050}; WEAK symbol<char*(int start)> ConcatArgs{0x0, 0x413050};
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x0, 0x0}; WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x0, 0x156E90};
WEAK symbol<void(const char* cmdName, void(), cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{0x0, 0x156880}; WEAK symbol<void(const char* cmdName, void(), cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{0x0, 0x156880};
WEAK symbol<void(const char*)> Cmd_RemoveCommand{0x0, 0x157690}; WEAK symbol<void(const char*)> Cmd_RemoveCommand{0x0, 0x157690};
WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x0, 0x0}; WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x0, 0x0}; // not a function
WEAK symbol<void()> Cmd_EndTokenizeString{0x0, 0x0}; WEAK symbol<void()> Cmd_EndTokenizeString{0x0, 0x0}; // not a function
WEAK symbol<void(void*, void*)> AimAssist_AddToTargetList{0x0, 0xE66C0}; WEAK symbol<void(void*, void*)> AimAssist_AddToTargetList{0x0, 0xE66C0};
@ -39,7 +39,7 @@ namespace game
WEAK symbol<void()> Com_Quit_f{0x0, 0x1F9280}; WEAK symbol<void()> Com_Quit_f{0x0, 0x1F9280};
WEAK symbol<void(char const* finalMessage)> Com_Shutdown{0x0, 0x0}; WEAK symbol<void(char const* finalMessage)> Com_Shutdown{0x0, 0x0};
WEAK symbol<void()> Quit{0x0, 0x1F9280}; WEAK symbol<void()> Quit{0x0, 0x17CF50};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x0, 0x316210}; WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x0, 0x316210};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessageBold{0x0, 0x3122F0}; WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessageBold{0x0, 0x3122F0};
@ -55,7 +55,7 @@ namespace game
WEAK symbol<dvar_t*(const char* name)> Dvar_FindVar{0x0, 0x183EB0}; WEAK symbol<dvar_t*(const char* name)> Dvar_FindVar{0x0, 0x183EB0};
WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{0x0, 0x0}; WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{0x0, 0x0};
WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{0x0, 0x4EA020}; WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{0x0, 0x4EA020};
WEAK symbol<const char*(dvar_t* dvar, dvar_value value)> Dvar_ValueToString{0x0, 0x0}; WEAK symbol<const char*(dvar_t* dvar, dvar_value value)> Dvar_ValueToString{0x0, 0x187000};
WEAK symbol<void(dvar_t* dvar, DvarSetSource source)> Dvar_Reset{0x0, 0x185390}; WEAK symbol<void(dvar_t* dvar, DvarSetSource source)> Dvar_Reset{0x0, 0x185390};
WEAK symbol<void(const char*, const char*, WEAK symbol<void(const char*, const char*,
DvarSetSource)> Dvar_SetFromStringByNameFromSource{0x0, 0x185BD0}; DvarSetSource)> Dvar_SetFromStringByNameFromSource{0x0, 0x185BD0};
@ -86,7 +86,7 @@ namespace game
WEAK symbol<void(VariableValue* result, unsigned int classnum, WEAK symbol<void(VariableValue* result, unsigned int classnum,
int entnum, int offset)> GetEntityFieldValue{0x0, 0x0}; int entnum, int offset)> GetEntityFieldValue{0x0, 0x0};
WEAK symbol<int(const char* fname)> generateHashValue{0x0, 0x0}; WEAK symbol<int(const char* fname)> generateHashValue{0x0, 0x183F80};
WEAK symbol<void()> G_Glass_Update{0x0, 0x0}; WEAK symbol<void()> G_Glass_Update{0x0, 0x0};
WEAK symbol<int(int clientNum)> G_GetClientScore{0x0, 0x0}; WEAK symbol<int(int clientNum)> G_GetClientScore{0x0, 0x0};
@ -186,7 +186,7 @@ namespace game
WEAK symbol<bool(const char* map)> SV_MapExists{0x0, 0x0}; WEAK symbol<bool(const char* map)> SV_MapExists{0x0, 0x0};
WEAK symbol<void(mp::client_t*, const char*, int)> SV_ExecuteClientCommand{0x0, 0x0}; WEAK symbol<void(mp::client_t*, const char*, int)> SV_ExecuteClientCommand{0x0, 0x0};
WEAK symbol<void(int localClientNum)> SV_FastRestart{0x0, 0x0}; WEAK symbol<void(int localClientNum)> SV_FastRestart{0x0, 0x0};
WEAK symbol<void(int clientNum, svscmd_type type, const char* text)> SV_GameSendServerCommand{0x0, 0x0}; WEAK symbol<void(void* cl, int type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x1CC040};
WEAK symbol<void()> Sys_ShowConsole{0x0, 0x0}; WEAK symbol<void()> Sys_ShowConsole{0x0, 0x0};
WEAK symbol<void(const char* error, ...)> Sys_Error{0x0, 0x0}; WEAK symbol<void(const char* error, ...)> Sys_Error{0x0, 0x0};
@ -221,7 +221,7 @@ namespace game
WEAK symbol<const char*> command_whitelist{0x0, 0x0}; WEAK symbol<const char*> command_whitelist{0x0, 0x0};
WEAK symbol<cmd_function_s*> cmd_functions{0x0, 0x344DF18}; WEAK symbol<cmd_function_s*> cmd_functions{0x0, 0x344DF18};
WEAK symbol<CmdArgs> cmd_args{0x0, 0x0}; WEAK symbol<CmdArgs> cmd_args{0x0, 0x2ED1E00};
WEAK symbol<int> g_poolSize{0x0, 0x0}; WEAK symbol<int> g_poolSize{0x0, 0x0};
WEAK symbol<scr_classStruct_t> g_classMap{0x0, 0x0}; WEAK symbol<scr_classStruct_t> g_classMap{0x0, 0x0};
@ -248,15 +248,15 @@ namespace game
namespace mp namespace mp
{ {
WEAK symbol<gentity_s> g_entities{0x0, 0x71F19E0}; WEAK symbol<gentity_s> g_entities{0x0, 0x71F19E0};
WEAK symbol<client_t> svs_clients{0x0, 0x0}; WEAK symbol<client_t> svs_clients{0x0, 0x2DC3390};
WEAK symbol<int> svs_numclients{0x0, 0x0}; WEAK symbol<int> svs_numclients{0x0, 0x2DC338C};
WEAK symbol<int> gameTime{0x0, 0x0}; WEAK symbol<int> gameTime{0x0, 0x0};
WEAK symbol<int> ping{0x0, 0x0}; WEAK symbol<int> ping{0x0, 0x0};
WEAK symbol<int> sv_serverId_value{0x0, 0x0}; WEAK symbol<int> sv_serverId_value{0x0, 0x0};
WEAK symbol<bool> virtualLobby_loaded{0x0, 0x0}; WEAK symbol<bool> virtualLobby_loaded{0x0, 0x2E6EC9D};
} }
namespace sp namespace sp