From a8dbedd4869730414c13cc5d24efd9a77007c3e5 Mon Sep 17 00:00:00 2001 From: Scott_NZ Date: Tue, 11 Dec 2012 14:31:17 +1300 Subject: [PATCH] Fix default difficulty not being serialised --- OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs | 6 ++++++ OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index cd0c4ca720..7971619b79 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -498,6 +498,12 @@ namespace OpenRA.Mods.RA.Server .Select(p => MakeSlotFromPlayerReference(p.Value)) .Where(s => s != null) .ToDictionary(s => s.PlayerReference, s => s); + + if (server.Map.Difficulties != null && server.Map.Difficulties.Any()) + if (!server.Map.Difficulties.Contains(server.lobbyInfo.GlobalSettings.Difficulty)) + server.lobbyInfo.GlobalSettings.Difficulty = server.Map.Difficulties.First(); + else + server.lobbyInfo.GlobalSettings.Difficulty = null; } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index aefc4e1ba0..8684901a28 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -159,12 +159,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic var difficulty = lobby.Get("DIFFICULTY_DROPDOWNBUTTON"); difficulty.IsVisible = () => Map != null && Map.Difficulties != null && Map.Difficulties.Any(); difficulty.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; - difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty ?? ""; + difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty; difficulty.OnMouseDown = _ => { var options = Map.Difficulties.Select(d => new DifficultyDropDownOption { - Title = d ?? "", + Title = d, IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d, OnClick = () => orderManager.IssueOrder(Order.Command("difficulty {0}".F(d))) }); @@ -270,8 +270,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic var title = Ui.Root.Get("TITLE"); title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName; - - orderManager.LobbyInfo.GlobalSettings.Difficulty = Map.Difficulties != null && Map.Difficulties.Any() ? Map.Difficulties.First() : null; } void UpdatePlayerList()