diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 34b753e64e..4f63e84d36 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -248,12 +248,12 @@ namespace OpenRA // Special case handling of Game.Mod argument: if it matches a real filesystem path // then we use this to override the mod search path, and replace it with the mod id - var modArgument = args.GetValue("Game.Mod", null); + var modID = args.GetValue("Game.Mod", null); var explicitModPaths = new string[0]; - if (modArgument != null && (File.Exists(modArgument) || Directory.Exists(modArgument))) + if (modID != null && (File.Exists(modID) || Directory.Exists(modID))) { - explicitModPaths = new[] { modArgument }; - args.ReplaceValue("Game.Mod", Path.GetFileNameWithoutExtension(modArgument)); + explicitModPaths = new[] { modID }; + modID = Path.GetFileNameWithoutExtension(modID); } InitializeSettings(args); @@ -330,7 +330,7 @@ namespace OpenRA foreach (var mod in ExternalMods) Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version); - InitializeMod(Settings.Game.Mod, args); + InitializeMod(modID, args); } public static void InitializeMod(string mod, Arguments args) @@ -360,12 +360,10 @@ namespace OpenRA ModData = null; - // Fall back to default if the mod doesn't exist if (mod == null) - mod = args.GetValue("Engine.DefaultMod", "modchooser"); + throw new InvalidOperationException("Game.Mod argument missing or mod could not be found."); Console.WriteLine("Loading mod: {0}", mod); - Settings.Game.Mod = mod; Sound.StopVideo(); diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 464e7f2d3c..b46c7ce312 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -154,10 +154,6 @@ namespace OpenRA public class GameSettings { - [Desc("Load a specific mod on startup.")] - public string Mod = null; - public string PreviousMod = "ra"; - public string Platform = "Default"; public bool ViewportEdgeScroll = true; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index 7b98c42b00..fcca9bc248 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -93,7 +93,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic // so we can't do this inside the input handler. Game.RunAfterTick(() => { - Game.Settings.Game.PreviousMod = modData.Manifest.Id; Game.InitializeMod("modchooser", null); }); }; diff --git a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs index d6e2e07f3e..583e296537 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs @@ -115,9 +115,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic catch (Exception) { } } - Manifest initialMod; - Game.Mods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod); - SelectMod(initialMod != null && initialMod.Id != "modchooser" ? initialMod : Game.Mods["ra"]); + SelectMod(Game.Mods["ra"]); RebuildModList(); } diff --git a/OpenRA.Server/Program.cs b/OpenRA.Server/Program.cs index 2cdbbda65a..c5c8509ae5 100644 --- a/OpenRA.Server/Program.cs +++ b/OpenRA.Server/Program.cs @@ -30,14 +30,17 @@ namespace OpenRA.Server // Special case handling of Game.Mod argument: if it matches a real filesystem path // then we use this to override the mod search path, and replace it with the mod id - var modArgument = arguments.GetValue("Game.Mod", null); + var modID = arguments.GetValue("Game.Mod", null); var explicitModPaths = new string[0]; - if (modArgument != null && (File.Exists(modArgument) || Directory.Exists(modArgument))) + if (modID != null && (File.Exists(modID) || Directory.Exists(modID))) { - explicitModPaths = new[] { modArgument }; - arguments.ReplaceValue("Game.Mod", Path.GetFileNameWithoutExtension(modArgument)); + explicitModPaths = new[] { modID }; + modID = Path.GetFileNameWithoutExtension(modID); } + if (modID == null) + throw new InvalidOperationException("Game.Mod argument missing or mod could not be found."); + // HACK: The engine code assumes that Game.Settings is set. // This isn't nearly as bad as ModData, but is still not very nice. Game.InitializeSettings(arguments); @@ -48,16 +51,15 @@ namespace OpenRA.Server FieldLoader.GetValue("MOD_SEARCH_PATHS", envModSearchPaths) : new[] { Path.Combine(".", "mods") }; - var mod = Game.Settings.Game.Mod; var mods = new InstalledMods(modSearchPaths, explicitModPaths); // HACK: The engine code *still* assumes that Game.ModData is set - var modData = Game.ModData = new ModData(mods[mod], mods); + var modData = Game.ModData = new ModData(mods[modID], mods); modData.MapCache.LoadMaps(); settings.Map = modData.MapCache.ChooseInitialMap(settings.Map, new MersenneTwister()); - Console.WriteLine("[{0}] Starting dedicated server for mod: {1}", DateTime.Now.ToString(settings.TimestampFormat), mod); + Console.WriteLine("[{0}] Starting dedicated server for mod: {1}", DateTime.Now.ToString(settings.TimestampFormat), modID); while (true) { var server = new Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, modData, true);