From 3a3a8752d13c4203772c5f175045e0328cdeda00 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 15 Dec 2015 14:33:59 +0100 Subject: [PATCH] Changed: Replace (uint16)~0 by std::numeric_limits::max() --HG-- branch : develop --- code/ryzom/common/src/game_share/base_types.h | 5 ++-- .../src/game_share/change_tracker_base.h | 2 +- .../src/game_share/mirrored_data_set_inline.h | 3 +- .../src/game_share/persistent_data_template.h | 28 +++++++++---------- .../game_share/property_allocator_client.h | 4 ++- .../server/src/ai_service/ai_world_map.h | 2 +- .../src/entities_game_service/deposit.h | 2 +- .../egs_sheets/egs_static_emot.h | 2 +- .../egs_sheets/egs_static_text_emotes.h | 2 +- .../phrase_manager/special_power_phrase.cpp | 2 +- .../special_power_shielding.cpp | 2 +- .../phrase_manager/special_power_taunt.cpp | 2 +- .../player_manager/character.cpp | 4 +-- .../player_manager/powers_and_auras.cpp | 6 ++-- .../player_manager/powers_and_auras.h | 2 +- 15 files changed, 36 insertions(+), 32 deletions(-) diff --git a/code/ryzom/common/src/game_share/base_types.h b/code/ryzom/common/src/game_share/base_types.h index f24daa69a..b1b0dc1e5 100644 --- a/code/ryzom/common/src/game_share/base_types.h +++ b/code/ryzom/common/src/game_share/base_types.h @@ -24,6 +24,7 @@ #include "nel/misc/types_nl.h" #include "nel/net/unified_network.h" +#include /* * Types for options of CMirroredDataSet::declareProperty() @@ -374,13 +375,13 @@ const TPropertyIndex INVALID_PROPERTY_INDEX = (TPropertyIndex)~0; #ifdef MIRROR_LIST_ROW_32BITS typedef uint32 TSharedListRow; -const TSharedListRow INVALID_SHAREDLIST_ROW = ~0; //((uint16)~0)-1; +const TSharedListRow INVALID_SHAREDLIST_ROW = std::numeric_limits::max(); // std::numeric_limits::max()-1; const uint NB_SHAREDLIST_CELLS = 500000; // property+list container footprint with data size of 32 bit and 500000 rows: 5.8 MB #else typedef uint16 TSharedListRow; -const TSharedListRow INVALID_SHAREDLIST_ROW = ((uint16)~0)-1; +const TSharedListRow INVALID_SHAREDLIST_ROW = std::numeric_limits::max()-1; const uint NB_SHAREDLIST_CELLS = INVALID_SHAREDLIST_ROW; // property+list container footprint with data size of 32 bit and 500000 rows: 1.3 MB #endif diff --git a/code/ryzom/common/src/game_share/change_tracker_base.h b/code/ryzom/common/src/game_share/change_tracker_base.h index 47ff79c3e..70298aadf 100644 --- a/code/ryzom/common/src/game_share/change_tracker_base.h +++ b/code/ryzom/common/src/game_share/change_tracker_base.h @@ -68,7 +68,7 @@ struct TChangeTrackerHeader }; -const uint16 LOCAL_TRACKER_SERVICE_ID = (uint16)~0; +const uint16 LOCAL_TRACKER_SERVICE_ID = std::numeric_limits::max(); /** * Item in a tracker diff --git a/code/ryzom/common/src/game_share/mirrored_data_set_inline.h b/code/ryzom/common/src/game_share/mirrored_data_set_inline.h index 518d2ede4..50ab076b7 100644 --- a/code/ryzom/common/src/game_share/mirrored_data_set_inline.h +++ b/code/ryzom/common/src/game_share/mirrored_data_set_inline.h @@ -22,6 +22,7 @@ #include //#include +#include const uint MAX_NB_DATASETS = 4; extern bool VerboseWarnWhenMirrorReturningUnknownEntityId; @@ -260,7 +261,7 @@ inline uint16 datasetToBitIndex( CMirroredDataSet *dataSet ) if ( DataSetQuickArray[i] == dataSet ) return (uint16)i; } - return (uint16)~0; + return std::numeric_limits::max(); } diff --git a/code/ryzom/common/src/game_share/persistent_data_template.h b/code/ryzom/common/src/game_share/persistent_data_template.h index 560603f0a..0115febef 100644 --- a/code/ryzom/common/src/game_share/persistent_data_template.h +++ b/code/ryzom/common/src/game_share/persistent_data_template.h @@ -370,13 +370,13 @@ void PERSISTENT_CLASS::store(CPersistentDataRecord &pdr _PERSISTENT_STORE_ARGS) #else // define the set of tokens - this makes sure that the tokens exist in the map and that we only look them up the once - static uint16 __Tok__MapKey= (uint16)~0u; pdr.addString("__Key__",__Tok__MapKey); - static uint16 __Tok__MapVal= (uint16)~0u; pdr.addString("__Val__",__Tok__MapVal); - #define _PROP(token,name,type,logic,get,set) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _STRUCT(token,name,logic,write,read) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _PROP_MAP(token,name,keyType,valType,logic,getKey,getVal,set) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _STRUCT_MAP(token,name,keyType,logic,getKey,valWrite,read) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _FLAG(token,name,logic,code) static uint16 token= (uint16)~0u; pdr.addString(name,token); + static uint16 __Tok__MapKey = std::numeric_limits::max(); pdr.addString("__Key__",__Tok__MapKey); + static uint16 __Tok__MapVal = std::numeric_limits::max(); pdr.addString("__Val__",__Tok__MapVal); + #define _PROP(token,name,type,logic,get,set) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _STRUCT(token,name,logic,write,read) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _PROP_MAP(token,name,keyType,valType,logic,getKey,getVal,set) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _STRUCT_MAP(token,name,keyType,logic,getKey,valWrite,read) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _FLAG(token,name,logic,code) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); PERSISTENT_DATA #undef _PROP #undef _STRUCT @@ -471,13 +471,13 @@ void PERSISTENT_CLASS::apply(CPersistentDataRecord &pdr _PERSISTENT_APPLY_ARGS) #endif // define the set of tokens - this makes sure that the tokens exist in the map and that we only look them up the once - static uint16 __Tok__MapKey= (uint16)~0u; pdr.addString("__Key__",__Tok__MapKey); - static uint16 __Tok__MapVal= (uint16)~0u; pdr.addString("__Val__",__Tok__MapVal); - #define _PROP(token,name,type,logic,get,set) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _STRUCT(token,name,logic,write,read) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _PROP_MAP(token,name,keyType,valType,logic,getKey,getVal,set) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _STRUCT_MAP(token,name,keyType,logic,getKey,valWrite,read) static uint16 token= (uint16)~0u; pdr.addString(name,token); - #define _FLAG(token,name,logic,code) static uint16 token= (uint16)~0u; pdr.addString(name,token); + static uint16 __Tok__MapKey = std::numeric_limits::max(); pdr.addString("__Key__",__Tok__MapKey); + static uint16 __Tok__MapVal = std::numeric_limits::max(); pdr.addString("__Val__",__Tok__MapVal); + #define _PROP(token,name,type,logic,get,set) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _STRUCT(token,name,logic,write,read) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _PROP_MAP(token,name,keyType,valType,logic,getKey,getVal,set) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _STRUCT_MAP(token,name,keyType,logic,getKey,valWrite,read) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); + #define _FLAG(token,name,logic,code) static uint16 token = std::numeric_limits::max(); pdr.addString(name,token); PERSISTENT_DATA #undef _PROP #undef _STRUCT diff --git a/code/ryzom/common/src/game_share/property_allocator_client.h b/code/ryzom/common/src/game_share/property_allocator_client.h index 1ab7bc73b..8d0b00857 100644 --- a/code/ryzom/common/src/game_share/property_allocator_client.h +++ b/code/ryzom/common/src/game_share/property_allocator_client.h @@ -23,6 +23,8 @@ #include "property_allocator.h" +#include + namespace NLNET { class CMessage; @@ -40,7 +42,7 @@ class CPropertyAllocatorClient : public CPropertyAllocator public: /// Constructor - CPropertyAllocatorClient() : _LocalMSId((uint16)~0) {} + CPropertyAllocatorClient() : _LocalMSId(std::numeric_limits::max()) {} /** Ask to allocate, if not done yet, a segment for the specified property. * The pointer will be soon returned by getPropertySegment(), but not always 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 33d23bf16..724bd842f 100644 --- a/code/ryzom/server/src/ai_service/ai_world_map.h +++ b/code/ryzom/server/src/ai_service/ai_world_map.h @@ -228,7 +228,7 @@ inline CAIMapSurfaceNeighbour::CAIMapSurfaceNeighbour(bool isNoGo) // constructo nlassert(isNoGo=true); // by definition this code can't be executed with isNoGo false _surface=NULL; - _distance=(uint16)-1; + _distance = std::numeric_limits::max(); //bool _sameRegion=false; memset(_direction,0,sizeof(_direction)); } diff --git a/code/ryzom/server/src/entities_game_service/deposit.h b/code/ryzom/server/src/entities_game_service/deposit.h index 79b9e9e53..fee33662a 100644 --- a/code/ryzom/server/src/entities_game_service/deposit.h +++ b/code/ryzom/server/src/entities_game_service/deposit.h @@ -33,7 +33,7 @@ class CDeposit; -const uint16 MaxNbActiveSources = (uint16)~0; +const uint16 MaxNbActiveSources = std::numeric_limits::max(); /** * A recent forage site prevents from extracting too much material from the same place in a short time. diff --git a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_emot.h b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_emot.h index 7e9c93491..ce0c388ad 100644 --- a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_emot.h +++ b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_emot.h @@ -52,7 +52,7 @@ public: std::map::const_iterator it = _AnimIdMap.find(animId); if (it!=_AnimIdMap.end()) return (uint16)it->second; - return (uint16)~0; + return std::numeric_limits::max(); } /// Removed diff --git a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_text_emotes.h b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_text_emotes.h index 0819db53f..64b237d73 100644 --- a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_text_emotes.h +++ b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_text_emotes.h @@ -117,7 +117,7 @@ public: std::map::const_iterator it = _EmoteIdMap.find(emoteId); if (it!=_EmoteIdMap.end()) return (uint16)it->second; - return (uint16)~0; + return std::numeric_limits::max(); } MBEHAV::EBehaviour getEmoteBehav(const std::string& emoteId) const; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp index 8ef7532ec..84d4d31fb 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp @@ -61,7 +61,7 @@ CSpecialPowerPhrase::CSpecialPowerPhrase() _IsStatic = false; _AddRecastTime = 0; _PhraseType = BRICK_TYPE::SPECIAL_POWER; - _ConsumableFamilyId = (uint16)~0; + _ConsumableFamilyId = std::numeric_limits::max(); } //----------------------------------------------- diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_shielding.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_shielding.cpp index f02acb3d7..36422f517 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_shielding.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_shielding.cpp @@ -54,7 +54,7 @@ bool CSpecialPowerShielding::validate(std::string &errorCode) } TGameCycle endDate; - if (!actor->canUsePower(_PowerType, (uint16)~0, endDate)) + if (!actor->canUsePower(_PowerType, std::numeric_limits::max(), endDate)) { uint16 seconds = uint16((endDate - CTickEventHandler::getGameCycle())*CTickEventHandler::getGameTimeStep()); uint8 minutes = uint8(seconds/60); diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_taunt.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_taunt.cpp index 6ffef15b7..86547178a 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_taunt.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_taunt.cpp @@ -66,7 +66,7 @@ bool CSpecialPowerTaunt::validate(std::string &errorCode) } TGameCycle endDate; - if (!actor->canUsePower(_PowerType, (uint16)~0, endDate)) + if (!actor->canUsePower(_PowerType, std::numeric_limits::max(), endDate)) { uint16 seconds = uint16( (endDate - CTickEventHandler::getGameCycle())*CTickEventHandler::getGameTimeStep() ); uint8 minutes = uint8(seconds/60); diff --git a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp index b5cb58a07..0945983c6 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -2611,7 +2611,7 @@ void CCharacter::serial(NLMISC::IStream &f) throw(NLMISC::EStream) void CCharacter::setPositionToDefaultRespawnPoint() { CContinent * continent = CZoneManager::getInstance().getContinent( getX(), getY() ); - uint16 zoneId = (uint16)~0; + uint16 zoneId = std::numeric_limits::max(); if( continent == 0 ) { nlwarning("::max() ) { // get the tp coords const CTpSpawnZone* zone = CZoneManager::getInstance().getTpSpawnZone( zoneId ); diff --git a/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.cpp b/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.cpp index 1939f21b3..7c9108bc6 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.cpp @@ -60,7 +60,7 @@ void CPowerActivationDateVector::clearConsumable() { for(sint32 i = (sint32)PowerActivationDates.size()-1; i >= 0; --i ) { - if (PowerActivationDates[i].ConsumableFamilyId != (uint16)~0) + if (PowerActivationDates[i].ConsumableFamilyId != std::numeric_limits::max()) { PowerActivationDates[i] = PowerActivationDates[PowerActivationDates.size()-1]; PowerActivationDates.pop_back(); @@ -117,7 +117,7 @@ bool CPowerActivationDateVector::isPowerAllowed(POWERS::TPowerType type, uint16 } else { - if ( (*it).PowerType == type || ((*it).ConsumableFamilyId != (uint16)~0 && (*it).ConsumableFamilyId == consumableFamilyId)) + if ( (*it).PowerType == type || ((*it).ConsumableFamilyId != std::numeric_limits::max() && (*it).ConsumableFamilyId == consumableFamilyId)) { endDate = (*it).ActivationDate; result = false; @@ -195,7 +195,7 @@ void CAuraActivationDateVector::clear() //----------------------------------------------------------------------------- void CAuraActivationDateVector::disableAura(POWERS::TPowerType type, NLMISC::TGameCycle startDate, NLMISC::TGameCycle endDate, const NLMISC::CEntityId &userId) { - _AuraActivationDates.push_back( CPowerActivationDate(type,(uint16)~0, startDate, endDate) ); + _AuraActivationDates.push_back( CPowerActivationDate(type, std::numeric_limits::max(), startDate, endDate) ); _AuraUsers.push_back(userId); } diff --git a/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.h b/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.h index 829167fd6..8061d91b1 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/powers_and_auras.h @@ -37,7 +37,7 @@ struct CPowerActivationDate NLMISC::TGameCycle DeactivationDate; NLMISC::TGameCycle ActivationDate; - CPowerActivationDate() : PowerType(POWERS::UnknownType), ConsumableFamilyId((uint16)~0), DeactivationDate(0), ActivationDate(0) + CPowerActivationDate() : PowerType(POWERS::UnknownType), ConsumableFamilyId(std::numeric_limits::max()), DeactivationDate(0), ActivationDate(0) {} CPowerActivationDate(POWERS::TPowerType type, uint16 consumableFamilyId, NLMISC::TGameCycle dateOff, NLMISC::TGameCycle dateOn) : PowerType(type), ConsumableFamilyId(consumableFamilyId), DeactivationDate(dateOff), ActivationDate(dateOn)