Changed: Replace more ~0 by std::numeric_limits<*>::max() some changes from private repository

This commit is contained in:
kervala 2015-12-17 14:35:48 +01:00
parent 3f561ac3f8
commit 7af56ceb40
14 changed files with 31 additions and 31 deletions

View file

@ -39,7 +39,7 @@
fauna: <10 bit manager id> <12 bit group id><8 bit bot id>
others: <10 bit manager id> ... the remaining 20 bits TBD ...
for ais as a rule ~0 is used as a reserved value
for ais as a rule std::numeric_limits<uint>::max() is used as a reserved value
managers are: 01 <10 bit manager id> 1111 1111 1111 1111 1111
fauna groups are: 01 <10 bit manager id> <12 bit grp id> 1111 1111
*/
@ -57,7 +57,7 @@
#define PLR_ID_BITS ( 32 - PLR_HDR_BITS )
#define PLR_ID_BIT_MASK ( ( 1<< PLR_ID_BITS ) -1 )
#define PLR_HDR_BIT_SHIFT PLR_ID_BITS
#define PLR_HDR_BIT_MASK (~0u<<PLR_HDR_BIT_SHIFT)
#define PLR_HDR_BIT_MASK (std::numeric_limits<uint>::max()<<PLR_HDR_BIT_SHIFT)
#define PLR_HDR 0x20000000 //(1<<PLR_HDR_BIT_SHIFT)
#define BOT_BITS 4 //8
@ -378,7 +378,7 @@ inline bool CAIEntityId::setGrpId(uint32 id)
inline bool CAIEntityId::setMgrId(uint32 id)
{
uint32 mask=((1<<MGR_BITS)-1);
if (id>=mask && id!=~0u) return false; // Test for bit count overflow
if (id>=mask && id!=std::numeric_limits<uint>::max()) return false; // Test for bit count overflow
//if (id==~0u) id=mask;
id&=mask; // Special case ~0u
mask<<=BOT_BITS+GRP_BITS;

View file

@ -608,7 +608,7 @@ CGrpFauna::CGrpFauna(CMgrFauna* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MA
_CurPopulation = std::numeric_limits<uint32>::max();
_CurrentCycle = std::numeric_limits<sint32>::max();
_CurrentCycle = std::numeric_limits<uint32>::max();
// default values.
setTimer(EAT_TIME, refTimer(EAT_TIME));

View file

@ -289,7 +289,7 @@ public:
static const CCycleDef cycles[];
static const uint32 nbCycle;
void setAutoSpawn(bool autoSpawn) { CGroup::setAutoSpawn(autoSpawn); if (!isAutoSpawn()) _CurrentCycle=-1; }
void setAutoSpawn(bool autoSpawn) { CGroup::setAutoSpawn(autoSpawn); if (!isAutoSpawn()) _CurrentCycle=std::numeric_limits<uint32>::max(); }
/// @name CChild implementation
//@{
@ -335,7 +335,7 @@ protected:
double _MotivationHarvestSap; // Motivation for the sap harvest.
std::vector<Cycle> _Cycles; // Cycles List.
sint32 _CurrentCycle; // current Cycle.
uint32 _CurrentCycle; // current Cycle.
sint32 _CurrentCycleIndex; // the pop index in the cycle
AITYPES::CPropertySet _Faction;

View file

@ -1149,7 +1149,7 @@ NLMISC_COMMAND(displayOutposts, "list the available outpost", "")
if (args.size() > 0)
return false;
uint32 instanceNumber = ~0;
uint32 instanceNumber = std::numeric_limits<uint32>::max();
for (uint i=0; i<CAIS::instance().AIList().size(); ++i)
{
CAIInstance *const aii = CAIS::instance().AIList()[i];
@ -1251,7 +1251,7 @@ NLMISC_COMMAND(outpostSpawnSquad, "Spawns a squad in an outpost", "<instance_num
if (args.size() != 6)
return false;
uint32 instanceNumber = ~0;
uint32 instanceNumber = std::numeric_limits<uint32>::max();
fromString(args[0], instanceNumber);
string continentName = args[1];
string outpostName = args[2];

View file

@ -77,7 +77,7 @@ void CAIPlaceFastXYR::display(CStringWriter& stringWriter) const
uint CFaunaGenericPlace::setupFromOldName(const std::string &name)
{
uint32 stayTime;
uint placeIndex = ~0;
uint placeIndex = std::numeric_limits<uint>::max();
// depending on place name setup eat/ rest/ sleep pointers
if (NLMISC::nlstricmp(name,"spawn")==0)
{

View file

@ -1308,7 +1308,7 @@ NLMISC_COMMAND(displaySpires, "list the available spire", "")
if (args.size() > 0)
return false;
uint32 instanceNumber = ~0;
uint32 instanceNumber = std::numeric_limits<uint32>::max();
for (uint i=0; i<CAIS::instance().AIList().size(); ++i)
{
CAIInstance *const aii = CAIS::instance().AIList()[i];
@ -1410,7 +1410,7 @@ NLMISC_COMMAND(spireSpawnSquad, "Spawns a squad in an spire", "<instance_number>
if (args.size() != 6)
return false;
uint32 instanceNumber = ~0;
uint32 instanceNumber = std::numeric_limits<uint32>::max();
fromString(args[0], instanceNumber);
string continentName = args[1];
string spireName = args[2];

View file

@ -240,7 +240,7 @@ inline CAIMapSurfaceNeighbour::CAIMapSurfaceNeighbour(bool isNoGo) // constructo
inline CAIMapSurface::CAIMapSurface(): _entityList(NULL)
{
_regionId=~0;
_regionId=std::numeric_limits<uint>::max();
_cell=NULL;
_h=0;
}

View file

@ -578,10 +578,10 @@ NLMISC_COMMAND(createStaticAIInstance, "Create a new static AIInstance for a giv
CUsedContinent &uc = CUsedContinent::instance();
const uint32 in = uc.getInstanceForContinent(args[0]);
if (in == INVALID_AI_INSTANCE)
if (in == std::numeric_limits<uint32>::max())
{
nlwarning("The continent '%s' is unknow or not active. Can't create instance, FATAL", args[0].c_str());
nlassert(in != INVALID_AI_INSTANCE);
nlassert(in != ~0);
// nlassertex(in != ~0, ("The continent '%s' is unknow or not active. Can't create instance, FATAL", args[0].c_str()));
}

View file

@ -1722,7 +1722,7 @@ public:
const CAIAliasDescriptionNode *eventNode,
CStateMachine *container)
{
uint32 emot = ~0;
uint32 emot = std::numeric_limits<uint32>::max();
if (!subActions.empty())
{
@ -1736,7 +1736,7 @@ public:
emot = CAIS::instance().getEmotNumber(args[0]);
if (emot == ~0)
if (emot == std::numeric_limits<uint32>::max())
{
nlwarning("emot (%s) unknow emot name : '%s' !", eventNode->fullName().c_str(), args[0].c_str());
_EmotNumber = MBEHAV::NUMBER_OF_BEHAVIOURS;

View file

@ -289,7 +289,7 @@ void CMirrors::processMirrorUpdates()
}
else
{
if (askedInstance!=~0)
if (askedInstance!=std::numeric_limits<uint32>::max())
{
// no need to warn for ai number instance not in this AIS !
// nlwarning("AIInstance %u not found on AIInstance changement for player %s", askedInstance, entityId.toString().c_str());

View file

@ -2482,7 +2482,7 @@ void emote_css_(CStateInstance* entity, CScriptStack& stack)
// Is the emote valid
uint32 emoteId = CAIS::instance().getEmotNumber(emoteName);
if (emoteId == ~0)
if (emoteId == std::numeric_limits<uint32>::max())
{
return;
}
@ -2513,7 +2513,7 @@ void emote_ss_(CStateInstance* entity, CScriptStack& stack)
// Is the emote valid
uint32 emoteId = CAIS::instance().getEmotNumber(emoteName);
if (emoteId == ~0)
if (emoteId == std::numeric_limits<uint32>::max())
{
return;
}
@ -2539,7 +2539,7 @@ void emote_s_(CStateInstance* entity, CScriptStack& stack)
// Is the emote valid
uint32 emoteId = CAIS::instance().getEmotNumber(emoteName);
if (emoteId == ~0)
if (emoteId == std::numeric_limits<uint32>::max())
return;
// Get the behaviour Id

View file

@ -241,7 +241,7 @@ void rndm_ff_f(CStateInstance* entity, CScriptStack& stack)
float min = stack.top();
// Min value
static uint32 const maxLimit = ((uint32)~0U)>>1;
static uint32 const maxLimit = std::numeric_limits<uint32>::max()>>1;
double const rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[
float const value = (float)(rval * (max-min) + min);

View file

@ -303,7 +303,7 @@ bool AISHEETS::CCreature::mustAssist(CCreature const& creature) const
void AISHEETS::CCreature::setAssisGroupIndexs()
{
_GroupPropertiesIndex = CSheets::getInstance()->getGroupPropertiesIndex(GroupIndexStr());
if (_GroupPropertiesIndex==~0)
if (_GroupPropertiesIndex==std::numeric_limits<uint32>::max())
return;
std::vector<uint32> groupList;
@ -316,7 +316,7 @@ void AISHEETS::CCreature::setAssisGroupIndexs()
void AISHEETS::CCreature::setAttackGroupIndexs()
{
_GroupPropertiesIndex = CSheets::getInstance()->getGroupPropertiesIndex(GroupIndexStr());
if (_GroupPropertiesIndex==~0)
if (_GroupPropertiesIndex==std::numeric_limits<uint32>::max())
return;
std::vector<uint32> groupList;
@ -356,9 +356,9 @@ bool AISHEETS::CCreature::addActionConfig(NLMISC::CSheetId const& sheetId, NLMIS
AISHEETS::CGroupProperties& AISHEETS::CCreature::getProperties(uint32 groupIndex)
{
#if !FINAL_VERSION
nlassert(groupIndex!=~0);
nlassert(groupIndex!=std::numeric_limits<uint32>::max());
#endif
if (_GroupPropertiesTbl.size()<=groupIndex && groupIndex!=~0)
if (_GroupPropertiesTbl.size()<=groupIndex && groupIndex!=std::numeric_limits<uint32>::max())
{
uint32 const resizeSize = std::max((uint32)CSheets::getInstance()->_NameToGroupIndex.size(), (uint32)(groupIndex+1));
_GroupPropertiesTbl.resize(resizeSize);
@ -812,7 +812,7 @@ void AISHEETS::CCreature::getGroupStr(std::vector<uint32>& groupIndexStrList, st
str = groupIndexStr.substr(firstIndex, lastIndex-firstIndex);
uint32 const otherGroupIndex = CSheets::getInstance()->getGroupPropertiesIndex(str);
if (otherGroupIndex!=~0)
if (otherGroupIndex!=std::numeric_limits<uint32>::max())
groupIndexStrList.push_back(otherGroupIndex);
} while (lastIndex!=std::string::npos);
}
@ -881,7 +881,7 @@ void AISHEETS::CSheets::init()
_PlayerGroupIndex=getGroupPropertiesIndex("zp");
#if !FINAL_VERSION
nlassert(_PlayerGroupIndex!=~0);
nlassert(_PlayerGroupIndex!=std::numeric_limits<uint32>::max());
#endif
packSheets(IService::getInstance()->WriteFilesDirectory.toString());
@ -966,10 +966,10 @@ void AISHEETS::CSheets::release()
_RaceStatsSheets.clear();
}
uint32 AISHEETS::CSheets::getGroupPropertiesIndex(std::string groupIndexName)
uint32 AISHEETS::CSheets::getGroupPropertiesIndex(const std::string &groupIndexName)
{
if (groupIndexName.empty())
return ~0;
return std::numeric_limits<uint32>::max();
NLMISC::strupr(groupIndexName);
std::map<string, uint32>::iterator it = _NameToGroupIndex.find(groupIndexName);

View file

@ -544,7 +544,7 @@ void CStateInstance::setNextState(CAIState* state)
// make sure the state is positional (not punctual)
if (!state->isPositional())
{
nlwarning("setNextState(): State should not be punctual '%s'%s - setting state to ~0",
nlwarning("setNextState(): State should not be punctual '%s'%s - setting state to std::numeric_limits<uint32>::max()",
state->getAliasNode()->fullName().c_str(),
state->getAliasString().c_str());
_NextState = NULL;
@ -565,7 +565,7 @@ void CStateInstance::setNextPunctualState(CAIState* state)
// make sure the state is not positional (ie punctual)
if (state->isPositional())
{
nlwarning("CStateInstance::setNextPunctualState(): State should be punctual '%s'%s - setting state to ~0",
nlwarning("CStateInstance::setNextPunctualState(): State should be punctual '%s'%s - setting state to std::numeric_limits<uint32>::max()",
state->getAliasNode()->fullName().c_str(),
state->getAliasString().c_str());
state = NULL;