Skip to content

Commit

Permalink
[9843] Restore need seelction show at loot roll.
Browse files Browse the repository at this point in the history
Also some clanups including merge 2 roll type enum.
  • Loading branch information
VladimirMangos committed May 6, 2010
1 parent dae88ff commit 4b92024
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 65 deletions.
68 changes: 36 additions & 32 deletions src/game/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "InstanceSaveMgr.h"
#include "MapInstanced.h"
#include "Util.h"
#include "LootMgr.h"

Group::Group() : m_Id(0), m_leaderGuid(0), m_mainTank(0), m_mainAssistant(0), m_groupType(GROUPTYPE_NORMAL),
m_dungeonDifficulty(REGULAR_DIFFICULTY), m_raidDifficulty(REGULAR_DIFFICULTY),
Expand Down Expand Up @@ -457,15 +458,15 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r)
data << uint32(r.itemRandomPropId); // item random property ID
data << uint32(r.itemCount); // items in stack
data << uint32(CountDown); // the countdown time to choose "need" or "greed"
data << uint8(ALL_ROLL_TYPE_MASK); // roll type mask
data << uint8(ALL_ROLL_VOTE_MASK); // roll type mask, allowed choises

for (Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
{
Player *p = sObjectMgr.GetPlayer(itr->first);
if(!p || !p->GetSession())
continue;

if(itr->second != NOT_VALID)
if(itr->second != ROLL_NOT_VALID)
p->GetSession()->SendPacket( &data );
}
}
Expand All @@ -489,12 +490,12 @@ void Group::SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 r
if(!p || !p->GetSession())
continue;

if(itr->second != NOT_VALID)
if(itr->second != ROLL_NOT_VALID)
p->GetSession()->SendPacket( &data );
}
}

void Group::SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll &r)
void Group::SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, RollVote rollType, const Roll &r)
{
WorldPacket data(SMSG_LOOT_ROLL_WON, (8+4+4+4+4+8+1+1));
data << r.lootedTargetGUID; // creature guid what we're looting
Expand All @@ -512,7 +513,7 @@ void Group::SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, uint
if(!p || !p->GetSession())
continue;

if(itr->second != NOT_VALID)
if(itr->second != ROLL_NOT_VALID)
p->GetSession()->SendPacket( &data );
}
}
Expand All @@ -532,7 +533,7 @@ void Group::SendLootAllPassed(Roll const& r)
if(!p || !p->GetSession())
continue;

