mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 11:50:53 +00:00
Changed: #142 Replace atoi and sscanf by fromString when it's possible
This commit is contained in:
parent
46ee8c173a
commit
58ddc84100
8 changed files with 137 additions and 69 deletions
|
@ -741,7 +741,8 @@ namespace ADMIN
|
|||
NLMISC::CFile::deleteFile(ShutdownRequestFileName);
|
||||
fileContents= fileContents.strip().splitToOneOfSeparators(" \t\n\r\x1a");
|
||||
|
||||
_ShutdownForPatch = atoi(fileContents.c_str()) == 0;
|
||||
NLMISC::fromString(fileContents, _ShutdownForPatch);
|
||||
_ShutdownForPatch = !_ShutdownForPatch;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -838,7 +839,10 @@ namespace ADMIN
|
|||
fclose(f);
|
||||
|
||||
// return the pid read from the file
|
||||
return atoi(txt.c_str());
|
||||
uint32 pid;
|
||||
NLMISC::fromString(txt, pid);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
||||
|
@ -864,7 +868,10 @@ namespace ADMIN
|
|||
fclose(f);
|
||||
|
||||
// parse the text in the buffer
|
||||
return uint32(atoi(txt.c_str()));
|
||||
uint32 counter;
|
||||
NLMISC::fromString(txt, counter);
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
// retrieve service launch info in the config file
|
||||
|
@ -1045,12 +1052,21 @@ namespace ADMIN
|
|||
// update the service state
|
||||
ss.RunningState = TRunningState::rs_online;
|
||||
if (pclDontUseShardOrders)
|
||||
ss.DontUseShardOrders = atoi(pclDontUseShardOrders->ParamValue.c_str()) != 0;
|
||||
NLMISC::fromString(pclDontUseShardOrders->ParamValue, ss.DontUseShardOrders);
|
||||
else
|
||||
ss.DontUseShardOrders = false;
|
||||
ss.LongName = pclLongName != NULL ? pclLongName->ParamValue : "unknown";
|
||||
ss.ShortName = pclShortName != NULL ? pclShortName->ParamValue : "unknown";
|
||||
ss.PID = pclPID!= NULL ? uint32(atoi(pclPID->ParamValue.c_str())) : 0;
|
||||
|
||||
if (pclPID!= NULL)
|
||||
{
|
||||
NLMISC::fromString(pclPID->ParamValue, ss.PID);
|
||||
}
|
||||
else
|
||||
{
|
||||
ss.PID = 0;
|
||||
}
|
||||
|
||||
ss.State = "";
|
||||
ss.LastStateDate = NLMISC::CTime::getSecondsSince1970();
|
||||
ss.ServiceModule = moduleProxy;
|
||||
|
@ -1362,7 +1378,8 @@ retry_pending_command_loop:
|
|||
return false;
|
||||
|
||||
string shardName = args[0];
|
||||
uint32 delay = atoi(args[1].c_str());
|
||||
uint32 delay;
|
||||
NLMISC::fromString(args[1], delay);
|
||||
|
||||
log.displayNL("Received command to stop all service of shard %s in %us", shardName.c_str(), delay);
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ NLMISC_COMMAND(dumpRoadCon, "dump road/cell connectivity graph","<continentName>
|
|||
uint instanceIndex = 0;
|
||||
|
||||
if (args.size() == 2)
|
||||
instanceIndex = atoi(args[1].c_str());
|
||||
NLMISC::fromString(args[1], instanceIndex);
|
||||
|
||||
if (instanceIndex >= CAIS::instance().AIList().size())
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ NLMISC_COMMAND(dumpContinent, "dump the structure of a continent","<continentNam
|
|||
uint instanceIndex = 0;
|
||||
|
||||
if (args.size() == 2)
|
||||
instanceIndex = atoi(args[1].c_str());
|
||||
NLMISC::fromString(args[1], instanceIndex);
|
||||
|
||||
if (instanceIndex >= CAIS::instance().AIList().size())
|
||||
{
|
||||
|
@ -552,7 +552,8 @@ NLMISC_COMMAND(createDynamicAIInstance, "Create a new dynamic AIInstance","")
|
|||
return false;
|
||||
|
||||
// find an unused continent id
|
||||
uint32 in=atoi(args[0].c_str());
|
||||
uint32 in;
|
||||
NLMISC::fromString(args[0], in);
|
||||
if( !CAIS::instance().getAIInstance(in) )
|
||||
{
|
||||
std::string name= NLMISC::toString("ring_%d",in);
|
||||
|
@ -813,7 +814,7 @@ public:
|
|||
const std::string &str=args[i];
|
||||
string res;
|
||||
if (getParameter(str,"index-",res))
|
||||
_index=uint32(atoi(res.c_str()));
|
||||
NLMISC::fromString(res, _index);
|
||||
if (getParameter(str,"value-",res))
|
||||
_value=float(atof(res.c_str()));
|
||||
_detailled|=getParameter(str,"detailled",res);
|
||||
|
@ -2039,7 +2040,7 @@ NLMISC_COMMAND(displayVisionRadius,"display roughly 'radius' cell vision centred
|
|||
x=atof(args[1].c_str());
|
||||
y=atof(args[2].c_str());
|
||||
if (args.size()==4)
|
||||
dist=atoi(args[3].c_str());
|
||||
NLMISC::fromString(args[3], dist);
|
||||
log.displayNL("%dm Vision around (%.3f,%.3f)", dist, x.asDouble(), y.asDouble());
|
||||
|
||||
uint32 botCount=0;
|
||||
|
@ -2230,7 +2231,8 @@ NLMISC_COMMAND(setWatch,"setup one of the watch variables","<watch id> <mgr, grp
|
|||
if (args.size()!=2 && args.size()!=3)
|
||||
return false;
|
||||
|
||||
uint idx=atoi(args[0].c_str());
|
||||
uint idx;
|
||||
NLMISC::fromString(args[0], idx);
|
||||
if ( toString(idx)!=args[0]
|
||||
|| idx>=sizeof(watchStrings)/sizeof(watchStrings[0]))
|
||||
return false;
|
||||
|
@ -2243,7 +2245,7 @@ NLMISC_COMMAND(setWatch,"setup one of the watch variables","<watch id> <mgr, grp
|
|||
watchEntity[idx]=CAIEntityPtr;
|
||||
|
||||
if (args.size()==3)
|
||||
watchIdx[idx]=atoi(args[2].c_str());
|
||||
NLMISC::fromString(args[2], watchIdx[idx]);
|
||||
else
|
||||
watchIdx[idx]=0;
|
||||
return true;
|
||||
|
@ -2414,14 +2416,18 @@ NLMISC_COMMAND(setGrpTimers,"set the timer values for a given group","<grp id> <
|
|||
return true;
|
||||
}
|
||||
|
||||
if (atoi(args[1].c_str())<1 || atoi(args[2].c_str())<1)
|
||||
uint32 eatTime, restTime;
|
||||
NLMISC::fromString(args[1], eatTime);
|
||||
NLMISC::fromString(args[2], restTime);
|
||||
|
||||
if (eatTime<1 || restTime<1)
|
||||
{
|
||||
log.displayNL("Invalid time parameters");
|
||||
return true;
|
||||
}
|
||||
|
||||
grp->setTimer(CGrpFauna::EAT_TIME,(uint32)atoi(args[1].c_str())*10);
|
||||
grp->setTimer(CGrpFauna::REST_TIME,(uint32)atoi(args[2].c_str())*10);
|
||||
grp->setTimer(CGrpFauna::EAT_TIME, eatTime*10);
|
||||
grp->setTimer(CGrpFauna::REST_TIME, restTime*10);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2437,13 +2443,18 @@ NLMISC_COMMAND(updateAI,"call CAIS::update() (simulate a tick off-line)","")
|
|||
return false;
|
||||
|
||||
// if there's an argument make sure its a positive integer
|
||||
if (args.size()==1 && (atoi(args[0].c_str())<1 || toString(atoi(args[0].c_str()))!=args[0]))
|
||||
return false;
|
||||
if (args.size()==1)
|
||||
{
|
||||
uint tick;
|
||||
NLMISC::fromString(args[0], tick);
|
||||
if ((tick < 1) || (toString(tick)!=args[0]))
|
||||
return false;
|
||||
|
||||
if (args.size()==0)
|
||||
cbTick();
|
||||
else
|
||||
ForceTicks=atoi(args[0].c_str());
|
||||
ForceTicks = tick;
|
||||
return true;
|
||||
}
|
||||
|
||||
cbTick();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2720,7 +2731,7 @@ NLMISC_COMMAND(botSetPosition,"set the position of one or several bots","<eid> [
|
|||
x = (float)atof(args[1].c_str());
|
||||
y = (float)atof(args[2].c_str());
|
||||
if (args.size()==4)
|
||||
z = (uint)atoi(args[3].c_str());
|
||||
NLMISC::fromString(args[3], z);
|
||||
}
|
||||
|
||||
// For each bot
|
||||
|
@ -3002,7 +3013,8 @@ NLMISC_COMMAND(simulateBug, "simulate an old AIS bug; command is one of 'list',
|
|||
}
|
||||
else
|
||||
{
|
||||
int i = atoi(args[1].c_str());
|
||||
sint i;
|
||||
NLMISC::fromString(args[1], i);
|
||||
if (i>=0 && i<bugSimulationCount)
|
||||
simulateBugs[i] = true;
|
||||
else
|
||||
|
@ -3023,7 +3035,8 @@ NLMISC_COMMAND(simulateBug, "simulate an old AIS bug; command is one of 'list',
|
|||
}
|
||||
else
|
||||
{
|
||||
int i = atoi(args[1].c_str());
|
||||
sint i;
|
||||
NLMISC::fromString(args[1], i);
|
||||
if (i>=0 && i<bugSimulationCount)
|
||||
simulateBugs[i] = false;
|
||||
else
|
||||
|
|
|
@ -78,7 +78,8 @@ public:
|
|||
{
|
||||
std::string weightStr, stateStr;
|
||||
AI_SHARE::stringToWordAndTail(args[i],weightStr, stateStr);
|
||||
sint16 weight=atoi(weightStr.c_str());
|
||||
sint16 weight;
|
||||
NLMISC::fromString(weightStr, weight);
|
||||
if ( weight<=0
|
||||
|| NLMISC::toString(weight)!=weightStr)
|
||||
{
|
||||
|
@ -2206,7 +2207,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
sint32 value = atoi(label.c_str());
|
||||
sint32 value;
|
||||
NLMISC::fromString(label, value);
|
||||
_Labels[i] = value ; // the other case eg "case 4:" -> _Label[?] = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ bool CNpcChatProfileImp::parseChatArgs(CAIInstance *aiInstance, const std::strin
|
|||
// parse optional item price
|
||||
if(AI_SHARE::stringToWordAndTail(tail, sTmp, tail))
|
||||
{
|
||||
price= atoi(sTmp.c_str());
|
||||
NLMISC::fromString(sTmp, price);
|
||||
}
|
||||
|
||||
// parse optional Faction type and point
|
||||
|
@ -564,13 +564,17 @@ bool CNpcChatProfileImp::parseChatArgs(CAIInstance *aiInstance, const std::strin
|
|||
// money is RRP
|
||||
priceInfo.setCurrency(RYMSG::TTradeCurrency::tc_rrps);
|
||||
priceInfo.setRRPLevel((R2::TSessionLevel::TValues)(money[3]-'0'));
|
||||
priceInfo.setAmount(atoi(param2.c_str()));
|
||||
sint32 amount;
|
||||
NLMISC::fromString(param2, amount);
|
||||
priceInfo.setAmount(amount);
|
||||
}
|
||||
else if (money == "dappers")
|
||||
{
|
||||
// money is dappers
|
||||
priceInfo.setCurrency(RYMSG::TTradeCurrency::tc_dappers);
|
||||
priceInfo.setAmount(atoi(param2.c_str()));
|
||||
sint32 amount;
|
||||
NLMISC::fromString(param2, amount);
|
||||
priceInfo.setAmount(amount);
|
||||
}
|
||||
else if (money == "item")
|
||||
{
|
||||
|
@ -596,7 +600,9 @@ bool CNpcChatProfileImp::parseChatArgs(CAIInstance *aiInstance, const std::strin
|
|||
// money is an item sheet
|
||||
priceInfo.setCurrency(RYMSG::TTradeCurrency::tc_faction_points);
|
||||
priceInfo.setFaction(PVP_CLAN::fromString(param2));
|
||||
priceInfo.setAmount(atoi(param3.c_str()));
|
||||
sint32 amount;
|
||||
NLMISC::fromString(param3, amount);
|
||||
priceInfo.setAmount(amount);
|
||||
if (priceInfo.getFaction() == PVP_CLAN::Unknown)
|
||||
return false;
|
||||
}
|
||||
|
@ -606,7 +612,9 @@ bool CNpcChatProfileImp::parseChatArgs(CAIInstance *aiInstance, const std::strin
|
|||
// money is an item sheet
|
||||
priceInfo.setCurrency(RYMSG::TTradeCurrency::tc_skill_points);
|
||||
priceInfo.setSkillType(EGSPD::CSPType::fromString(param2));
|
||||
priceInfo.setAmount(atoi(param3.c_str()));
|
||||
sint32 amount;
|
||||
NLMISC::fromString(param3, amount);
|
||||
priceInfo.setAmount(amount);
|
||||
if (priceInfo.getSkillType() == EGSPD::CSPType::Unknown)
|
||||
return false;
|
||||
}
|
||||
|
@ -644,7 +652,7 @@ bool CNpcChatProfileImp::parseChatArgs(CAIInstance *aiInstance, const std::strin
|
|||
// deal with 'phrase_race_filter' keywords
|
||||
if (NLMISC::nlstricmp(keyword, "phrase_race_filter") == 0 )
|
||||
{
|
||||
_FilterExplicitActionTradeByPlayerRace= atoi(tail.c_str())!=0;
|
||||
NLMISC::fromString(tail, _FilterExplicitActionTradeByPlayerRace);
|
||||
}
|
||||
|
||||
// deal with 'phrase_type' keywords
|
||||
|
@ -656,7 +664,7 @@ bool CNpcChatProfileImp::parseChatArgs(CAIInstance *aiInstance, const std::strin
|
|||
// deal with 'phrase_bot_race_filter' keywords
|
||||
if (NLMISC::nlstricmp(keyword, "phrase_bot_race_filter") == 0 )
|
||||
{
|
||||
_FilterExplicitActionTradeByBotRace = atoi(tail.c_str())!=0;
|
||||
NLMISC::fromString(tail, _FilterExplicitActionTradeByBotRace);
|
||||
}
|
||||
|
||||
// deal with '+mission' and '-mission' keywords
|
||||
|
|
|
@ -1915,7 +1915,9 @@ void CSubRuleTracer::generateCode(CSmartPtr<AIVM::CByteCode> &cByteCode) const
|
|||
case CScriptVM::JUMP:
|
||||
byteCode.push_back(op); // + Jump offset.
|
||||
|
||||
jumpTable.add(CJumpRememberer(atoi(param.c_str())));
|
||||
size_t index;
|
||||
NLMISC::fromString(param, index);
|
||||
jumpTable.add(CJumpRememberer(index));
|
||||
byteCode.push_back(0); // Invalid
|
||||
break;
|
||||
default:
|
||||
|
@ -1930,7 +1932,9 @@ void CSubRuleTracer::generateCode(CSmartPtr<AIVM::CByteCode> &cByteCode) const
|
|||
{
|
||||
if (str.find("Atof")!=string::npos)
|
||||
{
|
||||
const size_t index=atoi(param.c_str())-1;
|
||||
size_t index;
|
||||
NLMISC::fromString(param, index);
|
||||
--index;
|
||||
string &strRef=_childTracers[index]->_TextValue;
|
||||
const float f=(float)atof(strRef.c_str());
|
||||
byteCode.push_back(*((size_t*)&f));
|
||||
|
@ -1940,7 +1944,9 @@ void CSubRuleTracer::generateCode(CSmartPtr<AIVM::CByteCode> &cByteCode) const
|
|||
|
||||
if (str.find("String")!=string::npos)
|
||||
{
|
||||
const size_t index=atoi(param.c_str())-1;
|
||||
size_t index;
|
||||
NLMISC::fromString(param, index);
|
||||
--index;
|
||||
string &strRef=_childTracers[index]->_TextValue;
|
||||
TStringId strId;
|
||||
if ( strRef.at(0)=='"'
|
||||
|
@ -1997,7 +2003,9 @@ void CSubRuleTracer::generateCode(CSmartPtr<AIVM::CByteCode> &cByteCode) const
|
|||
|
||||
if (str.find("Code")!=string::npos)
|
||||
{
|
||||
const size_t index=atoi(param.c_str())-1;
|
||||
size_t index;
|
||||
NLMISC::fromString(param, index);
|
||||
--index;
|
||||
if (byteCode.size()==0)
|
||||
byteCode=codePieces[index]->_opcodes;
|
||||
else
|
||||
|
|
|
@ -44,7 +44,9 @@ NLMISC_COMMAND(setMgr,"set the active manager within a map","<name>|<slot>")
|
|||
if (args.size() !=1) return false;
|
||||
|
||||
// see if we have a number or a name
|
||||
uint slot=atoi(args[0].c_str());
|
||||
uint slot;
|
||||
NLMISC::fromString(args[0], slot);
|
||||
|
||||
if (toString(slot)!=args[0])
|
||||
CAIActions::exec("SET_MGR",slot);
|
||||
else
|
||||
|
@ -58,7 +60,9 @@ NLMISC_COMMAND(setGrp,"set the active group within a manager","<name>|<slot>")
|
|||
if (args.size() !=1) return false;
|
||||
|
||||
// see if we have a number or a name
|
||||
uint slot=atoi(args[0].c_str());
|
||||
uint slot;
|
||||
NLMISC::fromString(args[0], slot);
|
||||
|
||||
if (toString(slot)!=args[0])
|
||||
CAIActions::exec("SET_GRP",slot);
|
||||
else
|
||||
|
@ -82,7 +86,7 @@ NLMISC_COMMAND(newFaunaManager,"create the fauna manager for a region","<name> [
|
|||
case 2: // <name> <slot>
|
||||
{
|
||||
// the slot id is explicit so make sure its a number
|
||||
slot=atoi(args[1].c_str());
|
||||
NLMISC::fromString(args[1], slot);
|
||||
if (toString(slot)!=args[1])
|
||||
return false;
|
||||
break;
|
||||
|
@ -102,13 +106,14 @@ NLMISC_COMMAND(newPlaceXYR,"","<place name> <x> <y> <r> <verticalPos>")
|
|||
if(args.size() !=5)
|
||||
return false;
|
||||
|
||||
sint x=atoi(args[1].c_str());
|
||||
sint y=atoi(args[2].c_str());
|
||||
sint x, y;
|
||||
NLMISC::fromString(args[1], x);
|
||||
NLMISC::fromString(args[2], y);
|
||||
sint r=10; // default value.
|
||||
uint32 vp = AITYPES::vp_auto;
|
||||
if (!args[3].empty())
|
||||
{
|
||||
r=atoi(args[3].c_str());
|
||||
NLMISC::fromString(args[3], r);
|
||||
}
|
||||
vp = AITYPES::verticalPosFromString(args[4]);
|
||||
|
||||
|
@ -181,7 +186,8 @@ NLMISC_COMMAND(addHerbivorePopulation,"add a population version to the current g
|
|||
// check that every second argument is a number
|
||||
for (uint i=0;i<args.size();i+=2)
|
||||
{
|
||||
uint32 count=atoi(args[i+1].c_str());
|
||||
uint32 count;
|
||||
NLMISC::fromString(args[i+1], count);
|
||||
if (toString(count)!=args[i+1])
|
||||
return false;
|
||||
executeArgs.push_back(CAIActions::CArg(args[i]));
|
||||
|
@ -208,7 +214,7 @@ NLMISC_COMMAND(newUrbanManager,"create the urban npc manager for a sttlement","<
|
|||
case 2: // <name> <slot>
|
||||
{
|
||||
// the slot id is explicit so make sure its a number
|
||||
slot=atoi(args[1].c_str());
|
||||
NLMISC::fromString(args[1], slot);
|
||||
if (toString(slot)!=args[1])
|
||||
return false;
|
||||
break;
|
||||
|
|
|
@ -1382,7 +1382,8 @@ void CCreature::setBotDescription( const CGenNpcDescMsgImp& description )
|
|||
else
|
||||
{
|
||||
const string &factionName = result[1];
|
||||
const sint32 fameLevel = sint32( atoi(result[2].c_str()) );
|
||||
sint32 fameLevel;
|
||||
NLMISC::fromString(result[2], fameLevel);
|
||||
// get faction index
|
||||
const uint32 index = CStaticFames::getInstance().getFactionIndex(factionName);
|
||||
if (index == CStaticFames::INVALID_FACTION_INDEX)
|
||||
|
@ -1398,7 +1399,8 @@ void CCreature::setBotDescription( const CGenNpcDescMsgImp& description )
|
|||
else
|
||||
{
|
||||
const string &factionName = result[1];
|
||||
const sint32 fameLevel = sint32( atoi(result[2].c_str()) );
|
||||
sint32 fameLevel;
|
||||
NLMISC::fromString(result[2], fameLevel);
|
||||
// get faction index
|
||||
const uint32 index = CStaticFames::getInstance().getFactionIndex(factionName);
|
||||
if (index == CStaticFames::INVALID_FACTION_INDEX)
|
||||
|
@ -1435,20 +1437,25 @@ void CCreature::setBotDescription( const CGenNpcDescMsgImp& description )
|
|||
string res = NLMISC::strlwr(result[i]);
|
||||
_TicketFameRestriction = CStaticFames::getInstance().getFactionIndex(NLMISC::strlwr(result[i]));
|
||||
}
|
||||
else if( ( atoi(result[i].c_str()) * FameAbsoluteMax / 100 ) != 0 )
|
||||
else
|
||||
{
|
||||
_TicketFameRestrictionValue = atoi(result[i].c_str()) * FameAbsoluteMax / 100;
|
||||
if( _TicketFameRestriction == CStaticFames::INVALID_FACTION_INDEX )
|
||||
uint32 fame;
|
||||
NLMISC::fromString(result[i], fame);
|
||||
if( ( fame * FameAbsoluteMax / 100 ) != 0 )
|
||||
{
|
||||
if( _TicketClanRestriction != PVP_CLAN::None && _TicketFameRestriction == CStaticFames::INVALID_FACTION_INDEX )
|
||||
_TicketFameRestrictionValue = fame * FameAbsoluteMax / 100;
|
||||
if( _TicketFameRestriction == CStaticFames::INVALID_FACTION_INDEX )
|
||||
{
|
||||
_TicketFameRestriction = PVP_CLAN::getFactionIndex(_TicketClanRestriction);
|
||||
_TicketClanRestriction = PVP_CLAN::None;
|
||||
if( _TicketClanRestriction != PVP_CLAN::None && _TicketFameRestriction == CStaticFames::INVALID_FACTION_INDEX )
|
||||
{
|
||||
_TicketFameRestriction = PVP_CLAN::getFactionIndex(_TicketClanRestriction);
|
||||
_TicketClanRestriction = PVP_CLAN::None;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
nlwarning("parseBotOption -> invalid parameter '%s' for 'altar' command in bot %u", result[i].c_str(), _AIAlias );
|
||||
}
|
||||
else
|
||||
nlwarning("parseBotOption -> invalid parameter '%s' for 'altar' command in bot %u", result[i].c_str(), _AIAlias );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -126,7 +126,8 @@ void convertItemPartsNames( const string& name, const vector<string>& src, vecto
|
|||
string::size_type p = src[i].find_last_of( '_' );
|
||||
if ( p != string::npos )
|
||||
{
|
||||
uint itemPart = atoi( src[i].substr( p + 1 ).c_str() );
|
||||
uint itemPart;
|
||||
NLMISC::fromString(src[i].substr( p + 1 ), itemPart);
|
||||
if ( find( dest.begin(), dest.end(), itemPart ) == dest.end() )
|
||||
dest.push_back( itemPart );
|
||||
else
|
||||
|
@ -323,17 +324,19 @@ bool CDeposit::build( const NLLIGO::CPrimZone* zone )
|
|||
if ( ! zone->getPropertyByName( "deposit_statquality_max", maxEnergyS ) ) return malformed( "deposit_statquality_max", name );
|
||||
if ( ! zone->getPropertyByName( "deposit_min_quality_250", minQualityS ) ) return malformed( "deposit_min_quality_250", name );
|
||||
if ( ! zone->getPropertyByName( "deposit_max_quality_250", maxQualityS ) ) return malformed( "deposit_max_quality_250", name );
|
||||
_MinQuality = atoi( minQualityS.c_str() );
|
||||
_MaxQuality = atoi( maxQualityS.c_str() );
|
||||
NLMISC::fromString(minQualityS, _MinQuality);
|
||||
NLMISC::fromString(maxQualityS, _MaxQuality);
|
||||
|
||||
// Read quantity constraints
|
||||
string qttyLimitS, qttyRespawnTimeS;
|
||||
if ( ! zone->getPropertyByName( "deposit_quantity_limit", qttyLimitS ) ) return malformed( "deposit_quantity_limit", name );
|
||||
if ( ! zone->getPropertyByName( "deposit_quantity_respawn_time_ryzomdays", qttyRespawnTimeS ) ) return malformed( "deposit_quantity_respawn_time_ryzomdays", name );
|
||||
sint qttyLimit = atoi( qttyLimitS.c_str() );
|
||||
sint qttyLimit;
|
||||
NLMISC::fromString(qttyLimitS, qttyLimit);
|
||||
if ( qttyLimit > -1 )
|
||||
{
|
||||
sint qttyRespawnTime = atoi( qttyRespawnTimeS.c_str() );
|
||||
sint qttyRespawnTime;
|
||||
NLMISC::fromString(qttyRespawnTimeS, qttyRespawnTime);
|
||||
if ( (qttyLimit == 0) || (qttyLimit > 0xFFFF) || (qttyRespawnTime < 1) || (qttyRespawnTime > 0xFFFF) )
|
||||
nlwarning( "Invalid limit or respawn time too high in %s", name.c_str() );
|
||||
else
|
||||
|
@ -416,10 +419,13 @@ bool CDeposit::build( const NLLIGO::CPrimZone* zone )
|
|||
if ( ! zone->getPropertyByName( "auto_spawn_extraction_time_s", asetS ) ) return malformed( "auto_spawn_sources", name );
|
||||
if ( ! zone->getPropertyByName( "auto_spawn_min_source", amin ) ) return malformed( "auto_spawn_min_source", name );
|
||||
_AutoSpawnSourcePt = new CAutoSpawnProperties;
|
||||
_AutoSpawnSourcePt->SpawnPeriodGc = atoi( aspS.c_str() ) * 10;
|
||||
_AutoSpawnSourcePt->LifeTimeGc = atoi( asltS.c_str() ) * 10;
|
||||
_AutoSpawnSourcePt->ExtractionTimeGc = atoi( asetS.c_str() ) * 10;
|
||||
_AutoSpawnSourcePt->MinimumSpawnedSources = atoi( amin.c_str() );
|
||||
NLMISC::fromString(aspS, _AutoSpawnSourcePt->SpawnPeriodGc);
|
||||
_AutoSpawnSourcePt->SpawnPeriodGc *= 10;
|
||||
NLMISC::fromString(asltS, _AutoSpawnSourcePt->LifeTimeGc);
|
||||
_AutoSpawnSourcePt->LifeTimeGc *= 10;
|
||||
NLMISC::fromString(asetS, _AutoSpawnSourcePt->ExtractionTimeGc);
|
||||
_AutoSpawnSourcePt->ExtractionTimeGc *= 10;
|
||||
NLMISC::fromString(amin, _AutoSpawnSourcePt->MinimumSpawnedSources);
|
||||
// security!
|
||||
_AutoSpawnSourcePt->MinimumSpawnedSources = min(uint32(100), _AutoSpawnSourcePt->MinimumSpawnedSources);
|
||||
}
|
||||
|
@ -431,7 +437,7 @@ bool CDeposit::build( const NLLIGO::CPrimZone* zone )
|
|||
// Read source FX index
|
||||
string srcFXIndexS;
|
||||
if ( ! zone->getPropertyByName( "source_fx", srcFXIndexS ) ) return malformed( "source_fx", name );
|
||||
_SourceFXIndex = (uint16)atoi( srcFXIndexS.c_str() );
|
||||
NLMISC::fromString(srcFXIndexS, _SourceFXIndex);
|
||||
|
||||
// Read other initial properties
|
||||
string cpS, eS, ikaS, adpR;
|
||||
|
@ -447,8 +453,9 @@ bool CDeposit::build( const NLLIGO::CPrimZone* zone )
|
|||
nlwarning( "Invalid initial_kami_anger %.1f in %s", _KamiAnger, name.c_str() );
|
||||
|
||||
// Apply filters
|
||||
uint32 minEnergy = atoi( minEnergyS.c_str() );
|
||||
uint32 maxEnergy = atoi( maxEnergyS.c_str() );
|
||||
uint32 minEnergy, maxEnergy;
|
||||
NLMISC::fromString(minEnergyS, minEnergy);
|
||||
NLMISC::fromString(maxEnergyS, maxEnergy);
|
||||
if ( exactRMCodesS->empty() && rmFamilyFilterS->empty() && itemPartsFilterS->empty() )
|
||||
{
|
||||
nlwarning( "FG: Deposit %s: No RM, exactRms or item parts specified!", name.c_str() );
|
||||
|
@ -1558,7 +1565,7 @@ NLMISC_COMMAND( forageDisplayKamiAngerLevels, "Display the N deposits with the h
|
|||
{
|
||||
uint nb = 10;
|
||||
if ( args.size() > 0 )
|
||||
nb = atoi( args[0].c_str() );
|
||||
NLMISC::fromString(args[0], nb);
|
||||
|
||||
std::vector<CDeposit*> newDepositList = CZoneManager::getInstance().getDeposits();
|
||||
std::sort( newDepositList.begin(), newDepositList.end(), TCompareDepositsByHighestKamiAnger() );
|
||||
|
|
Loading…
Reference in a new issue