diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index c24451c867..42ff20938a 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -72,7 +72,7 @@ namespace OpenRA packageChangePending = false; Timer.Time( "load assemblies, packages: {0}" ); } - + static void LoadMap(string mapName) { Timer.Time("----LoadMap"); @@ -87,21 +87,21 @@ namespace OpenRA viewport = new Viewport(clientSize, map.TopLeft, map.BottomRight, Renderer); world = null; // trying to access the old world will NRE, rather than silently doing it wrong. Timer.Time("viewport: {0}"); - + Rules.LoadRules(modData.Manifest,map); Timer.Time( "load rules: {0}" ); - + SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] ); SequenceProvider.Initialize(modData.Manifest.Sequences); Timer.Time("SeqProv: {0}"); - + world = new World(modData.Manifest, map); Timer.Time("world: {0}"); Timer.Time("----end LoadMap"); Debug("Map change {0} -> {1}".F(Game.mapName, mapName)); } - + public static void MoveViewport(int2 loc) { viewport.Center(loc); @@ -119,7 +119,7 @@ namespace OpenRA lastConnectionState = ConnectionState.PreConnecting; ConnectionStateChanged(); - + orderManager = new OrderManager(new NetworkConnection(host, port), ChooseReplayFilename()); } @@ -132,7 +132,7 @@ namespace OpenRA { lastConnectionState = ConnectionState.PreConnecting; ConnectionStateChanged(); - + if (orderManager != null) orderManager.Dispose(); orderManager = new OrderManager(new EchoConnection()); } @@ -151,7 +151,7 @@ namespace OpenRA public static event Action ConnectionStateChanged = () => { }; static ConnectionState lastConnectionState = ConnectionState.PreConnecting; public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } } - + static void Tick() { if (packageChangePending) @@ -170,13 +170,13 @@ namespace OpenRA mapChangePending = false; return; } - + if (orderManager.Connection.ConnectionState != lastConnectionState) { lastConnectionState = orderManager.Connection.ConnectionState; ConnectionStateChanged(); } - + int t = Environment.TickCount; int dt = t - lastTime; if (dt >= Settings.Timestep) @@ -289,7 +289,7 @@ namespace OpenRA LoadMap(map); if (orderManager.GameStarted) return; Widget.SelectedWidget = null; - + world.Queries = new World.AllQueries(world); foreach (var gs in world.WorldActor.TraitsImplementing()) @@ -331,7 +331,7 @@ namespace OpenRA Modifiers = modifierKeys, }; Widget.HandleInput(world, mi); - + if (sync != world.SyncHash() && world == initialWorld) throw new InvalidOperationException("Desync in DispatchMouseInput"); } @@ -349,7 +349,7 @@ namespace OpenRA public static void HandleKeyEvent(KeyInput e) { int sync = world.SyncHash(); - + if (Widget.HandleKeyPress(e)) return; @@ -364,13 +364,13 @@ namespace OpenRA internal static void Initialize(Settings settings) { AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; - + var defaultSupport = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + "OpenRA"; - + SupportDir = settings.GetValue("SupportDir", defaultSupport); Settings = new UserSettings(settings); - + Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar; Log.AddChannel("perf", "perf.log"); Log.AddChannel("debug", "debug.log"); @@ -378,7 +378,7 @@ namespace OpenRA LobbyInfo.GlobalSettings.Mods = Settings.InitialMods; modData = new ModData( LobbyInfo.GlobalSettings.Mods ); - + Renderer.SheetSize = Settings.SheetSize; Renderer.Initialize( settings, Game.Settings.WindowMode ); @@ -395,15 +395,10 @@ namespace OpenRA Renderer = new Renderer(); clientSize = new int2(Renderer.Resolution); - if (Settings.Replay != null) - orderManager = new OrderManager(new ReplayConnection(Settings.Replay)); - else - JoinLocal(); - + JoinLocal(); StartGame(modData.Manifest.ShellmapUid); ResetTimer(); - } static bool quit; @@ -417,10 +412,10 @@ namespace OpenRA } public static void Exit() { quit = true; } - + public static Action AddChatLine = (c,n,s) => {}; - public static void Debug(string s) + public static void Debug(string s) { AddChatLine(Color.White, "Debug", s); } @@ -437,30 +432,24 @@ namespace OpenRA Widget.RootWidget.CloseWindow(); Widget.RootWidget.OpenWindow("MAINMENU_BG"); } - + static string baseSupportDir = null; public static string SupportDir { - set { + set + { var dir = value; - + // Expand paths relative to the personal directory if (dir.ElementAt(0) == '~') dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + dir.Substring(1); - + if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); - + baseSupportDir = dir + Path.DirectorySeparatorChar; - } - get {return baseSupportDir;} - } - - public static void InitializeEngineWithMods(string[] mods) - { - AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; - modData = new ModData( mods ); - Rules.LoadRules(modData.Manifest, new Map()); + } + get { return baseSupportDir; } } public static T CreateObject( string name ) diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index fa83fdc698..c0c749baf5 100755 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -47,7 +47,6 @@ namespace OpenRA.GameRules // External game settings public string LastServer = "localhost:1234"; - public string Replay = null; public string PlayerName = "Newbie"; public Color PlayerColor1 = Color.FromArgb(255,160,238); public Color PlayerColor2 = Color.FromArgb(68,0,56); diff --git a/RALint/RALint.cs b/RALint/RALint.cs index eb2a9bac64..c3f0c4d9a2 100644 --- a/RALint/RALint.cs +++ b/RALint/RALint.cs @@ -39,7 +39,9 @@ namespace RALint ObjectCreator.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s)); FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name)); - Game.InitializeEngineWithMods(args); + AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; + Game.modData = new ModData( args ); + Rules.LoadRules(Game.modData.Manifest, new Map()); // all the @something names which actually EXIST. var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null)