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

This commit is contained in:
kervala 2010-10-23 17:39:06 +02:00
parent 41d2767a33
commit e4f7ddb305
50 changed files with 766 additions and 501 deletions

View file

@ -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' // // for legacy reasons the field may be called 'unique_id' instead of 'alias'
// if (s.empty()) // if (s.empty())
// prim->getPropertyByName("unique_id",s); // 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 we haven't found a sensible alias value use the prim node address
// if (alias==0 && s!="0") // if (alias==0 && s!="0")
@ -518,7 +518,7 @@ static CAIEventActionNode::TSmartPtr parsePrimEventAction(const CAIAliasDescript
prim->getPropertyByName("action",result->Action); prim->getPropertyByName("action",result->Action);
prim->getPropertyByName("weight",weightStr); prim->getPropertyByName("weight",weightStr);
prim->getPropertyByName("parameters",parameters); prim->getPropertyByName("parameters",parameters);
result->Weight=atoi(weightStr.c_str()); NLMISC::fromString(weightStr, result->Weight);
result->Args=*parameters; result->Args=*parameters;
for (uint i=0;i<prim->getNumChildren();++i) for (uint i=0;i<prim->getNumChildren();++i)
@ -1134,7 +1134,8 @@ static void parsePrimPlaces(const CAIAliasDescriptionNode *treeNode,const IPrimi
// read the radius // read the radius
std::string radiusString; std::string radiusString;
child->getPropertyByName("radius",radiusString); child->getPropertyByName("radius",radiusString);
uint radius=atoi(radiusString.c_str()); uint radius;
NLMISC::fromString(radiusString, radius);
if (radius == 0) if (radius == 0)
{ {
nlwarning("Ignoring place '%s' because bad radius: '%s' (converted to int as %u)", 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)) if (child->getPropertyByName("visit_time_min", tmpStr))
{ {
stayTimeMin = atoi(tmpStr.c_str()); NLMISC::fromString(tmpStr, stayTimeMin);
} }
if (child->getPropertyByName("visit_time_max", tmpStr)) if (child->getPropertyByName("visit_time_max", tmpStr))
{ {
stayTimeMax = atoi(tmpStr.c_str()); NLMISC::fromString(tmpStr, stayTimeMax);
} }
if (child->getPropertyByName("index", tmpStr)) if (child->getPropertyByName("index", tmpStr))
{ {
index = atoi(tmpStr.c_str()); NLMISC::fromString(tmpStr, index);
} }
child->getPropertyByName("index_next", indexNext); child->getPropertyByName("index_next", indexNext);
if (child->getPropertyByName("flag_spawn", tmpStr)) if (child->getPropertyByName("flag_spawn", tmpStr))
@ -1283,7 +1284,7 @@ static void parsePopulation(const IPrimitive *prim, std::string &sheet, uint &co
sheet = s+".creature"; sheet = s+".creature";
} }
count=atoi(countStr.c_str()); NLMISC::fromString(countStr, count);
if (count<=0) if (count<=0)
{ {
throw parsePopException(std::string("FAUNA_SPAWN_ATOM property 'count' invalid: ")+countStr); 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; uint32 weight = 0;
if (prim->getPropertyByName("weight",s)) if (prim->getPropertyByName("weight",s))
{ {
weight=atoi(s.c_str()); NLMISC::fromString(s, weight);
if (toString(weight)!=s) if (toString(weight)!=s)
{ {
nlwarning("weight invalid value: %s"); nlwarning("weight invalid value: %s");
@ -1886,7 +1887,8 @@ static void parsePrimGrpNpc(const CAIAliasDescriptionNode *treeNode,const IPrimi
} }
prim->getPropertyByName("count",s); prim->getPropertyByName("count",s);
uint botCount=atoi(s.c_str()); uint botCount;
NLMISC::fromString(s, botCount);
if (foundBots && botCount != 0) if (foundBots && botCount != 0)
{ {
@ -2679,7 +2681,7 @@ static void parsePrimBotTemplate(const CAIAliasDescriptionNode *aliasNode, const
prim->getPropertyByName("sheet_look", lookSheet); prim->getPropertyByName("sheet_look", lookSheet);
multiLevel = true; multiLevel = true;
prim->getPropertyByName("level_delta", s); prim->getPropertyByName("level_delta", s);
levelDelta = atoi(s.c_str()); NLMISC::fromString(s, levelDelta);
} }
else else
{ {
@ -2729,7 +2731,7 @@ static void parsePrimGroupTemplate(const CAIAliasDescriptionNode *aliasNode, con
sint32 levelDelta = 0; sint32 levelDelta = 0;
prim->getPropertyByName("count", s); prim->getPropertyByName("count", s);
botCount = atoi(s.c_str()); NLMISC::fromString(s, botCount);
prim->getPropertyByName("count_multiplied_by_sheet", s); prim->getPropertyByName("count_multiplied_by_sheet", s);
countMultipliedBySheet = (s == "true"); countMultipliedBySheet = (s == "true");
@ -2748,7 +2750,7 @@ static void parsePrimGroupTemplate(const CAIAliasDescriptionNode *aliasNode, con
prim->getPropertyByName("bot_sheet_look", lookSheet); prim->getPropertyByName("bot_sheet_look", lookSheet);
multiLevel = true; multiLevel = true;
prim->getPropertyByName("level_delta", s); prim->getPropertyByName("level_delta", s);
levelDelta = atoi(s.c_str()); NLMISC::fromString(s, levelDelta);
} }
else else
{ {
@ -2773,13 +2775,13 @@ static void parsePrimGroupTemplate(const CAIAliasDescriptionNode *aliasNode, con
seasons[3] = (s == "true"); seasons[3] = (s == "true");
prim->getPropertyByName("weight_0_25", s); prim->getPropertyByName("weight_0_25", s);
weights[0] = atoi(s.c_str()); NLMISC::fromString(s, weights[0]);
prim->getPropertyByName("weight_25_50", s); prim->getPropertyByName("weight_25_50", s);
weights[1] = atoi(s.c_str()); NLMISC::fromString(s, weights[1]);
prim->getPropertyByName("weight_50_75", s); prim->getPropertyByName("weight_50_75", s);
weights[2] = atoi(s.c_str()); NLMISC::fromString(s, weights[2]);
prim->getPropertyByName("weight_75_100", s); prim->getPropertyByName("weight_75_100", s);
weights[3] = atoi(s.c_str()); NLMISC::fromString(s, weights[3]);
vector<string> *actParams = &EmptyStringVector; vector<string> *actParams = &EmptyStringVector;

View file

@ -756,7 +756,9 @@ ENTITY_VARIABLE(HP, "Hit points of a player")
} }
else 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 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 else
{ {
uint32 val = atoi(value.substr(1).c_str()); uint32 val;
NLMISC::fromString(value.substr(1), val);
if(dir == 1) if(dir == 1)
guild->addMoney(val); guild->addMoney(val);
else else
@ -941,11 +946,14 @@ ENTITY_VARIABLE(FactionPoint, "FactionPoint")
if(dir == 0) if(dir == 0)
{ {
c->setFactionPoint(clan, atoi(sNumber.c_str()), true); uint32 val;
NLMISC::fromString(sNumber, val);
c->setFactionPoint(clan, val, true);
} }
else else
{ {
uint32 val = atoi(sNumber.substr(1).c_str()); uint32 val;
NLMISC::fromString(sNumber.substr(1), val);
if(dir == 1) if(dir == 1)
c->setFactionPoint(clan, c->getFactionPoint(clan)+val, true); c->setFactionPoint(clan, c->getFactionPoint(clan)+val, true);
else else
@ -1142,7 +1150,9 @@ ENTITY_VARIABLE(Position, "Position of a player (in meter) <eid> <posx>,<posy>[,
if (res.size() >= 4) if (res.size() >= 4)
{ {
// season included // 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 else
{ {
@ -1171,7 +1181,9 @@ NLMISC_COMMAND(changeMode," change_mode","<entity id(id:type:crea:dyn)> <mode>")
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); 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; CEntityBase *e = 0;
if( id.getType() == 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]; string sheetName = args[1];
CSheetId sheet; CSheetId sheet;
uint32 sheetId = atoi(sheetName.c_str()); uint32 sheetId;
NLMISC::fromString(sheetName, sheetId);
if (sheetId != 0) if (sheetId != 0)
{ {
sheet = CSheetId(sheetId); sheet = CSheetId(sheetId);
@ -1276,14 +1289,16 @@ NLMISC_COMMAND (createItemInBag, "Create an item and put it in the player bag",
return false; return false;
} }
sint quantity = atoi(args[2].c_str()); sint quantity;
NLMISC::fromString(args[2], quantity);
if (quantity < 1) if (quantity < 1)
{ {
log.displayNL ("Quantity must be > 0"); log.displayNL ("Quantity must be > 0");
return false; return false;
} }
sint quality = atoi(args[3].c_str()); sint quality;
NLMISC::fromString(args[3], quality);
if (quality < 1) if (quality < 1)
{ {
log.displayNL ("Quality must be > 0"); 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]; string sheetName = args[1];
CSheetId sheet; CSheetId sheet;
uint32 sheetId = atoi(sheetName.c_str()); uint32 sheetId;
NLMISC::fromString(sheetName, sheetId);
if (sheetId != 0) if (sheetId != 0)
{ {
sheet = CSheetId(sheetId); sheet = CSheetId(sheetId);
@ -1363,14 +1379,16 @@ NLMISC_COMMAND (createItemInTmpInv, "Create an item and put it in the player tem
return false; return false;
} }
sint quantity = atoi(args[2].c_str()); sint quantity;
NLMISC::fromString(args[2], quantity);
if (quantity < 1) if (quantity < 1)
{ {
log.displayNL ("Quantity must be > 0"); log.displayNL ("Quantity must be > 0");
return false; return false;
} }
sint quality = atoi(args[3].c_str()); sint quality;
NLMISC::fromString(args[3], quality);
if (quality < 1) if (quality < 1)
{ {
log.displayNL ("Quality must be > 0"); 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]; string sheetName = args[2];
CSheetId sheet; CSheetId sheet;
uint32 sheetId = atoi(sheetName.c_str()); uint32 sheetId;
NLMISC::fromString(sheetName, sheetId);
if (sheetId != 0) if (sheetId != 0)
{ {
sheet = CSheetId(sheetId); sheet = CSheetId(sheetId);
@ -1433,21 +1452,25 @@ NLMISC_COMMAND (createItemInInv, "Create items and put them in the given invento
return false; return false;
} }
sint quantity = atoi(args[3].c_str()); sint quantity;
NLMISC::fromString(args[3], quantity);
if (quantity < 1) if (quantity < 1)
{ {
log.displayNL ("Quantity must be > 0"); log.displayNL ("Quantity must be > 0");
return false; return false;
} }
sint quality = atoi(args[4].c_str()); sint quality;
NLMISC::fromString(args[4], quality);
if (quality < 1) if (quality < 1)
{ {
log.displayNL ("Quality must be > 0"); log.displayNL ("Quality must be > 0");
return false; 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; uint nbCreatedItems = 0;
for (uint i = 0; i < nbItems; i++) for (uint i = 0; i < nbItems; i++)
{ {
@ -1479,7 +1502,7 @@ NLMISC_COMMAND(createNamedItemInBag, "create a named item in bag", "<eId> <item>
uint16 quantity; uint16 quantity;
if (args.size() == 3) if (args.size() == 3)
{ {
quantity = (uint16)atoi(args[2].c_str()); NLMISC::fromString(args[2], quantity);
if (quantity == 0) if (quantity == 0)
{ {
log.displayNL("invalid quantity '%s'", args[2].c_str()); 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 &race = args[1];
const string &type = args[2]; 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 uint16 min = quality - (quality-1)%5;
const string minStr = (min < 10) ? string("0") + toString(min) : toString(min); 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; if ( args.size() != 2 ) return false;
GET_CHARACTER GET_CHARACTER
uint i = atoi( args[1].c_str() ); uint i;
NLMISC::fromString(args[1], i);
uint nbSuccess = 0, nbFail = 0; uint nbSuccess = 0, nbFail = 0;
const CAllRolemasterPhrases& phrases = CSheets::getSRolemasterPhrasesMap(); 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 // Set the new satiety
string result; string result;
uint petIndex = atoi( args[1].c_str() ); uint petIndex;
NLMISC::fromString(args[1], petIndex);
float previousSatiety, maxSatiety; float previousSatiety, maxSatiety;
if ( c->getAnimalSatiety( petIndex, 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; if (args.size () < 2) return false;
GET_CHARACTER GET_CHARACTER
uint petIndex = atoi( args[1].c_str() ); uint petIndex;
NLMISC::fromString(args[1], petIndex);
if ( c ) if ( c )
{ {
// Get the satiety // Get the satiety
@ -2271,7 +2298,8 @@ NLMISC_COMMAND (addXPToSkill, "Gain experience in a given skills", "<eid> <xp> <
if (args.size () < 3) return false; if (args.size () < 3) return false;
GET_CHARACTER GET_CHARACTER
uint32 xp = atoi (args[1].c_str()); uint32 xp;
NLMISC::fromString(args[1], xp);
string skill = args[2]; string skill = args[2];
@ -2279,7 +2307,7 @@ NLMISC_COMMAND (addXPToSkill, "Gain experience in a given skills", "<eid> <xp> <
if(args.size()==3) if(args.size()==3)
count = 1; count = 1;
else else
count = atoi(args[3].c_str()); NLMISC::fromString(args[3], count);
count = min( count, (uint)100); count = min( count, (uint)100);
@ -2418,7 +2446,8 @@ NLMISC_COMMAND(execPhrase,"execute a sabrina phrase","<player id(id:type:crea:dy
if ( args.size() >= 3 ) if ( args.size() >= 3 )
{ {
GET_CHARACTER GET_CHARACTER
bool cyclic = atoi(args[1].c_str()) != 0; bool cyclic;
NLMISC::fromString(args[1], cyclic);
vector<CSheetId> brickIds; vector<CSheetId> brickIds;
for (uint i = 2 ; i < args.size() ; ++i) for (uint i = 2 ; i < args.size() ; ++i)
@ -2443,7 +2472,8 @@ NLMISC_COMMAND(executeSabrinaPhrase,"execute a sabrina phrase, an sphrase","<pla
{ {
GET_CHARACTER GET_CHARACTER
bool cyclic = atoi(args[1].c_str()) != 0; bool cyclic;
NLMISC::fromString(args[1], cyclic);
CSheetId phraseSheet(args[2]); CSheetId phraseSheet(args[2]);
CPhraseManager::getInstance().executePhrase(c->getEntityRowId(), c->getTargetDataSetRow(), phraseSheet, cyclic); CPhraseManager::getInstance().executePhrase(c->getEntityRowId(), c->getTargetDataSetRow(), phraseSheet, cyclic);
@ -2464,7 +2494,8 @@ NLMISC_COMMAND(memorizePhrase,"memorize a sabrina phrase","<player id(id:type:cr
CEntityId id; CEntityId id;
id.fromString(args[0].c_str()); id.fromString(args[0].c_str());
uint8 index = (uint8) atoi(args[1].c_str()); uint8 index;
NLMISC::fromString(args[1], index);
CCharacter * c = PlayerManager.getChar( id ); CCharacter * c = PlayerManager.getChar( id );
if (c ) if (c )
@ -2499,8 +2530,10 @@ NLMISC_COMMAND(execMemorizedPhrase,"memorize a memorized sabrina phrase","<playe
CEntityId id; CEntityId id;
id.fromString(args[0].c_str()); id.fromString(args[0].c_str());
uint8 index = (uint8) atoi(args[1].c_str()); uint8 index;
bool cyclic = (atoi(args[2].c_str()) == 1); NLMISC::fromString(args[1], index);
bool cyclic;
NLMISC::fromString(args[2], cyclic);
CCharacter * c = PlayerManager.getChar( id ); CCharacter * c = PlayerManager.getChar( id );
if (c ) if (c )
@ -2529,8 +2562,11 @@ NLMISC_COMMAND(respawnAfterDeath,"respawnAfterDeath at re-spawn point name, it m
{ {
GET_CHARACTER GET_CHARACTER
uint16 idx;
NLMISC::fromString(args[1], idx);
// A death character can choose to re-spawn to a previously validated re-spawn point, a last of one re-spawn point is always valid // A death character can choose to re-spawn to a previously validated re-spawn point, a last of one re-spawn point is always valid
c->respawn( atoi(args[1].c_str() ) ); c->respawn(idx);
return true; return true;
} }
@ -2582,7 +2618,9 @@ NLMISC_COMMAND(validateRespawnPoint,"Validate re-spawn point","<player id(id:typ
{ {
GET_CHARACTER GET_CHARACTER
c->getRespawnPoints().addRespawnPoint(atoi( args[1].c_str() )); CCharacterRespawnPoints::TRespawnPoint respawnPoint;
NLMISC::fromString(args[1], respawnPoint);
c->getRespawnPoints().addRespawnPoint(respawnPoint);
return true; return true;
} }
return false; return false;
@ -2606,7 +2644,8 @@ NLMISC_COMMAND(setItemSapLoad,"set an item sap load","<eId><slot index in bag (s
return false; return false;
GET_CHARACTER GET_CHARACTER
uint slot = atoi(args[1].c_str()); uint slot;
NLMISC::fromString(args[1], slot);
float value = (float)atof(args[2].c_str()); float value = (float)atof(args[2].c_str());
// vector<CGameItemPtr>& items = (vector<CGameItemPtr> &)c->getInventory()[INVENTORIES::bag]->getChildren(); // vector<CGameItemPtr>& items = (vector<CGameItemPtr> &)c->getInventory()[INVENTORIES::bag]->getChildren();
CInventoryPtr invent = c->getInventory(INVENTORIES::bag); CInventoryPtr invent = c->getInventory(INVENTORIES::bag);
@ -2686,7 +2725,9 @@ NLMISC_COMMAND( summonPet, "player can summon it's pet one time only", "<eid><Pe
return false; return false;
GET_CHARACTER 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(); const std::vector< CPetAnimal >& pet = c->getPlayerPets();
if( index < pet.size() ) if( index < pet.size() )
{ {
@ -2710,7 +2751,9 @@ NLMISC_COMMAND( allowSummonPet, "autorize player summon it's pet one time only",
return false; return false;
GET_CHARACTER 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(); const std::vector< CPetAnimal >& pet = c->getPlayerPets();
if( index < pet.size() ) if( index < pet.size() )
@ -2775,6 +2818,7 @@ void cbClientAdmin (NLNET::CMessage& msgin, const std::string &serviceName, NLNE
CEntityId eid; CEntityId eid;
CEntityId targetEid;
msgin.serial (eid); msgin.serial (eid);
bool onTarget; bool onTarget;
@ -3491,7 +3535,9 @@ NLMISC_COMMAND( root, "root a player", "<CSR id><player name><time in second>" )
} }
CHECK_RIGHT( c,target ); CHECK_RIGHT( c,target );
NLMISC::TGameCycle cycle = (NLMISC::TGameCycle) ( atoi(args[2].c_str()) / CTickEventHandler::getGameTimeStep() + CTickEventHandler::getGameCycle() ); NLMISC::TGameCycle cycle;
NLMISC::fromString(args[2], cycle);
cycle = TGameCycle(NLMISC::TGameTime(cycle) / CTickEventHandler::getGameTimeStep() + CTickEventHandler::getGameCycle());
PlayerManager.addGMRoot( eid, target->getId(), cycle ); PlayerManager.addGMRoot( eid, target->getId(), cycle );
return true; return true;
} }
@ -3610,7 +3656,10 @@ NLMISC_COMMAND( failMission, "force mission failure", "<CSR id><mission idx>" )
if ( args.size() != 2 ) if ( args.size() != 2 )
return false; return false;
GET_CHARACTER; GET_CHARACTER;
CMission * mission = c->getAdminProperties().getMission( atoi(args[1].c_str() ) );
uint index;
NLMISC::fromString(args[1], index);
CMission * mission = c->getAdminProperties().getMission(index);
if ( !mission ) if ( !mission )
{ {
CCharacter::sendDynamicSystemMessage( c->getEntityRowId(), "CSR_BAD_MISSION" ); CCharacter::sendDynamicSystemMessage( c->getEntityRowId(), "CSR_BAD_MISSION" );
@ -3626,7 +3675,10 @@ NLMISC_COMMAND( progressMission, "force mission progression", "<CSR id><mission
if ( args.size() != 2 || args.size() != 3 ) if ( args.size() != 2 || args.size() != 3 )
return false; return false;
GET_CHARACTER; GET_CHARACTER;
CMission * mission = c->getAdminProperties().getMission( atoi(args[1].c_str() ) );
uint index;
NLMISC::fromString(args[1], index);
CMission * mission = c->getAdminProperties().getMission(index);
if ( !mission ) if ( !mission )
{ {
CCharacter::sendDynamicSystemMessage( c->getEntityRowId(), "CSR_BAD_MISSION" ); CCharacter::sendDynamicSystemMessage( c->getEntityRowId(), "CSR_BAD_MISSION" );
@ -3635,7 +3687,7 @@ NLMISC_COMMAND( progressMission, "force mission progression", "<CSR id><mission
CCharacter * user = mission->getMainEntity(); CCharacter * user = mission->getMainEntity();
uint repeat = 1; uint repeat = 1;
if ( args.size() == 3 ) if ( args.size() == 3 )
repeat = (uint)atoi( args[2].c_str() ); NLMISC::fromString(args[2], repeat);
CMissionEventDebug event; CMissionEventDebug event;
for ( uint i = 0; i < repeat; i++ ) for ( uint i = 0; i < repeat; i++ )
user->processMissionEvent(event); user->processMissionEvent(event);
@ -3680,7 +3732,9 @@ NLMISC_COMMAND (mute, "mute a user", "<csr id> <player name><duration>")
return true; return true;
} }
CHECK_RIGHT( c,target ); CHECK_RIGHT( c,target );
NLMISC::TGameCycle cycle = (NLMISC::TGameCycle) ( atoi(args[2].c_str()) / CTickEventHandler::getGameTimeStep() + CTickEventHandler::getGameCycle() ); uint32 duration;
NLMISC::fromString(args[2], duration);
NLMISC::TGameCycle cycle = (NLMISC::TGameCycle) ( duration / CTickEventHandler::getGameTimeStep() + CTickEventHandler::getGameCycle() );
PlayerManager.addGMMute( eid, target->getId(), cycle ); PlayerManager.addGMMute( eid, target->getId(), cycle );
return true; return true;
} }
@ -3748,7 +3802,9 @@ NLMISC_COMMAND (muteUniverse, "mute the univers chat", "<csr id><player name><du
return true; return true;
} }
NLMISC::TGameCycle cycle = (NLMISC::TGameCycle) ( atoi(args[2].c_str()) / CTickEventHandler::getGameTimeStep() + CTickEventHandler::getGameCycle() ); uint32 duration;
NLMISC::fromString(args[2], duration);
NLMISC::TGameCycle cycle = (NLMISC::TGameCycle) (duration / CTickEventHandler::getGameTimeStep() + CTickEventHandler::getGameCycle() );
PlayerManager.muteUniverse( eid, cycle, target->getId() ); PlayerManager.muteUniverse( eid, cycle, target->getId() );
return true; return true;
} }
@ -3916,7 +3972,8 @@ NLMISC_COMMAND (infos, "give info on character (GodMode, Invisible...)", "")
// return false; // return false;
// //
// GET_GUILD(0, true, NLMISC::CEntityId::Unknown); // GET_GUILD(0, true, NLMISC::CEntityId::Unknown);
// sint xp = atoi( args[1].c_str() ); // sint xp;
// NLMISC::fromString(args[1], xp);
// if ( xp < 0 ) // if ( xp < 0 )
// { // {
// uint32 uXP = (uint32)(-xp); // uint32 uXP = (uint32)(-xp);
@ -3940,7 +3997,8 @@ NLMISC_COMMAND (infos, "give info on character (GodMode, Invisible...)", "")
// if ( args.size() != 2 ) // if ( args.size() != 2 )
// return false; // return false;
// GET_GUILD(0, true, NLMISC::CEntityId::Unknown); // GET_GUILD(0, true, NLMISC::CEntityId::Unknown);
// uint32 points = uint32(atoi( args[1].c_str() )); // uint32 points;
// NLMISC::fromString(args[1], points);
// guild->clearChargePoints(); // guild->clearChargePoints();
// guild->addChargePoints( points ); // guild->addChargePoints( points );
// log.displayNL( "set charge points to %u", points ); // log.displayNL( "set charge points to %u", points );
@ -4077,7 +4135,7 @@ NLMISC_COMMAND(broadcast,"[repeat=<num repeat> or during=<time in seconds>] [eve
string::size_type posEgale = message.find("=", pos); string::size_type posEgale = message.find("=", pos);
if( posEgale != string::npos ) if( posEgale != string::npos )
{ {
repeat = atoi( message.substr( posEgale+1 ).c_str() ); NLMISC::fromString(message.substr( posEgale+1 ), repeat);
if( posEgale + 1 > posMessage ) if( posEgale + 1 > posMessage )
posMessage = posEgale + 1; posMessage = posEgale + 1;
} }
@ -4089,7 +4147,7 @@ NLMISC_COMMAND(broadcast,"[repeat=<num repeat> or during=<time in seconds>] [eve
string::size_type posEgale = message.find("=", pos); string::size_type posEgale = message.find("=", pos);
if( posEgale != string::npos ) if( posEgale != string::npos )
{ {
during = atoi( message.substr( posEgale+1 ).c_str() ); NLMISC::fromString(message.substr( posEgale+1 ), during);
if( posEgale + 1 > posMessage ) if( posEgale + 1 > posMessage )
posMessage = posEgale + 1; posMessage = posEgale + 1;
} }
@ -4101,7 +4159,7 @@ NLMISC_COMMAND(broadcast,"[repeat=<num repeat> or during=<time in seconds>] [eve
string::size_type posEgale = message.find("=", pos); string::size_type posEgale = message.find("=", pos);
if( posEgale != string::npos ) if( posEgale != string::npos )
{ {
every = atoi( message.substr( posEgale+1 ).c_str() ); NLMISC::fromString(message.substr( posEgale+1 ), every);
if( posEgale + 1 > posMessage ) if( posEgale + 1 > posMessage )
posMessage = posEgale + 1; posMessage = posEgale + 1;
} }
@ -4362,9 +4420,7 @@ NLMISC_COMMAND(lPosFlags, "list position flags (short format)", "<csr_eid> [<rad
uint32 radius = 0; uint32 radius = 0;
if (args.size() == 2) if (args.size() == 2)
{ {
int arg = atoi(args[1].c_str()); NLMISC::fromString(args[1], radius);
if (arg > 0)
radius = arg;
} }
CPositionFlagManager::getInstance().sendFlagsList(eid, true, radius); CPositionFlagManager::getInstance().sendFlagsList(eid, true, radius);
@ -4382,9 +4438,7 @@ NLMISC_COMMAND(listPosFlags, "list position flags (long format)", "<csr_eid> [<r
uint32 radius = 0; uint32 radius = 0;
if (args.size() == 2) if (args.size() == 2)
{ {
int arg = atoi(args[1].c_str()); NLMISC::fromString(args[1], radius);
if (arg > 0)
radius = arg;
} }
CPositionFlagManager::getInstance().sendFlagsList(eid, false, radius); CPositionFlagManager::getInstance().sendFlagsList(eid, false, radius);
@ -4782,7 +4836,8 @@ NLMISC_COMMAND(setPvpClan, "set the pv clan for player", "<csr eid> <clan number
TRY_GET_CHARACTER; TRY_GET_CHARACTER;
uint8 clan = atoi(args[1].c_str()); uint8 clan;
NLMISC::fromString(args[1], clan);
if ( c && c->getEnterFlag() ) if ( c && c->getEnterFlag() )
{ {
@ -4821,7 +4876,7 @@ NLMISC_COMMAND(startEvent, "start an event with the given name", "<csr eid> <eve
if( args.size() > 6 ) if( args.size() > 6 )
{ {
factionChanelInZoneOnly = atoi(args[6].c_str()) != 0; NLMISC::fromString(args[6], factionChanelInZoneOnly);
} }
} }
@ -5076,7 +5131,8 @@ NLMISC_COMMAND(setChanHistoricSize, "Set size of the historic for a localized ch
nlwarning("Unknown channel : %s", args[0].c_str()); nlwarning("Unknown channel : %s", args[0].c_str());
return true; return true;
} }
uint historicSize = atoi(args[1].c_str()); uint historicSize;
NLMISC::fromString(args[1], historicSize);
// //
if (historicSize > 1000) if (historicSize > 1000)
{ {
@ -5100,9 +5156,9 @@ NLMISC_COMMAND(addChanClient, "add a client to a channel", "<client name or user
return true; return true;
} }
bool writeRight = true; bool writeRight = true;
if (args.size() > 2 && atoi(args[2].c_str()) == 1) if (args.size() > 2)
{ {
writeRight = true; NLMISC::fromString(args[2], writeRight);
} }
bool res = DynChatEGS.addSession(chanID, c->getEntityRowId(), writeRight); bool res = DynChatEGS.addSession(chanID, c->getEntityRowId(), writeRight);
if (!res) if (!res)
@ -5144,7 +5200,9 @@ NLMISC_COMMAND(setChanClientWriteRight, "set write right for a client in the giv
nlwarning("Unknown channel : %s", args[1].c_str()); nlwarning("Unknown channel : %s", args[1].c_str());
return true; return true;
} }
bool res = DynChatEGS.setWriteRight(chanID, c->getEntityRowId(), atoi(args[2].c_str()) != 0); bool canWrite;
NLMISC::fromString(args[2], canWrite);
bool res = DynChatEGS.setWriteRight(chanID, c->getEntityRowId(), canWrite);
if (!res) if (!res)
{ {
nlwarning("Couldn't remove character %s from channel %s", args[0].c_str(), args[1].c_str()); nlwarning("Couldn't remove character %s from channel %s", args[0].c_str(), args[1].c_str());
@ -5181,10 +5239,13 @@ ENTITY_VARIABLE (Aggro, "Aggroable by creatures")
TDataSetRow userRow = TheDataset.getDataSetRow( c->getId() ); TDataSetRow userRow = TheDataset.getDataSetRow( c->getId() );
if ( !TheDataset.isAccessible( userRow ) ) if ( !TheDataset.isAccessible( userRow ) )
return; return;
c->setAggroableOverride(atoi(value.c_str()));
c->setAggroableSave(atoi(value.c_str()));
sint8 aggroable = c->getAggroableOverride(); sint8 aggroable;
NLMISC::fromString(value, aggroable);
c->setAggroableOverride(aggroable);
c->setAggroableSave(aggroable);
aggroable = c->getAggroableOverride();
nlinfo ("%s aggroable = %d", entity.toString().c_str(), aggroable); nlinfo ("%s aggroable = %d", entity.toString().c_str(), aggroable);
if (aggroable>0) if (aggroable>0)
nlinfo ("%s is now aggroable", entity.toString().c_str()); nlinfo ("%s is now aggroable", entity.toString().c_str());
@ -5202,11 +5263,12 @@ NLMISC_COMMAND(acceptProposalForQueue, "player accept to enter critical part (fo
if (args.size() < 2 || args.size() > 3 ) return false; if (args.size() < 2 || args.size() > 3 ) return false;
CEntityId eid(args[0]); CEntityId eid(args[0]);
bool accept = atoi(args[1].c_str()) != 0; bool accept;
NLMISC::fromString(args[1], accept);
uint32 queueId = 0; uint32 queueId = 0;
if (args.size() == 3) if (args.size() == 3)
queueId = atoi(args[1].c_str()); NLMISC::fromString(args[1], queueId);
else else
{ {
CCharacter *player = PlayerManager.getChar(eid); CCharacter *player = PlayerManager.getChar(eid);
@ -5225,7 +5287,8 @@ NLMISC_COMMAND(awakePlayerInQueue, "awake player in given queue", "<eid> <queueI
if (args.size() != 2) return false; if (args.size() != 2) return false;
CEntityId eid(args[0]); CEntityId eid(args[0]);
uint32 queueId = atoi(args[1].c_str()); uint32 queueId;
NLMISC::fromString(args[1], queueId);
CMissionQueueManager::getInstance()->playerWakesUp( eid, queueId); CMissionQueueManager::getInstance()->playerWakesUp( eid, queueId);
@ -5331,9 +5394,11 @@ NLMISC_COMMAND(addFactionAttackableToTarget, "Add a faction to attackable list t
CCreature *creature = CreatureManager.getCreature(target); CCreature *creature = CreatureManager.getCreature(target);
if (creature) if (creature)
{ {
const sint32 fameLevel = sint32( atoi(args[2].c_str())*FameAbsoluteMax / 100 ); sint32 fameLevel;
bool above = (atoi(args[3].c_str()) ? true : false); NLMISC::fromString(args[2], fameLevel);
creature->addFactionAttackable(factionIndex, fameLevel, above); bool above;
NLMISC::fromString(args[3], above);
creature->addFactionAttackable(factionIndex, fameLevel * FameAbsoluteMax / 100, above);
} }
} }
} }
@ -5359,7 +5424,8 @@ NLMISC_COMMAND(taskPass, "pass a task from a rite", "<player eid> <rite> [<task>
CCharacterEncyclopedia &rEncy = c->getEncyclopedia(); CCharacterEncyclopedia &rEncy = c->getEncyclopedia();
if( args.size() == 3 ) if( args.size() == 3 )
{ {
uint32 nTask = atoi( args[2].c_str() ); uint32 nTask;
NLMISC::fromString(args[2], nTask);
if( nTask > 7 ) if( nTask > 7 )
{ {
nlwarning("<taskPass> task index too high : %d",nTask); nlwarning("<taskPass> task index too high : %d",nTask);
@ -5395,7 +5461,8 @@ NLMISC_COMMAND(setFamePlayer, "set the fame value of a player in the given facti
string faction = args[1]; string faction = args[1];
uint32 factionIndex = PVP_CLAN::getFactionIndex( PVP_CLAN::fromString(faction) ); uint32 factionIndex = PVP_CLAN::getFactionIndex( PVP_CLAN::fromString(faction) );
sint32 fame = atoi( args[2].c_str() ); sint32 fame;
NLMISC::fromString(args[2], fame);
CFameManager::getInstance().setEntityFame(c->getId(), factionIndex, fame, true); CFameManager::getInstance().setEntityFame(c->getId(), factionIndex, fame, true);
@ -5530,7 +5597,8 @@ NLMISC_COMMAND(eventSetBotScale, "changes the scale of a bot (in % up to 255)",
GET_ENTITY GET_ENTITY
TDataSetRow row = e->getEntityRowId(); TDataSetRow row = e->getEntityRowId();
uint32 scale = atoi(args[1].c_str()); uint32 scale;
NLMISC::fromString(args[1], scale);
if (scale>255) if (scale>255)
scale = 0; scale = 0;
CMirrorPropValue< SAltLookProp2, CPropLocationPacked<2> > visualPropertyB( TheDataset, row, DSPropertyVPB ); CMirrorPropValue< SAltLookProp2, CPropLocationPacked<2> > visualPropertyB( TheDataset, row, DSPropertyVPB );
@ -5739,7 +5807,7 @@ NLMISC_COMMAND(eventSetItemCustomText, "set an item custom text, which replaces
uint32 slot; uint32 slot;
ucstring text; ucstring text;
inventory = INVENTORIES::toInventory(args[1]); inventory = INVENTORIES::toInventory(args[1]);
slot = atoi(args[2].c_str()); NLMISC::fromString(args[2], slot);
text.fromUtf8(args[3]); text.fromUtf8(args[3]);
sint32 ret = clientEventSetItemCustomText(c, inventory, slot, text); sint32 ret = clientEventSetItemCustomText(c, inventory, slot, text);
@ -5780,7 +5848,8 @@ NLMISC_COMMAND(eventResetItemCustomText, "set an item custom text, which replace
log.displayNL("'%s' is not a valid inventory name", args[1].c_str()); log.displayNL("'%s' is not a valid inventory name", args[1].c_str());
return true; return true;
} }
uint32 slot = atoi(args[2].c_str()); uint32 slot;
NLMISC::fromString(args[2], slot);
CInventoryPtr invent = c->getInventory(inventory); CInventoryPtr invent = c->getInventory(inventory);
if (slot >= invent->getSlotCount()) if (slot >= invent->getSlotCount())
{ {
@ -5813,7 +5882,8 @@ NLMISC_COMMAND(useCatalyser, "use an xp catalyser", "<eId> [<slot in bag>]")
} }
GET_CHARACTER GET_CHARACTER
sint32 slot = atoi(args[1].c_str()); sint32 slot;
NLMISC::fromString(args[1], slot);
if( slot > 0 ) if( slot > 0 )
{ {
c->useItem( (uint32)slot ); c->useItem( (uint32)slot );
@ -5919,17 +5989,22 @@ NLMISC_COMMAND(farTPPush, "Far TP a character, but let the current position in t
// Push the new position into the stack // Push the new position into the stack
c->pushCurrentPosition(); c->pushCurrentPosition();
c->PositionStack.topToModify().SessionId = (TSessionId)(uint32)atoi(args[1].c_str()); uint32 sessionId;
NLMISC::fromString(args[1], sessionId);
c->PositionStack.topToModify().SessionId = TSessionId(sessionId);
if ( args.size() > 3 ) if ( args.size() > 3 )
{ {
c->PositionStack.topToModify().PosState.X = atoi(args[2].c_str()) * 1000; NLMISC::fromString(args[2], c->PositionStack.topToModify().PosState.X);
c->PositionStack.topToModify().PosState.Y = atoi(args[3].c_str()) * 1000; c->PositionStack.topToModify().PosState.X *= 1000;
NLMISC::fromString(args[3], c->PositionStack.topToModify().PosState.Y);
c->PositionStack.topToModify().PosState.Y *= 1000;
if ( args.size() > 4 ) if ( args.size() > 4 )
{ {
c->PositionStack.topToModify().PosState.Z = atoi(args[4].c_str()) * 1000; NLMISC::fromString(args[4], c->PositionStack.topToModify().PosState.Z);
c->PositionStack.topToModify().PosState.Z *= 1000;
if ( args.size() > 5 ) if ( args.size() > 5 )
{ {
c->PositionStack.topToModify().PosState.Heading = (float)atof(args[5].c_str()); NLMISC::fromString(args[5], c->PositionStack.topToModify().PosState.Heading);
} }
} }
} }
@ -5953,17 +6028,22 @@ NLMISC_COMMAND(farTPReplace, "Far TP a character. Pos in meters. Default values
c->pushCurrentPosition(); c->pushCurrentPosition();
if ( args.size() > 1 ) // with the same session id: will make the client reconnect if ( args.size() > 1 ) // with the same session id: will make the client reconnect
{ {
c->PositionStack.topToModify().SessionId = (TSessionId)(uint32)atoi(args[1].c_str()); uint32 sessionId;
NLMISC::fromString(args[1], sessionId);
c->PositionStack.topToModify().SessionId = TSessionId(sessionId);
if ( args.size() > 3 ) if ( args.size() > 3 )
{ {
c->PositionStack.topToModify().PosState.X = atoi(args[2].c_str()) * 1000; NLMISC::fromString(args[2], c->PositionStack.topToModify().PosState.X);
c->PositionStack.topToModify().PosState.Y = atoi(args[3].c_str()) * 1000; c->PositionStack.topToModify().PosState.X *= 1000;
NLMISC::fromString(args[3], c->PositionStack.topToModify().PosState.Y);
c->PositionStack.topToModify().PosState.Y *= 1000;
if ( args.size() > 4 ) if ( args.size() > 4 )
{ {
c->PositionStack.topToModify().PosState.Z = atoi(args[4].c_str()) * 1000; NLMISC::fromString(args[4], c->PositionStack.topToModify().PosState.Z);
c->PositionStack.topToModify().PosState.Z *= 1000;
if ( args.size() > 5 ) if ( args.size() > 5 )
{ {
c->PositionStack.topToModify().PosState.Heading = (float)atof(args[5].c_str()); NLMISC::fromString(args[5], c->PositionStack.topToModify().PosState.Heading);
} }
} }
} }
@ -6004,7 +6084,8 @@ NLMISC_COMMAND(farTPSubst, "Substitute a position in the stack (no immediate far
} }
// Access the specified position in the stack // Access the specified position in the stack
uint index = atoi(args[1].c_str()); uint index;
NLMISC::fromString(args[1], index);
if ( c->PositionStack.size() <= index ) if ( c->PositionStack.size() <= index )
{ {
log.displayNL( "Index out of bounds" ); log.displayNL( "Index out of bounds" );
@ -6013,14 +6094,19 @@ NLMISC_COMMAND(farTPSubst, "Substitute a position in the stack (no immediate far
// Modify // Modify
CFarPosition newFarPos = c->PositionStack[index]; CFarPosition newFarPos = c->PositionStack[index];
newFarPos.SessionId = (TSessionId)(uint32)atoi(args[2].c_str()); uint32 sessionId;
NLMISC::fromString(args[2], sessionId);
newFarPos.SessionId = TSessionId(sessionId);
if ( args.size() > 3 ) if ( args.size() > 3 )
{ {
newFarPos.PosState.X = atoi(args[3].c_str()) * 1000; NLMISC::fromString(args[3], newFarPos.PosState.X);
newFarPos.PosState.Y = atoi(args[4].c_str()) * 1000; newFarPos.PosState.X *= 1000;
NLMISC::fromString(args[4], newFarPos.PosState.Y);
newFarPos.PosState.Y *= 1000;
if ( args.size() > 5 ) if ( args.size() > 5 )
{ {
newFarPos.PosState.Z = atoi(args[5].c_str()) * 1000; NLMISC::fromString(args[5], newFarPos.PosState.Z);
newFarPos.PosState.Z *= 1000;
if ( args.size() > 6 ) if ( args.size() > 6 )
{ {
newFarPos.PosState.Heading = (float)atof(args[6].c_str()); newFarPos.PosState.Heading = (float)atof(args[6].c_str());
@ -6117,7 +6203,8 @@ NLMISC_COMMAND(quitDelay, "Inform the player that the shard will be stopped in N
if (args.size() != 1) if (args.size() != 1)
return false; return false;
sint delay = atoi(args[0].c_str()); sint delay;
NLMISC::fromString(args[0], delay);
SM_STATIC_PARAMS_1(params, STRING_MANAGER::integer); SM_STATIC_PARAMS_1(params, STRING_MANAGER::integer);

View file

@ -46,7 +46,8 @@ NLMISC_COMMAND(simGpmsTriggerIn,"simulate the buying of a guild building","<user
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
TDataSetRow rowId = TheDataset.getDataSetRow( id ); TDataSetRow rowId = TheDataset.getDataSetRow( id );
uint32 liftId = atoi( args[1].c_str() ); uint32 liftId;
NLMISC::fromString(args[1], liftId);
CBuildingManager::getInstance()->addTriggerRequest( rowId, (uint32)liftId ); CBuildingManager::getInstance()->addTriggerRequest( rowId, (uint32)liftId );
return true; return true;
} }
@ -94,7 +95,8 @@ NLMISC_COMMAND(dumpBuilding, "dump building infos", "<building_name = building_i
const string & buildingId = args[0]; const string & buildingId = args[0];
if (buildingId.size() > 0 && isdigit(buildingId[0])) if (buildingId.size() > 0 && isdigit(buildingId[0]))
{ {
TAIAlias alias = atoi(buildingId.c_str()); TAIAlias alias;
NLMISC::fromString(buildingId, alias);
building = CBuildingManager::getInstance()->getBuildingPhysicalsByAlias(alias); building = CBuildingManager::getInstance()->getBuildingPhysicalsByAlias(alias);
} }
else else
@ -113,7 +115,9 @@ NLMISC_COMMAND(removeGuildBuilding, "(DEBUG) remove guild building", "<guild id>
if (args.size() != 1) if (args.size() != 1)
return false; return false;
CBuildingManager::getInstance()->removeGuildBuilding( atoi(args[0].c_str()) ); uint32 guildId;
NLMISC::fromString(args[0], guildId);
CBuildingManager::getInstance()->removeGuildBuilding(guildId);
return true; return true;
} }

View file

@ -235,7 +235,8 @@ bool CBuildingManager::parsePhysicalBuildings( const NLLIGO::IPrimitive* prim, C
{ {
TAIAlias alias; TAIAlias alias;
nlverify( CPrimitivesParser::getAlias(prim, alias)); nlverify( CPrimitivesParser::getAlias(prim, alias));
//* TAIAlias alias = atoi( value.c_str() ); // TAIAlias alias;
// NLMISC::fromString(value, alias);
if ( _BuildingPhysicals.find( alias ) != _BuildingPhysicals.end() ) if ( _BuildingPhysicals.find( alias ) != _BuildingPhysicals.end() )
{ {
nlwarning("<BUILDING>building instance %s exists more than once", CPrimitivesParser::aliasToString(alias).c_str()); nlwarning("<BUILDING>building instance %s exists more than once", CPrimitivesParser::aliasToString(alias).c_str());
@ -294,7 +295,8 @@ bool CBuildingManager::parseTriggers( const NLLIGO::IPrimitive* prim, CBuildingP
std::string name; std::string name;
nlverify( prim->getPropertyByName("name",name) ); nlverify( prim->getPropertyByName("name",name) );
nlverify( prim->getPropertyByName("pacs_trigger_id",value) ); nlverify( prim->getPropertyByName("pacs_trigger_id",value) );
uint32 triggerId = (uint32) atoi( value.c_str() ); uint32 triggerId;
NLMISC::fromString(value, triggerId);
if ( triggerId == 0 && CMissionParser::getNoBlankString( value ) != "0" ) if ( triggerId == 0 && CMissionParser::getNoBlankString( value ) != "0" )
{ {

View file

@ -643,11 +643,11 @@ NLMISC_COMMAND (testBuildingManager, "(debug) Unit test for building manager",
} }
else if (args.size() == 5) else if (args.size() == 5)
{ {
nbChars = atoi( args[0].c_str() ); NLMISC::fromString(args[0], nbChars);
nbOps = atoi( args[1].c_str() ); NLMISC::fromString(args[1], nbOps);
nbSimultaneous = atoi( args[2].c_str() ); NLMISC::fromString(args[2], nbSimultaneous);
opDelay = atoi( args[3].c_str() ); NLMISC::fromString(args[3], opDelay);
Verbose = (atoi( args[4].c_str() ) == 1); NLMISC::fromString(args[4], Verbose);
} }
else else
return false; return false;

View file

@ -384,7 +384,8 @@ bool CExitDestination::build( const NLLIGO::IPrimitive* prim,const NLLIGO::IPrim
string value; string value;
// get properties // get properties
nlverify( prim->getPropertyByName("exit_index_in_instance",value) ); nlverify( prim->getPropertyByName("exit_index_in_instance",value) );
_ExitIndex = uint8(atoi( value.c_str() )) - (uint8)1; NLMISC::fromString(value, _ExitIndex);
--_ExitIndex;
if ( _ExitIndex == 0xFF ) if ( _ExitIndex == 0xFF )
{ {
nlwarning("<BUILDING> in destination '%s' invalid building '%s' starts at 1", _Name.c_str(), value.c_str() ); nlwarning("<BUILDING> in destination '%s' invalid building '%s' starts at 1", _Name.c_str(), value.c_str() );

View file

@ -116,7 +116,8 @@ void CDynamicSheetManager::addCustomLootTable(CCustomElementId id, CCustomLootTa
{ {
CStaticLootSet tmplootSet; CStaticLootSet tmplootSet;
string probaStr = it->first.Id; string probaStr = it->first.Id;
uint16 proba = static_cast<uint16>(atoi(probaStr.c_str())); uint16 proba;
NLMISC::fromString(probaStr, proba);
TScriptContent script = it->second; TScriptContent script = it->second;
uint32 lineNb = 0; uint32 lineNb = 0;
@ -135,8 +136,8 @@ void CDynamicSheetManager::addCustomLootTable(CCustomElementId id, CCustomLootTa
CStaticLootSet::SItemLoot item; CStaticLootSet::SItemLoot item;
item.Item = tmpVector[0]; item.Item = tmpVector[0];
item.Level = static_cast<uint16>(atoi(tmpVector[1].c_str())); NLMISC::fromString(tmpVector[1], item.Level);
item.Quantity = static_cast<uint16>(atoi(tmpVector[2].c_str())); NLMISC::fromString(tmpVector[2], item.Quantity);
nldebug("New Item: name='%s' quality=%d quantity=%d", item.Item.c_str(), item.Level, item.Quantity); nldebug("New Item: name='%s' quality=%d quantity=%d", item.Item.c_str(), item.Level, item.Quantity);
tmplootSet.ItemLoot.push_back(item); tmplootSet.ItemLoot.push_back(item);

View file

@ -618,7 +618,7 @@ bool CPlayerSkill::initFromString( const string& skillAndValue )
codeS = "S" + codeS; codeS = "S" + codeS;
} }
Code = SKILLS::toSkill( codeS ); Code = SKILLS::toSkill( codeS );
Value = atoi( skillAndValue.substr( p+1 ).c_str() ); NLMISC::fromString( skillAndValue.substr( p+1 ), Value );
return (Code != SKILLS::unknown); return (Code != SKILLS::unknown);
} }
} }

View file

@ -14,6 +14,9 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RY_EGS_STATIC_BRICK_CPP_H
#define RY_EGS_STATIC_BRICK_CPP_H
#include "nel/misc/smart_ptr.h" #include "nel/misc/smart_ptr.h"
class TBrickParam class TBrickParam
@ -394,7 +397,7 @@ struct CSBrickParamSap : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Sap=atoi(args[0].c_str()); NLMISC::fromString(args[0], Sap);
return *this; return *this;
} }
@ -427,7 +430,7 @@ struct CSBrickParamHp : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Hp=atoi(args[0].c_str()); NLMISC::fromString(args[0], Hp);
return *this; return *this;
} }
@ -460,7 +463,7 @@ struct CSBrickParamSta : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Sta=atoi(args[0].c_str()); NLMISC::fromString(args[0], Sta);
return *this; return *this;
} }
@ -498,7 +501,7 @@ struct CSBrickParamStaWeightFactor : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
StaFactor=(float)atof(args[0].c_str()); StaFactor=(float)atof(args[0].c_str());
StaConst=atoi(args[1].c_str()); NLMISC::fromString(args[1], StaConst);
return *this; return *this;
} }
@ -531,7 +534,7 @@ struct CSBrickParamFocus : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Focus=atoi(args[0].c_str()); NLMISC::fromString(args[0], Focus);
return *this; return *this;
} }
@ -859,8 +862,8 @@ struct CSBrickParamAttackSkillModifier : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
MinModifier=atoi(args[0].c_str()); NLMISC::fromString(args[0], MinModifier);
MaxModifier=atoi(args[1].c_str()); NLMISC::fromString(args[1], MaxModifier);
return *this; return *this;
} }
@ -896,8 +899,8 @@ struct CSBrickParamDefenseModifier : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
MinModifier=atoi(args[0].c_str()); NLMISC::fromString(args[0], MinModifier);
MaxModifier=atoi(args[1].c_str()); NLMISC::fromString(args[1], MaxModifier);
return *this; return *this;
} }
@ -1393,8 +1396,8 @@ struct CSBrickParamCombatSlowAttack : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
Duration=(float)atof(args[0].c_str()); Duration=(float)atof(args[0].c_str());
MinFactor=atoi(args[1].c_str()); NLMISC::fromString(args[1], MinFactor);
MaxFactor=atoi(args[2].c_str()); NLMISC::fromString(args[2], MaxFactor);
return *this; return *this;
} }
@ -1434,8 +1437,8 @@ struct CSBrickParamCombatSlow : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
Duration=(float)atof(args[0].c_str()); Duration=(float)atof(args[0].c_str());
MinFactor=atoi(args[1].c_str()); NLMISC::fromString(args[1], MinFactor);
MaxFactor=atoi(args[2].c_str()); NLMISC::fromString(args[2], MaxFactor);
return *this; return *this;
} }
@ -1615,8 +1618,8 @@ struct CSBrickParamCriticalHitMod : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
MinModifier=atoi(args[0].c_str()); NLMISC::fromString(args[0], MinModifier);
MaxModifier=atoi(args[1].c_str()); NLMISC::fromString(args[1], MaxModifier);
return *this; return *this;
} }
@ -1781,7 +1784,7 @@ struct CSBrickParamMagicEffectMod : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
EffectMod=atoi(args[0].c_str()); NLMISC::fromString(args[0], EffectMod);
return *this; return *this;
} }
@ -1919,9 +1922,9 @@ struct CSBrickParamMagicDmg : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Hp=atoi(args[0].c_str()); NLMISC::fromString(args[0], Hp);
Sap=atoi(args[1].c_str()); NLMISC::fromString(args[1], Sap);
Sta=atoi(args[2].c_str()); NLMISC::fromString(args[2], Sta);
return *this; return *this;
} }
@ -1960,9 +1963,9 @@ struct CSBrickParamMagicHeal : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Hp=atoi(args[0].c_str()); NLMISC::fromString(args[0], Hp);
Sap=atoi(args[1].c_str()); NLMISC::fromString(args[1], Sap);
Sta=atoi(args[2].c_str()); NLMISC::fromString(args[2], Sta);
return *this; return *this;
} }
@ -1995,7 +1998,7 @@ struct CSBrickParamMagicRanges : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
RangeIndex=atoi(args[0].c_str()); NLMISC::fromString(args[0], RangeIndex);
return *this; return *this;
} }
@ -2028,7 +2031,7 @@ struct CSBrickParamMagicLinkCost : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Cost=atoi(args[0].c_str()); NLMISC::fromString(args[0], Cost);
return *this; return *this;
} }
@ -2061,7 +2064,7 @@ struct CSBrickParamMagicLinkPeriod : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Period=atoi(args[0].c_str()); NLMISC::fromString(args[0], Period);
return *this; return *this;
} }
@ -2127,7 +2130,7 @@ struct CSBrickParamMagicLinkPower : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Power=atoi(args[0].c_str()); NLMISC::fromString(args[0], Power);
return *this; return *this;
} }
@ -2163,8 +2166,8 @@ struct CSBrickParamMagicBreakResist : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
BreakResist=atoi(args[0].c_str()); NLMISC::fromString(args[0], BreakResist);
BreakResistPower=atoi(args[1].c_str()); NLMISC::fromString(args[1], BreakResistPower);
return *this; return *this;
} }
@ -2197,7 +2200,7 @@ struct CSBrickParamMagicArmorComp : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
ArmorComp=atoi(args[0].c_str()); NLMISC::fromString(args[0], ArmorComp);
return *this; return *this;
} }
@ -2230,7 +2233,7 @@ struct CSBrickParamMagicVampirise : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Vampirise=atoi(args[0].c_str()); NLMISC::fromString(args[0], Vampirise);
return *this; return *this;
} }
@ -2296,7 +2299,7 @@ struct CSBrickParamCraftRecommended : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Recommended=atoi(args[0].c_str()); NLMISC::fromString(args[0], Recommended);
return *this; return *this;
} }
@ -2329,7 +2332,7 @@ struct CSBrickParamCraftHP : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
HitPoint=atoi(args[0].c_str()); NLMISC::fromString(args[0], HitPoint);
return *this; return *this;
} }
@ -2362,7 +2365,7 @@ struct CSBrickParamCraftSap : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Sap=atoi(args[0].c_str()); NLMISC::fromString(args[0], Sap);
return *this; return *this;
} }
@ -2395,7 +2398,7 @@ struct CSBrickParamCraftSta : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Stamina=atoi(args[0].c_str()); NLMISC::fromString(args[0], Stamina);
return *this; return *this;
} }
@ -2428,7 +2431,7 @@ struct CSBrickParamCraftFocus : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Focus=atoi(args[0].c_str()); NLMISC::fromString(args[0], Focus);
return *this; return *this;
} }
@ -2461,7 +2464,7 @@ struct CSBrickParamCraftQuality : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Quality=atoi(args[0].c_str()); NLMISC::fromString(args[0], Quality);
return *this; return *this;
} }
@ -2791,7 +2794,7 @@ struct CSBrickParamForageAngle : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Angle=atoi(args[0].c_str()); NLMISC::fromString(args[0], Angle);
return *this; return *this;
} }
@ -2824,7 +2827,7 @@ struct CSBrickParamForageMulti : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Limit=atoi(args[0].c_str()); NLMISC::fromString(args[0], Limit);
return *this; return *this;
} }
@ -2857,7 +2860,7 @@ struct CSBrickParamForageKnowledge : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Know=atoi(args[0].c_str()); NLMISC::fromString(args[0], Know);
return *this; return *this;
} }
@ -2989,7 +2992,7 @@ struct CSBrickParamStatEnergyOnly : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
StatEnergyExact=atoi(args[0].c_str()); NLMISC::fromString(args[0], StatEnergyExact);
return *this; return *this;
} }
@ -3055,7 +3058,7 @@ struct CSBrickParamForageVisStealth : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Mode=atoi(args[0].c_str()); NLMISC::fromString(args[0], Mode);
return *this; return *this;
} }
@ -3088,7 +3091,7 @@ struct CSBrickParamForageSourceLocator : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Flag=atoi(args[0].c_str()); NLMISC::fromString(args[0], Flag);
return *this; return *this;
} }
@ -3121,7 +3124,7 @@ struct CSBrickParamForageAttempts : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Nb=atoi(args[0].c_str()); NLMISC::fromString(args[0], Nb);
return *this; return *this;
} }
@ -3451,7 +3454,7 @@ struct CSBrickParamForageAbsorbSourceDmg : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Percent=atoi(args[0].c_str()); NLMISC::fromString(args[0], Percent);
return *this; return *this;
} }
@ -3484,7 +3487,7 @@ struct CSBrickParamKamiOffering : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Num=atoi(args[0].c_str()); NLMISC::fromString(args[0], Num);
return *this; return *this;
} }
@ -3616,7 +3619,7 @@ struct CSBrickParamForageRMGroupFilter : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Value=atoi(args[0].c_str()); NLMISC::fromString(args[0], Value);
return *this; return *this;
} }
@ -3649,7 +3652,7 @@ struct CSBrickParamForageRMFamilyFilter : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Value=atoi(args[0].c_str()); NLMISC::fromString(args[0], Value);
return *this; return *this;
} }
@ -3682,7 +3685,7 @@ struct CSBrickParamForageItemPartFilter : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
ItemPartIndex=atoi(args[0].c_str()); NLMISC::fromString(args[0], ItemPartIndex);
return *this; return *this;
} }
@ -3721,7 +3724,7 @@ struct CSBrickParamPowerTaunt : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
TauntPower=atoi(args[0].c_str()); NLMISC::fromString(args[0], TauntPower);
Range=(float)atof(args[1].c_str()); Range=(float)atof(args[1].c_str());
DisableTime=(float)atof(args[2].c_str()); DisableTime=(float)atof(args[2].c_str());
@ -3777,12 +3780,12 @@ struct CSBrickParamShielding : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
NoShieldProtectionFactor=atoi(args[0].c_str()); NLMISC::fromString(args[0], NoShieldProtectionFactor);
NoShieldProtectionMax=atoi(args[1].c_str()); NLMISC::fromString(args[1], NoShieldProtectionMax);
BucklerProtectionFactor=atoi(args[2].c_str()); NLMISC::fromString(args[2], BucklerProtectionFactor);
BucklerProtectionMax=atoi(args[3].c_str()); NLMISC::fromString(args[3], BucklerProtectionMax);
ShieldProtectionFactor=atoi(args[4].c_str()); NLMISC::fromString(args[4], ShieldProtectionFactor);
ShieldProtectionMax=atoi(args[5].c_str()); NLMISC::fromString(args[5], ShieldProtectionMax);
Duration=(float)atof(args[6].c_str()); Duration=(float)atof(args[6].c_str());
DisableTime=(float)atof(args[7].c_str()); DisableTime=(float)atof(args[7].c_str());
@ -3829,7 +3832,7 @@ struct CSBrickParamLifeAura : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
RegenMod=atoi(args[0].c_str()); NLMISC::fromString(args[0], RegenMod);
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
Radius=(float)atof(args[2].c_str()); Radius=(float)atof(args[2].c_str());
TargetDisableTime=(float)atof(args[3].c_str()); TargetDisableTime=(float)atof(args[3].c_str());
@ -3878,7 +3881,7 @@ struct CSBrickParamStaminaAura : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
RegenMod=atoi(args[0].c_str()); NLMISC::fromString(args[0], RegenMod);
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
Radius=(float)atof(args[2].c_str()); Radius=(float)atof(args[2].c_str());
TargetDisableTime=(float)atof(args[3].c_str()); TargetDisableTime=(float)atof(args[3].c_str());
@ -3927,7 +3930,7 @@ struct CSBrickParamSapAura : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
RegenMod=atoi(args[0].c_str()); NLMISC::fromString(args[0], RegenMod);
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
Radius=(float)atof(args[2].c_str()); Radius=(float)atof(args[2].c_str());
TargetDisableTime=(float)atof(args[3].c_str()); TargetDisableTime=(float)atof(args[3].c_str());
@ -3970,7 +3973,7 @@ struct CSBrickParamSpeedingUp : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
SpeedMod=atoi(args[0].c_str()); NLMISC::fromString(args[0], SpeedMod);
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
DisableTime=(float)atof(args[2].c_str()); DisableTime=(float)atof(args[2].c_str());
@ -4193,7 +4196,7 @@ struct CSBrickParamWarCry : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
TargetDisableTime=(float)atof(args[2].c_str()); TargetDisableTime=(float)atof(args[2].c_str());
UserDisableTime=(float)atof(args[3].c_str()); UserDisableTime=(float)atof(args[3].c_str());
DamageBonus=atoi(args[4].c_str()); NLMISC::fromString(args[4], DamageBonus);
return *this; return *this;
} }
@ -4242,7 +4245,7 @@ struct CSBrickParamFireWall : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
TargetDisableTime=(float)atof(args[2].c_str()); TargetDisableTime=(float)atof(args[2].c_str());
UserDisableTime=(float)atof(args[3].c_str()); UserDisableTime=(float)atof(args[3].c_str());
Damage=atoi(args[4].c_str()); NLMISC::fromString(args[4], Damage);
return *this; return *this;
} }
@ -4291,7 +4294,7 @@ struct CSBrickParamThornWall : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
TargetDisableTime=(float)atof(args[2].c_str()); TargetDisableTime=(float)atof(args[2].c_str());
UserDisableTime=(float)atof(args[3].c_str()); UserDisableTime=(float)atof(args[3].c_str());
Damage=atoi(args[4].c_str()); NLMISC::fromString(args[4], Damage);
return *this; return *this;
} }
@ -4340,7 +4343,7 @@ struct CSBrickParamWaterWall : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
TargetDisableTime=(float)atof(args[2].c_str()); TargetDisableTime=(float)atof(args[2].c_str());
UserDisableTime=(float)atof(args[3].c_str()); UserDisableTime=(float)atof(args[3].c_str());
Damage=atoi(args[4].c_str()); NLMISC::fromString(args[4], Damage);
return *this; return *this;
} }
@ -4389,7 +4392,7 @@ struct CSBrickParamLightningWall : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
TargetDisableTime=(float)atof(args[2].c_str()); TargetDisableTime=(float)atof(args[2].c_str());
UserDisableTime=(float)atof(args[3].c_str()); UserDisableTime=(float)atof(args[3].c_str());
Damage=atoi(args[4].c_str()); NLMISC::fromString(args[4], Damage);
return *this; return *this;
} }
@ -4438,7 +4441,7 @@ struct CSBrickParamBerserk : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
DamagePerUpdate=(float)atof(args[2].c_str()); DamagePerUpdate=(float)atof(args[2].c_str());
UpdateFrequency=(float)atof(args[3].c_str()); UpdateFrequency=(float)atof(args[3].c_str());
DamageBonus=atoi(args[4].c_str()); NLMISC::fromString(args[4], DamageBonus);
return *this; return *this;
} }
@ -4487,7 +4490,7 @@ struct CSBrickParamEnchantWeapon : public TBrickParam::IId
Duration=(float)atof(args[1].c_str()); Duration=(float)atof(args[1].c_str());
DamageType=args[2].c_str(); DamageType=args[2].c_str();
DpsBonus=(float)atof(args[3].c_str()); DpsBonus=(float)atof(args[3].c_str());
DamageBonus=atoi(args[4].c_str()); NLMISC::fromString(args[4], DamageBonus);
return *this; return *this;
} }
@ -4652,7 +4655,7 @@ struct CSBrickParamHeal : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
AffectedScore=args[0].c_str(); AffectedScore=args[0].c_str();
HealValue=atoi(args[1].c_str()); NLMISC::fromString(args[1], HealValue);
HealFactorValue=(float)atof(args[2].c_str()); HealFactorValue=(float)atof(args[2].c_str());
DisableTime=(float)atof(args[3].c_str()); DisableTime=(float)atof(args[3].c_str());
PowerType=args[4].c_str(); PowerType=args[4].c_str();
@ -4824,9 +4827,9 @@ struct CSBrickParamAreaBomb : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Radius=(float)atof(args[0].c_str()); NLMISC::fromString(args[0], Radius);
MinFactor=(float)atof(args[1].c_str()); NLMISC::fromString(args[1], MinFactor);
MaxTarget=(uint8)atoi(args[2].c_str()); NLMISC::fromString(args[2], MaxTarget);
return *this; return *this;
} }
@ -4868,10 +4871,10 @@ struct CSBrickParamAreaSpray : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
Angle=atoi(args[0].c_str()); NLMISC::fromString(args[0], Angle);
Height=(float)atof(args[1].c_str()); Height=(float)atof(args[1].c_str());
Base=(float)atof(args[2].c_str()); Base=(float)atof(args[2].c_str());
MaxTarget=(uint8)atoi(args[3].c_str()); NLMISC::fromString(args[3], MaxTarget);
return *this; return *this;
} }
@ -4911,7 +4914,7 @@ struct CSBrickParamAreaChain : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
Range=(float)atof(args[0].c_str()); Range=(float)atof(args[0].c_str());
MaxTargets=atoi(args[1].c_str()); NLMISC::fromString(args[1], MaxTargets);
Factor=(float)atof(args[2].c_str()); Factor=(float)atof(args[2].c_str());
return *this; return *this;
@ -4949,7 +4952,7 @@ struct CSBrickParamAreaTargets : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
TargetFactor=(float)atof(args[0].c_str()); TargetFactor=(float)atof(args[0].c_str());
MaxTargets=atoi(args[1].c_str()); NLMISC::fromString(args[1], MaxTargets);
return *this; return *this;
} }
@ -4982,7 +4985,7 @@ struct CSBrickParamMagicRecharge : public TBrickParam::IId
return *this; return *this;
ParsedOk=true; ParsedOk=true;
SapLoad=atoi(args[0].c_str()); NLMISC::fromString(args[0], SapLoad);
return *this; return *this;
} }
@ -5019,7 +5022,7 @@ struct CSBrickParamCharacUpgrade : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
Characteristic=args[0].c_str(); Characteristic=args[0].c_str();
Modifier=atoi(args[1].c_str()); NLMISC::fromString(args[1], Modifier);
return *this; return *this;
} }
@ -5056,7 +5059,7 @@ struct CSBrickParamScoreUpgrade : public TBrickParam::IId
ParsedOk=true; ParsedOk=true;
Score=args[0].c_str(); Score=args[0].c_str();
Modifier=atoi(args[1].c_str()); NLMISC::fromString(args[1], Modifier);
return *this; return *this;
} }
@ -5553,6 +5556,4 @@ struct CSBrickParamModMagicProtection : public TBrickParam::IId
} }
}; };
#endif // RY_EGS_STATIC_BRICK_CPP_H

