mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-05 18:40:22 +00:00
StringUtil: Make TryParse parse floats as booleans
This is needed to keep compatibility with old configuration files which didn't store booleans as booleans, but as floats/doubles.
This commit is contained in:
parent
5e829f4527
commit
213373f5f9
@ -247,9 +247,11 @@ bool TryParse(const std::string& str, u32* const output)
|
|||||||
|
|
||||||
bool TryParse(const std::string& str, bool* const output)
|
bool TryParse(const std::string& str, bool* const output)
|
||||||
{
|
{
|
||||||
if ("1" == str || !strcasecmp("true", str.c_str()))
|
float value;
|
||||||
|
const bool is_valid_float = TryParse(str, &value);
|
||||||
|
if ((is_valid_float && value == 1) || !strcasecmp("true", str.c_str()))
|
||||||
*output = true;
|
*output = true;
|
||||||
else if ("0" == str || !strcasecmp("false", str.c_str()))
|
else if ((is_valid_float && value == 0) || !strcasecmp("false", str.c_str()))
|
||||||
*output = false;
|
*output = false;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user