Changed: Replaced ~0 by corresponding std::numeric_limits<T>::max()

This commit is contained in:
kervala 2015-01-13 13:47:19 +01:00
parent 9d0695feee
commit 3602ab47f2
29 changed files with 94 additions and 94 deletions

View file

@ -224,7 +224,7 @@ uint32 CAIS::getEmotNumber(const std::string &name)
{ {
std::map<std::string, uint32>::iterator it(_EmotNames.find(name)); std::map<std::string, uint32>::iterator it(_EmotNames.find(name));
if (it==_EmotNames.end()) if (it==_EmotNames.end())
return ~0; return std::numeric_limits<uint32>::max();
return it->second; return it->second;
} }
@ -280,7 +280,7 @@ uint32 CAIS::createAIInstance(const std::string &continentName, uint32 instanceN
continue; continue;
nlwarning("CAIS::createAIInstance: instance number %u is already in use, can't create new instance.", instanceNumber); nlwarning("CAIS::createAIInstance: instance number %u is already in use, can't create new instance.", instanceNumber);
return ~0; return std::numeric_limits<uint32>::max();
} }
CAIInstance *aii = _AIInstances.addChild(new CAIInstance(this)); CAIInstance *aii = _AIInstances.addChild(new CAIInstance(this));

View file

@ -104,7 +104,7 @@ public:
// classic init(), update() and release() // classic init(), update() and release()
/** create an AI instance, return the instance index in the AIList /** 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<uint32>::max() if the instance number is already in use.
*/ */
uint32 createAIInstance(const std::string &continentName, uint32 instanceNumber); uint32 createAIInstance(const std::string &continentName, uint32 instanceNumber);
/** destroy an AI Instance (useful for ring creation / destruction of session) /** 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 /// Time warp managment. This method is called when time as warped more than 600ms
bool advanceUserTimer(uint32 nbTicks); 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<uint32>::max() if not found
uint32 getEmotNumber(const std::string &name); uint32 getEmotNumber(const std::string &name);
CCont<CAIInstance> &AIList () { return _AIInstances; } CCont<CAIInstance> &AIList () { return _AIInstances; }
@ -243,7 +243,7 @@ public:
class CCounter class CCounter
{ {
public: public:
CCounter(const uint32 max=~0):_Total(0),_Max(max) CCounter(const uint32 max=std::numeric_limits<uint32>::max()):_Total(0),_Max(max)
{} {}
virtual ~CCounter() virtual ~CCounter()
{} {}

View file

@ -571,7 +571,7 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
ennemy=entity; ennemy=entity;
} }
} }
entity->_ChooseLastTime=~0; entity->_ChooseLastTime = std::numeric_limits<uint32>::max();
} }
if (fleeEnnemy==NULL && !spawnBot->getUnreachableTarget().isNULL()) if (fleeEnnemy==NULL && !spawnBot->getUnreachableTarget().isNULL())

View file

@ -220,7 +220,7 @@ void CSpawnGroupFauna::update()
getPersistent().updateStateInstance(); getPersistent().updateStateInstance();
if (_CurrentCycle==~0) if (_CurrentCycle==std::numeric_limits<uint32>::max())
return; return;
// Respawn // Respawn
@ -606,9 +606,9 @@ CGrpFauna::CGrpFauna(CMgrFauna* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MA
// state // state
_CurPopulation = ~0u; _CurPopulation = std::numeric_limits<uint32>::max();
_CurrentCycle = ~0; _CurrentCycle = std::numeric_limits<sint32>::max();
// default values. // default values.
setTimer(EAT_TIME, refTimer(EAT_TIME)); setTimer(EAT_TIME, refTimer(EAT_TIME));
@ -699,9 +699,9 @@ CAliasTreeOwner* CGrpFauna::createChild(IAliasCont* cont, CAIAliasDescriptionNod
CAIPlaceXYRFauna *faunaPlace = new CAIPlaceXYRFauna(this, aliasTree); CAIPlaceXYRFauna *faunaPlace = new CAIPlaceXYRFauna(this, aliasTree);
child = faunaPlace; child = faunaPlace;
uint placeIndex = faunaPlace->setupFromOldName(name); uint placeIndex = faunaPlace->setupFromOldName(name);
nlassert(placeIndex!=~0); nlassert(placeIndex!=std::numeric_limits<uint>::max());
if (placeIndex!=~0) if (placeIndex!=std::numeric_limits<uint>::max())
cont->addAliasChild(child, placeIndex); cont->addAliasChild(child, placeIndex);
return child; return child;
@ -769,7 +769,7 @@ bool CGrpFauna::spawn()
return false; return false;
setStartState(getStartState()); // stateInstance. setStartState(getStartState()); // stateInstance.
return spawnPop(~0); return spawnPop(std::numeric_limits<uint>::max());
} }
bool CGrpFauna::timeAllowSpawn(uint32 popVersion) const bool CGrpFauna::timeAllowSpawn(uint32 popVersion) const
@ -841,7 +841,7 @@ bool CGrpFauna::spawnPop(uint popVersion)
} }
// check the validity of the input parameter // check the validity of the input parameter
if (popVersion!=~0 && popVersion>=_Populations.size()) if (popVersion!=std::numeric_limits<uint>::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()); nlwarning("CGrpFauna::spawn(idx) FAILED for group %s because idx (%d) >= _Populations.size() (%d)",this->CGroup::getFullName().c_str(),popVersion,_Populations.size());
return false; return false;

View file

@ -495,7 +495,7 @@ uint32 CAliasCont<TChld>::getChildIndexByAlias(uint32 alias) const
if (child!=NULL && child->getAlias()==alias) if (child!=NULL && child->getAlias()==alias)
return (uint32)i; return (uint32)i;
} }
return ~0; return std::numeric_limits<uint32>::max();
} }
template <class TChld> template <class TChld>

View file

@ -577,7 +577,7 @@ NLMISC_COMMAND(createStaticAIInstance, "Create a new static AIInstance for a giv
CUsedContinent &uc = CUsedContinent::instance(); CUsedContinent &uc = CUsedContinent::instance();
const uint32 in = uc.getInstanceForContinent(args[0]); const uint32 in = uc.getInstanceForContinent(args[0]);
if (in == ~0) 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()); nlwarning("The continent '%s' is unknow or not active. Can't create instance, FATAL", args[0].c_str());
nlassert(in != ~0); nlassert(in != ~0);

View file

@ -695,7 +695,7 @@ static CAIVector randomPos(double dispersionRadius)
{ {
return CAIVector(0., 0.); return CAIVector(0., 0.);
} }
uint32 const maxLimit=((uint32)~0U)>>1; uint32 const maxLimit=(std::numeric_limits<uint32>::max())>>1;
double rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[ double rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[
double r = dispersionRadius*sqrt(rval); double r = dispersionRadius*sqrt(rval);
rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[ rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[

View file

@ -210,7 +210,7 @@ class CFamilyBehavior
void spawnBoss(NLMISC::TStringId outpostName); void spawnBoss(NLMISC::TStringId outpostName);
uint32 energyScale (uint32 levelIndex=~0) const; uint32 energyScale (uint32 levelIndex=std::numeric_limits<uint32>::max()) const;
void setModifier (const float &value, const uint32 &index) void setModifier (const float &value, const uint32 &index)
{ {

View file

@ -161,7 +161,7 @@ public:
if (_value==-1) // not for affectation. if (_value==-1) // not for affectation.
return; return;
if (_index==~0) // all indexs ? if (_index==std::numeric_limits<size_t>::max()) // all indexs ?
{ {
for (uint32 nrjIndex=0;nrjIndex<4;nrjIndex++) for (uint32 nrjIndex=0;nrjIndex<4;nrjIndex++)
fb->setModifier (_value, nrjIndex); fb->setModifier (_value, nrjIndex);

View file

@ -168,11 +168,11 @@ public:
// - This method adds the new object to the top of the CFollowPath singleton's context stack // - This method adds the new object to the top of the CFollowPath singleton's context stack
// parameters: // parameters:
// - contextName : an arbitrary string naming the context // - 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<uint32>::max() meaning no limit)
// - forceMaxDepth : set this flag true to override previous limit with larger value // - forceMaxDepth : set this flag true to override previous limit with larger value
// example: // example:
// - ... Before we begin ... CFollowPath::_MaxSearchDepth = ~0u // - ... Before we begin ... CFollowPath::_MaxSearchDepth = std::numeric_limits<uint32>::max()
// - CFollowPathContext context1("tata") : CFollowPath::_MaxSearchDepth => ~0u // - CFollowPathContext context1("tata") : CFollowPath::_MaxSearchDepth => std::numeric_limits<uint32>::max()
// - CFollowPathContext context2("tete",456) : CFollowPath::_MaxSearchDepth => 456 // - CFollowPathContext context2("tete",456) : CFollowPath::_MaxSearchDepth => 456
// - CFollowPathContext context3("titi",123) : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context3("titi",123) : CFollowPath::_MaxSearchDepth => 123
// - CFollowPathContext context4("toto",456) : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context4("toto",456) : CFollowPath::_MaxSearchDepth => 123
@ -182,9 +182,9 @@ public:
// - CFollowPathContext context5.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context5.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 123
// - CFollowPathContext context4.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 123 // - CFollowPathContext context4.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 123
// - CFollowPathContext context3.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 456 // - CFollowPathContext context3.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => 456
// - CFollowPathContext context2.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => ~0u // - CFollowPathContext context2.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => std::numeric_limits<uint32>::max()
// - CFollowPathContext context1.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => ~0u // - CFollowPathContext context1.~CFollowPathContext() : CFollowPath::_MaxSearchDepth => std::numeric_limits<uint32>::max()
CFollowPathContext(const char* contextName, uint32 maxSearchDepth=~0u, bool forceMaxDepth=false); CFollowPathContext(const char* contextName, uint32 maxSearchDepth=std::numeric_limits<uint32>::max(), bool forceMaxDepth=false);
// dtor // dtor
// - This method removes the destroyed object from the CFollowPath singleton's context stack // - This method removes the destroyed object from the CFollowPath singleton's context stack
@ -270,7 +270,7 @@ private:
friend class CFollowPathContext; friend class CFollowPathContext;
CFollowPathContext* _TopFollowPathContext; CFollowPathContext* _TopFollowPathContext;
public: public:
uint32 getMaxSearchDepth() const { return (_TopFollowPathContext==NULL)? ~0u: _TopFollowPathContext->getMaxSearchDepth(); } uint32 getMaxSearchDepth() const { return (_TopFollowPathContext==NULL)? std::numeric_limits<uint32>::max(): _TopFollowPathContext->getMaxSearchDepth(); }
const char* getContextName() const; const char* getContextName() const;
}; };

View file

@ -185,7 +185,7 @@ protected:
CAITimerExtended _StateTimeout; CAITimerExtended _StateTimeout;
/// current state (index into manager's state vector) /// current state (index into manager's state vector)
CAIState* _state; CAIState* _state;
/// variable set to request a state change (~0 otherwise) /// variable set to request a state change (std::numeric_limits<uint32>::max() otherwise)
CAIState* _NextState; CAIState* _NextState;
/// timer for timing punctual states /// timer for timing punctual states

View file

@ -522,7 +522,7 @@ FILE_LIST_BUILDER(NewestFile,"remove all but the latest file for each account (a
uint32 accountId= accountIds[i]; uint32 accountId= accountIds[i];
uint32& bestTime= bestTimes[accountId]; uint32& bestTime= bestTimes[accountId];
uint32 timeStamp= fdc[i].FileTimeStamp; uint32 timeStamp= fdc[i].FileTimeStamp;
if (bestTime!=timeStamp || bestTime==~0u) if (bestTime!=timeStamp || bestTime==std::numeric_limits<uint32>::max())
{ {
fdc.removeFile(i); fdc.removeFile(i);
continue; continue;

View file

@ -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<uint32>::max());
if (!ret.empty()) if (!ret.empty())
{ {

View file

@ -238,8 +238,8 @@ namespace LGS
// create the log context closing // create the log context closing
_LogInfos.push_back(TLogInfo()); _LogInfos.push_back(TLogInfo());
_LogInfos.back().setLogName(contextName); _LogInfos.back().setLogName(contextName);
// tag as 'closing' with ~0 // tag as 'closing' with std::numeric_limits<uint32>::max()
_LogInfos.back().setTimeStamp(~0); _LogInfos.back().setTimeStamp(std::numeric_limits<uint32>::max());
} }
--_NbOpenContext; --_NbOpenContext;
if (VerboseLogger) if (VerboseLogger)

View file

@ -88,7 +88,7 @@ public:
virtual void description () virtual void description ()
{ {
className ("CUserEventMsg"); className ("CUserEventMsg");
property ("InstanceNumber", PropUInt32, uint32(~0), InstanceNumber); property ("InstanceNumber", PropUInt32, std::numeric_limits<uint32>::max(), InstanceNumber);
property ("GrpAlias", PropUInt32, uint32(0xffffffff), GrpAlias); property ("GrpAlias", PropUInt32, uint32(0xffffffff), GrpAlias);
property ("EventId", PropUInt8, uint8(0xff), EventId); property ("EventId", PropUInt8, uint8(0xff), EventId);
propertyCont ("Params", PropString, Params); propertyCont ("Params", PropString, Params);
@ -133,7 +133,7 @@ public:
virtual void description () virtual void description ()
{ {
className ("CSetEscortTeamId"); className ("CSetEscortTeamId");
property ("InstanceNumber", PropUInt32, uint32(~0), InstanceNumber); property ("InstanceNumber", PropUInt32, std::numeric_limits<uint32>::max(), InstanceNumber);
propertyCont ("Groups", PropUInt32, Groups); propertyCont ("Groups", PropUInt32, Groups);
property ("TeamId", PropUInt16, CTEAM::InvalidTeamId, TeamId); property ("TeamId", PropUInt16, CTEAM::InvalidTeamId, TeamId);
} }

View file

@ -47,7 +47,7 @@ public:
virtual void description () virtual void description ()
{ {
className ("CPetSpawnMsg"); className ("CPetSpawnMsg");
property ("AIInstanceId", PropUInt32, (uint32)~0, AIInstanceId); property ("AIInstanceId", PropUInt32, std::numeric_limits<uint32>::max(), AIInstanceId);
property ("SpawnMode", PropUInt16, (uint16)NEAR_PLAYER, SpawnMode); property ("SpawnMode", PropUInt16, (uint16)NEAR_PLAYER, SpawnMode);
property ("CharacterMirrorRow", PropDataSetRow, TDataSetRow(), CharacterMirrorRow); property ("CharacterMirrorRow", PropDataSetRow, TDataSetRow(), CharacterMirrorRow);
property ("PetSheetId", PropSheetId, NLMISC::CSheetId::Unknown, PetSheetId); property ("PetSheetId", PropSheetId, NLMISC::CSheetId::Unknown, PetSheetId);

View file

@ -147,8 +147,8 @@ namespace R2_VISION
void CUniverse::createInstance(uint32 aiInstance, uint32 groupId) void CUniverse::createInstance(uint32 aiInstance, uint32 groupId)
{ {
// just ignore attempts to create the ~0u instance // just ignore attempts to create the std::numeric_limits<uint32>::max() instance
if (aiInstance==~0u) if (aiInstance==std::numeric_limits<uint32>::max())
{ {
return; return;
} }
@ -172,8 +172,8 @@ namespace R2_VISION
void CUniverse::removeInstance(uint32 aiInstance) void CUniverse::removeInstance(uint32 aiInstance)
{ {
// just ignore attempts to remove the ~0u instance // just ignore attempts to remove the std::numeric_limits<uint32>::max() instance
if (aiInstance==~0u) if (aiInstance==std::numeric_limits<uint32>::max())
{ {
return; return;
} }
@ -227,7 +227,7 @@ namespace R2_VISION
SUniverseEntity& theEntity= _Entities[row]; SUniverseEntity& theEntity= _Entities[row];
// if the entity was already allocated then remove it // if the entity was already allocated then remove it
if (theEntity.AIInstance == ~0u) { return; } if (theEntity.AIInstance == std::numeric_limits<uint32>::max()) { return; }
if ( theEntity.ViewerRecord) 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); 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 // ensure that the new AIInstance exists
BOMB_IF(aiInstance!=~0u && (aiInstance>=_Instances.size() || _Instances[aiInstance]==NULL), BOMB_IF(aiInstance!=std::numeric_limits<uint32>::max() && (aiInstance>=_Instances.size() || _Instances[aiInstance]==NULL),
NLMISC::toString("ERROR: Failed to add entity %d to un-initialised instance: %d",row,aiInstance),aiInstance=~0u); NLMISC::toString("ERROR: Failed to add entity %d to un-initialised instance: %d",row,aiInstance),aiInstance=std::numeric_limits<uint32>::max());
// delegate to workhorse routine (converting y coordinate to +ve axis) // delegate to workhorse routine (converting y coordinate to +ve axis)
_teleportEntity(dataSetRow,aiInstance,x,-y,invisibilityLevel); _teleportEntity(dataSetRow,aiInstance,x,-y,invisibilityLevel);
@ -429,7 +429,7 @@ namespace R2_VISION
SUniverseEntity& theEntity= _Entities[row]; SUniverseEntity& theEntity= _Entities[row];
// if the entity was already allocated then remove it // if the entity was already allocated then remove it
if (theEntity.AIInstance!=~0u) if (theEntity.AIInstance!=std::numeric_limits<uint32>::max())
{ {
_removeEntity(dataSetRow); _removeEntity(dataSetRow);
} }
@ -455,7 +455,7 @@ namespace R2_VISION
{ {
// detach the entity from the instance it's currently in // detach the entity from the instance it's currently in
_Instances[theEntity.AIInstance]->removeEntity(theEntity); _Instances[theEntity.AIInstance]->removeEntity(theEntity);
theEntity.AIInstance= ~0u; theEntity.AIInstance= std::numeric_limits<uint32>::max();
theEntity.ViewerRecord= NULL; theEntity.ViewerRecord= NULL;
} }
} }
@ -466,8 +466,8 @@ namespace R2_VISION
SUniverseEntity& theEntity= _Entities[dataSetRow.getIndex()]; SUniverseEntity& theEntity= _Entities[dataSetRow.getIndex()];
#ifdef NL_DEBUG #ifdef NL_DEBUG
nlassert(theEntity.AIInstance==~0u || theEntity.AIInstance<_Instances.size()); nlassert(theEntity.AIInstance==std::numeric_limits<uint32>::max() || theEntity.AIInstance<_Instances.size());
nlassert(theEntity.AIInstance==~0u || _Instances[theEntity.AIInstance]!=NULL); nlassert(theEntity.AIInstance==std::numeric_limits<uint32>::max() || _Instances[theEntity.AIInstance]!=NULL);
#endif #endif
// if the entity is a viewer then move the view coordinates // 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 the entity is not currently in an AIInstance then stop here
if (theEntity.AIInstance==~0u) if (theEntity.AIInstance==std::numeric_limits<uint32>::max())
return; return;
// set the instance entity record position // set the instance entity record position
@ -498,10 +498,10 @@ namespace R2_VISION
// set the new AIInstance value for the entity // set the new AIInstance value for the entity
theEntity.AIInstance= aiInstance; theEntity.AIInstance= aiInstance;
// if the aiInstance is set to ~0u (a reserved value) then we stop here // if the aiInstance is set to std::numeric_limits<uint32>::max() (a reserved value) then we stop here
if (aiInstance==~0u) if (aiInstance==std::numeric_limits<uint32>::max())
{ {
// clear out the vision for an entity in aiInstance ~0u // clear out the vision for an entity in aiInstance std::numeric_limits<uint32>::max()
if (getEntity(dataSetRow)->ViewerRecord!=NULL) if (getEntity(dataSetRow)->ViewerRecord!=NULL)
{ {
TVision emptyVision(2); TVision emptyVision(2);
@ -785,7 +785,7 @@ namespace R2_VISION
// locate the old vision group (the one we're allocated to before isolation) // locate the old vision group (the one we're allocated to before isolation)
uint32 visionId= viewerRecord->VisionId; uint32 visionId= viewerRecord->VisionId;
NLMISC::CSmartPtr<CVisionGroup>& oldVisionGroup= _VisionGroups[visionId]; NLMISC::CSmartPtr<CVisionGroup>& 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<uint32>::max();return);
// if we're the only viewer then already isolated so just return // if we're the only viewer then already isolated so just return
if (oldVisionGroup->numViewers()==1) if (oldVisionGroup->numViewers()==1)
@ -830,7 +830,7 @@ namespace R2_VISION
if (viewerRecord!=NULL) if (viewerRecord!=NULL)
{ {
uint32 visionId= viewerRecord->VisionId; 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<uint32>::max();return);
_VisionGroups[visionId]->removeViewer(viewerRecord); _VisionGroups[visionId]->removeViewer(viewerRecord);
} }
@ -847,8 +847,8 @@ namespace R2_VISION
_Entities.pop_back(); _Entities.pop_back();
// invalidate the InstanceIndex value for the entity we just removed // invalidate the InstanceIndex value for the entity we just removed
entity.InstanceIndex=~0u; entity.InstanceIndex=std::numeric_limits<uint32>::max();
entity.AIInstance=~0u; entity.AIInstance=std::numeric_limits<uint32>::max();
} }
void CInstance::release() void CInstance::release()
@ -899,11 +899,11 @@ namespace R2_VISION
CVisionGroup::CVisionGroup() CVisionGroup::CVisionGroup()
{ {
_XMin=~0u; _XMin=std::numeric_limits<uint32>::max();
_XMax=0; _XMax=0;
_YMin=~0u; _YMin=std::numeric_limits<uint32>::max();
_YMax=0; _YMax=0;
_VisionId=~0u; _VisionId=std::numeric_limits<uint32>::max();
// setup the dummy entry in the vision buffer // setup the dummy entry in the vision buffer
_Vision.reserve(AllocatedVisionVectorSize); _Vision.reserve(AllocatedVisionVectorSize);
vectAppend(_Vision).DataSetRow= ZeroDataSetRow; vectAppend(_Vision).DataSetRow= ZeroDataSetRow;
@ -923,8 +923,8 @@ namespace R2_VISION
// ensure that the viewer wasn't aleady attached to another vision group // ensure that the viewer wasn't aleady attached to another vision group
#ifdef NL_DEBUG #ifdef NL_DEBUG
nlassert(viewer!=NULL); nlassert(viewer!=NULL);
nlassert(viewer->VisionId==~0u); nlassert(viewer->VisionId==std::numeric_limits<uint32>::max());
nlassert(viewer->VisionIndex==~0u); nlassert(viewer->VisionIndex==std::numeric_limits<uint32>::max());
#endif #endif
TEST(("add viewer %d to grp %d",viewer->getViewerId().getIndex(),_VisionId)); 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 // pop the back entry off the vector and flag oursleves as unused
_Viewers.pop_back(); _Viewers.pop_back();
viewer->VisionId= ~0u; viewer->VisionId= std::numeric_limits<uint32>::max();
viewer->VisionIndex= ~0u; viewer->VisionIndex= std::numeric_limits<uint32>::max();
// NOTE: after this the boundary may be out of date - this will be recalculated at the next // 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 // vision update so we don't take time to do it here
@ -1171,8 +1171,8 @@ namespace R2_VISION
return; return;
// calculate the bouding box for our viewers // calculate the bouding box for our viewers
uint32 xmin= ~0u; uint32 xmin= std::numeric_limits<uint32>::max();
uint32 ymin= ~0u; uint32 ymin= std::numeric_limits<uint32>::max();
uint32 xmax= 0; uint32 xmax= 0;
uint32 ymax= 0; uint32 ymax= 0;
for (uint32 i=(uint32)_Viewers.size();i--;) 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 // reset the vision vector and add in the dummy entry with DataSetRow=0
_Vision.resize(AllocatedVisionVectorSize); _Vision.resize(AllocatedVisionVectorSize);
_Vision[0].DataSetRow= ZeroDataSetRow; _Vision[0].DataSetRow= ZeroDataSetRow;
_Vision[0].VisionSlot= ~0u; _Vision[0].VisionSlot= std::numeric_limits<uint32>::max();
// setup a vision slot iterator for filling in the vision buffer (=1 to skip passed the dummy entry) // setup a vision slot iterator for filling in the vision buffer (=1 to skip passed the dummy entry)
uint32 nextVisionSlot=1; uint32 nextVisionSlot=1;
@ -1380,8 +1380,8 @@ namespace R2_VISION
CViewer::CViewer() CViewer::CViewer()
{ {
VisionId=~0u; VisionId=std::numeric_limits<uint32>::max();
VisionIndex=~0u; VisionIndex=std::numeric_limits<uint32>::max();
_VisionResetCount= 0; _VisionResetCount= 0;
} }
@ -1399,7 +1399,7 @@ namespace R2_VISION
// setup the dummy entry with DataSetRow=0 // setup the dummy entry with DataSetRow=0
_Vision[0].DataSetRow= ZeroDataSetRow; _Vision[0].DataSetRow= ZeroDataSetRow;
_Vision[0].VisionSlot= ~0u; _Vision[0].VisionSlot= std::numeric_limits<uint32>::max();
// setup the vision slots in reverse order from 254..0 (because they're popped from the back) // setup the vision slots in reverse order from 254..0 (because they're popped from the back)
_FreeVisionSlots.clear(); _FreeVisionSlots.clear();

View file

@ -140,7 +140,7 @@ namespace R2_VISION
// ctor // ctor
SViewedEntity() SViewedEntity()
{ {
VisionSlot=~0u; VisionSlot=std::numeric_limits<uint32>::max();
} }
}; };
@ -196,15 +196,15 @@ namespace R2_VISION
struct SUniverseEntity struct SUniverseEntity
{ {
TDataSetRow DataSetRow; // the complete data set row for the entity 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<uint32>::max() by default)
mutable uint32 InstanceIndex; // the index within the instance's _Entities vector mutable uint32 InstanceIndex; // the index within the instance's _Entities vector
NLMISC::CSmartPtr<CViewer> ViewerRecord; // pointer to the CViewer record for viewers (or NULL) NLMISC::CSmartPtr<CViewer> ViewerRecord; // pointer to the CViewer record for viewers (or NULL)
// ctor // ctor
SUniverseEntity() SUniverseEntity()
{ {
AIInstance=~0u; AIInstance=std::numeric_limits<uint32>::max();
InstanceIndex=~0u; InstanceIndex=std::numeric_limits<uint32>::max();
} }
}; };

View file

@ -105,7 +105,7 @@ uint32 CUsedContinent::getInstanceForContinent(const std::string &continentName)
if (it != _Continents.end()) if (it != _Continents.end())
return it->ContinentInstance; return it->ContinentInstance;
else else
return ~0; return std::numeric_limits<uint32>::max();
} }
uint32 CUsedContinent::getInstanceForContinent(CONTINENT::TContinent continentEnum) const uint32 CUsedContinent::getInstanceForContinent(CONTINENT::TContinent continentEnum) const
@ -115,7 +115,7 @@ uint32 CUsedContinent::getInstanceForContinent(CONTINENT::TContinent continentEn
if (it != _Continents.end()) if (it != _Continents.end())
return it->ContinentInstance; return it->ContinentInstance;
else else
return ~0; return std::numeric_limits<uint32>::max();
} }
const std::string &CUsedContinent::getContinentForInstance(uint32 instanceNumber) const const std::string &CUsedContinent::getContinentForInstance(uint32 instanceNumber) const

View file

@ -60,12 +60,12 @@ public:
bool isContinentUsed(const std::string &continentName) const; bool isContinentUsed(const std::string &continentName) const;
/** Return the static instance number associated with a continent name. /** 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<uint32>::max()
*/ */
uint32 getInstanceForContinent(const std::string &continentName) const; uint32 getInstanceForContinent(const std::string &continentName) const;
/** Return the static instance number associated with a continent enum value /** 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<uint32>::max()
*/ */
uint32 getInstanceForContinent(CONTINENT::TContinent continentEnum) const; uint32 getInstanceForContinent(CONTINENT::TContinent continentEnum) const;

