Skirmish mode starts with a bot selected.

This commit is contained in:
Paul Chote
2011-06-18 00:39:50 +12:00
parent c6182f6039
commit bcbd18bb52
5 changed files with 30 additions and 16 deletions

View File

@@ -31,6 +31,12 @@ namespace OpenRA.Network
return Clients.SingleOrDefault(c => c.Slot == slot.Index);
}
public int FirstEmptySlot()
{
return Slots.First(s => !s.Closed && ClientInSlot(s) == null
&& s.Bot == null).Index;
}
public enum ClientState
{
NotReady,

View File

@@ -216,7 +216,7 @@ namespace OpenRA.Server
// Enforce correct PlayerIndex and Slot
client.Index = newConn.PlayerIndex;
client.Slot = ChooseFreeSlot();
client.Slot = lobbyInfo.FirstEmptySlot();
var slotData = lobbyInfo.Slots.FirstOrDefault( x => x.Index == client.Slot );
if (slotData != null && slotData.MapPlayer != null)
@@ -235,13 +235,6 @@ namespace OpenRA.Server
}
catch (Exception) { DropClient(newConn); }
}
int ChooseFreeSlot()
{
return lobbyInfo.Slots.First(s => !s.Closed && s.Bot == null
&& !lobbyInfo.Clients.Any( c => c.Slot == s.Index )).Index;
}
public static void SyncClientToPlayerReference(Session.Client c, PlayerReference pr)
{

View File

@@ -199,6 +199,8 @@ namespace OpenRA.Widgets
}
return text;
}
public static Action Once( Action a ) { return () => { if (a != null) { a(); a = null; } }; }
}
[Flags]