From d1871380990d6f47061f4382ab0329baaabcccd1 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 17 Dec 2015 13:03:21 +0100 Subject: [PATCH] Changed: Replace more ~0 by std::numeric_limits<*>::max() --HG-- branch : develop --- .../server/src/ai_service/ai_grp_fauna.cpp | 42 +++++++++---------- .../server/src/ai_service/ai_instance.cpp | 4 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp b/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp index e3389b6d1..c9a493763 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp +++ b/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp @@ -846,11 +846,11 @@ bool CGrpFauna::spawnPop(uint popVersion) nlwarning("CGrpFauna::spawn(idx) FAILED for group %s because idx (%d) >= _Populations.size() (%d)",this->CGroup::getFullName().c_str(),popVersion,_Populations.size()); return false; } - - popVersion = ~0; - + + popVersion = std::numeric_limits::max(); + // if we are in a cycle. - if (_CurrentCycle!=~0) + if (_CurrentCycle != std::numeric_limits::max()) { Cycle const& cycle = _Cycles[_CurrentCycle]; @@ -868,18 +868,18 @@ bool CGrpFauna::spawnPop(uint popVersion) if (!timeAllowSpawn(popVersion)) { - popVersion=~0; + popVersion = std::numeric_limits::max(); } } - - if (popVersion==~0) + + if (popVersion == std::numeric_limits::max()) { - _CurrentCycle = ~0; + _CurrentCycle = std::numeric_limits::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::max()) { uint32 totalWeight = 0; @@ -913,9 +913,9 @@ bool CGrpFauna::spawnPop(uint popVersion) } #if !FINAL_VERSION - nlassert(popVersion!=~0); + nlassert(popVersion != std::numeric_limits::max()); #endif - if (popVersion==~0) + if (popVersion == std::numeric_limits::max()) return false; // find if we are starting a new cycle .. @@ -951,9 +951,9 @@ bool CGrpFauna::spawnPop(uint popVersion) { despawnGrp(); } - - nlassert(_CurPopulation!=~0); - + + nlassert(_CurPopulation != std::numeric_limits::max()); + ////////////////////////////////////////////////////////////////////////// // Init the group type. setType ((*_Populations[_CurPopulation])[0].getCreatureSheet()->FaunaType()); // gets the first population record of the population to spawn. @@ -990,15 +990,15 @@ bool CGrpFauna::spawnPop(uint popVersion) void CGrpFauna::despawnGrp() { CGroup::despawnGrp(); - _CurPopulation = ~0u; + _CurPopulation = std::numeric_limits::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::max(); + while (strIndex='a' && carac<='z') { - if (curCycle==~0) + if (curCycle == std::numeric_limits::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::max(); } } } @@ -1026,8 +1026,8 @@ void CGrpFauna::setCyles(std::string const& cycles) void CGrpFauna::setPopulation(CPopulation* pop) { CPopulation* sameAliasPop = NULL; - uint32 index = ~0; - + uint32 index = std::numeric_limits::max(); + if (pop) sameAliasPop = _Populations.getChildByAlias(pop->getAlias()); diff --git a/code/ryzom/server/src/ai_service/ai_instance.cpp b/code/ryzom/server/src/ai_service/ai_instance.cpp index ae8465e32..d97c0b0fa 100644 --- a/code/ryzom/server/src/ai_service/ai_instance.cpp +++ b/code/ryzom/server/src/ai_service/ai_instance.cpp @@ -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::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::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[