Catch invalid default game speeds while loading the ruleset
This commit is contained in:
@@ -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); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user