Catch invalid default game speeds while loading the ruleset

This commit is contained in:
abcdefg30
2017-10-08 00:41:33 +02:00
committed by reaperrr
parent 97e0f17e15
commit 7ccf41be77

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Controls the game speed, tech level, and short game lobby options.")]
public class MapOptionsInfo : ITraitInfo, ILobbyOptions
public class MapOptionsInfo : ITraitInfo, ILobbyOptions, IRulesetLoaded
{
[Desc("Default value of the short game checkbox in the lobby.")]
public readonly bool ShortGameEnabled = true;
@@ -57,6 +57,13 @@ namespace OpenRA.Mods.Common.Traits
GameSpeed, GameSpeedLocked);
}
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
{
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
if (!gameSpeeds.ContainsKey(GameSpeed))
throw new YamlException("Invalid default game speed '{0}'.".F(GameSpeed));
}
public object Create(ActorInitializer init) { return new MapOptions(this); }
}