diff --git a/code/ryzom/server/src/ai_service/ai.cpp b/code/ryzom/server/src/ai_service/ai.cpp index 587e5ac0c..49144fa9d 100644 --- a/code/ryzom/server/src/ai_service/ai.cpp +++ b/code/ryzom/server/src/ai_service/ai.cpp @@ -224,7 +224,7 @@ uint32 CAIS::getEmotNumber(const std::string &name) { std::map::iterator it(_EmotNames.find(name)); if (it==_EmotNames.end()) - return ~0; + return std::numeric_limits::max(); return it->second; } @@ -280,7 +280,7 @@ uint32 CAIS::createAIInstance(const std::string &continentName, uint32 instanceN continue; nlwarning("CAIS::createAIInstance: instance number %u is already in use, can't create new instance.", instanceNumber); - return ~0; + return std::numeric_limits::max(); } CAIInstance *aii = _AIInstances.addChild(new CAIInstance(this)); diff --git a/code/ryzom/server/src/ai_service/ai.h b/code/ryzom/server/src/ai_service/ai.h index 4f9a7d802..57ff524ec 100644 --- a/code/ryzom/server/src/ai_service/ai.h +++ b/code/ryzom/server/src/ai_service/ai.h @@ -104,7 +104,7 @@ public: // classic init(), update() and release() /** create an AI instance, return the instance index in the AIList - * Return ~0 if the instance number is already in use. + * Return std::numeric_limits::max() if the instance number is already in use. */ uint32 createAIInstance(const std::string &continentName, uint32 instanceNumber); /** destroy an AI Instance (useful for ring creation / destruction of session) @@ -205,7 +205,7 @@ public: /// Time warp managment. This method is called when time as warped more than 600ms bool advanceUserTimer(uint32 nbTicks); - /// Retreive emot number given it's name, return ~0 if not found + /// Retreive emot number given it's name, return std::numeric_limits::max() if not found uint32 getEmotNumber(const std::string &name); CCont &AIList () { return _AIInstances; } @@ -243,7 +243,7 @@ public: class CCounter { public: - CCounter(const uint32 max=~0):_Total(0),_Max(max) + CCounter(const uint32 max=std::numeric_limits::max()):_Total(0),_Max(max) {} virtual ~CCounter() {} diff --git a/code/ryzom/server/src/ai_service/ai_generic_fight.cpp b/code/ryzom/server/src/ai_service/ai_generic_fight.cpp index a19f747c3..f4c9a5cb0 100644 --- a/code/ryzom/server/src/ai_service/ai_generic_fight.cpp +++ b/code/ryzom/server/src/ai_service/ai_generic_fight.cpp @@ -571,7 +571,7 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot) ennemy=entity; } } - entity->_ChooseLastTime=~0; + entity->_ChooseLastTime = std::numeric_limits::max(); } if (fleeEnnemy==NULL && !spawnBot->getUnreachableTarget().isNULL()) 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 2bab5200d..6cd657ff2 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp +++ b/code/ryzom/server/src/ai_service/ai_grp_fauna.cpp @@ -220,7 +220,7 @@ void CSpawnGroupFauna::update() getPersistent().updateStateInstance(); - if (_CurrentCycle==~0) + if (_CurrentCycle==std::numeric_limits::max()) return; // Respawn @@ -606,9 +606,9 @@ CGrpFauna::CGrpFauna(CMgrFauna* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MA // state - _CurPopulation = ~0u; + _CurPopulation = std::numeric_limits::max(); - _CurrentCycle = ~0; + _CurrentCycle = std::numeric_limits::max(); // default values. setTimer(EAT_TIME, refTimer(EAT_TIME)); @@ -699,9 +699,9 @@ CAliasTreeOwner* CGrpFauna::createChild(IAliasCont* cont, CAIAliasDescriptionNod CAIPlaceXYRFauna *faunaPlace = new CAIPlaceXYRFauna(this, aliasTree); child = faunaPlace; uint placeIndex = faunaPlace->setupFromOldName(name); - nlassert(placeIndex!=~0); + nlassert(placeIndex!=std::numeric_limits::max()); - if (placeIndex!=~0) + if (placeIndex!=std::numeric_limits::max()) cont->addAliasChild(child, placeIndex); return child; @@ -769,7 +769,7 @@ bool CGrpFauna::spawn() return false; setStartState(getStartState()); // stateInstance. - return spawnPop(~0); + return spawnPop(std::numeric_limits::max()); } bool CGrpFauna::timeAllowSpawn(uint32 popVersion) const @@ -841,7 +841,7 @@ bool CGrpFauna::spawnPop(uint popVersion) } // check the validity of the input parameter - if (popVersion!=~0 && popVersion>=_Populations.size()) + if (popVersion!=std::numeric_limits::max() && popVersion>=_Populations.size()) { nlwarning("CGrpFauna::spawn(idx) FAILED for group %s because idx (%d) >= _Populations.size() (%d)",this->CGroup::getFullName().c_str(),popVersion,_Populations.size()); return false; diff --git a/code/ryzom/server/src/ai_service/child_container.h b/code/ryzom/server/src/ai_service/child_container.h index ab98d93af..0b5c79c4e 100644 --- a/code/ryzom/server/src/ai_service/child_container.h +++ b/code/ryzom/server/src/ai_service/child_container.h @@ -495,7 +495,7 @@ uint32 CAliasCont::getChildIndexByAlias(uint32 alias) const if (child!=NULL && child->getAlias()==alias) return (uint32)i; } - return ~0; + return std::numeric_limits::max(); } template diff --git a/code/ryzom/server/src/ai_service/commands.cpp b/code/ryzom/server/src/ai_service/commands.cpp index d257d0492..b51c7615b 100644 --- a/code/ryzom/server/src/ai_service/commands.cpp +++ b/code/ryzom/server/src/ai_service/commands.cpp @@ -577,7 +577,7 @@ NLMISC_COMMAND(createStaticAIInstance, "Create a new static AIInstance for a giv CUsedContinent &uc = CUsedContinent::instance(); const uint32 in = uc.getInstanceForContinent(args[0]); - if (in == ~0) + 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 != ~0); diff --git a/code/ryzom/server/src/ai_service/continent_inline.h b/code/ryzom/server/src/ai_service/continent_inline.h index 49c21248e..4ddf09c18 100644 --- a/code/ryzom/server/src/ai_service/continent_inline.h +++ b/code/ryzom/server/src/ai_service/continent_inline.h @@ -695,7 +695,7 @@ static CAIVector randomPos(double dispersionRadius) { return CAIVector(0., 0.); } - uint32 const maxLimit=((uint32)~0U)>>1; + uint32 const 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[ diff --git a/code/ryzom/server/src/ai_service/family_behavior.h b/code/ryzom/server/src/ai_service/family_behavior.h index 893282ae0..52d534e1c 100644 --- a/code/ryzom/server/src/ai_service/family_behavior.h +++ b/code/ryzom/server/src/ai_service/family_behavior.h @@ -210,7 +210,7 @@ class CFamilyBehavior void spawnBoss(NLMISC::TStringId outpostName); - uint32 energyScale (uint32 levelIndex=~0) const; + uint32 energyScale (uint32 levelIndex=std::numeric_limits::max()) const; void setModifier (const float &value, const uint32 &index) { diff --git a/code/ryzom/server/src/ai_service/nf_helpers.h b/code/ryzom/server/src/ai_service/nf_helpers.h index 2b8ead4e6..dc9c7c345 100644 --- a/code/ryzom/server/src/ai_service/nf_helpers.h +++ b/code/ryzom/server/src/ai_service/nf_helpers.h @@ -161,7 +161,7 @@ public: if (_value==-1) // not for affectation. return; - if (_index==~0) // all indexs ? + if (_index==std::numeric_limits::max()) // all indexs ? { for (uint32 nrjIndex=0;nrjIndex<4;nrjIndex++) fb->setModifier (_value, nrjIndex); diff --git a/code/ryzom/server/src/ai_service/path_behaviors.h b/code/ryzom/server/src/ai_service/path_behaviors.h index 8c509ae9d..6684b2db3 100644 --- a/code/ryzom/server/src/ai_service/path_behaviors.h +++ b/code/ryzom/server/src/ai_service/path_behaviors.h @@ -168,11 +168,11 @@ public: // - This method adds the new object to the top of the CFollowPath singleton's context stack // parameters: // - contextName : an arbitrary string naming the context - // - maxSearchDepth : the value that the path finder search depth should be limitted to (default to ~0u meaning no limit) + // - maxSearchDepth : the value that the path finder search depth should be limitted to (default to std::numeric_limits::max() meaning no limit) // - forceMaxDepth : set this flag true to override previous limit with larger value // example: - // - ... Before we begin ... CFollowPath::_MaxSearchDepth = ~0u - // - CFollowPathContext context1("tata") : CFollowPath::_MaxSearchDepth => ~0u + // - ... Before we begin ... CFollowPath::_MaxSearchDepth = std::numeric_limits::max() + // - CFollowPathContext context1("tata") : CFollowPath::_MaxSearchDepth => std::numeric_limits::max() // - CFollowPathContext context2("tete",456) : CFollowPath::_MaxSearchDepth => 456 // - CFollowPathContext context3("titi",123) : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context4("toto",456) : CFollowPath::_MaxSearchDepth => 123 @@ -182,9 +182,9 @@ public: // - CFollowPathContext context5.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context4.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context3.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 456 - // - CFollowPathContext context2.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => ~0u - // - CFollowPathContext context1.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => ~0u - CFollowPathContext(const char* contextName, uint32 maxSearchDepth=~0u, bool forceMaxDepth=false); + // - CFollowPathContext context2.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => std::numeric_limits::max() + // - CFollowPathContext context1.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => std::numeric_limits::max() + CFollowPathContext(const char* contextName, uint32 maxSearchDepth=std::numeric_limits::max(), bool forceMaxDepth=false); // dtor // - This method removes the destroyed object from the CFollowPath singleton's context stack @@ -270,7 +270,7 @@ private: friend class CFollowPathContext; CFollowPathContext* _TopFollowPathContext; public: - uint32 getMaxSearchDepth() const { return (_TopFollowPathContext==NULL)? ~0u: _TopFollowPathContext->getMaxSearchDepth(); } + uint32 getMaxSearchDepth() const { return (_TopFollowPathContext==NULL)? std::numeric_limits::max(): _TopFollowPathContext->getMaxSearchDepth(); } const char* getContextName() const; }; diff --git a/code/ryzom/server/src/ai_service/state_instance.h b/code/ryzom/server/src/ai_service/state_instance.h index 94755c143..3ad6e6d55 100644 --- a/code/ryzom/server/src/ai_service/state_instance.h +++ b/code/ryzom/server/src/ai_service/state_instance.h @@ -185,7 +185,7 @@ protected: CAITimerExtended _StateTimeout; /// current state (index into manager's state vector) CAIState* _state; - /// variable set to request a state change (~0 otherwise) + /// variable set to request a state change (std::numeric_limits::max() otherwise) CAIState* _NextState; /// timer for timing punctual states diff --git a/code/ryzom/server/src/pd_support_service/stat_user_file_list_builders.cpp b/code/ryzom/server/src/pd_support_service/stat_user_file_list_builders.cpp index 8f4f1e07f..d5d6570a4 100644 --- a/code/ryzom/server/src/pd_support_service/stat_user_file_list_builders.cpp +++ b/code/ryzom/server/src/pd_support_service/stat_user_file_list_builders.cpp @@ -522,7 +522,7 @@ FILE_LIST_BUILDER(NewestFile,"remove all but the latest file for each account (a uint32 accountId= accountIds[i]; uint32& bestTime= bestTimes[accountId]; uint32 timeStamp= fdc[i].FileTimeStamp; - if (bestTime!=timeStamp || bestTime==~0u) + if (bestTime!=timeStamp || bestTime==std::numeric_limits::max()) { fdc.removeFile(i); continue; diff --git a/code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service.cpp b/code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service.cpp index 1656f34c1..98ae3a893 100644 --- a/code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service.cpp +++ b/code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service.cpp @@ -912,7 +912,7 @@ void cbLSChooseShard (CMessage &msgin, const std::string &serviceName, TServiceI } - string ret = lsChooseShard(userName, cookie, userPriv, userExtended, WS::TUserRole::ur_player, 0xffffffff, ~0); + string ret = lsChooseShard(userName, cookie, userPriv, userExtended, WS::TUserRole::ur_player, 0xffffffff, std::numeric_limits::max()); if (!ret.empty()) { diff --git a/code/ryzom/server/src/server_share/logger_service_client.cpp b/code/ryzom/server/src/server_share/logger_service_client.cpp index e8174e0cd..d94834d12 100644 --- a/code/ryzom/server/src/server_share/logger_service_client.cpp +++ b/code/ryzom/server/src/server_share/logger_service_client.cpp @@ -238,8 +238,8 @@ namespace LGS // create the log context closing _LogInfos.push_back(TLogInfo()); _LogInfos.back().setLogName(contextName); - // tag as 'closing' with ~0 - _LogInfos.back().setTimeStamp(~0); + // tag as 'closing' with std::numeric_limits::max() + _LogInfos.back().setTimeStamp(std::numeric_limits::max()); } --_NbOpenContext; if (VerboseLogger) diff --git a/code/ryzom/server/src/server_share/msg_ai_service.h b/code/ryzom/server/src/server_share/msg_ai_service.h index bd4115f4a..13c6a3423 100644 --- a/code/ryzom/server/src/server_share/msg_ai_service.h +++ b/code/ryzom/server/src/server_share/msg_ai_service.h @@ -88,7 +88,7 @@ public: virtual void description () { className ("CUserEventMsg"); - property ("InstanceNumber", PropUInt32, uint32(~0), InstanceNumber); + property ("InstanceNumber", PropUInt32, std::numeric_limits::max(), InstanceNumber); property ("GrpAlias", PropUInt32, uint32(0xffffffff), GrpAlias); property ("EventId", PropUInt8, uint8(0xff), EventId); propertyCont ("Params", PropString, Params); @@ -133,7 +133,7 @@ public: virtual void description () { className ("CSetEscortTeamId"); - property ("InstanceNumber", PropUInt32, uint32(~0), InstanceNumber); + property ("InstanceNumber", PropUInt32, std::numeric_limits::max(), InstanceNumber); propertyCont ("Groups", PropUInt32, Groups); property ("TeamId", PropUInt16, CTEAM::InvalidTeamId, TeamId); } diff --git a/code/ryzom/server/src/server_share/pet_interface_msg.h b/code/ryzom/server/src/server_share/pet_interface_msg.h index d2f9e64a2..9aa914226 100644 --- a/code/ryzom/server/src/server_share/pet_interface_msg.h +++ b/code/ryzom/server/src/server_share/pet_interface_msg.h @@ -47,7 +47,7 @@ public: virtual void description () { className ("CPetSpawnMsg"); - property ("AIInstanceId", PropUInt32, (uint32)~0, AIInstanceId); + property ("AIInstanceId", PropUInt32, std::numeric_limits::max(), AIInstanceId); property ("SpawnMode", PropUInt16, (uint16)NEAR_PLAYER, SpawnMode); property ("CharacterMirrorRow", PropDataSetRow, TDataSetRow(), CharacterMirrorRow); property ("PetSheetId", PropSheetId, NLMISC::CSheetId::Unknown, PetSheetId); diff --git a/code/ryzom/server/src/server_share/r2_vision.cpp b/code/ryzom/server/src/server_share/r2_vision.cpp index 7433e9026..dd4b2a25d 100644 --- a/code/ryzom/server/src/server_share/r2_vision.cpp +++ b/code/ryzom/server/src/server_share/r2_vision.cpp @@ -147,8 +147,8 @@ namespace R2_VISION void CUniverse::createInstance(uint32 aiInstance, uint32 groupId) { - // just ignore attempts to create the ~0u instance - if (aiInstance==~0u) + // just ignore attempts to create the std::numeric_limits::max() instance + if (aiInstance==std::numeric_limits::max()) { return; } @@ -172,8 +172,8 @@ namespace R2_VISION void CUniverse::removeInstance(uint32 aiInstance) { - // just ignore attempts to remove the ~0u instance - if (aiInstance==~0u) + // just ignore attempts to remove the std::numeric_limits::max() instance + if (aiInstance==std::numeric_limits::max()) { return; } @@ -227,7 +227,7 @@ namespace R2_VISION SUniverseEntity& theEntity= _Entities[row]; // if the entity was already allocated then remove it - if (theEntity.AIInstance == ~0u) { return; } + if (theEntity.AIInstance == std::numeric_limits::max()) { return; } if ( theEntity.ViewerRecord) { @@ -325,8 +325,8 @@ namespace R2_VISION BOMB_IF(row>=_Entities.size(),NLMISC::toString("Ignoring attempt to set entity position with invalid row value: %d",row),return); // ensure that the new AIInstance exists - BOMB_IF(aiInstance!=~0u && (aiInstance>=_Instances.size() || _Instances[aiInstance]==NULL), - NLMISC::toString("ERROR: Failed to add entity %d to un-initialised instance: %d",row,aiInstance),aiInstance=~0u); + BOMB_IF(aiInstance!=std::numeric_limits::max() && (aiInstance>=_Instances.size() || _Instances[aiInstance]==NULL), + NLMISC::toString("ERROR: Failed to add entity %d to un-initialised instance: %d",row,aiInstance),aiInstance=std::numeric_limits::max()); // delegate to workhorse routine (converting y coordinate to +ve axis) _teleportEntity(dataSetRow,aiInstance,x,-y,invisibilityLevel); @@ -429,7 +429,7 @@ namespace R2_VISION SUniverseEntity& theEntity= _Entities[row]; // if the entity was already allocated then remove it - if (theEntity.AIInstance!=~0u) + if (theEntity.AIInstance!=std::numeric_limits::max()) { _removeEntity(dataSetRow); } @@ -455,7 +455,7 @@ namespace R2_VISION { // detach the entity from the instance it's currently in _Instances[theEntity.AIInstance]->removeEntity(theEntity); - theEntity.AIInstance= ~0u; + theEntity.AIInstance= std::numeric_limits::max(); theEntity.ViewerRecord= NULL; } } @@ -466,8 +466,8 @@ namespace R2_VISION SUniverseEntity& theEntity= _Entities[dataSetRow.getIndex()]; #ifdef NL_DEBUG - nlassert(theEntity.AIInstance==~0u || theEntity.AIInstance<_Instances.size()); - nlassert(theEntity.AIInstance==~0u || _Instances[theEntity.AIInstance]!=NULL); + nlassert(theEntity.AIInstance==std::numeric_limits::max() || theEntity.AIInstance<_Instances.size()); + nlassert(theEntity.AIInstance==std::numeric_limits::max() || _Instances[theEntity.AIInstance]!=NULL); #endif // if the entity is a viewer then move the view coordinates @@ -477,7 +477,7 @@ namespace R2_VISION } // if the entity is not currently in an AIInstance then stop here - if (theEntity.AIInstance==~0u) + if (theEntity.AIInstance==std::numeric_limits::max()) return; // set the instance entity record position @@ -498,10 +498,10 @@ namespace R2_VISION // set the new AIInstance value for the entity theEntity.AIInstance= aiInstance; - // if the aiInstance is set to ~0u (a reserved value) then we stop here - if (aiInstance==~0u) + // if the aiInstance is set to std::numeric_limits::max() (a reserved value) then we stop here + if (aiInstance==std::numeric_limits::max()) { - // clear out the vision for an entity in aiInstance ~0u + // clear out the vision for an entity in aiInstance std::numeric_limits::max() if (getEntity(dataSetRow)->ViewerRecord!=NULL) { TVision emptyVision(2); @@ -785,7 +785,7 @@ namespace R2_VISION // locate the old vision group (the one we're allocated to before isolation) uint32 visionId= viewerRecord->VisionId; NLMISC::CSmartPtr& oldVisionGroup= _VisionGroups[visionId]; - BOMB_IF(visionId>=_VisionGroups.size() ||oldVisionGroup==NULL,"Trying to remove entity from vision group with unknown vision id",viewerRecord->VisionId=~0u;return); + BOMB_IF(visionId>=_VisionGroups.size() ||oldVisionGroup==NULL,"Trying to remove entity from vision group with unknown vision id",viewerRecord->VisionId=std::numeric_limits::max();return); // if we're the only viewer then already isolated so just return if (oldVisionGroup->numViewers()==1) @@ -830,7 +830,7 @@ namespace R2_VISION if (viewerRecord!=NULL) { uint32 visionId= viewerRecord->VisionId; - BOMB_IF(visionId>=_VisionGroups.size() ||_VisionGroups[visionId]==NULL,"Trying to remove entity with unknown vision id",viewerRecord->VisionId=~0u;return); + BOMB_IF(visionId>=_VisionGroups.size() ||_VisionGroups[visionId]==NULL,"Trying to remove entity with unknown vision id",viewerRecord->VisionId=std::numeric_limits::max();return); _VisionGroups[visionId]->removeViewer(viewerRecord); } @@ -847,8 +847,8 @@ namespace R2_VISION _Entities.pop_back(); // invalidate the InstanceIndex value for the entity we just removed - entity.InstanceIndex=~0u; - entity.AIInstance=~0u; + entity.InstanceIndex=std::numeric_limits::max(); + entity.AIInstance=std::numeric_limits::max(); } void CInstance::release() @@ -899,11 +899,11 @@ namespace R2_VISION CVisionGroup::CVisionGroup() { - _XMin=~0u; + _XMin=std::numeric_limits::max(); _XMax=0; - _YMin=~0u; + _YMin=std::numeric_limits::max(); _YMax=0; - _VisionId=~0u; + _VisionId=std::numeric_limits::max(); // setup the dummy entry in the vision buffer _Vision.reserve(AllocatedVisionVectorSize); vectAppend(_Vision).DataSetRow= ZeroDataSetRow; @@ -923,8 +923,8 @@ namespace R2_VISION // ensure that the viewer wasn't aleady attached to another vision group #ifdef NL_DEBUG nlassert(viewer!=NULL); - nlassert(viewer->VisionId==~0u); - nlassert(viewer->VisionIndex==~0u); + nlassert(viewer->VisionId==std::numeric_limits::max()); + nlassert(viewer->VisionIndex==std::numeric_limits::max()); #endif TEST(("add viewer %d to grp %d",viewer->getViewerId().getIndex(),_VisionId)); @@ -961,8 +961,8 @@ namespace R2_VISION // pop the back entry off the vector and flag oursleves as unused _Viewers.pop_back(); - viewer->VisionId= ~0u; - viewer->VisionIndex= ~0u; + viewer->VisionId= std::numeric_limits::max(); + viewer->VisionIndex= std::numeric_limits::max(); // NOTE: after this the boundary may be out of date - this will be recalculated at the next // vision update so we don't take time to do it here @@ -1171,8 +1171,8 @@ namespace R2_VISION return; // calculate the bouding box for our viewers - uint32 xmin= ~0u; - uint32 ymin= ~0u; + uint32 xmin= std::numeric_limits::max(); + uint32 ymin= std::numeric_limits::max(); uint32 xmax= 0; uint32 ymax= 0; for (uint32 i=(uint32)_Viewers.size();i--;) @@ -1247,7 +1247,7 @@ namespace R2_VISION // reset the vision vector and add in the dummy entry with DataSetRow=0 _Vision.resize(AllocatedVisionVectorSize); _Vision[0].DataSetRow= ZeroDataSetRow; - _Vision[0].VisionSlot= ~0u; + _Vision[0].VisionSlot= std::numeric_limits::max(); // setup a vision slot iterator for filling in the vision buffer (=1 to skip passed the dummy entry) uint32 nextVisionSlot=1; @@ -1380,8 +1380,8 @@ namespace R2_VISION CViewer::CViewer() { - VisionId=~0u; - VisionIndex=~0u; + VisionId=std::numeric_limits::max(); + VisionIndex=std::numeric_limits::max(); _VisionResetCount= 0; } @@ -1399,7 +1399,7 @@ namespace R2_VISION // setup the dummy entry with DataSetRow=0 _Vision[0].DataSetRow= ZeroDataSetRow; - _Vision[0].VisionSlot= ~0u; + _Vision[0].VisionSlot= std::numeric_limits::max(); // setup the vision slots in reverse order from 254..0 (because they're popped from the back) _FreeVisionSlots.clear(); diff --git a/code/ryzom/server/src/server_share/r2_vision.h b/code/ryzom/server/src/server_share/r2_vision.h index 9bf3f7689..9872e606a 100644 --- a/code/ryzom/server/src/server_share/r2_vision.h +++ b/code/ryzom/server/src/server_share/r2_vision.h @@ -140,7 +140,7 @@ namespace R2_VISION // ctor SViewedEntity() { - VisionSlot=~0u; + VisionSlot=std::numeric_limits::max(); } }; @@ -196,15 +196,15 @@ namespace R2_VISION struct SUniverseEntity { TDataSetRow DataSetRow; // the complete data set row for the entity - uint32 AIInstance; // the id of the instance that we're currently in (~0u by default) + uint32 AIInstance; // the id of the instance that we're currently in (std::numeric_limits::max() by default) mutable uint32 InstanceIndex; // the index within the instance's _Entities vector NLMISC::CSmartPtr ViewerRecord; // pointer to the CViewer record for viewers (or NULL) // ctor SUniverseEntity() { - AIInstance=~0u; - InstanceIndex=~0u; + AIInstance=std::numeric_limits::max(); + InstanceIndex=std::numeric_limits::max(); } }; diff --git a/code/ryzom/server/src/server_share/used_continent.cpp b/code/ryzom/server/src/server_share/used_continent.cpp index 01ab2beda..075f16c14 100644 --- a/code/ryzom/server/src/server_share/used_continent.cpp +++ b/code/ryzom/server/src/server_share/used_continent.cpp @@ -105,7 +105,7 @@ uint32 CUsedContinent::getInstanceForContinent(const std::string &continentName) if (it != _Continents.end()) return it->ContinentInstance; else - return ~0; + return std::numeric_limits::max(); } uint32 CUsedContinent::getInstanceForContinent(CONTINENT::TContinent continentEnum) const @@ -115,7 +115,7 @@ uint32 CUsedContinent::getInstanceForContinent(CONTINENT::TContinent continentEn if (it != _Continents.end()) return it->ContinentInstance; else - return ~0; + return std::numeric_limits::max(); } const std::string &CUsedContinent::getContinentForInstance(uint32 instanceNumber) const diff --git a/code/ryzom/server/src/server_share/used_continent.h b/code/ryzom/server/src/server_share/used_continent.h index 150b6342c..85f002e40 100644 --- a/code/ryzom/server/src/server_share/used_continent.h +++ b/code/ryzom/server/src/server_share/used_continent.h @@ -60,12 +60,12 @@ public: bool isContinentUsed(const std::string &continentName) const; /** Return the static instance number associated with a continent name. - * If the continent name is unknow, return ~0 + * If the continent name is unknow, return std::numeric_limits::max() */ uint32 getInstanceForContinent(const std::string &continentName) const; /** Return the static instance number associated with a continent enum value - * If the continent name is unknow, return ~0 + * If the continent name is unknow, return std::numeric_limits::max() */ uint32 getInstanceForContinent(CONTINENT::TContinent continentEnum) const; diff --git a/code/ryzom/server/src/shard_unifier_service/character_sync.cpp b/code/ryzom/server/src/shard_unifier_service/character_sync.cpp index 3b1a8b995..29b404567 100644 --- a/code/ryzom/server/src/shard_unifier_service/character_sync.cpp +++ b/code/ryzom/server/src/shard_unifier_service/character_sync.cpp @@ -365,7 +365,7 @@ namespace CHARSYNC for (; first != last; ++first) { // default to no limit - uint32 limit=~0u; + uint32 limit=std::numeric_limits::max(); // if there's a limit in the limis map then use it instead... if (limitsMap.find(first->first)!=limitsMap.end()) diff --git a/code/ryzom/server/src/tick_service/range_mirror_manager.cpp b/code/ryzom/server/src/tick_service/range_mirror_manager.cpp index f988ac054..2c92c738f 100644 --- a/code/ryzom/server/src/tick_service/range_mirror_manager.cpp +++ b/code/ryzom/server/src/tick_service/range_mirror_manager.cpp @@ -472,7 +472,7 @@ void CRangeList::acquireFirstRow() */ bool CRangeList::acquireRange( NLNET::TServiceId ownerServiceId, NLNET::TServiceId mirrorServiceId, sint32 nbRows, TDataSetIndex *first, TDataSetIndex *last ) { - TDataSetIndex prevlast(~0); + TDataSetIndex prevlast(std::numeric_limits::max()); TRangeList::iterator irl = _RangeList.begin(); // Find a compatible range diff --git a/code/ryzom/server/src/tick_service/range_mirror_manager.h b/code/ryzom/server/src/tick_service/range_mirror_manager.h index 6615a1c6a..0bde600e4 100644 --- a/code/ryzom/server/src/tick_service/range_mirror_manager.h +++ b/code/ryzom/server/src/tick_service/range_mirror_manager.h @@ -46,7 +46,7 @@ class CRangeList public: /// Default constructor - CRangeList() : _TotalMaxRows(~0) { acquireFirstRow(); } + CRangeList() : _TotalMaxRows(std::numeric_limits::max()) { acquireFirstRow(); } /// Constructor CRangeList( sint32 totalMaxRows ) : _TotalMaxRows( totalMaxRows ) { acquireFirstRow(); } diff --git a/code/ryzom/server/src/tick_service/tick_service.cpp b/code/ryzom/server/src/tick_service/tick_service.cpp index 95f609571..4a64fdd7c 100644 --- a/code/ryzom/server/src/tick_service/tick_service.cpp +++ b/code/ryzom/server/src/tick_service/tick_service.cpp @@ -825,7 +825,7 @@ bool CTickService::loadGameCycle() /* * */ -CTickServiceGameCycleTimeMeasure::CTickServiceGameCycleTimeMeasure() : HistoryMain( CTickService::getInstance()->getServiceId(), NLNET::TServiceId(~0), false ) {} +CTickServiceGameCycleTimeMeasure::CTickServiceGameCycleTimeMeasure() : HistoryMain( CTickService::getInstance()->getServiceId(), NLNET::TServiceId(std::numeric_limits::max()), false ) {} /* @@ -904,7 +904,7 @@ void CTickServiceGameCycleTimeMeasure::displayStat( NLMISC::CLog *log, TTimeMeas uint divideBy = (HistoryMain.NbMeasures==0) ? 0 : ((stat==MHTSum) ? HistoryMain.NbMeasures : 1); HistoryMain.Stats[stat].displayStat( log, TickServiceTimeMeasureTypeToCString, divideBy ); { - CMirrorTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; + CMirrorTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, std::numeric_limits::max(), 0 }; for ( std::vector::const_iterator ihm=HistoryByMirror.begin(); ihm!=HistoryByMirror.end(); ++ihm ) { log->displayRawNL( "\tMS-%hu, %u measures:", (*ihm).ServiceId.get(), (*ihm).NbMeasures ); @@ -921,7 +921,7 @@ void CTickServiceGameCycleTimeMeasure::displayStat( NLMISC::CLog *log, TTimeMeas } } { - CServiceTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; + CServiceTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, std::numeric_limits::max(), 0 }; for ( std::vector::const_iterator ihs=HistoryByService.begin(); ihs!=HistoryByService.end(); ++ihs ) { log->displayRawNL( "\t%s (on MS-%hu), %u measures:", CUnifiedNetwork::getInstance()->getServiceUnifiedName( (*ihs).ServiceId ).c_str(), (*ihs).ParentServiceId.get(), (*ihs).NbMeasures ); diff --git a/code/ryzom/server/src/tick_service/tick_service.h b/code/ryzom/server/src/tick_service/tick_service.h index 5b07793a3..9abe079bc 100644 --- a/code/ryzom/server/src/tick_service/tick_service.h +++ b/code/ryzom/server/src/tick_service/tick_service.h @@ -113,7 +113,7 @@ public: NbMeasures = 0; Stats.resize( NbTimeMeasureHistoryStats ); Stats[MHTSum] = 0; - Stats[MHTMin] = ~0; + Stats[MHTMin] = std::numeric_limits::max(); Stats[MHTMax] = 0; } } diff --git a/code/ryzom/tools/leveldesign/mp_generator/utils.h b/code/ryzom/tools/leveldesign/mp_generator/utils.h index 63148f61f..01bb25fe7 100644 --- a/code/ryzom/tools/leveldesign/mp_generator/utils.h +++ b/code/ryzom/tools/leveldesign/mp_generator/utils.h @@ -55,17 +55,17 @@ public: * Display the item as a row of a HTML table. * If (key!=previousKey) and (name==previousName), the row will not be displayed entirely to save space * - * \param keyColumn If not ~0, column used for sorting => this column displays only the field matching the key + * \param keyColumn If not std::numeric_limits::max(), column used for sorting => this column displays only the field matching the key * \param key The key used for sorting (see keyColumn) * \param previousKey Previous key - * \param nameColumn If not ~0, column used for the unique name (column must have exaclty one element) + * \param nameColumn If not std::numeric_limits::max(), column used for the unique name (column must have exaclty one element) * \param previousName Previous name */ - std::string toHTMLRow( uint32 keyColumn=~0, const string& key=string(), const string& previousKey=string(), - uint32 nameColumn=~0, const string& previousName=string() ) const + std::string toHTMLRow( uint32 keyColumn=std::numeric_limits::max(), const string& key=string(), const string& previousKey=string(), + uint32 nameColumn=std::numeric_limits::max(), const string& previousName=string() ) const { std::string s = ""; - bool lightMode = (nameColumn == ~0) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName)); + bool lightMode = (nameColumn == std::numeric_limits::max()) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName)); for ( uint32 c=0; c!=NC; ++c ) { s += ""; @@ -86,11 +86,11 @@ public: /// - std::string toCSVLine( char columnSeparator=',', string internalSeparator=" - ", uint32 keyColumn=~0, const string& key=string(), const string& previousKey=string(), - uint32 nameColumn=~0, const string& previousName=string() ) const + std::string toCSVLine( char columnSeparator=',', string internalSeparator=" - ", uint32 keyColumn=std::numeric_limits::max(), const string& key=string(), const string& previousKey=string(), + uint32 nameColumn=std::numeric_limits::max(), const string& previousName=string() ) const { std::string s; - bool lightMode = (nameColumn == ~0) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName)); + bool lightMode = (nameColumn == std::numeric_limits::max()) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName)); for ( uint32 c=0; c!=NC; ++c ) { if ( c == keyColumn ) diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index 3d28a2439..7f63177ac 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -149,7 +149,7 @@ CPackageDescription::CPackageDescription() void CPackageDescription::clear() { - _NextVersionNumber= ~0u; + _NextVersionNumber= std::numeric_limits::max(); _VersionNumberReserved = false; _Categories.clear(); _IndexFileName.clear(); diff --git a/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp b/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp index a15f8c6d3..f194f996e 100644 --- a/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp +++ b/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp @@ -237,8 +237,8 @@ CProximityZone::CProximityZone(uint32 scanWidth,uint32 scanHeight,sint32 xOffset _MaxOffset = scanWidth * scanHeight -1; - _XMin = ~0u; - _YMin = ~0u; + _XMin = std::numeric_limits::max(); + _YMin = std::numeric_limits::max(); _XMax = 0; _YMax = 0; } @@ -386,7 +386,7 @@ void CProximityMapBuffer::load(const std::string& name) } } // setup the next pixel in the output buffers... - _Buffer[y*_ScanWidth+x]= (isAccessible? 0: (TBufferEntry)~0u); + _Buffer[y*_ScanWidth+x]= (isAccessible? 0: (TBufferEntry)std::numeric_limits::max()); } } } @@ -471,7 +471,7 @@ void CProximityMapBuffer::_prepareBufferForZoneProximityMap(const CProximityZone uint32 zoneWidth= zone.getZoneWidth(); uint32 zoneHeight= zone.getZoneHeight(); zoneBuffer.clear(); - zoneBuffer.resize(zoneWidth*zoneHeight,(TBufferEntry)~0u); + zoneBuffer.resize(zoneWidth*zoneHeight,(TBufferEntry)std::numeric_limits::max()); // setup the buffer's accessible points and prime vects[0] with the set of accessible points in the zone buffer for (uint32 i=0;i &islands, float camSpeed texturedMaterial.setDoubleSided(true); texturedMaterial.setZFunc(CMaterial::lessequal); // - uint currWorldIndex = ~0; + uint currWorldIndex = std::numeric_limits::max(); bool newPosWanted = true; // std::vector zones;