View file

@ -1844,7 +1844,8 @@ void CMP::loadGroups( const char *definitionFile )
for ( uint i=0; i!=nb; ++i ) for ( uint i=0; i!=nb; ++i )
{ {
formType->getDefinition( i, label, value ); formType->getDefinition( i, label, value );
uint groupId = atoi( value.c_str() ); uint groupId;
NLMISC::fromString(value, groupId);
// Set group -> name // Set group -> name
if ( groupId > 100000 ) if ( groupId > 100000 )

View file

@ -1108,7 +1108,8 @@ bool CStaticCreatures::applyProtectModification(uint index, const std::string &a
//Set protection max //Set protection max
if (attr == "max") if (attr == "max")
{ {
uint16 max = static_cast<uint16>(atoi(newValue.c_str())); uint16 max;
NLMISC::fromString(newValue, max);
_Protections[index].Max = max; _Protections[index].Max = max;
return false; return false;
} }
@ -1164,7 +1165,7 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
} }
case at_gender : case at_gender :
{ {
_Gender = static_cast<uint8>(atoi(scriptLine[1].c_str())); NLMISC::fromString(scriptLine[1], _Gender);
nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting Gender to %u", modelId.c_str(), _Gender); nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting Gender to %u", modelId.c_str(), _Gender);
break; break;
} }
@ -1185,7 +1186,8 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_nb_players : case at_nb_players :
{ {
int n = atoi(scriptLine[1].c_str()); sint n;
NLMISC::fromString(scriptLine[1], n);
if (n > 255 || n < 0) if (n > 255 || n < 0)
{ {
nlwarning("<CStaticCreatures::applyUserModel>Error while applying user model '%s': invalid value for attribute 'NbPlayers', setting 'NbPlayers' to 1.", modelId.c_str()); nlwarning("<CStaticCreatures::applyUserModel>Error while applying user model '%s': invalid value for attribute 'NbPlayers', setting 'NbPlayers' to 1.", modelId.c_str());
@ -1200,7 +1202,7 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_player_hp_level: case at_player_hp_level:
{ {
nldebug("<CStaticCreatures::applyUserModel> Applying '%s': setting playerHpLevel to '%s'", modelId.c_str(), scriptLine[1].c_str()); nldebug("<CStaticCreatures::applyUserModel> Applying '%s': setting playerHpLevel to '%s'", modelId.c_str(), scriptLine[1].c_str());
_PlayerHpLevel = atoi(scriptLine[1].c_str()); NLMISC::fromString(scriptLine[1], _PlayerHpLevel);
_CreatureDamagePerHitWithoutAverageDodge = uint32( (100*_PlayerHpLevel) / _NbHitToKillPlayer ); _CreatureDamagePerHitWithoutAverageDodge = uint32( (100*_PlayerHpLevel) / _NbHitToKillPlayer );
compileCreatureDamagePerHit(); compileCreatureDamagePerHit();
break; break;
@ -1258,7 +1260,8 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_life: case at_life:
{ {
sint32 hp = static_cast<sint32>(atoi(scriptLine[1].c_str())); sint32 hp;
NLMISC::fromString(scriptLine[1], hp);
if (hp == 0) if (hp == 0)
{ {
@ -1318,35 +1321,35 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_attack_level: case at_attack_level:
{ {
_AttackLevel = static_cast<uint16>(atoi(scriptLine[1].c_str())); NLMISC::fromString(scriptLine[1], _AttackLevel);
nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting attackLevel to '%u'", modelId.c_str(), _AttackLevel); nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting attackLevel to '%u'", modelId.c_str(), _AttackLevel);
break; break;
} }
case at_defense_level: case at_defense_level:
{ {
_DefenseLevel = static_cast<uint16>(atoi(scriptLine[1].c_str())); NLMISC::fromString(scriptLine[1], _DefenseLevel);
nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting defenseLevel to %u", modelId.c_str(), _DefenseLevel); nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting defenseLevel to %u", modelId.c_str(), _DefenseLevel);
break; break;
} }
case at_xp_level: case at_xp_level:
{ {
_XPLevel = static_cast<uint16>(atoi(scriptLine[1].c_str())); NLMISC::fromString(scriptLine[1], _XPLevel);
nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting XpLevel to %u", modelId.c_str(), _XPLevel); nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting XpLevel to %u", modelId.c_str(), _XPLevel);
break; break;
} }
case at_taunt_level: case at_taunt_level:
{ {
_TauntLevel = static_cast<uint16>(atoi(scriptLine[1].c_str())); NLMISC::fromString(scriptLine[1], _TauntLevel);
nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting TauntLevel to %u", modelId.c_str(), _TauntLevel); nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting TauntLevel to %u", modelId.c_str(), _TauntLevel);
break; break;
} }
case at_melee_reach_value: case at_melee_reach_value:
{ {
_MeleeReachValue = static_cast<uint8>(atoi(scriptLine[1].c_str())); NLMISC::fromString(scriptLine[1], _MeleeReachValue);
nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting MeleeReachValue to %u", modelId.c_str(), _MeleeReachValue); nldebug("<CStaticCreatures::applyUserModel> Applying '%s' : setting MeleeReachValue to %u", modelId.c_str(), _MeleeReachValue);
break; break;
} }
@ -1571,91 +1574,106 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_resists_fear : case at_resists_fear :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Fear = value; _Resists.Fear = value;
break; break;
} }
case at_resists_sleep : case at_resists_sleep :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Sleep = value; _Resists.Sleep = value;
break; break;
} }
case at_resists_stun : case at_resists_stun :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Stun = value; _Resists.Stun = value;
break; break;
} }
case at_resists_root : case at_resists_root :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Root = value; _Resists.Root = value;
break; break;
} }
case at_resists_snare : case at_resists_snare :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Snare = value; _Resists.Snare = value;
break; break;
} }
case at_resists_slow : case at_resists_slow :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Slow = value; _Resists.Slow = value;
break; break;
} }
case at_resists_madness : case at_resists_madness :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Madness = value; _Resists.Madness = value;
break; break;
} }
case at_resists_blind : case at_resists_blind :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Blind = value; _Resists.Blind = value;
break; break;
} }
case at_resists_acid : case at_resists_acid :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Acid = value; _Resists.Acid = value;
break; break;
} }
case at_resists_cold : case at_resists_cold :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Cold = value; _Resists.Cold = value;
break; break;
} }
case at_resists_electricity : case at_resists_electricity :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Electricity = value; _Resists.Electricity = value;
break; break;
} }
case at_resists_fire : case at_resists_fire :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Fire = value; _Resists.Fire = value;
break; break;
} }
case at_resists_poison : case at_resists_poison :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Poison = value; _Resists.Poison = value;
break; break;
} }
case at_resists_rot : case at_resists_rot :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Rot = value; _Resists.Rot = value;
break; break;
} }
case at_resists_shockwave : case at_resists_shockwave :
{ {
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str())); uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Shockwave = value; _Resists.Shockwave = value;
break; break;
} }

