IRulesetLoaded Warhead support and better error messages.
This commit is contained in:
@@ -46,7 +46,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static Func<string, Type, string, object> InvalidValueAction = (s, t, f) =>
|
public static Func<string, Type, string, object> InvalidValueAction = (s, t, f) =>
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("FieldLoader: Cannot parse `{0}` into `{1}.{2}` ".F(s, f, t));
|
throw new YamlException("FieldLoader: Cannot parse `{0}` into `{1}.{2}` ".F(s, f, t));
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Action<string, Type> UnknownFieldAction = (s, f) =>
|
public static Action<string, Type> UnknownFieldAction = (s, f) =>
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
return new ReplayMetadata(fs, path);
|
return new ReplayMetadata(fs, path);
|
||||||
}
|
}
|
||||||
|
catch (YamlException ex)
|
||||||
|
{
|
||||||
|
Log.Write("debug", ex.ToString());
|
||||||
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
Log.Write("debug", ex.ToString());
|
Log.Write("debug", ex.ToString());
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException)
|
catch (YamlException)
|
||||||
{
|
{
|
||||||
Log.Write("debug", "GameInformation deserialized invalid MiniYaml:\n{0}".F(data));
|
Log.Write("debug", "GameInformation deserialized invalid MiniYaml:\n{0}".F(data));
|
||||||
throw;
|
throw;
|
||||||
|
|||||||
@@ -44,9 +44,39 @@ namespace OpenRA
|
|||||||
Sequences = new ReadOnlyDictionary<string, SequenceProvider>(sequences);
|
Sequences = new ReadOnlyDictionary<string, SequenceProvider>(sequences);
|
||||||
|
|
||||||
foreach (var a in Actors.Values)
|
foreach (var a in Actors.Values)
|
||||||
|
{
|
||||||
foreach (var t in a.TraitInfos<IRulesetLoaded>())
|
foreach (var t in a.TraitInfos<IRulesetLoaded>())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
t.RulesetLoaded(this, a);
|
t.RulesetLoaded(this, a);
|
||||||
}
|
}
|
||||||
|
catch (YamlException e)
|
||||||
|
{
|
||||||
|
throw new YamlException("Actor type {0}: {1}".F(a.Name, e.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var weapon in Weapons)
|
||||||
|
{
|
||||||
|
foreach (var warhead in weapon.Value.Warheads)
|
||||||
|
{
|
||||||
|
var cacher = warhead as IRulesetLoaded<WeaponInfo>;
|
||||||
|
if (cacher != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cacher.RulesetLoaded(this, weapon.Value);
|
||||||
|
}
|
||||||
|
catch (YamlException e)
|
||||||
|
{
|
||||||
|
throw new YamlException("Weapon type {0}: {1}".F(weapon.Key, e.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<KeyValuePair<string, MusicInfo>> InstalledMusic { get { return Music.Where(m => m.Value.Exists); } }
|
public IEnumerable<KeyValuePair<string, MusicInfo>> InstalledMusic { get { return Music.Where(m => m.Value.Exists); } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,9 +59,13 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException e)
|
catch (YamlException)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Session deserialized invalid MiniYaml:\n{0}".F(data), e);
|
throw new YamlException("Session deserialized invalid MiniYaml:\n{0}".F(data));
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
throw new YamlException("Session deserialized invalid MiniYaml:\n{0}".F(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -369,5 +369,6 @@ namespace OpenRA.Traits
|
|||||||
bool RemoveActor(Actor self, Player owner);
|
bool RemoveActor(Actor self, Player owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IRulesetLoaded : ITraitInfo { void RulesetLoaded(Ruleset rules, ActorInfo ai); }
|
public interface IRulesetLoaded<TInfo> { void RulesetLoaded(Ruleset rules, TInfo info); }
|
||||||
|
public interface IRulesetLoaded : IRulesetLoaded<ActorInfo>, ITraitInfo { }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user