Disable the button/order when there aren't enough clients to assign
This commit is contained in:
@@ -333,15 +333,18 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
server.SendChatTo(conn, "Number of teams could not be parsed: {0}".F(s));
|
server.SendChatTo(conn, "Number of teams could not be parsed: {0}".F(s));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
teams = teams.Clamp(2, 8);
|
teams = teams.Clamp(2, 8);
|
||||||
|
|
||||||
var clients = server.lobbyInfo.Slots
|
var clients = server.lobbyInfo.Slots
|
||||||
.Select(slot => server.lobbyInfo.Clients.SingleOrDefault(c => c.Slot == slot.Key))
|
.Select(slot => server.lobbyInfo.Clients.SingleOrDefault(c => c.Slot == slot.Key))
|
||||||
.Where(c => c != null && !server.lobbyInfo.Slots[c.Slot].LockTeam).ToArray();
|
.Where(c => c != null && !server.lobbyInfo.Slots[c.Slot].LockTeam).ToArray();
|
||||||
|
if (clients.Length < 2)
|
||||||
|
{
|
||||||
|
server.SendChatTo(conn, "Not enough clients to assign teams");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var teamSizes = new int[clients.Length];
|
var teamSizes = new int[clients.Length];
|
||||||
|
|
||||||
for (var i = 0; i < clients.Length; i++)
|
for (var i = 0; i < clients.Length; i++)
|
||||||
teamSizes[i % teams]++;
|
teamSizes[i % teams]++;
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (assignTeams != null)
|
if (assignTeams != null)
|
||||||
{
|
{
|
||||||
assignTeams.IsVisible = () => Game.IsHost;
|
assignTeams.IsVisible = () => Game.IsHost;
|
||||||
assignTeams.IsDisabled = () => gameStarting || orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
|
assignTeams.IsDisabled = () => gameStarting || orderManager.LobbyInfo.Clients.Count < 2
|
||||||
|
|| orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
|
||||||
|
|
||||||
assignTeams.OnMouseDown = _ =>
|
assignTeams.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user