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,7 +216,19 @@ static void cm()
has_changed = false; has_changed = false;
// Only passive should reconnect // Only passive should reconnect
if (*namesteal == 1) if (*namesteal == 1)
g_IEngine->ClientCmd_Unrestricted("retry"); {
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)) if (!set_name.test_and_set(30000))
return; return;