Merge commit 'origin/master' into 310

This commit is contained in:
VladimirMangos 2009-06-09 09:51:34 +04:00
commit 05b1bda879
20 changed files with 299 additions and 38 deletions

View file

@ -1810,6 +1810,106 @@ void ObjectMgr::LoadItemPrototypes()
}
}
void ObjectMgr::LoadItemRequiredTarget()
{
m_ItemRequiredTarget.clear(); // needed for reload case
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM item_required_target");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 ItemRequiredTarget. DB table `item_required_target` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 uiItemId = fields[0].GetUInt32();
uint32 uiType = fields[1].GetUInt32();
uint32 uiTargetEntry = fields[2].GetUInt32();
ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(uiItemId);
if (!pItemProto)
{
sLog.outErrorDb("Table `item_required_target`: Entry %u listed for TargetEntry %u does not exist in `item_template`.",uiItemId,uiTargetEntry);
continue;
}
bool bIsItemSpellValid = false;
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
if (SpellEntry const* pSpellInfo = sSpellStore.LookupEntry(pItemProto->Spells[i].SpellId))
{
if (pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE ||
pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)
{
SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(pSpellInfo->Id);
SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(pSpellInfo->Id);
if (lower != upper)
break;
if (pSpellInfo->EffectImplicitTargetA[i] == TARGET_CHAIN_DAMAGE ||
pSpellInfo->EffectImplicitTargetB[i] == TARGET_CHAIN_DAMAGE ||
pSpellInfo->EffectImplicitTargetA[i] == TARGET_DUELVSPLAYER ||
pSpellInfo->EffectImplicitTargetB[i] == TARGET_DUELVSPLAYER)
{
bIsItemSpellValid = true;
break;
}
}
}
}
if (!bIsItemSpellValid)
{
sLog.outErrorDb("Table `item_required_target`: Spell used by item %u does not have implicit target TARGET_CHAIN_DAMAGE(6), TARGET_DUELVSPLAYER(25), already listed in `spell_script_target` or doesn't have item spelltrigger.",uiItemId);
continue;
}
if (!uiType || uiType > MAX_ITEM_REQ_TARGET_TYPE)
{
sLog.outErrorDb("Table `item_required_target`: Type %u for TargetEntry %u is incorrect.",uiType,uiTargetEntry);
continue;
}
if (!uiTargetEntry)
{
sLog.outErrorDb("Table `item_required_target`: TargetEntry == 0 for Type (%u).",uiType);
continue;
}
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiTargetEntry))
{
sLog.outErrorDb("Table `item_required_target`: creature template entry %u does not exist.",uiTargetEntry);
continue;
}
m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId,ItemRequiredTarget(ItemRequiredTargetType(uiType),uiTargetEntry)));
++count;
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u Item required targets", count);
}
void ObjectMgr::LoadPetLevelInfo()
{
// Loading levels data