maint: remove colours from dogs

This commit is contained in:
6arelyFuture 2025-01-09 15:40:46 +01:00
parent 8da7cf61cf
commit 8b48f92f08
Signed by: Future
GPG Key ID: F2000F181A4F7C85
2 changed files with 30 additions and 1 deletions

View File

@ -76,7 +76,16 @@ namespace colors
void com_clean_name_stub(const char* in, char* out, const int out_size)
{
strncpy_s(out, out_size, in, _TRUNCATE);
// Check that the name is at least 3 char without colors
char name[16]{};
game::I_strncpyz(out, in, out_size);
utils::string::strip(out, name, std::strlen(out) + 1);
if (std::strlen(name) < 3)
{
game::I_strncpyz(out, "UnnamedPlayer", out_size);
}
}
char* i_clean_str_stub(char* string)
@ -96,6 +105,21 @@ namespace colors
return result;
}
int com_sprintf_stub(char* dest, int size, const char* fmt, const char* name)
{
const auto len = sprintf_s(dest, size, fmt, name);
if (len < 0)
{
game::I_strncpyz(dest, "UnnamedAgent", size);
return len;
}
// This should inherit the name of the owner (a player) which already passed the length check in Com_CleanName
utils::string::strip(dest, dest, len + 1);
return len;
}
void rb_lookup_color_stub(const char index, DWORD* color)
{
*color = RGB(255, 255, 255);
@ -141,6 +165,10 @@ namespace colors
// don't apply colors to overhead names
utils::hook::call(0x14025CE79, cl_get_client_name_and_clan_tag_stub);
// don't apply colors to overhead names of agents (like dogs or juggernauts)
// hook Com_sprintf in CL_GetAgentName
utils::hook::call(0x1402CF760, com_sprintf_stub);
// patch I_CleanStr
utils::hook::jump(0x1404F63C0, i_clean_str_stub);
}

View File

@ -108,6 +108,7 @@ namespace game
WEAK symbol<game_hudelem_s*(int clientNum, int teamNum)> HudElem_Alloc{0x0, 0x1403997E0};
WEAK symbol<char*(char* string)> I_CleanStr{0x140432460, 0x1404F63C0};
WEAK symbol<void(char* dest, const char* src, int destsize)> I_strncpyz{0x140432810, 0x1404F67A0};
WEAK symbol<char*(GfxImage* image, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipCount,
uint32_t imageFlags, DXGI_FORMAT imageFormat, const char* name, const void* initData)>