Skip to content

Commit

Permalink
[9582] Send looted creature guid in proper field of loot packets.
Browse files Browse the repository at this point in the history
Also use ObjectGuid in related functions.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
  • Loading branch information
Opterman authored and VladimirMangos committed Mar 13, 2010
1 parent a5b43fc commit cee592b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 49 deletions.
70 changes: 35 additions & 35 deletions src/game/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ void Group::Disband(bool hideDestroy)
void Group::SendLootStartRoll(uint32 CountDown, const Roll &r)
{
WorldPacket data(SMSG_LOOT_START_ROLL, (8+4+4+4+4+4+4+1));
data << uint64(r.itemGUID); // guid of rolled item
data << uint32(r.totalPlayersRolling); // maybe the number of players rolling for it???
data << r.lootedTargetGUID; // creature guid what we're looting
data << uint32(r.totalPlayersRolling); // maybe the number of players rolling for it, or item slot in loot
data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
data << uint32(r.itemRandomSuffix); // randomSuffix
data << uint32(r.itemRandomPropId); // item random property ID
Expand All @@ -468,17 +468,17 @@ void Group::SendLootStartRoll(uint32 CountDown, const Roll &r)
}
}

void Group::SendLootRoll(const uint64& SourceGuid, const uint64& TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
void Group::SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll &r)
{
WorldPacket data(SMSG_LOOT_ROLL, (8+4+8+4+4+4+1+1+1));
data << uint64(SourceGuid); // guid of the item rolled
data << uint32(0); // unknown, maybe amount of players
data << uint64(TargetGuid);
data << r.lootedTargetGUID; // creature guid what we're looting
data << uint32(0); // unknown, maybe amount of players, or item slot in loot
data << targetGuid;
data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
data << uint32(r.itemRandomSuffix); // randomSuffix
data << uint32(r.itemRandomPropId); // Item random property ID
data << uint8(RollNumber); // 0: "Need for: [item name]" > 127: "you passed on: [item name]" Roll number
data << uint8(RollType); // 0: "Need for: [item name]" 0: "You have selected need for [item name] 1: need roll 2: greed roll
data << uint8(rollNumber); // 0: "Need for: [item name]" > 127: "you passed on: [item name]" Roll number
data << uint8(rollType); // 0: "Need for: [item name]" 0: "You have selected need for [item name] 1: need roll 2: greed roll
data << uint8(0); // 2.4.0

for( Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
Expand All @@ -492,17 +492,17 @@ void Group::SendLootRoll(const uint64& SourceGuid, const uint64& TargetGuid, uin
}
}

void Group::SendLootRollWon(const uint64& SourceGuid, const uint64& TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
void Group::SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll &r)
{
WorldPacket data(SMSG_LOOT_ROLL_WON, (8+4+4+4+4+8+1+1));
data << uint64(SourceGuid); // guid of the item rolled
data << uint32(0); // unknown, maybe amount of players
data << r.lootedTargetGUID; // creature guid what we're looting
data << uint32(0); // unknown, maybe amount of players, or item slot in loot
data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
data << uint32(r.itemRandomSuffix); // randomSuffix
data << uint32(r.itemRandomPropId); // Item random property
data << uint64(TargetGuid); // guid of the player who won.
data << uint8(RollNumber); // rollnumber realted to SMSG_LOOT_ROLL
data << uint8(RollType); // Rolltype related to SMSG_LOOT_ROLL
data << targetGuid; // guid of the player who won.
data << uint8(rollNumber); // rollnumber realted to SMSG_LOOT_ROLL
data << uint8(rollType); // Rolltype related to SMSG_LOOT_ROLL

for( Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
{
Expand All @@ -518,8 +518,8 @@ void Group::SendLootRollWon(const uint64& SourceGuid, const uint64& TargetGuid,
void Group::SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r)
{
WorldPacket data(SMSG_LOOT_ALL_PASSED, (8+4+4+4+4));
data << uint64(r.itemGUID); // Guid of the item rolled
data << uint32(NumberOfPlayers); // The number of players rolling for it???
data << r.lootedTargetGUID; // creature guid what we're looting
data << uint32(NumberOfPlayers); // The number of players rolling for it, or item slot in loot
data << uint32(r.itemid); // The itemEntryId for the item that shall be rolled for
data << uint32(r.itemRandomPropId); // Item random property ID
data << uint32(r.itemRandomSuffix); // Item random suffix ID
Expand All @@ -535,7 +535,7 @@ void Group::SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r)
}
}

void Group::GroupLoot(const uint64& playerGUID, Loot *loot, Creature *creature)
void Group::GroupLoot(ObjectGuid const& playerGUID, Loot *loot, Creature *creature)
{
std::vector<LootItem>::iterator i;
ItemPrototype const *item;
Expand All @@ -556,7 +556,7 @@ void Group::GroupLoot(const uint64& playerGUID, Loot *loot, Creature *creature)
if (item->Quality >= uint32(m_lootThreshold) && !i->freeforall)
{
uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr.GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM);
Roll* r = new Roll(newitemGUID, *i);
Roll* r=new Roll(newitemGUID,creature->GetGUID(),*i);

//a vector is filled with only near party members
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
Expand Down Expand Up @@ -590,7 +590,7 @@ void Group::GroupLoot(const uint64& playerGUID, Loot *loot, Creature *creature)
}
}

void Group::NeedBeforeGreed(const uint64& playerGUID, Loot *loot, Creature *creature)
void Group::NeedBeforeGreed(ObjectGuid const& playerGUID, Loot *loot, Creature *creature)
{
ItemPrototype const *item;
Player *player = sObjectMgr.GetPlayer(playerGUID);
Expand All @@ -605,7 +605,7 @@ void Group::NeedBeforeGreed(const uint64& playerGUID, Loot *loot, Creature *crea
if (item->Quality >= uint32(m_lootThreshold) && !i->freeforall)
{
uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr.GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM);
Roll* r = new Roll(newitemGUID, *i);
Roll* r=new Roll(newitemGUID,creature->GetGUID(),*i);

for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
{
Expand Down Expand Up @@ -644,7 +644,7 @@ void Group::NeedBeforeGreed(const uint64& playerGUID, Loot *loot, Creature *crea
}
}

void Group::MasterLoot(const uint64& playerGUID, Loot* /*loot*/, Creature *creature)
void Group::MasterLoot(ObjectGuid const& playerGUID, Loot* /*loot*/, Creature *creature)
{
Player *player = sObjectMgr.GetPlayer(playerGUID);
if(!player)
Expand Down Expand Up @@ -680,14 +680,14 @@ void Group::MasterLoot(const uint64& playerGUID, Loot* /*loot*/, Creature *creat
}
}

void Group::CountRollVote(const uint64& playerGUID, const uint64& Guid, uint32 NumberOfPlayers, uint8 Choise)
void Group::CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& itemGuid, uint32 numberOfPlayers, uint8 choise)
{
Rolls::iterator rollI = GetRoll(Guid);
Rolls::iterator rollI = GetRoll(itemGuid);
if (rollI == RollId.end())
return;
Roll* roll = *rollI;

Roll::PlayerVote::iterator itr = roll->playerVote.find(playerGUID);
Roll::PlayerVote::iterator itr = roll->playerVote.find(playerGUID.GetMaxCounter());
// this condition means that player joins to the party after roll begins
if (itr == roll->playerVote.end())
return;
Expand All @@ -696,40 +696,40 @@ void Group::CountRollVote(const uint64& playerGUID, const uint64& Guid, uint32 N
if (roll->getLoot()->items.empty())
return;

switch (Choise)
switch (choise)
{
case ROLL_PASS: // Player choose pass
{
SendLootRoll(0, playerGUID, 0, ROLL_PASS, *roll);
SendLootRoll(playerGUID, 0, ROLL_PASS, *roll);
++roll->totalPass;
itr->second = PASS;
}
break;
case ROLL_NEED: // player choose Need
{
SendLootRoll(0, playerGUID, 0, ROLL_NEED, *roll);
SendLootRoll(playerGUID, 0, ROLL_NEED, *roll);
++roll->totalNeed;
itr->second = NEED;
}
break;
case ROLL_GREED: // player choose Greed
{
SendLootRoll(0, playerGUID, 128, ROLL_GREED, *roll);
SendLootRoll(playerGUID, 128, ROLL_GREED, *roll);
++roll->totalGreed;
itr->second = GREED;
}
break;
case ROLL_DISENCHANT: // player choose Disenchant
{
SendLootRoll(0, playerGUID, 128, ROLL_DISENCHANT, *roll);
SendLootRoll(playerGUID, 128, ROLL_DISENCHANT, *roll);
++roll->totalGreed;
itr->second = DISENCHANT;
}
break;
}
if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling)
{
CountTheRoll(rollI, NumberOfPlayers);
CountTheRoll(rollI, numberOfPlayers);
}
}

Expand Down Expand Up @@ -760,7 +760,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers)
if(!roll->playerVote.empty())
{
uint8 maxresul = 0;
uint64 maxguid = (*roll->playerVote.begin()).first;
ObjectGuid maxguid = (*roll->playerVote.begin()).first;
Player *player;

for( Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
Expand All @@ -769,14 +769,14 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers)
continue;

uint8 randomN = urand(1, 99);
SendLootRoll(0, itr->first, randomN, ROLL_NEED, *roll);
SendLootRoll(itr->first, randomN, ROLL_NEED, *roll);
if (maxresul < randomN)
{
maxguid = itr->first;
maxresul = randomN;
}
}
SendLootRollWon(0, maxguid, maxresul, ROLL_NEED, *roll);
SendLootRollWon(maxguid, maxresul, ROLL_NEED, *roll);
player = sObjectMgr.GetPlayer(maxguid);

if(player && player->GetSession())
Expand Down Expand Up @@ -817,15 +817,15 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers)
continue;

