From d05461a8379ba29b8f1ecbd4b68f7603680b5133 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 29 Mar 2015 16:58:07 +0200 Subject: [PATCH] Fixup some more hashes --- code/nel/include/nel/misc/entity_id.h | 6 +++++- code/nel/include/nel/misc/ucstring.h | 2 +- code/nel/include/nel/sound/context_sound.h | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/misc/entity_id.h b/code/nel/include/nel/misc/entity_id.h index b4e40909e..8c80daaba 100644 --- a/code/nel/include/nel/misc/entity_id.h +++ b/code/nel/include/nel/misc/entity_id.h @@ -580,7 +580,11 @@ struct CEntityIdHashMapTraits size_t operator() (const NLMISC::CEntityId &id ) const { uint64 hash64 = id.getUniqueId(); - return size_t(hash64) ^ size_t( hash64 >> 32 ); +#if (HAVE_X86_64) + return (size_t)hash64; +#else + return (size_t)hash64 ^ (size_t)(hash64 >> 32); +#endif //return size_t(id.getShortId()); } bool operator() (const NLMISC::CEntityId &id1, const NLMISC::CEntityId &id2) const diff --git a/code/nel/include/nel/misc/ucstring.h b/code/nel/include/nel/misc/ucstring.h index 88e599c1a..2f921f9ae 100644 --- a/code/nel/include/nel/misc/ucstring.h +++ b/code/nel/include/nel/misc/ucstring.h @@ -363,7 +363,7 @@ struct CUCStringHashMapTraits } bool operator() (const ucstring &id1, const ucstring &id2) const { - return id1.size() < id2.size(); + return id1 < id2; } }; diff --git a/code/nel/include/nel/sound/context_sound.h b/code/nel/include/nel/sound/context_sound.h index 8424ee087..eeb29b433 100644 --- a/code/nel/include/nel/sound/context_sound.h +++ b/code/nel/include/nel/sound/context_sound.h @@ -71,6 +71,19 @@ struct CContextMatcher return memcmp(JokersValues, other.JokersValues, sizeof(uint32)*NbJoker) == 0; } + bool operator<(const CContextMatcher &other) const + { + if (UseRandom) + if (RandomValue != other.RandomValue) + return RandomValue < other.RandomValue; + + int cmp = memcmp(JokersValues, other.JokersValues, sizeof(uint32) * NbJoker); + if (cmp != 0) + return cmp < 0; + + return false; + } + size_t getHashValue() const { return size_t(HashValue); @@ -89,10 +102,9 @@ struct CContextMatcher } bool operator() (const CContextMatcher &patternMatcher1, const CContextMatcher &patternMatcher2) const { - return patternMatcher1.getHashValue() < patternMatcher2.getHashValue(); + return patternMatcher1 < patternMatcher2; } }; - };