mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[11454] Use ObjectGuid in class Loot
This commit is contained in:
parent
706c97c943
commit
b647835469
5 changed files with 66 additions and 62 deletions
|
|
@ -422,8 +422,8 @@ void Loot::AddItem(LootStoreItem const & item)
|
|||
{
|
||||
if (item.needs_quest) // Quest drop
|
||||
{
|
||||
if (quest_items.size() < MAX_NR_QUEST_ITEMS)
|
||||
quest_items.push_back(LootItem(item));
|
||||
if (m_questItems.size() < MAX_NR_QUEST_ITEMS)
|
||||
m_questItems.push_back(LootItem(item));
|
||||
}
|
||||
else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop
|
||||
{
|
||||
|
|
@ -458,7 +458,7 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
|
|||
}
|
||||
|
||||
items.reserve(MAX_NR_LOOT_ITEMS);
|
||||
quest_items.reserve(MAX_NR_QUEST_ITEMS);
|
||||
m_questItems.reserve(MAX_NR_QUEST_ITEMS);
|
||||
|
||||
tab->Process(*this, store,store.IsRatesAllowed ()); // Processing is done there, callback via Loot::AddItem()
|
||||
|
||||
|
|
@ -481,16 +481,16 @@ void Loot::FillNotNormalLootFor(Player* pl)
|
|||
{
|
||||
uint32 plguid = pl->GetGUIDLow();
|
||||
|
||||
QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid);
|
||||
if (qmapitr == PlayerQuestItems.end())
|
||||
QuestItemMap::const_iterator qmapitr = m_playerQuestItems.find(plguid);
|
||||
if (qmapitr == m_playerQuestItems.end())
|
||||
FillQuestLoot(pl);
|
||||
|
||||
qmapitr = PlayerFFAItems.find(plguid);
|
||||
if (qmapitr == PlayerFFAItems.end())
|
||||
qmapitr = m_playerFFAItems.find(plguid);
|
||||
if (qmapitr == m_playerFFAItems.end())
|
||||
FillFFALoot(pl);
|
||||
|
||||
qmapitr = PlayerNonQuestNonFFAConditionalItems.find(plguid);
|
||||
if (qmapitr == PlayerNonQuestNonFFAConditionalItems.end())
|
||||
qmapitr = m_playerNonQuestNonFFAConditionalItems.find(plguid);
|
||||
if (qmapitr == m_playerNonQuestNonFFAConditionalItems.end())
|
||||
FillNonQuestNonFFAConditionalLoot(pl);
|
||||
}
|
||||
|
||||
|
|
@ -513,7 +513,7 @@ QuestItemList* Loot::FillFFALoot(Player* player)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PlayerFFAItems[player->GetGUIDLow()] = ql;
|
||||
m_playerFFAItems[player->GetGUIDLow()] = ql;
|
||||
return ql;
|
||||
}
|
||||
|
||||
|
|
@ -522,9 +522,9 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
|
|||
if (items.size() == MAX_NR_LOOT_ITEMS) return NULL;
|
||||
QuestItemList *ql = new QuestItemList();
|
||||
|
||||
for(uint8 i = 0; i < quest_items.size(); ++i)
|
||||
for(uint8 i = 0; i < m_questItems.size(); ++i)
|
||||
{
|
||||
LootItem &item = quest_items[i];
|
||||
LootItem &item = m_questItems[i];
|
||||
if(!item.is_looted && item.AllowedForPlayer(player) )
|
||||
{
|
||||
ql->push_back(QuestItem(i));
|
||||
|
|
@ -548,7 +548,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PlayerQuestItems[player->GetGUIDLow()] = ql;
|
||||
m_playerQuestItems[player->GetGUIDLow()] = ql;
|
||||
return ql;
|
||||
}
|
||||
|
||||
|
|
@ -575,7 +575,7 @@ QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PlayerNonQuestNonFFAConditionalItems[player->GetGUIDLow()] = ql;
|
||||
m_playerNonQuestNonFFAConditionalItems[player->GetGUIDLow()] = ql;
|
||||
return ql;
|
||||
}
|
||||
|
||||
|
|
@ -585,30 +585,30 @@ void Loot::NotifyItemRemoved(uint8 lootIndex)
|
|||
{
|
||||
// notify all players that are looting this that the item was removed
|
||||
// convert the index to the slot the player sees
|
||||
std::set<uint64>::iterator i_next;
|
||||
for(std::set<uint64>::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next)
|
||||
PlayersLooting::iterator i_next;
|
||||
for (PlayersLooting::iterator i = m_playersLooting.begin(); i != m_playersLooting.end(); i = i_next)
|
||||
{
|
||||
i_next = i;
|
||||
++i_next;
|
||||
if(Player* pl = ObjectAccessor::FindPlayer(*i))
|
||||
if (Player* pl = ObjectAccessor::FindPlayer(*i))
|
||||
pl->SendNotifyLootItemRemoved(lootIndex);
|
||||
else
|
||||
PlayersLooting.erase(i);
|
||||
m_playersLooting.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
void Loot::NotifyMoneyRemoved()
|
||||
{
|
||||
// notify all players that are looting this that the money was removed
|
||||
std::set<uint64>::iterator i_next;
|
||||
for(std::set<uint64>::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next)
|
||||
PlayersLooting::iterator i_next;
|
||||
for (PlayersLooting::iterator i = m_playersLooting.begin(); i != m_playersLooting.end(); i = i_next)
|
||||
{
|
||||
i_next = i;
|
||||
++i_next;
|
||||
if(Player* pl = ObjectAccessor::FindPlayer(*i))
|
||||
if (Player* pl = ObjectAccessor::FindPlayer(*i))
|
||||
pl->SendNotifyLootMoneyRemoved();
|
||||
else
|
||||
PlayersLooting.erase(i);
|
||||
m_playersLooting.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -619,15 +619,15 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
|
|||
// (other questitems can be looted by each group member)
|
||||
// bit inefficient but isnt called often
|
||||
|
||||
std::set<uint64>::iterator i_next;
|
||||
for(std::set<uint64>::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next)
|
||||
PlayersLooting::iterator i_next;
|
||||
for (PlayersLooting::iterator i = m_playersLooting.begin(); i != m_playersLooting.end(); i = i_next)
|
||||
{
|
||||
i_next = i;
|
||||
++i_next;
|
||||
if(Player* pl = ObjectAccessor::FindPlayer(*i))
|
||||
if (Player* pl = ObjectAccessor::FindPlayer(*i))
|
||||
{
|
||||
QuestItemMap::const_iterator pq = PlayerQuestItems.find(pl->GetGUIDLow());
|
||||
if (pq != PlayerQuestItems.end() && pq->second)
|
||||
QuestItemMap::const_iterator pq = m_playerQuestItems.find(pl->GetGUIDLow());
|
||||
if (pq != m_playerQuestItems.end() && pq->second)
|
||||
{
|
||||
// find where/if the player has the given item in it's vector
|
||||
QuestItemList& pql = *pq->second;
|
||||
|
|
@ -642,7 +642,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
|
|||
}
|
||||
}
|
||||
else
|
||||
PlayersLooting.erase(i);
|
||||
m_playersLooting.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -666,13 +666,13 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
|
|||
if (lootSlot >= items.size())
|
||||
{
|
||||
uint32 questSlot = lootSlot - items.size();
|
||||
QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow());
|
||||
if (itr != PlayerQuestItems.end() && questSlot < itr->second->size())
|
||||
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)
|
||||
*qitem = qitem2;
|
||||
item = &quest_items[qitem2->index];
|
||||
item = &m_questItems[qitem2->index];
|
||||
is_looted = qitem2->is_looted;
|
||||
}
|
||||
}
|
||||
|
|
@ -682,8 +682,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
|
|||
is_looted = item->is_looted;
|
||||
if(item->freeforall)
|
||||
{
|
||||
QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUIDLow());
|
||||
if (itr != PlayerFFAItems.end())
|
||||
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)
|
||||
|
|
@ -698,8 +698,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
|
|||
}
|
||||
else if(item->conditionId)
|
||||
{
|
||||
QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow());
|
||||
if (itr != PlayerNonQuestNonFFAConditionalItems.end())
|
||||
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)
|
||||
{
|
||||
|
|
@ -724,8 +724,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
|
|||
|
||||
uint32 Loot::GetMaxSlotInLootFor(Player* player) const
|
||||
{
|
||||
QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow());
|
||||
return items.size() + (itr != PlayerQuestItems.end() ? itr->second->size() : 0);
|
||||
QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow());
|
||||
return items.size() + (itr != m_playerQuestItems.end() ? itr->second->size() : 0);
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& b, LootItem const& li)
|
||||
|
|
@ -802,7 +802,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
|
|||
QuestItemList *q_list = q_itr->second;
|
||||
for (QuestItemList::const_iterator qi = q_list->begin() ; qi != q_list->end(); ++qi)
|
||||
{
|
||||
LootItem &item = l.quest_items[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()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue