Fix the handling of maps with invalid rules. Fixes #6787.
This commit is contained in:
@@ -76,6 +76,7 @@ namespace OpenRA
|
|||||||
public string Tileset;
|
public string Tileset;
|
||||||
public bool AllowStartUnitConfig = true;
|
public bool AllowStartUnitConfig = true;
|
||||||
public Bitmap CustomPreview;
|
public Bitmap CustomPreview;
|
||||||
|
public bool InvalidCustomRules { get; private set; }
|
||||||
|
|
||||||
public readonly TileShape TileShape;
|
public readonly TileShape TileShape;
|
||||||
[FieldLoader.Ignore]
|
[FieldLoader.Ignore]
|
||||||
@@ -274,7 +275,21 @@ namespace OpenRA
|
|||||||
|
|
||||||
void PostInit()
|
void PostInit()
|
||||||
{
|
{
|
||||||
rules = Exts.Lazy(() => Game.modData.RulesetCache.LoadMapRules(this));
|
rules = Exts.Lazy(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Game.modData.RulesetCache.LoadMapRules(this);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
InvalidCustomRules = true;
|
||||||
|
Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Game.modData.DefaultRules;
|
||||||
|
});
|
||||||
|
|
||||||
cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]);
|
cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]);
|
||||||
|
|
||||||
var tl = Map.MapToCell(TileShape, new CPos(Bounds.Left, Bounds.Top));
|
var tl = Map.MapToCell(TileShape, new CPos(Bounds.Left, Bounds.Top));
|
||||||
|
|||||||
@@ -237,16 +237,8 @@ namespace OpenRA
|
|||||||
if (RuleStatus != MapRuleStatus.Unknown)
|
if (RuleStatus != MapRuleStatus.Unknown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
Map.PreloadRules();
|
||||||
{
|
RuleStatus = Map.InvalidCustomRules ? MapRuleStatus.Invalid : MapRuleStatus.Cached;
|
||||||
Map.PreloadRules();
|
|
||||||
RuleStatus = MapRuleStatus.Cached;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Write("debug", "Map {0} failed validation with an exception:\n{1}", Uid, e.Message);
|
|
||||||
RuleStatus = MapRuleStatus.Invalid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user