From 54f7b6430d46fc5759bcda3815d12e2a430644e3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 15 Aug 2010 16:58:46 +1200 Subject: [PATCH] Fix map importer --- OpenRA.Editor/LegacyMapImporter.cs | 10 +++++----- OpenRA.Game/ActorReference.cs | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/OpenRA.Editor/LegacyMapImporter.cs b/OpenRA.Editor/LegacyMapImporter.cs index 669953f451..5afaeccba7 100644 --- a/OpenRA.Editor/LegacyMapImporter.cs +++ b/OpenRA.Editor/LegacyMapImporter.cs @@ -251,7 +251,7 @@ namespace OpenRA.Editor Map.MapResources[i, j] = new TileReference(res.First, res.Second); if (o != 255 && overlayActorMapping.ContainsKey(raOverlayNames[o])) - Map.Actors.Add("Actor" + ActorCount, + Map.Actors.Add("Actor" + ActorCount++, new ActorReference(overlayActorMapping[raOverlayNames[o]]) { new LocationInit( new int2(i, j) ), @@ -269,7 +269,7 @@ namespace OpenRA.Editor foreach (KeyValuePair kv in terrain) { var loc = int.Parse(kv.Key); - Map.Actors.Add("Actor" + ActorCount, + Map.Actors.Add("Actor" + ActorCount++, new ActorReference(kv.Value.ToLowerInvariant()) { new LocationInit(new int2(loc % MapSize, loc / MapSize)), @@ -315,7 +315,7 @@ namespace OpenRA.Editor Map.MapResources[cell.X, cell.Y] = new TileReference(res.First, res.Second); if (overlayActorMapping.ContainsKey(kv.Value.ToLower())) - Map.Actors.Add("Actor" + ActorCount, + Map.Actors.Add("Actor" + ActorCount++, new ActorReference(overlayActorMapping[kv.Value.ToLower()]) { new LocationInit(cell), @@ -333,7 +333,7 @@ namespace OpenRA.Editor foreach (KeyValuePair kv in terrain) { var loc = int.Parse(kv.Key); - Map.Actors.Add("Actor" + ActorCount, + Map.Actors.Add("Actor" + ActorCount++, new ActorReference(kv.Value.Split(',')[0].ToLowerInvariant()) { new LocationInit(new int2(loc % MapSize, loc / MapSize)), @@ -351,7 +351,7 @@ namespace OpenRA.Editor var loc = int.Parse(parts[3]); if (parts[0] == "") parts[0] = "Neutral"; - Map.Actors.Add("Actor" + ActorCount, + Map.Actors.Add("Actor" + ActorCount++, new ActorReference(parts[1].ToLowerInvariant()) { new LocationInit(new int2(loc % MapSize, loc / MapSize)), diff --git a/OpenRA.Game/ActorReference.cs b/OpenRA.Game/ActorReference.cs index 63ba48f1e3..e0d0ebe92e 100755 --- a/OpenRA.Game/ActorReference.cs +++ b/OpenRA.Game/ActorReference.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Collections; +using System.IO; namespace OpenRA.FileFormats { @@ -22,6 +23,9 @@ namespace OpenRA.FileFormats public ActorReference( string type, Dictionary inits ) { + if (!Rules.Info.ContainsKey(type)) + throw new InvalidDataException("Unknown actor: `{0}'".F(type)); + Type = type; InitDict = new TypeDictionary(); foreach( var i in inits )