Fix IsSinglePlayer
This commit is contained in:
@@ -90,9 +90,14 @@ namespace OpenRA.Network
|
||||
return Slots.FirstOrDefault(s => !s.Value.Closed && ClientInSlot(s.Key) == null && s.Value.AllowBots).Key;
|
||||
}
|
||||
|
||||
public bool IsSinglePlayer
|
||||
public IEnumerable<Client> NonBotClients
|
||||
{
|
||||
get { return Clients.Count(c => c.Bot == null) == 1; }
|
||||
get { return Clients.Where(c => c.Bot == null); }
|
||||
}
|
||||
|
||||
public IEnumerable<Client> NonBotPlayers
|
||||
{
|
||||
get { return Clients.Where(c => c.Bot == null && c.Slot != null); }
|
||||
}
|
||||
|
||||
public enum ClientState { NotReady, Invalid, Ready, Disconnected = 1000 }
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace OpenRA.Network
|
||||
if (client != null)
|
||||
{
|
||||
var pause = order.TargetString == "Pause";
|
||||
if (orderManager.World.Paused != pause && world != null && !world.LobbyInfo.IsSinglePlayer)
|
||||
if (orderManager.World.Paused != pause && world != null && world.LobbyInfo.NonBotClients.Count() > 1)
|
||||
{
|
||||
var pausetext = "The game is {0} by {1}".F(pause ? "paused" : "un-paused", client.Name);
|
||||
Game.AddChatLine(Color.White, ServerChatName, pausetext);
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace OpenRA.Server
|
||||
Log.Write("server", "{0} ({1}) has joined the game.",
|
||||
client.Name, newConn.Socket.RemoteEndPoint);
|
||||
|
||||
if (Dedicated || !LobbyInfo.IsSinglePlayer)
|
||||
if (LobbyInfo.NonBotClients.Count() > 1)
|
||||
SendMessage("{0} has joined the game.".F(client.Name));
|
||||
|
||||
// Send initial ping
|
||||
@@ -392,7 +392,7 @@ namespace OpenRA.Server
|
||||
SendOrderTo(newConn, "Message", motd);
|
||||
}
|
||||
|
||||
if (!LobbyInfo.IsSinglePlayer && Map.DefinesUnsafeCustomRules)
|
||||
if (Map.DefinesUnsafeCustomRules)
|
||||
SendOrderTo(newConn, "Message", "This map contains custom rules. Game experience may change.");
|
||||
|
||||
if (!LobbyInfo.GlobalSettings.EnableSingleplayer)
|
||||
@@ -679,7 +679,7 @@ namespace OpenRA.Server
|
||||
}
|
||||
|
||||
// HACK: Turn down the latency if there is only one real player
|
||||
if (LobbyInfo.IsSinglePlayer)
|
||||
if (LobbyInfo.NonBotClients.Count() == 1)
|
||||
LobbyInfo.GlobalSettings.OrderLatency = 1;
|
||||
|
||||
SyncLobbyInfo();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -113,7 +114,7 @@ namespace OpenRA.Traits
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
Enabled = self.World.LobbyInfo.IsSinglePlayer || self.World.LobbyInfo.GlobalSettings
|
||||
Enabled = self.World.LobbyInfo.NonBotPlayers.Count() == 1 || self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("cheats", info.Enabled);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user