diff options
-rwxr-xr-x | src/server/game/Conditions/ConditionMgr.cpp | 51 | ||||
-rwxr-xr-x | src/server/game/Conditions/ConditionMgr.h | 27 |
2 files changed, 43 insertions, 35 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 0f1895bf1ed..755b9299352 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -515,7 +515,9 @@ bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditionList condType: %u val1: %u", (*i)->ConditionType, (*i)->ConditionValue1); if ((*i)->isLoaded()) { + //! Find ElseGroup in ElseGroupStore std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup); + //! If not found, add an entry in the store and set to true (placeholder) if (itr == ElseGroupStore.end()) ElseGroupStore[(*i)->ElseGroup] = true; else if (!(*itr).second) @@ -854,18 +856,6 @@ void ConditionMgr::LoadConditions(bool isReload) break; case CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT: { - //if no list for npc create one - if (SpellClickEventConditionStore.find(cond->SourceGroup) == SpellClickEventConditionStore.end()) - { - ConditionTypeContainer cmap; - SpellClickEventConditionStore[cond->SourceGroup] = cmap; - } - //if no list for spellclick spell create one - if (SpellClickEventConditionStore[cond->SourceGroup].find(cond->SourceEntry) == SpellClickEventConditionStore[cond->SourceGroup].end()) - { - ConditionList clist; - SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry] = clist; - } SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond); valid = true; ++count; @@ -877,18 +867,6 @@ void ConditionMgr::LoadConditions(bool isReload) break; case CONDITION_SOURCE_TYPE_VEHICLE_SPELL: { - //if no list for vehicle create one - if (VehicleSpellConditionStore.find(cond->SourceGroup) == VehicleSpellConditionStore.end()) - { - ConditionTypeContainer cmap; - VehicleSpellConditionStore[cond->SourceGroup] = cmap; - } - //if no list for vehicle's spell create one - if (VehicleSpellConditionStore[cond->SourceGroup].find(cond->SourceEntry) == VehicleSpellConditionStore[cond->SourceGroup].end()) - { - ConditionList clist; - VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry] = clist; - } VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond); valid = true; ++count; @@ -896,18 +874,8 @@ void ConditionMgr::LoadConditions(bool isReload) } case CONDITION_SOURCE_TYPE_SMART_EVENT: { - // If the entry does not exist, create a new list + //! TODO: PAIR_32 ? std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId); - if (SmartEventConditionStore.find(key) == SmartEventConditionStore.end()) - { - ConditionTypeContainer cmap; - SmartEventConditionStore[key] = cmap; - } - if (SmartEventConditionStore[key].find(cond->SourceGroup) == SmartEventConditionStore[key].end()) - { - ConditionList clist; - SmartEventConditionStore[key][cond->SourceGroup] = clist; - } SmartEventConditionStore[key][cond->SourceGroup].push_back(cond); valid = true; ++count; @@ -1929,6 +1897,19 @@ void ConditionMgr::Clean() SmartEventConditionStore.clear(); + for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr) + { + for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + { + for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) + delete *i; + it->second.clear(); + } + itr->second.clear(); + } + + SpellClickEventConditionStore.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) delete *itr; diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 5a5e2dd1c2e..ec6d6dd8453 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -72,6 +72,33 @@ enum ConditionTypes CONDITION_MAX = 39 // MAX }; +/*! Documentation on implementing a new ConditionSourceType: + Step 1: Check for the lowest free ID. Look for CONDITION_SOURCE_TYPE_UNUSED_XX in the enum. + Then define the new source type. + + Step 2: Determine and map the parameters for the new condition type. + + Step 3: Add a case block to ConditionMgr::isSourceTypeValid with the new condition type + and validate the parameters. + + Step 4: If your condition can be grouped (determined in step 2), add a rule for it in + ConditionMgr::CanHaveSourceGroupSet, following the example of the existing types. + + Step 5: Define the maximum available condition targets in ConditionMgr::GetMaxAvailableConditionTargets. + + The following steps only apply if your condition can be grouped: + + Step 6: Determine how you are going to store your conditions. You need to add a new storage container + for it in ConditionMgr class, along with a function like: + ConditionList GetConditionsForXXXYourNewSourceTypeXXX(parameters...) + + The above function should be placed in upper level (practical) code that actually + checks the conditions. + + Step 7: Implement loading for your source type in ConditionMgr::LoadConditions. + + Step 8: Implement memory cleaning for your source type in ConditionMgr::Clean. +*/ enum ConditionSourceType { CONDITION_SOURCE_TYPE_NONE = 0, |