Fix gen1 map importer crashing on invalid tiles
This commit is contained in:
committed by
Matthias Mailänder
parent
9d79e52989
commit
e49135bb09
@@ -103,6 +103,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
if (Map.Rules.TerrainInfo is ITerrainInfoNotifyMapCreated notifyMapCreated)
|
if (Map.Rules.TerrainInfo is ITerrainInfoNotifyMapCreated notifyMapCreated)
|
||||||
notifyMapCreated.MapCreated(Map);
|
notifyMapCreated.MapCreated(Map);
|
||||||
|
|
||||||
|
ReplaceInvalidTerrainTiles(Map);
|
||||||
|
|
||||||
var dest = Path.GetFileNameWithoutExtension(args[1]) + ".oramap";
|
var dest = Path.GetFileNameWithoutExtension(args[1]) + ".oramap";
|
||||||
|
|
||||||
Map.Save(ZipFileLoader.Create(dest));
|
Map.Save(ZipFileLoader.Create(dest));
|
||||||
@@ -159,6 +161,19 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
missionData.Value.Nodes.Add(new MiniYamlNode("Briefing", briefing.Replace("\n", " ").ToString()));
|
missionData.Value.Nodes.Add(new MiniYamlNode("Briefing", briefing.Replace("\n", " ").ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ReplaceInvalidTerrainTiles(Map map)
|
||||||
|
{
|
||||||
|
var terrainInfo = map.Rules.TerrainInfo;
|
||||||
|
foreach (var uv in map.AllCells.MapCoords)
|
||||||
|
{
|
||||||
|
if (!terrainInfo.TryGetTerrainInfo(map.Tiles[uv], out _))
|
||||||
|
{
|
||||||
|
map.Tiles[uv] = terrainInfo.DefaultTerrainTile;
|
||||||
|
Console.WriteLine($"Replaced invalid terrain tile at {uv}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void SetBounds(Map map, IniSection mapSection)
|
static void SetBounds(Map map, IniSection mapSection)
|
||||||
{
|
{
|
||||||
var offsetX = Exts.ParseIntegerInvariant(mapSection.GetValue("X", "0"));
|
var offsetX = Exts.ParseIntegerInvariant(mapSection.GetValue("X", "0"));
|
||||||
|
|||||||
Reference in New Issue
Block a user