Added small tweaks to lobby balancer and sorter for better spread on connect.
This commit is contained in:
parent
8b747a81e1
commit
e6818c4c46
@ -45,6 +45,8 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
if (!event.getTarget().getName().equalsIgnoreCase("Lobby"))
|
||||
return;
|
||||
|
||||
boolean sort = false;
|
||||
|
||||
synchronized (_serverLock)
|
||||
{
|
||||
if (_playersSentToBestServer >= _maxPlayersToSendToBestServer)
|
||||
@ -64,6 +66,11 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
{
|
||||
_bestServerIndex = 0;
|
||||
_maxPlayersToSendToBestServer = 1;
|
||||
|
||||
// Since we had to enter our dangerzone, update local data so if we have to enter it again we don't pick the same server over and over
|
||||
_sortedLobbies.get(_bestServerIndex).Players += 5;
|
||||
sort = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +78,10 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_bestServerIndex).Name));
|
||||
|
||||
_playersSentToBestServer++;
|
||||
|
||||
// Only if we had to pick default regardless of the buffer safezone
|
||||
if (sort)
|
||||
Collections.sort(_sortedLobbies, new LobbySorter());
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +92,6 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
|
||||
public void loadLobbyServers()
|
||||
{
|
||||
_playersSentToBestServer = 0;
|
||||
|
||||
List<ServerStatusData> serverStatusDataList = _repository.retrieveServerStatuses();
|
||||
|
||||
synchronized (_serverLock)
|
||||
@ -108,6 +117,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
|
||||
Collections.sort(_sortedLobbies, new LobbySorter());
|
||||
|
||||
_playersSentToBestServer = 0;
|
||||
_bestServerIndex = 0;
|
||||
|
||||
if (_sortedLobbies.size() > 0)
|
||||
|
@ -13,12 +13,6 @@ public class LobbySorter implements Comparator<ServerStatusData>
|
||||
if (first.Players == 999)
|
||||
return 1;
|
||||
|
||||
if (first.MaxPlayers - first.Players > 15 && second.MaxPlayers - second.Players <= 15)
|
||||
return -1;
|
||||
|
||||
if (second.MaxPlayers - second.Players > 15 && first.MaxPlayers - first.Players <= 15)
|
||||
return 1;
|
||||
|
||||
if (first.Players < (first.MaxPlayers / 2) && second.Players >= (second.MaxPlayers / 2))
|
||||
return -1;
|
||||
|
||||
@ -44,7 +38,9 @@ public class LobbySorter implements Comparator<ServerStatusData>
|
||||
|
||||
if (Integer.parseInt(first.Name.split("-")[1]) < Integer.parseInt(second.Name.split("-")[1]))
|
||||
return -1;
|
||||
else if (Integer.parseInt(second.Name.split("-")[1]) < Integer.parseInt(first.Name.split("-")[1]))
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user