mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +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
|
|
@ -495,7 +495,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
|
|||
}
|
||||
|
||||
//Player is not looking at loot list, he doesn't need to see updates on the loot list
|
||||
loot->RemoveLooter(player->GetGUID());
|
||||
loot->RemoveLooter(player->GetObjectGuid());
|
||||
}
|
||||
|
||||
void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
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))
|
||||
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))
|
||||
{
|
||||
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()));
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "ItemEnchantmentMgr.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Utilities/LinkedReference/RefManager.h"
|
||||
|
||||
#include <map>
|
||||
|
|
@ -235,9 +236,9 @@ struct Loot
|
|||
{
|
||||
friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
|
||||
|
||||
QuestItemMap const& GetPlayerQuestItems() const { return PlayerQuestItems; }
|
||||
QuestItemMap const& GetPlayerFFAItems() const { return PlayerFFAItems; }
|
||||
QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return PlayerNonQuestNonFFAConditionalItems; }
|
||||
QuestItemMap const& GetPlayerQuestItems() const { return m_playerQuestItems; }
|
||||
QuestItemMap const& GetPlayerFFAItems() const { return m_playerFFAItems; }
|
||||
QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return m_playerNonQuestNonFFAConditionalItems; }
|
||||
|
||||
LootItemList items;
|
||||
uint32 gold;
|
||||
|
|
@ -250,30 +251,30 @@ struct Loot
|
|||
// if loot becomes invalid this reference is used to inform the listener
|
||||
void addLootValidatorRef(LootValidatorRef* pLootValidatorRef)
|
||||
{
|
||||
i_LootValidatorRefManager.insertFirst(pLootValidatorRef);
|
||||
m_LootValidatorRefManager.insertFirst(pLootValidatorRef);
|
||||
}
|
||||
|
||||
// void clear();
|
||||
void clear()
|
||||
{
|
||||
for (QuestItemMap::const_iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr)
|
||||
for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr)
|
||||
delete itr->second;
|
||||
PlayerQuestItems.clear();
|
||||
m_playerQuestItems.clear();
|
||||
|
||||
for (QuestItemMap::const_iterator itr = PlayerFFAItems.begin(); itr != PlayerFFAItems.end(); ++itr)
|
||||
for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr)
|
||||
delete itr->second;
|
||||
PlayerFFAItems.clear();
|
||||
m_playerFFAItems.clear();
|
||||
|
||||
for (QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.begin(); itr != PlayerNonQuestNonFFAConditionalItems.end(); ++itr)
|
||||
for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.begin(); itr != m_playerNonQuestNonFFAConditionalItems.end(); ++itr)
|
||||
delete itr->second;
|
||||
PlayerNonQuestNonFFAConditionalItems.clear();
|
||||
m_playerNonQuestNonFFAConditionalItems.clear();
|
||||
|
||||
PlayersLooting.clear();
|
||||
m_playersLooting.clear();
|
||||
items.clear();
|
||||
quest_items.clear();
|
||||
m_questItems.clear();
|
||||
gold = 0;
|
||||
unlootedCount = 0;
|
||||
i_LootValidatorRefManager.clearReferences();
|
||||
m_LootValidatorRefManager.clearReferences();
|
||||
}
|
||||
|
||||
bool empty() const { return items.empty() && gold == 0; }
|
||||
|
|
@ -282,8 +283,8 @@ struct Loot
|
|||
void NotifyItemRemoved(uint8 lootIndex);
|
||||
void NotifyQuestItemRemoved(uint8 questIndex);
|
||||
void NotifyMoneyRemoved();
|
||||
void AddLooter(uint64 GUID) { PlayersLooting.insert(GUID); }
|
||||
void RemoveLooter(uint64 GUID) { PlayersLooting.erase(GUID); }
|
||||
void AddLooter(ObjectGuid guid) { m_playersLooting.insert(guid); }
|
||||
void RemoveLooter(ObjectGuid guid) { m_playersLooting.erase(guid); }
|
||||
|
||||
void generateMoneyLoot(uint32 minAmount, uint32 maxAmount);
|
||||
bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false);
|
||||
|
|
@ -300,14 +301,17 @@ struct Loot
|
|||
QuestItemList* FillQuestLoot(Player* player);
|
||||
QuestItemList* FillNonQuestNonFFAConditionalLoot(Player* player);
|
||||
|
||||
LootItemList quest_items;
|
||||
std::set<uint64> PlayersLooting;
|
||||
QuestItemMap PlayerQuestItems;
|
||||
QuestItemMap PlayerFFAItems;
|
||||
QuestItemMap PlayerNonQuestNonFFAConditionalItems;
|
||||
LootItemList m_questItems;
|
||||
|
||||
typedef std::set<ObjectGuid> PlayersLooting;
|
||||
PlayersLooting m_playersLooting;
|
||||
|
||||
QuestItemMap m_playerQuestItems;
|
||||
QuestItemMap m_playerFFAItems;
|
||||
QuestItemMap m_playerNonQuestNonFFAConditionalItems;
|
||||
|
||||
// All rolls are registered here. They need to know, when the loot is not valid anymore
|
||||
LootValidatorRefManager i_LootValidatorRefManager;
|
||||
LootValidatorRefManager m_LootValidatorRefManager;
|
||||
};
|
||||
|
||||
struct LootView
|
||||
|
|
|
|||
|
|
@ -8253,7 +8253,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
|
|||
|
||||
// add 'this' player as one of the players that are looting 'loot'
|
||||
if (permission != NONE_PERMISSION)
|
||||
loot->AddLooter(GetGUID());
|
||||
loot->AddLooter(GetObjectGuid());
|
||||
|
||||
if (loot_type == LOOT_CORPSE && !guid.IsItem())
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11453"
|
||||
#define REVISION_NR "11454"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue