Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- src/server/game/Conditions/ConditionMgr.cpp | 95 ++++++++++++++++++++++++++++-
- src/server/game/Conditions/ConditionMgr.h | 7 ++-
- 2 files changed, 97 insertions(+), 5 deletions(-)
- diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
- index 84830e0..4e80d99 100644
- --- a/src/server/game/Conditions/ConditionMgr.cpp
- +++ b/src/server/game/Conditions/ConditionMgr.cpp
- @@ -56,7 +56,9 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX]
- "Npc Vendor",
- "Spell Proc",
- "Terrain Swap",
- - "Phase"
- + "Phase",
- + "Creature Visibility",
- + "GameObject Visibility"
- };
- ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
- @@ -1190,6 +1212,34 @@ void ConditionMgr::LoadConditions(bool isReload)
- ++count;
- continue;
- }
- + else if (cond->SourceType == CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY)
- + {
- + CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(cond->SourceEntry));
- + if (!creature)
- + {
- + TC_LOG_ERROR("sql.sql", "%s has no creature data for guid %d in SourceEntry field!", cond->ToString().c_str(), cond->SourceEntry);
- + delete cond;
- + continue;
- + }
- + CreatureData& data = sObjectMgr->NewOrExistCreatureData(uint64(cond->SourceEntry));
- + data.conditions.push_back(cond); // data.conditions is: ConditionContainer conditions;
- + ++count;
- + continue;
- + }
- + else if (cond->SourceType == CONDITION_SOURCE_TYPE_GAMEOBJECT_VISIBILITY)
- + {
- + GameObjectData const* godata = sObjectMgr->GetGOData(uint64(cond->SourceEntry));
- + if (!godata)
- + {
- + TC_LOG_ERROR("sql.sql", "%s has no gameobject data for guid %d in SourceEntry field!", cond->ToString().c_str(), cond->SourceEntry);
- + delete cond;
- + continue;
- + }
- + GameObjectData& data = sObjectMgr->NewGOData(uint64(cond->SourceEntry));
- + data.conditions.push_back(cond); // data.conditions is: ConditionContainer conditions;
- + ++count;
- + continue;
- + }
- //handle not grouped conditions
- //add new Condition to storage based on Type/Entry
- @@ -1773,6 +1823,26 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
- }
- break;
- }
- + case CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY:
- + {
- + CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(cond->SourceEntry));
- + if (!creature)
- + {
- + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature` as guid %d, ignoring.", cond->ToString().c_str(), cond->SourceEntry);
- + return false;
- + }
- + break;
- + }
- + case CONDITION_SOURCE_TYPE_GAMEOBJECT_VISIBILITY:
- + {
- + GameObjectData const* godata = sObjectMgr->GetGOData(uint64(cond->SourceEntry));
- + if (!godata)
- + {
- + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `gameobject` as guid %d, ignoring.", cond->ToString().c_str(), cond->SourceEntry);
- + return false;
- + }
- + break;
- + }
- case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
- case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
- case CONDITION_SOURCE_TYPE_SMART_EVENT:
- @@ -2293,6 +2364,24 @@ void ConditionMgr::Clean()
- NpcVendorConditionContainerStore.clear();
- +
- + // todo fix cleanup
- + CreatureDataContainer* creatures = sObjectMgr->GetCreatureDataMap();
- + for (CreatureDataContainer::iterator itr = creatures->begin(); itr != creatures->end(); ++itr)
- + {
- + //for (ConditionList::const_iterator i = itr->second.conditions.begin(); i != itr->second.conditions.end(); ++i)
- + // delete *i;
- + itr->second.conditions.clear();
- + }
- +
- + GameObjectDataContainer* gameobjects = sObjectMgr->GetGameObjectDataMap();
- + for (GameObjectDataContainer::iterator itr = gameobjects->begin(); itr != gameobjects->end(); ++itr)
- + {
- + //for (ConditionList::const_iterator i = itr->second.conditions.begin(); i != itr->second.conditions.end(); ++i)
- + // delete *i;
- + itr->second.conditions.clear();
- + }
- +
- // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
- for (std::vector<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 d33b7ed..5cd2aae 100644
- --- a/src/server/game/Conditions/ConditionMgr.h
- +++ b/src/server/game/Conditions/ConditionMgr.h
- @@ -150,7 +151,9 @@ enum ConditionSourceType
- CONDITION_SOURCE_TYPE_SPELL_PROC = 24,
- CONDITION_SOURCE_TYPE_TERRAIN_SWAP = 25,
- CONDITION_SOURCE_TYPE_PHASE = 26,
- - CONDITION_SOURCE_TYPE_MAX = 27 // MAX
- + CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY = 27,
- + CONDITION_SOURCE_TYPE_GAMEOBJECT_VISIBILITY = 28,
- + CONDITION_SOURCE_TYPE_MAX = 29 // MAX
- };
- enum RelationType
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement