From 6bd3195c3d5fd7c7f6a46657c50103ad6a7ef92d Mon Sep 17 00:00:00 2001 From: Thehx Date: Fri, 13 Nov 2015 05:47:40 +0300 Subject: [PATCH] Changed ServerSettings cloning to a more reliable approach --- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/Settings.cs | 22 ++----------------- .../Widgets/Logic/ServerCreationLogic.cs | 2 +- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 07b6522dd1..1cf1724274 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -358,7 +358,7 @@ namespace OpenRA { Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map); Settings.Save(); - CreateServer(new ServerSettings(Settings.Server)); + CreateServer(Settings.Server.Clone()); while (true) { diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 1f5b4f3a70..f0cc9ea151 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -74,27 +74,9 @@ namespace OpenRA public string TimestampFormat = "s"; - public ServerSettings() { } - - public ServerSettings(ServerSettings other) + public ServerSettings Clone() { - Name = other.Name; - ListenPort = other.ListenPort; - ExternalPort = other.ExternalPort; - AdvertiseOnline = other.AdvertiseOnline; - Password = other.Password; - MasterServer = other.MasterServer; - DiscoverNatDevices = other.DiscoverNatDevices; - AllowPortForward = other.AllowPortForward; - NatDeviceAvailable = other.NatDeviceAvailable; - NatDiscoveryTimeout = other.NatDiscoveryTimeout; - VerboseNatDiscovery = other.VerboseNatDiscovery; - Map = other.Map; - Ban = other.Ban; - TimeOut = other.TimeOut; - Dedicated = other.Dedicated; - DedicatedLoop = other.DedicatedLoop; - LockBots = other.LockBots; + return (ServerSettings)MemberwiseClone(); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs index 46346f0c88..28667ce2c5 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs @@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Game.Settings.Save(); // Take a copy so that subsequent changes don't affect the server - var settings = new ServerSettings(Game.Settings.Server); + var settings = Game.Settings.Server.Clone(); // Create and join the server try