diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 7c34977179..928d946987 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -21,12 +21,8 @@ namespace OpenRa.Game public int2 Location; public Player Owner; public int Health; - public readonly bool IsMapActor; - public Actor(string name, int2 location, Player owner) - : this( name, location, owner, false ) {} - - public Actor( string name, int2 location, Player owner, bool isMapActor ) + public Actor( string name, int2 location, Player owner ) { ActorID = Game.world.NextAID(); unitInfo = Rules.UnitInfo[ name ]; @@ -34,7 +30,6 @@ namespace OpenRa.Game CenterLocation = new float2( 12, 12 ) + Game.CellSize * (float2)Location; Owner = owner; Health = unitInfo.Strength; /* todo: handle cases where this is not true! */ - IsMapActor = isMapActor; if( unitInfo.Traits != null ) { diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index c92cfc9629..e0f11c45ce 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -21,7 +21,7 @@ namespace OpenRa.Game if (orderGenerator != null) foreach (var order in orderGenerator.Order(xy.ToInt2(), left)) { - recentOrders.Add(order); + AddOrder( order ); if (order.Subject != null && order.Player == Game.LocalPlayer) doVoice = order.Subject; } diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index a36067a9ec..6e9fd393a2 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -38,6 +38,8 @@ namespace OpenRa.Game public static string Replay; + public static bool skipMakeAnims = true; + public static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer) { Rules.LoadRules(mapName); @@ -78,6 +80,8 @@ namespace OpenRa.Game : new OrderManager(new[] { new ReplayOrderSource(Replay) }); PlaySound("intro.aud", false); + + skipMakeAnims = false; } static void LoadMapBuildings( IniFile mapfile ) @@ -87,7 +91,7 @@ namespace OpenRa.Game //num=owner,type,health,location,facing,trigger,unknown,shouldRepair var parts = s.Value.ToLowerInvariant().Split( ',' ); var loc = int.Parse( parts[ 3 ] ); - world.Add( new Actor( parts[ 1 ], new int2( loc % 128, loc / 128 ), players[ 0 ], true ) ); + world.Add( new Actor( parts[ 1 ], new int2( loc % 128, loc / 128 ), players[ 0 ] ) ); } } @@ -98,7 +102,7 @@ namespace OpenRa.Game //num=owner,type,health,location,facing,action,trigger var parts = s.Value.ToLowerInvariant().Split( ',' ); var loc = int.Parse( parts[ 3 ] ); - world.Add( new Actor( parts[ 1 ], new int2( loc % 128, loc / 128 ), players[ 0 ], true ) ); + world.Add( new Actor( parts[ 1 ], new int2( loc % 128, loc / 128 ), players[ 0 ] ) ); } } @@ -140,15 +144,16 @@ namespace OpenRa.Game { lastTime += timestep; - if( controller.orderGenerator != null ) - controller.orderGenerator.Tick(); + if( orderManager.Tick() ) + { + if( controller.orderGenerator != null ) + controller.orderGenerator.Tick(); - world.Tick(); - UnitInfluence.Tick(); - foreach( var player in players.Values ) - player.Tick(); - - orderManager.Tick(); + world.Tick(); + UnitInfluence.Tick(); + foreach( var player in players.Values ) + player.Tick(); + } } viewport.cursor = controller.ChooseCursor(); diff --git a/OpenRa.Game/OrderManager.cs b/OpenRa.Game/OrderManager.cs index 4a85c762dc..5f86d5dfb6 100755 --- a/OpenRa.Game/OrderManager.cs +++ b/OpenRa.Game/OrderManager.cs @@ -27,9 +27,12 @@ namespace OpenRa.Game savingReplay = new BinaryWriter( new FileStream( replayFilename, FileMode.Create ) ); } - public void Tick() + public bool Tick() { var localOrders = Game.controller.GetRecentOrders(); + if( localOrders == null ) + return false; + foreach( var p in players ) p.Tick( localOrders ); @@ -48,6 +51,8 @@ namespace OpenRa.Game // sanity check on the framenumber. This is 2^31 frames maximum, or multiple *years* at 40ms/frame. if( ( frameNumber & 0x80000000 ) != 0 ) throw new InvalidOperationException( "(OrderManager) Frame number too large" ); + + return true; } } diff --git a/OpenRa.Game/Sidebar.cs b/OpenRa.Game/Sidebar.cs index 4f129bc780..eb76f1c5bf 100644 --- a/OpenRa.Game/Sidebar.cs +++ b/OpenRa.Game/Sidebar.cs @@ -236,6 +236,7 @@ namespace OpenRa.Game } else if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down) { + if( producing == null ) return; if (item.Tag != producing.Item) return; if (producing.Paused || producing.Done) diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index fb3f581aa3..a3692c11b4 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -18,14 +18,19 @@ namespace OpenRa.Game.Traits public RenderBuilding(Actor self) : base(self) { - if (self.IsMapActor) - anim.PlayRepeating("idle"); - else - anim.PlayThen("make", () => anim.PlayRepeating("idle")); + Make( () => anim.PlayRepeating("idle") ); DoBib(self, false); } + protected void Make( Action after ) + { + if (Game.skipMakeAnims) + after(); + else + anim.PlayThen("make", after); + } + void DoBib(Actor self, bool isRemove) { var buildingInfo = (UnitInfo.BuildingInfo)self.unitInfo; diff --git a/OpenRa.Game/Traits/RenderBuildingOre.cs b/OpenRa.Game/Traits/RenderBuildingOre.cs index 4c93fffca4..036e8f796e 100644 --- a/OpenRa.Game/Traits/RenderBuildingOre.cs +++ b/OpenRa.Game/Traits/RenderBuildingOre.cs @@ -10,7 +10,7 @@ namespace OpenRa.Game.Traits public RenderBuildingOre(Actor self) : base(self) { - anim.PlayThen("make", () => anim.PlayFetchIndex("idle", + Make( () => anim.PlayFetchIndex("idle", () => (int)(5 * self.Owner.GetSiloFullness()))); } } diff --git a/OpenRa.Game/Traits/RenderBuildingTurreted.cs b/OpenRa.Game/Traits/RenderBuildingTurreted.cs index 373a71f7dc..28a79617e3 100644 --- a/OpenRa.Game/Traits/RenderBuildingTurreted.cs +++ b/OpenRa.Game/Traits/RenderBuildingTurreted.cs @@ -10,7 +10,7 @@ namespace OpenRa.Game.Traits public RenderBuildingTurreted(Actor self) : base(self) { - anim.PlayThen( "make", () => anim.PlayFetchIndex( "idle", + Make( () => anim.PlayFetchIndex( "idle", () => self.traits.Get().turretFacing / 8 ) ); } } diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index c7b1b432e4..2d1acb1ad0 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits this.self = self; roof = new Animation(self.unitInfo.Image ?? self.unitInfo.Name); - anim.PlayThen("make", () => + Make( () => { doneBuilding = true; anim.Play("idle");