Various Cleanups (game L-M)

This commit is contained in:
Schmoozerd 2012-07-19 21:46:40 +02:00
parent 2bd41afb3e
commit 8d0c106aa4
29 changed files with 2201 additions and 2163 deletions

View file

@ -27,7 +27,8 @@
#include "DBCStores.h"
#include "SQLStorages.h"
static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = {
static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] =
{
CONFIG_FLOAT_RATE_DROP_ITEM_POOR, // ITEM_QUALITY_POOR
CONFIG_FLOAT_RATE_DROP_ITEM_NORMAL, // ITEM_QUALITY_NORMAL
CONFIG_FLOAT_RATE_DROP_ITEM_UNCOMMON, // ITEM_QUALITY_UNCOMMON
@ -37,26 +38,26 @@ static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = {
CONFIG_FLOAT_RATE_DROP_ITEM_ARTIFACT, // ITEM_QUALITY_ARTIFACT
};
LootStore LootTemplates_Creature( "creature_loot_template", "creature entry", true);
LootStore LootTemplates_Disenchant( "disenchant_loot_template", "item disenchant id", true);
LootStore LootTemplates_Fishing( "fishing_loot_template", "area id", true);
LootStore LootTemplates_Gameobject( "gameobject_loot_template", "gameobject lootid", true);
LootStore LootTemplates_Item( "item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true);
LootStore LootTemplates_Mail( "mail_loot_template", "mail template id", false);
LootStore LootTemplates_Milling( "milling_loot_template", "item entry (herb)", true);
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true);
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true);
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true);
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject lootid", true);
LootStore LootTemplates_Item("item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true);
LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false);
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true);
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true);
LootStore LootTemplates_Prospecting( "prospecting_loot_template", "item entry (ore)", true);
LootStore LootTemplates_Reference( "reference_loot_template", "reference id", false);
LootStore LootTemplates_Skinning( "skinning_loot_template", "creature skinning id", true);
LootStore LootTemplates_Spell( "spell_loot_template", "spell id (random item creating)",false);
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true);
LootStore LootTemplates_Reference("reference_loot_template", "reference id", false);
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true);
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)",false);
class LootTemplate::LootGroup // A set of loot definitions for items (refs are not allowed)
{
public:
void AddEntry(LootStoreItem& item); // Adds an entry to the group (at loading stage)
bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry
bool HasQuestDropForPlayer(Player const * player) const;
// The same for active quests of the player
bool HasQuestDropForPlayer(Player const* player) const;
// The same for active quests of the player
void Process(Loot& loot) const; // Rolls an item from the group (if any) and adds the item to the loot
float RawTotalChance() const; // Overall chance for the group (without equal chanced items)
float TotalChance() const; // Overall chance for the group
@ -68,7 +69,7 @@ class LootTemplate::LootGroup // A set of loot def
LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB
LootStoreItemList EqualChanced; // Zero chances - every entry takes the same chance
LootStoreItem const * Roll() const; // Rolls an item from the group, returns NULL if all miss their chances
LootStoreItem const* Roll() const; // Rolls an item from the group, returns NULL if all miss their chances
};
//Remove all data and free all memory
@ -83,7 +84,7 @@ void LootStore::Clear()
// Actual checks are done within LootTemplate::Verify() which is called for every template
void LootStore::Verify() const
{
for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i )
for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i)
i->second->Verify(*this, i->first);
}
@ -97,10 +98,10 @@ void LootStore::LoadLootTable()
// Clearing store (for reloading case)
Clear();
sLog.outString( "%s :", GetName());
sLog.outString("%s :", GetName());
// 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName());
QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName());
if (result)
{
@ -108,7 +109,7 @@ void LootStore::LoadLootTable()
do
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
bar.step();
uint32 entry = fields[0].GetUInt32();
@ -147,12 +148,12 @@ void LootStore::LoadLootTable()
continue;
// Looking for the template of the entry
// often entries are put together
// often entries are put together
if (m_LootTemplates.empty() || tab->first != entry)
{
// Searching the template (in case template Id changed)
tab = m_LootTemplates.find(entry);
if ( tab == m_LootTemplates.end() )
if (tab == m_LootTemplates.end())
{
std::pair< LootTemplateMap::iterator, bool > pr = m_LootTemplates.insert(LootTemplateMap::value_type(entry, new LootTemplate));
tab = pr.first;
@ -165,26 +166,27 @@ void LootStore::LoadLootTable()
tab->second->AddEntry(storeitem);
++count;
} while (result->NextRow());
}
while (result->NextRow());
delete result;
Verify(); // Checks validity of the loot store
sLog.outString();
sLog.outString( ">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size());
sLog.outString(">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size());
}
else
{
sLog.outString();
sLog.outErrorDb( ">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName() );
sLog.outErrorDb(">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName());
}
}
bool LootStore::HaveQuestLootFor(uint32 loot_id) const
{
LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id);
if(itr == m_LootTemplates.end())
if (itr == m_LootTemplates.end())
return false;
// scan loot for quest items
@ -215,20 +217,20 @@ void LootStore::LoadAndCollectLootIds(LootIdSet& ids_set)
{
LoadLootTable();
for(LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab)
for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab)
ids_set.insert(tab->first);
}
void LootStore::CheckLootRefs(LootIdSet* ref_set) const
{
for(LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr)
for (LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr)
ltItr->second->CheckLootRefs(ref_set);
}
void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const
{
// all still listed ids isn't referenced
for(LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr)
for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr)
sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr,GetEntryName());
}
@ -245,13 +247,13 @@ void LootStore::ReportNotExistedId(uint32 id) const
// RATE_DROP_ITEMS is no longer used for all types of entries
bool LootStoreItem::Roll(bool rate) const
{
if(chance>=100.0f)
if (chance>=100.0f)
return true;
if(mincountOrRef < 0) // reference case
if (mincountOrRef < 0) // reference case
return roll_chance_f(chance* (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f));
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid);
float qualityModifier = pProto && rate ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f;
@ -275,8 +277,8 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const
if (mincountOrRef > 0) // item (quest or non-quest) entry, maybe grouped
{
ItemPrototype const *proto = ObjectMgr::GetItemPrototype(itemid);
if(!proto)
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemid);
if (!proto)
{
sLog.outErrorDb("Table '%s' entry %d item %d: item entry not listed in `item_template` - skipped", store.GetName(), entry, itemid);
return false;
@ -361,13 +363,13 @@ LootItem::LootItem(uint32 itemid_, uint32 count_, uint32 randomSuffix_, int32 ra
}
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
bool LootItem::AllowedForPlayer(Player const * player) const
bool LootItem::AllowedForPlayer(Player const* player) const
{
// DB conditions check
if (conditionId && !sObjectMgr.IsPlayerMeetToNEWCondition(player, conditionId))
return false;
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid);
if (!pProto)
return false;
@ -378,10 +380,10 @@ bool LootItem::AllowedForPlayer(Player const * player) const
if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
return false;
if ( needs_quest )
if (needs_quest)
{
// Checking quests for quest-only drop (check only quests requirements in this case)
if( !player->HasQuestForItem(itemid) )
if (!player->HasQuestForItem(itemid))
return false;
}
else
@ -420,7 +422,7 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play
//
// Inserts the item into the loot (called by LootTemplate processors)
void Loot::AddItem(LootStoreItem const & item)
void Loot::AddItem(LootStoreItem const& item)
{
if (item.needs_quest) // Quest drop
{
@ -447,7 +449,7 @@ void Loot::AddItem(LootStoreItem const & item)
bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError)
{
// Must be provided
if(!loot_owner)
if (!loot_owner)
return false;
LootTemplate const* tab = store.GetLootFor(loot_id);
@ -462,14 +464,14 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
items.reserve(MAX_NR_LOOT_ITEMS);
m_questItems.reserve(MAX_NR_QUEST_ITEMS);
tab->Process(*this, store,store.IsRatesAllowed ()); // Processing is done there, callback via Loot::AddItem()
tab->Process(*this, store,store.IsRatesAllowed()); // Processing is done there, callback via Loot::AddItem()
// Setting access rights for group loot case
Group * pGroup=loot_owner->GetGroup();
if(!personal && pGroup)
Group* pGroup=loot_owner->GetGroup();
if (!personal && pGroup)
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
if(Player* pl = itr->getSource())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* pl = itr->getSource())
FillNotNormalLootFor(pl);
}
// ... for personal loot
@ -498,12 +500,12 @@ void Loot::FillNotNormalLootFor(Player* pl)
QuestItemList* Loot::FillFFALoot(Player* player)
{
QuestItemList *ql = new QuestItemList();
QuestItemList* ql = new QuestItemList();
for(uint8 i = 0; i < items.size(); ++i)
for (uint8 i = 0; i < items.size(); ++i)
{
LootItem &item = items[i];
if(!item.is_looted && item.freeforall && item.AllowedForPlayer(player) )
LootItem& item = items[i];
if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player))
{
ql->push_back(QuestItem(i));
++unlootedCount;
@ -522,12 +524,12 @@ QuestItemList* Loot::FillFFALoot(Player* player)
QuestItemList* Loot::FillQuestLoot(Player* player)
{
if (items.size() == MAX_NR_LOOT_ITEMS) return NULL;
QuestItemList *ql = new QuestItemList();
QuestItemList* ql = new QuestItemList();
for(uint8 i = 0; i < m_questItems.size(); ++i)
for (uint8 i = 0; i < m_questItems.size(); ++i)
{
LootItem &item = m_questItems[i];
if(!item.is_looted && item.AllowedForPlayer(player) )
LootItem& item = m_questItems[i];
if (!item.is_looted && item.AllowedForPlayer(player))
{
ql->push_back(QuestItem(i));
@ -556,15 +558,15 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player)
{
QuestItemList *ql = new QuestItemList();
QuestItemList* ql = new QuestItemList();
for(uint8 i = 0; i < items.size(); ++i)
for (uint8 i = 0; i < items.size(); ++i)
{
LootItem &item = items[i];
if(!item.is_looted && !item.freeforall && item.conditionId && item.AllowedForPlayer(player))
LootItem& item = items[i];
if (!item.is_looted && !item.freeforall && item.conditionId && item.AllowedForPlayer(player))
{
ql->push_back(QuestItem(i));
if(!item.is_counted)
if (!item.is_counted)
{
++unlootedCount;
item.is_counted=true;
@ -648,7 +650,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
}
}
void Loot::generateMoneyLoot( uint32 minAmount, uint32 maxAmount )
void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
{
if (maxAmount > 0)
{
@ -661,7 +663,7 @@ void Loot::generateMoneyLoot( uint32 minAmount, uint32 maxAmount )
}
}
LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qitem, QuestItem **ffaitem, QuestItem **conditem)
LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qitem, QuestItem** ffaitem, QuestItem** conditem)
{
LootItem* item = NULL;
bool is_looted = true;
@ -671,8 +673,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow());
if (itr != m_playerQuestItems.end() && questSlot < itr->second->size())
{
QuestItem *qitem2 = &itr->second->at(questSlot);
if(qitem)
QuestItem* qitem2 = &itr->second->at(questSlot);
if (qitem)
*qitem = qitem2;
item = &m_questItems[qitem2->index];
is_looted = qitem2->is_looted;
@ -682,16 +684,16 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
{
item = &items[lootSlot];
is_looted = item->is_looted;
if(item->freeforall)
if (item->freeforall)
{
QuestItemMap::const_iterator itr = m_playerFFAItems.find(player->GetGUIDLow());
if (itr != m_playerFFAItems.end())
{
for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
if(iter->index==lootSlot)
for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
if (iter->index==lootSlot)
{
QuestItem *ffaitem2 = (QuestItem*)&(*iter);
if(ffaitem)
QuestItem* ffaitem2 = (QuestItem*)&(*iter);
if (ffaitem)
*ffaitem = ffaitem2;
is_looted = ffaitem2->is_looted;
break;
@ -703,12 +705,12 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow());
if (itr != m_playerNonQuestNonFFAConditionalItems.end())
{
for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
{
if(iter->index==lootSlot)
if (iter->index==lootSlot)
{
QuestItem *conditem2 = (QuestItem*)&(*iter);
if(conditem)
QuestItem* conditem2 = (QuestItem*)&(*iter);
if (conditem)
*conditem = conditem2;
is_looted = conditem2->is_looted;
break;
@ -718,7 +720,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
}
}
if(is_looted)
if (is_looted)
return NULL;
return item;
@ -750,7 +752,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
return b; // nothing output more
}
Loot &l = lv.loot;
Loot& l = lv.loot;
uint8 itemsShown = 0;
@ -779,10 +781,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUIDLow());
if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
{
QuestItemList *conditional_list = nn_itr->second;
QuestItemList* conditional_list = nn_itr->second;
for (QuestItemList::const_iterator ci = conditional_list->begin() ; ci != conditional_list->end(); ++ci)
{
LootItem &item = l.items[ci->index];
LootItem& item = l.items[ci->index];
LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, !ci->is_looted);
if (slot_type >= MAX_LOOT_SLOT_TYPE)
@ -801,10 +803,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUIDLow());
if (q_itr != lootPlayerQuestItems.end())
{
QuestItemList *q_list = q_itr->second;
QuestItemList* q_list = q_itr->second;
for (QuestItemList::const_iterator qi = q_list->begin() ; qi != q_list->end(); ++qi)
{
LootItem &item = l.m_questItems[qi->index];
LootItem& item = l.m_questItems[qi->index];
if (!qi->is_looted && !item.is_looted)
{
b << uint8(l.items.size() + (qi - q_list->begin()));
@ -819,10 +821,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUIDLow());
if (ffa_itr != lootPlayerFFAItems.end())
{
QuestItemList *ffa_list = ffa_itr->second;
QuestItemList* ffa_list = ffa_itr->second;
for (QuestItemList::const_iterator fi = ffa_list->begin() ; fi != ffa_list->end(); ++fi)
{
LootItem &item = l.items[fi->index];
LootItem& item = l.items[fi->index];
if (!fi->is_looted && !item.is_looted)
{
b << uint8(fi->index) << item;
@ -852,7 +854,7 @@ void LootTemplate::LootGroup::AddEntry(LootStoreItem& item)
}
// Rolls an item from the group, returns NULL if all miss their chances
LootStoreItem const * LootTemplate::LootGroup::Roll() const
LootStoreItem const* LootTemplate::LootGroup::Roll() const
{
if (!ExplicitlyChanced.empty()) // First explicitly chanced entries are checked
{
@ -860,7 +862,7 @@ LootStoreItem const * LootTemplate::LootGroup::Roll() const
for (uint32 i=0; i<ExplicitlyChanced.size(); ++i) //check each explicitly chanced entry in the template and modify its chance based on quality.
{
if(ExplicitlyChanced[i].chance>=100.0f)
if (ExplicitlyChanced[i].chance>=100.0f)
return &ExplicitlyChanced[i];
Roll -= ExplicitlyChanced[i].chance;
@ -887,7 +889,7 @@ bool LootTemplate::LootGroup::HasQuestDrop() const
}
// True if group includes at least 1 quest drop entry for active quests of the player
bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const * player) const
bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const
{
for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (player->HasQuestForItem(i->itemid))
@ -901,7 +903,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const * player) const
// Rolls an item from the group (if any takes its chance) and adds the item to the loot
void LootTemplate::LootGroup::Process(Loot& loot) const
{
LootStoreItem const * item = Roll();
LootStoreItem const* item = Roll();
if (item != NULL)
loot.AddItem(*item);
}
@ -912,7 +914,7 @@ float LootTemplate::LootGroup::RawTotalChance() const
float result = 0;
for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if ( !i->needs_quest )
if (!i->needs_quest)
result += i->chance;
return result;
@ -937,7 +939,7 @@ void LootTemplate::LootGroup::Verify(LootStore const& lootstore, uint32 id, uint
sLog.outErrorDb("Table '%s' entry %u group %d has total chance > 100%% (%f)", lootstore.GetName(), id, group_id, chance);
}
if(chance >= 100.0f && !EqualChanced.empty())
if (chance >= 100.0f && !EqualChanced.empty())
{
sLog.outErrorDb("Table '%s' entry %u group %d has items with chance=0%% but group total chance >= 100%% (%f)", lootstore.GetName(), id, group_id, chance);
}
@ -947,22 +949,22 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const
{
for (LootStoreItemList::const_iterator ieItr=ExplicitlyChanced.begin(); ieItr != ExplicitlyChanced.end(); ++ieItr)
{
if(ieItr->mincountOrRef < 0)
if (ieItr->mincountOrRef < 0)
{
if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
else if(ref_set)
else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef);
}
}
for (LootStoreItemList::const_iterator ieItr=EqualChanced.begin(); ieItr != EqualChanced.end(); ++ieItr)
{
if(ieItr->mincountOrRef < 0)
if (ieItr->mincountOrRef < 0)
{
if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
else if(ref_set)
else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef);
}
}
@ -998,7 +1000,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
}
// Rolling non-grouped items
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i )
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i)
{
if (!i->Roll(rate))
continue; // Bad luck for the entry
@ -1007,10 +1009,10 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
{
LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-i->mincountOrRef);
if(!Referenced)
if (!Referenced)
continue; // Error message already printed at loading stage
for (uint32 loop=0; loop < i->maxcount; ++loop )// Ref multiplicator
for (uint32 loop=0; loop < i->maxcount; ++loop) // Ref multiplicator
Referenced->Process(loot, store, rate, i->group);
}
else // Plain entries (not a reference, not grouped)
@ -1018,7 +1020,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
}
// Now processing groups
for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; ++i )
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
i->Process(loot);
}
@ -1032,22 +1034,22 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
return Groups[groupId-1].HasQuestDrop();
}
for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i )
for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i)
{
if (i->mincountOrRef < 0) // References
{
LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef);
if( Referenced ==store.end() )
if (Referenced ==store.end())
continue; // Error message [should be] already printed at loading stage
if (Referenced->second->HasQuestDrop(store, i->group) )
if (Referenced->second->HasQuestDrop(store, i->group))
return true;
}
else if ( i->needs_quest )
else if (i->needs_quest)
return true; // quest drop found
}
// Now processing groups
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i )
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
if (i->HasQuestDrop())
return true;
@ -1065,22 +1067,22 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
}
// Checking non-grouped entries
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i )
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i)
{
if (i->mincountOrRef < 0) // References processing
{
LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef);
if (Referenced == store.end() )
if (Referenced == store.end())
continue; // Error message already printed at loading stage
if (Referenced->second->HasQuestDropForPlayer(store, player, i->group) )
if (Referenced->second->HasQuestDropForPlayer(store, player, i->group))
return true;
}
else if ( player->HasQuestForItem(i->itemid) )
else if (player->HasQuestForItem(i->itemid))
return true; // active quest drop found
}
// Now checking groups
for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i )
for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
if (i->HasQuestDropForPlayer(player))
return true;
@ -1099,18 +1101,18 @@ void LootTemplate::Verify(LootStore const& lootstore, uint32 id) const
void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const
{
for(LootStoreItemList::const_iterator ieItr = Entries.begin(); ieItr != Entries.end(); ++ieItr)
for (LootStoreItemList::const_iterator ieItr = Entries.begin(); ieItr != Entries.end(); ++ieItr)
{
if(ieItr->mincountOrRef < 0)
if (ieItr->mincountOrRef < 0)
{
if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
else if(ref_set)
else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef);
}
}
for(LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr)
for (LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr)
grItr->CheckLootRefs(ref_set);
}
@ -1120,11 +1122,11 @@ void LoadLootTemplates_Creature()
LootTemplates_Creature.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if(uint32 lootid = cInfo->lootid)
if (uint32 lootid = cInfo->lootid)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Creature.ReportNotExistedId(lootid);
@ -1133,7 +1135,7 @@ void LoadLootTemplates_Creature()
}
}
}
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
// for alterac valley we've defined Player-loot inside creature_loot_template id=0
@ -1150,11 +1152,11 @@ void LoadLootTemplates_Disenchant()
LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{
if(ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{
if(uint32 lootid = proto->DisenchantID)
if (uint32 lootid = proto->DisenchantID)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Disenchant.ReportNotExistedId(lootid);
@ -1163,7 +1165,7 @@ void LoadLootTemplates_Disenchant()
}
}
}
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Disenchant.ReportUnusedIds(ids_set);
@ -1175,9 +1177,9 @@ void LoadLootTemplates_Fishing()
LootTemplates_Fishing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sAreaStore.GetNumRows(); ++i )
for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i)
{
if(AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i))
if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i))
if (ids_set.find(areaEntry->ID) != ids_set.end())
ids_set.erase(areaEntry->ID);
}
@ -1195,11 +1197,11 @@ void LoadLootTemplates_Gameobject()
LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
{
if(GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
{
if(uint32 lootid = gInfo->GetLootId())
if (uint32 lootid = gInfo->GetLootId())
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Gameobject.ReportNotExistedId(lootid);
@ -1208,7 +1210,7 @@ void LoadLootTemplates_Gameobject()
}
}
}
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids
@ -1221,11 +1223,11 @@ void LoadLootTemplates_Item()
LootTemplates_Item.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{
if(ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{
if (!(proto->Flags & ITEM_FLAG_LOOTABLE))
if (!(proto->Flags & ITEM_FLAG_LOOTABLE))
continue;
if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0)
@ -1246,10 +1248,10 @@ void LoadLootTemplates_Milling()
LootTemplates_Milling.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i);
if(!proto)
if (!proto)
continue;
if (!(proto->Flags & ITEM_FLAG_MILLABLE))
@ -1271,11 +1273,11 @@ void LoadLootTemplates_Pickpocketing()
LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if(uint32 lootid = cInfo->pickpocketLootId)
if (uint32 lootid = cInfo->pickpocketLootId)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Pickpocketing.ReportNotExistedId(lootid);
@ -1284,7 +1286,7 @@ void LoadLootTemplates_Pickpocketing()
}
}
}
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids
@ -1297,7 +1299,7 @@ void LoadLootTemplates_Prospecting()
LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i);
if (!proto)
@ -1322,8 +1324,8 @@ void LoadLootTemplates_Mail()
LootTemplates_Mail.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i )
if(sMailTemplateStore.LookupEntry(i))
for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
if (sMailTemplateStore.LookupEntry(i))
if (ids_set.find(i) != ids_set.end())
ids_set.erase(i);
@ -1337,11 +1339,11 @@ void LoadLootTemplates_Skinning()
LootTemplates_Skinning.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i )
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if(uint32 lootid = cInfo->SkinLootId)
if (uint32 lootid = cInfo->SkinLootId)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Skinning.ReportNotExistedId(lootid);
@ -1350,7 +1352,7 @@ void LoadLootTemplates_Skinning()
}
}
}
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids
@ -1363,14 +1365,14 @@ void LoadLootTemplates_Spell()
LootTemplates_Spell.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for(uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry (spell_id);
if(!spellInfo)
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if (!spellInfo)
continue;
// possible cases
if( !IsLootCraftingSpell(spellInfo))
if (!IsLootCraftingSpell(spellInfo))
continue;
if (ids_set.find(spell_id) == ids_set.end())