From ec0141261a8e3565d7636e109f95fefd72d1223e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 7 May 2010 01:36:48 +0400 Subject: [PATCH] [9843] Restore need seelction show at loot roll. Also some clanups including merge 2 roll type enum. --- src/game/Group.cpp | 68 +++++++++++++++++++++------------------ src/game/Group.h | 33 +++++++++++++------ src/game/GroupHandler.cpp | 7 ++-- src/game/LootMgr.h | 20 ------------ src/game/Player.h | 1 - src/shared/revision_nr.h | 2 +- 6 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 414c3cadf..1433a0237 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -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), @@ -457,7 +458,7 @@ 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) { @@ -465,7 +466,7 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r) if(!p || !p->GetSession()) continue; - if(itr->second != NOT_VALID) + if(itr->second != ROLL_NOT_VALID) p->GetSession()->SendPacket( &data ); } } @@ -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 @@ -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 ); } } @@ -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 ); } } @@ -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; } } @@ -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); @@ -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; } } @@ -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); @@ -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) @@ -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; @@ -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); @@ -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); @@ -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); @@ -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 ); @@ -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); @@ -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; } } diff --git a/src/game/Group.h b/src/game/Group.h index eebca48f0..94041dc21 100644 --- a/src/game/Group.h +++ b/src/game/Group.h @@ -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 @@ -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); } @@ -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; diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index 047c685cd..db463a6bf 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -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) { diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 0b7914dff..35662044a 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -26,31 +26,11 @@ #include #include -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, diff --git a/src/game/Player.h b/src/game/Player.h index 530e9052d..fbc4acee8 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2662,5 +2662,4 @@ bool Player::CheckAllControlledUnits(Func const& func, bool withTotems, bool wit return Unit::CheckAllControlledUnits(func,withTotems,withGuardians,withCharms); } - #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 689007d9f..d6b3ee6e4 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9842" + #define REVISION_NR "9843" #endif // __REVISION_NR_H__