mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Conditions: Optimizations part 3 changed ConditionStore to a simple array
This commit is contained in:
@@ -818,15 +818,11 @@ bool ConditionMgr::IsObjectMeetingNotGroupedConditions(ConditionSourceType sourc
|
||||
{
|
||||
if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
|
||||
{
|
||||
ConditionEntriesByTypeMap::const_iterator itr = ConditionStore.find(sourceType);
|
||||
if (itr != ConditionStore.end())
|
||||
ConditionsByEntryMap::const_iterator i = ConditionStore[sourceType].find(entry);
|
||||
if (i != ConditionStore[sourceType].end())
|
||||
{
|
||||
ConditionsByEntryMap::const_iterator i = itr->second.find(entry);
|
||||
if (i != itr->second.end())
|
||||
{
|
||||
TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry);
|
||||
return IsObjectMeetToConditions(sourceInfo, i->second);
|
||||
}
|
||||
TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry);
|
||||
return IsObjectMeetToConditions(sourceInfo, i->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,12 +839,9 @@ bool ConditionMgr::HasConditionsForNotGroupedEntry(ConditionSourceType sourceTyp
|
||||
{
|
||||
ConditionContainer spellCond;
|
||||
if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
|
||||
{
|
||||
ConditionEntriesByTypeMap::const_iterator itr = ConditionStore.find(sourceType);
|
||||
if (itr != ConditionStore.end())
|
||||
if (itr->second.find(entry) != itr->second.end())
|
||||
return true;
|
||||
}
|
||||
if (ConditionStore[sourceType].find(entry) != ConditionStore[sourceType].end())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2263,12 +2256,14 @@ void ConditionMgr::Clean()
|
||||
|
||||
ConditionReferenceStore.clear();
|
||||
|
||||
for (ConditionEntriesByTypeMap::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
|
||||
for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
for (uint32 i = 0; i < CONDITION_SOURCE_TYPE_MAX; ++i)
|
||||
{
|
||||
for (ConditionsByEntryMap::iterator it = ConditionStore[i].begin(); it != ConditionStore[i].end(); ++it)
|
||||
for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
|
||||
ConditionStore.clear();
|
||||
ConditionStore[i].clear();
|
||||
}
|
||||
|
||||
for (ConditionEntriesByCreatureIdMap::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
|
||||
for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
|
||||
@@ -237,10 +237,9 @@ struct Condition
|
||||
|
||||
typedef std::vector<Condition*> ConditionContainer;
|
||||
typedef std::unordered_map<uint32 /*SourceEntry*/, ConditionContainer> ConditionsByEntryMap;
|
||||
typedef std::unordered_map<ConditionSourceType /*SourceType*/, ConditionsByEntryMap> ConditionEntriesByTypeMap;
|
||||
typedef std::array<ConditionsByEntryMap, CONDITION_SOURCE_TYPE_MAX> ConditionEntriesByTypeArray;
|
||||
typedef std::unordered_map<uint32, ConditionsByEntryMap> ConditionEntriesByCreatureIdMap;
|
||||
typedef std::unordered_map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionsByEntryMap> SmartEventConditionContainer;
|
||||
|
||||
typedef std::unordered_map<uint32, ConditionContainer> ConditionReferenceContainer;//only used for references
|
||||
|
||||
class ConditionMgr
|
||||
@@ -299,7 +298,7 @@ class ConditionMgr
|
||||
void Clean(); // free up resources
|
||||
std::vector<Condition*> AllocatedMemoryStore; // some garbage collection :)
|
||||
|
||||
ConditionEntriesByTypeMap ConditionStore;
|
||||
ConditionEntriesByTypeArray ConditionStore;
|
||||
ConditionReferenceContainer ConditionReferenceStore;
|
||||
ConditionEntriesByCreatureIdMap VehicleSpellConditionStore;
|
||||
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore;
|
||||
|
||||
Reference in New Issue
Block a user