Remove stub map constructor.

This commit is contained in:
Paul Chote
2015-07-05 11:02:33 +01:00
parent 0dbbc00d0a
commit b8b27f11af
3 changed files with 24 additions and 11 deletions

View File

@@ -19,6 +19,8 @@ namespace OpenRA
{
public sealed class RulesetCache : IDisposable
{
static readonly List<MiniYamlNode> NoMapRules = new List<MiniYamlNode>();
readonly ModData modData;
readonly Dictionary<string, ActorInfo> actorCache = new Dictionary<string, ActorInfo>();
@@ -43,7 +45,7 @@ namespace OpenRA
public Ruleset LoadDefaultRules()
{
return LoadMapRules(new Map());
return LoadMapRules(null);
}
public Ruleset LoadMapRules(Map map)
@@ -58,20 +60,34 @@ namespace OpenRA
Dictionary<string, TileSet> tileSets;
using (new PerfTimer("Actors"))
actors = LoadYamlRules(actorCache, m.Rules, map.RuleDefinitions, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y));
actors = LoadYamlRules(actorCache, m.Rules,
map != null ? map.RuleDefinitions : NoMapRules,
(k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y));
using (new PerfTimer("Weapons"))
weapons = LoadYamlRules(weaponCache, m.Weapons, map.WeaponDefinitions, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
weapons = LoadYamlRules(weaponCache, m.Weapons,
map != null ? map.WeaponDefinitions : NoMapRules,
(k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
using (new PerfTimer("Voices"))
voices = LoadYamlRules(voiceCache, m.Voices, map.VoiceDefinitions, (k, _) => new SoundInfo(k.Value));
voices = LoadYamlRules(voiceCache, m.Voices,
map != null ? map.VoiceDefinitions : NoMapRules,
(k, _) => new SoundInfo(k.Value));
using (new PerfTimer("Notifications"))
notifications = LoadYamlRules(notificationCache, m.Notifications, map.NotificationDefinitions, (k, _) => new SoundInfo(k.Value));
notifications = LoadYamlRules(notificationCache, m.Notifications,
map != null ? map.NotificationDefinitions : NoMapRules,
(k, _) => new SoundInfo(k.Value));
using (new PerfTimer("Music"))
music = LoadYamlRules(musicCache, m.Music, new List<MiniYamlNode>(), (k, _) => new MusicInfo(k.Key, k.Value));
music = LoadYamlRules(musicCache, m.Music,
NoMapRules,
(k, _) => new MusicInfo(k.Key, k.Value));
using (new PerfTimer("TileSets"))
tileSets = LoadTileSets(tileSetCache, sequenceCaches, m.TileSets);
var sequences = sequenceCaches.ToDictionary(kvp => kvp.Key, kvp => new SequenceProvider(kvp.Value, map));
return new Ruleset(actors, weapons, voices, notifications, music, tileSets, sequences);
}

View File

@@ -120,7 +120,7 @@ namespace OpenRA.Graphics
public Sequences LoadSequences(Map map)
{
using (new Support.PerfTimer("LoadSequences"))
return Load(map.SequenceDefinitions);
return Load(map != null ? map.SequenceDefinitions : new List<MiniYamlNode>());
}
Sequences Load(List<MiniYamlNode> sequenceNodes)

View File

@@ -261,9 +261,6 @@ namespace OpenRA
throw new InvalidOperationException("Required file {0} not present in this map".F(filename));
}
/// <summary>A stub constructor that doesn't produce a valid map. Do not use.</summary>
public Map() { }
/// <summary>
/// Initializes a new map created by the editor or importer.
/// The map will not recieve a valid UID until after it has been saved and reloaded.