From a41817b7030fec528aff5da57b88e543a8c5ea68 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 19 Apr 2025 20:49:05 +1000 Subject: [PATCH] Prevent devs from setting '.' as a button's mnemonic see c2ba2d7d4, #4217 --- .../Base Implementations/Bk2MnemonicLookup.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs b/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs index 080f7676ac..7a0024887b 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs @@ -1,4 +1,7 @@ using System.Collections.Generic; +using System.Diagnostics; + +using BizHawk.Common; using BizHawk.Common.StringExtensions; namespace BizHawk.Emulation.Common @@ -915,5 +918,18 @@ namespace BizHawk.Emulation.Common ["Weapon Select"] = "W", }, }; + + static Bk2MnemonicLookup() + { + const string ERR_FMT_STR = $"{nameof(Bk2MnemonicLookup)}.{{1}}[\"{{0}}\"] must not be '.' as that indicates unpressed buttons"; + foreach (var (k, v) in BaseMnemonicLookupTable) + { + Debug.Assert(v is not '.', ERR_FMT_STR, k, nameof(BaseMnemonicLookupTable)); + } + foreach (var (sysID, dict) in SystemOverrides) foreach (var (k, v) in dict) + { + Debug.Assert(v is not '.', ERR_FMT_STR, k, $"{nameof(SystemOverrides)}[{sysID}]"); + } + } } }