mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/Conditions: Optimizations part 2 removed unneeded code
(cherry picked from commit e5c1e7d71c)
This commit is contained in:
@@ -663,15 +663,6 @@ ConditionMgr::~ConditionMgr()
|
||||
Clean();
|
||||
}
|
||||
|
||||
ConditionContainer ConditionMgr::GetConditionReferences(uint32 refId)
|
||||
{
|
||||
ConditionContainer conditions;
|
||||
ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
|
||||
if (ref != ConditionReferenceStore.end())
|
||||
conditions = (*ref).second;
|
||||
return conditions;
|
||||
}
|
||||
|
||||
uint32 ConditionMgr::GetSearcherTypeMaskForConditionList(ConditionContainer const& conditions)
|
||||
{
|
||||
if (conditions.empty())
|
||||
@@ -995,14 +986,8 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
|
||||
if (iSourceTypeOrReferenceId < 0)//it is a reference template
|
||||
{
|
||||
uint32 uRefId = abs(iSourceTypeOrReferenceId);
|
||||
if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end())//make sure we have a list for our conditions, based on reference id
|
||||
{
|
||||
ConditionContainer mCondList;
|
||||
ConditionReferenceStore[uRefId] = mCondList;
|
||||
}
|
||||
ConditionReferenceStore[uRefId].push_back(cond);//add to reference storage
|
||||
count++;
|
||||
ConditionReferenceStore[std::abs(iSourceTypeOrReferenceId)].push_back(cond);//add to reference storage
|
||||
++count;
|
||||
continue;
|
||||
}//end of reference templates
|
||||
|
||||
@@ -1138,20 +1123,6 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
}
|
||||
|
||||
//handle not grouped conditions
|
||||
//make sure we have a storage list for our SourceType
|
||||
if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
|
||||
{
|
||||
ConditionsByEntryMap mTypeMap;
|
||||
ConditionStore[cond->SourceType] = mTypeMap;//add new empty list for SourceType
|
||||
}
|
||||
|
||||
//make sure we have a condition list for our SourceType's entry
|
||||
if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
|
||||
{
|
||||
ConditionContainer mCondList;
|
||||
ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
|
||||
}
|
||||
|
||||
//add new Condition to storage based on Type/Entry
|
||||
ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
|
||||
++count;
|
||||
@@ -2113,76 +2084,43 @@ void ConditionMgr::LogUselessConditionValue(Condition* cond, uint8 index, uint32
|
||||
void ConditionMgr::Clean()
|
||||
{
|
||||
for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionContainer::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
delete *it;
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
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 (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
it->second.clear();
|
||||
}
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
ConditionStore.clear();
|
||||
|
||||
for (ConditionEntriesByCreatureIdMap::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
it->second.clear();
|
||||
}
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
VehicleSpellConditionStore.clear();
|
||||
|
||||
for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
it->second.clear();
|
||||
}
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
SmartEventConditionStore.clear();
|
||||
|
||||
for (ConditionEntriesByCreatureIdMap::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
it->second.clear();
|
||||
}
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
SpellClickEventConditionStore.clear();
|
||||
|
||||
for (ConditionEntriesByCreatureIdMap::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
it->second.clear();
|
||||
}
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
NpcVendorConditionContainerStore.clear();
|
||||
|
||||
|
||||
@@ -158,13 +158,13 @@ enum MaxConditionTargets
|
||||
struct ConditionSourceInfo
|
||||
{
|
||||
WorldObject* mConditionTargets[MAX_CONDITION_TARGETS]; // an array of targets available for conditions
|
||||
Condition* mLastFailedCondition;
|
||||
ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = NULL, WorldObject* target2 = NULL)
|
||||
Condition const* mLastFailedCondition;
|
||||
ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = nullptr, WorldObject* target2 = nullptr)
|
||||
{
|
||||
mConditionTargets[0] = target0;
|
||||
mConditionTargets[1] = target1;
|
||||
mConditionTargets[2] = target2;
|
||||
mLastFailedCondition = NULL;
|
||||
mLastFailedCondition = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -205,10 +205,10 @@ struct Condition
|
||||
NegativeCondition = false;
|
||||
}
|
||||
|
||||
bool Meets(ConditionSourceInfo& sourceInfo);
|
||||
uint32 GetSearcherTypeMaskForCondition();
|
||||
bool Meets(ConditionSourceInfo& sourceInfo) const;
|
||||
uint32 GetSearcherTypeMaskForCondition() const;
|
||||
bool isLoaded() const { return ConditionType > CONDITION_NONE || ReferenceId; }
|
||||
uint32 GetMaxAvailableConditionTargets();
|
||||
uint32 GetMaxAvailableConditionTargets() const;
|
||||
|
||||
std::string ToString(bool ext = false) const; /// For logging purpose
|
||||
};
|
||||
@@ -236,19 +236,18 @@ class ConditionMgr
|
||||
|
||||
void LoadConditions(bool isReload = false);
|
||||
bool isConditionTypeValid(Condition* cond);
|
||||
ConditionContainer GetConditionReferences(uint32 refId);
|
||||
|
||||
uint32 GetSearcherTypeMaskForConditionList(ConditionContainer const& conditions);
|
||||
bool IsObjectMeetToConditions(WorldObject* object, ConditionContainer const& conditions);
|
||||
bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionContainer const& conditions);
|
||||
bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions);
|
||||
bool IsObjectMeetToConditions(WorldObject* object, ConditionContainer const& conditions) const;
|
||||
bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionContainer const& conditions) const;
|
||||
bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const;
|
||||
static bool CanHaveSourceGroupSet(ConditionSourceType sourceType);
|
||||
static bool CanHaveSourceIdSet(ConditionSourceType sourceType);
|
||||
ConditionContainer GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry);
|
||||
ConditionContainer GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId);
|
||||
ConditionContainer GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType);
|
||||
ConditionContainer GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId);
|
||||
ConditionContainer GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId);
|
||||
ConditionContainer GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry) const;
|
||||
ConditionContainer GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId) const;
|
||||
ConditionContainer GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType) const;
|
||||
ConditionContainer GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId) const;
|
||||
ConditionContainer GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId) const;
|
||||
|
||||
struct ConditionTypeInfo
|
||||
{
|
||||
@@ -257,16 +256,16 @@ class ConditionMgr
|
||||
bool HasConditionValue2;
|
||||
bool HasConditionValue3;
|
||||
};
|
||||
static char const* StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX];
|
||||
static char const* const StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX];
|
||||
static ConditionTypeInfo const StaticConditionTypeData[CONDITION_MAX];
|
||||
|
||||
private:
|
||||
bool isSourceTypeValid(Condition* cond);
|
||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
||||
bool addToGossipMenus(Condition* cond);
|
||||
bool addToGossipMenuItems(Condition* cond);
|
||||
bool addToSpellImplicitTargetConditions(Condition* cond);
|
||||
bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions);
|
||||
bool isSourceTypeValid(Condition* cond) const;
|
||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot) const;
|
||||
bool addToGossipMenus(Condition* cond) const;
|
||||
bool addToGossipMenuItems(Condition* cond) const;
|
||||
bool addToSpellImplicitTargetConditions(Condition* cond) const;
|
||||
bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const;
|
||||
|
||||
static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user