Disallow starting a game without players
This commit is contained in:
committed by
Matthias Mailänder
parent
ea72c50fb4
commit
ee3c54b572
@@ -33,6 +33,9 @@ namespace OpenRA.Mods.Common.Server
|
||||
[TranslationReference]
|
||||
static readonly string NoStartUntilRequiredSlotsFull = "no-start-until-required-slots-full";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string NoStartWithoutPlayers = "no-start-without-players";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string TwoHumansRequired = "two-humans-required";
|
||||
|
||||
@@ -252,6 +255,10 @@ namespace OpenRA.Mods.Common.Server
|
||||
if (server.LobbyInfo.Slots.Any(sl => sl.Value.Required && server.LobbyInfo.ClientInSlot(sl.Key) == null))
|
||||
return;
|
||||
|
||||
// Don't start without any players
|
||||
if (server.LobbyInfo.Slots.All(sl => server.LobbyInfo.ClientInSlot(sl.Key) == null))
|
||||
return;
|
||||
|
||||
if (LobbyUtils.InsufficientEnabledSpawnPoints(server.Map, server.LobbyInfo))
|
||||
return;
|
||||
|
||||
@@ -296,6 +303,12 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
if (server.LobbyInfo.Slots.All(sl => server.LobbyInfo.ClientInSlot(sl.Key) == null))
|
||||
{
|
||||
server.SendOrderTo(conn, "Message", NoStartWithoutPlayers);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!server.LobbyInfo.GlobalSettings.EnableSingleplayer && server.LobbyInfo.NonBotPlayers.Count() < 2)
|
||||
{
|
||||
server.SendLocalizedMessageTo(conn, TwoHumansRequired);
|
||||
|
||||
@@ -383,6 +383,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
startGameButton.IsDisabled = () => configurationDisabled() || map.Status != MapStatus.Available ||
|
||||
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null) ||
|
||||
orderManager.LobbyInfo.Slots.All(sl => orderManager.LobbyInfo.ClientInSlot(sl.Key) == null) ||
|
||||
(!orderManager.LobbyInfo.GlobalSettings.EnableSingleplayer && orderManager.LobbyInfo.NonBotPlayers.Count() < 2) ||
|
||||
insufficientPlayerSpawns;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user