Remove redundant Rules definition from ImportLegacyMapCommand.

This commit is contained in:
Paul Chote
2016-03-01 21:42:21 +00:00
parent 51ceda4e7f
commit 2029f34c86
4 changed files with 11 additions and 13 deletions

View File

@@ -858,10 +858,10 @@ namespace OpenRA
ProjectedCellBounds = new ProjectedCellRegion(this, tl, br); ProjectedCellBounds = new ProjectedCellRegion(this, tl, br);
} }
public void FixOpenAreas(Ruleset rules) public void FixOpenAreas()
{ {
var r = new Random(); var r = new Random();
var tileset = rules.TileSets[Tileset]; var tileset = Rules.TileSets[Tileset];
for (var j = Bounds.Top; j < Bounds.Bottom; j++) for (var j = Bounds.Top; j < Bounds.Bottom; j++)
{ {

View File

@@ -33,7 +33,6 @@ namespace OpenRA.Mods.Common.UtilityCommands
public ModData ModData; public ModData ModData;
public Map Map; public Map Map;
public Ruleset Rules;
public List<string> Players = new List<string>(); public List<string> Players = new List<string>();
public MapPlayers MapPlayers; public MapPlayers MapPlayers;
@@ -49,7 +48,6 @@ namespace OpenRA.Mods.Common.UtilityCommands
// HACK: The engine code assumes that Game.modData is set. // HACK: The engine code assumes that Game.modData is set.
Game.ModData = modData; Game.ModData = modData;
Rules = modData.RulesetCache.Load(modData.DefaultFileSystem);
var filename = args[1]; var filename = args[1];
using (var stream = modData.DefaultFileSystem.Open(filename)) using (var stream = modData.DefaultFileSystem.Open(filename))
@@ -62,7 +60,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
ValidateMapFormat(format); ValidateMapFormat(format);
var tileset = GetTileset(mapSection); var tileset = GetTileset(mapSection);
Map = new Map(modData, Rules.TileSets[tileset], MapSize, MapSize) Map = new Map(modData, modData.DefaultRules.TileSets[tileset], MapSize, MapSize)
{ {
Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)), Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)),
Author = "Westwood Studios" Author = "Westwood Studios"
@@ -93,7 +91,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
Map.PlayerDefinitions = MapPlayers.ToMiniYaml(); Map.PlayerDefinitions = MapPlayers.ToMiniYaml();
} }
Map.FixOpenAreas(Rules); Map.FixOpenAreas();
var dest = Path.GetFileNameWithoutExtension(args[1]) + ".oramap"; var dest = Path.GetFileNameWithoutExtension(args[1]) + ".oramap";
var package = new ZipFile(modData.ModFiles, dest, true); var package = new ZipFile(modData.ModFiles, dest, true);
@@ -180,9 +178,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
public virtual void ReadActors(IniFile file) public virtual void ReadActors(IniFile file)
{ {
LoadActors(file, "STRUCTURES", Players, MapSize, Rules, Map); LoadActors(file, "STRUCTURES", Players, MapSize, Map);
LoadActors(file, "UNITS", Players, MapSize, Rules, Map); LoadActors(file, "UNITS", Players, MapSize, Map);
LoadActors(file, "INFANTRY", Players, MapSize, Rules, Map); LoadActors(file, "INFANTRY", Players, MapSize, Map);
} }
public abstract void LoadPlayer(IniFile file, string section); public abstract void LoadPlayer(IniFile file, string section);
@@ -298,7 +296,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
mapPlayers.Players[section] = pr; mapPlayers.Players[section] = pr;
} }
public static void LoadActors(IniFile file, string section, List<string> players, int mapSize, Ruleset rules, Map map) public static void LoadActors(IniFile file, string section, List<string> players, int mapSize, Map map)
{ {
foreach (var s in file.GetSection(section, true)) foreach (var s in file.GetSection(section, true))
{ {
@@ -334,7 +332,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
var actorCount = map.ActorDefinitions.Count; var actorCount = map.ActorDefinitions.Count;
if (!rules.Actors.ContainsKey(parts[1].ToLowerInvariant())) if (!map.Rules.Actors.ContainsKey(parts[1].ToLowerInvariant()))
Console.WriteLine("Ignoring unknown actor type: `{0}`".F(parts[1].ToLowerInvariant())); Console.WriteLine("Ignoring unknown actor type: `{0}`".F(parts[1].ToLowerInvariant()));
else else
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + actorCount++, actor.Save())); map.ActorDefinitions.Add(new MiniYamlNode("Actor" + actorCount++, actor.Save()));

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
map.SetBounds(tl, br); map.SetBounds(tl, br);
map.PlayerDefinitions = new MapPlayers(map.Rules, map.SpawnPoints.Value.Length).ToMiniYaml(); map.PlayerDefinitions = new MapPlayers(map.Rules, map.SpawnPoints.Value.Length).ToMiniYaml();
map.FixOpenAreas(world.Map.Rules); map.FixOpenAreas();
Action<string> afterSave = uid => Action<string> afterSave = uid =>
{ {

View File

@@ -226,7 +226,7 @@ namespace OpenRA.Mods.RA.UtilityCommands
public override void ReadActors(IniFile file) public override void ReadActors(IniFile file)
{ {
base.ReadActors(file); base.ReadActors(file);
LoadActors(file, "SHIPS", Players, MapSize, Rules, Map); LoadActors(file, "SHIPS", Players, MapSize, Map);
} }
} }
} }