mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Merge pull request #8527 from Robyt3/Client-GenerateTimeoutCode
Extract `GenerateTimeoutCode` function to reduce duplicate code, avoid magic numbers for generating timeout code
This commit is contained in:
commit
6c5095203f
|
@ -202,6 +202,20 @@ void CGameClient::OnConsoleInit()
|
|||
Console()->Chain("cl_menu_map", ConchainMenuMap, this);
|
||||
}
|
||||
|
||||
static void GenerateTimeoutCode(char *pTimeoutCode)
|
||||
{
|
||||
if(pTimeoutCode[0] == '\0' || str_comp(pTimeoutCode, "hGuEYnfxicsXGwFq") == 0)
|
||||
{
|
||||
for(unsigned int i = 0; i < 16; i++)
|
||||
{
|
||||
if(rand() % 2)
|
||||
pTimeoutCode[i] = (char)((rand() % ('z' - 'a' + 1)) + 'a');
|
||||
else
|
||||
pTimeoutCode[i] = (char)((rand() % ('Z' - 'A' + 1)) + 'A');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameClient::OnInit()
|
||||
{
|
||||
const int64_t OnInitStart = time_get();
|
||||
|
@ -324,27 +338,8 @@ void CGameClient::OnInit()
|
|||
// Set free binds to DDRace binds if it's active
|
||||
m_Binds.SetDDRaceBinds(true);
|
||||
|
||||
if(g_Config.m_ClTimeoutCode[0] == '\0' || str_comp(g_Config.m_ClTimeoutCode, "hGuEYnfxicsXGwFq") == 0)
|
||||
{
|
||||
for(unsigned int i = 0; i < 16; i++)
|
||||
{
|
||||
if(rand() % 2)
|
||||
g_Config.m_ClTimeoutCode[i] = (char)((rand() % 26) + 97);
|
||||
else
|
||||
g_Config.m_ClTimeoutCode[i] = (char)((rand() % 26) + 65);
|
||||
}
|
||||
}
|
||||
|
||||
if(g_Config.m_ClDummyTimeoutCode[0] == '\0' || str_comp(g_Config.m_ClDummyTimeoutCode, "hGuEYnfxicsXGwFq") == 0)
|
||||
{
|
||||
for(unsigned int i = 0; i < 16; i++)
|
||||
{
|
||||
if(rand() % 2)
|
||||
g_Config.m_ClDummyTimeoutCode[i] = (char)((rand() % 26) + 97);
|
||||
else
|
||||
g_Config.m_ClDummyTimeoutCode[i] = (char)((rand() % 26) + 65);
|
||||
}
|
||||
}
|
||||
GenerateTimeoutCode(g_Config.m_ClTimeoutCode);
|
||||
GenerateTimeoutCode(g_Config.m_ClDummyTimeoutCode);
|
||||
|
||||
m_MapImages.SetTextureScale(g_Config.m_ClTextEntitiesSize);
|
||||
|
||||
|
|
Loading…
Reference in a new issue