Require Game.Mod to be give an a launch arg to OpenRA.Game.exe.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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<string[]>("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);
|
||||
|
||||
Reference in New Issue
Block a user