From cd699d7c5225e445c3cc28c2488c4bb48a830607 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sat, 12 Apr 2025 06:48:18 +0200 Subject: [PATCH] fix separator conflict in mame dipswitch option code "@" was used as part of a description string, breaking the parsing. Surely no description includes a newline... (is there a better way to do this?) - closes #4288 --- src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs | 4 ++-- src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs index 50295873a0..96c537efd1 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs @@ -93,11 +93,11 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME }; var DIPSwitchOptions = MameGetString(MAMELuaCommand.GetDIPSwitchOptions(tag, fieldName)); - var options = DIPSwitchOptions.Split(new[] { '@' }, StringSplitOptions.RemoveEmptyEntries); + var options = DIPSwitchOptions.Split('\n'); if (options.Length is 0) continue; foreach (var option in options) { - var opt = option.Split(new[] { '~' }, StringSplitOptions.RemoveEmptyEntries); + var opt = option.Split('~'); setting.Options.Add(opt[0], opt[1]); } CurrentDriverSettings.Add(setting); diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs index 71616ec3dd..7da111e2dc 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs @@ -433,10 +433,10 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME public static string GetDIPSwitchOptions(string tag, string fieldName) => "local final = { } " + $"for value, description in pairs(manager.machine.ioport.ports[\"{ tag }\"].fields[\"{ fieldName }\"].settings) do " + - "table.insert(final, string.format(\"%d~%s@\", value, description)) " + + "table.insert(final, string.format(\"%d~%s\", value, description)) " + "end " + "table.sort(final) " + - "return table.concat(final)"; + "return table.concat(final, '\\n')"; public static string GetViewName(string index) => $"return manager.machine.video.snapshot_target.view_names[{ index }]"; }