if(itr->second != NOT_VALID)
if(itr->second != ROLL_NOT_VALID)
p->GetSession()->SendPacket( &data );
}
}
Expand Down Expand Up @@ -569,7 +570,7 @@ void Group::GroupLoot(ObjectGuid const& playerGUID, Loot *loot, Creature *creatu
{
if (member->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
{
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
r->playerVote[member->GetGUID()] = ROLL_NOT_EMITED_YET;
++r->totalPlayersRolling;
}
}
Expand All @@ -581,7 +582,7 @@ void Group::GroupLoot(ObjectGuid const& playerGUID, Loot *loot, Creature *creatu
r->itemSlot = itemSlot;

if (r->totalPlayersRolling == 1) // single looter
r->playerVote.begin()->second = NEED;
r->playerVote.begin()->second = ROLL_NEED;
else
{
group->SendLootStartRoll(60000, creature->GetMapId(), *r);
Expand Down Expand Up @@ -628,7 +629,7 @@ void Group::NeedBeforeGreed(ObjectGuid const& playerGUID, Loot *loot, Creature *
{
if (playerToRoll->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
{
r->playerVote[playerToRoll->GetGUID()] = NOT_EMITED_YET;
r->playerVote[playerToRoll->GetGUID()] = ROLL_NOT_EMITED_YET;
++r->totalPlayersRolling;
}
}
Expand All @@ -640,7 +641,7 @@ void Group::NeedBeforeGreed(ObjectGuid const& playerGUID, Loot *loot, Creature *
r->itemSlot = itemSlot;

if (r->totalPlayersRolling == 1) // single looter
r->playerVote.begin()->second = NEED;
r->playerVote.begin()->second = ROLL_NEED;
else
{
group->SendLootStartRoll(60000, creature->GetMapId(), *r);
Expand Down Expand Up @@ -693,7 +694,7 @@ void Group::MasterLoot(ObjectGuid const& playerGUID, Loot* /*loot*/, Creature *c
}
}

void Group::CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& lootedTarget, uint32 itemSlot, uint8 choise)
void Group::CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote choise)
{
Rolls::iterator rollI = RollId.begin();
for (; rollI != RollId.end(); ++rollI)
Expand All @@ -706,7 +707,7 @@ void Group::CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& looted
CountRollVote(playerGUID, rollI, choise);
}

bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI, uint8 choise)
bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI, RollVote choise)
{
Roll* roll = *rollI;

Expand All @@ -723,33 +724,36 @@ bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI,
{
case ROLL_PASS: // Player choose pass
{
SendLootRoll(playerGUID, 0, ROLL_PASS, *roll);
SendLootRoll(playerGUID, 128, 128, *roll);
++roll->totalPass;
itr->second = PASS;
itr->second = ROLL_PASS;
break;
}
break;
case ROLL_NEED: // player choose Need
{
SendLootRoll(playerGUID, 0, ROLL_NEED, *roll);
SendLootRoll(playerGUID, 0, 0, *roll);
++roll->totalNeed;
itr->second = NEED;
itr->second = ROLL_NEED;
break;
}
break;
case ROLL_GREED: // player choose Greed
{
SendLootRoll(playerGUID, 128, ROLL_GREED, *roll);
++roll->totalGreed;
itr->second = GREED;
itr->second = ROLL_GREED;
break;
}
break;
case ROLL_DISENCHANT: // player choose Disenchant
{
SendLootRoll(playerGUID, 128, ROLL_DISENCHANT, *roll);
++roll->totalGreed;
itr->second = DISENCHANT;
itr->second = ROLL_DISENCHANT;
break;
}
break;
default: // Roll removed case
break;
}

if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling)
{
CountTheRoll(rollI);
Expand Down Expand Up @@ -791,7 +795,7 @@ void Group::CountTheRoll(Rolls::iterator& rollI)

for( Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
{
if (itr->second != NEED)
if (itr->second != ROLL_NEED)
continue;

uint8 randomN = urand(1, 99);
Expand Down Expand Up @@ -834,12 +838,12 @@ void Group::CountTheRoll(Rolls::iterator& rollI)
uint8 maxresul = 0;
uint64 maxguid = (*roll->playerVote.begin()).first;
Player *player;
RollVote rollvote = PASS; //Fixed: Using uninitialized memory 'rollvote'
RollVote rollvote = ROLL_PASS; //Fixed: Using uninitialized memory 'rollvote'

Roll::PlayerVote::iterator itr;
for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
{
if (itr->second != GREED && itr->second != DISENCHANT)
if (itr->second != ROLL_GREED && itr->second != ROLL_DISENCHANT)
continue;

uint8 randomN = urand(1, 99);
Expand All @@ -860,7 +864,7 @@ void Group::CountTheRoll(Rolls::iterator& rollI)

LootItem *item = &(roll->getLoot()->items[roll->itemSlot]);

if(rollvote == GREED)
if(rollvote == ROLL_GREED)
{
ItemPosCountVec dest;
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count );
Expand All @@ -877,7 +881,7 @@ void Group::CountTheRoll(Rolls::iterator& rollI)
player->SendEquipError( msg, NULL, NULL, roll->itemid );
}
}
else if(rollvote == DISENCHANT)
else if(rollvote == ROLL_DISENCHANT)
{
item->is_looted = true;
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
Expand Down Expand Up @@ -1258,18 +1262,18 @@ void Group::_removeRolls(const uint64 &guid)
continue;
}

if (itr2->second == GREED || itr2->second == DISENCHANT)
if (itr2->second == ROLL_GREED || itr2->second == ROLL_DISENCHANT)
--roll->totalGreed;
if (itr2->second == NEED)
if (itr2->second == ROLL_NEED)
--roll->totalNeed;
if (itr2->second == PASS)
if (itr2->second == ROLL_PASS)
--roll->totalPass;
if (itr2->second != NOT_VALID)
if (itr2->second != ROLL_NOT_VALID)
--roll->totalPlayersRolling;

roll->playerVote.erase(itr2);

if (!CountRollVote(guid, it, MAX_ROLL_TYPE))
if (!CountRollVote(guid, it, ROLL_NOT_EMITED_YET))
++it;
}
}
Expand Down
33 changes: 24 additions & 9 deletions src/game/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,29 @@
#define MAXRAIDSIZE 40
#define TARGETICONCOUNT 8

enum LootMethod
{
FREE_FOR_ALL = 0,
ROUND_ROBIN = 1,
MASTER_LOOT = 2,
GROUP_LOOT = 3,
NEED_BEFORE_GREED = 4
};

#define ALL_ROLL_VOTE_MASK 0x0F // set what votes allowed

enum RollVote
{
PASS = 0,
NEED = 1,
GREED = 2,
DISENCHANT = 3,
NOT_EMITED_YET = 4,
NOT_VALID = 5
ROLL_PASS = 0,
ROLL_NEED = 1,
ROLL_GREED = 2,
ROLL_DISENCHANT = 3,

// other not send by client
MAX_ROLL_FROM_CLIENT = 4,

ROLL_NOT_EMITED_YET = 4, // send to client
ROLL_NOT_VALID = 5 // not send to client
};

enum GroupMemberOnlineStatus
Expand Down Expand Up @@ -314,12 +329,12 @@ class MANGOS_DLL_SPEC Group

void SendLootStartRoll(uint32 CountDown, uint32 mapid, 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 SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, RollVote rollType, const Roll &r);
void SendLootAllPassed(const Roll &r);
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);
void CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& lootedTarget, uint32 itemSlot, uint8 choise);
void CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote choise);
void EndRoll();

