diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index a0f9137c49..57d65d0713 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -136,7 +136,6 @@ namespace OpenRA foreach (var q in tabImageNames) if (!Rules.TechTree.BuildableItems(world.LocalPlayer, q.Key).Any()) { - CheckDeadTab(world, q.Key); if (currentTab == q.Key) currentTab = null; } @@ -544,13 +543,6 @@ namespace OpenRA paletteAnimating = true; } - void CheckDeadTab( World world, string groupName ) - { - var queue = world.LocalPlayer.PlayerActor.traits.Get(); - foreach( var item in queue.AllItems( groupName ) ) - Game.IssueOrder(Order.CancelProduction(world.LocalPlayer, item.Item)); - } - float? lastPowerProvidedPos; float? lastPowerDrainedPos; diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 7f7827d442..dabf0dcb43 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -181,29 +181,6 @@ namespace OpenRA viewport.Center(loc); } - internal static void Initialize(Renderer renderer, int2 clientSize, int localPlayer, Controller controller) - { - Game.renderer = renderer; - Game.clientSize = clientSize; - - Sound.Initialize(); - PerfHistory.items["render"].hasNormalTick = false; - PerfHistory.items["batches"].hasNormalTick = false; - PerfHistory.items["text"].hasNormalTick = false; - PerfHistory.items["cursor"].hasNormalTick = false; - Game.controller = controller; - AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods); - - ChangeMods(); - - if( Settings.Replay != "" ) - orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) ); - else - JoinLocal(); - - LoadShellMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid); - } - public static string CurrentHost = ""; public static int CurrentPort = 0; internal static void JoinServer(string host, int port) @@ -493,7 +470,7 @@ namespace OpenRA desktopResolution.Height); } - public static void PreInit(Settings settings) + public static void Initialize(Settings settings) { AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; while (!Directory.Exists("mods")) @@ -517,9 +494,24 @@ namespace OpenRA renderer = new Renderer(resolution, windowed); resolution = renderer.Resolution; - var controller = new Controller(); + Game.controller = new Controller(); + Game.clientSize = new int2(resolution); + + Sound.Initialize(); + PerfHistory.items["render"].hasNormalTick = false; + PerfHistory.items["batches"].hasNormalTick = false; + PerfHistory.items["text"].hasNormalTick = false; + PerfHistory.items["cursor"].hasNormalTick = false; + AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods); + + ChangeMods(); - Game.Initialize(renderer, new int2(resolution), Game.Settings.Player, controller); + if( Settings.Replay != "" ) + orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) ); + else + JoinLocal(); + + LoadShellMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid); Game.ResetTimer(); } diff --git a/OpenRA.Game/Support/Program.cs b/OpenRA.Game/Support/Program.cs index d8e31513e5..a247df1ab4 100644 --- a/OpenRA.Game/Support/Program.cs +++ b/OpenRA.Game/Support/Program.cs @@ -47,7 +47,7 @@ namespace OpenRA static void Run( string[] args ) { - Game.PreInit( new Settings( args ) ); + Game.Initialize( new Settings( args ) ); Game.Run(); } } diff --git a/OpenRA.Game/Traits/Player/ProductionQueue.cs b/OpenRA.Game/Traits/Player/ProductionQueue.cs index c99c736b09..699850f456 100644 --- a/OpenRA.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Game/Traits/Player/ProductionQueue.cs @@ -44,8 +44,15 @@ namespace OpenRA.Traits public void Tick( Actor self ) { foreach( var p in production ) + { + while( p.Value.Count > 0 && !Rules.TechTree.BuildableItems( self.Owner, p.Key ).Contains( p.Value[ 0 ].Item ) ) + { + self.Owner.GiveCash(p.Value[0].TotalCost - p.Value[0].RemainingCost); // refund what's been paid so far. + FinishProduction(p.Key); + } if( p.Value.Count > 0 ) - (p.Value)[0].Tick( self.Owner ); + ( p.Value )[ 0 ].Tick( self.Owner ); + } } public void ResolveOrder( Actor self, Order order ) @@ -127,7 +134,7 @@ namespace OpenRA.Traits { queue.RemoveAt(lastIndex); } - else + else if( lastIndex == 0 ) { var item = queue[0]; self.Owner.GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.