diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 4724884176..1985da8503 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -58,7 +58,6 @@ namespace OpenRA public class MapOptions { - public bool? Creeps; public bool? AllyBuildRadius; public string TechLevel; public string[] Difficulties = { }; @@ -66,8 +65,6 @@ namespace OpenRA public void UpdateServerSettings(Session.Global settings) { - if (Creeps.HasValue) - settings.Creeps = Creeps.Value; if (AllyBuildRadius.HasValue) settings.AllyBuildRadius = AllyBuildRadius.Value; if (ShortGame.HasValue) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index f210809632..f19e4b8e08 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -732,6 +732,7 @@ + diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index 03f84d407b..5d5320faf2 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -545,7 +545,8 @@ namespace OpenRA.Mods.Common.Server return true; } - if (server.Map.Options.Creeps.HasValue) + var mapCreeps = server.Map.Rules.Actors["world"].TraitInfoOrDefault(); + if (mapCreeps == null || mapCreeps.Locked) { server.SendOrderTo(conn, "Message", "Map has disabled Creeps spawning configuration."); return true; diff --git a/OpenRA.Mods.Common/Traits/World/MapCreeps.cs b/OpenRA.Mods.Common/Traits/World/MapCreeps.cs new file mode 100644 index 0000000000..192976e15f --- /dev/null +++ b/OpenRA.Mods.Common/Traits/World/MapCreeps.cs @@ -0,0 +1,28 @@ +#region Copyright & License Information +/* + * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Collections.Generic; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Traits +{ + [Desc("Controls the 'Creeps' checkbox in the lobby options.")] + public class MapCreepsInfo : TraitInfo + { + [Desc("Default value of the creeps checkbox in the lobby.")] + public readonly bool Enabled = true; + + [Desc("Prevent the creeps state from being changed in the lobby.")] + public readonly bool Locked = false; + } + + public class MapCreeps { } +} diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 7b52a6cb8d..b33cbd46a5 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -376,8 +376,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic var creeps = optionsBin.GetOrNull("CREEPS_CHECKBOX"); if (creeps != null) { + var creepsLocked = new CachedTransform(map => + { + var mapCreeps = map.Rules.Actors["world"].TraitInfoOrDefault(); + return mapCreeps == null || mapCreeps.Locked; + }); + creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps; - creeps.IsDisabled = () => configurationDisabled() || Map.Options.Creeps.HasValue; + creeps.IsDisabled = () => configurationDisabled() || creepsLocked.Update(Map); creeps.OnClick = () => orderManager.IssueOrder(Order.Command( "creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps))); } diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 4006d6c919..588310043a 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -72,6 +72,7 @@ World: ResourceClaimLayer: PathfinderDebugOverlay: WarheadDebugOverlay: + MapCreeps: SpawnMapActors: MPStartLocations: CreateMPPlayers: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 02bcc2ff29..5a8ac60f62 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -87,6 +87,7 @@ World: Type: SandCrater Sequence: sandcraters SmokePercentage: 0 + MapCreeps: SpawnMapActors: CreateMPPlayers: MPStartLocations: