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

View file

@ -756,7 +756,9 @@ ENTITY_VARIABLE(HP, "Hit points of a player")
}
else
{
e->getScores()._PhysicalScores[SCORES::hit_points].Current = atoi(value.c_str());
sint32 v;
NLMISC::fromString(value, v);
e->getScores()._PhysicalScores[SCORES::hit_points].Current = v;
}
}
@ -770,7 +772,9 @@ ENTITY_VARIABLE(MaxHP, "Max hit points of a player")
}
else
{
e->getScores()._PhysicalScores[SCORES::hit_points].Max = atoi(value.c_str());
sint32 v;
NLMISC::fromString(value, v);
e->getScores()._PhysicalScores[SCORES::hit_points].Max = v;
}
}
@ -888,7 +892,8 @@ ENTITY_VARIABLE(MoneyGuild, "MoneyGuild")
}
else
{
uint32 val = atoi(value.substr(1).c_str());
uint32 val;
NLMISC::fromString(value.substr(1), val);
if(dir == 1)
guild->addMoney(val);
else
@ -941,11 +946,14 @@ ENTITY_VARIABLE(FactionPoint, "FactionPoint")
if(dir == 0)
{
c->setFactionPoint(clan, atoi(sNumber.c_str()), true);
uint32 val;
NLMISC::fromString(sNumber, val);
c->setFactionPoint(clan, val, true);
}
else
{
uint32 val = atoi(sNumber.substr(1).c_str());
uint32 val;
NLMISC::fromString(sNumber.substr(1), val);
if(dir == 1)
c->setFactionPoint(clan, c->getFactionPoint(clan)+val, true);
else
@ -1142,7 +1150,9 @@ ENTITY_VARIABLE(Position, "Position of a player (in meter) <eid> <posx>,<posy>[,
if (res.size() >= 4)
{
// season included
c->teleportCharacter(x,y,z,true, false, 0.f, 0xFF, 0, (uint8) atoi(res[3].c_str()));
uint8 season;
NLMISC::fromString(res[3], season);
c->teleportCharacter(x,y,z,true, false, 0.f, 0xFF, 0, season);
}
else
{
@ -1171,7 +1181,9 @@ NLMISC_COMMAND(changeMode," change_mode","<entity id(id:type:crea:dyn)> <mode>")
CEntityId id;
id.fromString( args[0].c_str() );
MBEHAV::EMode mode = MBEHAV::EMode(atoi(args[1].c_str()));
sint iMode;
NLMISC::fromString(args[1], iMode);
MBEHAV::EMode mode = MBEHAV::EMode(iMode);
CEntityBase *e = 0;
if( id.getType() == 0 )
@ -1236,7 +1248,8 @@ NLMISC_COMMAND (createItemInBag, "Create an item and put it in the player bag",
string sheetName = args[1];
CSheetId sheet;
uint32 sheetId = atoi(sheetName.c_str());
uint32 sheetId;
NLMISC::fromString(sheetName, sheetId);
if (sheetId != 0)
{
sheet = CSheetId(sheetId);
@ -1276,14 +1289,16 @@ NLMISC_COMMAND (createItemInBag, "Create an item and put it in the player bag",
return false;
}
sint quantity = atoi(args[2].c_str());
sint quantity;
NLMISC::fromString(args[2], quantity);
if (quantity < 1)
{
log.displayNL ("Quantity must be > 0");
return false;
}
sint quality = atoi(args[3].c_str());
sint quality;
NLMISC::fromString(args[3], quality);
if (quality < 1)
{
log.displayNL ("Quality must be > 0");
@ -1324,7 +1339,8 @@ NLMISC_COMMAND (createItemInTmpInv, "Create an item and put it in the player tem
string sheetName = args[1];
CSheetId sheet;
uint32 sheetId = atoi(sheetName.c_str());
uint32 sheetId;
NLMISC::fromString(sheetName, sheetId);
if (sheetId != 0)
{
sheet = CSheetId(sheetId);
@ -1363,14 +1379,16 @@ NLMISC_COMMAND (createItemInTmpInv, "Create an item and put it in the player tem
return false;
}
sint quantity = atoi(args[2].c_str());
sint quantity;
NLMISC::fromString(args[2], quantity);
if (quantity < 1)
{
log.displayNL ("Quantity must be > 0");
return false;
}
sint quality = atoi(args[3].c_str());
sint quality;
NLMISC::fromString(args[3], quality);
if (quality < 1)
{
log.displayNL ("Quality must be > 0");
@ -1394,7 +1412,8 @@ NLMISC_COMMAND (createItemInInv, "Create items and put them in the given invento
string sheetName = args[2];
CSheetId sheet;
uint32 sheetId = atoi(sheetName.c_str());
uint32 sheetId;
NLMISC::fromString(sheetName, sheetId);
if (sheetId != 0)
{
sheet = CSheetId(sheetId);
@ -1433,21 +1452,25 @@ NLMISC_COMMAND (createItemInInv, "Create items and put them in the given invento
return false;
}
sint quantity = atoi(args[3].c_str());
sint quantity;
NLMISC::fromString(args[3], quantity);
if (quantity < 1)
{
log.displayNL ("Quantity must be > 0");
return false;
}
sint quality = atoi(args[4].c_str());
sint quality;
NLMISC::fromString(args[4], quality);
if (quality < 1)
{
log.displayNL ("Quality must be > 0");
return false;
}
uint nbItems = min(uint(atoi(args[5].c_str())), 1000U);
uint nb;
NLMISC::fromString(args[5], nb);
uint nbItems = min(nb, 1000U);
uint nbCreatedItems = 0;
for (uint i = 0; i < nbItems; i++)
{
@ -1479,7 +1502,7 @@ NLMISC_COMMAND(createNamedItemInBag, "create a named item in bag", "<eId> <item>
uint16 quantity;
if (args.size() == 3)
{
quantity = (uint16)atoi(args[2].c_str());
NLMISC::fromString(args[2], quantity);
if (quantity == 0)
{
log.displayNL("invalid quantity '%s'", args[2].c_str());
@ -1528,7 +1551,8 @@ NLMISC_COMMAND (createFullArmorSet, "Create and equip player with chosen full ar
const string &race = args[1];
const string &type = args[2];
const uint16 quality = atoi(args[3].c_str());
uint16 quality;
NLMISC::fromString(args[3], quality);
const uint16 min = quality - (quality-1)%5;
const string minStr = (min < 10) ? string("0") + toString(min) : toString(min);
@ -1917,7 +1941,8 @@ NLMISC_COMMAND (learnAllForagePhrases, "Learn all forage phrase, begin at specif
if ( args.size() != 2 ) return false;
GET_CHARACTER
uint i = atoi( args[1].c_str() );
uint i;
NLMISC::fromString(args[1], i);
uint nbSuccess = 0, nbFail = 0;
const CAllRolemasterPhrases& phrases = CSheets::getSRolemasterPhrasesMap();
@ -2171,7 +2196,8 @@ NLMISC_COMMAND(setPetAnimalSatiety,"Set the satiety of pet animal (petIndex in 0
{
// Set the new satiety
string result;
uint petIndex = atoi( args[1].c_str() );
uint petIndex;
NLMISC::fromString(args[1], petIndex);
float previousSatiety, maxSatiety;
if ( c->getAnimalSatiety( petIndex, previousSatiety, maxSatiety ) )
{
@ -2215,7 +2241,8 @@ NLMISC_COMMAND(getPetAnimalSatiety,"Set the satiety of pet animal (petIndex in 0
if (args.size () < 2) return false;
GET_CHARACTER
uint petIndex = atoi( args[1].c_str() );
uint petIndex;
NLMISC::fromString(args[1], petIndex);
if ( c )
{
// Get the satiety
@ -2271,7 +2298,8 @@ NLMISC_COMMAND (addXPToSkill, "Gain experience in a given skills", "<eid> <xp> <
if (args.size () < 3) return false;
GET_CHARACTER
uint32 xp = atoi (args[1].c_str());
uint32 xp;
NLMISC::fromString(args[1], xp);
string skill = args[2];
@ -2279,7 +2307,7 @@ NLMISC_COMMAND (addXPToSkill, "Gain experience in a given skills", "<eid> <xp> <
if(args.size()==3)
count = 1;
else
count = atoi(args[3].c_str());
NLMISC::fromString(args[3], count);
count = min( count, (uint)100);
@ -2418,7 +2446,8 @@ NLMISC_COMMAND(execPhrase,"execute a sabrina phrase","<player id(id:type:crea:dy
if ( args.size() >= 3 )
{
GET_CHARACTER
bool cyclic = atoi(args[1].c_str()) != 0;
bool cyclic;
NLMISC::fromString(args[1], cyclic);
vector<CSheetId> brickIds;
for (uint i = 2 ; i < args.size() ; ++i)
@ -2443,7 +2472,8 @@ NLMISC_COMMAND(executeSabrinaPhrase,"execute a sabrina phrase, an sphrase","<pla
{
GET_CHARACTER
bool cyclic = atoi(args[1].c_str()) != 0;
bool cyclic;
NLMISC::fromString(args[1], cyclic);
CSheetId phraseSheet(args[2]);
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;
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 );
if (c )
@ -2499,8 +2530,10 @@ NLMISC_COMMAND(execMemorizedPhrase,"memorize a memorized sabrina phrase","<playe
CEntityId id;
id.fromString(args[0].c_str());
uint8 index = (uint8) atoi(args[1].c_str());
bool cyclic = (atoi(args[2].c_str()) == 1);
uint8 index;
NLMISC::fromString(args[1], index);
bool cyclic;
NLMISC::fromString(args[2], cyclic);
CCharacter * c = PlayerManager.getChar( id );
if (c )
@ -2529,8 +2562,11 @@ NLMISC_COMMAND(respawnAfterDeath,"respawnAfterDeath at re-spawn point name, it m
{
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
c->respawn( atoi(args[1].c_str() ) );
c->respawn(idx);
return true;
}
@ -2582,7 +2618,9 @@ NLMISC_COMMAND(validateRespawnPoint,"Validate re-spawn point","<player id(id:typ
{
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 false;
@ -2606,7 +2644,8 @@ NLMISC_COMMAND(setItemSapLoad,"set an item sap load","<eId><slot index in bag (s
return false;
GET_CHARACTER
uint slot = atoi(args[1].c_str());
uint slot;
NLMISC::fromString(args[1], slot);
float value = (float)atof(args[2].c_str());
// vector<CGameItemPtr>& items = (vector<CGameItemPtr> &)c->getInventory()[INVENTORIES::bag]->getChildren();
CInventoryPtr invent = c->getInventory(INVENTORIES::bag);
@ -2686,7 +2725,9 @@ NLMISC_COMMAND( summonPet, "player can summon it's pet one time only", "<eid><Pe
return false;
GET_CHARACTER
uint32 index = atoi(args[1].c_str()) - 1;
uint32 index;
NLMISC::fromString(args[1], index);
--index;
const std::vector< CPetAnimal >& pet = c->getPlayerPets();
if( index < pet.size() )
{
@ -2710,7 +2751,9 @@ NLMISC_COMMAND( allowSummonPet, "autorize player summon it's pet one time only",
return false;
GET_CHARACTER
uint32 index = atoi(args[1].c_str()) - 1;
uint32 index;
NLMISC::fromString(args[1], index);
--index;
const std::vector< CPetAnimal >& pet = c->getPlayerPets();
if( index < pet.size() )
@ -2775,6 +2818,7 @@ void cbClientAdmin (NLNET::CMessage& msgin, const std::string &serviceName, NLNE
CEntityId eid;
CEntityId targetEid;
msgin.serial (eid);
bool onTarget;
@ -3491,7 +3535,9 @@ NLMISC_COMMAND( root, "root a player", "<CSR id><player name><time in second>" )
}
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 );
return true;
}
@ -3610,7 +3656,10 @@ NLMISC_COMMAND( failMission, "force mission failure", "<CSR id><mission idx>" )
if ( args.size() != 2 )
return false;
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 )
{
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 )
return false;
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 )
{
CCharacter::sendDynamicSystemMessage( c->getEntityRowId(), "CSR_BAD_MISSION" );
@ -3635,7 +3687,7 @@ NLMISC_COMMAND( progressMission, "force mission progression", "<CSR id><mission
CCharacter * user = mission->getMainEntity();
uint repeat = 1;
if ( args.size() == 3 )
repeat = (uint)atoi( args[2].c_str() );
NLMISC::fromString(args[2], repeat);
CMissionEventDebug event;
for ( uint i = 0; i < repeat; i++ )
user->processMissionEvent(event);
@ -3680,7 +3732,9 @@ NLMISC_COMMAND (mute, "mute a user", "<csr id> <player name><duration>")
return true;
}
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 );
return true;
}
@ -3748,7 +3802,9 @@ NLMISC_COMMAND (muteUniverse, "mute the univers chat", "<csr id><player name><du
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() );
return true;
}
@ -3916,7 +3972,8 @@ NLMISC_COMMAND (infos, "give info on character (GodMode, Invisible...)", "")
// return false;
//
// GET_GUILD(0, true, NLMISC::CEntityId::Unknown);
// sint xp = atoi( args[1].c_str() );
// sint xp;
// NLMISC::fromString(args[1], xp);
// if ( xp < 0 )
// {
// uint32 uXP = (uint32)(-xp);
@ -3940,7 +3997,8 @@ NLMISC_COMMAND (infos, "give info on character (GodMode, Invisible...)", "")
// if ( args.size() != 2 )
// return false;
// 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->addChargePoints( 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);
if( posEgale != string::npos )
{
repeat = atoi( message.substr( posEgale+1 ).c_str() );
NLMISC::fromString(message.substr( posEgale+1 ), repeat);
if( posEgale + 1 > posMessage )
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);
if( posEgale != string::npos )
{
during = atoi( message.substr( posEgale+1 ).c_str() );
NLMISC::fromString(message.substr( posEgale+1 ), during);
if( posEgale + 1 > posMessage )
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);
if( posEgale != string::npos )
{
every = atoi( message.substr( posEgale+1 ).c_str() );
NLMISC::fromString(message.substr( posEgale+1 ), every);
if( posEgale + 1 > posMessage )
posMessage = posEgale + 1;
}
@ -4362,9 +4420,7 @@ NLMISC_COMMAND(lPosFlags, "list position flags (short format)", "<csr_eid> [<rad
uint32 radius = 0;
if (args.size() == 2)
{
int arg = atoi(args[1].c_str());
if (arg > 0)
radius = arg;
NLMISC::fromString(args[1], 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;
if (args.size() == 2)
{
int arg = atoi(args[1].c_str());
if (arg > 0)
radius = arg;
NLMISC::fromString(args[1], 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;
uint8 clan = atoi(args[1].c_str());
uint8 clan;
NLMISC::fromString(args[1], clan);
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 )
{
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());
return true;
}
uint historicSize = atoi(args[1].c_str());
uint historicSize;
NLMISC::fromString(args[1], historicSize);
//
if (historicSize > 1000)
{
@ -5100,9 +5156,9 @@ NLMISC_COMMAND(addChanClient, "add a client to a channel", "<client name or user
return 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);
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());
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)
{
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() );
if ( !TheDataset.isAccessible( userRow ) )
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);
if (aggroable>0)
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;
CEntityId eid(args[0]);
bool accept = atoi(args[1].c_str()) != 0;
bool accept;
NLMISC::fromString(args[1], accept);
uint32 queueId = 0;
if (args.size() == 3)
queueId = atoi(args[1].c_str());
NLMISC::fromString(args[1], queueId);
else
{
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;
CEntityId eid(args[0]);
uint32 queueId = atoi(args[1].c_str());
uint32 queueId;
NLMISC::fromString(args[1], 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);
if (creature)
{
const sint32 fameLevel = sint32( atoi(args[2].c_str())*FameAbsoluteMax / 100 );
bool above = (atoi(args[3].c_str()) ? true : false);
creature->addFactionAttackable(factionIndex, fameLevel, above);
sint32 fameLevel;
NLMISC::fromString(args[2], fameLevel);
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();
if( args.size() == 3 )
{
uint32 nTask = atoi( args[2].c_str() );
uint32 nTask;
NLMISC::fromString(args[2], nTask);
if( nTask > 7 )
{
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];
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);
@ -5530,7 +5597,8 @@ NLMISC_COMMAND(eventSetBotScale, "changes the scale of a bot (in % up to 255)",
GET_ENTITY
TDataSetRow row = e->getEntityRowId();
uint32 scale = atoi(args[1].c_str());
uint32 scale;
NLMISC::fromString(args[1], scale);
if (scale>255)
scale = 0;
CMirrorPropValue< SAltLookProp2, CPropLocationPacked<2> > visualPropertyB( TheDataset, row, DSPropertyVPB );
@ -5739,7 +5807,7 @@ NLMISC_COMMAND(eventSetItemCustomText, "set an item custom text, which replaces
uint32 slot;
ucstring text;
inventory = INVENTORIES::toInventory(args[1]);
slot = atoi(args[2].c_str());
NLMISC::fromString(args[2], slot);
text.fromUtf8(args[3]);
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());
return true;
}
uint32 slot = atoi(args[2].c_str());
uint32 slot;
NLMISC::fromString(args[2], slot);
CInventoryPtr invent = c->getInventory(inventory);
if (slot >= invent->getSlotCount())
{
@ -5813,7 +5882,8 @@ NLMISC_COMMAND(useCatalyser, "use an xp catalyser", "<eId> [<slot in bag>]")
}
GET_CHARACTER
sint32 slot = atoi(args[1].c_str());
sint32 slot;
NLMISC::fromString(args[1], slot);
if( slot > 0 )
{
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
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 )
{
c->PositionStack.topToModify().PosState.X = atoi(args[2].c_str()) * 1000;
c->PositionStack.topToModify().PosState.Y = atoi(args[3].c_str()) * 1000;
NLMISC::fromString(args[2], c->PositionStack.topToModify().PosState.X);
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 )
{
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 )
{
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();
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 )
{
c->PositionStack.topToModify().PosState.X = atoi(args[2].c_str()) * 1000;
c->PositionStack.topToModify().PosState.Y = atoi(args[3].c_str()) * 1000;
NLMISC::fromString(args[2], c->PositionStack.topToModify().PosState.X);
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 )
{
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 )
{
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
uint index = atoi(args[1].c_str());
uint index;
NLMISC::fromString(args[1], index);
if ( c->PositionStack.size() <= index )
{
log.displayNL( "Index out of bounds" );
@ -6013,14 +6094,19 @@ NLMISC_COMMAND(farTPSubst, "Substitute a position in the stack (no immediate far
// Modify
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 )
{
newFarPos.PosState.X = atoi(args[3].c_str()) * 1000;
newFarPos.PosState.Y = atoi(args[4].c_str()) * 1000;
NLMISC::fromString(args[3], newFarPos.PosState.X);
newFarPos.PosState.X *= 1000;
NLMISC::fromString(args[4], newFarPos.PosState.Y);
newFarPos.PosState.Y *= 1000;
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 )
{
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)
return false;
sint delay = atoi(args[0].c_str());
sint delay;
NLMISC::fromString(args[0], delay);
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;
id.fromString( args[0].c_str() );
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 );
return true;
}
@ -94,7 +95,8 @@ NLMISC_COMMAND(dumpBuilding, "dump building infos", "<building_name = building_i
const string & buildingId = args[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);
}
else
@ -113,7 +115,9 @@ NLMISC_COMMAND(removeGuildBuilding, "(DEBUG) remove guild building", "<guild id>
if (args.size() != 1)
return false;
CBuildingManager::getInstance()->removeGuildBuilding( atoi(args[0].c_str()) );
uint32 guildId;
NLMISC::fromString(args[0], guildId);
CBuildingManager::getInstance()->removeGuildBuilding(guildId);
return true;
}

View file

@ -235,7 +235,8 @@ bool CBuildingManager::parsePhysicalBuildings( const NLLIGO::IPrimitive* prim, C
{
TAIAlias alias;
nlverify( CPrimitivesParser::getAlias(prim, alias));
//* TAIAlias alias = atoi( value.c_str() );
// TAIAlias alias;
// NLMISC::fromString(value, alias);
if ( _BuildingPhysicals.find( alias ) != _BuildingPhysicals.end() )
{
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;
nlverify( prim->getPropertyByName("name",name) );
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" )
{

View file

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

View file

@ -384,7 +384,8 @@ bool CExitDestination::build( const NLLIGO::IPrimitive* prim,const NLLIGO::IPrim
string value;
// get properties
nlverify( prim->getPropertyByName("exit_index_in_instance",value) );
_ExitIndex = uint8(atoi( value.c_str() )) - (uint8)1;
NLMISC::fromString(value, _ExitIndex);
--_ExitIndex;
if ( _ExitIndex == 0xFF )
{
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;
string probaStr = it->first.Id;
uint16 proba = static_cast<uint16>(atoi(probaStr.c_str()));
uint16 proba;
NLMISC::fromString(probaStr, proba);
TScriptContent script = it->second;
uint32 lineNb = 0;
@ -135,8 +136,8 @@ void CDynamicSheetManager::addCustomLootTable(CCustomElementId id, CCustomLootTa
CStaticLootSet::SItemLoot item;
item.Item = tmpVector[0];
item.Level = static_cast<uint16>(atoi(tmpVector[1].c_str()));
item.Quantity = static_cast<uint16>(atoi(tmpVector[2].c_str()));
NLMISC::fromString(tmpVector[1], item.Level);
NLMISC::fromString(tmpVector[2], item.Quantity);
nldebug("New Item: name='%s' quality=%d quantity=%d", item.Item.c_str(), item.Level, item.Quantity);
tmplootSet.ItemLoot.push_back(item);

View file

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

View file

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

View file

@ -1108,7 +1108,8 @@ bool CStaticCreatures::applyProtectModification(uint index, const std::string &a
//Set protection max
if (attr == "max")
{
uint16 max = static_cast<uint16>(atoi(newValue.c_str()));
uint16 max;
NLMISC::fromString(newValue, max);
_Protections[index].Max = max;
return false;
}
@ -1164,7 +1165,7 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
}
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);
break;
}
@ -1185,7 +1186,8 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_nb_players :
{
int n = atoi(scriptLine[1].c_str());
sint n;
NLMISC::fromString(scriptLine[1], n);
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());
@ -1200,7 +1202,7 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_player_hp_level:
{
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 );
compileCreatureDamagePerHit();
break;
@ -1258,7 +1260,8 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_life:
{
sint32 hp = static_cast<sint32>(atoi(scriptLine[1].c_str()));
sint32 hp;
NLMISC::fromString(scriptLine[1], hp);
if (hp == 0)
{
@ -1318,35 +1321,35 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
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);
break;
}
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);
break;
}
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);
break;
}
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);
break;
}
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);
break;
}
@ -1571,91 +1574,106 @@ bool CStaticCreatures::applyUserModel(CCustomElementId userModelId, const std::v
case at_resists_fear :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Fear = value;
break;
}
case at_resists_sleep :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Sleep = value;
break;
}
case at_resists_stun :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Stun = value;
break;
}
case at_resists_root :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Root = value;
break;
}
case at_resists_snare :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Snare = value;
break;
}
case at_resists_slow :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Slow = value;
break;
}
case at_resists_madness :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Madness = value;
break;
}
case at_resists_blind :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Blind = value;
break;
}
case at_resists_acid :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Acid = value;
break;
}
case at_resists_cold :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Cold = value;
break;
}
case at_resists_electricity :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Electricity = value;
break;
}
case at_resists_fire :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Fire = value;
break;
}
case at_resists_poison :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Poison = value;
break;
}
case at_resists_rot :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Rot = value;
break;
}
case at_resists_shockwave :
{
uint16 value = static_cast<uint16>(atoi(scriptLine[1].c_str()));
uint16 value;
NLMISC::fromString(scriptLine[1], value);
_Resists.Shockwave = value;
break;
}

View file

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

View file

@ -278,7 +278,8 @@ NLMISC_COMMAND( spawnFakePlayers, "Temp", "<nb>" )
{
if ( args.size() == 0 )
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;
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 )
{
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.Description = ucstring::makeFromUtf8(mainlands.asString(i+2));
mlSm.LanguageCode = mainlands.asString(i+3);
@ -1426,7 +1429,9 @@ void CPlayerService::init()
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)
{
@ -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(0 , files[ i ].find('_') );
uint32 account = atoi( files[ i ].c_str() );
uint32 account;
NLMISC::fromString(files[ i ], account);
if ( playerIds.find( account ) == playerIds.end() )
playerIds.insert( account );
}
@ -2141,7 +2147,8 @@ NLMISC_COMMAND(plrStat,"get or set a player stat","<pid><stat><value>")
// get
if( args.size() == 2 )
{
uint32 pid = atoi( args[0].c_str() );
uint32 pid;
NLMISC::fromString(args[0], pid);
CEntityId playerId(RYZOMID::player,pid);
string stat( args[1] );
string value = PlayerManager.getValue( playerId, stat );
@ -2152,7 +2159,8 @@ NLMISC_COMMAND(plrStat,"get or set a player stat","<pid><stat><value>")
// set
if( args.size() > 2 )
{
uint32 pid = atoi( args[0].c_str() );
uint32 pid;
NLMISC::fromString(args[0], pid);
CEntityId playerId(RYZOMID::player,pid);
string stat( args[1] );
string value = args[2];
@ -2181,7 +2189,8 @@ NLMISC_COMMAND(obj_stat,"get or set an object stat","<oid><stat>[type|loc|qualit
// get
if( args.size() == 2 )
{
uint32 oid = atoi( args[0].c_str() );
uint32 oid;
NLMISC::fromString(args[0], oid);
CEntityId objectId(player,oid);
string stat( args[1] );
string result;
@ -2196,12 +2205,13 @@ NLMISC_COMMAND(obj_stat,"get or set an object stat","<oid><stat>[type|loc|qualit
// set
if( args.size() > 2 )
{
uint32 oid = atoi( args[0].c_str() );
uint32 oid;
NLMISC::fromString(args[0], 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] == "quality" ) WorldObjectManager.getObject(objectId).setQuality(atoi(args[2].c_str()));
if( args[1] == "hp" ) WorldObjectManager.getObject(objectId).setHP(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(NLMISC::fromString(args[2].c_str()));
return true;
}
@ -2221,7 +2231,7 @@ NLMISC_COMMAND(create_obj,"create a new object","<type>")
CWorldObjectLocation loc;
uint16 quality = 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 false;
@ -2237,7 +2247,8 @@ NLMISC_COMMAND(remove_obj,"remove an object","<id>")
{
if( args.size() > 0 )
{
uint32 oid = atoi( args[0].c_str() );
uint32 oid;
NLMISC::fromString(args[0], oid);
CEntityId objId(object,oid);
WorldObjectManager.removeObject( objId );
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 )
{
CEntityId objId = CEntityId(object,atoi(args[0].c_str()));
CEntityId objId = CEntityId(object,NLMISC::fromString(args[0].c_str()));
if( args.size() > 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;
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;
if( id.getType() == 0 )
@ -2373,7 +2384,9 @@ NLMISC_COMMAND(changeBehaviour," change entity behaviour","<entity id(id:type:cr
CEntityId id;
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;
if( id.getType() == 0 )
@ -2587,7 +2600,8 @@ NLMISC_COMMAND(changeVisualPropertyA, " changeVisualPropertyA","<entity id(id:ty
id.fromString( args[0].c_str() );
string name = args[1];
uint8 value = (uint8) atoi( args[2].c_str() );
uint8 value;
NLMISC::fromString(args[2], value);
CCharacter *c;
c = PlayerManager.getChar(id);
@ -2923,7 +2937,8 @@ NLMISC_COMMAND(createPlayer," create a player","<playerId, characterName, race,
{
if( args.size() == 4 )
{
uint32 playerId = atoi( args[0].c_str() );
uint32 playerId;
NLMISC::fromString(args[0], playerId);
string characterName = args[1];
EGSPD::CPeople::TPeople race = EGSPD::CPeople::fromString( args[2] );
if( race == EGSPD::CPeople::EndPeople ) return false;
@ -2966,7 +2981,8 @@ NLMISC_COMMAND(spawnCharacters," spawn somes characters","<Number, characterName
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 )
{
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 )
{
uint32 playerId = atoi( args[0].c_str() );
uint32 playerId;
NLMISC::fromString(args[0], playerId);
string characterName = args[1];
EGSPD::CPeople::TPeople race = EGSPD::CPeople::fromString( args[2] );
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] );
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 );
if( player != 0 )
@ -3017,7 +3035,8 @@ NLMISC_COMMAND(savePlayerActiveChar," save player with regular character filenam
{
if( args.size() >= 1 )
{
uint32 userId = atoi( args[0].c_str() );
uint32 userId;
NLMISC::fromString(args[0], userId);
if(args.size() == 2)
{
string filename = args[1];
@ -3040,7 +3059,8 @@ NLMISC_COMMAND(saveAllPlayerChars," saveAllPlayerChars","uid")
{
if( args.size() == 1 )
{
uint32 userId = atoi( args[0].c_str() );
uint32 userId;
NLMISC::fromString(args[0], userId);
// If the user really exist
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 )
{
uint32 userId = atoi( args[0].c_str() );
uint32 userId;
NLMISC::fromString(args[0], userId);
if(args.size() == 3)
{
uint32 charIndex = (uint32)atoi(args[1].c_str());
uint32 charIndex;
NLMISC::fromString(args[1], charIndex);
string filename = args[2];
PlayerManager.reloadPlayerActiveChar( userId, charIndex, &filename );
}
@ -3101,7 +3123,8 @@ NLMISC_COMMAND(loadPlayer," load a player","uid")
{
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
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 )
{
uint32 userId = atoi( args[0].c_str() );
uint32 characterIndex = atoi( args[1].c_str() );
uint32 userId;
NLMISC::fromString(args[0], userId);
uint32 characterIndex;
NLMISC::fromString(args[1], characterIndex);
CCharacter * ch = PlayerManager.getChar( userId, characterIndex );
if( ch )
@ -3153,8 +3178,10 @@ NLMISC_COMMAND(simulateClientReady,"Simulate clientReady for a character","clien
{
if( args.size() == 2 )
{
uint32 userId = atoi( args[0].c_str() );
uint32 characterIndex = atoi( args[1].c_str() );
uint32 userId;
NLMISC::fromString(args[0], userId);
uint32 characterIndex;
NLMISC::fromString(args[1], characterIndex);
CCharacter * ch = PlayerManager.getChar( userId, characterIndex );
if( ch )
@ -3206,7 +3233,8 @@ NLMISC_COMMAND(moveCharAndOfflineCmdToHashTable, "Move all character and offline
explode(CFile::getFilename(allChars[i]), string("_"), parts);
if (parts.size() == 4)
{
uint32 userId = atoi(parts[1].c_str());
uint32 userId;
NLMISC::fromString(parts[1], userId);
// make sure the dest path exist
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);
if (parts.size() == 4)
{
uint32 userId = atoi(parts[1].c_str());
uint32 userId;
NLMISC::fromString(parts[1], userId);
// make sure the dest path exist
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];
uint32 account, slot;
account = atoi(accountStr.c_str());
slot = atoi(slotStr.c_str());
NLMISC::fromString(accountStr, account);
NLMISC::fromString(slotStr, 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];
uint32 account, slot;
account = atoi(accountStr.c_str());
slot = atoi(slotStr.c_str());
NLMISC::fromString(accountStr, account);
NLMISC::fromString(slotStr, slot);
// check if the character is already converted
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 )
return false;
uint32 fid = (uint32)atoi(args[0].c_str());
uint32 lid = (uint32)atoi(args[1].c_str());
uint32 rep = (uint32)atoi(args[2].c_str());
NLNET::TServiceId feid(atoi(args[3].c_str()));
uint32 fid, lid, rep;
NLMISC::fromString(args[0], fid);
NLMISC::fromString(args[1], lid);
NLMISC::fromString(args[2], rep);
uint16 sid;
NLMISC::fromString(args[3], sid);
NLNET::TServiceId feid(sid);
if( rep != 0 && lid >= fid )
{
@ -3499,7 +3531,8 @@ NLMISC_COMMAND(disconnectPlayer,"remove player from egs","<user id>")
if( args.size() != 1 )
return false;
uint32 id = (uint32)atoi(args[0].c_str());
uint32 id;
NLMISC::fromString(args[0], id);
if( PlayerManager.getPlayer( id ) != 0)
{
PlayerManager.savePlayerActiveChar( id );
@ -3611,9 +3644,11 @@ NLMISC_COMMAND( harvest," harvest","entity id(id:type:crea:dyn), Index Mp, Qty")
CEntityId id;
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 );
if( character )
@ -3666,7 +3701,8 @@ NLMISC_COMMAND( createItemInBagTest," create_item_in_bag", "player id(id:type:cr
CSheetId sheet;
uint32 sheetId = atoi(args[1].c_str());
uint32 sheetId;
NLMISC::fromString(args[1], sheetId);
if (sheetId)
sheet = CSheetId(sheetId);
else
@ -3676,8 +3712,9 @@ NLMISC_COMMAND( createItemInBagTest," create_item_in_bag", "player id(id:type:cr
sheetName += string(".item");
sheet = CSheetId(sheetName.c_str());
}
uint quantity = atoi(args[2].c_str());
uint quality = atoi(args[3].c_str());
uint quantity, quality;
NLMISC::fromString(args[2], quantity);
NLMISC::fromString(args[3], quality);
const CStaticItem* form = CSheets::getForm( sheet );
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() );
sint32 vb, b, m, s;
vb = atoi( args[1].c_str() );
b = atoi( args[2].c_str() );
m = atoi( args[3].c_str() );
s = atoi( args[4].c_str() );
NLMISC::fromString(args[1], vb);
NLMISC::fromString(args[2], b);
NLMISC::fromString(args[3], m);
NLMISC::fromString(args[4], s);
CCharacter *e = PlayerManager.getChar(id);
if( e )
@ -4146,7 +4183,8 @@ NLMISC_COMMAND(displayAIRegisteredServices,"Display the list of services registe
return false;
}
const uint16 level = atoi( args[2].c_str() );
uint16 level;
NLMISC::fromString(args[2], level);
CCharacter *e = PlayerManager.getChar(id);
if( e )
@ -4177,7 +4215,7 @@ NLMISC_COMMAND(entityForcedDefaultLevel,"read or set the EntityForcedDefaultLeve
}
else if( args.size() == 1 )
{
EntityForcedDefaultLevel = (uint8)atoi(args[0].c_str());
NLMISC::fromString(args[0], EntityForcedDefaultLevel);
log.displayNL("EntityForcedDefaultLevel set to %d", EntityForcedDefaultLevel);
return true;
}
@ -4238,7 +4276,8 @@ NLMISC_COMMAND(setAllJobsLevel,"set all chosen player job levels to given value
CEntityId id;
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);
if( e )
@ -4273,7 +4312,8 @@ NLMISC_COMMAND(setAllSkillsToValue,"set all skills to value","<entity id(id:type
CEntityId id;
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);
if( e )
@ -4370,11 +4410,14 @@ NLMISC_COMMAND(displayItemInInventory,"display item characteristics (item is in
INVENTORIES::TInventory inventory = INVENTORIES::toInventory( args[1].c_str() );
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 )
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);
if (item != NULL)
@ -4407,11 +4450,12 @@ NLMISC_COMMAND(destroyItemInInventory,"destroy the specified item","<player id(i
return true;
}
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;
if (args.size() == 4)
qty = atoi(args[3].c_str());
NLMISC::fromString(args[3], qty);
CGameItemPtr itemPtr = c->getInventory(inventory)->getItem(slot);
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 uint32 slot1 = atoi(args[2].c_str());
uint32 slot1;
NLMISC::fromString(args[2], slot1);
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;
if (args.size() == 6)
qty = atoi(args[5].c_str());
NLMISC::fromString(args[5], 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() );
return true;
}
const uint16 inventory = (uint16) atoi(args[1].c_str());
const uint16 slot = (uint16) atoi(args[2].c_str());
uint16 inventory;
NLMISC::fromString(args[1], inventory);
uint16 slot;
NLMISC::fromString(args[2], slot);
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);
if (itemPtr != NULL)
@ -4598,8 +4647,8 @@ NLMISC_COMMAND(sendPetAnimalCommand,"Send a pet animal command","<player id(id:t
uint32 petCommand;
id.fromString( args[0].c_str() );
petIndex = atoi( args[1].c_str());
petCommand = atoi( args[2].c_str() );
NLMISC::fromString(args[1], petIndex);
NLMISC::fromString(args[2], petCommand);
CCharacter *c = PlayerManager.getChar(id);
if( c )
@ -4631,7 +4680,7 @@ NLMISC_COMMAND(testProgression,"testProgression of skill","<player id(id:type:cr
else
{
c->TestProgression = SKILLS::toSkill( c->TestProgressSkill ) != SKILLS::unknown;
Rate = atoi( args[1].c_str() );
NLMISC::fromString(args[1], Rate);
c->XpGainRate = Rate;
c->TestProgressSkill = args[2];
@ -4677,9 +4726,12 @@ NLMISC_COMMAND(teleportPlayerCharacter,"Teleport online player character","<char
if( c )
{
sint32 x, y, z;
x = atoi( args[1].c_str() ) * 1000;
y = atoi( args[2].c_str() ) * 1000;
z = atoi( args[3].c_str() ) * 1000;
NLMISC::fromString(args[1], x);
x *= 1000;
NLMISC::fromString(args[2], y);
y *= 1000;
NLMISC::fromString(args[3], z);
z *= 1000;
if( c->getEnterFlag() )
{
@ -4740,7 +4792,8 @@ NLMISC_COMMAND(setHPBar,"set the value of an entity HP bar (0..100)","<entity id
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) );
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 );
if (c )
{
uint8 nb = (uint8)atoi(args[1].c_str());
uint8 nb;
NLMISC::fromString(args[1], nb);
c->consumeAmmo(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;
uint32 sapRecharged;
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 ) );
if( player )
{
@ -5125,7 +5179,8 @@ NLMISC_COMMAND(enchantItem,"enchantItem with crystallized action from bag","<eId
{
CEntityId id;
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 ) );
if( player )
{
@ -5150,7 +5205,8 @@ NLMISC_COMMAND(rechargeItem,"recharge sapLaod of an item with sap recharge item
{
CEntityId id;
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 ) );
if( player )
{
@ -5429,8 +5485,11 @@ NLMISC_COMMAND (createEffectOnEntity, "create given effect on entity", "<eid> <e
return false;
}
uint32 duration = (uint32)( atoi(args[2].c_str()) / CTickEventHandler::getGameTimeStep() );
uint32 value = (uint32) atoi(args[3].c_str());
uint32 duration;
NLMISC::fromString(args[2], duration);
duration = (uint32)(NLMISC::TGameCycle(duration) / CTickEventHandler::getGameTimeStep());
uint32 value;
NLMISC::fromString(args[3], value);
CSTimedEffect *effect = IEffectFactory::buildEffect(family);
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() );
sint32 &temp = lookupStat(var);
sint32 v = atoi( value.c_str() );
sint32 v;
NLMISC::fromString(value, v);
if( v < 0 )
{
v = 0;
@ -881,7 +882,8 @@ bool CEntityBase::modifyValue( const string& var, const string& value )
try
{
sint32 &temp = lookupStat(var);
sint32 v = atoi( value.c_str() );
sint32 v;
NLMISC::fromString(value, v);
sint32 oldValue = temp;
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() );

View file

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

View file

@ -852,11 +852,15 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
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);
// 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;
// }
//
// 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);
// if (item != NULL)
@ -911,12 +918,18 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
// return false;
// }
//
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) );
// //uint16 quality = (uint16)atoi(args[1].c_str());
// CEntityId itemId( RYZOMID::object, NLMISC::fromString(args[0].c_str()) );
// //uint16 quality = (uint16)NLMISC::fromString(args[1].c_str());
//
// sint32 x = (sint32)atoi(args[2].c_str()) * 1000;
// sint32 y = (sint32)atoi(args[3].c_str()) * 1000;
// sint32 z = (sint32)atoi(args[4].c_str()) * 1000;
// sint32 x;
// NLMISC::fromString(args[2], x);
// 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 );
//
@ -936,20 +949,20 @@ NLMISC_COMMAND(createItem,"create a new item","<sheet id><quality><owner id>")
// if( args.size() < 6 )
// {
// CSheetId sheetId(args[0]);
// uint16 quality = (uint16)atoi(args[1].c_str());
// sint32 x = (sint32)atoi(args[2].c_str()) * 1000;
// sint32 y = (sint32)atoi(args[3].c_str()) * 1000;
// sint32 z = (sint32)atoi(args[4].c_str()) * 1000;
// uint16 quality = (uint16)NLMISC::fromString(args[1].c_str());
// sint32 x = (sint32)NLMISC::fromString(args[2].c_str()) * 1000;
// sint32 y = (sint32)NLMISC::fromString(args[3].c_str()) * 1000;
// sint32 z = (sint32)NLMISC::fromString(args[4].c_str()) * 1000;
// GameItemManager.createItem( sheetId, quality, x, y, z, true , true);
// }
// else
// {
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) );
// CEntityId itemId( RYZOMID::object, NLMISC::fromString(args[0].c_str()) );
// CSheetId sheetId(args[1]);
// uint16 quality = (uint16)atoi(args[2].c_str());
// sint32 x = (sint32)atoi(args[3].c_str()) * 1000;
// sint32 y = (sint32)atoi(args[4].c_str()) * 1000;
// sint32 z = (sint32)atoi(args[5].c_str()) * 1000;
// uint16 quality = (uint16)NLMISC::fromString(args[2].c_str());
// sint32 x = (sint32)NLMISC::fromString(args[3].c_str()) * 1000;
// sint32 y = (sint32)NLMISC::fromString(args[4].c_str()) * 1000;
// sint32 z = (sint32)NLMISC::fromString(args[5].c_str()) * 1000;
// 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;
// }
//
// CEntityId itemId( RYZOMID::object, atoi(args[0].c_str()) );
// CEntityId itemId( RYZOMID::object, NLMISC::fromString(args[0].c_str()) );
// CGameItemPtr ptr = GameItemManager.getItem(itemId);
// 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;
}
sint32 fame = atoi(args[2].c_str());
sint32 fame;
NLMISC::fromString(args[2], fame);
CFameManager &fm = CFameManager::getInstance();
@ -2088,7 +2089,8 @@ NLMISC_COMMAND (adjustCharacterFame, "For a character, adjust a specific clan by
}
// 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);
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
sint32 fameAdjustment = atoi(args[2].c_str());
sint32 fameAdjustment;
NLMISC::fromString(args[2], 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)));

View file

@ -412,8 +412,10 @@ NLMISC_COMMAND(testGuildSetLeader,"set the leader of a guild","<userId> <index>
return true;
CEntityId eId;
eId.fromString(args[0].c_str());
uint16 index = (uint16)atoi(args[1].c_str() );
uint8 session = (uint8)atoi(args[2].c_str() );
uint16 index;
NLMISC::fromString(args[1], index);
uint8 session;
NLMISC::fromString(args[2], session);
GET_GUILD_MODULE(eId);
module->setLeader( index,session );
log.displayNL("Command Executed");
@ -427,8 +429,10 @@ NLMISC_COMMAND(testGuildSetGrade,"set the grade of a member","<userId> <index> <
return false;
CEntityId eId;
eId.fromString(args[0].c_str());
uint16 index = (uint16)atoi(args[1].c_str() );
uint8 session = (uint8)atoi(args[2].c_str() );
uint16 index;
NLMISC::fromString(args[1], index);
uint8 session;
NLMISC::fromString(args[2], session);
EGSPD::CGuildGrade::TGuildGrade grade = EGSPD::CGuildGrade::fromString( args[4] );
GET_GUILD_MODULE(eId);
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();
else
{
guildId = atoi(args[1].c_str());
NLMISC::fromString(args[1], guildId);
if (guildId == 0)
{
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
string idStr = file.substr(6,5);
uint32 id = atoi( idStr.c_str() );
uint32 id;
NLMISC::fromString(idStr, id);
if (guildId != 0)
id = guildId;
@ -524,7 +529,8 @@ NLMISC_COMMAND( importGuildFile, "Import a guild file into the server", "<filena
{
// Load a text file
string idStr = file.substr(6,5);
uint32 id = atoi( idStr.c_str() );
uint32 id;
NLMISC::fromString(idStr, id);
if (guildId != 0)
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+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())
{
@ -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+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);
@ -1859,7 +1861,9 @@ NLMISC_CLASS_COMMAND_IMPL(CGuildManager, loadGuild)
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)
{
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)
// return false;
//
// TGuildId guildId = atoi(args[0].c_str());
// TGuildId guildId;
// NLMISC::fromString(args[0], guildId);
//
// CGuild *guild = getGuildFromId(guildId);
// if (guild == NULL)

View file

@ -1191,10 +1191,6 @@ NLMISC_VARIABLE( sint32, ForageSourceDisplay, "Row index of source to verbose" )
TDataSetRow TestSourceRow;
#define astof(i) ((float)(atoi( args[i].c_str() )))
void forageTestDoBegin()
{
CHarvestSource templateSource, *testSource;
@ -1323,21 +1319,25 @@ NLMISC_COMMAND( forageTestExtract, "Make a test extraction (floats in percent)",
float successFactor = 1.0f;
if ( n > 0 )
{
nbIterations = atoi( args[0].c_str() );
NLMISC::fromString(args[0], nbIterations);
if ( n > 1 )
{
reqPeriod = astof( 1 );
NLMISC::fromString(args[1], reqPeriod);
if ( n > 2)
{
reqA = astof( 2 );
NLMISC::fromString(args[2], reqA);
if ( n > 3 )
{
reqQ = astof( 3 );
if ( n > 34)
NLMISC::fromString(args[3], reqQ);
if ( n > 4)
{
absorption = astof( 4 ) / 100.0f;
NLMISC::fromString(args[4], absorption);
absorption /= 100.0f;
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;
// get numeric values for the 2 arguments
IInterShardExchangeValidator::TShardId shardId= (IInterShardExchangeValidator::TShardId)atoi(args[0].c_str());
IInterShardExchangeValidator::TLevelCap levelCap= (IInterShardExchangeValidator::TLevelCap)atoi(args[1].c_str());
IInterShardExchangeValidator::TShardId shardId;
NLMISC::fromString(args[0], shardId);
IInterShardExchangeValidator::TLevelCap levelCap;
NLMISC::fromString(args[1], levelCap);
// make sure the numeric conversion was successfule for the 2 arguments
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;
// 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
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");
error = true;
}
// TAIAlias id = atoi( value.c_str() );
// TAIAlias id;
// NLMISC::fromString(value, id);
if ( !prim->getPropertyByName("name",name) )
{
nlwarning("<CAIAliasTranslator buildMissionTree> no name property in a mission node");

View file

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

View file

@ -207,7 +207,7 @@ bool CMissionEventGiveMoney::buildFromScript( const std::vector< std::string > &
log.displayNL("<money>");
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");
return true;
}
@ -283,8 +283,8 @@ bool CMissionEventBuyItem::buildFromScript( const std::vector< std::string > & s
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Quantity = atoi( script[1].c_str() );
Quality = atoi( script[2].c_str() );
NLMISC::fromString(script[1], Quantity);
NLMISC::fromString(script[2], Quality);
if (script.size() == 4)
{
CEntityId id;
@ -315,8 +315,8 @@ bool CMissionEventSellItem::buildFromScript( const std::vector< std::string > &
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Quantity = atoi( script[1].c_str() );
Quality = atoi( script[2].c_str() );
NLMISC::fromString(script[1], Quantity);
NLMISC::fromString(script[2], Quality);
if (script.size() == 4)
{
CEntityId id;
@ -348,8 +348,8 @@ bool CMissionEventForage::buildFromScript( const std::vector< std::string > & sc
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Quantity = atoi( script[1].c_str() );
Quality = atoi( script[2].c_str() );
NLMISC::fromString(script[1], Quantity);
NLMISC::fromString(script[2], Quality);
return ret;
}
@ -380,7 +380,7 @@ bool CMissionEventSkillProgress::buildFromScript( const std::vector< std::string
ret = false;
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Level = atoi( script[1].c_str() );
NLMISC::fromString(script[1], Level);
return ret;
}
@ -419,8 +419,8 @@ bool CMissionEventCraft::buildFromScript( const std::vector< std::string > & scr
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Quantity = atoi( script[1].c_str() );
Quality = atoi( script[2].c_str() );
NLMISC::fromString(script[1], Quantity);
NLMISC::fromString(script[2], Quality);
return ret;
}
@ -464,8 +464,8 @@ bool CMissionEventLootItem::buildFromScript( const std::vector< std::string > &
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Quantity = atoi( script[1].c_str() );
Quality = atoi( script[2].c_str() );
NLMISC::fromString(script[1], Quantity);
NLMISC::fromString(script[2], Quality);
return ret;
}
@ -485,8 +485,8 @@ bool CMissionEventLootRm::buildFromScript( const std::vector< std::string > & sc
log.displayNL("Invalid sheet %s",script[0].c_str() );
}
Quantity = atoi( script[1].c_str() );
Quality = atoi( script[2].c_str() );
NLMISC::fromString(script[1], Quantity);
NLMISC::fromString(script[2], Quality);
return ret;
}
@ -498,8 +498,8 @@ bool CMissionEventKillGroup::buildFromScript( const std::vector< std::string > &
log.displayNL("<alias>");
return false;
}
Alias = (TAIAlias)atoi(script[0].c_str());
NLMISC::fromString(script[0], Alias);
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());
ret = false;
}
_Quality = (uint16) atoi( script[3].c_str() );
NLMISC::fromString(script[3], _Quality);
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());
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" ) )
_Params.SapBuff = atoi(args[1].c_str());
NLMISC::fromString(args[1], _Params.SapBuff);
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" ) )
_Params.FocusBuff = atoi(args[1].c_str());
NLMISC::fromString(args[1], _Params.FocusBuff);
else if( !nlstricmp(args[0],"Color" ) )
{
uint8 color = (uint8)atoi(args[1].c_str());
uint8 color;
NLMISC::fromString(args[1], color);
if( color <= 7 )
{
_Params.Color[color] = 1;

View file

@ -72,7 +72,7 @@ bool CMissionParser::solveTextsParams(uint32 lineNum, TVectorParamCheck & txtPar
if ( j == paramTypes.size() )
{
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" )
{
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() ) ;
ret = false;
}
uint16 quality = (uint16) atoi( args[1].c_str() );
uint16 quality;
NLMISC::fromString(args[1], quality);
if ( quality == 0 )
{
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>");
return false;
}
_ChargePoints = uint32(atoi( script[1].c_str() ));
NLMISC::fromString(script[1], _ChargePoints);
if ( _ChargePoints == 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" );
missionData.ChatParams.push_back( make_pair( args[0], STRING_MANAGER::item ) );
if ( args.size() > 1 )
subStep.Quantity = atoi( args[1].c_str() );
NLMISC::fromString(args[1], subStep.Quantity);
else
subStep.Quantity = 1;
if ( args.size() == 3 )
{
subStep.Quality = atoi( args[2].c_str() );
qualityFound = true;;
NLMISC::fromString(args[2], subStep.Quality);
qualityFound = true;
}
else
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -485,15 +485,19 @@ NLMISC_COMMAND(activateEasterEgg, "activate an easter egg","<EasterEggId><Scenar
if( args.size() != 6 )
return false;
uint32 easterEggId = (uint32)atoi(args[0].c_str());
TSessionId scenarioId = (TSessionId)(uint32)atoi(args[1].c_str());
uint32 aiInstanceId = (uint32)atoi(args[2].c_str());
NLMISC::CSheetId itemSheet = CSheetId(args[3]);
uint32 easterEggId;
NLMISC::fromString(args[0], easterEggId);
uint32 scId;
NLMISC::fromString(args[1], scId);
TSessionId scenarioId(scId);
uint32 aiInstanceId;
NLMISC::fromString(args[2], aiInstanceId);
NLMISC::CSheetId itemSheet(args[3]);
CFarPosition fPos;
fPos.SessionId = scenarioId;
fPos.PosState.X = (sint32)atoi(args[4].c_str());;
fPos.PosState.Y = (sint32)atoi(args[5].c_str());;
NLMISC::fromString(args[4], fPos.PosState.X);;
NLMISC::fromString(args[5], fPos.PosState.Y);;
R2::TItemAndQuantity item;
item.Quantity = 1;
@ -511,8 +515,10 @@ NLMISC_COMMAND(deactivateEasterEgg, "unactive an easter egg spwaned by scenario"
if( args.size() != 2 )
return false;
uint32 easterEggId = (uint32)atoi(args[0].c_str());
TSessionId scenarioId = (TSessionId)(uint32)atoi(args[1].c_str());
uint32 easterEggId, scId;
NLMISC::fromString(args[0], easterEggId);
NLMISC::fromString(args[1], scId);
TSessionId scenarioId(scId);
CR2EasterEgg::getInstance().deactivateEasterEgg(easterEggId, scenarioId);
return true;
@ -527,8 +533,8 @@ NLMISC_COMMAND(easterEggTPActChange, "simulate an act change", "<CharacterId><x>
eid.fromString(args[0].c_str());
CFarPosition fPos;
fPos.PosState.X = (sint32)atoi(args[1].c_str());
fPos.PosState.Y = (sint32)atoi(args[2].c_str());
NLMISC::fromString(args[1], fPos.PosState.X);
NLMISC::fromString(args[2], fPos.PosState.Y);
CR2EasterEgg::getInstance().easterEggTPActChange(eid, fPos);
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();
else return false;
msg.GroupAlias = (uint32)atoi(args[2].c_str());
msg.InstanceId = (uint32)atoi(args[3].c_str());
NLMISC::fromString(args[2], msg.GroupAlias);
NLMISC::fromString(args[3], msg.InstanceId);
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];
CR2GiveItem::getInstance().giveItemRequest( msg );
return true;
@ -345,7 +347,8 @@ NLMISC_COMMAND(giveItemGranted, "test command for give item R2 features", "<Crea
CCreature *c = CreatureManager.getCreature(eid);
if(c) creatureRowId = c->getEntityRowId();
else return false;
uint32 actionId = (uint32)atoi(args[1].c_str());
uint32 actionId;
NLMISC::fromString(args[1], actionId);
CR2GiveItem::getInstance().giveItemGranted( creatureRowId, actionId );
return true;
}

View file

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

View file

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

View file

@ -357,7 +357,8 @@ void COutpostManager::outpostFileCallback(const CFileDescription& fileDescriptio
aliasStr.resize( aliasStr.length() - 4 );
aliasStr = aliasStr.substr( 8);
TAIAlias alias = (TAIAlias) atoi( aliasStr.c_str() );
TAIAlias alias;
NLMISC::fromString(aliasStr, alias);
COutpost * outpost = getOutpostFromAlias( alias );
if ( !outpost )
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 = aliasStr.substr( 8, file.length() - 8 );
//
// TAIAlias alias = (TAIAlias) atoi( aliasStr.c_str() );
// TAIAlias alias;
// NLMISC::fromString(aliasStr, alias);
// COutpost * outpost = getOutpostFromAlias( alias );
// if ( !outpost )
// 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() );
return true;
}
uint16 radius = (uint16) atoi(args[2].c_str());
uint16 radius;
NLMISC::fromString(args[2], radius);
CRangeSelector selector;
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;
}
uint16 range = (uint16) atoi(args[2].c_str());
uint max = (uint) atoi(args[3].c_str());
uint16 range;
NLMISC::fromString(args[2], range);
uint max;
NLMISC::fromString(args[3], max);
CRangeSelector selector;
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 )
{
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;
player->getValue(var,currentValueStr);
sint32 currentValue = atoi( currentValueStr.c_str() );
sint32 currentValue;
NLMISC::fromString(currentValueStr, currentValue);
string newValueStr = toString(currentValue + _Modifier1 + _Modifier2);
player->setValue(var,newValueStr);
@ -85,7 +86,8 @@ void CChgCharacEffect::removed()
string currentValueStr;
player->getValue(var,currentValueStr);
sint32 currentValue = atoi( currentValueStr.c_str() );
sint32 currentValue;
NLMISC::fromString(currentValueStr, currentValue);
string newValueStr = toString(currentValue - _Modifier1 - _Modifier2);
player->setValue(var,newValueStr);
}

View file

@ -705,9 +705,10 @@ NLMISC_COMMAND(simuCraft, "Simulation de craft pour verifier les probabilit
if (args.size() != 3)
return false;
uint32 nbSimu = (uint32)atoi(args[0].c_str());
uint32 skillLevel = (uint32)atoi(args[1].c_str());
uint32 itemQuality = (uint32)atoi(args[2].c_str());
uint32 nbSimu, skillLevel, itemQuality;
NLMISC::fromString(args[0], nbSimu);
NLMISC::fromString(args[1], skillLevel);
NLMISC::fromString(args[2], 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 )
{
// 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) )
{
CVector centerPos;

View file

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

View file

@ -156,15 +156,15 @@ NLMISC_COMMAND( spawnToxicCloud, "Spawn a toxic cloud", "<posXm> <posYm> <iRadiu
TGameCycle lifetime = CToxicCloud::ToxicCloudDefaultLifetime;
if ( args.size() > 2 )
{
iRadius = atoi( args[2].c_str() );
NLMISC::fromString(args[2], iRadius);
if ( args.size() > 3 )
{
dmgPerHit = atoi( args[3].c_str() );
NLMISC::fromString(args[3], dmgPerHit);
if ( args.size() > 4 )
{
updateFrequency = atoi( args[4].c_str() );
NLMISC::fromString(args[4], updateFrequency);
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)
{
// dealing with an array of entries
unsigned countAsInt=(unsigned)atoi(count);
uint countAsInt;
NLMISC::fromString(count, countAsInt);
nlassert((const char *) count != NULL);
for (unsigned i=0;i<countAsInt;i++)
for (uint i=0;i<countAsInt;i++)
{
// Progress bar
progressCallBack.progress ((float)i/(float)countAsInt);
@ -345,10 +346,11 @@ void CCDBStructNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &pro
if ((const char *) count != NULL)
{
// dealing with an array of entries
unsigned countAsInt=(unsigned)atoi(count);
uint countAsInt;
NLMISC::fromString(count, countAsInt);
nlassert((const char *) count != NULL);
for (unsigned i=0;i<countAsInt;i++)
for (uint i=0;i<countAsInt;i++)
{
// Progress bar
progressCallBack.progress ((float)i/(float)countAsInt);

View file

@ -926,7 +926,7 @@ bool CCharacter::setValue( string var, string value )
try
{
sint32 &temp = lookupStat(var);
temp = atoi( value.c_str() );
NLMISC::fromString(value, temp);
}
catch( CCharacter::EInvalidStat &e)
{
@ -949,7 +949,9 @@ bool CCharacter::modifyValue( string var, string value )
try
{
sint32 &temp = lookupStat(var);
temp = temp + atoi( value.c_str() );
sint32 valueInt;
NLMISC::fromString(value, valueInt);
temp = temp + valueInt;
}
catch( CCharacter::EInvalidStat &e)
{
@ -7882,7 +7884,8 @@ void CCharacter::setStartStatistics( const CCreateCharMsg& createCharMsg )
if( valueString.size() > 0 )
{
SKILLS::ESkills skillEnum = SKILLS::toSkill(skillString);
sint32 skillPoint = (sint32) atoi(valueString.c_str());
sint32 skillPoint;
NLMISC::fromString(valueString, skillPoint);
if( skillEnum != SKILLS::unknown )
{
_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)
code = phraseStr.substr(4,1); //string( text[4] );
txt = phraseStr.substr(5,2);
lvl = atoi( txt.c_str() );
NLMISC::fromString(txt, lvl);
CHARACTERISTICS::TCharacteristics charac = CHARACTERISTICS::getCharacteristicFromCode(code);
if (charac < CHARACTERISTICS::NUM_CHARACTERISTICS)