Restore support for inline map rules.
This commit is contained in:
@@ -26,18 +26,17 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
public void Run(Action<string> emitError, Action<string> emitWarning, Map map)
|
||||
{
|
||||
if (map != null && !map.SequenceDefinitions.Any())
|
||||
if (map.SequenceDefinitions == null)
|
||||
return;
|
||||
|
||||
var modData = Game.ModData;
|
||||
this.emitError = emitError;
|
||||
|
||||
var mapSequences = map != null ? map.SequenceDefinitions : new string[0];
|
||||
sequenceDefinitions = MiniYaml.Merge(modData.Manifest.Sequences.Append(mapSequences).Select(s => MiniYaml.FromStream(map.Open(s))));
|
||||
sequenceDefinitions = MiniYaml.Load(map, modData.Manifest.Sequences, map.SequenceDefinitions);
|
||||
|
||||
var rules = map == null ? modData.DefaultRules : map.Rules;
|
||||
var rules = map.Rules;
|
||||
var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
||||
var sequenceProviders = map == null ? rules.Sequences.Values : new[] { rules.Sequences[map.Tileset] };
|
||||
var sequenceProviders = new[] { rules.Sequences[map.Tileset] };
|
||||
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
|
||||
server.SendMessage("{0} changed the map to {1}.".F(client.Name, server.Map.Title));
|
||||
|
||||
if (server.Map.RuleDefinitions.Any())
|
||||
if (server.Map.RuleDefinitions != null)
|
||||
server.SendMessage("This map contains custom rules. Game experience may change.");
|
||||
|
||||
if (server.Settings.DisableSinglePlayer)
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
testMap.PreloadRules();
|
||||
|
||||
// Run all rule checks on the map if it defines custom rules.
|
||||
if (testMap.RuleDefinitions.Any() || testMap.VoiceDefinitions.Any() || testMap.WeaponDefinitions.Any())
|
||||
if (testMap.RuleDefinitions != null || testMap.VoiceDefinitions != null || testMap.WeaponDefinitions != null)
|
||||
CheckRules(modData, testMap.Rules, testMap);
|
||||
|
||||
// Run all map-level checks here.
|
||||
|
||||
@@ -27,17 +27,23 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
delegate void UpgradeAction(int engineVersion, ref List<MiniYamlNode> nodes, MiniYamlNode parent, int depth);
|
||||
|
||||
static void ProcessYaml(Map map, IEnumerable<string> files, int engineDate, UpgradeAction processFile)
|
||||
static void ProcessYaml(Map map, MiniYaml yaml, int engineDate, UpgradeAction processYaml)
|
||||
{
|
||||
foreach (var filename in files)
|
||||
{
|
||||
if (!map.Package.Contains(filename))
|
||||
continue;
|
||||
if (yaml == null)
|
||||
return;
|
||||
|
||||
var yaml = MiniYaml.FromStream(map.Package.GetStream(filename));
|
||||
processFile(engineDate, ref yaml, null, 0);
|
||||
((IReadWritePackage)map.Package).Update(filename, Encoding.ASCII.GetBytes(yaml.WriteToString()));
|
||||
}
|
||||
if (yaml.Value != null)
|
||||
{
|
||||
var files = FieldLoader.GetValue<string[]>("value", yaml.Value);
|
||||
foreach (var filename in files)
|
||||
{
|
||||
var fileNodes = MiniYaml.FromStream(map.Package.GetStream(filename));
|
||||
processYaml(engineDate, ref fileNodes, null, 0);
|
||||
((IReadWritePackage)map.Package).Update(filename, Encoding.ASCII.GetBytes(fileNodes.WriteToString()));
|
||||
}
|
||||
}
|
||||
|
||||
processYaml(engineDate, ref yaml.Nodes, null, 1);
|
||||
}
|
||||
|
||||
public static void UpgradeMap(ModData modData, IReadWritePackage package, int engineDate)
|
||||
|
||||
Reference in New Issue
Block a user