diff options
Diffstat (limited to 'src/server/game/Groups/Group.cpp')
-rw-r--r-- | src/server/game/Groups/Group.cpp | 168 |
1 files changed, 98 insertions, 70 deletions
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 11d29ba8b62..30ecfb83f59 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1343,16 +1343,16 @@ void Group::CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choice) } if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling) - CountTheRoll(rollI); + CountTheRoll(rollI, nullptr); } //called when roll timer expires -void Group::EndRoll(Loot* pLoot) +void Group::EndRoll(Loot* pLoot, Map* allowedMap) { for (Rolls::iterator itr = RollId.begin(); itr != RollId.end();) { if ((*itr)->getLoot() == pLoot) { - CountTheRoll(itr); //i don't have to edit player votes, who didn't vote ... he will pass + CountTheRoll(itr, allowedMap); //i don't have to edit player votes, who didn't vote ... he will pass itr = RollId.begin(); } else @@ -1360,7 +1360,7 @@ void Group::EndRoll(Loot* pLoot) } } -void Group::CountTheRoll(Rolls::iterator rollI) +void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) { Roll* roll = *rollI; if (!roll->isValid()) // is loot already deleted ? @@ -1376,14 +1376,21 @@ void Group::CountTheRoll(Rolls::iterator rollI) if (!roll->playerVote.empty()) { uint8 maxresul = 0; - ObjectGuid maxguid = (*roll->playerVote.begin()).first; - Player* player; + ObjectGuid maxguid = ObjectGuid::Empty; + Player* player = nullptr; for (Roll::PlayerVote::const_iterator itr=roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) { if (itr->second != NEED) continue; + player = ObjectAccessor::FindPlayer(itr->first); + if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap)) + { + --roll->totalNeed; + continue; + } + uint8 randomN = urand(1, 100); SendLootRoll(ObjectGuid::Empty, itr->first, randomN, ROLL_NEED, *roll); if (maxresul < randomN) @@ -1392,39 +1399,46 @@ void Group::CountTheRoll(Rolls::iterator rollI) maxresul = randomN; } } - SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll); - player = ObjectAccessor::FindConnectedPlayer(maxguid); - if (player && player->GetSession()) + if (!maxguid.IsEmpty()) { - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, roll->itemid, maxresul); + SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll); + player = ObjectAccessor::FindConnectedPlayer(maxguid); - ItemPosCountVec dest; - LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]); - InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); - if (msg == EQUIP_ERR_OK) + if (player && player->GetSession()) { - item->is_looted = true; - roll->getLoot()->NotifyItemRemoved(roll->itemSlot); - roll->getLoot()->unlootedCount--; - player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, item->GetAllowedLooters()); - } - else - { - item->is_blocked = false; - item->rollWinnerGUID = player->GetGUID(); - player->SendEquipError(msg, nullptr, nullptr, roll->itemid); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, roll->itemid, maxresul); + + ItemPosCountVec dest; + LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]); + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); + if (msg == EQUIP_ERR_OK) + { + item->is_looted = true; + roll->getLoot()->NotifyItemRemoved(roll->itemSlot); + roll->getLoot()->unlootedCount--; + player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, item->GetAllowedLooters()); + } + else + { + item->is_blocked = false; + item->rollWinnerGUID = player->GetGUID(); + player->SendEquipError(msg, NULL, NULL, roll->itemid); + } } } + else + roll->totalNeed = 0; } } - else if (roll->totalGreed > 0) + + if (roll->totalNeed == 0 && roll->totalGreed > 0) // if (roll->totalNeed == 0 && ...), not else if, because numbers can be modified above if player is on a different map { if (!roll->playerVote.empty()) { uint8 maxresul = 0; - ObjectGuid maxguid = (*roll->playerVote.begin()).first; - Player* player; + ObjectGuid maxguid = ObjectGuid::Empty; + Player* player = nullptr; RollVote rollvote = NOT_VALID; Roll::PlayerVote::iterator itr; @@ -1433,6 +1447,13 @@ void Group::CountTheRoll(Rolls::iterator rollI) if (itr->second != GREED && itr->second != DISENCHANT) continue; + player = ObjectAccessor::FindPlayer(itr->first); + if (!player || (allowedMap != NULL && player->FindMap() != allowedMap)) + { + --roll->totalGreed; + continue; + } + uint8 randomN = urand(1, 100); SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll); if (maxresul < randomN) @@ -1442,63 +1463,70 @@ void Group::CountTheRoll(Rolls::iterator rollI) rollvote = itr->second; } } - SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll); - player = ObjectAccessor::FindConnectedPlayer(maxguid); - if (player && player->GetSession()) + if (!maxguid.IsEmpty()) { - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, roll->itemid, maxresul); - - LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]); + SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll); + player = ObjectAccessor::FindConnectedPlayer(maxguid); - if (rollvote == GREED) + if (player && player->GetSession()) { - ItemPosCountVec dest; - InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); - if (msg == EQUIP_ERR_OK) + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, roll->itemid, maxresul); + + LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]); + + if (rollvote == GREED) + { + ItemPosCountVec dest; + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); + if (msg == EQUIP_ERR_OK) + { + item->is_looted = true; + roll->getLoot()->NotifyItemRemoved(roll->itemSlot); + roll->getLoot()->unlootedCount--; + player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, item->GetAllowedLooters()); + } + else + { + item->is_blocked = false; + item->rollWinnerGUID = player->GetGUID(); + player->SendEquipError(msg, NULL, NULL, roll->itemid); + } + } + else if (rollvote == DISENCHANT) { item->is_looted = true; roll->getLoot()->NotifyItemRemoved(roll->itemSlot); roll->getLoot()->unlootedCount--; - player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, item->GetAllowedLooters()); - } - else - { - item->is_blocked = false; - item->rollWinnerGUID = player->GetGUID(); - player->SendEquipError(msg, nullptr, nullptr, roll->itemid); - } - } - else if (rollvote == DISENCHANT) - { - item->is_looted = true; - roll->getLoot()->NotifyItemRemoved(roll->itemSlot); - roll->getLoot()->unlootedCount--; - ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid); - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, 13262); // Disenchant - - ItemPosCountVec dest; - InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); - if (msg == EQUIP_ERR_OK) - player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true); - else // If the player's inventory is full, send the disenchant result in a mail. - { - Loot loot; - loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true); - - uint32 max_slot = loot.GetMaxSlotInLootFor(player); - for (uint32 i = 0; i < max_slot; ++i) + ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, 13262); // Disenchant + + ItemPosCountVec dest; + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); + if (msg == EQUIP_ERR_OK) + player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true); + else // If the player's inventory is full, send the disenchant result in a mail. { - LootItem* lootItem = loot.LootItemInSlot(i, player); - player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid); - player->SendItemRetrievalMail(lootItem->itemid, lootItem->count); + Loot loot; + loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true); + + uint32 max_slot = loot.GetMaxSlotInLootFor(player); + for (uint32 i = 0; i < max_slot; ++i) + { + LootItem* lootItem = loot.LootItemInSlot(i, player); + player->SendEquipError(msg, NULL, NULL, lootItem->itemid); + player->SendItemRetrievalMail(lootItem->itemid, lootItem->count); + } } } } } + else + roll->totalGreed = 0; } } - else + + if (roll->totalNeed == 0 && roll->totalGreed == 0) // if, not else, because numbers can be modified above if player is on a different map { SendLootAllPassed(*roll); @@ -1988,7 +2016,7 @@ bool Group::InCombatToInstance(uint32 instanceId) for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { Player* player = itr->GetSource(); - if (player && !player->getAttackers().empty() && player->GetInstanceId() == instanceId && (player->GetMap()->IsRaidOrHeroicDungeon())) + if (player && player->GetInstanceId() == instanceId && !player->getAttackers().empty() && (player->GetMap()->IsRaidOrHeroicDungeon())) for (std::set<Unit*>::const_iterator i = player->getAttackers().begin(); i != player->getAttackers().end(); ++i) if ((*i) && (*i)->GetTypeId() == TYPEID_UNIT && (*i)->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) return true; |