Possible Auto Join Issue
Prommah
Join Date: 2013-01-17 Member: 180293Members, NS2 Playtester, NS2 Map Tester, Reinforced - Supporter, Reinforced - Silver, Reinforced - Gold, Reinforced - Diamond, Reinforced - Shadow, WC 2013 - Supporter
I've been working on a mod for the main menu, and noticed a potential issue with the autojoin system.
As far as I can tell, Client.RefreshServer is asynchronous (even without using a callback). Adding the code below to the end of GUIMainMenu.Update to test this never prints "DIFFERENT":
Then I saw this (line 2134, lua/menu/GUIMainMenu.lua):
If Client.RefreshServer is asynchronous, then surely this means that if the server data is refreshed, the client won't check the refreshed data (thus not noticing a free spot) for 10 seconds? In my experience autojoin (most of the time) connects me to popular servers when several people have left or tries to connect then tells me the server is full. I have better luck spamming the connect command in the console. So unless I misunderstand, maybe switching to using a callback could dramatically improve the usefulness of autojoin?
Something like this:
As far as I can tell, Client.RefreshServer is asynchronous (even without using a callback). Adding the code below to the end of GUIMainMenu.Update to test this never prints "DIFFERENT":
if(Client.GetNumServers() > 0) then local startPing = Client.GetServerPing(0); Client.RefreshServer(0); local endPing = Client.GetServerPing(0); if(startPing ~= endPing) then Print("DIFFERENT"); end end
Then I saw this (line 2134, lua/menu/GUIMainMenu.lua):
if self.updateAutoJoin then if not self.timeLastAutoJoinUpdate or self.timeLastAutoJoinUpdate + 10 < Shared.GetTime() then Client.RefreshServer(MainMenu_GetSelectedServer()) if MainMenu_GetSelectedIsFull() then self.timeLastAutoJoinUpdate = Shared.GetTime() else MainMenu_JoinSelected() self.autoJoinWindow:SetIsVisible(false) end end end
If Client.RefreshServer is asynchronous, then surely this means that if the server data is refreshed, the client won't check the refreshed data (thus not noticing a free spot) for 10 seconds? In my experience autojoin (most of the time) connects me to popular servers when several people have left or tries to connect then tells me the server is full. I have better luck spamming the connect command in the console. So unless I misunderstand, maybe switching to using a callback could dramatically improve the usefulness of autojoin?
Something like this:
if self.updateAutoJoin then if not self.timeLastAutoJoinUpdate or self.timeLastAutoJoinUpdate + 10 < Shared.GetTime() then self.timeLastAutoJoinUpdate = Shared.GetTime() Client.RefreshServer(MainMenu_GetSelectedServer(), function(serverIndex) if self.updateAutoJoin then if not MainMenu_GetSelectedIsFull() then MainMenu_JoinSelected() self.autoJoinWindow:SetIsVisible(false) end end end) end end