From 82c9c12cae8db457f58f74a7bf76f4737355cda7 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 14 May 2010 08:16:33 +1200 Subject: [PATCH] NO THAT IS NOT WHAT YOU DO WITH USELESS CODE --- OpenRA.FileFormats/Map/Map.cs | 5 +++-- OpenRA.Game/PathSearch.cs | 2 -- .../Traits/Modifiers/WithMuzzleFlash.cs | 1 - .../Player/ConquestVictoryConditions.cs | 1 - .../Traits/Render/RenderBuildingWall.cs | 11 ++++------ OpenRA.Game/Traits/Repairable.cs | 3 +-- OpenRA.Game/Widgets/BuildPaletteWidget.cs | 7 ------ OpenRA.Game/World.cs | 22 +++++-------------- 8 files changed, 13 insertions(+), 39 deletions(-) diff --git a/OpenRA.FileFormats/Map/Map.cs b/OpenRA.FileFormats/Map/Map.cs index 04bc97b51b..759f1fdfe1 100644 --- a/OpenRA.FileFormats/Map/Map.cs +++ b/OpenRA.FileFormats/Map/Map.cs @@ -157,8 +157,9 @@ namespace OpenRA.FileFormats { using (var dataStream = Package.GetContent("map.bin")) { - //byte version = - ReadByte(dataStream); + if (ReadByte(dataStream) != 1) + throw new InvalidDataException("Unknown binary map format"); + // Load header info var width = ReadWord(dataStream); var height = ReadWord(dataStream); diff --git a/OpenRA.Game/PathSearch.cs b/OpenRA.Game/PathSearch.cs index 59c7d1e1d2..36127f7beb 100755 --- a/OpenRA.Game/PathSearch.cs +++ b/OpenRA.Game/PathSearch.cs @@ -30,7 +30,6 @@ namespace OpenRA public class PathSearch { World world; - //ResourceLayer resources; public CellInfo[ , ] cellInfo; public PriorityQueue queue; public Func heuristic; @@ -51,7 +50,6 @@ namespace OpenRA buildingInfluence = world.WorldActor.traits.Get(); unitInfluence = world.WorldActor.traits.Get(); - //resources = world.WorldActor.traits.Get(); } public PathSearch InReverse() diff --git a/OpenRA.Game/Traits/Modifiers/WithMuzzleFlash.cs b/OpenRA.Game/Traits/Modifiers/WithMuzzleFlash.cs index d184b20837..de9d5073a4 100644 --- a/OpenRA.Game/Traits/Modifiers/WithMuzzleFlash.cs +++ b/OpenRA.Game/Traits/Modifiers/WithMuzzleFlash.cs @@ -40,7 +40,6 @@ namespace OpenRA.Traits muzzleFlash = new Animation(render.GetImage(self), () => unit.Facing); muzzleFlash.Play("muzzle"); - //var len = muzzleFlash.CurrentSequence.Length; render.anims.Add("muzzle", new RenderSimple.AnimationWithOffset( muzzleFlash, diff --git a/OpenRA.Game/Traits/Player/ConquestVictoryConditions.cs b/OpenRA.Game/Traits/Player/ConquestVictoryConditions.cs index b4e3a2beb5..c85f67e6fa 100644 --- a/OpenRA.Game/Traits/Player/ConquestVictoryConditions.cs +++ b/OpenRA.Game/Traits/Player/ConquestVictoryConditions.cs @@ -36,7 +36,6 @@ namespace OpenRA.Traits public void Tick(Actor self) { - //var info = self.Info.Traits.Get(); var hasAnything = self.World.Queries.OwnedBy[self.Owner] .WithTrait().Any(); diff --git a/OpenRA.Game/Traits/Render/RenderBuildingWall.cs b/OpenRA.Game/Traits/Render/RenderBuildingWall.cs index 57d55809f4..24129e2af5 100644 --- a/OpenRA.Game/Traits/Render/RenderBuildingWall.cs +++ b/OpenRA.Game/Traits/Render/RenderBuildingWall.cs @@ -32,17 +32,12 @@ namespace OpenRA.Traits class RenderBuildingWall : RenderBuilding { string seqName; - int damageStates; - //Actor self; int adjacentWalls = 0; public RenderBuildingWall(Actor self) : base(self) { seqName = "idle"; - //this.self = self; - this.damageStates = self.Info.Traits.Get().DamageStates; - anim.PlayFetchIndex(seqName, () => adjacentWalls); } @@ -72,6 +67,8 @@ namespace OpenRA.Traits var oldState = GetExtendedState(self, e.Damage); var newState = GetExtendedState(self, 0); + var numStates = self.Info.Traits.Get().DamageStates; + if (oldState == newState) return; switch (newState) @@ -80,7 +77,7 @@ namespace OpenRA.Traits seqName = "idle"; break; case ExtendedDamageState.ThreeQuarter: - if (damageStates >= 4) + if (numStates >= 4) seqName = "minor-damaged-idle"; break; case ExtendedDamageState.Half: @@ -88,7 +85,7 @@ namespace OpenRA.Traits Sound.Play(self.Info.Traits.Get().DamagedSound, self.CenterLocation); break; case ExtendedDamageState.Quarter: - if (damageStates >= 3) + if (numStates >= 3) { seqName = "critical-idle"; Sound.Play(self.Info.Traits.Get().DamagedSound, self.CenterLocation); diff --git a/OpenRA.Game/Traits/Repairable.cs b/OpenRA.Game/Traits/Repairable.cs index 3ed2c1c1ec..0ca69d6e28 100644 --- a/OpenRA.Game/Traits/Repairable.cs +++ b/OpenRA.Game/Traits/Repairable.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. @@ -44,7 +44,6 @@ namespace OpenRA.Traits if (order.OrderString == "Enter") { - //var res = order.TargetActor.traits.GetOrDefault(); var rp = order.TargetActor.traits.GetOrDefault(); self.CancelActivity(); diff --git a/OpenRA.Game/Widgets/BuildPaletteWidget.cs b/OpenRA.Game/Widgets/BuildPaletteWidget.cs index 64a1144ee9..d6600f594f 100644 --- a/OpenRA.Game/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Game/Widgets/BuildPaletteWidget.cs @@ -222,7 +222,6 @@ namespace OpenRA.Widgets // Icons string tooltipItem = null; - //float2 tooltipPos = float2.Zero; foreach (var item in allBuildables) { var rect = new RectangleF(origin.X + x * 64, origin.Y + 48 * y, 64, 48); @@ -233,10 +232,7 @@ namespace OpenRA.Widgets var firstOfThis = queue.AllItems(queueName).FirstOrDefault(a => a.Item == item.Name); if (rect.Contains(Game.chrome.lastMousePos.ToPoint())) - { tooltipItem = item.Name; - //tooltipPos = drawPos; - } var overlayPos = drawPos + new float2((64 - ready.Image.size.X) / 2, 2); @@ -470,7 +466,6 @@ namespace OpenRA.Widgets void DrawProductionTooltip(World world, string unit, int2 pos) { pos.Y += 15; - //var chromeCollection = "chrome-" + world.LocalPlayer.Country.Race; var p = pos.ToFloat2() - new float2(297, -3); @@ -534,8 +529,6 @@ namespace OpenRA.Widgets int size = p.visibleTabs.Count(); if (size > 0) { - //string last = p.visibleTabs.Last(); - //string first = p.visibleTabs.First(); int current = p.visibleTabs.IndexOf(p.currentTab); if (!shift) { diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 7e16b1cf3b..a16f3577a0 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -138,18 +138,9 @@ namespace OpenRA public void Tick() { - //var sw = new Stopwatch(); - foreach (var a in actors) a.Tick(); - Queries.WithTraitMultiple().Do( x => - { - //var t = sw.ElapsedTime(); - x.Trait.Tick( x.Actor ); - //var dt = sw.ElapsedTime() - t; -// if( dt > 0.001 ) -// Log.Write( "expensive tick: {0}->{1}", x.Actor.Info.Name, x.Trait.GetType() ); - } ); + Queries.WithTraitMultiple().Do(x => x.Trait.Tick(x.Actor)); foreach (var e in effects) e.Tick( this ); @@ -173,14 +164,11 @@ namespace OpenRA public int SyncHash() { - //using (new PerfSample("synchash")) - { - int ret = 0; - foreach (var a in Actors) - ret += (int)a.ActorID * Sync.CalculateSyncHash(a); + int ret = 0; + foreach (var a in Actors) + ret += (int)a.ActorID * Sync.CalculateSyncHash(a); - return ret; - } + return ret; } public class AllQueries