From 36a537a88e74a357baaa708b537e1c8f1f61e988 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 13 Nov 2013 21:37:28 +0100 Subject: [PATCH] Changed: Replaced atof by fromString --- code/nel/src/georges/type.cpp | 2 +- code/nel/src/ligo/primitive.cpp | 2 +- code/nel/src/ligo/primitive_class.cpp | 2 +- code/nel/tools/3d/zone_welder/zone_welder.cpp | 2 +- code/ryzom/common/src/game_share/fame.cpp | 7 ++++-- .../server/src/ai_data_service/pacs_scan.cpp | 22 +++++++++++++------ .../server/src/ai_share/primitive_parser.cpp | 18 ++++++++------- 7 files changed, 34 insertions(+), 21 deletions(-) diff --git a/code/nel/src/georges/type.cpp b/code/nel/src/georges/type.cpp index 5b18c65c5..688a0f72f 100644 --- a/code/nel/src/georges/type.cpp +++ b/code/nel/src/georges/type.cpp @@ -350,7 +350,7 @@ public: { i++; // Set the result - result = atof (filename.c_str () + i); + NLMISC::fromString(filename.substr(i), result); } else { diff --git a/code/nel/src/ligo/primitive.cpp b/code/nel/src/ligo/primitive.cpp index 4120c2c2a..9cf7df13f 100644 --- a/code/nel/src/ligo/primitive.cpp +++ b/code/nel/src/ligo/primitive.cpp @@ -139,7 +139,7 @@ bool ReadFloat (const char *propName, float &result, const char *filename, xmlNo string value; if (GetPropertyString (value, filename, xmlNode, propName)) { - result = (float)atof (value.c_str ()); + NLMISC::fromString(value, result); return true; } return false; diff --git a/code/nel/src/ligo/primitive_class.cpp b/code/nel/src/ligo/primitive_class.cpp index 5f7903a89..2d7c6070d 100644 --- a/code/nel/src/ligo/primitive_class.cpp +++ b/code/nel/src/ligo/primitive_class.cpp @@ -38,7 +38,7 @@ bool ReadFloat (const char *propName, float &result, xmlNodePtr xmlNode) string value; if (CIXml::getPropertyString (value, xmlNode, propName)) { - result = (float)atof (value.c_str ()); + NLMISC::fromString(value, result); return true; } return false; diff --git a/code/nel/tools/3d/zone_welder/zone_welder.cpp b/code/nel/tools/3d/zone_welder/zone_welder.cpp index 3afd5aca6..f30a4b38b 100644 --- a/code/nel/tools/3d/zone_welder/zone_welder.cpp +++ b/code/nel/tools/3d/zone_welder/zone_welder.cpp @@ -991,7 +991,7 @@ int main(sint argc, char **argv) if(argc == 4) { - weldRadius = (float) atof(argv[3]); + NLMISC::fromString(argv[3], weldRadius); } std::string center=getName(argv[1]).c_str(); diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index 541a2e8d9..b453bca4e 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -477,9 +477,12 @@ void CStaticFames::loadStaticFame( const string& filename ) if (sep == string::npos) sep = s.size(); else - factor = (float) atof( s.substr(sep+1, s.size()-sep-1).c_str()); + NLMISC::fromString(s.substr(sep+1, s.size()-sep-1), factor); // Fames in file are in [-600;600] so don't forget 1000 factor - sint32 fame = (sint32)(atof(s.substr(0,sep).c_str())*1000.f); + sint32 fame; + float fameFloat; + NLMISC::fromString(s.substr(0, sep), fameFloat); + fame = (sint32)(fameFloat * 1000.f); _FameTable[iFaction*_FameTableSize + jFaction] = fame; _PropagationFactorTable[iFaction*_FameTableSize + jFaction] = factor; diff --git a/code/ryzom/server/src/ai_data_service/pacs_scan.cpp b/code/ryzom/server/src/ai_data_service/pacs_scan.cpp index b593c7a37..5fc1ed6b5 100644 --- a/code/ryzom/server/src/ai_data_service/pacs_scan.cpp +++ b/code/ryzom/server/src/ai_data_service/pacs_scan.cpp @@ -2401,9 +2401,17 @@ NLMISC_COMMAND(setStartPoint,"Set the start point for a continent"," CVectorD startPoint; - startPoint.x = atof(args[1].c_str()); - startPoint.y = atof(args[2].c_str()); - startPoint.z = (args.size() < 4 ? 0.0 : atof(args[3].c_str())); + NLMISC::fromString(args[1], startPoint.x); + NLMISC::fromString(args[2], startPoint.y); + + if (args.size() < 4) + { + startPoint.z = 0.0; + } + else + { + NLMISC::fromString(args[3], startPoint.z); + } StartPoints.insert(multimap::value_type(args[0], startPoint)); @@ -2417,10 +2425,10 @@ NLMISC_COMMAND(setBoundingBox, "Set the working bounding box", " getPrimVector()->y; string s; prim->getPropertyByName("radius", s); - r = float(atof(s.c_str())); + NLMISC::fromString(s, r); vector *params = &EmptyStringVector; prim->getPropertyByName("properties", params); @@ -2361,7 +2361,7 @@ static void parsePrimDynNpcZonePlace(const CAIAliasDescriptionNode *aliasNode, c y = prim->getPrimVector()->y; string s; prim->getPropertyByName("radius", s); - r = float(atof(s.c_str())); + NLMISC::fromString(s, r); vector *params=&EmptyStringVector; prim->getPropertyByName("properties", params); @@ -2425,19 +2425,19 @@ static void parsePrimRoadTrigger(const CAIAliasDescriptionNode *aliasNode, const { t1 = *child->getPrimVector(); child->getPropertyByName("radius", s); - t1r = float(atof(s.c_str())); + NLMISC::fromString(s, t1r); } else if (nodeName(child) == "trigger 2") { t2 = *child->getPrimVector(); child->getPropertyByName("radius", s); - t2r = float(atof(s.c_str())); + NLMISC::fromString(s, t2r); } else if (nodeName(child) == "spawn") { sp = *child->getPrimVector(); child->getPropertyByName("radius", s); - spr = float(atof(s.c_str())); + NLMISC::fromString(s, spr); } } } @@ -2468,7 +2468,8 @@ static void parsePrimDynRoad(const CAIAliasDescriptionNode *aliasNode, const IPr // road dificulty string s; prim->getPropertyByName("difficulty", s); - float difficulty = float(atof(s.c_str())); + float difficulty; + NLMISC::fromString(s, difficulty); uint32 verticalPos; parseVerticalPos(prim, verticalPos); @@ -3169,7 +3170,7 @@ static void parsePrimOutpostSpawnZone(const CAIAliasDescriptionNode *aliasNode, y = prim->getPrimVector()->y; string s; prim->getPropertyByName("radius", s); - r = float(atof(s.c_str())); + NLMISC::fromString(s, r); uint32 verticalPos; parseVerticalPos(prim, verticalPos); @@ -3428,7 +3429,8 @@ static void parsePrimSafeZone(const IPrimitive *prim, const std::string &mapName float y=(float)(prim->getPrimVector()->y); string radiusString; prim->getPropertyByName("radius",radiusString); - float radius=(float)atof(radiusString.c_str()); + float radius; + NLMISC::fromString(radiusString, radius); CAIActions::exec("SAFEZONE", x, y, radius); }