Skip to content

Commit

Permalink
[10215] Implement ROLL_VOTE_DISENCHANT disable
Browse files Browse the repository at this point in the history
* for player without reqired enchanting skill
* for item without disenchanting possibility
  • Loading branch information
VladimirMangos committed Jul 17, 2010
1 parent edda486 commit 53ee68b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
35 changes: 28 additions & 7 deletions src/game/Group.cpp
Expand Up @@ -452,7 +452,6 @@ void Group::Disband(bool hideDestroy)
void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r)
{
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(r.itemid);
uint8 voteMask = pProto->Flags2 & ITEM_FLAGS2_NEED_ROLL_DISABLED ? ROLL_VOTE_MASK_NO_NEED : ROLL_VOTE_MASK_ALL;

WorldPacket data(SMSG_LOOT_START_ROLL, (8+4+4+4+4+4+4+1));
data << r.lootedTargetGUID; // creature guid what we're looting
Expand All @@ -463,16 +462,24 @@ 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(voteMask); // roll type mask, allowed choices

size_t voteMaskPos = data.wpos();
data << uint8(0); // roll type mask, allowed choices (placeholder)

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 != ROLL_NOT_VALID)
p->GetSession()->SendPacket( &data );
if(itr->second == ROLL_NOT_VALID)
continue;

// dependent from player
RollVoteMask voteMask = GetVoteMaskFor(pProto, p);
data.put<uint8>(voteMaskPos,uint8(voteMask));

p->GetSession()->SendPacket( &data );
}
}

Expand Down Expand Up @@ -622,7 +629,20 @@ void Group::MasterLoot(Creature *creature, Loot* loot)
}
}

bool Group::CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote vote)
RollVoteMask Group::GetVoteMaskFor( ItemPrototype const* itemProto, Player* player )
{
RollVoteMask mask = ROLL_VOTE_MASK_ALL;

if (itemProto->Flags2 & ITEM_FLAGS2_NEED_ROLL_DISABLED)
mask = RollVoteMask(mask & ~ROLL_VOTE_MASK_NEED);

if (!itemProto->DisenchantID || uint32(itemProto->RequiredDisenchantSkill) > player->GetSkillValue(SKILL_ENCHANTING))
mask = RollVoteMask(mask & ~ROLL_VOTE_MASK_DISENCHANT);

return mask;
}

bool Group::CountRollVote(Player* player, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote vote)
{
Rolls::iterator rollI = RollId.begin();
for (; rollI != RollId.end(); ++rollI)
Expand All @@ -634,10 +654,11 @@ bool Group::CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& looted

// possible cheating
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype((*rollI)->itemid);
if ((pProto->Flags2 & ITEM_FLAGS2_NEED_ROLL_DISABLED) && vote == ROLL_NEED)
RollVoteMask voteMask = GetVoteMaskFor(pProto, player);
if ((voteMask & (1 << vote)) == 0)
return false;

CountRollVote(playerGUID, rollI, vote); // result not related this function result meaning, ignore
CountRollVote(player->GetObjectGuid(), rollI, vote); // result not related this function result meaning, ignore
return true;
}

Expand Down
13 changes: 6 additions & 7 deletions src/game/Group.h
Expand Up @@ -28,6 +28,10 @@
#include <map>
#include <vector>

struct ItemPrototype;
class BattleGround;
class InstanceSave;

#define MAX_GROUP_SIZE 5
#define MAX_RAID_SIZE 40
#define MAX_RAID_SUBGROUPS (MAX_RAID_SIZE / MAX_GROUP_SIZE)
Expand Down Expand Up @@ -65,8 +69,6 @@ enum RollVoteMask
ROLL_VOTE_MASK_DISENCHANT = 0x08,

ROLL_VOTE_MASK_ALL = 0x0F,

ROLL_VOTE_MASK_NO_NEED = ROLL_VOTE_MASK_ALL & ~ROLL_VOTE_MASK_NEED,
};


Expand Down Expand Up @@ -101,8 +103,6 @@ enum GroupFlagMask
GROUP_MAIN_TANK = 0x04,
};

class BattleGround;

enum GroupUpdateFlags
{
GROUP_UPDATE_FLAG_NONE = 0x00000000, // nothing
Expand Down Expand Up @@ -134,8 +134,6 @@ enum GroupUpdateFlags
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19
static const uint8 GroupUpdateLength[GROUP_UPDATE_FLAGS_COUNT] = { 0, 2, 2, 2, 1, 2, 2, 2, 2, 4, 8, 8, 1, 2, 2, 2, 1, 2, 2, 8};

class InstanceSave;

class Roll : public LootValidatorRef
{
public:
Expand Down Expand Up @@ -357,7 +355,7 @@ class MANGOS_DLL_SPEC Group
void GroupLoot(Creature *creature, Loot *loot);
void NeedBeforeGreed(Creature *creature, Loot *loot);
void MasterLoot(Creature *creature, Loot *loot);
bool CountRollVote(ObjectGuid const& playerGUID, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote vote);
bool CountRollVote(Player* player, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote vote);
void StartLootRool(Creature* lootTarget, Loot* loot, uint8 itemSlot, bool skipIfCanNotUse);
void EndRoll();

Expand Down Expand Up @@ -431,6 +429,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, RollVote vote);
static RollVoteMask GetVoteMaskFor(ItemPrototype const* itemProto, Player* player);

GroupFlagMask GetFlags(MemberSlot const& slot) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/GroupHandler.cpp
Expand Up @@ -393,7 +393,7 @@ void WorldSession::HandleLootRoll( WorldPacket &recv_data )
return;

// everything is fine, do it, if false then some cheating problem found
if(!group->CountRollVote(GetPlayer()->GetObjectGuid(), lootedTarget, itemSlot, RollVote(rollType)))
if(!group->CountRollVote(GetPlayer(), lootedTarget, itemSlot, RollVote(rollType)))
return;

switch (rollType)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10214"
#define REVISION_NR "10215"
#endif // __REVISION_NR_H__

3 comments on commit 53ee68b

@LordJZ
Copy link
Contributor

@LordJZ LordJZ commented on 53ee68b Jul 17, 2010

Choose a reason for hiding this comment

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

If an enchanter with enough required skill to disenchant an item is in the party, then all members of the party should be able to roll disenchant...

Also, good job on implementing all thouse new flags and stuff.

@Naxp
Copy link

@Naxp Naxp commented on 53ee68b Jul 17, 2010

Choose a reason for hiding this comment

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

Agreed , Great Work. Keep it up you and your fellow developers dedication is greatly apprecaited.

@VladimirMangos
Copy link

Choose a reason for hiding this comment

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

I am already informed, thanks anyway for note. I work at reimplement in more proper way... :)

Please sign in to comment.