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

This commit is contained in:
kervala 2010-10-23 17:11:21 +02:00
parent ab840bf640
commit 48dfc73ef0
29 changed files with 250 additions and 138 deletions

View file

@ -272,7 +272,7 @@ namespace ADMIN
// every 16 seconds because very slow
IVariable *var = dynamic_cast<IVariable*>(ICommand::getCommand("ProcessUsedMemory"));
if (var != NULL)
_ProcessUsedMemory = uint32(atoi(var->toString().c_str()));
NLMISC::fromString(var->toString(), _ProcessUsedMemory);
}
// at least one second as passed, check for updates to send to

View file

@ -187,7 +187,8 @@ namespace ADMIN
// read the command line
const TParsedCommandLine *webPort = pcl.getParam("webPort");
nlassert(webPort != NULL);
uint16 port = atoi(webPort->ParamValue.c_str());
uint16 port;
NLMISC::fromString(webPort->ParamValue, port);
// open the web interface
CAdminServiceWebItf::openItf(port);
@ -987,7 +988,8 @@ retry_pending_command:
return false;
string shardName = args[0];
uint32 delay = atoi(args[1].c_str());
uint32 delay;
NLMISC::fromString(args[1], delay);
if (_ShardOrders.find(shardName) == _ShardOrders.end())
{

View file

@ -2566,11 +2566,11 @@ NLMISC_COMMAND(pacsCrunchLoop,"Run a serie of tests of pacs crunch","<file name
startx = (float)atof(args[1].c_str());
starty = (float)atof(args[2].c_str());
loopx = (uint)atoi(args[3].c_str());
loopy = (uint)atoi(args[4].c_str());
NLMISC::fromString(args[3], loopx);
NLMISC::fromString(args[4], loopy);
if (args.size() >= 6)
size = (float)atoi(args[5].c_str());
NLMISC::fromString(args[5], size);
pc.init(args[0]);
@ -2801,12 +2801,12 @@ NLMISC_COMMAND(findPath, "Find path between 2 world positions", "startx starty s
sint32 startx, starty, startslot;
sint32 endx, endy, endslot;
startx = atoi(args[0].c_str());
starty = atoi(args[1].c_str());
startslot = atoi(args[2].c_str());
endx = atoi(args[3].c_str());
endy = atoi(args[4].c_str());
endslot = atoi(args[5].c_str());
NLMISC::fromString(args[0], startx);
NLMISC::fromString(args[1], starty);
NLMISC::fromString(args[2], startslot);
NLMISC::fromString(args[3], endx);
NLMISC::fromString(args[4], endy);
NLMISC::fromString(args[5], endslot);
CWorldPosition start = StaticWorldMap.getWorldPosition(CMapPosition(startx, starty), CSlot(startslot));
CWorldPosition end = StaticWorldMap.getWorldPosition(CMapPosition(endx, endy), CSlot(endslot));
@ -2848,7 +2848,14 @@ NLMISC_COMMAND(testLinks, "test links at a position", "x y slot")
CWorldPosition pos, mv, back;
CDirection dir(CDirection::E);
pos = StaticWorldMap.getWorldPosition(CMapPosition(atoi(args[0].c_str()), atoi(args[1].c_str())), CSlot(atoi(args[2].c_str())));
sint posx, posy;
uint slot;
NLMISC::fromString(args[0], posx);
NLMISC::fromString(args[1], posy);
NLMISC::fromString(args[2], slot);
pos = StaticWorldMap.getWorldPosition(CMapPosition(posx, posy), CSlot(slot));
uint i;
for (i=0; i<8; ++i)
@ -2888,9 +2895,9 @@ NLMISC_COMMAND(getH, "get H", "")
sint32 startx, starty, startslot;
startx = atoi(args[0].c_str());
starty = atoi(args[1].c_str());
startslot = atoi(args[2].c_str());
NLMISC::fromString(args[0], startx);
NLMISC::fromString(args[1], starty);
NLMISC::fromString(args[2], startslot);
CWorldPosition start = StaticWorldMap.getWorldPosition(CMapPosition(startx, starty), CSlot(startslot));

View file

@ -74,7 +74,8 @@ void selectEntities (const string &entityName, vector <uint32> &entities)
else if (entityName.find ("-") != string::npos)
{
// it's a range
uint ent2 = atoi(entityName.substr(entityName.find("-")+1).c_str());
uint ent2;
NLMISC::fromString(entityName.substr(entityName.find("-")+1), ent2);
for (uint i = entity; i <= ent2; i++)
entities.push_back (i);
}
@ -132,7 +133,7 @@ ENTITY_VARIABLE(test, "test")
if(entity >= Entities.size())
Entities.resize(entity+1);
Entities[entity].first = atoi(value.c_str());
NLMISC::fromString(value, Entities[entity].first);
}
}
@ -150,7 +151,7 @@ ENTITY_VARIABLE(test2, "test2")
if(entity >= Entities.size())
Entities.resize(entity+1);
Entities[entity].second = atoi(value.c_str());
NLMISC::fromString(value, Entities[entity].second);
}
}

View file

