diff --git a/OpenRA.FileFormats/Session.cs b/OpenRA.FileFormats/Session.cs index 615bc9b9b3..e91c9debc2 100644 --- a/OpenRA.FileFormats/Session.cs +++ b/OpenRA.FileFormats/Session.cs @@ -48,7 +48,7 @@ namespace OpenRA.FileFormats public class Global { - public string Map = "testmap"; + public string Map; public string[] Packages = {}; // filename:sha1 pairs. public string[] Mods = { "ra" }; // mod names public int OrderLatency = 3; @@ -62,6 +62,8 @@ namespace OpenRA.FileFormats Folders, Packages, Rules, Sequences, Chrome, Assemblies, ChromeLayout, Weapons, Voices, Terrain; + + public readonly string ShellmapUid; public Manifest(string[] mods) { @@ -79,6 +81,8 @@ namespace OpenRA.FileFormats Weapons = YamlList(yaml, "Weapons"); Voices = YamlList(yaml, "Voices"); Terrain = YamlList(yaml, "Terrain"); + + ShellmapUid = yaml["ShellmapUid"].Value; } static string[] YamlList(Dictionary ys, string key) { return ys[key].Nodes.Keys.ToArray(); } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 45cd81156f..5858b29f3d 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -131,11 +131,7 @@ namespace OpenRA var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods); Timer.Time( "manifest: {0}" ); - - // TODO: Only do this on mod change - AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods); - Timer.Time( "maplist: {0}" ); - + Game.LoadModAssemblies(manifest); Game.changePending = false; Game.mapName = mapName; @@ -165,7 +161,7 @@ namespace OpenRA Debug("Map change {0} -> {1}".F(Game.mapName, mapName)); } - internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, Controller controller) + internal static void Initialize(Renderer renderer, int2 clientSize, int localPlayer, Controller controller) { Game.renderer = renderer; Game.clientSize = clientSize; @@ -176,8 +172,9 @@ namespace OpenRA PerfHistory.items["text"].hasNormalTick = false; PerfHistory.items["cursor"].hasNormalTick = false; Game.controller = controller; + AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods); - ChangeMap(mapName); + ChangeMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid); if( Settings.Replay != "" ) orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) ); @@ -217,6 +214,10 @@ namespace OpenRA { if (changePending && PackageDownloader.IsIdle()) { + // TODO: Only do this on mod change + AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods); + Timer.Time( "maplist: {0}" ); + ChangeMap(LobbyInfo.GlobalSettings.Map); return; } @@ -457,7 +458,7 @@ namespace OpenRA { var current = Directory.GetCurrentDirectory(); if (Directory.GetDirectoryRoot(current) == current) - throw new InvalidOperationException("Unable to load MIX files."); + throw new InvalidOperationException("Unable to find game root."); Directory.SetCurrentDirectory(".."); } @@ -476,7 +477,7 @@ namespace OpenRA var controller = new Controller(); - Game.Initialize(Game.Settings.Map, renderer, new int2(resolution), Game.Settings.Player, controller); + Game.Initialize(renderer, new int2(resolution), Game.Settings.Player, controller); Game.ResetTimer(); } diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index 3dca5655d0..1a8ab88654 100644 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -41,7 +41,6 @@ namespace OpenRA.GameRules // External game settings public readonly string NetworkHost = ""; public readonly int NetworkPort = 0; - public readonly string Map = "testmap"; public readonly int Player = 1; public readonly string Replay = ""; public readonly string PlayerName = ""; diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 7bea0bc9c2..66087122de 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -54,7 +54,7 @@ namespace OpenRA.Server static bool isInternetServer; static string masterServerUrl; - public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport, string[] mods) + public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport, string[] mods, string map) { Server.masterServerUrl = masterServerUrl; isInternetServer = internetServer; @@ -67,11 +67,14 @@ namespace OpenRA.Server lobbyInfo = new Session(); lobbyInfo.GlobalSettings.Mods = mods; lobbyInfo.GlobalSettings.RandomSeed = randomSeed; - + lobbyInfo.GlobalSettings.Map = map; + Console.WriteLine("Initial mods: "); foreach( var m in lobbyInfo.GlobalSettings.Mods ) Console.WriteLine("- {0}", m); + Console.WriteLine("Initial map: {0}",lobbyInfo.GlobalSettings.Map); + try { listener.Start(); diff --git a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs index 8aaa86068b..fd8e2736b5 100644 --- a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -19,7 +19,8 @@ #endregion using System.Net; - +using System.Linq; +using System.Collections.Generic; namespace OpenRA.Widgets.Delegates { public class CreateServerMenuDelegate : WidgetDelegate @@ -63,10 +64,20 @@ namespace OpenRA.Widgets.Delegates { Game.chrome.rootWidget.ShowMenu(null); Log.Write("Creating server"); + + + // TODO: Get this from a map chooser + string map = Game.AvailableMaps.Keys.FirstOrDefault(); + + // TODO: Get this from a mod chooser + var mods = Game.Settings.InitialMods; + + // TODO: Get this from a textbox + var gameName = Game.Settings.GameName; Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer, - Game.Settings.GameName, Game.Settings.ListenPort, - Game.Settings.ExternalPort, Game.Settings.InitialMods); + gameName, Game.Settings.ListenPort, + Game.Settings.ExternalPort, mods, map); Log.Write("Joining server"); Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort); diff --git a/mods/cnc/maps/scm01ea/map.yaml b/mods/cnc/maps/scm01ea/map.yaml index c0b47a3ce9..465c10f70c 100644 --- a/mods/cnc/maps/scm01ea/map.yaml +++ b/mods/cnc/maps/scm01ea/map.yaml @@ -1,4 +1,4 @@ -Uid: testmap +Uid: 97516324 MapFormat: 1 diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 04ab128763..8be602691d 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -50,4 +50,6 @@ Voices: mods/cnc/voices.yaml: Terrain: - mods/cnc/terrain.yaml \ No newline at end of file + mods/cnc/terrain.yaml + +ShellmapUid:119926504 diff --git a/mods/ra/maps/scm01ea/map.yaml b/mods/ra/maps/scm01ea/map.yaml index 35006a10be..d8b56eb3ee 100644 --- a/mods/ra/maps/scm01ea/map.yaml +++ b/mods/ra/maps/scm01ea/map.yaml @@ -1,4 +1,4 @@ -Uid: testmap +Uid: 45646351 MapFormat: 1 diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index a8a0ab4a91..3a7cb9e5de 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -48,4 +48,6 @@ Voices: mods/ra/voices.yaml Terrain: - mods/ra/terrain.yaml \ No newline at end of file + mods/ra/terrain.yaml + +ShellmapUid:1134734410