Changed: Replaced atoi and atof by NLMISC::fromString
This commit is contained in:
parent
0193bd948c
commit
713dcf97ee
21 changed files with 116 additions and 65 deletions
|
@ -44,19 +44,19 @@ NLMISC_COMMAND(setWaterPool, "Setup a pool of water in the water pool manager",
|
|||
}
|
||||
if (numArgs == 3)
|
||||
{
|
||||
whmb.FilterWeight = ::atof(args[2].c_str());
|
||||
NLMISC::fromString(args[2], whmb.FilterWeight);
|
||||
}
|
||||
if (numArgs == 4)
|
||||
{
|
||||
whmb.UnitSize = ::atof(args[3].c_str());
|
||||
NLMISC::fromString(args[3], whmb.UnitSize);
|
||||
}
|
||||
if (numArgs == 5)
|
||||
{
|
||||
whmb.WaveIntensity = ::atof(args[4].c_str());
|
||||
NLMISC::fromString(args[4], whmb.WaveIntensity);
|
||||
}
|
||||
if (numArgs == 4)
|
||||
{
|
||||
whmb.WavePeriod = ::atof(args[5].c_str());
|
||||
NLMISC::fromString(args[5], whmb.WavePeriod);
|
||||
}
|
||||
// create the water pool
|
||||
GetWaterPoolManager().createWaterPool(whmb);
|
||||
|
|
|
@ -1731,7 +1731,9 @@ namespace NLMISC
|
|||
|
||||
double CSString::atof() const
|
||||
{
|
||||
return ::atof(c_str());
|
||||
double val;
|
||||
NLMISC::fromString(*this, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
bool CSString::readFromFile(const CSString& fileName)
|
||||
|
|
|
@ -176,7 +176,10 @@ void CSoundAnimation::load()
|
|||
throw NLMISC::Exception("Invalid sound animation marker");
|
||||
}
|
||||
|
||||
marker->setTime((float) atof(time));
|
||||
float val;
|
||||
NLMISC::fromString(time, val);
|
||||
|
||||
marker->setTime(val);
|
||||
xmlFree ((void*)time);
|
||||
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ retry:
|
|||
|
||||
// now the user is on the database
|
||||
|
||||
uid = atoi(row[0]);
|
||||
NLMISC::fromString(row[0], uid);
|
||||
|
||||
if(cpassword != row[2])
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ BOOL CConfiguration::Load()
|
|||
|
||||
// Reading the configuration file version
|
||||
GetValue(csBuffer, KEY_VERSION, csValue);
|
||||
m_dVersion = atof(csValue);
|
||||
NLMISC::fromString(csValue, m_dVersion);
|
||||
nlinfo("Config' version %s", csValue);
|
||||
|
||||
if(m_dVersion < APP.m_dVersion)
|
||||
|
|
|
@ -324,7 +324,7 @@ void CNel_launcherApp::LoadVersion()
|
|||
else
|
||||
{
|
||||
nlinfo("Launcher' version %s", csVersion);
|
||||
m_dVersion = atof(csVersion);
|
||||
NLMISC::fromString(csVersion, m_dVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,10 @@ void cbNotesChanged()
|
|||
Notes.Notes.clear();
|
||||
return;
|
||||
}
|
||||
pos.x = (float)atof(posstr[0].c_str());
|
||||
pos.y = (float)atof(posstr[1].c_str());
|
||||
pos.z = (float)atof(posstr[2].c_str());
|
||||
|
||||
NLMISC::fromString(posstr[0], pos.x);
|
||||
NLMISC::fromString(posstr[1], pos.y);
|
||||
NLMISC::fromString(posstr[2], pos.z);
|
||||
|
||||
string note(var.asString(i+2));
|
||||
if(note.empty())
|
||||
|
|
|
@ -37,7 +37,11 @@ float getFloat()
|
|||
char delimiter[] = "[] \t";
|
||||
char *ptr = strtok(NULL, delimiter);
|
||||
if(ptr != NULL)
|
||||
return (float) atof(ptr);
|
||||
{
|
||||
float val;
|
||||
NLMISC::fromString(ptr, val);
|
||||
return val;
|
||||
}
|
||||
return 0.f;
|
||||
}// getFloat //
|
||||
|
||||
|
@ -94,7 +98,7 @@ std::vector<float> getVectorOfFloat(uint8 nbCol)
|
|||
ptr = strtok(NULL, delimiter);
|
||||
if(ptr != NULL)
|
||||
{
|
||||
val = (float)atof(ptr);
|
||||
NLMISC::fromString(ptr, val);
|
||||
if (val != 0.0f)
|
||||
vect.push_back(val);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ void CSceneParser::load(const string &filename)
|
|||
|
||||
char *ptr = strtok(tmpBuff, delimiter);
|
||||
if(ptr != NULL)
|
||||
_FrameRate = atof(ptr);
|
||||
NLMISC::fromString(ptr, _FrameRate);
|
||||
}
|
||||
|
||||
// Close the speed file.
|
||||
|
@ -1693,7 +1693,7 @@ void CSceneParser::loadScene(const string &filename)
|
|||
ptr = strtok(NULL, delimiter);
|
||||
if(ptr != NULL)
|
||||
{
|
||||
seq.second = atof(ptr);
|
||||
NLMISC::fromString(ptr, seq.second);
|
||||
_Scene.push_back(seq);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -479,10 +479,9 @@ void CStaticFames::loadStaticFame( const string& filename )
|
|||
else
|
||||
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;
|
||||
float fameFloat;
|
||||
NLMISC::fromString(s.substr(0, sep), fameFloat);
|
||||
fame = (sint32)(fameFloat * 1000.f);
|
||||
sint32 fame = (sint32)(fameFloat * 1000.f);
|
||||
|
||||
_FameTable[iFaction*_FameTableSize + jFaction] = fame;
|
||||
_PropagationFactorTable[iFaction*_FameTableSize + jFaction] = factor;
|
||||
|
|
|
@ -706,7 +706,12 @@ inline float CPersistentDataRecord::CArg::asFloat() const
|
|||
case UINT64: return (float)(uint64)_Value.i64;
|
||||
case FLOAT32: return (float)_Value.f32;
|
||||
case FLOAT64: return (float)_Value.f64;
|
||||
case STRING: return (float)atof(_String.c_str());
|
||||
case STRING:
|
||||
{
|
||||
float val;
|
||||
NLMISC::fromString(_String, val);
|
||||
return val;
|
||||
}
|
||||
case FLAG: return 1.0f;
|
||||
case EXTEND_TYPE:
|
||||
switch(_Value.ExType)
|
||||
|
@ -733,7 +738,12 @@ inline double CPersistentDataRecord::CArg::asDouble() const
|
|||
case UINT64: return (double)(uint64)_Value.i64;
|
||||
case FLOAT32: return (double)_Value.f32;
|
||||
case FLOAT64: return (double)_Value.f64;
|
||||
case STRING: return (double)atof(_String.c_str());
|
||||
case STRING:
|
||||
{
|
||||
double val;
|
||||
NLMISC::fromString(_String, val);
|
||||
return val;
|
||||
}
|
||||
case FLAG: return 1.0;
|
||||
case EXTEND_TYPE:
|
||||
switch(_Value.ExType)
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace ADMIN
|
|||
gs.HighRezTimeStamp = timer;
|
||||
IVariable *var = dynamic_cast<IVariable*>(ICommand::getCommand(gvi.VarName));
|
||||
if (var != NULL)
|
||||
gs.SampleValue = atof(var->toString().c_str());
|
||||
NLMISC::fromString(var->toString(), gs.SampleValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +305,11 @@ namespace ADMIN
|
|||
// no sample collected yet, just ask a new one
|
||||
IVariable *var = dynamic_cast<IVariable*>(ICommand::getCommand(gvi.VarName));
|
||||
if (var != NULL)
|
||||
gd.setValue(atof(var->toString().c_str()));
|
||||
{
|
||||
float val;
|
||||
NLMISC::fromString(var->toString(), val);
|
||||
gd.setValue(val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -586,7 +586,10 @@ NLMISC_COMMAND(actorSetOrientation,"Add one or more static actors","<direction>
|
|||
if (i<(sizeof(angleNames)/sizeof(angleNames[0])))
|
||||
theta=3.14159265359f*2.0f*(float)i/(float)(sizeof(angleNames)/sizeof(angleNames[0]));
|
||||
else
|
||||
theta=(float)atof(args[0].c_str())/360.0f*2.0f*3.14159265359f;
|
||||
{
|
||||
NLMISC::fromString(args[0], theta);
|
||||
theta = theta / 360.0f*2.0f*3.14159265359f;
|
||||
}
|
||||
|
||||
if (args.size()==1)
|
||||
{
|
||||
|
@ -620,11 +623,13 @@ NLMISC_COMMAND(actorSetMagnetRange,"Set the magnet properties for wandering beha
|
|||
if(args.size() <1) return false;
|
||||
COMMAND_MACRO_RECORD_TEST
|
||||
|
||||
float range=(float)atof(args[0].c_str());
|
||||
float range;
|
||||
NLMISC::fromString(args[0], range);
|
||||
if (range<=0.0f) return false;
|
||||
|
||||
unsigned start;
|
||||
float decay=(float)atof(args[0].c_str());
|
||||
float decay;
|
||||
NLMISC::fromString(args[0], decay);
|
||||
if (decay<0.0f) return false;
|
||||
if (decay==0.0f)
|
||||
{
|
||||
|
@ -664,7 +669,8 @@ NLMISC_COMMAND(actorSetAttackDistance,"set actor attack distance","<distance> [<
|
|||
if(args.size() <1) return false;
|
||||
COMMAND_MACRO_RECORD_TEST
|
||||
|
||||
float distance=(float)atof(args[0].c_str());
|
||||
float distance;
|
||||
NLMISC::fromString(args[0], distance);
|
||||
// if (distance<=0.0f) return false;
|
||||
|
||||
if (args.size()<2)
|
||||
|
@ -781,11 +787,13 @@ NLMISC_COMMAND(actorSetRespawnDelay,"set actor respawn delay","<min time> [<max
|
|||
if(args.size() <1) return false;
|
||||
COMMAND_MACRO_RECORD_TEST
|
||||
|
||||
float min=(float)atof(args[0].c_str());
|
||||
float min;
|
||||
NLMISC::fromString(args[0], min);
|
||||
if (min<=0.0f) return false;
|
||||
|
||||
unsigned start;
|
||||
float max=(float)atof(args[0].c_str());
|
||||
float max;
|
||||
NLMISC::fromString(args[0], max);
|
||||
if (max==0.0f)
|
||||
{
|
||||
max=min;
|
||||
|
@ -1144,10 +1152,14 @@ NLMISC_COMMAND(generateScript, "Generate a sript that spawn a given type of crea
|
|||
return false;
|
||||
|
||||
const string &scriptName = args[0];
|
||||
double spawnX = atof(args[1].c_str());
|
||||
double spawnY = atof(args[2].c_str());
|
||||
double spacing = atof(args[3].c_str());
|
||||
uint width = atoi(args[4].c_str());
|
||||
double spawnX;
|
||||
NLMISC::fromString(args[1], spawnX);
|
||||
double spawnY;
|
||||
NLMISC::fromString(args[2], spawnY);
|
||||
double spacing;
|
||||
NLMISC::fromString(args[3], spacing);
|
||||
uint width;
|
||||
NLMISC::fromString(args[4], width);
|
||||
const string &extension = args[5];
|
||||
vector<string> filters;
|
||||
|
||||
|
|
|
@ -2465,9 +2465,17 @@ NLMISC_COMMAND(setDefaultStart,"Set the default start point for all continents",
|
|||
|
||||
CVectorD startPoint;
|
||||
|
||||
startPoint.x = atof(args[0].c_str());
|
||||
startPoint.y = atof(args[1].c_str());
|
||||
startPoint.z = (args.size() < 3 ? 0.0 : atof(args[2].c_str()));
|
||||
NLMISC::fromString(args[0], startPoint.x);
|
||||
NLMISC::fromString(args[1], startPoint.y);
|
||||
|
||||
if (args.size() > 2)
|
||||
{
|
||||
NLMISC::fromString(args[2], startPoint.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
startPoint.z = 0.0;
|
||||
}
|
||||
|
||||
DefaultStartPoint = startPoint;
|
||||
|
||||
|
@ -2921,13 +2929,15 @@ NLMISC_COMMAND(testPacsMove, "test a pacs move", "<continent> <x> <y> <dx> <dy>"
|
|||
if (args.size() != 5)
|
||||
return false;
|
||||
|
||||
CPacsCruncher pc;
|
||||
CPacsCruncher pc;
|
||||
|
||||
string name = args[0];
|
||||
double x = atof(args[1].c_str());
|
||||
double y = atof(args[2].c_str());
|
||||
double dx = atof(args[3].c_str());
|
||||
double dy = atof(args[4].c_str());
|
||||
string name = args[0];
|
||||
|
||||
double x, y, dx, dy;
|
||||
NLMISC::fromString(args[1], x);
|
||||
NLMISC::fromString(args[2], y);
|
||||
NLMISC::fromString(args[3], dx);
|
||||
NLMISC::fromString(args[4], dy);
|
||||
|
||||
pc.init(name);
|
||||
|
||||
|
|
|
@ -229,8 +229,9 @@ NLMISC_COMMAND(eventCreateNpcGroup, "create an event npc group", "<aiInstanceId>
|
|||
return true;
|
||||
}
|
||||
|
||||
double x = atof(args[3].c_str());
|
||||
double y = atof(args[4].c_str());
|
||||
double x, y;
|
||||
NLMISC::fromString(args[3], x);
|
||||
NLMISC::fromString(args[4], y);
|
||||
|
||||
double dispersionRadius = 10.;
|
||||
if (args.size()>5)
|
||||
|
@ -1970,8 +1971,8 @@ NLMISC_COMMAND(displayVision3x3,"display 3x3 cell vision centred on a given coor
|
|||
}
|
||||
|
||||
CAICoord x, y;
|
||||
x=atof(args[1].c_str());
|
||||
y=atof(args[2].c_str());
|
||||
NLMISC::fromString(args[1], x);
|
||||
NLMISC::fromString(args[2], y);
|
||||
log.displayNL("3x3 Vision around (%.3f,%.3f)", x.asDouble(), y.asDouble());
|
||||
|
||||
uint32 botCount=0;
|
||||
|
|
|
@ -1412,8 +1412,7 @@ public:
|
|||
if ((str[0]<='9' && str[0]>='0')||(str[0]=='-')) // its a number
|
||||
{
|
||||
var.Type = constant;
|
||||
double val = atof(str.c_str());
|
||||
var.Value = float(val);
|
||||
NLMISC::fromString(str, var.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1058,8 +1058,9 @@ NLMISC_COMMAND(getEffects, "get effects of a spire","<x> <y>" )
|
|||
return false;
|
||||
else
|
||||
{
|
||||
float x = (float)atof(args[0].c_str());
|
||||
float y = (float)atof(args[1].c_str());
|
||||
float x, y;
|
||||
NLMISC::fromString(args[0], x);
|
||||
NLMISC::fromString(args[1], y);
|
||||
|
||||
NLMISC::CVector vec( x, y, 0.0f );
|
||||
|
||||
|
@ -1101,8 +1102,9 @@ NLMISC_COMMAND(buildSpirePos, "build a spire","<Eid> <x> <y>")
|
|||
return true;
|
||||
}
|
||||
|
||||
float x = (float)atof(args[1].c_str());
|
||||
float y = (float)atof(args[2].c_str());
|
||||
float x, y;
|
||||
NLMISC::fromString(args[1], x);
|
||||
NLMISC::fromString(args[2], y);
|
||||
|
||||
NLMISC::CVector vec( x, y, 0.0f );
|
||||
|
||||
|
@ -1138,8 +1140,9 @@ NLMISC_COMMAND(destroySpirePos, "destroy a spire","<x> <y>")
|
|||
return false;
|
||||
else
|
||||
{
|
||||
float x = (float)atof(args[0].c_str());
|
||||
float y = (float)atof(args[1].c_str());
|
||||
float x, y;
|
||||
NLMISC::fromString(args[0], x);
|
||||
NLMISC::fromString(args[1], y);
|
||||
|
||||
NLMISC::CVector vec( x, y, 0.0f );
|
||||
|
||||
|
@ -1178,8 +1181,9 @@ NLMISC_COMMAND(getEffectsPos, "get effects of a spire","<Eid> <x> <y>" )
|
|||
return true;
|
||||
}
|
||||
|
||||
float x = (float)atof(args[1].c_str());
|
||||
float y = (float)atof(args[2].c_str());
|
||||
float x, y;
|
||||
NLMISC::fromString(args[1], x);
|
||||
NLMISC::fromString(args[2], y);
|
||||
|
||||
NLMISC::CVector vec( x, y, 0.0f );
|
||||
|
||||
|
@ -1265,8 +1269,9 @@ NLMISC_COMMAND(getRegionOwner, "display the faction which currently owns the reg
|
|||
return false;
|
||||
else
|
||||
{
|
||||
float x = (float)atof(args[0].c_str());
|
||||
float y = (float)atof(args[1].c_str());
|
||||
float x, y;
|
||||
NLMISC::fromString(args[0], x);
|
||||
NLMISC::fromString(args[1], y);
|
||||
|
||||
NLMISC::CVector vec( x, y, 0.0f );
|
||||
|
||||
|
@ -1294,8 +1299,9 @@ NLMISC_COMMAND(getSpireStats, "display the status of spire in region correspondi
|
|||
return false;
|
||||
else
|
||||
{
|
||||
float x = (float)atof(args[0].c_str());
|
||||
float y = (float)atof(args[1].c_str());
|
||||
float x, y;
|
||||
NLMISC::fromString(args[0], x);
|
||||
NLMISC::fromString(args[1], y);
|
||||
|
||||
NLMISC::CVector vec( x, y, 0.0f );
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@ NLMISC_COMMAND(getPatatEntryIndex, "Get the patat entry index at a pos", "x, y")
|
|||
|
||||
CVector pos;
|
||||
|
||||
pos.x = (float)atof(args[0].c_str());
|
||||
pos.y = (float)atof(args[1].c_str());
|
||||
NLMISC::fromString(args[0], pos.x);
|
||||
NLMISC::fromString(args[1], pos.y);
|
||||
pos.z = 0;
|
||||
|
||||
nlinfo("entryIndex(%.1f, %.1f) = %d", pos.x, pos.y, CWorldPositionManager::getEntryIndex(pos));
|
||||
|
|
|
@ -203,7 +203,7 @@ void CTypeUnitDouble::SetLowLimit( const CStringEx _sxll )
|
|||
void CTypeUnitDouble::SetHighLimit( const CStringEx _sxhl )
|
||||
{
|
||||
sxhighlimit = _sxhl;
|
||||
dhighlimit = atof( sxhighlimit.c_str() );
|
||||
NLMISC::fromString(sxhighlimit, dhighlimit);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -629,7 +629,7 @@ void addPointPrimitive (CLandscape &landscape, const char *primFilename, uint32
|
|||
string scaleText;
|
||||
float scale = 1;
|
||||
if (point->getPropertyByName ("scale", scaleText))
|
||||
scale = (float) atof (scaleText.c_str ());
|
||||
NLMISC::fromString(scaleText, scale);
|
||||
|
||||
// Get zone coordinates
|
||||
sint x = (sint)floor (position.x / options.CellSize);
|
||||
|
@ -654,7 +654,7 @@ void addPointPrimitive (CLandscape &landscape, const char *primFilename, uint32
|
|||
|
||||
// Get height
|
||||
if (!snap && point->getPropertyByName ("height", text))
|
||||
position.z = (float)atof(text.c_str());
|
||||
NLMISC::fromString(text, position.z);
|
||||
|
||||
// *** Add the instance
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void CAnimCombatState::build(const string &line)
|
|||
{
|
||||
StateCode= line.substr(4, 2);
|
||||
string time= line.substr(10, 5);
|
||||
MeanAnimTime= (float)atof(time.c_str());
|
||||
NLMISC::fromString(time, MeanAnimTime);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue