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

hg/feature/sound
kervala 14 years ago
parent 8350856a05
commit 2a3e170bee

@ -1271,7 +1271,10 @@ NLMISC_COMMAND(outpostSpawnSquad, "Spawns a squad in an outpost", "<instance_num
string zoneName = args[5]; string zoneName = args[5];
uint32 respawnTimeGC = 5*60*10; uint32 respawnTimeGC = 5*60*10;
if ( args.size() > 6 ) 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) for (size_t i=0; i<5; ++i)
if (args[i]=="") if (args[i]=="")

@ -237,7 +237,9 @@ public:
if (params.size()!=2) if (params.size()!=2)
throw ReadFightActionException("EVERY_SEC Needs 2 Params: <time in seconds>,<ScriptComp>"); 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; CSmartPtr<CFightScriptComp> scriptComp;
try try
@ -653,7 +655,9 @@ public:
if (strings.size()!=1) if (strings.size()!=1)
throw ReadFightActionException("AGGRO_BLOCK Needs 1 param"); 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); return new CFightAggroBlock(time);
} }

@ -1419,7 +1419,10 @@ NLMISC_COMMAND(spireSpawnSquad, "Spawns a squad in an spire", "<instance_number>
string zoneName = args[5]; string zoneName = args[5];
uint32 respawnTimeGC = 5*60*10; uint32 respawnTimeGC = 5*60*10;
if ( args.size() > 6 ) 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) for (size_t i=0; i<5; ++i)
if (args[i]=="") if (args[i]=="")

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

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

Loading…
Cancel
Save