diff --git a/code/ryzom/server/src/ai_share/primitive_parser.cpp b/code/ryzom/server/src/ai_share/primitive_parser.cpp index 1ca550ce0..1e5175c7a 100644 --- a/code/ryzom/server/src/ai_share/primitive_parser.cpp +++ b/code/ryzom/server/src/ai_share/primitive_parser.cpp @@ -137,7 +137,7 @@ uint32 nodeAlias(const IPrimitive *prim, bool canFail = false) // // for legacy reasons the field may be called 'unique_id' instead of 'alias' // if (s.empty()) // prim->getPropertyByName("unique_id",s); -// alias=atoi(s.c_str()); +// alias=NLMISC::fromString(s.c_str()); // // if we haven't found a sensible alias value use the prim node address // if (alias==0 && s!="0") @@ -518,7 +518,7 @@ static CAIEventActionNode::TSmartPtr parsePrimEventAction(const CAIAliasDescript prim->getPropertyByName("action",result->Action); prim->getPropertyByName("weight",weightStr); prim->getPropertyByName("parameters",parameters); - result->Weight=atoi(weightStr.c_str()); + NLMISC::fromString(weightStr, result->Weight); result->Args=*parameters; for (uint i=0;igetNumChildren();++i) @@ -1134,7 +1134,8 @@ static void parsePrimPlaces(const CAIAliasDescriptionNode *treeNode,const IPrimi // read the radius std::string radiusString; child->getPropertyByName("radius",radiusString); - uint radius=atoi(radiusString.c_str()); + uint radius; + NLMISC::fromString(radiusString, radius); if (radius == 0) { nlwarning("Ignoring place '%s' because bad radius: '%s' (converted to int as %u)", @@ -1180,15 +1181,15 @@ static void parsePrimPlaces(const CAIAliasDescriptionNode *treeNode,const IPrimi // if (child->getPropertyByName("visit_time_min", tmpStr)) { - stayTimeMin = atoi(tmpStr.c_str()); + NLMISC::fromString(tmpStr, stayTimeMin); } if (child->getPropertyByName("visit_time_max", tmpStr)) { - stayTimeMax = atoi(tmpStr.c_str()); + NLMISC::fromString(tmpStr, stayTimeMax); } if (child->getPropertyByName("index", tmpStr)) { - index = atoi(tmpStr.c_str()); + NLMISC::fromString(tmpStr, index); } child->getPropertyByName("index_next", indexNext); if (child->getPropertyByName("flag_spawn", tmpStr)) @@ -1283,7 +1284,7 @@ static void parsePopulation(const IPrimitive *prim, std::string &sheet, uint &co sheet = s+".creature"; } - count=atoi(countStr.c_str()); + NLMISC::fromString(countStr, count); if (count<=0) { throw parsePopException(std::string("FAUNA_SPAWN_ATOM property 'count' invalid: ")+countStr); @@ -1316,7 +1317,7 @@ static void parsePrimGrpFaunaSpawn(const CAIAliasDescriptionNode *treeNode,const uint32 weight = 0; if (prim->getPropertyByName("weight",s)) { - weight=atoi(s.c_str()); + NLMISC::fromString(s, weight); if (toString(weight)!=s) { nlwarning("weight invalid value: %s"); @@ -1886,7 +1887,8 @@ static void parsePrimGrpNpc(const CAIAliasDescriptionNode *treeNode,const IPrimi } prim->getPropertyByName("count",s); - uint botCount=atoi(s.c_str()); + uint botCount; + NLMISC::fromString(s, botCount); if (foundBots && botCount != 0) { @@ -2679,7 +2681,7 @@ static void parsePrimBotTemplate(const CAIAliasDescriptionNode *aliasNode, const prim->getPropertyByName("sheet_look", lookSheet); multiLevel = true; prim->getPropertyByName("level_delta", s); - levelDelta = atoi(s.c_str()); + NLMISC::fromString(s, levelDelta); } else { @@ -2729,7 +2731,7 @@ static void parsePrimGroupTemplate(const CAIAliasDescriptionNode *aliasNode, con sint32 levelDelta = 0; prim->getPropertyByName("count", s); - botCount = atoi(s.c_str()); + NLMISC::fromString(s, botCount); prim->getPropertyByName("count_multiplied_by_sheet", s); countMultipliedBySheet = (s == "true"); @@ -2748,7 +2750,7 @@ static void parsePrimGroupTemplate(const CAIAliasDescriptionNode *aliasNode, con prim->getPropertyByName("bot_sheet_look", lookSheet); multiLevel = true; prim->getPropertyByName("level_delta", s); - levelDelta = atoi(s.c_str()); + NLMISC::fromString(s, levelDelta); } else { @@ -2773,13 +2775,13 @@ static void parsePrimGroupTemplate(const CAIAliasDescriptionNode *aliasNode, con seasons[3] = (s == "true"); prim->getPropertyByName("weight_0_25", s); - weights[0] = atoi(s.c_str()); + NLMISC::fromString(s, weights[0]); prim->getPropertyByName("weight_25_50", s); - weights[1] = atoi(s.c_str()); + NLMISC::fromString(s, weights[1]); prim->getPropertyByName("weight_50_75", s); - weights[2] = atoi(s.c_str()); + NLMISC::fromString(s, weights[2]); prim->getPropertyByName("weight_75_100", s); - weights[3] = atoi(s.c_str()); + NLMISC::fromString(s, weights[3]); vector *actParams = &EmptyStringVector; diff --git a/code/ryzom/server/src/entities_game_service/admin.cpp b/code/ryzom/server/src/entities_game_service/admin.cpp index d582ca0d3..e4b4075b6 100644 --- a/code/ryzom/server/src/entities_game_service/admin.cpp +++ b/code/ryzom/server/src/entities_game_service/admin.cpp @@ -756,7 +756,9 @@ ENTITY_VARIABLE(HP, "Hit points of a player") } else { - e->getScores()._PhysicalScores[SCORES::hit_points].Current = atoi(value.c_str()); + sint32 v; + NLMISC::fromString(value, v); + e->getScores()._PhysicalScores[SCORES::hit_points].Current = v; } } @@ -770,7 +772,9 @@ ENTITY_VARIABLE(MaxHP, "Max hit points of a player") } else { - e->getScores()._PhysicalScores[SCORES::hit_points].Max = atoi(value.c_str()); + sint32 v; + NLMISC::fromString(value, v); + e->getScores()._PhysicalScores[SCORES::hit_points].Max = v; } } @@ -888,7 +892,8 @@ ENTITY_VARIABLE(MoneyGuild, "MoneyGuild") } else { - uint32 val = atoi(value.substr(1).c_str()); + uint32 val; + NLMISC::fromString(value.substr(1), val); if(dir == 1) guild->addMoney(val); else @@ -941,11 +946,14 @@ ENTITY_VARIABLE(FactionPoint, "FactionPoint") if(dir == 0) { - c->setFactionPoint(clan, atoi(sNumber.c_str()), true); + uint32 val; + NLMISC::fromString(sNumber, val); + c->setFactionPoint(clan, val, true); } else { - uint32 val = atoi(sNumber.substr(1).c_str()); + uint32 val; + NLMISC::fromString(sNumber.substr(1), val); if(dir == 1) c->setFactionPoint(clan, c->getFactionPoint(clan)+val, true); else @@ -1142,7 +1150,9 @@ ENTITY_VARIABLE(Position, "Position of a player (in meter) ,[, if (res.size() >= 4) { // season included - c->teleportCharacter(x,y,z,true, false, 0.f, 0xFF, 0, (uint8) atoi(res[3].c_str())); + uint8 season; + NLMISC::fromString(res[3], season); + c->teleportCharacter(x,y,z,true, false, 0.f, 0xFF, 0, season); } else { @@ -1171,7 +1181,9 @@ NLMISC_COMMAND(changeMode," change_mode"," ") CEntityId id; id.fromString( args[0].c_str() ); - MBEHAV::EMode mode = MBEHAV::EMode(atoi(args[1].c_str())); + sint iMode; + NLMISC::fromString(args[1], iMode); + MBEHAV::EMode mode = MBEHAV::EMode(iMode); CEntityBase *e = 0; if( id.getType() == 0 ) @@ -1236,7 +1248,8 @@ NLMISC_COMMAND (createItemInBag, "Create an item and put it in the player bag", string sheetName = args[1]; CSheetId sheet; - uint32 sheetId = atoi(sheetName.c_str()); + uint32 sheetId; + NLMISC::fromString(sheetName, sheetId); if (sheetId != 0) { sheet = CSheetId(sheetId); @@ -1276,14 +1289,16 @@ NLMISC_COMMAND (createItemInBag, "Create an item and put it in the player bag", return false; } - sint quantity = atoi(args[2].c_str()); + sint quantity; + NLMISC::fromString(args[2], quantity); if (quantity < 1) { log.displayNL ("Quantity must be > 0"); return false; } - sint quality = atoi(args[3].c_str()); + sint quality; + NLMISC::fromString(args[3], quality); if (quality < 1) { log.displayNL ("Quality must be > 0"); @@ -1324,7 +1339,8 @@ NLMISC_COMMAND (createItemInTmpInv, "Create an item and put it in the player tem string sheetName = args[1]; CSheetId sheet; - uint32 sheetId = atoi(sheetName.c_str()); + uint32 sheetId; + NLMISC::fromString(sheetName, sheetId); if (sheetId != 0) { sheet = CSheetId(sheetId); @@ -1363,14 +1379,16 @@ NLMISC_COMMAND (createItemInTmpInv, "Create an item and put it in the player tem return false; } - sint quantity = atoi(args[2].c_str()); + sint quantity; + NLMISC::fromString(args[2], quantity); if (quantity < 1) { log.displayNL ("Quantity must be > 0"); return false; } - sint quality = atoi(args[3].c_str()); + sint quality; + NLMISC::fromString(args[3], quality); if (quality < 1) { log.displayNL ("Quality must be > 0"); @@ -1394,7 +1412,8 @@ NLMISC_COMMAND (createItemInInv, "Create items and put them in the given invento string sheetName = args[2]; CSheetId sheet; - uint32 sheetId = atoi(sheetName.c_str()); + uint32 sheetId; + NLMISC::fromString(sheetName, sheetId); if (sheetId != 0) { sheet = CSheetId(sheetId); @@ -1433,21 +1452,25 @@ NLMISC_COMMAND (createItemInInv, "Create items and put them in the given invento return false; } - sint quantity = atoi(args[3].c_str()); + sint quantity; + NLMISC::fromString(args[3], quantity); if (quantity < 1) { log.displayNL ("Quantity must be > 0"); return false; } - sint quality = atoi(args[4].c_str()); + sint quality; + NLMISC::fromString(args[4], quality); if (quality < 1) { log.displayNL ("Quality must be > 0"); return false; } - uint nbItems = min(uint(atoi(args[5].c_str())), 1000U); + uint nb; + NLMISC::fromString(args[5], nb); + uint nbItems = min(nb, 1000U); uint nbCreatedItems = 0; for (uint i = 0; i < nbItems; i++) { @@ -1479,7 +1502,7 @@ NLMISC_COMMAND(createNamedItemInBag, "create a named item in bag", " uint16 quantity; if (args.size() == 3) { - quantity = (uint16)atoi(args[2].c_str()); + NLMISC::fromString(args[2], quantity); if (quantity == 0) { log.displayNL("invalid quantity '%s'", args[2].c_str()); @@ -1528,7 +1551,8 @@ NLMISC_COMMAND (createFullArmorSet, "Create and equip player with chosen full ar const string &race = args[1]; const string &type = args[2]; - const uint16 quality = atoi(args[3].c_str()); + uint16 quality; + NLMISC::fromString(args[3], quality); const uint16 min = quality - (quality-1)%5; const string minStr = (min < 10) ? string("0") + toString(min) : toString(min); @@ -1917,7 +1941,8 @@ NLMISC_COMMAND (learnAllForagePhrases, "Learn all forage phrase, begin at specif if ( args.size() != 2 ) return false; GET_CHARACTER - uint i = atoi( args[1].c_str() ); + uint i; + NLMISC::fromString(args[1], i); uint nbSuccess = 0, nbFail = 0; const CAllRolemasterPhrases& phrases = CSheets::getSRolemasterPhrasesMap(); @@ -2171,7 +2196,8 @@ NLMISC_COMMAND(setPetAnimalSatiety,"Set the satiety of pet animal (petIndex in 0 { // Set the new satiety string result; - uint petIndex = atoi( args[1].c_str() ); + uint petIndex; + NLMISC::fromString(args[1], petIndex); float previousSatiety, maxSatiety; if ( c->getAnimalSatiety( petIndex, previousSatiety, maxSatiety ) ) { @@ -2215,7 +2241,8 @@ NLMISC_COMMAND(getPetAnimalSatiety,"Set the satiety of pet animal (petIndex in 0 if (args.size () < 2) return false; GET_CHARACTER - uint petIndex = atoi( args[1].c_str() ); + uint petIndex; + NLMISC::fromString(args[1], petIndex); if ( c ) { // Get the satiety @@ -2271,7 +2298,8 @@ NLMISC_COMMAND (addXPToSkill, "Gain experience in a given skills", " < if (args.size () < 3) return false; GET_CHARACTER - uint32 xp = atoi (args[1].c_str()); + uint32 xp; + NLMISC::fromString(args[1], xp); string skill = args[2]; @@ -2279,7 +2307,7 @@ NLMISC_COMMAND (addXPToSkill, "Gain experience in a given skills", " < if(args.size()==3) count = 1; else - count = atoi(args[3].c_str()); + NLMISC::fromString(args[3], count); count = min( count, (uint)100); @@ -2418,7 +2446,8 @@ NLMISC_COMMAND(execPhrase,"execute a sabrina phrase","= 3 ) { GET_CHARACTER - bool cyclic = atoi(args[1].c_str()) != 0; + bool cyclic; + NLMISC::fromString(args[1], cyclic); vector brickIds; for (uint i = 2 ; i < args.size() ; ++i) @@ -2443,7 +2472,8 @@ NLMISC_COMMAND(executeSabrinaPhrase,"execute a sabrina phrase, an sphrase","getEntityRowId(), c->getTargetDataSetRow(), phraseSheet, cyclic); @@ -2464,7 +2494,8 @@ NLMISC_COMMAND(memorizePhrase,"memorize a sabrina phrase","respawn( atoi(args[1].c_str() ) ); + c->respawn(idx); return true; } @@ -2582,7 +2618,9 @@ NLMISC_COMMAND(validateRespawnPoint,"Validate re-spawn point","getRespawnPoints().addRespawnPoint(atoi( args[1].c_str() )); + CCharacterRespawnPoints::TRespawnPoint respawnPoint; + NLMISC::fromString(args[1], respawnPoint); + c->getRespawnPoints().addRespawnPoint(respawnPoint); return true; } return false; @@ -2606,7 +2644,8 @@ NLMISC_COMMAND(setItemSapLoad,"set an item sap load","& items = (vector &)c->getInventory()[INVENTORIES::bag]->getChildren(); CInventoryPtr invent = c->getInventory(INVENTORIES::bag); @@ -2686,7 +2725,9 @@ NLMISC_COMMAND( summonPet, "player can summon it's pet one time only", "& pet = c->getPlayerPets(); if( index < pet.size() ) { @@ -2710,7 +2751,9 @@ NLMISC_COMMAND( allowSummonPet, "autorize player summon it's pet one time only", return false; GET_CHARACTER - uint32 index = atoi(args[1].c_str()) - 1; + uint32 index; + NLMISC::fromString(args[1], index); + --index; const std::vector< CPetAnimal >& pet = c->getPlayerPets(); if( index < pet.size() ) @@ -2775,6 +2818,7 @@ void cbClientAdmin (NLNET::CMessage& msgin, const std::string &serviceName, NLNE CEntityId eid; + CEntityId targetEid; msgin.serial (eid); bool onTarget; @@ -3491,7 +3535,9 @@ NLMISC_COMMAND( root, "root a player", "