From c3b08a60b864ec8655944efd93fe691ad5570655 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 30 Jan 2011 14:00:10 +1300 Subject: [PATCH] more cleanup --- OpenRA.Editor/ActorTool.cs | 12 +++++++++++- OpenRA.Editor/ResourceTool.cs | 5 ++++- OpenRA.Editor/Surface.cs | 19 ------------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/OpenRA.Editor/ActorTool.cs b/OpenRA.Editor/ActorTool.cs index c8a6fcc9d2..751d7302c7 100644 --- a/OpenRA.Editor/ActorTool.cs +++ b/OpenRA.Editor/ActorTool.cs @@ -34,12 +34,22 @@ namespace OpenRA.Editor return; var owner = "Neutral"; - var id = surface.NextActorName(); + var id = NextActorName(surface); surface.Map.Actors[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant()) { new LocationInit( surface.GetBrushLocation() ), new OwnerInit( owner) }; } + + string NextActorName(Surface surface) + { + var id = 0; + for (; ; ) + { + var possible = "Actor{0}".F(id++); + if (!surface.Map.Actors.ContainsKey(possible)) return possible; + } + } } } diff --git a/OpenRA.Editor/ResourceTool.cs b/OpenRA.Editor/ResourceTool.cs index 580977f09e..0d63a7c227 100644 --- a/OpenRA.Editor/ResourceTool.cs +++ b/OpenRA.Editor/ResourceTool.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using OpenRA.FileFormats; using SGraphics = System.Drawing.Graphics; @@ -26,7 +27,7 @@ namespace OpenRA.Editor = new TileReference { type = (byte)Resource.Info.ResourceType, - index = (byte)surface.random.Next(Resource.Info.SpriteNames.Length), + index = (byte)random.Next(Resource.Info.SpriteNames.Length), image = (byte)Resource.Value }; @@ -44,5 +45,7 @@ namespace OpenRA.Editor { surface.DrawImage(g, Resource.Bitmap, surface.GetBrushLocation()); } + + Random random = new Random(); } } diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 74d36052f0..35cf2859af 100755 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -186,25 +186,6 @@ namespace OpenRA.Editor void Draw() { if (Tool != null) Tool.Apply(this); - - AfterChange(); - } - - int id; - public string NextActorName() - { - for (; ; ) - { - var possible = "Actor{0}".F(id++); - if (!Map.Actors.ContainsKey(possible)) return possible; - } - } - - public System.Random random = new System.Random(); - void DrawWithResource() - { - - AfterChange(); }