forked from 0ad/0ad
Avoid potentially dangerous locale-dependent atof functions
This was SVN commit r9639.
This commit is contained in:
parent
9b930d9617
commit
10481ca174
@ -136,6 +136,9 @@ public:
|
||||
// Return the string value of this object
|
||||
operator const wchar_t* () const;
|
||||
|
||||
// Return the floating point value of this object
|
||||
double getDouble() const;
|
||||
|
||||
// Check whether the object contains anything (even if those things are empty)
|
||||
bool defined() const { return (bool)p; }
|
||||
|
||||
|
@ -128,6 +128,18 @@ AtObj::operator const wchar_t* () const
|
||||
return L"";
|
||||
}
|
||||
|
||||
double AtObj::getDouble() const
|
||||
{
|
||||
double val = 0;
|
||||
if (p)
|
||||
{
|
||||
std::wstringstream s;
|
||||
s << p->value;
|
||||
s >> val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void AtObj::add(const char* key, AtObj& data)
|
||||
{
|
||||
if (!p)
|
||||
|
@ -625,13 +625,13 @@ void PlayerSettingsControl::ReadFromEngine()
|
||||
{
|
||||
sCameraInfo info;
|
||||
AtObj camPos = *player["StartingCamera"]["Position"];
|
||||
info.pX = wxAtof(*camPos["x"]);
|
||||
info.pY = wxAtof(*camPos["y"]);
|
||||
info.pZ = wxAtof(*camPos["z"]);
|
||||
info.pX = (float)(*camPos["x"]).getDouble();
|
||||
info.pY = (float)(*camPos["y"]).getDouble();
|
||||
info.pZ = (float)(*camPos["z"]).getDouble();
|
||||
AtObj camRot = *player["StartingCamera"]["Rotation"];
|
||||
info.rX = wxAtof(*camRot["x"]);
|
||||
info.rY = wxAtof(*camRot["y"]);
|
||||
info.rZ = wxAtof(*camRot["z"]);
|
||||
info.rX = (float)(*camRot["x"]).getDouble();
|
||||
info.rY = (float)(*camRot["y"]).getDouble();
|
||||
info.rZ = (float)(*camRot["z"]).getDouble();
|
||||
|
||||
controls.page->SetCamera(info, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user