Changed: #142 Replace atoi and sscanf by fromString when it's possible

This commit is contained in:
kervala 2011-06-04 13:25:58 +02:00
parent dc66068f94
commit 787fffd092
5 changed files with 26 additions and 14 deletions

View file

@ -1271,7 +1271,10 @@ NLMISC_COMMAND(outpostSpawnSquad, "Spawns a squad in an outpost", "<instance_num
string zoneName = args[5];
uint32 respawnTimeGC = 5*60*10;
if ( args.size() > 6 )
respawnTimeGC = atoi( args[6].c_str() ) * 10;
{
NLMISC::fromString(args[6], respawnTimeGC);
respawnTimeGC *= 10;
}
for (size_t i=0; i<5; ++i)
if (args[i]=="")

View file

@ -237,7 +237,9 @@ public:
if (params.size()!=2)
throw ReadFightActionException("EVERY_SEC Needs 2 Params: <time in seconds>,<ScriptComp>");
int time=atoi(params[0].c_str())*10;
sint time;
NLMISC::fromString(params[0], time);
time *= 10;
CSmartPtr<CFightScriptComp> scriptComp;
try
@ -653,7 +655,9 @@ public:
if (strings.size()!=1)
throw ReadFightActionException("AGGRO_BLOCK Needs 1 param");
uint32 time=atoi(strings[0].c_str())*10;
uint32 time;
NLMISC::fromString(strings[0], time);
time *= 10;
return new CFightAggroBlock(time);
}

View file

@ -1419,7 +1419,10 @@ NLMISC_COMMAND(spireSpawnSquad, "Spawns a squad in an spire", "<instance_number>
string zoneName = args[5];
uint32 respawnTimeGC = 5*60*10;
if ( args.size() > 6 )
respawnTimeGC = atoi( args[6].c_str() ) * 10;
{
NLMISC::fromString(args[6], respawnTimeGC);
respawnTimeGC *= 10;
}
for (size_t i=0; i<5; ++i)
if (args[i]=="")

View file

@ -614,10 +614,10 @@ public:
switch (args.size())
{
case 2: _min=atoi(args[0].c_str()); if (args[0]!=NLMISC::toString(_min)) goto BadArgs;
_max=atoi(args[1].c_str()); if (args[1]!=NLMISC::toString(_max)) goto BadArgs;
case 2: NLMISC::fromString(args[0], _min); if (args[0]!=NLMISC::toString(_min)) goto BadArgs;
NLMISC::fromString(args[1], _max); if (args[1]!=NLMISC::toString(_max)) goto BadArgs;
break;
case 1: _min=atoi(args[0].c_str()); if (args[0]!=NLMISC::toString(_min)) goto BadArgs;
case 1: NLMISC::fromString(args[0], _min); if (args[0]!=NLMISC::toString(_min)) goto BadArgs;
_max=_min;
break;
default:
@ -759,10 +759,10 @@ public:
_Mode = tm_timer;
switch (args.size())
{
case 2: _Min=atoi(args[0].c_str()); if (args[0]!=NLMISC::toString(_Min)) goto BadArgs;
_Max=atoi(args[1].c_str()); if (args[1]!=NLMISC::toString(_Max)) goto BadArgs;
case 2: NLMISC::fromString(args[0], _Min); if (args[0]!=NLMISC::toString(_Min)) goto BadArgs;
NLMISC::fromString(args[1], _Max); if (args[1]!=NLMISC::toString(_Max)) goto BadArgs;
break;
case 1: _Min=atoi(args[0].c_str()); if (args[0]!=NLMISC::toString(_Min)) goto BadArgs;
case 1: NLMISC::fromString(args[0], _Min); if (args[0]!=NLMISC::toString(_Min)) goto BadArgs;
_Max=_Min;
break;
default:
@ -2945,9 +2945,9 @@ public:
if(cstring=="DSS_")
{
_Id=true;
NLMISC::CSString tmp = NLMISC::CSString (_Sentence).right((unsigned int)_Sentence.length()-4);
NLMISC::CSString tmp = NLMISC::CSString (_Sentence).right((uint)_Sentence.length()-4);
NLMISC::CSString tmp2 = tmp.strtok(" ",false,false,false,false);
_ScenarioId = atoi(tmp2.c_str());
_ScenarioId = tmp2.atoui();
_Sentence = tmp;
nlwarning("<npc_say> scenario id : %d string id : %s ",_ScenarioId,_Sentence.c_str());
}

View file

@ -51,7 +51,8 @@ void CCDBStructNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &progr
// IF type is an INT with n bits [1,64].
if ((type.getDatas()[0] == 'I') || (type.getDatas()[0] == 'U'))
{
uint nbBit = atoi(type.getDatas() + 1);
uint nbBit;
NLMISC::fromString(type.getDatas() + 1, nbBit);
if(nbBit>=1 && nbBit<=64)
_Type=(ICDBStructNode::EPropType)nbBit;
else
@ -62,7 +63,8 @@ void CCDBStructNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &progr
}
else if (type.getDatas()[0] == 'S')
{
uint nbBit = atoi(type.getDatas() + 1);
uint nbBit;
NLMISC::fromString(type.getDatas() + 1, nbBit);
if(nbBit>=1 && nbBit<=64)
_Type = (ICDBStructNode::EPropType)nbBit; // all is I on the server (unlike the client)
else