Moved software checks in front of other checks in clifront

in order to make things more consistent with behaving when cmd line
parameters are sent, also added emuopts support to add newly created
options if some is added with adding software item in slot (no whatsnew)
This commit is contained in:
Miodrag Milanovic 2012-02-16 13:54:52 +00:00
parent b68594778f
commit a7343bc628
2 changed files with 72 additions and 64 deletions

View File

@ -150,38 +150,15 @@ int cli_frontend::execute(int argc, char **argv)
m_result = MAMERR_NONE; m_result = MAMERR_NONE;
try try
{ {
// parse the command line, adding any system-specific options // first parse options to be able to get software from it
astring option_errors; astring option_errors;
if (!m_options.parse_command_line(argc, argv, option_errors)) m_options.parse_command_line(argc, argv, option_errors);
if (strlen(m_options.software_name()) > 0)
{ {
// if we failed, check for no command and a system name first; in that case error on the name
if (strlen(m_options.command()) == 0 && m_options.system() == NULL && strlen(m_options.system_name()) > 0)
throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name());
// otherwise, error on the options
throw emu_fatalerror(MAMERR_INVALID_CONFIG, "%s", option_errors.trimspace().cstr());
}
if (option_errors)
printf("Error in command line:\n%s\n", option_errors.trimspace().cstr());
// determine the base name of the EXE
astring exename;
core_filename_extract_base(exename, argv[0], true);
// if we have a command, execute that
if (strlen(m_options.command()) != 0)
execute_commands(exename);
// otherwise, check for a valid system
else
{
// if we can't find it, give an appropriate error
const game_driver *system = m_options.system(); const game_driver *system = m_options.system();
if (system == NULL && strlen(m_options.system_name()) > 0) if (system == NULL && strlen(m_options.system_name()) > 0)
throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name());
if (strlen(m_options.software_name()) > 0)
{
machine_config config(*system, m_options); machine_config config(*system, m_options);
software_list_device_iterator iter(config.root_device()); software_list_device_iterator iter(config.root_device());
if (iter.first() == NULL) if (iter.first() == NULL)
@ -242,6 +219,34 @@ int cli_frontend::execute(int argc, char **argv)
throw emu_fatalerror(MAMERR_FATALERROR, ""); throw emu_fatalerror(MAMERR_FATALERROR, "");
} }
} }
// parse the command line, adding any system-specific options
if (!m_options.parse_command_line(argc, argv, option_errors))
{
// if we failed, check for no command and a system name first; in that case error on the name
if (strlen(m_options.command()) == 0 && m_options.system() == NULL && strlen(m_options.system_name()) > 0)
throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name());
// otherwise, error on the options
throw emu_fatalerror(MAMERR_INVALID_CONFIG, "%s", option_errors.trimspace().cstr());
}
if (option_errors)
printf("Error in command line:\n%s\n", option_errors.trimspace().cstr());
// determine the base name of the EXE
astring exename;
core_filename_extract_base(exename, argv[0], true);
// if we have a command, execute that
if (strlen(m_options.command()) != 0)
execute_commands(exename);
// otherwise, check for a valid system
else
{
// if we can't find it, give an appropriate error
const game_driver *system = m_options.system();
if (system == NULL && strlen(m_options.system_name()) > 0)
throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name());
// otherwise just run the game // otherwise just run the game
m_result = mame_execute(m_options, m_osd); m_result = mame_execute(m_options, m_osd);
} }

View File

@ -374,6 +374,8 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], astring &error_stri
} }
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
update_slot_options(); update_slot_options();
add_device_options(true);
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
return result; return result;
} }
@ -502,6 +504,7 @@ void emu_options::set_system_name(const char *name)
// then add the options // then add the options
add_device_options(true); add_device_options(true);
update_slot_options(); update_slot_options();
add_device_options(true);
} }
} }