uint8 randomN = urand(1, 99);
SendLootRoll(0, itr->first, randomN, itr->second, *roll);
SendLootRoll(itr->first, randomN, itr->second, *roll);
if (maxresul < randomN)
{
maxguid = itr->first;
maxresul = randomN;
rollvote = itr->second;
}
}
SendLootRollWon(0, maxguid, maxresul, rollvote, *roll);
SendLootRollWon(maxguid, maxresul, rollvote, *roll);
player = sObjectMgr.GetPlayer(maxguid);

if(player && player->GetSession())
Expand Down
21 changes: 11 additions & 10 deletions src/game/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ class InstanceSave;
class Roll : public LootValidatorRef
{
public:
Roll(uint64 _guid, LootItem const& li)
: itemGUID(_guid), itemid(li.itemid), itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix), itemCount(li.count),
Roll(ObjectGuid _itemGuid, ObjectGuid _lootedTragetGuid, LootItem const& li)
: itemGUID(_itemGuid), lootedTargetGUID(_lootedTragetGuid), itemid(li.itemid), itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix),
totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0) {}
~Roll() { }
void setLoot(Loot *pLoot) { link(pLoot, this); }
Loot *getLoot() { return getTarget(); }
void targetObjectBuildLink();

uint64 itemGUID;
ObjectGuid itemGUID;
ObjectGuid lootedTargetGUID;
uint32 itemid;
int32 itemRandomPropId;
uint32 itemRandomSuffix;
Expand Down Expand Up @@ -313,13 +314,13 @@ class MANGOS_DLL_SPEC Group
/*********************************************************/

