Changed: Replace more ~0 by std::numeric_limits<*>::max()

--HG--
branch : develop
This commit is contained in:
kervala 2015-12-17 13:03:21 +01:00
parent ad93a9005f
commit d187138099
2 changed files with 23 additions and 23 deletions

View file

@ -847,10 +847,10 @@ bool CGrpFauna::spawnPop(uint popVersion)
return false;
}
popVersion = ~0;
popVersion = std::numeric_limits<uint>::max();
// if we are in a cycle.
if (_CurrentCycle!=~0)
if (_CurrentCycle != std::numeric_limits<uint32>::max())
{
Cycle const& cycle = _Cycles[_CurrentCycle];
@ -868,18 +868,18 @@ bool CGrpFauna::spawnPop(uint popVersion)
if (!timeAllowSpawn(popVersion))
{
popVersion=~0;
popVersion = std::numeric_limits<uint>::max();
}
}
if (popVersion==~0)
if (popVersion == std::numeric_limits<uint>::max())
{
_CurrentCycle = ~0;
_CurrentCycle = std::numeric_limits<uint32>::max();
}
}
// if the population version has not been specified then select one at weighted random with day/night difference.
if (popVersion==~0)
if (popVersion == std::numeric_limits<uint>::max())
{
uint32 totalWeight = 0;
@ -913,9 +913,9 @@ bool CGrpFauna::spawnPop(uint popVersion)
}
#if !FINAL_VERSION
nlassert(popVersion!=~0);
nlassert(popVersion != std::numeric_limits<uint>::max());
#endif
if (popVersion==~0)
if (popVersion == std::numeric_limits<uint>::max())
return false;
// find if we are starting a new cycle ..
@ -952,7 +952,7 @@ bool CGrpFauna::spawnPop(uint popVersion)
despawnGrp();
}
nlassert(_CurPopulation!=~0);
nlassert(_CurPopulation != std::numeric_limits<uint32>::max());
//////////////////////////////////////////////////////////////////////////
// Init the group type.
@ -990,14 +990,14 @@ bool CGrpFauna::spawnPop(uint popVersion)
void CGrpFauna::despawnGrp()
{
CGroup::despawnGrp();
_CurPopulation = ~0u;
_CurPopulation = std::numeric_limits<uint32>::max();
}
// reads cycle from primitive (string representation).
void CGrpFauna::setCyles(std::string const& cycles)
{
uint32 strIndex = 0;
uint32 curCycle = ~0;
uint32 curCycle = std::numeric_limits<uint32>::max();
while (strIndex<cycles.size())
{
@ -1008,7 +1008,7 @@ void CGrpFauna::setCyles(std::string const& cycles)
if (carac>='a' && carac<='z')
{
if (curCycle==~0)
if (curCycle == std::numeric_limits<uint32>::max())
{
curCycle = (uint32)_Cycles.size();
_Cycles.push_back(Cycle());
@ -1018,7 +1018,7 @@ void CGrpFauna::setCyles(std::string const& cycles)
}
else
{
curCycle = ~0;
curCycle = std::numeric_limits<uint32>::max();
}
}
}
@ -1026,7 +1026,7 @@ void CGrpFauna::setCyles(std::string const& cycles)
void CGrpFauna::setPopulation(CPopulation* pop)
{
CPopulation* sameAliasPop = NULL;
uint32 index = ~0;
uint32 index = std::numeric_limits<uint32>::max();
if (pop)
sameAliasPop = _Populations.getChildByAlias(pop->getAlias());

View file

@ -412,7 +412,7 @@ CAIEntity* CAIInstance::tryToGetEntity(char const* str, CAIS::TSearchType search
CManager *mgrPtr=NULL;
CGroup *grpPtr=NULL;
CBot *botPtr=NULL;
uint32 localIndex=~0;
uint32 localIndex = std::numeric_limits<uint32>::max();
mgr = id;
while((*id!=':')&&(*id!=0)) id++;
@ -635,7 +635,7 @@ static CAIVector randomPos(double dispersionRadius)
{
return CAIVector(0., 0.);
}
uint32 const maxLimit=((uint32)~0U)>>1;
const uint32 maxLimit = std::numeric_limits<uint32>::max() >>1;
double rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[
double r = dispersionRadius*sqrt(rval);
rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[