From 7af56ceb409917bff505a2ae99381a02107dc9d2 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 17 Dec 2015 14:35:48 +0100 Subject: [PATCH] Changed: Replace more ~0 by std::numeric_limits<*>::max() some changes from private repository --- .../server/src/ai_service/ai_entity_id_inline.h | 6 +++--- .../ryzom/server/src/ai_service/ai_grp_fauna.cpp | 2 +- code/ryzom/server/src/ai_service/ai_grp_fauna.h | 4 ++-- code/ryzom/server/src/ai_service/ai_outpost.cpp | 4 ++-- code/ryzom/server/src/ai_service/ai_place.cpp | 2 +- code/ryzom/server/src/ai_service/ai_spire.cpp | 4 ++-- code/ryzom/server/src/ai_service/ai_world_map.h | 2 +- code/ryzom/server/src/ai_service/commands.cpp | 4 ++-- .../src/ai_service/generic_logic_action.cpp | 4 ++-- code/ryzom/server/src/ai_service/mirrors.cpp | 2 +- code/ryzom/server/src/ai_service/nf_grp_npc.cpp | 6 +++--- code/ryzom/server/src/ai_service/nf_static.cpp | 2 +- code/ryzom/server/src/ai_service/sheets.cpp | 16 ++++++++-------- .../ryzom/server/src/ai_service/state_instance.h | 4 ++-- 14 files changed, 31 insertions(+), 31 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_entity_id_inline.h b/code/ryzom/server/src/ai_service/ai_entity_id_inline.h index b5f633f64..3cd6b43ba 100644 --- a/code/ryzom/server/src/ai_service/ai_entity_id_inline.h +++ b/code/ryzom/server/src/ai_service/ai_entity_id_inline.h @@ -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::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<::max()<=mask && id!=~0u) return false; // Test for bit count overflow + if (id>=mask && id!=std::numeric_limits::max()) return false; // Test for bit count overflow //if (id==~0u) id=mask; id&=mask; // Special case ~0u mask<<=BOT_BITS+GRP_BITS; 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 c9a493763..5738af614 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp +++ b/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp @@ -608,7 +608,7 @@ CGrpFauna::CGrpFauna(CMgrFauna* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MA _CurPopulation = std::numeric_limits::max(); - _CurrentCycle = std::numeric_limits::max(); + _CurrentCycle = std::numeric_limits::max(); // default values. setTimer(EAT_TIME, refTimer(EAT_TIME)); diff --git a/code/ryzom/server/src/ai_service/ai_grp_fauna.h b/code/ryzom/server/src/ai_service/ai_grp_fauna.h index b3aa49b74..e6363aa5d 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_fauna.h +++ b/code/ryzom/server/src/ai_service/ai_grp_fauna.h @@ -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::max(); } /// @name CChild implementation //@{ @@ -335,7 +335,7 @@ protected: double _MotivationHarvestSap; // Motivation for the sap harvest. std::vector _Cycles; // Cycles List. - sint32 _CurrentCycle; // current Cycle. + uint32 _CurrentCycle; // current Cycle. sint32 _CurrentCycleIndex; // the pop index in the cycle AITYPES::CPropertySet _Faction; diff --git a/code/ryzom/server/src/ai_service/ai_outpost.cpp b/code/ryzom/server/src/ai_service/ai_outpost.cpp index 10bfa1162..bdbfd537b 100644 --- a/code/ryzom/server/src/ai_service/ai_outpost.cpp +++ b/code/ryzom/server/src/ai_service/ai_outpost.cpp @@ -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::max(); for (uint i=0; i::max(); fromString(args[0], instanceNumber); string continentName = args[1]; string outpostName = args[2]; diff --git a/code/ryzom/server/src/ai_service/ai_place.cpp b/code/ryzom/server/src/ai_service/ai_place.cpp index 660e4a284..e000fc4d5 100644 --- a/code/ryzom/server/src/ai_service/ai_place.cpp +++ b/code/ryzom/server/src/ai_service/ai_place.cpp @@ -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::max(); // depending on place name setup eat/ rest/ sleep pointers if (NLMISC::nlstricmp(name,"spawn")==0) { diff --git a/code/ryzom/server/src/ai_service/ai_spire.cpp b/code/ryzom/server/src/ai_service/ai_spire.cpp index 26d4f435d..5e2c2c05d 100644 --- a/code/ryzom/server/src/ai_service/ai_spire.cpp +++ b/code/ryzom/server/src/ai_service/ai_spire.cpp @@ -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::max(); for (uint i=0; i if (args.size() != 6) return false; - uint32 instanceNumber = ~0; + uint32 instanceNumber = std::numeric_limits::max(); fromString(args[0], instanceNumber); string continentName = args[1]; string spireName = args[2]; diff --git a/code/ryzom/server/src/ai_service/ai_world_map.h b/code/ryzom/server/src/ai_service/ai_world_map.h index 724bd842f..097e20426 100644 --- a/code/ryzom/server/src/ai_service/ai_world_map.h +++ b/code/ryzom/server/src/ai_service/ai_world_map.h @@ -240,7 +240,7 @@ inline CAIMapSurfaceNeighbour::CAIMapSurfaceNeighbour(bool isNoGo) // constructo inline CAIMapSurface::CAIMapSurface(): _entityList(NULL) { - _regionId=~0; + _regionId=std::numeric_limits::max(); _cell=NULL; _h=0; } diff --git a/code/ryzom/server/src/ai_service/commands.cpp b/code/ryzom/server/src/ai_service/commands.cpp index 641503b70..52315372a 100644 --- a/code/ryzom/server/src/ai_service/commands.cpp +++ b/code/ryzom/server/src/ai_service/commands.cpp @@ -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::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())); } diff --git a/code/ryzom/server/src/ai_service/generic_logic_action.cpp b/code/ryzom/server/src/ai_service/generic_logic_action.cpp index e2c761619..0b0e254b7 100644 --- a/code/ryzom/server/src/ai_service/generic_logic_action.cpp +++ b/code/ryzom/server/src/ai_service/generic_logic_action.cpp @@ -1722,7 +1722,7 @@ public: const CAIAliasDescriptionNode *eventNode, CStateMachine *container) { - uint32 emot = ~0; + uint32 emot = std::numeric_limits::max(); if (!subActions.empty()) { @@ -1736,7 +1736,7 @@ public: emot = CAIS::instance().getEmotNumber(args[0]); - if (emot == ~0) + if (emot == std::numeric_limits::max()) { nlwarning("emot (%s) unknow emot name : '%s' !", eventNode->fullName().c_str(), args[0].c_str()); _EmotNumber = MBEHAV::NUMBER_OF_BEHAVIOURS; diff --git a/code/ryzom/server/src/ai_service/mirrors.cpp b/code/ryzom/server/src/ai_service/mirrors.cpp index 7b4ce58c0..e567a1e48 100644 --- a/code/ryzom/server/src/ai_service/mirrors.cpp +++ b/code/ryzom/server/src/ai_service/mirrors.cpp @@ -289,7 +289,7 @@ void CMirrors::processMirrorUpdates() } else { - if (askedInstance!=~0) + if (askedInstance!=std::numeric_limits::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()); diff --git a/code/ryzom/server/src/ai_service/nf_grp_npc.cpp b/code/ryzom/server/src/ai_service/nf_grp_npc.cpp index 25fd7e4e0..c16190bde 100644 --- a/code/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/code/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -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::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::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::max()) return; // Get the behaviour Id diff --git a/code/ryzom/server/src/ai_service/nf_static.cpp b/code/ryzom/server/src/ai_service/nf_static.cpp index cbdebfba4..3470a2c70 100644 --- a/code/ryzom/server/src/ai_service/nf_static.cpp +++ b/code/ryzom/server/src/ai_service/nf_static.cpp @@ -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::max()>>1; double const rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[ float const value = (float)(rval * (max-min) + min); diff --git a/code/ryzom/server/src/ai_service/sheets.cpp b/code/ryzom/server/src/ai_service/sheets.cpp index 8369023e0..e15ca327f 100644 --- a/code/ryzom/server/src/ai_service/sheets.cpp +++ b/code/ryzom/server/src/ai_service/sheets.cpp @@ -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::max()) return; std::vector 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::max()) return; std::vector 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::max()); #endif - if (_GroupPropertiesTbl.size()<=groupIndex && groupIndex!=~0) + if (_GroupPropertiesTbl.size()<=groupIndex && groupIndex!=std::numeric_limits::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& groupIndexStrList, st str = groupIndexStr.substr(firstIndex, lastIndex-firstIndex); uint32 const otherGroupIndex = CSheets::getInstance()->getGroupPropertiesIndex(str); - if (otherGroupIndex!=~0) + if (otherGroupIndex!=std::numeric_limits::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::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::max(); NLMISC::strupr(groupIndexName); std::map::iterator it = _NameToGroupIndex.find(groupIndexName); diff --git a/code/ryzom/server/src/ai_service/state_instance.h b/code/ryzom/server/src/ai_service/state_instance.h index 3ad6e6d55..802172825 100644 --- a/code/ryzom/server/src/ai_service/state_instance.h +++ b/code/ryzom/server/src/ai_service/state_instance.h @@ -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::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::max()", state->getAliasNode()->fullName().c_str(), state->getAliasString().c_str()); state = NULL;