Drop support for older map formats.
This commit is contained in:
@@ -436,8 +436,11 @@ namespace OpenRA.Editor
|
|||||||
OwnsWorld = (section == "Neutral"),
|
OwnsWorld = (section == "Neutral"),
|
||||||
NonCombatant = (section == "Neutral"),
|
NonCombatant = (section == "Neutral"),
|
||||||
Race = (isRA) ? ((section == "BadGuy") ? "soviet" : "allies") : ((section == "BadGuy") ? "nod" : "gdi"),
|
Race = (isRA) ? ((section == "BadGuy") ? "soviet" : "allies") : ((section == "BadGuy") ? "nod" : "gdi"),
|
||||||
Color = color.First,
|
ColorRamp = new ColorRamp(
|
||||||
Color2 = color.Second,
|
(byte)((color.First.GetHue() / 360.0f) * 255),
|
||||||
|
(byte)(color.First.GetSaturation() * 255),
|
||||||
|
(byte)(color.First.GetBrightness() * 255),
|
||||||
|
(byte)(color.Second.GetBrightness() * 255))
|
||||||
};
|
};
|
||||||
|
|
||||||
var Neutral = new List<string>(){"Neutral"};
|
var Neutral = new List<string>(){"Neutral"};
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ namespace OpenRA.FileFormats
|
|||||||
public string Race;
|
public string Race;
|
||||||
|
|
||||||
public bool LockColor = false;
|
public bool LockColor = false;
|
||||||
public Color Color = Color.FromArgb(238,238,238);
|
|
||||||
public Color Color2 = Color.FromArgb(44,28,24);
|
|
||||||
public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25);
|
public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25);
|
||||||
|
|
||||||
public int InitialCash = 0;
|
public int InitialCash = 0;
|
||||||
|
|||||||
@@ -89,68 +89,38 @@ namespace OpenRA
|
|||||||
// 'Simple' metadata
|
// 'Simple' metadata
|
||||||
FieldLoader.Load( this, yaml );
|
FieldLoader.Load( this, yaml );
|
||||||
|
|
||||||
|
// Support for formats 1-3 dropped 2011-02-11.
|
||||||
|
// Use release-20110207 to convert older maps to format 4
|
||||||
|
if (MapFormat < 4)
|
||||||
|
throw new InvalidDataException("Map format {0} is not supported.\n File: {1}".F(MapFormat, path));
|
||||||
|
|
||||||
// Players & Actors -- this has changed several times.
|
|
||||||
// - Be backwards compatible wherever possible.
|
|
||||||
// - Loading a map then saving it out upgrades to latest.
|
|
||||||
// Minimum criteria for dropping a format:
|
|
||||||
// - There are no maps of this format left in tree
|
|
||||||
|
|
||||||
switch (MapFormat)
|
// Define RequiresMod for map installer
|
||||||
{
|
if (MapFormat < 5)
|
||||||
case 1:
|
RequiresMod = Game.CurrentMods.Keys.First();
|
||||||
{
|
|
||||||
Players.Add("Neutral", new PlayerReference("Neutral", "allies", true, true));
|
|
||||||
|
|
||||||
int actors = 0;
|
|
||||||
foreach (var kv in yaml.NodesDict["Actors"].NodesDict)
|
|
||||||
{
|
|
||||||
string[] vals = kv.Value.Value.Split(' ');
|
|
||||||
string[] loc = vals[2].Split(',');
|
|
||||||
Actors.Add("Actor" + actors++, new ActorReference(vals[0])
|
|
||||||
{
|
|
||||||
new LocationInit( new int2( int.Parse( loc[ 0 ] ), int.Parse( loc[ 1 ] ) ) ),
|
|
||||||
new OwnerInit( "Neutral" ),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case 2:
|
// Load players
|
||||||
{
|
|
||||||
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
||||||
{
|
{
|
||||||
var player = new PlayerReference(kv.Value);
|
var player = new PlayerReference(kv.Value);
|
||||||
Players.Add(player.Name, player);
|
Players.Add(player.Name, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var kv in yaml.NodesDict["Actors"].NodesDict)
|
// Creep player
|
||||||
|
if (MapFormat < 5)
|
||||||
{
|
{
|
||||||
var oldActorReference = FieldLoader.Load<Format2ActorReference>(kv.Value);
|
foreach (var mp in Players.Where(p => !p.Value.NonCombatant && !p.Value.Enemies.Contains("Creeps")))
|
||||||
Actors.Add(oldActorReference.Id, new ActorReference(oldActorReference.Type)
|
mp.Value.Enemies = mp.Value.Enemies.Concat(new[] {"Creeps"}).ToArray();
|
||||||
|
|
||||||
|
Players.Add("Creeps", new PlayerReference
|
||||||
{
|
{
|
||||||
new LocationInit( oldActorReference.Location ),
|
Name = "Creeps",
|
||||||
new OwnerInit( oldActorReference.Owner )
|
Race = "Random",
|
||||||
|
NonCombatant = true,
|
||||||
|
Enemies = Players.Keys.Where(k => k != "Neutral").ToArray()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
|
||||||
{
|
|
||||||
var player = new PlayerReference(kv.Value);
|
|
||||||
Players.Add(player.Name, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var kv in yaml.NodesDict["Actors"].NodesDict)
|
|
||||||
Actors.Add(kv.Key, new ActorReference(kv.Value.Value, kv.Value.NodesDict));
|
|
||||||
} break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new InvalidDataException("Map format {0} is not supported.".F(MapFormat));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* hack: make some slots. */
|
/* hack: make some slots. */
|
||||||
if (!Players.Any(p => p.Value.Playable))
|
if (!Players.Any(p => p.Value.Playable))
|
||||||
@@ -169,32 +139,9 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color1/Color2 -> ColorRamp
|
// Load actors
|
||||||
if (MapFormat < 4)
|
foreach (var kv in yaml.NodesDict["Actors"].NodesDict)
|
||||||
foreach (var mp in Players)
|
Actors.Add(kv.Key, new ActorReference(kv.Value.Value, kv.Value.NodesDict));
|
||||||
mp.Value.ColorRamp = new ColorRamp(
|
|
||||||
(byte)((mp.Value.Color.GetHue() / 360.0f) * 255),
|
|
||||||
(byte)(mp.Value.Color.GetSaturation() * 255),
|
|
||||||
(byte)(mp.Value.Color.GetBrightness() * 255),
|
|
||||||
(byte)(mp.Value.Color2.GetBrightness() * 255));
|
|
||||||
|
|
||||||
|
|
||||||
// Creep player / Required Mod
|
|
||||||
if (MapFormat < 5)
|
|
||||||
{
|
|
||||||
RequiresMod = Game.CurrentMods.Keys.First();
|
|
||||||
|
|
||||||
foreach (var mp in Players.Where(p => !p.Value.NonCombatant && !p.Value.Enemies.Contains("Creeps")))
|
|
||||||
mp.Value.Enemies = mp.Value.Enemies.Concat(new[] {"Creeps"}).ToArray();
|
|
||||||
|
|
||||||
Players.Add("Creeps", new PlayerReference
|
|
||||||
{
|
|
||||||
Name = "Creeps",
|
|
||||||
Race = "Random",
|
|
||||||
NonCombatant = true,
|
|
||||||
Enemies = Players.Keys.Where(k => k != "Neutral").ToArray()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Smudges
|
// Smudges
|
||||||
foreach (var kv in yaml.NodesDict["Smudges"].NodesDict)
|
foreach (var kv in yaml.NodesDict["Smudges"].NodesDict)
|
||||||
|
|||||||
Reference in New Issue
Block a user