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
This commit is contained in:
Morilli 2025-04-12 06:48:18 +02:00
parent d94fb910c7
commit cd699d7c52
2 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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 }]";
}