View file

@ -88,7 +88,8 @@ void CStaticContinent::readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &f
const UFormElm *zc; const UFormElm *zc;
if(elm->getArrayNode(&zc, i) && zc) if(elm->getArrayNode(&zc, i) && zc)
nlverify(zc->getValueByName(value, "outpost_number")); nlverify(zc->getValueByName(value, "outpost_number"));
uint index = (uint) atoi(value.c_str()); uint index;
NLMISC::fromString(value, index);
Outposts.push_back( index ); Outposts.push_back( index );
} }
} }

View file

@ -278,7 +278,8 @@ NLMISC_COMMAND( spawnFakePlayers, "Temp", "<nb>" )
{ {
if ( args.size() == 0 ) if ( args.size() == 0 )
return false; return false;
uint nb = atoi(args[0].c_str()); uint nb;
NLMISC::fromString(args[0], nb);
sint32 minx=2236000, maxx=6000000, miny=-7000000, maxy=-1000000; sint32 minx=2236000, maxx=6000000, miny=-7000000, maxy=-1000000;
log.displayNL( "Spawning %u fake players in (%d,%d)-(%d,%d)", nb, minx, miny, maxx, maxy ); log.displayNL( "Spawning %u fake players in (%d,%d)-(%d,%d)", nb, minx, miny, maxx, maxy );
@ -1258,7 +1259,9 @@ void CPlayerService::initConfigFileVars()
for ( uint i = 0; (sint)i<mainlands.size(); i+=4 ) for ( uint i = 0; (sint)i<mainlands.size(); i+=4 )
{ {
CMainlandSummary mlSm; CMainlandSummary mlSm;
mlSm.Id = (TSessionId) atoi(mainlands.asString(i).c_str()); uint32 sessionId;
NLMISC::fromString(mainlands.asString(i), sessionId);
mlSm.Id = TSessionId(sessionId);
mlSm.Name = ucstring::makeFromUtf8(mainlands.asString(i+1)); mlSm.Name = ucstring::makeFromUtf8(mainlands.asString(i+1));
mlSm.Description = ucstring::makeFromUtf8(mainlands.asString(i+2)); mlSm.Description = ucstring::makeFromUtf8(mainlands.asString(i+2));
mlSm.LanguageCode = mainlands.asString(i+3); mlSm.LanguageCode = mainlands.asString(i+3);
@ -1426,7 +1429,9 @@ void CPlayerService::init()
if (IService::getInstance()->haveArg('S')) if (IService::getInstance()->haveArg('S'))
{ {
IService::getInstance()->anticipateShardId( atoi(IService::getInstance()->getArg('S').c_str()) ); uint32 shardId;
NLMISC::fromString(IService::getInstance()->getArg('S'), shardId);
IService::getInstance()->anticipateShardId(shardId);
} }
else if (ConfigFile.getVarPtr("ShardId") != NULL) else if (ConfigFile.getVarPtr("ShardId") != NULL)
{ {
@ -1624,7 +1629,8 @@ NLMISC_COMMAND(loadAndReSaveCharacters,"load and resave the complete set of play
{ {
files[ i ] = files[ i ].substr( files[ i ].find("account_") + strlen("account_"), string::npos ); files[ i ] = files[ i ].substr( files[ i ].find("account_") + strlen("account_"), string::npos );
files[ i ] = files[ i ].substr(0 , files[ i ].find('_') ); files[ i ] = files[ i ].substr(0 , files[ i ].find('_') );
uint32 account = atoi( files[ i ].c_str() ); uint32 account;
NLMISC::fromString(files[ i ], account);
if ( playerIds.find( account ) == playerIds.end() ) if ( playerIds.find( account ) == playerIds.end() )
playerIds.insert( account ); playerIds.insert( account );
} }
@ -2141,7 +2147,8 @@ NLMISC_COMMAND(plrStat,"get or set a player stat","<pid><stat><value>")
// get // get
if( args.size() == 2 ) if( args.size() == 2 )
{ {
uint32 pid = atoi( args[0].c_str() ); uint32 pid;
NLMISC::fromString(args[0], pid);
CEntityId playerId(RYZOMID::player,pid); CEntityId playerId(RYZOMID::player,pid);
string stat( args[1] ); string stat( args[1] );
string value = PlayerManager.getValue( playerId, stat ); string value = PlayerManager.getValue( playerId, stat );
@ -2152,7 +2159,8 @@ NLMISC_COMMAND(plrStat,"get or set a player stat","<pid><stat><value>")
// set // set
if( args.size() > 2 ) if( args.size() > 2 )
{ {
uint32 pid = atoi( args[0].c_str() ); uint32 pid;
NLMISC::fromString(args[0], pid);
CEntityId playerId(RYZOMID::player,pid); CEntityId playerId(RYZOMID::player,pid);
string stat( args[1] ); string stat( args[1] );
string value = args[2]; string value = args[2];
@ -2181,7 +2189,8 @@ NLMISC_COMMAND(obj_stat,"get or set an object stat","<oid><stat>[type|loc|qualit
// get // get
if( args.size() == 2 ) if( args.size() == 2 )
{ {
uint32 oid = atoi( args[0].c_str() ); uint32 oid;
NLMISC::fromString(args[0], oid);
CEntityId objectId(player,oid); CEntityId objectId(player,oid);
string stat( args[1] ); string stat( args[1] );
string result; string result;
@ -2196,12 +2205,13 @@ NLMISC_COMMAND(obj_stat,"get or set an object stat","<oid><stat>[type|loc|qualit
// set // set
if( args.size() > 2 ) if( args.size() > 2 )
{ {
uint32 oid = atoi( args[0].c_str() ); uint32 oid;
NLMISC::fromString(args[0], oid);
CEntityId objectId(object,oid); CEntityId objectId(object,oid);
if( args[1] == "type" ) WorldObjectManager.getObject(objectId).setType(atoi(args[2].c_str())); if( args[1] == "type" ) WorldObjectManager.getObject(objectId).setType(NLMISC::fromString(args[2].c_str()));
//if( args[1] == "loc" ) //if( args[1] == "loc" )
if( args[1] == "quality" ) WorldObjectManager.getObject(objectId).setQuality(atoi(args[2].c_str())); if( args[1] == "quality" ) WorldObjectManager.getObject(objectId).setQuality(NLMISC::fromString(args[2].c_str()));
if( args[1] == "hp" ) WorldObjectManager.getObject(objectId).setHP(atoi(args[2].c_str())); if( args[1] == "hp" ) WorldObjectManager.getObject(objectId).setHP(NLMISC::fromString(args[2].c_str()));
return true; return true;
} }
@ -2221,7 +2231,7 @@ NLMISC_COMMAND(create_obj,"create a new object","<type>")
CWorldObjectLocation loc; CWorldObjectLocation loc;
uint16 quality = 0; uint16 quality = 0;
uint32 hp = 0; uint32 hp = 0;
WorldObjectManager.createObject(atoi(args[2].c_str()),loc,quality,hp); WorldObjectManager.createObject(NLMISC::fromString(args[2].c_str()),loc,quality,hp);
return true; return true;
} }
return false; return false;
@ -2237,7 +2247,8 @@ NLMISC_COMMAND(remove_obj,"remove an object","<id>")
{ {
if( args.size() > 0 ) if( args.size() > 0 )
{ {
uint32 oid = atoi( args[0].c_str() ); uint32 oid;
NLMISC::fromString(args[0], oid);
CEntityId objId(object,oid); CEntityId objId(object,oid);
WorldObjectManager.removeObject( objId ); WorldObjectManager.removeObject( objId );
return true; return true;
@ -2274,7 +2285,7 @@ NLMISC_COMMAND(dump_stats,"dump stats of an object to the output win or log","<o
{ {
if( args.size() > 0 ) if( args.size() > 0 )
{ {
CEntityId objId = CEntityId(object,atoi(args[0].c_str())); CEntityId objId = CEntityId(object,NLMISC::fromString(args[0].c_str()));
if( args.size() > 1 ) if( args.size() > 1 )
{ {
WorldObjectManager.getObject(objId).dumpWorldObjectStats(args[1]); WorldObjectManager.getObject(objId).dumpWorldObjectStats(args[1]);
@ -2301,7 +2312,7 @@ NLMISC_COMMAND(changeMode," change_mode","<entity id(id:type:crea:dyn)> <mode>")
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
MBEHAV::EMode mode = MBEHAV::EMode(atoi(args[1].c_str())); MBEHAV::EMode mode = MBEHAV::EMode(NLMISC::fromString(args[1].c_str()));
CEntityBase *e; CEntityBase *e;
if( id.getType() == 0 ) if( id.getType() == 0 )
@ -2373,7 +2384,9 @@ NLMISC_COMMAND(changeBehaviour," change entity behaviour","<entity id(id:type:cr
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
MBEHAV::EBehaviour behaviour = MBEHAV::EBehaviour(atoi(args[1].c_str())); sint behav;
NLMISC::fromString(args[1], behav);
MBEHAV::EBehaviour behaviour = MBEHAV::EBehaviour(behav);
CEntityBase *e = NULL; CEntityBase *e = NULL;
if( id.getType() == 0 ) if( id.getType() == 0 )
@ -2587,7 +2600,8 @@ NLMISC_COMMAND(changeVisualPropertyA, " changeVisualPropertyA","<entity id(id:ty
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
string name = args[1]; string name = args[1];
uint8 value = (uint8) atoi( args[2].c_str() ); uint8 value;
NLMISC::fromString(args[2], value);
CCharacter *c; CCharacter *c;
c = PlayerManager.getChar(id); c = PlayerManager.getChar(id);
@ -2923,7 +2937,8 @@ NLMISC_COMMAND(createPlayer," create a player","<playerId, characterName, race,
{ {
if( args.size() == 4 ) if( args.size() == 4 )
{ {
uint32 playerId = atoi( args[0].c_str() ); uint32 playerId;
NLMISC::fromString(args[0], playerId);
string characterName = args[1]; string characterName = args[1];
EGSPD::CPeople::TPeople race = EGSPD::CPeople::fromString( args[2] ); EGSPD::CPeople::TPeople race = EGSPD::CPeople::fromString( args[2] );
if( race == EGSPD::CPeople::EndPeople ) return false; if( race == EGSPD::CPeople::EndPeople ) return false;
@ -2966,7 +2981,8 @@ NLMISC_COMMAND(spawnCharacters," spawn somes characters","<Number, characterName
if( args.size() == 4 ) if( args.size() == 4 )
{ {
uint32 NbPlayer = atoi( args[0].c_str() ); uint32 NbPlayer;
NLMISC::fromString(args[0], NbPlayer);
for( uint32 i = 0; i < NbPlayer; ++i ) for( uint32 i = 0; i < NbPlayer; ++i )
{ {
command = string("createPlayer ") + NLMISC::toString(i) + string(" ") + args[1] + NLMISC::toString(i) + string(" ") + args[2] + string(" ") + args[3]; command = string("createPlayer ") + NLMISC::toString(i) + string(" ") + args[1] + NLMISC::toString(i) + string(" ") + args[2] + string(" ") + args[3];
@ -2986,7 +3002,8 @@ NLMISC_COMMAND(spawnCharacters," spawn somes characters","<Number, characterName
{ {
if( args.size() == 6 ) if( args.size() == 6 )
{ {
uint32 playerId = atoi( args[0].c_str() ); uint32 playerId;
NLMISC::fromString(args[0], playerId);
string characterName = args[1]; string characterName = args[1];
EGSPD::CPeople::TPeople race = EGSPD::CPeople::fromString( args[2] ); EGSPD::CPeople::TPeople race = EGSPD::CPeople::fromString( args[2] );
if( race == EGSPD::CPeople::EndPeople ) return false; if( race == EGSPD::CPeople::EndPeople ) return false;
@ -2997,7 +3014,8 @@ NLMISC_COMMAND(spawnCharacters," spawn somes characters","<Number, characterName
ROLES::ERole role = ROLES::toRoleId( args[4] ); ROLES::ERole role = ROLES::toRoleId( args[4] );
if( role == ROLES::role_unknown ) return false; if( role == ROLES::role_unknown ) return false;
uint16 level = atoi( args[5].c_str() ); uint16 level;
NLMISC::fromString(args[5], level);
CPlayer *player = PlayerManager.getPlayer( playerId ); CPlayer *player = PlayerManager.getPlayer( playerId );
if( player != 0 ) if( player != 0 )
@ -3017,7 +3035,8 @@ NLMISC_COMMAND(savePlayerActiveChar," save player with regular character filenam
{ {
if( args.size() >= 1 ) if( args.size() >= 1 )
{ {
uint32 userId = atoi( args[0].c_str() ); uint32 userId;
NLMISC::fromString(args[0], userId);
if(args.size() == 2) if(args.size() == 2)
{ {
string filename = args[1]; string filename = args[1];
@ -3040,7 +3059,8 @@ NLMISC_COMMAND(saveAllPlayerChars," saveAllPlayerChars","uid")
{ {
if( args.size() == 1 ) if( args.size() == 1 )
{ {
uint32 userId = atoi( args[0].c_str() ); uint32 userId;
NLMISC::fromString(args[0], userId);
// If the user really exist // If the user really exist
CPlayer *player= PlayerManager.getPlayer(userId); CPlayer *player= PlayerManager.getPlayer(userId);
@ -3078,10 +3098,12 @@ NLMISC_COMMAND(reloadPlayer," reload a connected player character, a previous sa
{ {
if( args.size() == 1 || args.size() == 3 ) if( args.size() == 1 || args.size() == 3 )
{ {
uint32 userId = atoi( args[0].c_str() ); uint32 userId;
NLMISC::fromString(args[0], userId);
if(args.size() == 3) if(args.size() == 3)
{ {
uint32 charIndex = (uint32)atoi(args[1].c_str()); uint32 charIndex;
NLMISC::fromString(args[1], charIndex);
string filename = args[2]; string filename = args[2];
PlayerManager.reloadPlayerActiveChar( userId, charIndex, &filename ); PlayerManager.reloadPlayerActiveChar( userId, charIndex, &filename );
} }
@ -3101,7 +3123,8 @@ NLMISC_COMMAND(loadPlayer," load a player","uid")
{ {
if( args.size() == 1 ) if( args.size() == 1 )
{ {
uint32 userId = atoi( args[0].c_str() ); uint32 userId;
NLMISC::fromString(args[0], userId);
// set the front end id of this player // set the front end id of this player
PlayerManager.setPlayerFrontEndId( userId, NLNET::TServiceId(0xff) ); PlayerManager.setPlayerFrontEndId( userId, NLNET::TServiceId(0xff) );
@ -3128,8 +3151,10 @@ NLMISC_COMMAND(activePlayer," active a character (same has choosed by player)","
{ {
if( args.size() == 2 ) if( args.size() == 2 )
{ {
uint32 userId = atoi( args[0].c_str() ); uint32 userId;
uint32 characterIndex = atoi( args[1].c_str() ); NLMISC::fromString(args[0], userId);
uint32 characterIndex;
NLMISC::fromString(args[1], characterIndex);
CCharacter * ch = PlayerManager.getChar( userId, characterIndex ); CCharacter * ch = PlayerManager.getChar( userId, characterIndex );
if( ch ) if( ch )
@ -3153,8 +3178,10 @@ NLMISC_COMMAND(simulateClientReady,"Simulate clientReady for a character","clien
{ {
if( args.size() == 2 ) if( args.size() == 2 )
{ {
uint32 userId = atoi( args[0].c_str() ); uint32 userId;
uint32 characterIndex = atoi( args[1].c_str() ); NLMISC::fromString(args[0], userId);
uint32 characterIndex;
NLMISC::fromString(args[1], characterIndex);
CCharacter * ch = PlayerManager.getChar( userId, characterIndex ); CCharacter * ch = PlayerManager.getChar( userId, characterIndex );
if( ch ) if( ch )
@ -3206,7 +3233,8 @@ NLMISC_COMMAND(moveCharAndOfflineCmdToHashTable, "Move all character and offline
explode(CFile::getFilename(allChars[i]), string("_"), parts); explode(CFile::getFilename(allChars[i]), string("_"), parts);
if (parts.size() == 4) if (parts.size() == 4)
{ {
uint32 userId = atoi(parts[1].c_str()); uint32 userId;
NLMISC::fromString(parts[1], userId);
// make sure the dest path exist // make sure the dest path exist
CFile::createDirectory(PlayerManager.getCharacterPath(userId, false)); CFile::createDirectory(PlayerManager.getCharacterPath(userId, false));
@ -3232,7 +3260,8 @@ NLMISC_COMMAND(moveCharAndOfflineCmdToHashTable, "Move all character and offline
explode(CFile::getFilename(allCommands[i]), string("_"), parts); explode(CFile::getFilename(allCommands[i]), string("_"), parts);
if (parts.size() == 4) if (parts.size() == 4)
{ {
uint32 userId = atoi(parts[1].c_str()); uint32 userId;
NLMISC::fromString(parts[1], userId);
// make sure the dest path exist // make sure the dest path exist
CFile::createDirectory(PlayerManager.getOfflineCommandPath(userId, false)); CFile::createDirectory(PlayerManager.getOfflineCommandPath(userId, false));
@ -3284,8 +3313,8 @@ NLMISC_COMMAND(loadAllPlayerAndReady,"Load all the player saves (all account, al
string slotStr = parts[2]; string slotStr = parts[2];
uint32 account, slot; uint32 account, slot;
account = atoi(accountStr.c_str()); NLMISC::fromString(accountStr, account);
slot = atoi(slotStr.c_str()); NLMISC::fromString(slotStr, slot);
nldebug("Loading account %u, slot %u", account, slot); nldebug("Loading account %u, slot %u", account, slot);
@ -3375,8 +3404,8 @@ NLMISC_COMMAND(convertAllOldCharacterSaves,"Load all the old (.bin) not already
string slotStr = parts[2]; string slotStr = parts[2];
uint32 account, slot; uint32 account, slot;
account = atoi(accountStr.c_str()); NLMISC::fromString(accountStr, account);
slot = atoi(slotStr.c_str()); NLMISC::fromString(slotStr, slot);
// check if the character is already converted // check if the character is already converted
string newFileName = PlayerManager.getCharacterPath(account, false)+toString("/account_%u_%u_pdr.bin", account, slot); string newFileName = PlayerManager.getCharacterPath(account, false)+toString("/account_%u_%u_pdr.bin", account, slot);
@ -3428,10 +3457,13 @@ NLMISC_COMMAND(simulatePlayerConnect,"simulate connect players","<first user id>
if( args.size() != 4 ) if( args.size() != 4 )
return false; return false;
uint32 fid = (uint32)atoi(args[0].c_str()); uint32 fid, lid, rep;
uint32 lid = (uint32)atoi(args[1].c_str()); NLMISC::fromString(args[0], fid);
uint32 rep = (uint32)atoi(args[2].c_str()); NLMISC::fromString(args[1], lid);
NLNET::TServiceId feid(atoi(args[3].c_str())); NLMISC::fromString(args[2], rep);
uint16 sid;
NLMISC::fromString(args[3], sid);
NLNET::TServiceId feid(sid);
if( rep != 0 && lid >= fid ) if( rep != 0 && lid >= fid )
{ {
@ -3499,7 +3531,8 @@ NLMISC_COMMAND(disconnectPlayer,"remove player from egs","<user id>")
if( args.size() != 1 ) if( args.size() != 1 )
return false; return false;
uint32 id = (uint32)atoi(args[0].c_str()); uint32 id;
NLMISC::fromString(args[0], id);
if( PlayerManager.getPlayer( id ) != 0) if( PlayerManager.getPlayer( id ) != 0)
{ {
PlayerManager.savePlayerActiveChar( id ); PlayerManager.savePlayerActiveChar( id );
@ -3611,9 +3644,11 @@ NLMISC_COMMAND( harvest," harvest","entity id(id:type:crea:dyn), Index Mp, Qty")
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
uint8 index = (uint8) atoi( args[1].c_str() ); uint8 index;
NLMISC::fromString(args[1], index);
uint16 qty = (uint16) atoi( args[2].c_str() ); uint16 qty;
NLMISC::fromString(args[2], qty);
CCharacter *character = PlayerManager.getChar( id ); CCharacter *character = PlayerManager.getChar( id );
if( character ) if( character )
@ -3666,7 +3701,8 @@ NLMISC_COMMAND( createItemInBagTest," create_item_in_bag", "player id(id:type:cr
CSheetId sheet; CSheetId sheet;
uint32 sheetId = atoi(args[1].c_str()); uint32 sheetId;
NLMISC::fromString(args[1], sheetId);
if (sheetId) if (sheetId)
sheet = CSheetId(sheetId); sheet = CSheetId(sheetId);
else else
@ -3676,8 +3712,9 @@ NLMISC_COMMAND( createItemInBagTest," create_item_in_bag", "player id(id:type:cr
sheetName += string(".item"); sheetName += string(".item");
sheet = CSheetId(sheetName.c_str()); sheet = CSheetId(sheetName.c_str());
} }
uint quantity = atoi(args[2].c_str()); uint quantity, quality;
uint quality = atoi(args[3].c_str()); NLMISC::fromString(args[2], quantity);
NLMISC::fromString(args[3], quality);
const CStaticItem* form = CSheets::getForm( sheet ); const CStaticItem* form = CSheets::getForm( sheet );
if (form == NULL) if (form == NULL)
@ -3926,10 +3963,10 @@ NLMISC_COMMAND(spendMoney," spend money","<entity id(id:type:crea:dyn)> <money>"
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
sint32 vb, b, m, s; sint32 vb, b, m, s;
vb = atoi( args[1].c_str() ); NLMISC::fromString(args[1], vb);
b = atoi( args[2].c_str() ); NLMISC::fromString(args[2], b);
m = atoi( args[3].c_str() ); NLMISC::fromString(args[3], m);
s = atoi( args[4].c_str() ); NLMISC::fromString(args[4], s);
CCharacter *e = PlayerManager.getChar(id); CCharacter *e = PlayerManager.getChar(id);
if( e ) if( e )
@ -4146,7 +4183,8 @@ NLMISC_COMMAND(displayAIRegisteredServices,"Display the list of services registe
return false; return false;
} }
const uint16 level = atoi( args[2].c_str() ); uint16 level;
NLMISC::fromString(args[2], level);
CCharacter *e = PlayerManager.getChar(id); CCharacter *e = PlayerManager.getChar(id);
if( e ) if( e )
@ -4177,7 +4215,7 @@ NLMISC_COMMAND(entityForcedDefaultLevel,"read or set the EntityForcedDefaultLeve
} }
else if( args.size() == 1 ) else if( args.size() == 1 )
{ {
EntityForcedDefaultLevel = (uint8)atoi(args[0].c_str()); NLMISC::fromString(args[0], EntityForcedDefaultLevel);
log.displayNL("EntityForcedDefaultLevel set to %d", EntityForcedDefaultLevel); log.displayNL("EntityForcedDefaultLevel set to %d", EntityForcedDefaultLevel);
return true; return true;
} }
@ -4238,7 +4276,8 @@ NLMISC_COMMAND(setAllJobsLevel,"set all chosen player job levels to given value
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
uint8 level = (uint8)atoi(args[1].c_str()); uint8 level;
NLMISC::fromString(args[1], level);
CCharacter *e = PlayerManager.getChar(id); CCharacter *e = PlayerManager.getChar(id);
if( e ) if( e )
@ -4273,7 +4312,8 @@ NLMISC_COMMAND(setAllSkillsToValue,"set all skills to value","<entity id(id:type
CEntityId id; CEntityId id;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
sint32 value = atoi(args[1].c_str()); sint32 value;
NLMISC::fromString(args[1], value);
CCharacter *e = PlayerManager.getChar(id); CCharacter *e = PlayerManager.getChar(id);
if( e ) if( e )
@ -4370,11 +4410,14 @@ NLMISC_COMMAND(displayItemInInventory,"display item characteristics (item is in
INVENTORIES::TInventory inventory = INVENTORIES::toInventory( args[1].c_str() ); INVENTORIES::TInventory inventory = INVENTORIES::toInventory( args[1].c_str() );
if( inventory == INVENTORIES::UNDEFINED ) if( inventory == INVENTORIES::UNDEFINED )
{ {
inventory = INVENTORIES::TInventory(atoi(args[1].c_str())); sint invId;
NLMISC::fromString(args[1], invId);
inventory = INVENTORIES::TInventory(invId);
if( inventory >= INVENTORIES::UNDEFINED ) if( inventory >= INVENTORIES::UNDEFINED )
return false; return false;
} }
const uint32 slot = atoi(args[2].c_str()); uint32 slot;
NLMISC::fromString(args[2], slot);
const CGameItemPtr item = player->getInventory( inventory)->getItem(slot); const CGameItemPtr item = player->getInventory( inventory)->getItem(slot);
if (item != NULL) if (item != NULL)
@ -4407,11 +4450,12 @@ NLMISC_COMMAND(destroyItemInInventory,"destroy the specified item","<player id(i
return true; return true;
} }
const INVENTORIES::TInventory inventory = INVENTORIES::toInventory(args[1].c_str()); const INVENTORIES::TInventory inventory = INVENTORIES::toInventory(args[1].c_str());
const uint32 slot = atoi(args[2].c_str()); uint32 slot;
NLMISC::fromString(args[2], slot);
uint32 qty = 1; uint32 qty = 1;
if (args.size() == 4) if (args.size() == 4)
qty = atoi(args[3].c_str()); NLMISC::fromString(args[3], qty);
CGameItemPtr itemPtr = c->getInventory(inventory)->getItem(slot); CGameItemPtr itemPtr = c->getInventory(inventory)->getItem(slot);
if (itemPtr != NULL) if (itemPtr != NULL)
@ -4451,13 +4495,15 @@ NLMISC_COMMAND(swapItemInInventory,"swap item in specified inventory / slot","<p
} }
const INVENTORIES::TInventory inventory1 = INVENTORIES::toInventory(args[1]); const INVENTORIES::TInventory inventory1 = INVENTORIES::toInventory(args[1]);
const uint32 slot1 = atoi(args[2].c_str()); uint32 slot1;
NLMISC::fromString(args[2], slot1);
const INVENTORIES::TInventory inventory2 = INVENTORIES::toInventory(args[3]); const INVENTORIES::TInventory inventory2 = INVENTORIES::toInventory(args[3]);
const uint32 slot2 = atoi(args[4].c_str()); uint32 slot2;
NLMISC::fromString(args[4], slot2);
uint32 qty = 1; uint32 qty = 1;
if (args.size() == 6) if (args.size() == 6)
qty = atoi(args[5].c_str()); NLMISC::fromString(args[5], qty);
c->moveItem( inventory1, slot1, inventory2, slot2, qty ); c->moveItem( inventory1, slot1, inventory2, slot2, qty );
@ -4548,10 +4594,13 @@ NLMISC_COMMAND(carriedItemsDecayRate,"display/change the rate of carried items d
log.displayNL("<changeItemVar> command, unknown player '%s'", id.toString().c_str() ); log.displayNL("<changeItemVar> command, unknown player '%s'", id.toString().c_str() );
return true; return true;
} }
const uint16 inventory = (uint16) atoi(args[1].c_str()); uint16 inventory;
const uint16 slot = (uint16) atoi(args[2].c_str()); NLMISC::fromString(args[1], inventory);
uint16 slot;
NLMISC::fromString(args[2], slot);
const string &var = args[3]; const string &var = args[3];
const sint32 value = (sint32) atoi(args[4].c_str()); sint32 value;
NLMISC::fromString(args[4], value);
CGameItemPtr itemPtr = player->getItem( inventory, slot); CGameItemPtr itemPtr = player->getItem( inventory, slot);
if (itemPtr != NULL) if (itemPtr != NULL)
@ -4598,8 +4647,8 @@ NLMISC_COMMAND(sendPetAnimalCommand,"Send a pet animal command","<player id(id:t
uint32 petCommand; uint32 petCommand;
id.fromString( args[0].c_str() ); id.fromString( args[0].c_str() );
petIndex = atoi( args[1].c_str()); NLMISC::fromString(args[1], petIndex);
petCommand = atoi( args[2].c_str() ); NLMISC::fromString(args[2], petCommand);
CCharacter *c = PlayerManager.getChar(id); CCharacter *c = PlayerManager.getChar(id);
if( c ) if( c )
@ -4631,7 +4680,7 @@ NLMISC_COMMAND(testProgression,"testProgression of skill","<player id(id:type:cr
else else
{ {
c->TestProgression = SKILLS::toSkill( c->TestProgressSkill ) != SKILLS::unknown; c->TestProgression = SKILLS::toSkill( c->TestProgressSkill ) != SKILLS::unknown;
Rate = atoi( args[1].c_str() ); NLMISC::fromString(args[1], Rate);
c->XpGainRate = Rate; c->XpGainRate = Rate;
c->TestProgressSkill = args[2]; c->TestProgressSkill = args[2];
@ -4677,9 +4726,12 @@ NLMISC_COMMAND(teleportPlayerCharacter,"Teleport online player character","<char
if( c ) if( c )
{ {
sint32 x, y, z; sint32 x, y, z;
x = atoi( args[1].c_str() ) * 1000; NLMISC::fromString(args[1], x);
y = atoi( args[2].c_str() ) * 1000; x *= 1000;
z = atoi( args[3].c_str() ) * 1000; NLMISC::fromString(args[2], y);
y *= 1000;
NLMISC::fromString(args[3], z);
z *= 1000;
if( c->getEnterFlag() ) if( c->getEnterFlag() )
{ {
@ -4740,7 +4792,8 @@ NLMISC_COMMAND(setHPBar,"set the value of an entity HP bar (0..100)","<entity id
return false; return false;
} }
sint32 barValue = atoi( args[1].c_str() ); sint32 barValue;
NLMISC::fromString(args[1], barValue);
entity->setScoreBar( SCORES::hit_points, (uint32)(barValue * 1023 / 100) ); entity->setScoreBar( SCORES::hit_points, (uint32)(barValue * 1023 / 100) );
log.displayNL("for entity id %s, new hpBar value : %d", id.toString().c_str(), barValue ); log.displayNL("for entity id %s, new hpBar value : %d", id.toString().c_str(), barValue );
@ -4960,7 +5013,8 @@ NLMISC_COMMAND(consumeAmmos,"consume ammos for given player ","<player id(id:typ
CCharacter * c = PlayerManager.getChar( id ); CCharacter * c = PlayerManager.getChar( id );
if (c ) if (c )
{ {
uint8 nb = (uint8)atoi(args[1].c_str()); uint8 nb;
NLMISC::fromString(args[1], nb);
c->consumeAmmo(nb); c->consumeAmmo(nb);
log.displayNL("Player id %s consumed %u ammos",id.toString().c_str(), nb); log.displayNL("Player id %s consumed %u ammos",id.toString().c_str(), nb);
@ -5100,7 +5154,7 @@ NLMISC_COMMAND(createSapRecharge,"create sap recharge item in temp inventory","<
CEntityId id; CEntityId id;
uint32 sapRecharged; uint32 sapRecharged;
id.fromString(args[0].c_str()); id.fromString(args[0].c_str());
sapRecharged = (uint32) atoi( args[1].c_str()); NLMISC::fromString(args[1], sapRecharged);
CCharacter * player = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( id ) ); CCharacter * player = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( id ) );
if( player ) if( player )
{ {
@ -5125,7 +5179,8 @@ NLMISC_COMMAND(enchantItem,"enchantItem with crystallized action from bag","<eId
{ {
CEntityId id; CEntityId id;
id.fromString(args[0].c_str()); id.fromString(args[0].c_str());
uint16 slot = (uint16) atoi( args[1].c_str() ); uint16 slot;
NLMISC::fromString(args[1], slot);
CCharacter * player = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( id ) ); CCharacter * player = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( id ) );
if( player ) if( player )
{ {
@ -5150,7 +5205,8 @@ NLMISC_COMMAND(rechargeItem,"recharge sapLaod of an item with sap recharge item
{ {
CEntityId id; CEntityId id;
id.fromString(args[0].c_str()); id.fromString(args[0].c_str());
uint16 slot = (uint16) atoi( args[1].c_str() ); uint16 slot;
NLMISC::fromString(args[1], slot);
CCharacter * player = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( id ) ); CCharacter * player = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( id ) );
if( player ) if( player )
{ {
@ -5429,8 +5485,11 @@ NLMISC_COMMAND (createEffectOnEntity, "create given effect on entity", "<eid> <e
return false; return false;
} }
uint32 duration = (uint32)( atoi(args[2].c_str()) / CTickEventHandler::getGameTimeStep() ); uint32 duration;
uint32 value = (uint32) atoi(args[3].c_str()); NLMISC::fromString(args[2], duration);
duration = (uint32)(NLMISC::TGameCycle(duration) / CTickEventHandler::getGameTimeStep());
uint32 value;
NLMISC::fromString(args[3], value);
CSTimedEffect *effect = IEffectFactory::buildEffect(family); CSTimedEffect *effect = IEffectFactory::buildEffect(family);
if (effect) if (effect)

View file

@ -851,7 +851,8 @@ bool CEntityBase::setValue( const string& var, const string& value )
{ {
nldebug( "CEntityBase::setValue setting value %s to %s", var.c_str(),value.c_str() ); nldebug( "CEntityBase::setValue setting value %s to %s", var.c_str(),value.c_str() );
sint32 &temp = lookupStat(var); sint32 &temp = lookupStat(var);
sint32 v = atoi( value.c_str() ); sint32 v;
NLMISC::fromString(value, v);
if( v < 0 ) if( v < 0 )
{ {
v = 0; v = 0;
@ -881,7 +882,8 @@ bool CEntityBase::modifyValue( const string& var, const string& value )
try try
{ {
sint32 &temp = lookupStat(var); sint32 &temp = lookupStat(var);
sint32 v = atoi( value.c_str() ); sint32 v;
NLMISC::fromString(value, v);
sint32 oldValue = temp; sint32 oldValue = temp;
temp = temp + v; temp = temp + v;
//nlinfo(" Modify value %s of %s for entity %s, old value %d, new value %d", var.c_str(), value.c_str(), _Id.toString().c_str(), oldValue, temp.getValue() ); //nlinfo(" Modify value %s of %s for entity %s, old value %d, new value %d", var.c_str(), value.c_str(), _Id.toString().c_str(), oldValue, temp.getValue() );

View file

@ -4824,7 +4824,9 @@ NLMISC_COMMAND(testParanoidItemSystem,"run some test code that should provoke a
// if (args.size()!=1) // if (args.size()!=1)
// return false; // return false;
// //
// switch (atoi(args[0].c_str())) // sint test;
// NLMISC::fromString(args[0], test);
// switch (test)
// { // {
// case 0: // case 0:
// { // {

View file

@ -852,11 +852,15 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
return false; return false;
} }
CSheetId sheetId = CSheetId( atoi( args[0].c_str() ) ); uint32 itemId;
NLMISC::fromString(args[0], itemId);
CSheetId sheetId(itemId);
uint16 quality = (uint16)atoi( args[1].c_str() ); uint16 quality;
NLMISC::fromString(args[1], quality);
uint32 ownerIdTmp = atoi( args[2].c_str() ); uint32 ownerIdTmp;
NLMISC::fromString(args[2], ownerIdTmp);
CEntityId ownerId(RYZOMID::object,ownerIdTmp); CEntityId ownerId(RYZOMID::object,ownerIdTmp);
// CGameItemPtr item = GameItemManager.createItem( sheetId, quality, ownerId, -1, true,true ); // CGameItemPtr item = GameItemManager.createItem( sheetId, quality, ownerId, -1, true,true );
@ -886,7 +890,10 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
// return false; // return false;
// } // }
// //
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) ); // uint32 itemId;
// NLMISC::fromString(args[0], itemId)
//
// CEntityId itemId(RYZOMID::object, itemId);
// //
// CGameItemPtr item = GameItemManager.getItem(itemId); // CGameItemPtr item = GameItemManager.getItem(itemId);
// if (item != NULL) // if (item != NULL)
@ -911,12 +918,18 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
// return false; // return false;
// } // }
// //
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) ); // CEntityId itemId( RYZOMID::object, NLMISC::fromString(args[0].c_str()) );
// //uint16 quality = (uint16)atoi(args[1].c_str()); // //uint16 quality = (uint16)NLMISC::fromString(args[1].c_str());
// //
// sint32 x = (sint32)atoi(args[2].c_str()) * 1000; // sint32 x;
// sint32 y = (sint32)atoi(args[3].c_str()) * 1000; // NLMISC::fromString(args[2], x);
// sint32 z = (sint32)atoi(args[4].c_str()) * 1000; // x *= 1000;
// sint32 y;
// NLMISC::fromString(args[3], y);
// y *= 1000;
// sint32 z;
// NLMISC::fromString(args[4], z);
// z *= 1000;
// //
// GameItemManager.dropOnTheGround( itemId, x, y, z ); // GameItemManager.dropOnTheGround( itemId, x, y, z );
// //
@ -936,20 +949,20 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
// if( args.size() < 6 ) // if( args.size() < 6 )
// { // {
// CSheetId sheetId(args[0]); // CSheetId sheetId(args[0]);
// uint16 quality = (uint16)atoi(args[1].c_str()); // uint16 quality = (uint16)NLMISC::fromString(args[1].c_str());
// sint32 x = (sint32)atoi(args[2].c_str()) * 1000; // sint32 x = (sint32)NLMISC::fromString(args[2].c_str()) * 1000;
// sint32 y = (sint32)atoi(args[3].c_str()) * 1000; // sint32 y = (sint32)NLMISC::fromString(args[3].c_str()) * 1000;
// sint32 z = (sint32)atoi(args[4].c_str()) * 1000; // sint32 z = (sint32)NLMISC::fromString(args[4].c_str()) * 1000;
// GameItemManager.createItem( sheetId, quality, x, y, z, true , true); // GameItemManager.createItem( sheetId, quality, x, y, z, true , true);
// } // }
// else // else
// { // {
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) ); // CEntityId itemId( RYZOMID::object, NLMISC::fromString(args[0].c_str()) );
// CSheetId sheetId(args[1]); // CSheetId sheetId(args[1]);
// uint16 quality = (uint16)atoi(args[2].c_str()); // uint16 quality = (uint16)NLMISC::fromString(args[2].c_str());
// sint32 x = (sint32)atoi(args[3].c_str()) * 1000; // sint32 x = (sint32)NLMISC::fromString(args[3].c_str()) * 1000;
// sint32 y = (sint32)atoi(args[4].c_str()) * 1000; // sint32 y = (sint32)NLMISC::fromString(args[4].c_str()) * 1000;
// sint32 z = (sint32)atoi(args[5].c_str()) * 1000; // sint32 z = (sint32)NLMISC::fromString(args[5].c_str()) * 1000;
// GameItemManager.createItem( itemId, sheetId, quality, x, y, z, true, true ); // GameItemManager.createItem( itemId, sheetId, quality, x, y, z, true, true );
// } // }
// //
@ -967,7 +980,7 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
// return false; // return false;
// } // }
// //
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) ); // CEntityId itemId( RYZOMID::object, NLMISC::fromString(args[0].c_str()) );
// CGameItemPtr ptr = GameItemManager.getItem(itemId); // CGameItemPtr ptr = GameItemManager.getItem(itemId);
// GameItemManager.destroyItem( ptr ); // GameItemManager.destroyItem( ptr );
// //

View file

@ -1954,7 +1954,8 @@ NLMISC_COMMAND(setFameMemory, "set a value in the fame history, reset the fame i
return false; return false;
} }
sint32 fame = atoi(args[2].c_str()); sint32 fame;
NLMISC::fromString(args[2], fame);
CFameManager &fm = CFameManager::getInstance(); CFameManager &fm = CFameManager::getInstance();
@ -2088,7 +2089,8 @@ NLMISC_COMMAND (adjustCharacterFame, "For a character, adjust a specific clan by
} }
// Third argument is the value // Third argument is the value
sint32 fameAdjustment = atoi(args[2].c_str()); sint32 fameAdjustment;
NLMISC::fromString(args[2], fameAdjustment);
CFameInterface::getInstance().addFameIndexed(id, factionIndex, fameAdjustment); CFameInterface::getInstance().addFameIndexed(id, factionIndex, fameAdjustment);
log.displayNL("Character's new fame value: %d",CFameInterface::getInstance().getFameIndexed(id,factionIndex)); log.displayNL("Character's new fame value: %d",CFameInterface::getInstance().getFameIndexed(id,factionIndex));
@ -2203,7 +2205,8 @@ NLMISC_COMMAND (adjustGuildFame, "For a guild, adjust a specific clan by indicat
} }
// Third argument is the value // Third argument is the value
sint32 fameAdjustment = atoi(args[2].c_str()); sint32 fameAdjustment;
NLMISC::fromString(args[2], fameAdjustment);
CFameInterface::getInstance().addFameIndexed(id, PVP_CLAN::getFactionIndex(theClan), fameAdjustment); CFameInterface::getInstance().addFameIndexed(id, PVP_CLAN::getFactionIndex(theClan), fameAdjustment);
log.displayNL("Guild's new fame value: %d",CFameInterface::getInstance().getFameIndexed(id,PVP_CLAN::getFactionIndex(theClan))); log.displayNL("Guild's new fame value: %d",CFameInterface::getInstance().getFameIndexed(id,PVP_CLAN::getFactionIndex(theClan)));

View file

@ -412,8 +412,10 @@ NLMISC_COMMAND(testGuildSetLeader,"set the leader of a guild","<userId> <index>
return true; return true;
CEntityId eId; CEntityId eId;
eId.fromString(args[0].c_str()); eId.fromString(args[0].c_str());
uint16 index = (uint16)atoi(args[1].c_str() ); uint16 index;
uint8 session = (uint8)atoi(args[2].c_str() ); NLMISC::fromString(args[1], index);
uint8 session;
NLMISC::fromString(args[2], session);
GET_GUILD_MODULE(eId); GET_GUILD_MODULE(eId);
module->setLeader( index,session ); module->setLeader( index,session );
log.displayNL("Command Executed"); log.displayNL("Command Executed");
@ -427,8 +429,10 @@ NLMISC_COMMAND(testGuildSetGrade,"set the grade of a member","<userId> <index> <
return false; return false;
CEntityId eId; CEntityId eId;
eId.fromString(args[0].c_str()); eId.fromString(args[0].c_str());
uint16 index = (uint16)atoi(args[1].c_str() ); uint16 index;
uint8 session = (uint8)atoi(args[2].c_str() ); NLMISC::fromString(args[1], index);
uint8 session;
NLMISC::fromString(args[2], session);
EGSPD::CGuildGrade::TGuildGrade grade = EGSPD::CGuildGrade::fromString( args[4] ); EGSPD::CGuildGrade::TGuildGrade grade = EGSPD::CGuildGrade::fromString( args[4] );
GET_GUILD_MODULE(eId); GET_GUILD_MODULE(eId);
module->setGrade(index,session, (EGSPD::CGuildGrade::TGuildGrade) grade); module->setGrade(index,session, (EGSPD::CGuildGrade::TGuildGrade) grade);
@ -471,7 +475,7 @@ NLMISC_COMMAND( importGuildFile, "Import a guild file into the server", "<filena
guildId = CGuildManager::getInstance()->getFreeGuildId(); guildId = CGuildManager::getInstance()->getFreeGuildId();
else else
{ {
guildId = atoi(args[1].c_str()); NLMISC::fromString(args[1], guildId);
if (guildId == 0) if (guildId == 0)
{ {
log.displayNL("Invalid specific guildId, must be a number or 'highest', found '%s'", args[1].c_str()); log.displayNL("Invalid specific guildId, must be a number or 'highest', found '%s'", args[1].c_str());
@ -495,7 +499,8 @@ NLMISC_COMMAND( importGuildFile, "Import a guild file into the server", "<filena
{ {
// load a binary file // load a binary file
string idStr = file.substr(6,5); string idStr = file.substr(6,5);
uint32 id = atoi( idStr.c_str() ); uint32 id;
NLMISC::fromString(idStr, id);
if (guildId != 0) if (guildId != 0)
id = guildId; id = guildId;
@ -524,7 +529,8 @@ NLMISC_COMMAND( importGuildFile, "Import a guild file into the server", "<filena
{ {
// Load a text file // Load a text file
string idStr = file.substr(6,5); string idStr = file.substr(6,5);
uint32 id = atoi( idStr.c_str() ); uint32 id;
NLMISC::fromString(idStr, id);
if (guildId != 0) if (guildId != 0)
id = guildId; id = guildId;

View file

@ -1067,7 +1067,8 @@ void CGuildManager::callback(const CFileDescriptionContainer& fileList)
BOMB_IF(pos == string::npos, "Invalid guild file "<<fd.FileName<<" returned by BS : can't find 'guild_' inside", continue); BOMB_IF(pos == string::npos, "Invalid guild file "<<fd.FileName<<" returned by BS : can't find 'guild_' inside", continue);
BOMB_IF(pos+6+5 >= fd.FileName.size(), "Invalid guild file "<<fd.FileName<<" returned by BS : not enough character after 'guild_'", continue); BOMB_IF(pos+6+5 >= fd.FileName.size(), "Invalid guild file "<<fd.FileName<<" returned by BS : not enough character after 'guild_'", continue);
TGuildId guildId = atoi(fd.FileName.substr(pos+6, 5).c_str()); TGuildId guildId;
NLMISC::fromString(fd.FileName.substr(pos+6, 5), guildId);
if (_GuildToLoad.find(guildId) != _GuildToLoad.end()) if (_GuildToLoad.find(guildId) != _GuildToLoad.end())
{ {
@ -1133,7 +1134,8 @@ void CGuildManager::callback(const CFileDescription& fileDescription, NLMISC::IS
BOMB_IF(pos == string::npos, "Invalid guild file "<<fileDescription.FileName<<" send by BS : can't find 'guild_' inside", return); BOMB_IF(pos == string::npos, "Invalid guild file "<<fileDescription.FileName<<" send by BS : can't find 'guild_' inside", return);
BOMB_IF(pos+6+5 >= fileDescription.FileName.size(), "Invalid guild file "<<fileDescription.FileName<<" send by BS : not enough character after 'guild_'", return); BOMB_IF(pos+6+5 >= fileDescription.FileName.size(), "Invalid guild file "<<fileDescription.FileName<<" send by BS : not enough character after 'guild_'", return);
TGuildId guildId = atoi(fileDescription.FileName.substr(pos+6, 5).c_str()); TGuildId guildId;
NLMISC::fromString(fileDescription.FileName.substr(pos+6, 5), guildId);
BOMB_IF(guildId == 0, "Invalid guild file name '"<<fileDescription.FileName<<"' : can't found a valid guild id", return); BOMB_IF(guildId == 0, "Invalid guild file name '"<<fileDescription.FileName<<"' : can't found a valid guild id", return);
@ -1859,7 +1861,9 @@ NLMISC_CLASS_COMMAND_IMPL(CGuildManager, loadGuild)
return true; return true;
} }
TGuildId guildId = (atoi(args[0].substr(pos+6, 5).c_str())) & 0xfffff; TGuildId guildId;
NLMISC::fromString(args[0].substr(pos+6, 5), guildId);
guildId = guildId & 0xfffff;
if (guildId == 0) if (guildId == 0)
{ {
log.displayNL("Invalid guild ID in '%s'", args[0].c_str()); log.displayNL("Invalid guild ID in '%s'", args[0].c_str());
@ -1928,7 +1932,8 @@ NLMISC_CLASS_COMMAND_IMPL(CGuildManager, addGuildMember)
// if (args.size() > 3) // if (args.size() > 3)
// return false; // return false;
// //
// TGuildId guildId = atoi(args[0].c_str()); // TGuildId guildId;
// NLMISC::fromString(args[0], guildId);
// //
// CGuild *guild = getGuildFromId(guildId); // CGuild *guild = getGuildFromId(guildId);
// if (guild == NULL) // if (guild == NULL)

View file

@ -1191,10 +1191,6 @@ NLMISC_VARIABLE( sint32, ForageSourceDisplay, "Row index of source to verbose" )
TDataSetRow TestSourceRow; TDataSetRow TestSourceRow;
#define astof(i) ((float)(atoi( args[i].c_str() )))
void forageTestDoBegin() void forageTestDoBegin()
{ {
CHarvestSource templateSource, *testSource; CHarvestSource templateSource, *testSource;
@ -1323,21 +1319,25 @@ NLMISC_COMMAND( forageTestExtract, "Make a test extraction (floats in percent)",
float successFactor = 1.0f; float successFactor = 1.0f;
if ( n > 0 ) if ( n > 0 )
{ {
nbIterations = atoi( args[0].c_str() ); NLMISC::fromString(args[0], nbIterations);
if ( n > 1 ) if ( n > 1 )
{ {
reqPeriod = astof( 1 ); NLMISC::fromString(args[1], reqPeriod);
if ( n > 2) if ( n > 2)
{ {
reqA = astof( 2 ); NLMISC::fromString(args[2], reqA);
if ( n > 3 ) if ( n > 3 )
{ {
reqQ = astof( 3 ); NLMISC::fromString(args[3], reqQ);
if ( n > 34) if ( n > 4)
{ {
absorption = astof( 4 ) / 100.0f; NLMISC::fromString(args[4], absorption);
absorption /= 100.0f;
if ( n > 5 ) if ( n > 5 )
successFactor = astof( 5 ) / 100.0f; {
NLMISC::fromString(args[5], successFactor);
successFactor /= 100.0f;
}
} }
} }
} }

View file

@ -215,8 +215,10 @@ NLMISC_COMMAND(setShardExchangeLimit, "set the level limit for items exchanged b
return false; return false;
// get numeric values for the 2 arguments // get numeric values for the 2 arguments
IInterShardExchangeValidator::TShardId shardId= (IInterShardExchangeValidator::TShardId)atoi(args[0].c_str()); IInterShardExchangeValidator::TShardId shardId;
IInterShardExchangeValidator::TLevelCap levelCap= (IInterShardExchangeValidator::TLevelCap)atoi(args[1].c_str()); NLMISC::fromString(args[0], shardId);
IInterShardExchangeValidator::TLevelCap levelCap;
NLMISC::fromString(args[1], levelCap);
// make sure the numeric conversion was successfule for the 2 arguments // make sure the numeric conversion was successfule for the 2 arguments
if (NLMISC::toString(shardId)!=args[0] || NLMISC::toString(levelCap)!=args[1]) if (NLMISC::toString(shardId)!=args[0] || NLMISC::toString(levelCap)!=args[1])
@ -238,7 +240,8 @@ NLMISC_COMMAND(resetShardExchangeLimit, "reset the level limit for items exchang
return false; return false;
// get numeric values for the 2 arguments // get numeric values for the 2 arguments
IInterShardExchangeValidator::TShardId shardId= (IInterShardExchangeValidator::TShardId)atoi(args[0].c_str()); IInterShardExchangeValidator::TShardId shardId;
NLMISC::fromString(args[0], shardId);
// make sure the numeric conversion was successfule for the 2 arguments // make sure the numeric conversion was successfule for the 2 arguments
if (NLMISC::toString(shardId)!=args[0]) if (NLMISC::toString(shardId)!=args[0])

View file

@ -195,7 +195,8 @@ void CAIAliasTranslator::buildMissionTree(const NLLIGO::IPrimitive* prim)
nlwarning("<CAIAliasTranslator buildMissionTree> no alias property in a mission node"); nlwarning("<CAIAliasTranslator buildMissionTree> no alias property in a mission node");
error = true; error = true;
} }
// TAIAlias id = atoi( value.c_str() ); // TAIAlias id;
// NLMISC::fromString(value, id);
if ( !prim->getPropertyByName("name",name) ) if ( !prim->getPropertyByName("name",name) )
{ {
nlwarning("<CAIAliasTranslator buildMissionTree> no name property in a mission node"); nlwarning("<CAIAliasTranslator buildMissionTree> no name property in a mission node");

View file

@ -521,7 +521,7 @@ class CMissionActionRecvItem : public IMissionAction
_Quantity = 1; _Quantity = 1;
if ( args.size() >= 2) if ( args.size() >= 2)
_Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Quantity);
uint i = 0; uint i = 0;
for (; i < missionData.Items.size(); i++ ) for (; i < missionData.Items.size(); i++ )
@ -552,7 +552,7 @@ class CMissionActionRecvItem : public IMissionAction
_Quality = 1; _Quality = 1;
if ( args.size() == 3 ) if ( args.size() == 3 )
{ {
_Quality = atoi(args[2].c_str()); NLMISC::fromString(args[2], _Quality);
if ( _Quality == 0 ) if ( _Quality == 0 )
{ {
MISLOGERROR("quality = 0"); MISLOGERROR("quality = 0");
@ -802,7 +802,7 @@ class CMissionActionRecvNamedItem : public IMissionAction
// read quantity // read quantity
_Quantity = 1; _Quantity = 1;
if ( args.size() >= 2) if ( args.size() >= 2)
_Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Quantity);
// read group // read group
_Group = false; _Group = false;
@ -972,7 +972,7 @@ public:
// read the quantity, or 1 by default // read the quantity, or 1 by default
_Quantity = 1; _Quantity = 1;
if ( args.size() >= 2) if ( args.size() >= 2)
_Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Quantity);
// If the name of the item macthes one of the special defined mission items for this mission // If the name of the item macthes one of the special defined mission items for this mission
uint i = 0; uint i = 0;
@ -1008,7 +1008,7 @@ public:
_Quality = 1; _Quality = 1;
if ( args.size() == 3 ) if ( args.size() == 3 )
{ {
_Quality = atoi(args[2].c_str()); NLMISC::fromString(args[2], _Quality);
if ( _Quality == 0 ) if ( _Quality == 0 )
{ {
MISLOGERROR("quality = 0"); MISLOGERROR("quality = 0");
@ -1622,7 +1622,7 @@ class CMissionActionRecvMoney : public IMissionAction
CMissionParser::tokenizeString( multiArgs[0]," \t",args ); CMissionParser::tokenizeString( multiArgs[0]," \t",args );
if ( args.size() == 1 ) if ( args.size() == 1 )
{ {
_Amount = (uint)atoi( script[1].c_str() ); NLMISC::fromString(script[1], _Amount);
} }
else if ( !CMissionParser::addItemPrice( _SourceLine, args,_Amount ) ) else if ( !CMissionParser::addItemPrice( _SourceLine, args,_Amount ) )
ret = false; ret = false;
@ -1694,7 +1694,7 @@ class CMissionActionRecvFame : public IMissionAction
MISLOGERROR1("invalid faction '%s'", args[0].c_str()); MISLOGERROR1("invalid faction '%s'", args[0].c_str());
return false; return false;
} }
_Value = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Value);
if ( _Value == 0 ) if ( _Value == 0 )
{ {
MISLOGERROR("fame = 0"); MISLOGERROR("fame = 0");
@ -1757,7 +1757,7 @@ class CMissionActionRecvXp : public IMissionAction
} }
// parse gain // parse gain
_Value = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Value);
if (_Value <= 0) if (_Value <= 0)
{ {
MISLOGERROR("XP amount <= 0"); MISLOGERROR("XP amount <= 0");
@ -1827,7 +1827,7 @@ class CMissionActionRecvFactionPoint : public IMissionAction
MISLOGERROR1("invalid faction '%s'", args[0].c_str()); MISLOGERROR1("invalid faction '%s'", args[0].c_str());
return false; return false;
} }
_Value = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Value);
if (_Value == 0) if (_Value == 0)
{ {
MISLOGERROR("faction points = 0"); MISLOGERROR("faction points = 0");
@ -2195,7 +2195,7 @@ class CMissionActionCondJumpSkill : public CMissionActionJump
MISLOGERROR2("invalid skill name (%uth skill) '%s'", i, parts[0].c_str()); MISLOGERROR2("invalid skill name (%uth skill) '%s'", i, parts[0].c_str());
return false; return false;
} }
level = atoi(parts[1].c_str()); NLMISC::fromString(parts[1], level);
if (level == 0) if (level == 0)
{ {
MISLOGERROR2("invalid skill value (%uth skill) '%s'", i, sn[i].c_str()); MISLOGERROR2("invalid skill value (%uth skill) '%s'", i, sn[i].c_str());
@ -2599,7 +2599,7 @@ class CMissionActionAIEvent : public IMissionAction
MISLOGERROR1("invalid group '%s'", sGroup.c_str() ); MISLOGERROR1("invalid group '%s'", sGroup.c_str() );
ret = false; ret = false;
} }
EventId = (uint8) atoi( args[1].c_str() ); NLMISC::fromString(args[1], EventId);
if( EventId > 9) if( EventId > 9)
{ {
MISLOGERROR1("invalid event '%s' ( [0-9] )", args[1].c_str() ); MISLOGERROR1("invalid event '%s' ( [0-9] )", args[1].c_str() );
@ -2656,7 +2656,7 @@ class CMissionActionTimer : public IMissionAction
MISLOGSYNTAXERROR("<delay>"); MISLOGSYNTAXERROR("<delay>");
return false; return false;
} }
Delay = ( NLMISC::TGameCycle ) atoi( script[1].c_str() ); NLMISC::fromString(script[1], Delay);
return true; return true;
} }
void launch(CMission* instance, std::list< CMissionEvent * > & eventList) void launch(CMission* instance, std::list< CMissionEvent * > & eventList)
@ -2699,8 +2699,10 @@ class CMissionActionDayPeriod : public IMissionAction
MISLOGSYNTAXERROR("<hour> <min>; <hour> <min>"); MISLOGSYNTAXERROR("<hour> <min>; <hour> <min>");
return false; return false;
} }
uint hour = (uint)atoi(params[0].c_str()); uint hour;
uint min = (uint)atoi(params[1].c_str()); NLMISC::fromString(params[0], hour);
uint min;
NLMISC::fromString(params[1], min);
if ( hour < 0 || hour >23 ) if ( hour < 0 || hour >23 )
{ {
MISLOGERROR("hour must be between 0 and 23"); MISLOGERROR("hour must be between 0 and 23");
@ -2721,8 +2723,8 @@ class CMissionActionDayPeriod : public IMissionAction
MISLOGSYNTAXERROR("<hour> <min>; <hour> <min>"); MISLOGSYNTAXERROR("<hour> <min>; <hour> <min>");
return false; return false;
} }
hour = (uint) atoi(params[0].c_str()); NLMISC::fromString(params[0], hour);
min = (uint)atoi(params[1].c_str()); NLMISC::fromString(params[1], min);
if ( hour < 0 || hour >23 ) if ( hour < 0 || hour >23 )
{ {
MISLOGERROR("hour must be between 0 and 23"); MISLOGERROR("hour must be between 0 and 23");
@ -2857,7 +2859,7 @@ public:
uint16 quantity = 1; uint16 quantity = 1;
if ( args.size() >= 2) if ( args.size() >= 2)
quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], quantity);
for (uint i = 0; i < items.size(); i++ ) for (uint i = 0; i < items.size(); i++ )
{ {
@ -2883,7 +2885,7 @@ public:
uint16 quality = 1; uint16 quality = 1;
if ( args.size() == 3 ) if ( args.size() == 3 )
{ {
quality = atoi(args[2].c_str()); NLMISC::fromString(args[2], quality);
if ( quality == 0 ) if ( quality == 0 )
{ {
MISLOG("sline:%u syntax error quality = 0", line); MISLOG("sline:%u syntax error quality = 0", line);
@ -3285,7 +3287,7 @@ class CMissionActionRecvChargePoint : public IMissionAction
MISLOGSYNTAXERROR("<_ChargesPoints>"); MISLOGSYNTAXERROR("<_ChargesPoints>");
return false; return false;
} }
_ChargesPoints = (uint32)atoi( script[1].c_str() ); NLMISC::fromString(script[1], _ChargesPoints);
if (_ChargesPoints == 0) if (_ChargesPoints == 0)
{ {
MISLOGERROR("_ChargesPoints = 0"); MISLOGERROR("_ChargesPoints = 0");
@ -3500,7 +3502,7 @@ class CMissionActionRecvGuildXp : public IMissionAction
MISLOGSYNTAXERROR("<amount>"); MISLOGSYNTAXERROR("<amount>");
return false; return false;
} }
Amount = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Amount);
return true; return true;
} }
void launch(CMission* instance, std::list< CMissionEvent * > & eventList) void launch(CMission* instance, std::list< CMissionEvent * > & eventList)
@ -3550,7 +3552,7 @@ class CMissionActionInside : public IMissionAction
} }
Place = place->getId(); Place = place->getId();
if ( script.size() == 3 ) if ( script.size() == 3 )
Delay = (NLMISC::TGameCycle)atoi( script[2].c_str() ); NLMISC::fromString(script[2], Delay);
else else
Delay = 300; Delay = 300;
return true; return true;
@ -3592,7 +3594,7 @@ class CMissionActionOutside: public IMissionAction
} }
Place = place->getId(); Place = place->getId();
if ( script.size() == 3 ) if ( script.size() == 3 )
Delay = (NLMISC::TGameCycle)atoi( script[2].c_str() ); NLMISC::fromString(script[2], Delay);
else else
Delay = 300; Delay = 300;
return true; return true;
@ -3828,8 +3830,8 @@ class CMissionActionEncycloUnlock : public IMissionAction
return false; return false;
} }
AlbumNb = atoi( vars[0].c_str() ); NLMISC::fromString(vars[0], AlbumNb);
ThemaNb = atoi( vars[1].c_str() ); NLMISC::fromString(vars[1], ThemaNb);
return true; return true;
} }
@ -4088,7 +4090,7 @@ class CMissionActionSDBSet : public IMissionAction
_SDBPath = CMissionParser::getNoBlankString(script[1]); _SDBPath = CMissionParser::getNoBlankString(script[1]);
nlassert(!_SDBPath.empty()); nlassert(!_SDBPath.empty());
_SDBValue = atoi(CMissionParser::getNoBlankString(script[2]).c_str()); NLMISC::fromString(CMissionParser::getNoBlankString(script[2]), _SDBValue);
return true; return true;
} }
@ -4126,7 +4128,7 @@ class CMissionActionSDBAdd : public IMissionAction
_SDBPath = CMissionParser::getNoBlankString(script[1]); _SDBPath = CMissionParser::getNoBlankString(script[1]);
nlassert(!_SDBPath.empty()); nlassert(!_SDBPath.empty());
_SDBDelta = atoi(CMissionParser::getNoBlankString(script[2]).c_str()); NLMISC::fromString(CMissionParser::getNoBlankString(script[2]), _SDBDelta);
return true; return true;
} }
@ -4164,7 +4166,7 @@ class CMissionActionSDBPlayerAdd : public IMissionAction
_SDBPath = CMissionParser::getNoBlankString(script[1]); _SDBPath = CMissionParser::getNoBlankString(script[1]);
nlassert(!_SDBPath.empty()); nlassert(!_SDBPath.empty());
_SDBDelta = atoi(CMissionParser::getNoBlankString(script[2]).c_str()); NLMISC::fromString(CMissionParser::getNoBlankString(script[2]), _SDBDelta);
return true; return true;
} }
@ -4568,7 +4570,7 @@ public:
} }
factionIndex = CStaticFames::getInstance().getFactionIndex( CMissionParser::getNoBlankString(script[1])); factionIndex = CStaticFames::getInstance().getFactionIndex( CMissionParser::getNoBlankString(script[1]));
fameValue = atoi( CMissionParser::getNoBlankString(script[2]).c_str() ); NLMISC::fromString( CMissionParser::getNoBlankString(script[2]), fameValue);
if( factionIndex == CStaticFames::INVALID_FACTION_INDEX ) if( factionIndex == CStaticFames::INVALID_FACTION_INDEX )
{ {
@ -4701,7 +4703,9 @@ public:
return false; return false;
} }
Items.push_back( retList[0] ); Items.push_back( retList[0] );
ItemQty.push_back( atoi(retList[1].c_str()) ); sint16 quantity;
NLMISC::fromString(retList[1], quantity);
ItemQty.push_back(quantity);
} }
Label = CMissionParser::getNoBlankString(script[script.size()-1]); Label = CMissionParser::getNoBlankString(script[script.size()-1]);

View file

@ -207,7 +207,7 @@ bool CMissionEventGiveMoney::buildFromScript( const std::vector< std::string > &
log.displayNL("<money>"); log.displayNL("<money>");
return false; return false;
} }
Amount = atoi( script[0].c_str() ); NLMISC::fromString(script[0], Amount);
log.displayNL("Not the best way to test this event : bot chat needed"); log.displayNL("Not the best way to test this event : bot chat needed");
return true; return true;
} }
@ -283,8 +283,8 @@ bool CMissionEventBuyItem::buildFromScript( const std::vector< std::string > & s
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Quantity = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Quantity);
Quality = atoi( script[2].c_str() ); NLMISC::fromString(script[2], Quality);
if (script.size() == 4) if (script.size() == 4)
{ {
CEntityId id; CEntityId id;
@ -315,8 +315,8 @@ bool CMissionEventSellItem::buildFromScript( const std::vector< std::string > &
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Quantity = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Quantity);
Quality = atoi( script[2].c_str() ); NLMISC::fromString(script[2], Quality);
if (script.size() == 4) if (script.size() == 4)
{ {
CEntityId id; CEntityId id;
@ -348,8 +348,8 @@ bool CMissionEventForage::buildFromScript( const std::vector< std::string > & sc
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Quantity = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Quantity);
Quality = atoi( script[2].c_str() ); NLMISC::fromString(script[2], Quality);
return ret; return ret;
} }
@ -380,7 +380,7 @@ bool CMissionEventSkillProgress::buildFromScript( const std::vector< std::string
ret = false; ret = false;
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Level = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Level);
return ret; return ret;
} }
@ -419,8 +419,8 @@ bool CMissionEventCraft::buildFromScript( const std::vector< std::string > & scr
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Quantity = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Quantity);
Quality = atoi( script[2].c_str() ); NLMISC::fromString(script[2], Quality);
return ret; return ret;
} }
@ -464,8 +464,8 @@ bool CMissionEventLootItem::buildFromScript( const std::vector< std::string > &
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Quantity = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Quantity);
Quality = atoi( script[2].c_str() ); NLMISC::fromString(script[2], Quality);
return ret; return ret;
} }
@ -485,8 +485,8 @@ bool CMissionEventLootRm::buildFromScript( const std::vector< std::string > & sc
log.displayNL("Invalid sheet %s",script[0].c_str() ); log.displayNL("Invalid sheet %s",script[0].c_str() );
} }
Quantity = atoi( script[1].c_str() ); NLMISC::fromString(script[1], Quantity);
Quality = atoi( script[2].c_str() ); NLMISC::fromString(script[2], Quality);
return ret; return ret;
} }
@ -498,8 +498,8 @@ bool CMissionEventKillGroup::buildFromScript( const std::vector< std::string > &
log.displayNL("<alias>"); log.displayNL("<alias>");
return false; return false;
} }
Alias = (TAIAlias)atoi(script[0].c_str()); NLMISC::fromString(script[0], Alias);
return ret; return ret;
} }

View file

@ -52,7 +52,7 @@ bool CMissionItem::buildFromScript( const std::vector<std::string> & script, std
MISLOG("Invalid sitem sheet '%s'", (CMissionParser::getNoBlankString( script[1] ) + ".sitem").c_str()); MISLOG("Invalid sitem sheet '%s'", (CMissionParser::getNoBlankString( script[1] ) + ".sitem").c_str());
ret = false; ret = false;
} }
_Quality = (uint16) atoi( script[3].c_str() ); NLMISC::fromString(script[3], _Quality);
for ( uint i = 4; i < script.size(); i++) for ( uint i = 4; i < script.size(); i++)
{ {
@ -101,16 +101,17 @@ bool CMissionItem::buildFromScript( const std::vector<std::string> & script, std
_Params.MaxPiercingProtection = (float)atof(args[1].c_str()); _Params.MaxPiercingProtection = (float)atof(args[1].c_str());
else if( !nlstricmp(args[0],"HpBuff" ) ) else if( !nlstricmp(args[0],"HpBuff" ) )
_Params.HpBuff = atoi(args[1].c_str()); NLMISC::fromString(args[1], _Params.HpBuff);
else if( !nlstricmp(args[0],"SapBuff" ) ) else if( !nlstricmp(args[0],"SapBuff" ) )
_Params.SapBuff = atoi(args[1].c_str()); NLMISC::fromString(args[1], _Params.SapBuff);
else if( !nlstricmp(args[0],"StaBuff" ) ) else if( !nlstricmp(args[0],"StaBuff" ) )
_Params.StaBuff = atoi(args[1].c_str()); NLMISC::fromString(args[1], _Params.StaBuff);
else if( !nlstricmp(args[0],"FocusBuff" ) ) else if( !nlstricmp(args[0],"FocusBuff" ) )
_Params.FocusBuff = atoi(args[1].c_str()); NLMISC::fromString(args[1], _Params.FocusBuff);
else if( !nlstricmp(args[0],"Color" ) ) else if( !nlstricmp(args[0],"Color" ) )
{ {
uint8 color = (uint8)atoi(args[1].c_str()); uint8 color;
NLMISC::fromString(args[1], color);
if( color <= 7 ) if( color <= 7 )
{ {
_Params.Color[color] = 1; _Params.Color[color] = 1;

View file

@ -72,7 +72,7 @@ bool CMissionParser::solveTextsParams(uint32 lineNum, TVectorParamCheck & txtPar
if ( j == paramTypes.size() ) if ( j == paramTypes.size() )
{ {
txtParams[i].Type = STRING_MANAGER::integer; txtParams[i].Type = STRING_MANAGER::integer;
txtParams[i].Int = atoi( txtParams[i].Identifier.c_str() ); NLMISC::fromString( txtParams[i].Identifier, txtParams[i].Int);
if ( txtParams[i].Int == 0 && txtParams[i].Identifier != "0" ) if ( txtParams[i].Int == 0 && txtParams[i].Identifier != "0" )
{ {
MISLOG("<MISSIONS> at line %u: param '%s' has an unknown type", lineNum, txtParams[i].Identifier.c_str()); MISLOG("<MISSIONS> at line %u: param '%s' has an unknown type", lineNum, txtParams[i].Identifier.c_str());
@ -382,7 +382,8 @@ bool CMissionParser::addItemPrice(uint32 line, const vector<string>& args, uint
MISLOG("<MISSIONS> line %u: syntax error sheetId '%s' is unknon", line, sheetName.c_str() ) ; MISLOG("<MISSIONS> line %u: syntax error sheetId '%s' is unknon", line, sheetName.c_str() ) ;
ret = false; ret = false;
} }
uint16 quality = (uint16) atoi( args[1].c_str() ); uint16 quality;
NLMISC::fromString(args[1], quality);
if ( quality == 0 ) if ( quality == 0 )
{ {
MISLOG("<MISSIONS> line %u: syntax error quality is 0 ('%s')", line, args[1].c_str() ) ; MISLOG("<MISSIONS> line %u: syntax error quality is 0 ('%s')", line, args[1].c_str() ) ;

View file

@ -49,7 +49,7 @@ class CMissionStepGainChargePoint : public IMissionStepTemplate
MISLOGSYNTAXERROR("<points>"); MISLOGSYNTAXERROR("<points>");
return false; return false;
} }
_ChargePoints = uint32(atoi( script[1].c_str() )); NLMISC::fromString(script[1], _ChargePoints);
if ( _ChargePoints == 0 ) if ( _ChargePoints == 0 )
{ {
MISLOGERROR("charge points = 0"); MISLOGERROR("charge points = 0");

View file

@ -68,14 +68,14 @@ bool IMissionStepItem::buildStep( uint32 line, const std::vector< std::string >
subStep.Sheet = CSheetId( args[0] + ".sitem" ); subStep.Sheet = CSheetId( args[0] + ".sitem" );
missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::item ) ); missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::item ) );
if ( args.size() > 1 ) if ( args.size() > 1 )
subStep.Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], subStep.Quantity);
else else
subStep.Quantity = 1; subStep.Quantity = 1;
if ( args.size() == 3 ) if ( args.size() == 3 )
{ {
subStep.Quality = atoi( args[2].c_str() ); NLMISC::fromString(args[2], subStep.Quality);
qualityFound = true;; qualityFound = true;
} }
else else
{ {

View file

@ -81,7 +81,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
ret = false; ret = false;
MISLOGERROR1("invalid sheet '%s'", args[0].c_str()); MISLOGERROR1("invalid sheet '%s'", args[0].c_str());
} }
subStep.Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], subStep.Quantity);
_SubSteps.push_back(subStep); _SubSteps.push_back(subStep);
} }
if ( script.size() == 3 ) if ( script.size() == 3 )
@ -245,7 +245,7 @@ class CMissionStepKillRace : public IMissionStepTemplate
ret = false; ret = false;
MISLOGERROR1("invalid race '%s'", args[0].c_str()); MISLOGERROR1("invalid race '%s'", args[0].c_str());
} }
subStep.Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], subStep.Quantity);
_SubSteps.push_back( subStep ); _SubSteps.push_back( subStep );
} }
if ( script.size() == 3 ) if ( script.size() == 3 )
@ -608,7 +608,7 @@ class CMissionStepKillFaction : public IMissionStepTemplate
ret = false; ret = false;
MISLOGERROR1("invalid faction '%s'", args[0].c_str()); MISLOGERROR1("invalid faction '%s'", args[0].c_str());
} }
_Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], _Quantity);
if ( script.size() == 3 ) if ( script.size() == 3 )
{ {
@ -768,7 +768,7 @@ class CMissionStepKillByName : public IMissionStepTemplate
Aliases.insert(va.begin(), va.end()); Aliases.insert(va.begin(), va.end());
} }
Quantity = (uint16) atoi( args[1].c_str() ); NLMISC::fromString(args[1], Quantity);
if ( Quantity == 0 ) if ( Quantity == 0 )
{ {
MISLOGERROR("invalid quantity 0"); MISLOGERROR("invalid quantity 0");

View file

@ -757,7 +757,7 @@ class CMissionStepSkill : public IMissionStepTemplate
CSubStep subStep; CSubStep subStep;
subStep.Skill = SKILLS::toSkill( args[0] ); subStep.Skill = SKILLS::toSkill( args[0] );
missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::skill ) ); missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::skill ) );
subStep.Level = atoi( args[1].c_str() ); NLMISC::fromString(args[1], subStep.Level);
if ( subStep.Skill == SKILLS::unknown ) if ( subStep.Skill == SKILLS::unknown )
{ {
ret = false; ret = false;
@ -1289,7 +1289,7 @@ bool CMissionStepHandleCreate::buildStep( uint32 line, const std::vector< std::s
GroupAlias = aliases[0]; GroupAlias = aliases[0];
DespawnTime = 0; DespawnTime = 0;
if (script.size() == 3) if (script.size() == 3)
DespawnTime = atoi(CMissionParser::getNoBlankString( script[2] ).c_str()); NLMISC::fromString(CMissionParser::getNoBlankString( script[2] ), DespawnTime);
return true; return true;
} }

View file

@ -67,7 +67,7 @@ bool CMissionStepQueueStart::buildStep( uint32 line, const vector< string > & sc
pos = QueueName.find_first_of(" "); pos = QueueName.find_first_of(" ");
} }
Timer = (uint32)atoi(script[2].c_str()); NLMISC::fromString(script[2], Timer);
return true; return true;
} }

View file

@ -184,7 +184,7 @@ class CMissionGiveMoney : public IMissionStepTemplate
MISLOGSYNTAXERROR("<amount><npc_name>"); MISLOGSYNTAXERROR("<amount><npc_name>");
return false; return false;
} }
_Amount = (uint)atoi(script[1].c_str()); NLMISC::fromString(script[1], _Amount);
if ( !CMissionParser::parseBotName(script[2],_Bot,missionData) ) if ( !CMissionParser::parseBotName(script[2],_Bot,missionData) )
{ {
@ -322,7 +322,7 @@ class CMissionStepGiveItem : public IMissionStepTemplate
CSubStep subStep; CSubStep subStep;
subStep.Sheet = CSheetId( CMissionParser::getNoBlankString(args[0]) + ".sitem" ); subStep.Sheet = CSheetId( CMissionParser::getNoBlankString(args[0]) + ".sitem" );
missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::item ) ); missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::item ) );
subStep.Quantity = atoi( args[1].c_str() ); NLMISC::fromString(args[1], subStep.Quantity);
if ( subStep.Sheet == CSheetId::Unknown ) if ( subStep.Sheet == CSheetId::Unknown )
{ {
ret = false; ret = false;
@ -332,7 +332,7 @@ class CMissionStepGiveItem : public IMissionStepTemplate
{ {
if( args.size() == 3 ) if( args.size() == 3 )
{ {
subStep.Quality = atoi( args[2].c_str() ); NLMISC::fromString(args[2], subStep.Quality);
Quality = true; Quality = true;
} }
else else

View file

@ -421,7 +421,7 @@ bool CMissionTemplate::build(const NLLIGO::IPrimitive* prim,CMissionGlobalParsin
else if ( script[0] == "mono" ) else if ( script[0] == "mono" )
{ {
if ( script.size() > 1) if ( script.size() > 1)
MonoTimer = (NLMISC::TGameCycle)atoi(script[1].c_str()); NLMISC::fromString(script[1], MonoTimer);
else else
MonoTimer = MonoMissionTimout; MonoTimer = MonoMissionTimout;
} }
@ -515,8 +515,8 @@ bool CMissionTemplate::build(const NLLIGO::IPrimitive* prim,CMissionGlobalParsin
Prerequisits.EncycloReqTaskDone = true; Prerequisits.EncycloReqTaskDone = true;
else else
Prerequisits.EncycloReqTaskDone = false; Prerequisits.EncycloReqTaskDone = false;
Prerequisits.EncycloReqAlbum = atoi(vars[0].c_str()); NLMISC::fromString(vars[0], Prerequisits.EncycloReqAlbum);
Prerequisits.EncycloReqThema = atoi(vars[1].c_str()); NLMISC::fromString(vars[1], Prerequisits.EncycloReqThema);
} }
} }
} }
@ -2431,9 +2431,9 @@ bool CMissionTemplate::addSkillToList( uint32 line, const std::vector< std::stri
skill.Min = 1; skill.Min = 1;
skill.Max = 0x7FFFFFFF; skill.Max = 0x7FFFFFFF;
if ( args.size() > 1 ) if ( args.size() > 1 )
skill.Min = atoi( args[1].c_str() ); NLMISC::fromString(args[1], skill.Min);
if ( args.size() == 3 ) if ( args.size() == 3 )
skill.Max = atoi( args[2].c_str() ); NLMISC::fromString(args[2], skill.Max);
if ( args.size() >= 4 ) if ( args.size() >= 4 )
{ {
MISLOGSYNTAXERROR( "<skill_name> [<min_level> [<max_level>]] *[;<skill_name> [<min_level> [<max_level>]] ]"); MISLOGSYNTAXERROR( "<skill_name> [<min_level> [<max_level>]] *[;<skill_name> [<min_level> [<max_level>]] ]");
@ -2516,7 +2516,7 @@ bool CMissionTemplate::parseFamePrereq(uint32 line, const std::vector< std::stri
return false; return false;
} }
Prerequisits.FameId = CStringMapper::map( vars[0] ); Prerequisits.FameId = CStringMapper::map( vars[0] );
Prerequisits.FameMin = atoi( vars[1].c_str() ); NLMISC::fromString(vars[1], Prerequisits.FameMin);
return true; return true;
} }
}// CMissionTemplate parseFamePrereq }// CMissionTemplate parseFamePrereq
@ -2550,7 +2550,7 @@ bool CMissionTemplate::parseInt(uint32 line, const std::vector< std::string > &
} }
else else
{ {
ret = atoi( script[1].c_str() ); NLMISC::fromString(script[1], ret);
return true; return true;
} }
}// CMissionTemplate parseInt }// CMissionTemplate parseInt

View file

@ -161,7 +161,8 @@ NLMISC_COMMAND(addSuccessfulMission,"add a successful mission to the player","<p
CCharacter * user = PlayerManager.getChar( id ); CCharacter * user = PlayerManager.getChar( id );
if (user) if (user)
{ {
TAIAlias alias = atoi( args[1].c_str() ); TAIAlias alias;
NLMISC::fromString(args[1], alias);
const CHashMap< uint,CMissionTemplate* > &mts = CMissionManager::getInstance()->getMissionTemplates(); const CHashMap< uint,CMissionTemplate* > &mts = CMissionManager::getInstance()->getMissionTemplates();
if (mts.find(alias) == mts.end()) if (mts.find(alias) == mts.end())
{ {
@ -196,7 +197,8 @@ NLMISC_COMMAND(createMissionItem,"","")
return true; return true;
} }
uint16 quantity = (uint16) atoi(args[1].c_str() ); uint16 quantity;
NLMISC::fromString(args[1], quantity);
std::vector< std::string > script; std::vector< std::string > script;
vector< pair<string, STRING_MANAGER::TParamType > > chatParams; vector< pair<string, STRING_MANAGER::TParamType > > chatParams;
@ -498,7 +500,8 @@ NLMISC_COMMAND(removeMission,"Remove mission of character","<character_id> <miss
GET_CHARACTER GET_CHARACTER
TAIAlias missionAlias = (TAIAlias)atoi(args[1].c_str()); TAIAlias missionAlias;
NLMISC::fromString(args[1], missionAlias);
c->removeMission(missionAlias, 0); c->removeMission(missionAlias, 0);
c->removeMissionFromHistories(missionAlias); c->removeMissionFromHistories(missionAlias);
@ -520,9 +523,11 @@ NLMISC_COMMAND(addMission,"Add mission to character","<character_id> <Mission gi
GET_CHARACTER GET_CHARACTER
TAIAlias giverAlias = (TAIAlias)atoi(args[1].c_str()); TAIAlias giverAlias;
NLMISC::fromString(args[1], giverAlias);
TAIAlias missionAlias = (TAIAlias)atoi(args[2].c_str()); TAIAlias missionAlias;
NLMISC::fromString(args[2], missionAlias);
c->endBotChat(); c->endBotChat();
c->setAfkState(false); c->setAfkState(false);

View file

@ -240,7 +240,8 @@ public:
if (args.size() != 1) if (args.size() != 1)
return false; return false;
TSessionId sessionId(atoi(args[0].c_str())); TSessionId sessionId;
NLMISC::fromString(args[0], sessionId);
if (sessionId == 0) if (sessionId == 0)
{ {
log.displayNL("Invalid session id '%s'", args[0].c_str()); log.displayNL("Invalid session id '%s'", args[0].c_str());

View file

@ -747,7 +747,8 @@ NLMISC_CLASS_COMMAND_IMPL(CCharacterControl, disconnectChar)
return false; return false;
} }
uint32 charId = atoi(args[0].c_str()); uint32 charId;
NLMISC::fromString(args[0], charId);
log.displayNL("Try to disconnect char %u", charId); log.displayNL("Try to disconnect char %u", charId);
this->disconnectChar(0, charId); this->disconnectChar(0, charId);
@ -763,7 +764,8 @@ NLMISC_CLASS_COMMAND_IMPL(CCharacterControl, returnToPreviousSession)
return false; return false;
} }
uint32 charId = atoi(args[0].c_str()); uint32 charId;
NLMISC::fromString(args[0], charId);
log.displayNL("Try to returnToMainLand char %u", charId); log.displayNL("Try to returnToMainLand char %u", charId);
this->returnToPreviousSession(0, charId); this->returnToPreviousSession(0, charId);
@ -779,8 +781,10 @@ NLMISC_CLASS_COMMAND_IMPL(CCharacterControl, setPioneerRight)
return false; return false;
} }
uint32 charId = atoi(args[0].c_str()); uint32 charId;
bool isDm = atoi(args[1].c_str()) != 0; NLMISC::fromString(args[0], charId);
bool isDm;
NLMISC::fromString(args[1], isDm);
log.displayNL("Try to setPioneerRight char %u", charId); log.displayNL("Try to setPioneerRight char %u", charId);
this->setPioneerRight(0, charId, isDm); this->setPioneerRight(0, charId, isDm);

View file

@ -485,15 +485,19 @@ NLMISC_COMMAND(activateEasterEgg, "activate an easter egg","<EasterEggId><Scenar
if( args.size() != 6 ) if( args.size() != 6 )
return false; return false;
uint32 easterEggId = (uint32)atoi(args[0].c_str()); uint32 easterEggId;
TSessionId scenarioId = (TSessionId)(uint32)atoi(args[1].c_str()); NLMISC::fromString(args[0], easterEggId);
uint32 aiInstanceId = (uint32)atoi(args[2].c_str()); uint32 scId;
NLMISC::CSheetId itemSheet = CSheetId(args[3]); NLMISC::fromString(args[1], scId);
TSessionId scenarioId(scId);
uint32 aiInstanceId;
NLMISC::fromString(args[2], aiInstanceId);
NLMISC::CSheetId itemSheet(args[3]);
CFarPosition fPos; CFarPosition fPos;
fPos.SessionId = scenarioId; fPos.SessionId = scenarioId;
fPos.PosState.X = (sint32)atoi(args[4].c_str());; NLMISC::fromString(args[4], fPos.PosState.X);;
fPos.PosState.Y = (sint32)atoi(args[5].c_str());; NLMISC::fromString(args[5], fPos.PosState.Y);;
R2::TItemAndQuantity item; R2::TItemAndQuantity item;
item.Quantity = 1; item.Quantity = 1;
@ -511,8 +515,10 @@ NLMISC_COMMAND(deactivateEasterEgg, "unactive an easter egg spwaned by scenario"
if( args.size() != 2 ) if( args.size() != 2 )
return false; return false;
uint32 easterEggId = (uint32)atoi(args[0].c_str()); uint32 easterEggId, scId;
TSessionId scenarioId = (TSessionId)(uint32)atoi(args[1].c_str()); NLMISC::fromString(args[0], easterEggId);
NLMISC::fromString(args[1], scId);
TSessionId scenarioId(scId);
CR2EasterEgg::getInstance().deactivateEasterEgg(easterEggId, scenarioId); CR2EasterEgg::getInstance().deactivateEasterEgg(easterEggId, scenarioId);
return true; return true;
@ -527,8 +533,8 @@ NLMISC_COMMAND(easterEggTPActChange, "simulate an act change", "<CharacterId><x>
eid.fromString(args[0].c_str()); eid.fromString(args[0].c_str());
CFarPosition fPos; CFarPosition fPos;
fPos.PosState.X = (sint32)atoi(args[1].c_str()); NLMISC::fromString(args[1], fPos.PosState.X);
fPos.PosState.Y = (sint32)atoi(args[2].c_str()); NLMISC::fromString(args[2], fPos.PosState.Y);
CR2EasterEgg::getInstance().easterEggTPActChange(eid, fPos); CR2EasterEgg::getInstance().easterEggTPActChange(eid, fPos);
return true; return true;

View file

@ -324,10 +324,12 @@ NLMISC_COMMAND(giveItemRequest, "test command for give item R2 feature", "<Chara
if(c) msg.CreatureRowId = c->getEntityRowId(); if(c) msg.CreatureRowId = c->getEntityRowId();
else return false; else return false;
msg.GroupAlias = (uint32)atoi(args[2].c_str()); NLMISC::fromString(args[2], msg.GroupAlias);
msg.InstanceId = (uint32)atoi(args[3].c_str()); NLMISC::fromString(args[3], msg.InstanceId);
msg.Items.push_back( CSheetId(args[4])); msg.Items.push_back( CSheetId(args[4]));
msg.Quantities.push_back( (uint32)atoi(args[5].c_str()) ); uint32 quantity;
NLMISC::fromString(args[5], quantity);
msg.Quantities.push_back(quantity);
msg.MissionText = args[6]; msg.MissionText = args[6];
CR2GiveItem::getInstance().giveItemRequest( msg ); CR2GiveItem::getInstance().giveItemRequest( msg );
return true; return true;
@ -345,7 +347,8 @@ NLMISC_COMMAND(giveItemGranted, "test command for give item R2 features", "<Crea
CCreature *c = CreatureManager.getCreature(eid); CCreature *c = CreatureManager.getCreature(eid);
if(c) creatureRowId = c->getEntityRowId(); if(c) creatureRowId = c->getEntityRowId();
else return false; else return false;
uint32 actionId = (uint32)atoi(args[1].c_str()); uint32 actionId;
NLMISC::fromString(args[1], actionId);
CR2GiveItem::getInstance().giveItemGranted( creatureRowId, actionId ); CR2GiveItem::getInstance().giveItemGranted( creatureRowId, actionId );
return true; return true;
} }

View file

@ -493,7 +493,9 @@ NLMISC_COMMAND(itemR2Description, "set definition of a R2 item", "<ScenarioId> <
if( args.size() != 5 ) if( args.size() != 5 )
return false; return false;
TSessionId scenarioId( (uint32)atoi(args[0].c_str()) ); uint32 sessionId;
NLMISC::fromString(args[0], sessionId);
TSessionId scenarioId(sessionId);
R2::TMissionItem itemDesc; R2::TMissionItem itemDesc;
itemDesc.SheetId = CSheetId(args[1]); itemDesc.SheetId = CSheetId(args[1]);
@ -515,10 +517,12 @@ NLMISC_COMMAND(giveItemR2ToCharacter, "Give an item R2 to a character", "<Charac
CEntityId eid; CEntityId eid;
eid.fromString(args[0].c_str()); eid.fromString(args[0].c_str());
TSessionId scenarioId( (uint32)atoi(args[1].c_str()) ); uint32 sessionId;
NLMISC::fromString(args[1], sessionId);
TSessionId scenarioId(sessionId);
R2::TItemAndQuantity item; R2::TItemAndQuantity item;
item.SheetId = CSheetId(args[2]); item.SheetId = CSheetId(args[2]);
item.Quantity = (uint32)atoi(args[3].c_str()); NLMISC::fromString(args[3], item.Quantity);
std::vector< R2::TItemAndQuantity > items; std::vector< R2::TItemAndQuantity > items;
items.push_back(item); items.push_back(item);
@ -544,7 +548,9 @@ NLMISC_COMMAND(endScenario, "Simulate the end of a R2 scenario", "<ScenarioId>")
if( args.size() != 1) if( args.size() != 1)
return false; return false;
TSessionId scenarioId( (uint32)atoi(args[0].c_str()) ); uint32 sessionId;
NLMISC::fromString(args[0], sessionId);
TSessionId scenarioId(sessionId);
CR2MissionItem::getInstance().endScenario( scenarioId ); CR2MissionItem::getInstance().endScenario( scenarioId );
return true; return true;
} }
@ -558,7 +564,7 @@ NLMISC_COMMAND(destroyMissionR2Item, "Destroy an R2 itme mission owned by a play
eid.fromString(args[0].c_str()); eid.fromString(args[0].c_str());
R2::TItemAndQuantity item; R2::TItemAndQuantity item;
item.SheetId = CSheetId(args[1]); item.SheetId = CSheetId(args[1]);
item.Quantity = (uint32)atoi(args[2].c_str()); NLMISC::fromString(args[2], item.Quantity);
std::vector<R2::TItemAndQuantity> items; std::vector<R2::TItemAndQuantity> items;
items.push_back(item); items.push_back(item);

View file

@ -120,10 +120,9 @@ NLMISC_COMMAND(outpostSimulateTimer0End, "", "<outpost_id> [<absolute end time>
uint32 endTime = 1; uint32 endTime = 1;
if (args.size()>1) if (args.size()>1)
{ {
NLMISC::fromString(args[1], endTime);
if (args[1][0]=='+') if (args[1][0]=='+')
endTime = CTime::getSecondsSince1970() + atoi(args[1].c_str()); endTime += CTime::getSecondsSince1970();
else
endTime = atoi(args[1].c_str());
} }
if (endTime==0) endTime = 1; if (endTime==0) endTime = 1;
@ -144,10 +143,9 @@ NLMISC_COMMAND(outpostSimulateTimer1End, "", "<outpost_id> [<absolute end time>
uint32 endTime = 1; uint32 endTime = 1;
if (args.size()>1) if (args.size()>1)
{ {
NLMISC::fromString(args[1], endTime);
if (args[1][0]=='+') if (args[1][0]=='+')
endTime = CTime::getSecondsSince1970() + atoi(args[1].c_str()); endTime += CTime::getSecondsSince1970();
else
endTime = atoi(args[1].c_str());
} }
if (endTime==0) endTime = 1; if (endTime==0) endTime = 1;
@ -168,10 +166,9 @@ NLMISC_COMMAND(outpostSimulateTimer2End, "", "<outpost_id> [<absolute end time>
uint32 endTime = 1; uint32 endTime = 1;
if (args.size()>1) if (args.size()>1)
{ {
NLMISC::fromString(args[1], endTime);
if (args[1][0]=='+') if (args[1][0]=='+')
endTime = CTime::getSecondsSince1970() + atoi(args[1].c_str()); endTime += CTime::getSecondsSince1970();
else
endTime = atoi(args[1].c_str());
} }
if (endTime==0) endTime = 1; if (endTime==0) endTime = 1;
@ -191,7 +188,8 @@ NLMISC_COMMAND(outpostSetFightData, "", "<outpost_id> <current_round> [<current_
if (args.size() > 1) if (args.size() > 1)
{ {
uint32 currentRound = uint32( atoi(args[1].c_str()) ); uint32 currentRound;
NLMISC::fromString(args[1], currentRound);
if (currentRound > 0 && currentRound <= outpost->computeRoundCount()) if (currentRound > 0 && currentRound <= outpost->computeRoundCount())
{ {
outpost->_FightData._CurrentCombatRound = currentRound - 1; outpost->_FightData._CurrentCombatRound = currentRound - 1;
@ -202,7 +200,8 @@ NLMISC_COMMAND(outpostSetFightData, "", "<outpost_id> <current_round> [<current_
if (args.size() > 2) if (args.size() > 2)
{ {
uint32 currentLevel = uint32( atoi(args[2].c_str()) ); uint32 currentLevel;
NLMISC::fromString(args[2], currentLevel);
if (currentLevel > 0 && currentLevel <= outpost->computeRoundCount()) if (currentLevel > 0 && currentLevel <= outpost->computeRoundCount())
{ {
outpost->_FightData._CurrentCombatLevel = currentLevel - 1; outpost->_FightData._CurrentCombatLevel = currentLevel - 1;
@ -213,7 +212,8 @@ NLMISC_COMMAND(outpostSetFightData, "", "<outpost_id> <current_round> [<current_
if (args.size() > 3) if (args.size() > 3)
{ {
uint32 maxAttackLevel = uint32( atoi(args[3].c_str()) ); uint32 maxAttackLevel;
NLMISC::fromString(args[3], maxAttackLevel);
if (maxAttackLevel <= outpost->computeRoundCount()) if (maxAttackLevel <= outpost->computeRoundCount())
{ {
outpost->_FightData._MaxAttackLevel = maxAttackLevel; outpost->_FightData._MaxAttackLevel = maxAttackLevel;
@ -224,7 +224,8 @@ NLMISC_COMMAND(outpostSetFightData, "", "<outpost_id> <current_round> [<current_
if (args.size() > 4) if (args.size() > 4)
{ {
uint32 maxDefenseLevel = uint32( atoi(args[4].c_str()) ); uint32 maxDefenseLevel;
NLMISC::fromString(args[4], maxDefenseLevel);
if (maxDefenseLevel <= outpost->computeRoundCount()) if (maxDefenseLevel <= outpost->computeRoundCount())
{ {
outpost->_FightData._MaxDefenseLevel = maxDefenseLevel; outpost->_FightData._MaxDefenseLevel = maxDefenseLevel;
@ -247,7 +248,8 @@ NLMISC_COMMAND(setOutpostLevel, "Set the outpost level", "<outpost id><level>" )
if (outpost == NULL) if (outpost == NULL)
return true; return true;
uint32 level = atoi(args[1].c_str()); uint32 level;
NLMISC::fromString(args[1], level);
outpost->setOutpostCurrentLevel(level); outpost->setOutpostCurrentLevel(level);
return true; return true;
} }
@ -284,7 +286,7 @@ NLMISC_COMMAND(outpostAccelerateConstruction, "set all current construction to a
uint nNbSecondLeft = 30; uint nNbSecondLeft = 30;
if (args.size() == 1) if (args.size() == 1)
nNbSecondLeft = atoi(args[0].c_str()); NLMISC::fromString(args[0], nNbSecondLeft);
COutpostManager::getInstance().setConstructionTime(nNbSecondLeft); COutpostManager::getInstance().setConstructionTime(nNbSecondLeft);
@ -607,8 +609,10 @@ NLMISC_COMMAND(outpostSetAttackDefenseHour, "Set attack and defense time of an o
if (outpost == NULL) if (outpost == NULL)
return true; return true;
uint32 attackHour = (uint32)atoi(args[1].c_str()); uint32 attackHour;
uint32 defenseHour = (uint32)atoi(args[2].c_str()); NLMISC::fromString(args[1], attackHour);
uint32 defenseHour;
NLMISC::fromString(args[2], defenseHour);
if(attackHour > 23) if(attackHour > 23)
{ {
@ -638,7 +642,8 @@ NLMISC_COMMAND(outpostSetAttackDefenseDate, "Set attack and defense date of an o
if (outpost == NULL) if (outpost == NULL)
return true; return true;
uint32 nbDaysAdd = (uint32)atoi(args[1].c_str()); uint32 nbDaysAdd;
NLMISC::fromString(args[1], nbDaysAdd);
outpost->setRealChallengeTime( outpost->getRealChallengeTime() + nbDaysAdd*days ); outpost->setRealChallengeTime( outpost->getRealChallengeTime() + nbDaysAdd*days );
outpost->setChallengeTime( (outpost->getRealChallengeTime()/hours + 1)*hours ); outpost->setChallengeTime( (outpost->getRealChallengeTime()/hours + 1)*hours );
@ -675,7 +680,8 @@ NLMISC_COMMAND(setMemberEntryDate, "Set guild member entry date", "<eid> <entryC
GET_CHARACTER GET_CHARACTER
uint32 cycleEntryDate = uint32(atoi(args[1].c_str())); uint32 cycleEntryDate;
NLMISC::fromString(args[1], cycleEntryDate);
CGuild * guild = CGuildManager::getInstance()->getGuildFromId( c->getGuildId() ); CGuild * guild = CGuildManager::getInstance()->getGuildFromId( c->getGuildId() );
if (guild == NULL) if (guild == NULL)

View file

@ -357,7 +357,8 @@ void COutpostManager::outpostFileCallback(const CFileDescription& fileDescriptio
aliasStr.resize( aliasStr.length() - 4 ); aliasStr.resize( aliasStr.length() - 4 );
aliasStr = aliasStr.substr( 8); aliasStr = aliasStr.substr( 8);
TAIAlias alias = (TAIAlias) atoi( aliasStr.c_str() ); TAIAlias alias;
NLMISC::fromString(aliasStr, alias);
COutpost * outpost = getOutpostFromAlias( alias ); COutpost * outpost = getOutpostFromAlias( alias );
if ( !outpost ) if ( !outpost )
OUTPOST_WRN("Invalid outpost file '%s' %s : not found in the primitive", fileDescription.FileName.c_str(), CPrimitivesParser::aliasToString(alias).c_str()); OUTPOST_WRN("Invalid outpost file '%s' %s : not found in the primitive", fileDescription.FileName.c_str(), CPrimitivesParser::aliasToString(alias).c_str());
@ -419,7 +420,8 @@ void COutpostManager::loadOutpostSaveFiles()
// aliasStr.resize( file.length() - 4 ); // aliasStr.resize( file.length() - 4 );
// aliasStr = aliasStr.substr( 8, file.length() - 8 ); // aliasStr = aliasStr.substr( 8, file.length() - 8 );
// //
// TAIAlias alias = (TAIAlias) atoi( aliasStr.c_str() ); // TAIAlias alias;
// NLMISC::fromString(aliasStr, alias);
// COutpost * outpost = getOutpostFromAlias( alias ); // COutpost * outpost = getOutpostFromAlias( alias );
// if ( !outpost ) // if ( !outpost )
// OUTPOST_WRN("Invalid outpost file '%s' ('%u') : not found in the primitive", file.c_str(), alias); // OUTPOST_WRN("Invalid outpost file '%s' ('%u') : not found in the primitive", file.c_str(), alias);

View file

@ -238,7 +238,8 @@ NLMISC_COMMAND(displayBombRange,"display the affected entities ( all entities in
log.displayNL( "invalid entity %s", args[1].c_str() ); log.displayNL( "invalid entity %s", args[1].c_str() );
return true; return true;
} }
uint16 radius = (uint16) atoi(args[2].c_str()); uint16 radius;
NLMISC::fromString(args[2], radius);
CRangeSelector selector; CRangeSelector selector;
selector.buildDisc( source,target->getX(),target->getY(), radius,EntityMatrix, false ); selector.buildDisc( source,target->getX(),target->getY(), radius,EntityMatrix, false );
@ -313,8 +314,11 @@ NLMISC_COMMAND(displayChainRange,"display the affected entities ( all entities i
return true; return true;
} }
uint16 range = (uint16) atoi(args[2].c_str()); uint16 range;
uint max = (uint) atoi(args[3].c_str()); NLMISC::fromString(args[2], range);
uint max;
NLMISC::fromString(args[3], max);
CRangeSelector selector; CRangeSelector selector;
selector.buildChain(source , target, range, max, EntityMatrix,ACTNATURE::NEUTRAL); selector.buildChain(source , target, range, max, EntityMatrix,ACTNATURE::NEUTRAL);

View file

@ -323,7 +323,7 @@ NLMISC_COMMAND( testRolemaster, "Test rolemaster phrases selection (list separat
if ( args.size() > 2 ) if ( args.size() > 2 )
{ {
skillValueLimit = atoi( args[2].c_str() ); NLMISC::fromString(args[2], skillValueLimit);
} }
} }
} }

View file

@ -56,7 +56,8 @@ bool CChgCharacEffect::update(CTimerEvent * event, bool applyEffect)
string currentValueStr; string currentValueStr;
player->getValue(var,currentValueStr); player->getValue(var,currentValueStr);
sint32 currentValue = atoi( currentValueStr.c_str() ); sint32 currentValue;
NLMISC::fromString(currentValueStr, currentValue);
string newValueStr = toString(currentValue + _Modifier1 + _Modifier2); string newValueStr = toString(currentValue + _Modifier1 + _Modifier2);
player->setValue(var,newValueStr); player->setValue(var,newValueStr);
@ -85,7 +86,8 @@ void CChgCharacEffect::removed()
string currentValueStr; string currentValueStr;
player->getValue(var,currentValueStr); player->getValue(var,currentValueStr);
sint32 currentValue = atoi( currentValueStr.c_str() ); sint32 currentValue;
NLMISC::fromString(currentValueStr, currentValue);
string newValueStr = toString(currentValue - _Modifier1 - _Modifier2); string newValueStr = toString(currentValue - _Modifier1 - _Modifier2);
player->setValue(var,newValueStr); player->setValue(var,newValueStr);
} }

View file

@ -705,9 +705,10 @@ NLMISC_COMMAND(simuCraft, "Simulation de craft pour verifier les probabilit
if (args.size() != 3) if (args.size() != 3)
return false; return false;
uint32 nbSimu = (uint32)atoi(args[0].c_str()); uint32 nbSimu, skillLevel, itemQuality;
uint32 skillLevel = (uint32)atoi(args[1].c_str()); NLMISC::fromString(args[0], nbSimu);
uint32 itemQuality = (uint32)atoi(args[2].c_str()); NLMISC::fromString(args[1], skillLevel);
NLMISC::fromString(args[2], itemQuality);
sint32 deltaLvl = skillLevel - itemQuality; sint32 deltaLvl = skillLevel - itemQuality;

View file

@ -1652,7 +1652,9 @@ NLMISC_COMMAND( makeDepositMap, "Write a map of the raw materials at a position"
else if ( (p = args[0].find( '_' )) == 0 ) else if ( (p = args[0].find( '_' )) == 0 )
{ {
// Get player position (if rowId given) // Get player position (if rowId given)
playerRowId = TDataSetRow::createFromRawIndex( atoi( args[0].substr( 1 ).c_str() ) ); TDataSetIndex entityIndex;
NLMISC::fromString(args[0].substr( 1 ), entityIndex);
playerRowId = TDataSetRow::createFromRawIndex(entityIndex);
if ( TheDataset.isAccessible(playerRowId) ) if ( TheDataset.isAccessible(playerRowId) )
{ {
CVector centerPos; CVector centerPos;

View file

@ -2182,7 +2182,7 @@ NLMISC_COMMAND(useDebugBrick,"use debug Brick or not","<0/1>")
return true; return true;
} }
// UseDebugBrick = ( atoi(args[0].c_str()) != 0); // NLMISC::fromString(args[0], UseDebugBrick);
return true; return true;
} }

View file

@ -156,15 +156,15 @@ NLMISC_COMMAND( spawnToxicCloud, "Spawn a toxic cloud", "<posXm> <posYm> <iRadiu
TGameCycle lifetime = CToxicCloud::ToxicCloudDefaultLifetime; TGameCycle lifetime = CToxicCloud::ToxicCloudDefaultLifetime;
if ( args.size() > 2 ) if ( args.size() > 2 )
{ {
iRadius = atoi( args[2].c_str() ); NLMISC::fromString(args[2], iRadius);
if ( args.size() > 3 ) if ( args.size() > 3 )
{ {
dmgPerHit = atoi( args[3].c_str() ); NLMISC::fromString(args[3], dmgPerHit);
if ( args.size() > 4 ) if ( args.size() > 4 )
{ {
updateFrequency = atoi( args[4].c_str() ); NLMISC::fromString(args[4], updateFrequency);
if ( args.size() > 5 ) if ( args.size() > 5 )
lifetime = atoi( args[4].c_str() ); NLMISC::fromString(args[4], lifetime);
} }
} }
} }

View file

@ -283,10 +283,11 @@ void CCDBStructNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &pro
if ((const char *) count != NULL) if ((const char *) count != NULL)
{ {
// dealing with an array of entries // dealing with an array of entries
unsigned countAsInt=(unsigned)atoi(count); uint countAsInt;
NLMISC::fromString(count, countAsInt);
nlassert((const char *) count != NULL); nlassert((const char *) count != NULL);
for (unsigned i=0;i<countAsInt;i++) for (uint i=0;i<countAsInt;i++)
{ {
// Progress bar // Progress bar
progressCallBack.progress ((float)i/(float)countAsInt); progressCallBack.progress ((float)i/(float)countAsInt);
@ -345,10 +346,11 @@ void CCDBStructNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &pro
if ((const char *) count != NULL) if ((const char *) count != NULL)
{ {
// dealing with an array of entries // dealing with an array of entries
unsigned countAsInt=(unsigned)atoi(count); uint countAsInt;
NLMISC::fromString(count, countAsInt);
nlassert((const char *) count != NULL); nlassert((const char *) count != NULL);
for (unsigned i=0;i<countAsInt;i++) for (uint i=0;i<countAsInt;i++)
{ {
// Progress bar // Progress bar
progressCallBack.progress ((float)i/(float)countAsInt); progressCallBack.progress ((float)i/(float)countAsInt);

View file

@ -926,7 +926,7 @@ bool CCharacter::setValue( string var, string value )
try try
{ {
sint32 &temp = lookupStat(var); sint32 &temp = lookupStat(var);
temp = atoi( value.c_str() ); NLMISC::fromString(value, temp);
} }
catch( CCharacter::EInvalidStat &e) catch( CCharacter::EInvalidStat &e)
{ {
@ -949,7 +949,9 @@ bool CCharacter::modifyValue( string var, string value )
try try
{ {
sint32 &temp = lookupStat(var); sint32 &temp = lookupStat(var);
temp = temp + atoi( value.c_str() ); sint32 valueInt;
NLMISC::fromString(value, valueInt);
temp = temp + valueInt;
} }
catch( CCharacter::EInvalidStat &e) catch( CCharacter::EInvalidStat &e)
{ {
@ -7882,7 +7884,8 @@ void CCharacter::setStartStatistics( const CCreateCharMsg& createCharMsg )
if( valueString.size() > 0 ) if( valueString.size() > 0 )
{ {
SKILLS::ESkills skillEnum = SKILLS::toSkill(skillString); SKILLS::ESkills skillEnum = SKILLS::toSkill(skillString);
sint32 skillPoint = (sint32) atoi(valueString.c_str()); sint32 skillPoint;
NLMISC::fromString(valueString, skillPoint);
if( skillEnum != SKILLS::unknown ) if( skillEnum != SKILLS::unknown )
{ {
_Skills._Skills[ skillEnum ].Base = min( skillPoint, (sint32)SkillsTree->SkillsTree[ skillEnum ].MaxSkillValue ); _Skills._Skills[ skillEnum ].Base = min( skillPoint, (sint32)SkillsTree->SkillsTree[ skillEnum ].MaxSkillValue );
@ -16174,7 +16177,7 @@ void CCharacter::checkCharacAndScoresValues()
// phrase = abppXZZ.sphrase with X = characteristic code and ZZ = brick level (CharacteristicBrickStep*ZZ) // phrase = abppXZZ.sphrase with X = characteristic code and ZZ = brick level (CharacteristicBrickStep*ZZ)
code = phraseStr.substr(4,1); //string( text[4] ); code = phraseStr.substr(4,1); //string( text[4] );
txt = phraseStr.substr(5,2); txt = phraseStr.substr(5,2);
lvl = atoi( txt.c_str() ); NLMISC::fromString(txt, lvl);
CHARACTERISTICS::TCharacteristics charac = CHARACTERISTICS::getCharacteristicFromCode(code); CHARACTERISTICS::TCharacteristics charac = CHARACTERISTICS::getCharacteristicFromCode(code);
if (charac < CHARACTERISTICS::NUM_CHARACTERISTICS) if (charac < CHARACTERISTICS::NUM_CHARACTERISTICS)