Game Development Community

Console Variables and Locale

by Igor G · in Torque Game Engine · 10/22/2008 (11:17 am) · 0 replies

I am having some issues with Internationalization (under Windows) and was wondering if anybody has found a way to fix this:

In most European countries, the decimal symbol is the decimal comma, not the decimal period we use in the U.S. So if I set my regional settings to Germany, the decimal 0.5 would be represented as 0,5

If I perform some math functions in the console, such as $var = 50.0 / 100.0; the value of $var would be saved as 0,5 (this is correct)

Now, in the engine code, if I were to do a Con::getFloatVariable("$var"); this would return 0.0f.

In the getFloatVariable function, the call to getVariable returns "0.5", but when the code runs through dAtof("0.5"), this returns 0.0 because the system's decimal symbol is the comma, and is expecting "0,5".

Does anyone know how I can use script variables in C++ code if the user's decimal symbol is not the decimal period?

Thanks.