Changed: Replace sscanf by fromString

This commit is contained in:
kervala 2016-10-20 12:33:37 +02:00
parent 9ab62c5606
commit fd61399877
4 changed files with 8 additions and 7 deletions

View file

@ -1082,7 +1082,7 @@ NLMISC_CATEGORISED_COMMAND(nel,displayMeasures, "display hierarchical timer", "[
} }
sint depth = 0; sint depth = 0;
bool hasDepth = (sscanf(args[0].c_str(), "%d", &depth) == 1 || (args.size() > 1 && sscanf(args[1].c_str(), "%d", &depth) == 1)); bool hasDepth = (fromString(args[0], depth) || (args.size() > 1 && fromString(args[1], depth)));
CASE_DISPLAYMEASURES(NoSort, -3) CASE_DISPLAYMEASURES(NoSort, -3)
CASE_DISPLAYMEASURES(TotalTime, -2) CASE_DISPLAYMEASURES(TotalTime, -2)

View file

@ -3122,8 +3122,8 @@ static void setRyzomDebugDate(CRyzomDate &rd)
NLMISC_COMMAND(setDebugHour, "set the current debug hour", "<hour>") NLMISC_COMMAND(setDebugHour, "set the current debug hour", "<hour>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
int hour; sint hour;
if (sscanf(args[0].c_str(), "%d", &hour) != 1) return false; if (!fromString(args[0], hour)) return false;
CRyzomDate rd; CRyzomDate rd;
getRyzomDebugDate(rd); getRyzomDebugDate(rd);
rd.Time = fmodf(rd.Time, 1.f) + (float) hour; rd.Time = fmodf(rd.Time, 1.f) + (float) hour;
@ -3134,8 +3134,8 @@ NLMISC_COMMAND(setDebugHour, "set the current debug hour", "<hour>")
NLMISC_COMMAND(setDebugDayOfYear, "set the current debug day of year (first day has index 1)", "<day>") NLMISC_COMMAND(setDebugDayOfYear, "set the current debug day of year (first day has index 1)", "<day>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
int day; sint day;
if (sscanf(args[0].c_str(), "%d", &day) != 1) return false; if (!fromString(args[0], day)) return false;
CRyzomDate rd; CRyzomDate rd;
getRyzomDebugDate(rd); getRyzomDebugDate(rd);
rd.Day = day - 1; // for the user, days start at '1' rd.Day = day - 1; // for the user, days start at '1'

View file

@ -3916,7 +3916,8 @@ NLMISC_COMMAND( db, "Display or set the value of a property in the database", "<
{ {
// Set // Set
sint64 value; sint64 value;
sscanf( args[2].c_str(), "%"NL_I64"d", &value ); fromString(args[2], value);
if ( (args.size() > 3) && (args[3]!="0") ) if ( (args.size() > 3) && (args[3]!="0") )
{ {
res = e->_PropertyDatabase.x_setPropButDontSend( entry, value ); res = e->_PropertyDatabase.x_setPropButDontSend( entry, value );

View file

@ -1217,7 +1217,7 @@ NLMISC_COMMAND(dumpToXml, "dump the content of an object into an xml file", "<da
if (id == NLMISC::CEntityId::Unknown) if (id == NLMISC::CEntityId::Unknown)
{ {
if (sscanf(args[1].c_str(), "%"NL_I64"u", &key) != 1) if (!fromString(args[1], key))
{ {
log.displayNL("id '%s' is not recognized as an EntityId, an ObjectIndex nor a 64 bits raw key", args[1].c_str()); log.displayNL("id '%s' is not recognized as an EntityId, an ObjectIndex nor a 64 bits raw key", args[1].c_str());
return false; return false;