Changed: Replace atof by fromString

--HG--
branch : develop
This commit is contained in:
kervala 2016-06-11 16:54:10 +02:00
parent 4a2fe97f95
commit 9609ac7de2
8 changed files with 20 additions and 14 deletions

View file

@ -137,8 +137,8 @@ NLMISC_COMMAND(fightDefaultRange, "Generic default fight range","")
{ {
if (args.size()==2) if (args.size()==2)
{ {
CBotProfileFightHeal::fightDefaultMinRange = (float)atof(args[0].c_str()); NLMISC::fromString(args[0], CBotProfileFightHeal::fightDefaultMinRange);
CBotProfileFightHeal::fightDefaultMaxRange = (float)atof(args[1].c_str()); NLMISC::fromString(args[1], CBotProfileFightHeal::fightDefaultMaxRange);
} }
log.displayNL("Generic default fight range is [%f;%f]", CBotProfileFightHeal::fightDefaultMinRange, CBotProfileFightHeal::fightDefaultMaxRange); log.displayNL("Generic default fight range is [%f;%f]", CBotProfileFightHeal::fightDefaultMinRange, CBotProfileFightHeal::fightDefaultMaxRange);
return true; return true;

View file

@ -219,7 +219,7 @@ DEFINE_ACTION(ContextRegion,CELLZNE)
// if (args[i+1].get(str)) // if (args[i+1].get(str))
// { // {
// if (!str.empty()) // if (!str.empty())
// value=atof(str.c_str()); // NLMISC::fromString(str, value);
// } // }
// levelEnergy.setLevelEnergyValue(value, i); // levelEnergy.setLevelEnergyValue(value, i);
// } // }
@ -241,7 +241,7 @@ DEFINE_ACTION(ContextGroupFamily,CZ_NRJ)
if (args[i].get(str)) if (args[i].get(str))
{ {
if (!str.empty()) if (!str.empty())
value=atof(str.c_str()); NLMISC::fromString(str, value);
} }
groupFamily->setLevelEnergyValue(value, i); groupFamily->setLevelEnergyValue(value, i);
} }
@ -268,7 +268,7 @@ DEFINE_ACTION(ContextGroupFamily,CZ_NRJ)
// if (args[i+1].get(str)) // if (args[i+1].get(str))
// { // {
// if (!str.empty()) // if (!str.empty())
// value=atof(str.c_str()); // NLMISC::fromString(str, value);
// } // }
// levelEnergy.setLevelEnergyValue(value, i); // levelEnergy.setLevelEnergyValue(value, i);
// } // }

View file

@ -1438,7 +1438,8 @@ public:
// try to parse a constant value // try to parse a constant value
// var.Type = constant; // var.Type = constant;
// double val = atof(str.c_str()); // double val;
// NLMISC::fromString(str, val);
// var.Value = float(val); // var.Value = float(val);
// return true; // return true;
} }

View file

@ -1488,7 +1488,8 @@ CCaseTracer::CCaseTracer(const CSmartPtr<CSubRuleTracer> &tracer, const string &
if (valChldTracer=chldTracer->getChildForName(s_kw_NUMBER)) if (valChldTracer=chldTracer->getChildForName(s_kw_NUMBER))
{ {
const string &strRef=valChldTracer->_TextValue; const string &strRef=valChldTracer->_TextValue;
const float f=(float)atof(strRef.c_str()); float f;
NLMISC::fromString(strRef, f);
_sortValue=*((size_t*)&f); _sortValue=*((size_t*)&f);
break; break;
} }
@ -1954,7 +1955,8 @@ void CSubRuleTracer::generateCode(CSmartPtr<AIVM::CByteCode> &cByteCode) const
NLMISC::fromString(param, index); NLMISC::fromString(param, index);
--index; --index;
string &strRef=_childTracers[index]->_TextValue; 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)); byteCode.push_back(*((size_t*)&f));
jumpTable.newCodeBlock(); jumpTable.newCodeBlock();
break; break;

View file

@ -118,7 +118,8 @@ onchildren { return TOKEN_ONCHILDREN; }
{double} { {double} {
const float f=(float)atof(yytext); float f;
NLMISC::fromString(yytext, f);
INIT(*((size_t*)&f)); INIT(*((size_t*)&f));
return TOKEN_NUMBER; return TOKEN_NUMBER;
} }

View file

@ -4473,7 +4473,8 @@ case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 120 "ai_service/script_parser.lex" #line 120 "ai_service/script_parser.lex"
{ {
const float f=(float)atof(yytext); float f;
NLMISC::fromString(yytext, f);
INIT(*((size_t*)&f)); INIT(*((size_t*)&f));
return TOKEN_NUMBER; return TOKEN_NUMBER;
} }

View file

@ -304,7 +304,7 @@ void CScriptVM::interpretCode(
case CScriptStack::EString: case CScriptStack::EString:
{ {
string &str=stack.top(); string &str=stack.top();
f=(float)atof(str.c_str()); NLMISC::fromString(str, f);
} }
break; break;
case CScriptStack::EFloat: case CScriptStack::EFloat:
@ -406,7 +406,7 @@ void CScriptVM::interpretCode(
case CScriptStack::EString: case CScriptStack::EString:
{ {
string& str = stack.top(); string& str = stack.top();
f = (float)atof(str.c_str()); NLMISC::fromString(str, f);
} }
break; break;
case CScriptStack::EFloat: case CScriptStack::EFloat:
@ -601,7 +601,7 @@ void CScriptVM::interpretCode(
case CScriptStack::EString: case CScriptStack::EString:
{ {
string& str = stack.top(); string& str = stack.top();
f = (float)atof(str.c_str()); NLMISC::fromString(str, f);
} }
break; break;
case CScriptStack::EFloat: case CScriptStack::EFloat:

View file

@ -1122,7 +1122,8 @@ NLMISC_COMMAND(setSheetProperty,"change a value read from a sheet","<sheet> leve
} }
// get the value // 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") if (val==0 && args[2]!="0" && args[2]!="0.0")
{ {
log.displayNL("'%s' is not a valid value",args[2].c_str()); log.displayNL("'%s' is not a valid value",args[2].c_str());