cache world.LocalPlayer instead of fetching it repeatedly within loops

This commit is contained in:
Bob
2010-10-31 17:40:54 +13:00
committed by Chris Forbes
parent d7d0d371c6
commit e3ddb8f757
5 changed files with 21 additions and 17 deletions

View File

@@ -73,17 +73,15 @@ namespace OpenRA.Mods.RA
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
trailStart.G, trailStart.B);
// LocalPlayer is null on shellmap
ShroudRenderer shroud = null;
if (self.World.LocalPlayer != null)
shroud = self.World.LocalPlayer.Shroud;
for (int i = positions.Count - 1; i >= 1; --i)
{
var conPos = positions[i];
var nextPos = positions[i - 1];
ShroudRenderer shroud = null;
// LocalPlayer is null on shellmap
if (self.World.LocalPlayer != null)
{
shroud = self.World.LocalPlayer.Shroud;
}
if (shroud == null ||
shroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) ||