summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2026-01-13 03:16:26 +1100
committer Vas Crabb <vas@vastheman.com>2026-01-13 03:16:26 +1100
commit6907b0eb4dfcb0ad3b0cb17c86923f4d56608771 (patch)
tree0f49372404cdd55ef12377f9c8bb4821c4e22557 /src/frontend
parente25ef95c4628fcf2c712e82d7ba4475a4a6faa89 (diff)
-util/options.cpp: Shuffled numeric option conversions:
* Moved float/integer conversions into the option entries themselves. * Fixed another bug where float values would be converted to strings with the global local, but converted from strings using the "classic" locale. * frontend/mame/luaengine.cpp: Got rid of duplicated numeric options conversion code.
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/luaengine.cpp36
1 files changed, 6 insertions, 30 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 5b6bed871f8..fb6ec7c17e0 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -1358,21 +1358,21 @@ void lua_engine::initialize()
if (e.type() != core_options::option_type::BOOLEAN)
luaL_error(s, "Cannot set option to wrong type");
else
- e.set_value(val ? "1" : "0", OPTION_PRIORITY_CMDLINE);
+ e.set_value(val ? 1 : 0, OPTION_PRIORITY_CMDLINE);
},
[] (core_options::entry &e, sol::this_state s, int val)
{
if (e.type() != core_options::option_type::INTEGER)
luaL_error(s, "Cannot set option to wrong type");
else
- e.set_value(string_format(std::locale::classic(), "%d", val), OPTION_PRIORITY_CMDLINE);
+ e.set_value(val, OPTION_PRIORITY_CMDLINE);
},
[] (core_options::entry &e, sol::this_state s, float val)
{
if (e.type() != core_options::option_type::FLOAT)
luaL_error(s, "Cannot set option to wrong type");
else
- e.set_value(string_format(std::locale::classic(), "%f", val), OPTION_PRIORITY_CMDLINE);
+ e.set_value(val, OPTION_PRIORITY_CMDLINE);
},
[] (core_options::entry &e, sol::this_state s, const char *val)
{
@@ -1388,35 +1388,11 @@ void lua_engine::initialize()
switch (e.type())
{
case core_options::option_type::BOOLEAN:
- {
- std::istringstream str(e.value());
- str.imbue(std::locale::classic());
- int ival;
- if (str >> ival)
- return sol::make_object(s, ival != 0);
- else
- return sol::make_object(s, false);
- }
+ return sol::make_object(s, e.bool_value());
case core_options::option_type::INTEGER:
- {
- std::istringstream str(e.value());
- str.imbue(std::locale::classic());
- int ival;
- if (str >> ival)
- return sol::make_object(s, ival);
- else
- return sol::make_object(s, 0);
- }
+ return sol::make_object(s, e.int_value());
case core_options::option_type::FLOAT:
- {
- std::istringstream str(e.value());
- str.imbue(std::locale::classic());
- float fval;
- if (str >> fval)
- return sol::make_object(s, fval);
- else
- return sol::make_object(s, 0.0F);
- }
+ return sol::make_object(s, e.float_value());
default:
return sol::make_object(s, e.value());
}