Skip to content

Commit

Permalink
Fix looting animation when loot is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberium committed May 31, 2016
1 parent eecee9a commit a29d18c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions src/game/LootMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,8 @@ void Loot::ShowContentTo(Player* plr)
data << m_guidTarget;
data << uint8(m_clientLootType);

if (GetLootContentFor(plr, data))
SetPlayerIsLooting(plr);
GetLootContentFor(plr, data); // fill the data with items contained in the loot (may be empty)
SetPlayerIsLooting(plr);

plr->SendDirectMessage(&data);
}
Expand Down Expand Up @@ -2125,8 +2125,19 @@ void Loot::SendGold(Player* player)
ForceLootAnimationCLientUpdate();
}

bool Loot::IsItemAlreadyIn(uint32 itemId) const
{
for (LootItemList::const_iterator lootItemItr = m_lootItems.begin(); lootItemItr != m_lootItems.end(); ++lootItemItr)
{
LootItem* lootItem = *lootItemItr;
if (lootItem->itemId == itemId)
return true;
}
return false;
}

// fill in the bytebuffer with loot content for specified player (return false if no items/gold filled)
bool Loot::GetLootContentFor(Player* player, ByteBuffer& buffer)
void Loot::GetLootContentFor(Player* player, ByteBuffer& buffer)
{
uint8 itemsShown = 0;

Expand All @@ -2142,7 +2153,7 @@ bool Loot::GetLootContentFor(Player* player, ByteBuffer& buffer)
LootSlotType slot_type = lootItem->GetSlotTypeForSharedLoot(player, this);
if (slot_type >= MAX_LOOT_SLOT_TYPE)
{
sLog.outDebug("Item cannot send> itemid(%u) in slot (%u)!", lootItem->itemId, uint32(lootItem->lootSlot));
sLog.outDebug("Item not visible for %s> itemid(%u) in slot (%u)!", player->GetGuidStr().c_str(), lootItem->itemId, uint32(lootItem->lootSlot));
continue;
}

Expand All @@ -2151,12 +2162,11 @@ bool Loot::GetLootContentFor(Player* player, ByteBuffer& buffer)
buffer << uint8(slot_type); // 0 - get 1 - look only 2 - master selection
++itemsShown;

sLog.outDebug("Sending loot> itemid(%u) in slot (%u)!", lootItem->itemId, uint32(lootItem->lootSlot));
sLog.outDebug("Sending loot to %s> itemid(%u) in slot (%u)!", player->GetGuidStr().c_str(), lootItem->itemId, uint32(lootItem->lootSlot));
}

// update number of items shown
buffer.put<uint8>(count_pos, itemsShown);
return m_gold != 0 || itemsShown != 0;
}

ByteBuffer& operator<<(ByteBuffer& b, LootItem const& li)
Expand Down
2 changes: 1 addition & 1 deletion src/game/LootMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class Loot
void ForceLootAnimationCLientUpdate();
void SetPlayerIsLooting(Player* player);
void SetPlayerIsNotLooting(Player* player);
bool GetLootContentFor(Player* player, ByteBuffer& buffer);
void GetLootContentFor(Player* player, ByteBuffer& buffer);
// What is looted
WorldObject* m_lootTarget;
Item* m_itemTarget;
Expand Down

0 comments on commit a29d18c

Please sign in to comment.