From bbb07835304154cfdf165ce115e686b9bafa4545 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Sun, 1 Aug 2021 00:38:15 +0200 Subject: [PATCH] Fix potential ad-hoc problem --- src/hooks/GetFriendPersonaName.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/hooks/GetFriendPersonaName.cpp b/src/hooks/GetFriendPersonaName.cpp index 449803f4..065fdb68 100644 --- a/src/hooks/GetFriendPersonaName.cpp +++ b/src/hooks/GetFriendPersonaName.cpp @@ -216,7 +216,19 @@ static void cm() has_changed = false; // Only passive should reconnect 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)) return;