Fix potential ad-hoc problem

This commit is contained in:
BenCat07 2021-08-01 00:38:15 +02:00
parent fd9052e0e3
commit bbb0783530

View File

@ -216,8 +216,20 @@ static void cm()
has_changed = false;
// Only passive should reconnect
if (*namesteal == 1)
{
static std::string previous_server = "";
static int retry_count = 0;
if (previous_server != ((INetChannel *) g_IEngine->GetNetChannelInfo())->GetAddress())
{
previous_server = ((INetChannel *) g_IEngine->GetNetChannelInfo())->GetAddress();
retry_count = 0;
}
retry_count++;
// Retry only up to 3 times, else you get an ad-hoc error
if (retry_count <= 3)
g_IEngine->ClientCmd_Unrestricted("retry");
}
}
if (!set_name.test_and_set(30000))
return;
std::string new_name = GetNamestealName(g_ISteamUser->GetSteamID());