mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 09:19:01 +00:00
Changed: #142 Replace atoi and sscanf by fromString when it's possible
This commit is contained in:
parent
5574174db4
commit
7db03223fc
8 changed files with 36 additions and 15 deletions
|
@ -179,7 +179,9 @@ bool getZoneCoordByName(const char * name, uint16& x, uint16& y)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
y = -atoi(ystr.c_str());
|
||||
|
||||
NLMISC::fromString(ystr, y);
|
||||
y = -y;
|
||||
|
||||
// x
|
||||
x = 0;
|
||||
|
@ -223,7 +225,11 @@ sint getYFromZoneName (const string &ZoneName)
|
|||
{
|
||||
xStr += ZoneName[i]; ++i;
|
||||
}
|
||||
return -atoi(yStr.c_str());
|
||||
|
||||
sint y = 0;
|
||||
NLMISC::fromString(yStr, y);
|
||||
|
||||
return -y;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
|
|
@ -203,7 +203,7 @@ CParseNode *parse##nodename(CTokenizer &tokenizer) \
|
|||
{ \
|
||||
if (tokenizer.end() || tokenizer.current() != TokenNumber) \
|
||||
PARSE_FAIL \
|
||||
main->savein = atoi(tokenizer.get(tokenizer.currentToken()).c_str()); \
|
||||
NLMISC::fromString(tokenizer.get(tokenizer.currentToken()), main->savein); \
|
||||
tokenizer.next(); \
|
||||
}
|
||||
|
||||
|
|
|
@ -865,7 +865,9 @@ public:
|
|||
|
||||
if (env->envExists(subname))
|
||||
{
|
||||
CTemplatizerEnv* subenv = (atoi(evalinsub.c_str()) ? env->getEnv(subname) : env);
|
||||
sint eval;
|
||||
NLMISC::fromString(evalinsub, eval);
|
||||
CTemplatizerEnv* subenv = (eval ? env->getEnv(subname) : env);
|
||||
return ITemplatizerBloc::eval(subenv);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ bool getZonePos(const std::string &name, sint &destX, sint &destY)
|
|||
if (xStr.size() != 2) return false;
|
||||
// compute min corner
|
||||
destX = ((xStr[0] - 'A') * 26 + (xStr[1] - 'A'));
|
||||
destY = -atoi(yStr.c_str());
|
||||
NLMISC::fromString(yStr, destY);
|
||||
destY = -destY;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -317,10 +317,10 @@ sint main( sint argc, char ** argv )
|
|||
skill.ParentSkill = toUpper(string( ptr ));
|
||||
break;
|
||||
case 3: // max skill value
|
||||
skill.MaxValue = (uint16)atoi(ptr);
|
||||
NLMISC::fromString(std::string(ptr), skill.MaxValue);
|
||||
break;
|
||||
case 4: // stage type
|
||||
skill.StageType = (uint8)atoi(ptr);
|
||||
NLMISC::fromString(std::string(ptr), skill.StageType);
|
||||
break;
|
||||
case 5: // main category
|
||||
skill.MainCategory = string( ptr );
|
||||
|
|
|
@ -196,7 +196,9 @@ NLMISC_COMMAND(jobsPromote,"pause execution of jobs","<jobId>")
|
|||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
uint32 idx= atoi(args[0].c_str());
|
||||
uint32 idx;
|
||||
NLMISC::fromString(args[0], idx);
|
||||
|
||||
if ( (idx==0 && args[0]!="0") )
|
||||
{
|
||||
nlwarning("Argument is not a valid job id - should be a number");
|
||||
|
@ -216,7 +218,9 @@ NLMISC_COMMAND(JobUpdatesPerUpdate,"set or display the number of job updates per
|
|||
|
||||
if (args.size()==1)
|
||||
{
|
||||
uint32 count= atoi(args[0].c_str());
|
||||
uint32 count;
|
||||
NLMISC::fromString(args[0], count);
|
||||
|
||||
if ( (count==0 && args[0]!="0") )
|
||||
{
|
||||
nlwarning("Argument is not a valid number");
|
||||
|
@ -270,7 +274,9 @@ NLMISC_COMMAND(jobsDisplayDetails,"display detailed info for the current job (or
|
|||
|
||||
case 1:
|
||||
{
|
||||
uint32 idx= atoi(args[0].c_str());
|
||||
uint32 idx;
|
||||
NLMISC::fromString(args[0], idx);
|
||||
|
||||
if ( (idx==0 && args[0]!="0") )
|
||||
{
|
||||
nlwarning("Argument is not a valid job id - should be a number");
|
||||
|
|
|
@ -339,7 +339,8 @@ int extractBotNames(int argc, char *argv[])
|
|||
result[i]->getPropertyByName("count", countStr);
|
||||
result[i]->getPropertyByName("bot_sheet_look", sheetStr);
|
||||
|
||||
uint32 count = atoi(countStr.c_str());
|
||||
uint32 count;
|
||||
NLMISC::fromString(countStr, count);
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
|
@ -402,7 +403,8 @@ int extractBotNames(int argc, char *argv[])
|
|||
result[i]->getPropertyByName("count", countStr);
|
||||
result[i]->getPropertyByName("bot_sheet_client", sheetStr);
|
||||
|
||||
uint32 count = atoi(countStr.c_str());
|
||||
uint32 count;
|
||||
NLMISC::fromString(countStr, count);
|
||||
|
||||
if (count > 0 && sheetStr.empty())
|
||||
{
|
||||
|
|
|
@ -263,14 +263,16 @@ bool parseDiffCommandFromComment(const ucstring &comments, TDiffInfo &diffInfo)
|
|||
string indexStr;
|
||||
if (!CI18N::parseLabel(it, last, indexStr))
|
||||
return false;
|
||||
diffInfo.Index1 = atoi(indexStr.c_str());
|
||||
|
||||
NLMISC::fromString(indexStr, diffInfo.Index1);
|
||||
|
||||
if (diffInfo.Command == diff_swap)
|
||||
{
|
||||
CI18N::skipWhiteSpace(it, last);
|
||||
if (!CI18N::parseLabel(it, last, indexStr))
|
||||
return false;
|
||||
diffInfo.Index2 = atoi(indexStr.c_str());
|
||||
|
||||
NLMISC::fromString(indexStr, diffInfo.Index2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3183,7 +3185,9 @@ int main(int argc, char *argv[])
|
|||
showUsage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
uint nbLines = atoi(argv[3]);
|
||||
|
||||
uint nbLines;
|
||||
NLMISC::fromString(argv[3], nbLines);
|
||||
|
||||
cropLines(argv[2], nbLines);
|
||||
|
||||
|
|
Loading…
Reference in a new issue