View file

@ -365,7 +365,7 @@ namespace CHARSYNC
for (; first != last; ++first) for (; first != last; ++first)
{ {
// default to no limit // default to no limit
uint32 limit=~0u; uint32 limit=std::numeric_limits<uint32>::max();
// if there's a limit in the limis map then use it instead... // if there's a limit in the limis map then use it instead...
if (limitsMap.find(first->first)!=limitsMap.end()) if (limitsMap.find(first->first)!=limitsMap.end())

View file

@ -472,7 +472,7 @@ void CRangeList::acquireFirstRow()
*/ */
bool CRangeList::acquireRange( NLNET::TServiceId ownerServiceId, NLNET::TServiceId mirrorServiceId, sint32 nbRows, TDataSetIndex *first, TDataSetIndex *last ) bool CRangeList::acquireRange( NLNET::TServiceId ownerServiceId, NLNET::TServiceId mirrorServiceId, sint32 nbRows, TDataSetIndex *first, TDataSetIndex *last )
{ {
TDataSetIndex prevlast(~0); TDataSetIndex prevlast(std::numeric_limits<uint32>::max());
TRangeList::iterator irl = _RangeList.begin(); TRangeList::iterator irl = _RangeList.begin();
// Find a compatible range // Find a compatible range

View file

@ -46,7 +46,7 @@ class CRangeList
public: public:
/// Default constructor /// Default constructor
CRangeList() : _TotalMaxRows(~0) { acquireFirstRow(); } CRangeList() : _TotalMaxRows(std::numeric_limits<sint32>::max()) { acquireFirstRow(); }
/// Constructor /// Constructor
CRangeList( sint32 totalMaxRows ) : _TotalMaxRows( totalMaxRows ) { acquireFirstRow(); } CRangeList( sint32 totalMaxRows ) : _TotalMaxRows( totalMaxRows ) { acquireFirstRow(); }

View file

@ -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<uint16>::max()), false ) {}
/* /*
@ -904,7 +904,7 @@ void CTickServiceGameCycleTimeMeasure::displayStat( NLMISC::CLog *log, TTimeMeas
uint divideBy = (HistoryMain.NbMeasures==0) ? 0 : ((stat==MHTSum) ? HistoryMain.NbMeasures : 1); uint divideBy = (HistoryMain.NbMeasures==0) ? 0 : ((stat==MHTSum) ? HistoryMain.NbMeasures : 1);
HistoryMain.Stats[stat].displayStat( log, TickServiceTimeMeasureTypeToCString, divideBy ); HistoryMain.Stats[stat].displayStat( log, TickServiceTimeMeasureTypeToCString, divideBy );
{ {
CMirrorTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; CMirrorTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, std::numeric_limits<uint16>::max(), 0 };
for ( std::vector<CMirrorTimeMeasureHistory>::const_iterator ihm=HistoryByMirror.begin(); ihm!=HistoryByMirror.end(); ++ihm ) for ( std::vector<CMirrorTimeMeasureHistory>::const_iterator ihm=HistoryByMirror.begin(); ihm!=HistoryByMirror.end(); ++ihm )
{ {
log->displayRawNL( "\tMS-%hu, %u measures:", (*ihm).ServiceId.get(), (*ihm).NbMeasures ); 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<uint16>::max(), 0 };
for ( std::vector<CServiceTimeMeasureHistory>::const_iterator ihs=HistoryByService.begin(); ihs!=HistoryByService.end(); ++ihs ) for ( std::vector<CServiceTimeMeasureHistory>::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 ); log->displayRawNL( "\t%s (on MS-%hu), %u measures:", CUnifiedNetwork::getInstance()->getServiceUnifiedName( (*ihs).ServiceId ).c_str(), (*ihs).ParentServiceId.get(), (*ihs).NbMeasures );

View file

@ -113,7 +113,7 @@ public:
NbMeasures = 0; NbMeasures = 0;
Stats.resize( NbTimeMeasureHistoryStats ); Stats.resize( NbTimeMeasureHistoryStats );
Stats[MHTSum] = 0; Stats[MHTSum] = 0;
Stats[MHTMin] = ~0; Stats[MHTMin] = std::numeric_limits<T>::max();
Stats[MHTMax] = 0; Stats[MHTMax] = 0;
} }
} }

View file

@ -55,17 +55,17 @@ public:
* Display the item as a row of a HTML table. * 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 * 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<uint32>::max(), column used for sorting => this column displays only the field matching the key
* \param key The key used for sorting (see keyColumn) * \param key The key used for sorting (see keyColumn)
* \param previousKey Previous key * \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<uint32>::max(), column used for the unique name (column must have exaclty one element)
* \param previousName Previous name * \param previousName Previous name
*/ */
std::string toHTMLRow( uint32 keyColumn=~0, const string& key=string(), const string& previousKey=string(), std::string toHTMLRow( uint32 keyColumn=std::numeric_limits<uint32>::max(), const string& key=string(), const string& previousKey=string(),
uint32 nameColumn=~0, const string& previousName=string() ) const uint32 nameColumn=std::numeric_limits<uint32>::max(), const string& previousName=string() ) const
{ {
std::string s = "<tr>"; std::string s = "<tr>";
bool lightMode = (nameColumn == ~0) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName)); bool lightMode = (nameColumn == std::numeric_limits<uint32>::max()) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName));
for ( uint32 c=0; c!=NC; ++c ) for ( uint32 c=0; c!=NC; ++c )
{ {
s += "<td>"; s += "<td>";
@ -86,11 +86,11 @@ public:
/// ///
std::string toCSVLine( char columnSeparator=',', string internalSeparator=" - ", uint32 keyColumn=~0, const string& key=string(), const string& previousKey=string(), std::string toCSVLine( char columnSeparator=',', string internalSeparator=" - ", uint32 keyColumn=std::numeric_limits<uint32>::max(), const string& key=string(), const string& previousKey=string(),
uint32 nameColumn=~0, const string& previousName=string() ) const uint32 nameColumn=std::numeric_limits<uint32>::max(), const string& previousName=string() ) const
{ {
std::string s; std::string s;
bool lightMode = (nameColumn == ~0) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName)); bool lightMode = (nameColumn == std::numeric_limits<uint32>::max()) ? false : ((key != previousKey) && (Fields[nameColumn][0] == previousName));
for ( uint32 c=0; c!=NC; ++c ) for ( uint32 c=0; c!=NC; ++c )
{ {
if ( c == keyColumn ) if ( c == keyColumn )

View file

@ -149,7 +149,7 @@ CPackageDescription::CPackageDescription()
void CPackageDescription::clear() void CPackageDescription::clear()
{ {
_NextVersionNumber= ~0u; _NextVersionNumber= std::numeric_limits<uint32>::max();
_VersionNumberReserved = false; _VersionNumberReserved = false;
_Categories.clear(); _Categories.clear();
_IndexFileName.clear(); _IndexFileName.clear();

View file

@ -237,8 +237,8 @@ CProximityZone::CProximityZone(uint32 scanWidth,uint32 scanHeight,sint32 xOffset
_MaxOffset = scanWidth * scanHeight -1; _MaxOffset = scanWidth * scanHeight -1;
_XMin = ~0u; _XMin = std::numeric_limits<uint32>::max();
_YMin = ~0u; _YMin = std::numeric_limits<uint32>::max();
_XMax = 0; _XMax = 0;
_YMax = 0; _YMax = 0;
} }
@ -386,7 +386,7 @@ void CProximityMapBuffer::load(const std::string& name)
} }
} }
// setup the next pixel in the output buffers... // 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<uint16>::max());
} }
} }
} }
@ -471,7 +471,7 @@ void CProximityMapBuffer::_prepareBufferForZoneProximityMap(const CProximityZone
uint32 zoneWidth= zone.getZoneWidth(); uint32 zoneWidth= zone.getZoneWidth();
uint32 zoneHeight= zone.getZoneHeight(); uint32 zoneHeight= zone.getZoneHeight();
zoneBuffer.clear(); zoneBuffer.clear();
zoneBuffer.resize(zoneWidth*zoneHeight,(TBufferEntry)~0u); zoneBuffer.resize(zoneWidth*zoneHeight,(TBufferEntry)std::numeric_limits<uint16>::max());
// setup the buffer's accessible points and prime vects[0] with the set of accessible points in the zone buffer // 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<zone.getOffsets().size();++i) for (uint32 i=0;i<zone.getOffsets().size();++i)

View file

@ -443,7 +443,7 @@ void CPackedWorldBuilder::fly(std::vector<CIslandInfo> &islands, float camSpeed
texturedMaterial.setDoubleSided(true); texturedMaterial.setDoubleSided(true);
texturedMaterial.setZFunc(CMaterial::lessequal); texturedMaterial.setZFunc(CMaterial::lessequal);
// //
uint currWorldIndex = ~0; uint currWorldIndex = std::numeric_limits<uint>::max();
bool newPosWanted = true; bool newPosWanted = true;
// //
std::vector<TPackedZoneBaseSPtr> zones; std::vector<TPackedZoneBaseSPtr> zones;