diff options
Diffstat (limited to 'src/server/game/Conditions/ConditionMgr.cpp')
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 76 |
1 files changed, 64 insertions, 12 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 1c5c294d9c1..dcb67d0f631 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -80,7 +80,9 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] "Phase", "Graveyard", "AreaTrigger", - "ConversationLine" + "ConversationLine", + "AreaTrigger Client Triggered", + "Trainer Spell" }; ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] = @@ -951,7 +953,8 @@ bool ConditionMgr::CanHaveSourceGroupSet(ConditionSourceType sourceType) sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT || sourceType == CONDITION_SOURCE_TYPE_NPC_VENDOR || sourceType == CONDITION_SOURCE_TYPE_PHASE || - sourceType == CONDITION_SOURCE_TYPE_AREATRIGGER); + sourceType == CONDITION_SOURCE_TYPE_AREATRIGGER || + sourceType == CONDITION_SOURCE_TYPE_TRAINER_SPELL); } bool ConditionMgr::CanHaveSourceIdSet(ConditionSourceType sourceType) @@ -1060,7 +1063,7 @@ bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 ConditionsByEntryMap::const_iterator i = (*itr).second.find(itemId); if (i != (*itr).second.end()) { - TC_LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry %u item %u", creatureId, itemId); + TC_LOG_DEBUG("condition", "GetConditionsForNpcVendor: found conditions for creature entry %u item %u", creatureId, itemId); ConditionSourceInfo sourceInfo(player, vendor); return IsObjectMeetToConditions(sourceInfo, i->second); } @@ -1073,6 +1076,21 @@ ConditionContainer const* ConditionMgr::GetConditionsForAreaTrigger(uint32 areaT return Trinity::Containers::MapGetValuePtr(AreaTriggerConditionContainerStore, { areaTriggerId, isServerSide }); } +bool ConditionMgr::IsObjectMeetingTrainerSpellConditions(uint32 trainerId, uint32 spellId, Player* player) const +{ + ConditionEntriesByCreatureIdMap::const_iterator itr = TrainerSpellConditionContainerStore.find(trainerId); + if (itr != TrainerSpellConditionContainerStore.end()) + { + ConditionsByEntryMap::const_iterator i = (*itr).second.find(spellId); + if (i != (*itr).second.end()) + { + TC_LOG_DEBUG("condition", "GetConditionsForTrainerSpell: found conditions for trainer id %u spell %u", trainerId, spellId); + return IsObjectMeetToConditions(player, i->second); + } + } + return true; +} + ConditionMgr* ConditionMgr::instance() { static ConditionMgr instance; @@ -1316,6 +1334,13 @@ void ConditionMgr::LoadConditions(bool isReload) ++count; continue; } + case CONDITION_SOURCE_TYPE_TRAINER_SPELL: + { + TrainerSpellConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond); + valid = true; + ++count; + continue; + } default: break; } @@ -1769,7 +1794,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry, DIFFICULTY_NONE); if (!spellInfo) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `Spell.db2`, ignoring.", cond->ToString().c_str()); return false; } @@ -1836,7 +1861,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry, DIFFICULTY_NONE); if (!spellProto) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `Spell.db2`, ignoring.", cond->ToString().c_str()); return false; } break; @@ -1851,26 +1876,26 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const case CONDITION_SOURCE_TYPE_VEHICLE_SPELL: if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str()); return false; } if (!sSpellMgr->GetSpellInfo(cond->SourceEntry, DIFFICULTY_NONE)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `Spell.db2`, ignoring.", cond->ToString().c_str()); return false; } break; case CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT: if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str()); return false; } if (!sSpellMgr->GetSpellInfo(cond->SourceEntry, DIFFICULTY_NONE)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `Spell.db2`, ignoring.", cond->ToString().c_str()); return false; } break; @@ -1878,7 +1903,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const { if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str()); return false; } ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry); @@ -1893,7 +1918,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const { if (!sMapStore.LookupEntry(cond->SourceEntry)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in Map.dbc, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in Map.db2, ignoring.", cond->ToString().c_str()); return false; } break; @@ -1902,7 +1927,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const { if (cond->SourceEntry && !sAreaTableStore.LookupEntry(cond->SourceEntry)) { - TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in AreaTable.dbc, ignoring.", cond->ToString().c_str()); + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in AreaTable.db2, ignoring.", cond->ToString().c_str()); return false; } break; @@ -1944,6 +1969,20 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const return false; } break; + case CONDITION_SOURCE_TYPE_TRAINER_SPELL: + { + if (!sObjectMgr->GetTrainer(cond->SourceGroup)) + { + TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `trainer`, ignoring.", cond->ToString().c_str()); + return false; + } + if (!sSpellMgr->GetSpellInfo(cond->SourceEntry, DIFFICULTY_NONE)) + { + TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table does not exist in `Spell.db2`, ignoring.", cond->ToString().c_str()); + return false; + } + break; + } default: TC_LOG_ERROR("sql.sql", "%s Invalid ConditionSourceType in `condition` table, ignoring.", cond->ToString().c_str()); return false; @@ -2517,6 +2556,19 @@ void ConditionMgr::Clean() NpcVendorConditionContainerStore.clear(); + for (ConditionEntriesByAreaTriggerIdMap::iterator itr = AreaTriggerConditionContainerStore.begin(); itr != AreaTriggerConditionContainerStore.end(); ++itr) + for (ConditionContainer::const_iterator i = itr->second.begin(); i != itr->second.end(); ++i) + delete *i; + + AreaTriggerConditionContainerStore.clear(); + + for (ConditionEntriesByCreatureIdMap::iterator itr = TrainerSpellConditionContainerStore.begin(); itr != TrainerSpellConditionContainerStore.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; + + TrainerSpellConditionContainerStore.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; |