void LinkMember(GroupReference *pRef) { m_memberMgr.insertFirst(pRef); }
Expand Down Expand Up @@ -391,7 +406,7 @@ class MANGOS_DLL_SPEC Group
}

void CountTheRoll(Rolls::iterator& roll); // iterator update to next, in CountRollVote if true
bool CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& roll, uint8 choise);
bool CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& roll, RollVote choise);

uint32 m_Id; // 0 for not created or BG groups
MemberSlotList m_memberSlots;
Expand Down
7 changes: 5 additions & 2 deletions src/game/GroupHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,14 @@ void WorldSession::HandleLootRoll( WorldPacket &recv_data )
//DEBUG_LOG("WORLD RECIEVE CMSG_LOOT_ROLL, From:%u, Numberofplayers:%u, rollType:%u", (uint32)Guid, NumberOfPlayers, rollType);

Group* group = GetPlayer()->GetGroup();
if(!group)
if (!group)
return;

if (rollType >= MAX_ROLL_FROM_CLIENT)
return;

// everything is fine, do it
group->CountRollVote(GetPlayer()->GetObjectGuid(), lootedTarget, itemSlot, rollType);
group->CountRollVote(GetPlayer()->GetObjectGuid(), lootedTarget, itemSlot, RollVote(rollType));

switch (rollType)
{
Expand Down
20 changes: 0 additions & 20 deletions src/game/LootMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,11 @@
#include <map>
#include <vector>

enum RollType
{
ROLL_PASS = 0,
ROLL_NEED = 1,
ROLL_GREED = 2,
ROLL_DISENCHANT = 3,
MAX_ROLL_TYPE = 4
};

#define ALL_ROLL_TYPE_MASK 0x0F

#define MAX_NR_LOOT_ITEMS 16
// note: the client cannot show more than 16 items total
#define MAX_NR_QUEST_ITEMS 32
// unrelated to the number of quest items shown, just for reserve

enum LootMethod
{
FREE_FOR_ALL = 0,
ROUND_ROBIN = 1,
MASTER_LOOT = 2,
GROUP_LOOT = 3,
NEED_BEFORE_GREED = 4
};

enum PermissionTypes
{
ALL_PERMISSION = 0,
Expand Down
1 change: 0 additions & 1 deletion src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2662,5 +2662,4 @@ bool Player::CheckAllControlledUnits(Func const& func, bool withTotems, bool wit
return Unit::CheckAllControlledUnits(func,withTotems,withGuardians,withCharms);
}


#endif
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 "9842"
#define REVISION_NR "9843"
#endif // __REVISION_NR_H__

1 comment on commit 4b92024

@DarkYodah
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be CHOICE instead of CHOISE ?

Please sign in to comment.