diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index 30f7ae16d5..f911449363 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -79,6 +79,7 @@ namespace OpenRA.Network public bool AllowCheats = false; public bool Dedicated; public string Difficulty; + public bool Crates = true; } public Session(string[] mods) diff --git a/OpenRA.Mods.RA/CrateDrop.cs b/OpenRA.Mods.RA/CrateDrop.cs index 2e2d362d1d..4a4708e90b 100644 --- a/OpenRA.Mods.RA/CrateDrop.cs +++ b/OpenRA.Mods.RA/CrateDrop.cs @@ -40,6 +40,8 @@ namespace OpenRA.Mods.RA public void Tick(Actor self) { + if (!self.World.LobbyInfo.GlobalSettings.Crates) return; + if (--ticks <= 0) { ticks = Info.SpawnInterval * 25; // todo: randomize diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index 3d645c162e..c2313dfaa8 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -318,6 +318,19 @@ namespace OpenRA.Mods.RA.Server server.SyncLobbyInfo(); return true; }}, + { "crates", + s => + { + if (!client.IsAdmin) + { + server.SendChatTo(conn, "Only the host can set that option"); + return true; + } + + bool.TryParse(s, out server.lobbyInfo.GlobalSettings.Crates); + server.SyncLobbyInfo(); + return true; + }}, { "difficulty", s => { diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 3029766a98..86e6814709 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -169,6 +169,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); + var crates = lobby.GetOrNull("CRATES_CHECKBOX"); + if (crates != null) + { + crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates; + crates.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null + || orderManager.LocalClient.IsReady; // maybe disable the checkbox if a map forcefully removes CrateDrop? + crates.OnClick = () => orderManager.IssueOrder(Order.Command( + "crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates))); + } + var difficulty = lobby.GetOrNull("DIFFICULTY_DROPDOWNBUTTON"); if (difficulty != null) { diff --git a/mods/ra/chrome/lobby.yaml b/mods/ra/chrome/lobby.yaml index 60ab28fe8e..1e91a0a9e1 100644 --- a/mods/ra/chrome/lobby.yaml +++ b/mods/ra/chrome/lobby.yaml @@ -432,9 +432,15 @@ Background@SERVER_LOBBY: Width: 80 Height: 20 Text: Allow Cheats + Checkbox@CRATES_CHECKBOX: + X: PARENT_RIGHT-154 + Y: PARENT_BOTTOM-154 + Width: 80 + Height: 20 + Text: Crates Button@DISCONNECT_BUTTON: X:PARENT_RIGHT-154 - Y:PARENT_BOTTOM-129 + Y:PARENT_BOTTOM-99 Width:120 Height:25 Text:Disconnect