mirror of
https://github.com/holub/mame
synced 2025-05-20 20:58:51 +03:00
- Added new operation on options which enables adding of parameter and executing it's callback
- Updated parse_ini_file so before INI is loaded set of driver name is done, and therefore needed callback is executed. This fixes issue that when running MESS you are able to mount images even if you did not start driver directly, before this change we got unknown ini options warnings. (no whatsnew)
This commit is contained in:
parent
6cc37700c8
commit
fcd17cc3af
@ -565,6 +565,14 @@ static int parse_ini_file(core_options *options, const char *name, int priority)
|
||||
if (filerr != FILERR_NONE)
|
||||
return FALSE;
|
||||
|
||||
/* clear flag for added devices */
|
||||
options_set_bool(options, OPTION_ADDED_DEVICE_OPTIONS, FALSE, OPTION_PRIORITY_CMDLINE);
|
||||
|
||||
/* update game name so depending callback options could be added */
|
||||
if (priority==OPTION_PRIORITY_DRIVER_INI) {
|
||||
options_force_option_callback(options, OPTION_GAMENAME, name, priority);
|
||||
}
|
||||
|
||||
/* parse the file and close it */
|
||||
mame_printf_verbose("Parsing %s.ini\n", name);
|
||||
options_parse_ini_file(options, mame_core_file(file), priority);
|
||||
|
@ -494,6 +494,30 @@ int options_parse_command_line(core_options *opts, int argc, char **argv, int pr
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
options_force_option_callback - set option value
|
||||
and execute callback call
|
||||
-------------------------------------------------*/
|
||||
|
||||
int options_force_option_callback(core_options *opts, const char *optionname, const char *newval, int priority)
|
||||
{
|
||||
options_data *data = find_entry_data(opts, optionname, TRUE);
|
||||
if (data == NULL)
|
||||
{
|
||||
message(opts, OPTMSG_ERROR, "Error: unknown option: %s\n", optionname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* invoke callback, if present */
|
||||
if (data->callback != NULL)
|
||||
(*data->callback)(opts, newval);
|
||||
|
||||
/* allocate a new copy of data for this */
|
||||
update_data(opts, data, newval, priority);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
options_parse_ini_file - parse a series
|
||||
of entries in an INI file
|
||||
|
@ -164,6 +164,9 @@ int options_set_option_callback(core_options *opts, const char *name, void (*cal
|
||||
/* parse option data from a command line */
|
||||
int options_parse_command_line(core_options *opts, int argc, char **argv, int priority);
|
||||
|
||||
/* set option value and execute callback call */
|
||||
int options_force_option_callback(core_options *opts, const char *optionname, const char *newval, int priority);
|
||||
|
||||
/* parse option data from an INI file */
|
||||
int options_parse_ini_file(core_options *opts, core_file *inifile, int priority);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user