diff options
author | 2016-01-11 09:18:43 +0100 | |
---|---|---|
committer | 2016-01-11 09:18:43 +0100 | |
commit | 36195292e370de0fb6b32085c105a236995ce36e (patch) | |
tree | 1fb147c3e21824272b60e4989f606bc9c206030c /src/emu/mconfig.cpp | |
parent | 7c944fa3b02cd26dec3c27f1e6a4c0d33f462c4e (diff) | |
parent | 115db95642ad6d861aad63775b92350e0491f2dd (diff) |
Merge pull request #561 from ajrhacker/strings
Return std::string objects by value rather than pass by reference [ajrhacker]
Diffstat (limited to 'src/emu/mconfig.cpp')
-rw-r--r-- | src/emu/mconfig.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/emu/mconfig.cpp b/src/emu/mconfig.cpp index 1d3b5a2effd..6c052d7ce23 100644 --- a/src/emu/mconfig.cpp +++ b/src/emu/mconfig.cpp @@ -39,15 +39,16 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) for (device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) { device_t &owner = slot->device(); - std::string temp; - const char *selval = options.main_value(temp, owner.tag()+1); + std::string selval; bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT); - if (!is_selected_driver || !options.exists(owner.tag()+1)) - selval = slot->default_option(); + if (is_selected_driver && options.exists(owner.tag()+1)) + selval = options.main_value(owner.tag()+1); + else if (slot->default_option() != nullptr) + selval.assign(slot->default_option()); - if (selval != nullptr && *selval != 0) + if (!selval.empty()) { - const device_slot_option *option = slot->option(selval); + const device_slot_option *option = slot->option(selval.c_str()); if (option && (isdefault || option->selectable())) { @@ -66,7 +67,7 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) device_t::static_set_input_default(*new_dev, input_device_defaults); } else - throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval, owner.tag()+1); + throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval.c_str(), owner.tag()+1); } } |