Merge pull request #656 from diamante0018/main

feat(chat): add chat history (in-game console)
This commit is contained in:
Maurice Heumann 2023-05-07 17:33:55 +02:00 committed by GitHub
commit 052583cae5
2 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,12 @@ namespace chat
a.cmp(dword_ptr(rax, 0x16AE0), 0x0); // game's code
a.jmp(0x14029905B_g);
}
void cl_handle_chat(char* dest, size_t dest_size, const char* src)
{
game::I_strcpy(dest, dest_size, src);
printf("%s\n", dest);
}
}
const char* get_client_name(const uint64_t xuid)
@ -96,7 +102,7 @@ namespace chat
if (xuid < 19 && !game::is_server())
{
char buffer[256];
char buffer[256]{};
game::CL_GetClientName(0, static_cast<int>(xuid - 1), buffer, sizeof(buffer), true);
return utils::string::va("%s\n", buffer);
@ -167,6 +173,9 @@ namespace chat
{
// Ignore some check that suppresses the chat
utils::hook::nop(0x141DEA9BD_g, 2);
// Add chat history to the in-game console
utils::hook::call(0x141DEAA0F_g, cl_handle_chat); // I_strcpy
}
}
};

View File

@ -210,6 +210,9 @@ namespace game
// Utils
WEAK symbol<const char*(char* str)> I_CleanStr{0x1422E9050, 0x140580E80};
WEAK symbol<void(char* dest, size_t destsize, const char* src)> I_strcpy{
0x1422E9410, 0x1405811E0
};
// Variables
WEAK symbol<cmd_function_s> cmd_functions{0x15689DF58, 0x14946F860};