Fixes and cleanups in loot code.

* Move not-normal loot tables generation in single place (Loot::FillLoot function) for group and non group case.
* Simplify LootView code.
This commit is contained in:
VladimirMangos 2009-02-07 09:19:18 +03:00
parent fb432a0f36
commit 7d63f4ce02
6 changed files with 86 additions and 99 deletions

View file

@ -7401,11 +7401,11 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
sLog.outDebug(" if(lootid)");
loot->clear();
loot->FillLoot(lootid, LootTemplates_Gameobject, this);
loot->FillLoot(lootid, LootTemplates_Gameobject, this, false);
}
if(loot_type == LOOT_FISHING)
go->getFishLoot(loot);
go->getFishLoot(loot,this);
go->SetLootState(GO_ACTIVATED);
}
@ -7428,7 +7428,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this);
loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this,true);
}
}
else if(loot_type == LOOT_PROSPECTING)
@ -7439,7 +7439,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this);
loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this,true);
}
}
else if(loot_type == LOOT_MILLING)
@ -7450,7 +7450,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this);
loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this,true);
}
}
else
@ -7461,7 +7461,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetEntry(), LootTemplates_Item, this);
loot->FillLoot(item->GetEntry(), LootTemplates_Item, this,true);
loot->generateMoneyLoot(item->GetProto()->MinMoneyLoot,item->GetProto()->MaxMoneyLoot);
}
@ -7519,7 +7519,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
loot->clear();
if (uint32 lootid = creature->GetCreatureInfo()->pickpocketLootId)
loot->FillLoot(lootid, LootTemplates_Pickpocketing, this);
loot->FillLoot(lootid, LootTemplates_Pickpocketing, this, false);
// Generate extra money for pick pocket loot
const uint32 a = urand(0, creature->getLevel()/2);
@ -7549,7 +7549,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
loot->clear();
if (uint32 lootid = creature->GetCreatureInfo()->lootid)
loot->FillLoot(lootid, LootTemplates_Creature, recipient);
loot->FillLoot(lootid, LootTemplates_Creature, recipient, false);
loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold,creature->GetCreatureInfo()->maxgold);
@ -7579,7 +7579,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
if (loot_type == LOOT_SKINNING)
{
loot->clear();
loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this);
loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this, false);
}
// set group rights only for loot_type != LOOT_SKINNING
else
@ -7613,39 +7613,6 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
SetLootGUID(guid);
QuestItemList *q_list = 0;
if (permission != NONE_PERMISSION)
{
QuestItemMap const& lootPlayerQuestItems = loot->GetPlayerQuestItems();
QuestItemMap::const_iterator itr = lootPlayerQuestItems.find(GetGUIDLow());
if (itr == lootPlayerQuestItems.end())
q_list = loot->FillQuestLoot(this);
else
q_list = itr->second;
}
QuestItemList *ffa_list = 0;
if (permission != NONE_PERMISSION)
{
QuestItemMap const& lootPlayerFFAItems = loot->GetPlayerFFAItems();
QuestItemMap::const_iterator itr = lootPlayerFFAItems.find(GetGUIDLow());
if (itr == lootPlayerFFAItems.end())
ffa_list = loot->FillFFALoot(this);
else
ffa_list = itr->second;
}
QuestItemList *conditional_list = 0;
if (permission != NONE_PERMISSION)
{
QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = loot->GetPlayerNonQuestNonFFAConditionalItems();
QuestItemMap::const_iterator itr = lootPlayerNonQuestNonFFAConditionalItems.find(GetGUIDLow());
if (itr == lootPlayerNonQuestNonFFAConditionalItems.end())
conditional_list = loot->FillNonQuestNonFFAConditionalLoot(this);
else
conditional_list = itr->second;
}
// LOOT_PICKPOCKETING, LOOT_PROSPECTING, LOOT_DISENCHANTING, LOOT_INSIGNIA and LOOT_MILLING unsupported by client, sending LOOT_SKINNING instead
if(loot_type == LOOT_PICKPOCKETING || loot_type == LOOT_DISENCHANTING || loot_type == LOOT_PROSPECTING || loot_type == LOOT_INSIGNIA || loot_type == LOOT_MILLING)
loot_type = LOOT_SKINNING;
@ -7657,7 +7624,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
data << uint64(guid);
data << uint8(loot_type);
data << LootView(*loot, q_list, ffa_list, conditional_list, this, permission);
data << LootView(*loot, this, permission);
SendDirectMessage(&data);
@ -12799,7 +12766,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
Loot questMailLoot;
questMailLoot.FillLoot(pQuest->GetQuestId(), LootTemplates_QuestMail, this);
questMailLoot.FillLoot(pQuest->GetQuestId(), LootTemplates_QuestMail, this,true);
// fill mail
MailItemsInfo mi; // item list preparing
@ -19412,7 +19379,7 @@ void Player::InitRunes()
void Player::AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store)
{
Loot loot;
loot.FillLoot (loot_id,store,this);
loot.FillLoot (loot_id,store,this,true);
if(loot.items.empty ())
return;
LootItem const* lootItem = &loot.items[0];