@ -912,7 +912,8 @@ void CBotNpc::setColours(std::string input)
{
// split succeeded so verify that idxStr contains anumber in range 0..7 and add
// the name to the list of valid names for the given slot
uint32 idx=(uint32)atoi(idxStr.c_str());
uint32 idx;
NLMISC::fromString(idxStr, idx);
if (NLMISC::toString(idx)==idxStr && idx<numColours)
colourNames[idx].push_back(name);
}
@ -948,10 +949,11 @@ void CBotNpc::setColours(std::string input)
// extract the next word from the tail
AI_SHARE::stringToWordAndTail(tail,colour,tail);
// if the colour string is a number then treat it directly
if (NLMISC::toString(atoi(colour.c_str()))==colour)
uint32 idx;
NLMISC::fromString(colour, idx);
if (NLMISC::toString(idx)==colour)
{
// we've got a number so make sue it's in valid range and add to results vector
uint32 idx = atoi(colour.c_str());
if (idx<numColours)
results.push_back(idx);
else

View file

@ -411,7 +411,8 @@ NLMISC_COMMAND(entityPlayerVisibilityDistance,"Set distance (0 to 255) at which
if(args.size()==1)
{
int n = atoi(args[0].c_str());
sint n;
NLMISC::fromString(args[0], n);
if (n>=0 && n<=255)
CAIEntityPhysical::_PlayerVisibilityDistance = n;
}

View file

@ -619,7 +619,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
// the bots are bad guys! they will attack players in their aggro range.
if (!tail.empty())
{
_AggroDist = atoi(tail.c_str());
NLMISC::fromString(tail, _AggroDist);
// bad guy imply attackable!
_PlayerAttackable = true;
// bad guy imply vulnerable!
@ -636,7 +636,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
{
if (!tail.empty())
{
_AggroDist = atoi(tail.c_str());
NLMISC::fromString(tail, _AggroDist);
}
else
@ -1177,7 +1177,8 @@ NLMISC_COMMAND(NpcGroupSlowUpdatePeriod, "Slow update period of the NPC groups",
{
if (args.size()==1)
{
uint32 ticks = (uint32)atoi(args[0].c_str());
uint32 ticks;
NLMISC::fromString(args[0], ticks);
if (ticks>0)
CSpawnGroupNpc::setSlowUpdatePeriod(ticks);
else

View file

@ -1386,7 +1386,9 @@ NLMISC_COMMAND(simulateMsgAskBotDespawnNotification, "", "<service_id> <bot_alia
if (args.size() != 3)
return false;
NLNET::TServiceId serviceId(atoi(args[0].c_str()));
uint16 id;
NLMISC::fromString(args[0], id);
NLNET::TServiceId serviceId(id);
uint32 botAlias = LigoConfig.aliasFromString(args[1]);
CEntityId botId(args[2].c_str());
@ -1413,13 +1415,19 @@ NLMISC_COMMAND(simulateMsgSpawnEasterEgg, "", "<service_id> <ai_instance> <easte
if (args.size() != 7)
return false;
NLNET::TServiceId serviceId(atoi(args[0].c_str()));
uint32 instanceNumber = atoi(args[1].c_str());
uint32 easterEggId = atoi(args[2].c_str());
uint16 id;
NLMISC::fromString(args[0], id);
NLNET::TServiceId serviceId(id);
uint32 instanceNumber;
NLMISC::fromString(args[1], instanceNumber);
uint32 easterEggId;
NLMISC::fromString(args[2], easterEggId);
CSheetId sheetId(args[3]);
string botName = args[4];
sint32 x = atoi(args[5].c_str());
sint32 y = atoi(args[6].c_str());
sint32 x;
NLMISC::fromString(args[5], x);
sint32 y;
NLMISC::fromString(args[6], y);
sint32 z = 0;
sint32 heading = 0;
std::string look = "";
@ -1445,9 +1453,13 @@ NLMISC_COMMAND(simulateMsgDespawnEasterEgg, "", "<service_id> <ai_instance> <eas
if (args.size() != 3)
return false;
NLNET::TServiceId serviceId(atoi(args[0].c_str()));
uint32 instanceNumber = atoi(args[1].c_str());
uint32 easterEggId = atoi(args[2].c_str());
uint16 id;
NLMISC::fromString(args[0], id);
NLNET::TServiceId serviceId(id);
uint32 instanceNumber;
NLMISC::fromString(args[1], instanceNumber);
uint32 easterEggId;
NLMISC::fromString(args[2], easterEggId);
NLNET::CMessage msg("DESPAWN_EASTER_EGG");
uint32 messageVersion = 1;

View file

@ -235,7 +235,8 @@ DEFINE_ACTION(ContextGlobal,CUSTOMLT)
if (noComment != "")
lootSetContent.push_back(noComment);
}
uint16 proba = static_cast<uint16>(atoi(dropProba.c_str()));
uint16 proba;
NLMISC::fromString(dropProba, proba);
// FIXME: test on proba value...
if (proba == 0 || proba > 100)
{

View file

@ -3557,7 +3557,7 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack )
case STRING_MANAGER::money:
{
param.Money = static_cast<uint64>(atoi( s.c_str() ));
NLMISC::fromString(s, param.Money);
break;
}
@ -3593,13 +3593,13 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack )
case STRING_MANAGER::integer:
{
param.Int = atoi( s.c_str());
NLMISC::fromString(s, param.Int);
break;
}
case STRING_MANAGER::time:
{
param.Time = atoi( s.c_str());
NLMISC::fromString(s, param.Time);
break;
}
@ -3642,7 +3642,7 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack )
case STRING_MANAGER::score:
case STRING_MANAGER::body_part:
{
param.Enum = static_cast<uint32>( atoi( s.c_str()) );
NLMISC::fromString(s, param.Enum);
break;
}
@ -3651,8 +3651,8 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack )
break;
case STRING_MANAGER::dyn_string_id:
case STRING_MANAGER::string_id:
param.StringId = static_cast<uint32>( atoi( s.c_str()) );
case STRING_MANAGER::string_id:
NLMISC::fromString(s, param.StringId);
break;
case STRING_MANAGER::self:

View file

@ -1546,7 +1546,8 @@ void receiveMissionItems_ssc_(CStateInstance* entity, CScriptStack& stack)
}
const uint32 quantity = (uint32)atoi(itemAndQty[1].c_str());
uint32 quantity;
NLMISC::fromString(itemAndQty[1], quantity);
if (quantity == 0)
{
nlwarning("receiveMissionItems failed: invalid quantity '%s'", itemAndQty[1].c_str());
@ -1711,7 +1712,8 @@ void giveMissionItems_ssc_(CStateInstance* entity, CScriptStack& stack)
}
const uint32 quantity = (uint32)atoi(itemAndQty[1].c_str());
uint32 quantity;
NLMISC::fromString(itemAndQty[1], quantity);
if (quantity == 0)
{
nlwarning("giveMissionItems failed: invalid quantity '%s'", itemAndQty[1].c_str());
@ -2126,16 +2128,17 @@ void npcSay_css_(CStateInstance* entity, CScriptStack& stack)
if(prefix=="DSS_")
{
NLMISC::CSString phrase = NLMISC::CSString (text).right((unsigned int)text.length()-4);
NLMISC::CSString phrase = NLMISC::CSString (text).right((uint)text.length()-4);
NLMISC::CSString idStr = phrase.strtok(" ",false,false,false,false);
uint32 scenarioId = atoi(idStr.c_str());
uint32 scenarioId;
NLMISC::fromString(idStr, scenarioId);
forwardToDss(spawnBot->dataSetRow(), CChatGroup::say, phrase, scenarioId);
return;
}
if (prefix=="RAW ")
{
NLMISC::CSString phrase = NLMISC::CSString (text).right((unsigned int)text.length()-4);
NLMISC::CSString phrase = NLMISC::CSString (text).right((uint)text.length()-4);
npcChatToChannelSentence(spawnBot->dataSetRow(),CChatGroup::say, phrase);
return;
}

View file

@ -1305,17 +1305,20 @@ NLMISC_CATEGORISED_COMMAND(egs, convertToPdr, "Load all possible characters from
return false;
std::string param = args[op++];
bool val = false;
NLMISC::fromString(param, val);
if (opt == "-recurse")
{
recurse = (param == "true" || atoi(param.c_str()) != 0);
recurse = (param == "true" || val);
}
else if (opt == "-xml")
{
xml = (param == "true" || atoi(param.c_str()) != 0);
xml = (param == "true" || val);
}
else if (opt == "-overwrite")
{
overwrite = (param == "true" || atoi(param.c_str()) != 0);
overwrite = (param == "true" || val);
}
else if (opt == "-wcbin")
{

View file

@ -2516,7 +2516,8 @@ NLMISC_COMMAND(actionReport,"report action for progression testing","<character
CEntityId id;
id.fromString( args[0].c_str() );
sint32 deltaLevel = atoi( args[1].c_str() );
sint32 deltaLevel;
NLMISC::fromString(args[1], deltaLevel);
string Skill = args[2];
SKILLS::ESkills s = SKILLS::toSkill( Skill );
if( s == SKILLS::unknown )
@ -2557,7 +2558,8 @@ NLMISC_COMMAND(setPriv,"set a privilege to a user using his user id, must be in
return true;
}
uint32 uid = atoi(args[0].c_str());
uint32 uid;
NLMISC::fromString(args[0], uid);
CPlayer *p = PlayerManager.getPlayer(uid);
if (p == NULL)
{
@ -2610,7 +2612,8 @@ NLMISC_COMMAND(setPvPTag,"set player character PvP TAG to true or false","<eid>
CEntityId id;
id.fromString(args[0].c_str());
uint tagValue = atoi(args[1].c_str());
uint tagValue;
NLMISC::fromString(args[1], tagValue);
CCharacter *c = PlayerManager.getChar(id);
if (c == NULL)
{

View file

@ -1221,7 +1221,7 @@ NLMISC_COMMAND(setSpireEffectValue, "change base value of a spire effect","<effe
return false;
}
CPVPFactionRewardManager::EffectValues[ family ] = atoi( args[1].c_str() );
NLMISC::fromString(args[1], CPVPFactionRewardManager::EffectValues[ family ]);
}
// update effects for everyone
@ -1340,7 +1340,8 @@ NLMISC_COMMAND(addFactionPoint, "add (or substract) faction point in faction poo
return false;
else
{
sint32 deltaFactionPoint = atoi(args[0].c_str());
sint32 deltaFactionPoint;
NLMISC::fromString(args[0], deltaFactionPoint);
PVP_CLAN::TPVPClan faction = PVP_CLAN::fromString(args[1].c_str());
if(faction == PVP_CLAN::Unknown)

View file

@ -237,13 +237,13 @@ CSoldItem::CSoldItem( const std::string& command )
extract = c.strtok(",");
_ItemSheet = CSheetId( extract );
extract = c.strtok(",");
_Quantity = atoi( extract.c_str() );
NLMISC::fromString(extract, _Quantity);
extract = c.strtok(",");
_Price = atoi( extract.c_str() );
NLMISC::fromString(extract, _Price);
extract = c.strtok(",");
_BasePrice = atoi( extract.c_str() );
NLMISC::fromString(extract, _BasePrice);
extract = c.strtok(",");
_Identifier = atoi( extract.c_str() );
NLMISC::fromString(extract, _Identifier);
_Buyer.fromString( c.c_str() );
}
}
@ -279,8 +279,8 @@ CMaximumShopStoreTimeReached::CMaximumShopStoreTimeReached( const std::string& c
extract = c.strtok(",");
_ItemSheet = CSheetId( extract );
extract = c.strtok(",");
_Quantity = atoi( extract.c_str() );
_Identifier = atoi( c.c_str() );
NLMISC::fromString(extract, _Quantity);
NLMISC::fromString(c, _Identifier);
}
}

View file

@ -644,7 +644,9 @@ uint32 CShopTypeManager::convertQualityToQualityIndex( uint32 quality )
{
for( uint32 index = _QualityStart + 1; index < _QualityEnd; ++index )
{
if( quality <= (uint32) atoi( _CategoryName[ index ].substr( 1 ).c_str() ) )
uint32 qualityIndex;
NLMISC::fromString(_CategoryName[ index ].substr( 1 ), qualityIndex);
if( quality <= qualityIndex )
{
return index - _QualityStart - 1;
}
@ -660,7 +662,10 @@ uint32 CShopTypeManager::convertLevelToLevelIndex( uint32 level )
{
for( uint32 index = _LevelStart + 1; index < _LevelEnd; ++index )
{
if( level <= (uint32) atoi( _CategoryName[ index ].substr( 1 ).c_str() ) )
uint32 levelIndex;
NLMISC::fromString(_CategoryName[ index ].substr( 1 ), levelIndex);
if( level <= levelIndex )
{
return index - _LevelStart - 1;
}
@ -697,13 +702,15 @@ void CShopTypeManager::mountItemShopBase( const std::string& type )
{
for( uint quality = 0; quality < min( (uint)NUM_QUALITY, (uint)(_QualityEnd - _QualityStart - 1)); ++quality )
{
uint16 q = atoi(_CategoryName[ _QualityStart + quality + 1 ].substr(1).c_str());
uint16 q;
NLMISC::fromString(_CategoryName[ _QualityStart + quality + 1 ].substr(1), q);
uint maxLevel = min( (uint)NUM_LEVEL, (uint)(_LevelEnd - _LevelStart - 1) );
for( uint level = 0; level < maxLevel; ++level )
{
uint16 l = atoi(_CategoryName[ _LevelStart + level + 1 ].substr(1).c_str());
uint16 l;
NLMISC::fromString(_CategoryName[ _LevelStart + level + 1 ].substr(1), l);
if( l > MaxLevelNpcItemInStore )
continue;
@ -761,13 +768,15 @@ void CShopTypeManager::mountItemShopBase( const std::string& type )
{
// if( ( (*it2).second.Family != ITEMFAMILY::CRAFTING_TOOL && (*it2).second.Family != ITEMFAMILY::HARVEST_TOOL && (*it2).second.Family != ITEMFAMILY::PET_ANIMAL_TICKET ) || quality == 0 )
{
uint16 q = atoi(_CategoryName[ _QualityStart + quality + 1 ].substr(1).c_str());
uint16 q;
NLMISC::fromString(_CategoryName[ _QualityStart + quality + 1 ].substr(1), q);
uint maxLevel = min( (uint)NUM_LEVEL, (uint)(_LevelEnd - _LevelStart - 1) );
for( uint level = 0; level < maxLevel; ++level )
{
// if( ( (*it2).second.Family != ITEMFAMILY::CRAFTING_TOOL && (*it2).second.Family != ITEMFAMILY::HARVEST_TOOL && (*it2).second.Family != ITEMFAMILY::PET_ANIMAL_TICKET ) || level == 2 ) // remove this filter when tool merchant are setted
{
uint16 l = atoi(_CategoryName[ _LevelStart + level + 1 ].substr(1).c_str());
uint16 l;
NLMISC::fromString(_CategoryName[ _LevelStart + level + 1 ].substr(1), l);
if( l > MaxLevelNpcItemInStore )
continue;
@ -838,14 +847,16 @@ void CShopTypeManager::mountRmShopBase( const std::string& family )
{
for( uint quality = 0; quality < min((uint)NUM_QUALITY, (uint)(_QualityEnd - _QualityStart - 1)); ++quality )
{
uint16 q = atoi(_CategoryName[ _QualityStart + quality + 1 ].substr(1).c_str());
uint16 q;
NLMISC::fromString(_CategoryName[ _QualityStart + quality + 1 ].substr(1), q);
if( (*it).second.Mp->StatEnergy == q )
{
uint maxLevel = min( (uint)NUM_LEVEL, (uint)(_LevelEnd - _LevelStart - 1) );
for( uint level = 0; level < maxLevel; ++level )
{
uint16 l = atoi(_CategoryName[ _LevelStart + level + 1 ].substr(1).c_str());
uint16 l;
NLMISC::fromString(_CategoryName[ _LevelStart + level + 1 ].substr(1), l);
// npc not sell Raw Material of level higher than MaxNPCRawMaterialQualityInSell
if( l <= MaxNPCRawMaterialQualityInSell )
{

View file

@ -1127,7 +1127,7 @@ NLMISC_COMMAND (sdbCreateValue, "create a value leaf in SDB", "<path> [<value>]"
if (args.size() < 2)
val = 0;
else
val = atoi(args[1].c_str());
NLMISC::fromString(args[1], val);
if (!CStatDB::getInstance()->createValue(path, val))
{
@ -1176,7 +1176,8 @@ NLMISC_COMMAND (sdbValueSet, "set a value leaf in SDB", "<path> <value>")
return false;
const string & path = args[0];
sint32 val = atoi(args[1].c_str());
sint32 val;
NLMISC::fromString(args[1], val);
if (!CStatDB::getInstance()->valueSet(path, val))
{
@ -1193,7 +1194,8 @@ NLMISC_COMMAND (sdbValueAdd, "add a value to a value leaf in SDB", "<path> <valu
return false;
const string & path = args[0];
sint32 val = atoi(args[1].c_str());
sint32 val;
NLMISC::fromString(args[1], val);
if (!CStatDB::getInstance()->valueAdd(path, val))
{
@ -1210,7 +1212,8 @@ NLMISC_COMMAND (sdbTableAdd, "add a value to a table leaf in SDB", "<path> <valu
return false;
const string & path = args[0];
sint32 val = atoi(args[1].c_str());
sint32 val;
NLMISC::fromString(args[1], val);
const string & targetType = args[2];
if (targetType == "guild")

View file

@ -256,7 +256,7 @@ bool CPlace::build(const NLLIGO::CPrimPath * path, uint16 id)
_MainPlace = false;
nlverify (CPrimitivesParser::getAlias(path, _Alias));
// _Alias = atoi( val.c_str() );
// _Alias = NLMISC::fromString( val.c_str() );
nlassert( _Alias != CAIAliasTranslator::Invalid );
// get the bounding box
@ -314,7 +314,7 @@ bool CPlace::build(const NLLIGO::CPrimZone * zone,uint16 id, bool reportAutorise
buildPrimPath(zone).c_str());
nlstop;
}
// _Alias = atoi( val.c_str() );
// _Alias = NLMISC::fromString( val.c_str() );
nlassert( _Alias != CAIAliasTranslator::Invalid );

View file

@ -1589,7 +1589,7 @@ NLMISC_COMMAND(verbosePropertiesSent,"Turn on or off or check the state of verbo
else if ( args[0] == string("off") )
verbosePropertiesSent = INVALID_CLIENT;
else
verbosePropertiesSent = atoi(args[0].c_str());
NLMISC::fromString(args[0], verbosePropertiesSent);
}
log.displayNL( "verbosePropertiesSent is %s", (verbosePropertiesSent==INVALID_CLIENT)?"off":((verbosePropertiesSent==0)?"all":toString("C%hu", verbosePropertiesSent).c_str()) );

View file

@ -1583,7 +1583,7 @@ NLMISC_COMMAND( displayPlayerInfo, "Display the properties of a player", "[<clie
TClientId clientid;
/*if ( entityId.isUnknownId() )
{*/
clientid = atoi(args[0].c_str());
NLMISC::fromString(args[0], clientid);
/*}
else
{
@ -1629,10 +1629,12 @@ NLMISC_COMMAND( slotToEntityId, "Get the entityid of a slot of a client (and pos
if ( args.size() < 2 )
return false;
TClientId clientid = atoi(args[0].c_str());
TClientId clientid;
NLMISC::fromString(args[0], clientid);
if ( clientid <= MaxNbClients )
{
TCLEntityId slot = atoi(args[1].c_str());
TCLEntityId slot;
NLMISC::fromString(args[1], slot);
TEntityIndex entityIndex = CFrontEndService::instance()->PrioSub.VisionArray.getEntityIndex( clientid, slot );
if ( entityIndex.getIndex() < (uint32)TheDataset.maxNbRows() )
{
@ -1734,7 +1736,7 @@ NLMISC_COMMAND( clientByUserId, "Get a client id by user id", "<userId>" )
if ( args.empty() )
return false;
else
userId = atoi(args[0].c_str());
NLMISC::fromString(args[0], userId);
CClientHost *clienthost = CFrontEndService::instance()->receiveSub()->findClientHostByUid( userId );
if ( clienthost )
@ -1759,7 +1761,7 @@ NLMISC_COMMAND( dumpClientInfo, "Dump all client info into a file", "<fileName>
else
{
filename = args[0];
clientid = atoi(args[1].c_str());
NLMISC::fromString(args[1], clientid);
if ( args.size() > 2 )
sbd = (args[2]==string("1"));
}

View file

@ -1217,7 +1217,7 @@ void CFrontEndService::init()
// if (IService::getInstance()->haveArg('p'))
// {
// // use the command line param if set
// frontendPort = atoi(IService::getInstance()->getArg('p').c_str());
// frontendPort = NLMISC::fromString(IService::getInstance()->getArg('p').c_str());
// }
// else
// {
@ -1735,7 +1735,8 @@ NLMISC_COMMAND( switchStats, "Switch stats", "" )
NLMISC_COMMAND( monitorClient, "Set the client id to monitor", "<clientid>" )
{
if (args.size() != 1) return false;
TClientId clientid = atoi(args[0].c_str());
TClientId clientid;
NLMISC::fromString(args[0], clientid);
if ( clientid <= MAX_NB_CLIENTS )
CFrontEndService::instance()->monitorClient( clientid );
return true;
@ -1746,7 +1747,8 @@ NLMISC_COMMAND( disconnectClient, "Disconnect a client", "<clientid>" )
{
if (args.size() != 1) return false;
TClientId clientid = atoi(args[0].c_str());
TClientId clientid;
NLMISC::fromString(args[0], clientid);
CClientHost *clienthost;
if ( (clientid <= MaxNbClients) && ((clienthost = CFrontEndService::instance()->sendSub()->clientIdCont()[clientid]) != NULL) )
@ -1780,8 +1782,10 @@ NLMISC_COMMAND( getTargetPosAtTick, "Get the last target entity position that wa
{
if ( args.size() < 2 )
return false;
TClientId clientId = atoi(args[0].c_str());
NLMISC::TGameCycle tick = atoi(args[1].c_str());
TClientId clientId;
NLMISC::fromString(args[0], clientId);
NLMISC::TGameCycle tick;
NLMISC::fromString(args[1], tick);
// Search
bool found = false;
@ -1819,7 +1823,10 @@ NLMISC_COMMAND( dumpImpulseStats, "Dump Impulse stat to XML log", "<logfile> [[-
sint maxdump = -1;
if (args.size() >= 2)
maxdump = abs(atoi(args[1].c_str()));
{
NLMISC::fromString(args[1], maxdump);
maxdump = abs(maxdump);
}
bool reverse = (args.size() >= 2 && args[1][0] == '-');

View file

@ -124,8 +124,10 @@ CClientHost *CVisionArray::clientHost( TClientId clientid )
if(args.size() != 2) return false;
// get the values
TClientId clientid = atoi(args[0].c_str());
TCLEntityId slot = atoi(args[1].c_str());
TClientId clientid;
NLMISC::fromString(args[0], clientid);
TCLEntityId slot;
NLMISC::fromString(args[1], slot);
if ( (clientid <= MaxNbClients) && (slot < MAX_SEEN_ENTITIES_PER_CLIENT) )
{

View file

@ -730,7 +730,8 @@ NLMISC_COMMAND( displayEntityInfo, "Display the properties of an entity", "<enti
if(args.size() != 1) return false;
// get the values
TDataSetIndex entityIndex = atoi(args[0].c_str());
TDataSetIndex entityIndex;
NLMISC::fromString(args[0], entityIndex);
if ( entityIndex < (uint32)TheDataset.maxNbRows() )
{
TDataSetRow datasetrow = TheDataset.getCurrentDataSetRow( entityIndex );
@ -783,8 +784,10 @@ NLMISC_COMMAND( displaySlotInfo, "Display info for a particular slot of a client
if ( args.size() < 2 )
return false;
TClientId clientid = atoi(args[0].c_str());
CLFECOMMON::TCLEntityId slot = atoi(args[1].c_str());
TClientId clientid;
NLMISC::fromString(args[0], clientid);
CLFECOMMON::TCLEntityId slot;
NLMISC::fromString(args[1], slot);
CClientHost *clienthost;
if ( (clientid <= MaxNbClients) && ((clienthost = CFrontEndService::instance()->sendSub()->clientIdCont()[clientid]) != NULL) )
{

View file

@ -42,7 +42,8 @@ NLMISC_COMMAND(setPlayerSpeedCheck, "set player speed check (0=disable)", "entit
CEntityId id;
id.fromString(args[0].c_str());
bool enable = (atoi(args[1].c_str()) != 0);
bool enable;
NLMISC::fromString(args[1], enable);
CWorldEntity *entity = CWorldPositionManager::getEntityPtr( CWorldPositionManager::getEntityIndex(id) );
if (entity == NULL || entity->PlayerInfos == NULL)
@ -64,7 +65,8 @@ NLMISC_COMMAND(loadContinent, "load a continent in the gpms","index name filenam
if (args.size() < 3)
return false;
uint8 continent = (uint8)atoi(args[0].c_str());
uint8 continent;
NLMISC::fromString(args[0], continent);
string name = args[1];
string file = args[2];
@ -79,7 +81,8 @@ NLMISC_COMMAND(removeContinent, "remove a continent from the gpms","index")
if (args.size() < 1)
return false;
uint8 continent = (uint8)atoi(args[0].c_str());
uint8 continent;
NLMISC::fromString(args[0], continent);
CWorldPositionManager::removeContinent(continent);
@ -201,11 +204,13 @@ NLMISC_COMMAND(addEntity,"Add entity to GPMS","entity Id, entity PosX(meters), e
// get the values
CEntityId id;
id.fromString(args[0].c_str());
sint32 PosX = atoi(args[1].c_str());
sint32 PosY = atoi(args[2].c_str());
sint32 PosZ = atoi(args[3].c_str());
sint32 PosX, PosY, PosZ;
NLMISC::fromString(args[1], PosX);
NLMISC::fromString(args[2], PosY);
NLMISC::fromString(args[3], PosZ);
uint16 FeId = atoi(args[4].c_str());
uint16 FeId;
NLMISC::fromString(args[4], FeId);
// display the result on the displayer
log.displayNL("Add entity Id %s to GPMS", id.toString().c_str() );
@ -228,7 +233,8 @@ NLMISC_COMMAND(addEntity,"Add entity to GPMS","entity Id, entity PosX(meters), e
if(args.size() != 1) return false;
// get the values
uint32 num = atoi(args[0].c_str());
uint32 num;
NLMISC::fromString(args[0], num);
// Init Entity
CEntityId id;
@ -259,7 +265,8 @@ NLMISC_COMMAND(addEntity,"Add entity to GPMS","entity Id, entity PosX(meters), e
if(args.size() != 1) return false;
// get the values
uint32 num = atoi(args[0].c_str());
uint32 num;
NLMISC::fromString(args[0], num);
// Init Entity
@ -306,8 +313,10 @@ NLMISC_COMMAND(removeAllEntities,"remove AiVision entities for the specified ser
{
if(args.size() >= 1)
{
uint16 serviceId;
NLMISC::fromString(args[0], serviceId);
// get the values
NLNET::TServiceId ServiceId(atoi(args[0].c_str()));
NLNET::TServiceId ServiceId(serviceId);
//CWorldPositionManager::removeAiVisionEntitiesForService( ServiceId );
}
@ -333,10 +342,14 @@ NLMISC_COMMAND(moveEntity,"move an entity in the GPMS","entity Id, newPos X (met
if(args.size() != 4) return false;
// get the values
uint32 Id = atoi(args[0].c_str());
uint32 PosX = atoi(args[1].c_str());
uint32 PosY = atoi(args[2].c_str());
sint32 PosZ = atoi(args[3].c_str());
uint32 Id;
NLMISC::fromString(args[0], Id);
uint32 PosX;
NLMISC::fromString(args[1], PosX);
uint32 PosY;
NLMISC::fromString(args[2], PosY);
sint32 PosZ;
NLMISC::fromString(args[3], PosZ);
// Init Entity
CEntityId id;
@ -361,10 +374,14 @@ NLMISC_COMMAND(teleportEntity,"teleport an entity", "entity Id, newPos X (meters
id.fromString(args[0].c_str());
// get the values
uint32 PosX = atoi(args[1].c_str());
uint32 PosY = atoi(args[2].c_str());
sint32 PosZ = atoi(args[3].c_str());
sint32 Cell = atoi(args[4].c_str());
uint32 PosX;
NLMISC::fromString(args[1], PosX);
uint32 PosY;
NLMISC::fromString(args[2], PosY);
sint32 PosZ;
NLMISC::fromString(args[3], PosZ);
sint32 Cell;
NLMISC::fromString(args[4], Cell);
// display the result on the displayer
log.displayNL("teleport entity %s", id.toString().c_str());
@ -398,7 +415,9 @@ NLMISC_COMMAND(setEntityContent,"set an entity content", "CEntityId entityId, [C
{
CEntityId id;
id.fromString(args[arg].c_str());
CSheetId sheet(atoi(args[arg+1].c_str()));
uint32 sheetId;
NLMISC::fromString(args[arg+1], sheetId);
CSheetId sheet(sheetId);
content.push_back(CEntitySheetId(id, sheet));
}
@ -421,8 +440,11 @@ NLMISC_COMMAND(mirrorAroundEntity,"Ask a local mirror arround an entity","servic
}
// get the values
NLNET::TServiceId ServiceId(atoi(args[0].c_str()));
uint32 Id = atoi(args[1].c_str());
uint16 serviceId;
NLMISC::fromString(args[0], serviceId);
NLNET::TServiceId ServiceId(serviceId);
uint32 Id;
NLMISC::fromString(args[1], Id);
list< string > properties;
properties.push_back( "X" );
@ -558,7 +580,10 @@ NLMISC_COMMAND(displayTriggerSubscriberInfo, "display subscriber info", "trigger
{
if (args.size() != 1)
return false;
CWorldPositionManager::displaySubscriberInfo(TServiceId(atoi(args[0].c_str())), &log);
uint16 serviceId;
NLMISC::fromString(args[0], serviceId);
CWorldPositionManager::displaySubscriberInfo(TServiceId(serviceId), &log);
return true;
}

View file

@ -78,9 +78,12 @@ NLMISC_COMMAND(smString, "display a string from the string manager <string_id>",
return false;
}
const ucstring &str = SM->getString(atoi(args[0].c_str()));
uint32 stringId;
NLMISC::fromString(args[0], stringId);
log.displayNL("String id %u = [%s]", atoi(args[0].c_str()), str.toString().c_str());
const ucstring &str = SM->getString(stringId);
log.displayNL("String id %u = [%s]", stringId, str.toString().c_str());
return true;
}
@ -373,7 +376,8 @@ NLMISC_COMMAND(smTest, "Send a test dyn string to a client (look at first phrase
}
else if (args[1] == "TEST_DYN_STRING")
{
uint32 id = atoi(args[2].c_str());
uint32 id;
NLMISC::fromString(args[2], id);
p.Type = STRING_MANAGER::dyn_string_id;
p.StringId = id;
params.push_back(p);
@ -381,7 +385,8 @@ NLMISC_COMMAND(smTest, "Send a test dyn string to a client (look at first phrase
}
else if (args[1] == "TEST_STRING")
{
uint32 id = atoi(args[2].c_str());
uint32 id;
NLMISC::fromString(args[2], id);
p.Type = STRING_MANAGER::string_id;
p.StringId = id;
params.push_back(p);
@ -523,7 +528,7 @@ NLMISC_COMMAND(mute,"Mute or unmute a player. the player can be muted for a fixe
sint32 delay = -1;
if( args.size() > 1 )
{
delay = atoi(args[1].c_str());
NLMISC::fromString(args[1], delay);
}
CCharacterInfos * charInfos = IOS->getCharInfos( args[0] );
@ -588,8 +593,10 @@ NLMISC_COMMAND(genImpulsion,"generate a fake impulsion, used to debug the CActio
CBitMemStream stream;
uint count;
NLMISC::fromString(args[0], count);
uint8 val = 0xAC;
for (uint i = 0; i < atoi(args[0].c_str()); i++)
for (uint i = 0; i < count; i++)
stream.serial (val);
//vector<uint8> &v = stream.bufferAsVector();

View file

@ -264,7 +264,9 @@ void CStringManager::TSheetInfo::readGeorges (const NLMISC::CSmartPtr<NLGEORGES:
if (sheetId.getSheetType() == NLMISC::CSheetId::typeFromFileExtension("creature"))
{
form->getRootNode ().getValueByName (gender, "Basics.Gender");
Gender = GSGENDER::EGender(atoi(gender.c_str()));
sint genderId;
NLMISC::fromString(gender, genderId);
Gender = GSGENDER::EGender(genderId);
form->getRootNode ().getValueByName (Race, "Basics.Race");
@ -1351,7 +1353,7 @@ NLMISC_CATEGORISED_COMMAND(stringmanager, loadBotNames, "load a bot names file",
filename = args[0];
if (args.size() > 1)
resetBotnames = (atoi(args[1].c_str()) != 0);
NLMISC::fromString(args[1], resetBotnames);
SM->loadBotNames(filename, resetBotnames, &log);
return true;

View file

@ -1035,7 +1035,7 @@ bool CStringManager::parseCondition(const CPhrase &phrase, const ucstring &str,
NLMISC::strlwr(cond.ReferenceStr);
// try to eval value as an integer value
cond.ReferenceInt = atoi(cond.ReferenceStr.c_str());
NLMISC::fromString(cond.ReferenceStr, cond.ReferenceInt);
if (paramName != "self")
{

View file

@ -57,12 +57,12 @@ std::string decodeDbPathId(const std::string& pathid)
if (p == std::string::npos)
{
id = atoi(pathid.c_str());
NLMISC::fromString(pathid, id);
}
else
{
shard = pathid.substr(0, p);
id = atoi(&(*(pathid.begin()+p+1)));
NLMISC::fromString(pathid.substr(p+1), id);
}
return CPDSLib::getLogDirectory(id, shard);
@ -212,7 +212,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, displayLog, "display pd_log file human readab
if (args.size() != 2)
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -279,7 +280,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, displayLogs,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -315,7 +317,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, searchEId,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -354,7 +357,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, searchString,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -392,7 +396,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, searchEIds,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -445,7 +450,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, searchValueByEId,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -488,7 +494,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, displayDescription,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);
@ -551,7 +558,8 @@ NLMISC_CATEGORISED_COMMAND(pd_log, displayTableDescription,
return false;
/*
uint databaseId = atoi(args[0].c_str());
uint databaseId;
NLMISC::fromString(args[0], databaseId);
string logpath = CPDSLib::getLogDirectory(databaseId);
*/
string logpath = decodeDbPathId(args[0]);

View file

@ -483,8 +483,8 @@ void cbResult(CMemStream &msgin, TSockId host)
//nlinfo("param=%s value=%s", param.c_str(), value.c_str());
if (param == "id") queryId = atoi(value.c_str());
else if (param == "page") page = atoi(value.c_str());
if (param == "id") NLMISC::fromString(value, queryId);
else if (param == "page") NLMISC::fromString(value, page);
else if (param == "filter") filter = value;
else if (param == "fmode") filter_exclusive = (value == "exclusive");
}
@ -497,8 +497,12 @@ void cbResult(CMemStream &msgin, TSockId host)
if (res.size() >= 1)
{
page = (res.size() >= 2 ? atoi(res[1].c_str()) : 0);
queryId = atoi(res[0].c_str());
if (res.size() >= 2)
NLMISC::fromString(res[1], page);
else
page = 0;
NLMISC::fromString(res[0], queryId);
}
}
@ -548,7 +552,8 @@ void cbCancelQuery(CMemStream &msgin, TSockId host)
std::string idStr;
msgin.serial(idStr);
uint32 queryId = atoi(idStr.c_str());
uint32 queryId;
NLMISC::fromString(idStr, queryId);
CLogAnalyserService::getInstance()->cancelQuery(queryId);