From 85ef19776ac83c4c3559df991a856249cf22cac7 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Oct 2010 17:11:21 +0200 Subject: [PATCH] Changed: #142 Replace atoi and sscanf by fromString when it's possible --- .../src/admin_modules/aes_client_module.cpp | 2 +- .../server/src/admin_modules/as_module.cpp | 6 +- .../server/src/ai_data_service/pacs_scan.cpp | 33 +++++---- code/ryzom/server/src/ai_service/admin.h | 7 +- .../server/src/ai_service/ai_bot_npc.cpp | 8 ++- .../src/ai_service/ai_entity_physical.cpp | 3 +- .../server/src/ai_service/ai_grp_npc.cpp | 7 +- .../server/src/ai_service/ai_instance.cpp | 30 +++++--- .../server/src/ai_service/ais_user_models.cpp | 3 +- code/ryzom/server/src/ai_service/nf_grp.cpp | 12 ++-- .../server/src/ai_service/nf_grp_npc.cpp | 13 ++-- .../player_manager/player.cpp | 9 ++- .../player_manager/player_manager.cpp | 9 ++- .../pvp_faction_reward_manager.cpp | 5 +- .../shop_type/offline_character_command.cpp | 12 ++-- .../shop_type/shop_type_manager.cpp | 27 +++++--- .../src/entities_game_service/stat_db.cpp | 11 +-- .../entities_game_service/zone_manager.cpp | 4 +- .../frontend_service/distance_prioritizer.cpp | 2 +- .../src/frontend_service/fe_receive_sub.cpp | 12 ++-- .../src/frontend_service/frontend_service.cpp | 19 +++-- .../src/frontend_service/vision_array.cpp | 6 +- .../src/frontend_service/vision_provider.cpp | 9 ++- .../ryzom/server/src/gpm_service/commands.cpp | 69 +++++++++++++------ .../src/input_output_service/commands.cpp | 19 +++-- .../input_output_service/string_manager.cpp | 6 +- .../string_manager_parser.cpp | 2 +- .../src/log_analyser_service/commands.cpp | 28 +++++--- .../log_analyser_service.cpp | 15 ++-- 29 files changed, 250 insertions(+), 138 deletions(-) diff --git a/code/ryzom/server/src/admin_modules/aes_client_module.cpp b/code/ryzom/server/src/admin_modules/aes_client_module.cpp index 663ea60dd..7f81659b2 100644 --- a/code/ryzom/server/src/admin_modules/aes_client_module.cpp +++ b/code/ryzom/server/src/admin_modules/aes_client_module.cpp @@ -272,7 +272,7 @@ namespace ADMIN // every 16 seconds because very slow IVariable *var = dynamic_cast(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 diff --git a/code/ryzom/server/src/admin_modules/as_module.cpp b/code/ryzom/server/src/admin_modules/as_module.cpp index 0a7a3f52b..5f6d89692 100644 --- a/code/ryzom/server/src/admin_modules/as_module.cpp +++ b/code/ryzom/server/src/admin_modules/as_module.cpp @@ -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()) { diff --git a/code/ryzom/server/src/ai_data_service/pacs_scan.cpp b/code/ryzom/server/src/ai_data_service/pacs_scan.cpp index e03bd24ec..b71cafa11 100644 --- a/code/ryzom/server/src/ai_data_service/pacs_scan.cpp +++ b/code/ryzom/server/src/ai_data_service/pacs_scan.cpp @@ -2566,11 +2566,11 @@ NLMISC_COMMAND(pacsCrunchLoop,"Run a serie of tests of pacs crunch","= 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)); diff --git a/code/ryzom/server/src/ai_service/admin.h b/code/ryzom/server/src/ai_service/admin.h index a26778fbb..480b9b7b7 100644 --- a/code/ryzom/server/src/ai_service/admin.h +++ b/code/ryzom/server/src/ai_service/admin.h @@ -74,7 +74,8 @@ void selectEntities (const string &entityName, vector &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); } } diff --git a/code/ryzom/server/src/ai_service/ai_bot_npc.cpp b/code/ryzom/server/src/ai_service/ai_bot_npc.cpp index 78770e4e6..f56a745db 100644 --- a/code/ryzom/server/src/ai_service/ai_bot_npc.cpp +++ b/code/ryzom/server/src/ai_service/ai_bot_npc.cpp @@ -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=0 && n<=255) CAIEntityPhysical::_PlayerVisibilityDistance = n; } diff --git a/code/ryzom/server/src/ai_service/ai_grp_npc.cpp b/code/ryzom/server/src/ai_service/ai_grp_npc.cpp index e434ed1c9..5b3ffc35b 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_npc.cpp +++ b/code/ryzom/server/src/ai_service/ai_grp_npc.cpp @@ -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 diff --git a/code/ryzom/server/src/ai_service/ai_instance.cpp b/code/ryzom/server/src/ai_service/ai_instance.cpp index ac696b8fb..cbadd0bf5 100644 --- a/code/ryzom/server/src/ai_service/ai_instance.cpp +++ b/code/ryzom/server/src/ai_service/ai_instance.cpp @@ -1386,7 +1386,9 @@ NLMISC_COMMAND(simulateMsgAskBotDespawnNotification, "", " (atoi(dropProba.c_str())); + uint16 proba; + NLMISC::fromString(dropProba, proba); // FIXME: test on proba value... if (proba == 0 || proba > 100) { diff --git a/code/ryzom/server/src/ai_service/nf_grp.cpp b/code/ryzom/server/src/ai_service/nf_grp.cpp index 66efb2896..ff779543e 100644 --- a/code/ryzom/server/src/ai_service/nf_grp.cpp +++ b/code/ryzom/server/src/ai_service/nf_grp.cpp @@ -3557,7 +3557,7 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) case STRING_MANAGER::money: { - param.Money = static_cast(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( 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( atoi( s.c_str()) ); + case STRING_MANAGER::string_id: + NLMISC::fromString(s, param.StringId); break; case STRING_MANAGER::self: diff --git a/code/ryzom/server/src/ai_service/nf_grp_npc.cpp b/code/ryzom/server/src/ai_service/nf_grp_npc.cpp index 9d663e95c..2a008373c 100644 --- a/code/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/code/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -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; } diff --git a/code/ryzom/server/src/entities_game_service/player_manager/player.cpp b/code/ryzom/server/src/entities_game_service/player_manager/player.cpp index 394ca40c8..977598a23 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/player.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/player.cpp @@ -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") { diff --git a/code/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp b/code/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp index dfd597032..a0305c712 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp @@ -2516,7 +2516,8 @@ NLMISC_COMMAND(actionReport,"report action for progression testing"," 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) { diff --git a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp index 0b5da3b8a..b7f279434 100644 --- a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp @@ -1221,7 +1221,7 @@ NLMISC_COMMAND(setSpireEffectValue, "change base value of a spire effect"," 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 ) { diff --git a/code/ryzom/server/src/entities_game_service/stat_db.cpp b/code/ryzom/server/src/entities_game_service/stat_db.cpp index 773cc9183..4e08fdabb 100644 --- a/code/ryzom/server/src/entities_game_service/stat_db.cpp +++ b/code/ryzom/server/src/entities_game_service/stat_db.cpp @@ -1127,7 +1127,7 @@ NLMISC_COMMAND (sdbCreateValue, "create a value leaf in SDB", " []" 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", " ") 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", " valueAdd(path, val)) { @@ -1210,7 +1212,8 @@ NLMISC_COMMAND (sdbTableAdd, "add a value to a table leaf in SDB", " 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", "" ) 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", " else { filename = args[0]; - clientid = atoi(args[1].c_str()); + NLMISC::fromString(args[1], clientid); if ( args.size() > 2 ) sbd = (args[2]==string("1")); } diff --git a/code/ryzom/server/src/frontend_service/frontend_service.cpp b/code/ryzom/server/src/frontend_service/frontend_service.cpp index 9b2ea65eb..d0e23a5ef 100644 --- a/code/ryzom/server/src/frontend_service/frontend_service.cpp +++ b/code/ryzom/server/src/frontend_service/frontend_service.cpp @@ -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", "" ) { 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", "" ) { 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", " [[- 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] == '-'); diff --git a/code/ryzom/server/src/frontend_service/vision_array.cpp b/code/ryzom/server/src/frontend_service/vision_array.cpp index 4ee23ef66..dde09ff79 100644 --- a/code/ryzom/server/src/frontend_service/vision_array.cpp +++ b/code/ryzom/server/src/frontend_service/vision_array.cpp @@ -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) ) { diff --git a/code/ryzom/server/src/frontend_service/vision_provider.cpp b/code/ryzom/server/src/frontend_service/vision_provider.cpp index fadebe437..5e12cc58b 100644 --- a/code/ryzom/server/src/frontend_service/vision_provider.cpp +++ b/code/ryzom/server/src/frontend_service/vision_provider.cpp @@ -730,7 +730,8 @@ NLMISC_COMMAND( displayEntityInfo, "Display the properties of an entity", "sendSub()->clientIdCont()[clientid]) != NULL) ) { diff --git a/code/ryzom/server/src/gpm_service/commands.cpp b/code/ryzom/server/src/gpm_service/commands.cpp index 5e30230b9..d24f830e7 100644 --- a/code/ryzom/server/src/gpm_service/commands.cpp +++ b/code/ryzom/server/src/gpm_service/commands.cpp @@ -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; } diff --git a/code/ryzom/server/src/input_output_service/commands.cpp b/code/ryzom/server/src/input_output_service/commands.cpp index a406a6b1e..66c30db8f 100644 --- a/code/ryzom/server/src/input_output_service/commands.cpp +++ b/code/ryzom/server/src/input_output_service/commands.cpp @@ -78,9 +78,12 @@ NLMISC_COMMAND(smString, "display a string from the string manager ", 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 &v = stream.bufferAsVector(); diff --git a/code/ryzom/server/src/input_output_service/string_manager.cpp b/code/ryzom/server/src/input_output_service/string_manager.cpp index e2331f005..2e598f70b 100644 --- a/code/ryzom/server/src/input_output_service/string_manager.cpp +++ b/code/ryzom/server/src/input_output_service/string_manager.cpp @@ -264,7 +264,9 @@ void CStringManager::TSheetInfo::readGeorges (const NLMISC::CSmartPtrgetRootNode ().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; diff --git a/code/ryzom/server/src/input_output_service/string_manager_parser.cpp b/code/ryzom/server/src/input_output_service/string_manager_parser.cpp index 3a58685ed..94af5e29b 100644 --- a/code/ryzom/server/src/input_output_service/string_manager_parser.cpp +++ b/code/ryzom/server/src/input_output_service/string_manager_parser.cpp @@ -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") { diff --git a/code/ryzom/server/src/log_analyser_service/commands.cpp b/code/ryzom/server/src/log_analyser_service/commands.cpp index 0932a66c4..7fb97c6c4 100644 --- a/code/ryzom/server/src/log_analyser_service/commands.cpp +++ b/code/ryzom/server/src/log_analyser_service/commands.cpp @@ -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]); diff --git a/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp b/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp index 43f801685..2c8e50058 100644 --- a/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp +++ b/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp @@ -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);