Fixed a bug where the pickpocket spell would share picked up money with the caster's group. Fixes #2.

This commit is contained in:
Tristan Cormier 2017-01-28 02:10:01 -05:00 committed by Antz
parent 06d9945fd9
commit d6e44477ba

View File

@ -270,35 +270,41 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/)
if (pLoot) if (pLoot)
{ {
pLoot->NotifyMoneyRemoved(); pLoot->NotifyMoneyRemoved();
// Items/objects can ONLY be looted by a single player
if (!guid.IsItem() && player->GetGroup()) // item can be looted only single player if (!guid.IsItem() && player->GetGroup())
{ {
Group* group = player->GetGroup(); // Pickpocket case
if (player->getClass() == CLASS_ROGUE && GetPlayer()->GetMap()->GetCreature(guid)->lootForPickPocketed)
player->ModifyMoney(pLoot->gold);
else
{
Group* group = player->GetGroup();
std::vector<Player*> playersNear; std::vector<Player*> playersNear;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player* playerGroup = itr->getSource(); Player* playerGroup = itr->getSource();
if (!playerGroup) if (!playerGroup)
{ continue; } continue;
if (player->IsWithinDistInMap(playerGroup, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false)) if (player->IsWithinDistInMap(playerGroup, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
{ playersNear.push_back(playerGroup); } playersNear.push_back(playerGroup);
} }
uint32 money_per_player = uint32((pLoot->gold) / (playersNear.size())); uint32 money_per_player = uint32((pLoot->gold) / (playersNear.size()));
for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i) for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{ {
(*i)->ModifyMoney(money_per_player); (*i)->ModifyMoney(money_per_player);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4); WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4);
data << uint32(money_per_player); data << uint32(money_per_player);
(*i)->GetSession()->SendPacket(&data); (*i)->GetSession()->SendPacket(&data);
} }
}
} }
else else
{ player->ModifyMoney(pLoot->gold); } player->ModifyMoney(pLoot->gold);
// Used by Eluna // Used by Eluna
#ifdef ENABLE_ELUNA #ifdef ENABLE_ELUNA
@ -308,7 +314,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/)
pLoot->gold = 0; pLoot->gold = 0;
if (pItem) if (pItem)
{ pItem->SetLootState(ITEM_LOOT_CHANGED); } pItem->SetLootState(ITEM_LOOT_CHANGED);
} }
} }