void SendLootStartRoll(uint32 CountDown, const Roll &r);
void SendLootRoll(const uint64& SourceGuid, const uint64& TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
void SendLootRollWon(const uint64& SourceGuid, const uint64& TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
void SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll &r);
void SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll &r);
void SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r);
void GroupLoot(const uint64& playerGUID, Loot *loot, Creature *creature);
void NeedBeforeGreed(const uint64& playerGUID, Loot *loot, Creature *creature);
void MasterLoot(const uint64& playerGUID, Loot *loot, Creature *creature);
Rolls::iterator GetRoll(uint64 Guid)
void GroupLoot(ObjectGuid const& playerGUID, Loot *loot, Creature *creature);
void NeedBeforeGreed(ObjectGuid const& playerGUID, Loot *loot, Creature *creature);
void MasterLoot(ObjectGuid const& playerGUID, Loot *loot, Creature *creature);
Rolls::iterator GetRoll(ObjectGuid const& Guid)
{
Rolls::iterator iter;
for (iter=RollId.begin(); iter != RollId.end(); ++iter)
Expand All @@ -332,7 +333,7 @@ class MANGOS_DLL_SPEC Group
return RollId.end();
}
void CountTheRoll(Rolls::iterator roll, uint32 NumberOfPlayers);
void CountRollVote(const uint64& playerGUID, const uint64& Guid, uint32 NumberOfPlayers, uint8 Choise);
void CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& itemGuid, uint32 numberOfPlayers, uint8 choise);
void EndRoll();

void LinkMember(GroupReference *pRef) { m_memberMgr.insertFirst(pRef); }
Expand Down
6 changes: 3 additions & 3 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7730,13 +7730,13 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
{
case GROUP_LOOT:
// GroupLoot delete items over threshold (threshold even not implemented), and roll them. Items with quality<threshold, round robin
group->GroupLoot(recipient->GetGUID(), loot, creature);
group->GroupLoot(recipient->GetObjectGuid(), loot, creature);
break;
case NEED_BEFORE_GREED:
group->NeedBeforeGreed(recipient->GetGUID(), loot, creature);
group->NeedBeforeGreed(recipient->GetObjectGuid(), loot, creature);
break;
case MASTER_LOOT:
group->MasterLoot(recipient->GetGUID(), loot, creature);
group->MasterLoot(recipient->GetObjectGuid(), loot, creature);
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9581"
#define REVISION_NR "9582"
#endif // __REVISION_NR_H__

0 comments on commit cee592b

Please sign in to comment.