[11951] Unify loot related code and fix engrish.

Also readd the m_groupLootId check in case the StopGroupLoot will be called from other places

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
stfx 2012-04-12 17:06:48 +02:00 committed by Schmoozerd
parent 1c5f99f4b8
commit f153193a02
5 changed files with 16 additions and 15 deletions

View file

@ -538,10 +538,10 @@ void Creature::Update(uint32 update_diff, uint32 diff)
m_corpseDecayTimer -= update_diff; m_corpseDecayTimer -= update_diff;
if (m_groupLootId) if (m_groupLootId)
{ {
if(update_diff < m_groupLootTimer) if (m_groupLootTimer <= update_diff)
m_groupLootTimer -= update_diff;
else
StopGroupLoot(); StopGroupLoot();
else
m_groupLootTimer -= update_diff;
} }
} }

View file

@ -1820,13 +1820,14 @@ void GameObject::SetDisplayId(uint32 modelId)
void GameObject::StartGroupLoot(Group* group, uint32 timer) void GameObject::StartGroupLoot(Group* group, uint32 timer)
{ {
m_groupLootId = group->GetId(); m_groupLootId = group->GetId();
m_groupLootTimer = timer;
if (m_groupLootId)
m_groupLootTimer = timer;
} }
void GameObject::StopGroupLoot() void GameObject::StopGroupLoot()
{ {
if (!m_groupLootId)
return;
if (Group* group = sObjectMgr.GetGroupById(m_groupLootId)) if (Group* group = sObjectMgr.GetGroupById(m_groupLootId))
group->EndRoll(); group->EndRoll();

View file

@ -601,7 +601,7 @@ void Group::GroupLoot(WorldObject* pSource, Loot* loot)
//roll for over-threshold item if it's one-player loot //roll for over-threshold item if it's one-player loot
if (itemProto->Quality >= uint32(m_lootThreshold) && !lootItem.freeforall) if (itemProto->Quality >= uint32(m_lootThreshold) && !lootItem.freeforall)
StartLootRool(pSource, GROUP_LOOT, loot, itemSlot, maxEnchantingSkill); StartLootRoll(pSource, GROUP_LOOT, loot, itemSlot, maxEnchantingSkill);
else else
lootItem.is_underthreshold = 1; lootItem.is_underthreshold = 1;
} }
@ -623,7 +623,7 @@ void Group::NeedBeforeGreed(WorldObject* pSource, Loot* loot)
//only roll for one-player items, not for ones everyone can get //only roll for one-player items, not for ones everyone can get
if (itemProto->Quality >= uint32(m_lootThreshold) && !lootItem.freeforall) if (itemProto->Quality >= uint32(m_lootThreshold) && !lootItem.freeforall)
StartLootRool(pSource, NEED_BEFORE_GREED, loot, itemSlot, maxEnchantingSkill); StartLootRoll(pSource, NEED_BEFORE_GREED, loot, itemSlot, maxEnchantingSkill);
else else
lootItem.is_underthreshold = 1; lootItem.is_underthreshold = 1;
} }
@ -743,20 +743,20 @@ bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI,
return false; return false;
} }
void Group::StartLootRool(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill) void Group::StartLootRoll(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill)
{ {
if (itemSlot >= loot->items.size()) if (itemSlot >= loot->items.size())
return; return;
LootItem const& lootItem = loot->items[itemSlot]; LootItem const& lootItem = loot->items[itemSlot];
Roll* r = new Roll(lootTarget->GetObjectGuid(), method, lootItem); Roll* r = new Roll(lootTarget->GetObjectGuid(), method, lootItem);
//a vector is filled with only near party members //a vector is filled with only near party members
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player *playerToRoll = itr->getSource(); Player* playerToRoll = itr->getSource();
if(!playerToRoll || !playerToRoll->GetSession()) if (!playerToRoll || !playerToRoll->GetSession())
continue; continue;
if (lootItem.AllowedForPlayer(playerToRoll)) if (lootItem.AllowedForPlayer(playerToRoll))

View file

@ -353,7 +353,7 @@ class MANGOS_DLL_SPEC Group
void NeedBeforeGreed(WorldObject* pSource, Loot* loot); void NeedBeforeGreed(WorldObject* pSource, Loot* loot);
void MasterLoot(WorldObject* pSource, Loot* loot); void MasterLoot(WorldObject* pSource, Loot* loot);
bool CountRollVote(Player* player, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote vote); bool CountRollVote(Player* player, ObjectGuid const& lootedTarget, uint32 itemSlot, RollVote vote);
void StartLootRool(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill); void StartLootRoll(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill);
void EndRoll(); void EndRoll();
void LinkMember(GroupReference *pRef) { m_memberMgr.insertFirst(pRef); } void LinkMember(GroupReference *pRef) { m_memberMgr.insertFirst(pRef); }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11950" #define REVISION_NR "11951"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__