Bump the map format 5 -> 6.
Version 6 ensures that maps define RequiresMod.
This commit is contained in:
@@ -137,9 +137,16 @@ namespace OpenRA
|
|||||||
throw new InvalidOperationException("Required file {0} not present in this map".F(filename));
|
throw new InvalidOperationException("Required file {0} not present in this map".F(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map() { } /* doesn't really produce a valid map, but enough for loading a mod */
|
// Stub constructor that doesn't produce a valid map, but is
|
||||||
|
// sufficient for loading a mod to the content-install panel
|
||||||
|
public Map() { }
|
||||||
|
|
||||||
public Map(string path)
|
// The standard constructor for most purposes
|
||||||
|
public Map(string path) : this(path, null) { }
|
||||||
|
|
||||||
|
// Support upgrading format 5 maps to a more
|
||||||
|
// recent version by defining upgradeForMod.
|
||||||
|
public Map(string path, string upgradeForMod)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
Container = FileSystem.OpenPackage(path, null, int.MaxValue);
|
Container = FileSystem.OpenPackage(path, null, int.MaxValue);
|
||||||
@@ -156,6 +163,19 @@ namespace OpenRA
|
|||||||
if (MapFormat < 5)
|
if (MapFormat < 5)
|
||||||
throw new InvalidDataException("Map format {0} is not supported.\n File: {1}".F(MapFormat, path));
|
throw new InvalidDataException("Map format {0} is not supported.\n File: {1}".F(MapFormat, path));
|
||||||
|
|
||||||
|
// Format 5 -> 6 enforces the use of RequiresMod
|
||||||
|
if (MapFormat == 5)
|
||||||
|
{
|
||||||
|
if (upgradeForMod == null)
|
||||||
|
throw new InvalidDataException("Map format {0} is not supported, but can be upgraded.\n File: {1}".F(MapFormat, path));
|
||||||
|
|
||||||
|
Console.WriteLine("Upgrading {0} from Format 5 to Format 6", path);
|
||||||
|
|
||||||
|
// TODO: This isn't very nice, but there is no other consistent way
|
||||||
|
// of finding the mod early during the engine initialization.
|
||||||
|
RequiresMod = upgradeForMod;
|
||||||
|
}
|
||||||
|
|
||||||
// Load players
|
// Load players
|
||||||
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
||||||
{
|
{
|
||||||
@@ -198,6 +218,12 @@ namespace OpenRA
|
|||||||
MapTiles = Lazy.New(() => LoadMapTiles());
|
MapTiles = Lazy.New(() => LoadMapTiles());
|
||||||
MapResources = Lazy.New(() => LoadResourceTiles());
|
MapResources = Lazy.New(() => LoadResourceTiles());
|
||||||
|
|
||||||
|
// The Uid is calculated from the data on-disk, so
|
||||||
|
// format changes must be flushed to disk.
|
||||||
|
// TODO: this isn't very nice
|
||||||
|
if (MapFormat < 6)
|
||||||
|
Save(path);
|
||||||
|
|
||||||
Uid = ComputeHash();
|
Uid = ComputeHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +237,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Save(string toPath)
|
public void Save(string toPath)
|
||||||
{
|
{
|
||||||
MapFormat = 5;
|
MapFormat = 6;
|
||||||
|
|
||||||
var root = new List<MiniYamlNode>();
|
var root = new List<MiniYamlNode>();
|
||||||
var fields = new[]
|
var fields = new[]
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var map = new Map(path);
|
var map = new Map(path, Manifest.Mod.Id);
|
||||||
ret.Add(map.Uid, map);
|
ret.Add(map.Uid, map);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
Reference in New Issue
Block a user