From 615e7c80b9f1ae91c64654a022ecc50379ea4136 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Jun 2016 16:54:10 +0200 Subject: [PATCH] Changed: Replace atof by fromString --- code/ryzom/server/src/ai_service/ai_generic_fight.cpp | 4 ++-- code/ryzom/server/src/ai_service/continent_actions.cpp | 6 +++--- code/ryzom/server/src/ai_service/generic_logic_action.cpp | 3 ++- code/ryzom/server/src/ai_service/script_compiler.cpp | 6 ++++-- code/ryzom/server/src/ai_service/script_parser.lex | 3 ++- code/ryzom/server/src/ai_service/script_parser_lex.cpp | 3 ++- code/ryzom/server/src/ai_service/script_vm.cpp | 6 +++--- code/ryzom/server/src/ai_service/sheets.cpp | 3 ++- 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_generic_fight.cpp b/code/ryzom/server/src/ai_service/ai_generic_fight.cpp index fb8235063..c88a93b8f 100644 --- a/code/ryzom/server/src/ai_service/ai_generic_fight.cpp +++ b/code/ryzom/server/src/ai_service/ai_generic_fight.cpp @@ -137,8 +137,8 @@ NLMISC_COMMAND(fightDefaultRange, "Generic default fight range","") { if (args.size()==2) { - CBotProfileFightHeal::fightDefaultMinRange = (float)atof(args[0].c_str()); - CBotProfileFightHeal::fightDefaultMaxRange = (float)atof(args[1].c_str()); + NLMISC::fromString(args[0], CBotProfileFightHeal::fightDefaultMinRange); + NLMISC::fromString(args[1], CBotProfileFightHeal::fightDefaultMaxRange); } log.displayNL("Generic default fight range is [%f;%f]", CBotProfileFightHeal::fightDefaultMinRange, CBotProfileFightHeal::fightDefaultMaxRange); return true; diff --git a/code/ryzom/server/src/ai_service/continent_actions.cpp b/code/ryzom/server/src/ai_service/continent_actions.cpp index aaabf9b98..18780b3f5 100644 --- a/code/ryzom/server/src/ai_service/continent_actions.cpp +++ b/code/ryzom/server/src/ai_service/continent_actions.cpp @@ -219,7 +219,7 @@ DEFINE_ACTION(ContextRegion,CELLZNE) // if (args[i+1].get(str)) // { // if (!str.empty()) -// value=atof(str.c_str()); +// NLMISC::fromString(str, value); // } // levelEnergy.setLevelEnergyValue(value, i); // } @@ -241,7 +241,7 @@ DEFINE_ACTION(ContextGroupFamily,CZ_NRJ) if (args[i].get(str)) { if (!str.empty()) - value=atof(str.c_str()); + NLMISC::fromString(str, value); } groupFamily->setLevelEnergyValue(value, i); } @@ -268,7 +268,7 @@ DEFINE_ACTION(ContextGroupFamily,CZ_NRJ) // if (args[i+1].get(str)) // { // if (!str.empty()) -// value=atof(str.c_str()); +// NLMISC::fromString(str, value); // } // levelEnergy.setLevelEnergyValue(value, i); // } diff --git a/code/ryzom/server/src/ai_service/generic_logic_action.cpp b/code/ryzom/server/src/ai_service/generic_logic_action.cpp index 0b0e254b7..a7c01d5ef 100644 --- a/code/ryzom/server/src/ai_service/generic_logic_action.cpp +++ b/code/ryzom/server/src/ai_service/generic_logic_action.cpp @@ -1438,7 +1438,8 @@ public: // try to parse a constant value // var.Type = constant; -// double val = atof(str.c_str()); +// double val; +// NLMISC::fromString(str, val); // var.Value = float(val); // return true; } diff --git a/code/ryzom/server/src/ai_service/script_compiler.cpp b/code/ryzom/server/src/ai_service/script_compiler.cpp index 7fb49008f..8e28d0c9f 100644 --- a/code/ryzom/server/src/ai_service/script_compiler.cpp +++ b/code/ryzom/server/src/ai_service/script_compiler.cpp @@ -1488,7 +1488,8 @@ CCaseTracer::CCaseTracer(const CSmartPtr &tracer, const string & if (valChldTracer=chldTracer->getChildForName(s_kw_NUMBER)) { const string &strRef=valChldTracer->_TextValue; - const float f=(float)atof(strRef.c_str()); + float f; + NLMISC::fromString(strRef, f); _sortValue=*((size_t*)&f); break; } @@ -1954,7 +1955,8 @@ void CSubRuleTracer::generateCode(CSmartPtr &cByteCode) const NLMISC::fromString(param, index); --index; string &strRef=_childTracers[index]->_TextValue; - const float f=(float)atof(strRef.c_str()); + float f; + NLMISC::fromString(strRef, f); byteCode.push_back(*((size_t*)&f)); jumpTable.newCodeBlock(); break; diff --git a/code/ryzom/server/src/ai_service/script_parser.lex b/code/ryzom/server/src/ai_service/script_parser.lex index ccddc5a62..d5c4128a8 100644 --- a/code/ryzom/server/src/ai_service/script_parser.lex +++ b/code/ryzom/server/src/ai_service/script_parser.lex @@ -118,7 +118,8 @@ onchildren { return TOKEN_ONCHILDREN; } {double} { - const float f=(float)atof(yytext); + float f; + NLMISC::fromString(yytext, f); INIT(*((size_t*)&f)); return TOKEN_NUMBER; } diff --git a/code/ryzom/server/src/ai_service/script_parser_lex.cpp b/code/ryzom/server/src/ai_service/script_parser_lex.cpp index fcd16d8b9..cacd9ab78 100644 --- a/code/ryzom/server/src/ai_service/script_parser_lex.cpp +++ b/code/ryzom/server/src/ai_service/script_parser_lex.cpp @@ -4473,7 +4473,8 @@ case 23: YY_RULE_SETUP #line 120 "ai_service/script_parser.lex" { - const float f=(float)atof(yytext); + float f; + NLMISC::fromString(yytext, f); INIT(*((size_t*)&f)); return TOKEN_NUMBER; } diff --git a/code/ryzom/server/src/ai_service/script_vm.cpp b/code/ryzom/server/src/ai_service/script_vm.cpp index 14d0fc933..243110520 100644 --- a/code/ryzom/server/src/ai_service/script_vm.cpp +++ b/code/ryzom/server/src/ai_service/script_vm.cpp @@ -304,7 +304,7 @@ void CScriptVM::interpretCode( case CScriptStack::EString: { string &str=stack.top(); - f=(float)atof(str.c_str()); + NLMISC::fromString(str, f); } break; case CScriptStack::EFloat: @@ -406,7 +406,7 @@ void CScriptVM::interpretCode( case CScriptStack::EString: { string& str = stack.top(); - f = (float)atof(str.c_str()); + NLMISC::fromString(str, f); } break; case CScriptStack::EFloat: @@ -601,7 +601,7 @@ void CScriptVM::interpretCode( case CScriptStack::EString: { string& str = stack.top(); - f = (float)atof(str.c_str()); + NLMISC::fromString(str, f); } break; case CScriptStack::EFloat: diff --git a/code/ryzom/server/src/ai_service/sheets.cpp b/code/ryzom/server/src/ai_service/sheets.cpp index 57b26f4d2..24a56328e 100644 --- a/code/ryzom/server/src/ai_service/sheets.cpp +++ b/code/ryzom/server/src/ai_service/sheets.cpp @@ -1122,7 +1122,8 @@ NLMISC_COMMAND(setSheetProperty,"change a value read from a sheet"," leve } // get the value - float val = (float)atof(args[2].c_str()); + float val; + NLMISC::fromString(args[2], val); if (val==0 && args[2]!="0" && args[2]!="0.0") { log.displayNL("'%s' is not a valid value",args[2].c_str());