diff options
| -rw-r--r-- | src/common/Common.h | 15 | ||||
| -rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Conditions/ConditionMgr.h | 14 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellInfo.h | 2 |
4 files changed, 24 insertions, 9 deletions
diff --git a/src/common/Common.h b/src/common/Common.h index 6c94f461d2a..2a492e0eeee 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -179,4 +179,19 @@ namespace Trinity } } +//! Hash implementation for std::pair to allow using pairs in unordered_set or as key for unordered_map +//! Individual types used in pair must be hashable by boost::hash +namespace std +{ + template<class K, class V> + struct hash<std::pair<K, V>> + { + public: + size_t operator()(std::pair<K, V> const& key) const + { + return boost::hash_value(key); + } + }; +} + #endif diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 864b989e2b0..bb697dbdddb 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -2327,7 +2327,7 @@ void ConditionMgr::Clean() NpcVendorConditionContainerStore.clear(); // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;) - for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) + for (std::vector<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr; AllocatedMemoryStore.clear(); diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 3bf68142943..d34e8857696 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -234,13 +234,13 @@ struct Condition std::string ToString(bool ext = false) const; /// For logging purpose }; -typedef std::list<Condition*> ConditionContainer; -typedef std::map<uint32 /*SourceEntry*/, ConditionContainer> ConditionsByEntryMap; -typedef std::map<ConditionSourceType /*SourceType*/, ConditionsByEntryMap> ConditionEntriesByTypeMap; -typedef std::map<uint32, ConditionsByEntryMap> ConditionEntriesByCreatureIdMap; -typedef std::map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionsByEntryMap> SmartEventConditionContainer; +typedef std::vector<Condition*> ConditionContainer; +typedef std::unordered_map<uint32 /*SourceEntry*/, ConditionContainer> ConditionsByEntryMap; +typedef std::unordered_map<ConditionSourceType /*SourceType*/, ConditionsByEntryMap> ConditionEntriesByTypeMap; +typedef std::unordered_map<uint32, ConditionsByEntryMap> ConditionEntriesByCreatureIdMap; +typedef std::unordered_map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionsByEntryMap> SmartEventConditionContainer; -typedef std::map<uint32, ConditionContainer> ConditionReferenceContainer;//only used for references +typedef std::unordered_map<uint32, ConditionContainer> ConditionReferenceContainer;//only used for references class ConditionMgr { @@ -294,7 +294,7 @@ class ConditionMgr static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value); void Clean(); // free up resources - std::list<Condition*> AllocatedMemoryStore; // some garbage collection :) + std::vector<Condition*> AllocatedMemoryStore; // some garbage collection :) ConditionEntriesByTypeMap ConditionStore; ConditionReferenceContainer ConditionReferenceStore; diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 86d8addfbdb..6a56b876ccc 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -263,7 +263,7 @@ public: uint32 TriggerSpell; flag128 SpellClassMask; float BonusCoefficientFromAP; - std::list<Condition*>* ImplicitTargetConditions; + std::vector<Condition*>* ImplicitTargetConditions; // SpellScalingEntry struct ScalingInfo { |
