Disable 1 human versus bots games
Changed the Server.LockBots setting to Server.DisableSinglePlayer. If the setting is enabled, and there is only one client in the server, the game won't start.
This commit is contained in:
@@ -196,6 +196,7 @@ namespace OpenRA.Network
|
|||||||
public bool ShortGame = true;
|
public bool ShortGame = true;
|
||||||
public bool AllowVersionMismatch;
|
public bool AllowVersionMismatch;
|
||||||
public string GameUid;
|
public string GameUid;
|
||||||
|
public bool DisableSingleplayer;
|
||||||
|
|
||||||
public static Global Deserialize(MiniYaml data)
|
public static Global Deserialize(MiniYaml data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ namespace OpenRA.Server
|
|||||||
RandomSeed = randomSeed,
|
RandomSeed = randomSeed,
|
||||||
Map = settings.Map,
|
Map = settings.Map,
|
||||||
ServerName = settings.Name,
|
ServerName = settings.Name,
|
||||||
Dedicated = settings.Dedicated
|
Dedicated = settings.Dedicated,
|
||||||
|
DisableSingleplayer = settings.DisableSinglePlayer,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -395,8 +396,8 @@ namespace OpenRA.Server
|
|||||||
if (Map.RuleDefinitions.Any() && !LobbyInfo.IsSinglePlayer)
|
if (Map.RuleDefinitions.Any() && !LobbyInfo.IsSinglePlayer)
|
||||||
SendOrderTo(newConn, "Message", "This map contains custom rules. Game experience may change.");
|
SendOrderTo(newConn, "Message", "This map contains custom rules. Game experience may change.");
|
||||||
|
|
||||||
if (Settings.LockBots)
|
if (Settings.DisableSinglePlayer)
|
||||||
SendOrderTo(newConn, "Message", "Bots have been disabled on this server.");
|
SendOrderTo(newConn, "Message", "Singleplayer games have been disabled on this server.");
|
||||||
else if (MapPlayers.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
else if (MapPlayers.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
||||||
SendOrderTo(newConn, "Message", "Bots have been disabled on this map.");
|
SendOrderTo(newConn, "Message", "Bots have been disabled on this map.");
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ namespace OpenRA
|
|||||||
[Desc("Automatically restart when a game ends. Disable this when something else already takes care about it.")]
|
[Desc("Automatically restart when a game ends. Disable this when something else already takes care about it.")]
|
||||||
public bool DedicatedLoop = true;
|
public bool DedicatedLoop = true;
|
||||||
|
|
||||||
[Desc("Disallow AI bots.")]
|
[Desc("Disallow games where only one player plays with bots.")]
|
||||||
public bool LockBots = false;
|
public bool DisableSinglePlayer = false;
|
||||||
|
|
||||||
public string TimestampFormat = "s";
|
public string TimestampFormat = "s";
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
if (server.LobbyInfo.Slots.Any(sl => sl.Value.Required && server.LobbyInfo.ClientInSlot(sl.Key) == null))
|
if (server.LobbyInfo.Slots.Any(sl => sl.Value.Required && server.LobbyInfo.ClientInSlot(sl.Key) == null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Does server have only one player?
|
||||||
|
if (server.Settings.DisableSinglePlayer && playerClients.Count() == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
server.StartGame();
|
server.StartGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +119,13 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (server.Settings.DisableSinglePlayer &&
|
||||||
|
server.LobbyInfo.Clients.Where(c => c.Bot == null && c.Slot != null).Count() == 1)
|
||||||
|
{
|
||||||
|
server.SendOrderTo(conn, "Message", "Unable to start the game until another player joins.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
server.StartGame();
|
server.StartGame();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -373,8 +384,8 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
if (server.Map.RuleDefinitions.Any())
|
if (server.Map.RuleDefinitions.Any())
|
||||||
server.SendMessage("This map contains custom rules. Game experience may change.");
|
server.SendMessage("This map contains custom rules. Game experience may change.");
|
||||||
|
|
||||||
if (server.Settings.LockBots)
|
if (server.Settings.DisableSinglePlayer)
|
||||||
server.SendMessage("Bots have been disabled on this server.");
|
server.SendMessage("Singleplayer games have been disabled on this server.");
|
||||||
else if (server.MapPlayers.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
else if (server.MapPlayers.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
||||||
server.SendMessage("Bots have been disabled on this map.");
|
server.SendMessage("Bots have been disabled on this map.");
|
||||||
|
|
||||||
@@ -923,8 +934,6 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
static Session.Slot MakeSlotFromPlayerReference(PlayerReference pr)
|
static Session.Slot MakeSlotFromPlayerReference(PlayerReference pr)
|
||||||
{
|
{
|
||||||
if (!pr.Playable) return null;
|
if (!pr.Playable) return null;
|
||||||
if (Game.Settings.Server.LockBots)
|
|
||||||
pr.AllowBots = false;
|
|
||||||
return new Session.Slot
|
return new Session.Slot
|
||||||
{
|
{
|
||||||
PlayerReference = pr.Name,
|
PlayerReference = pr.Name,
|
||||||
|
|||||||
@@ -318,7 +318,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (startGameButton != null)
|
if (startGameButton != null)
|
||||||
{
|
{
|
||||||
startGameButton.IsDisabled = () => configurationDisabled() || Map.RuleStatus != MapRuleStatus.Cached ||
|
startGameButton.IsDisabled = () => configurationDisabled() || Map.RuleStatus != MapRuleStatus.Cached ||
|
||||||
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null);
|
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null) ||
|
||||||
|
(orderManager.LobbyInfo.GlobalSettings.DisableSingleplayer && orderManager.LobbyInfo.IsSinglePlayer);
|
||||||
startGameButton.OnClick = () =>
|
startGameButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
// Bots and admins don't count
|
// Bots and admins don't count
|
||||||
|
|||||||
Reference in New Issue
Block a user