fallenangelX/Infinity — Issue #19: Chest group loot fix. 
Author: Kreegoth
Created: 2012-01-06 17:59:14+00:00
State: open

Have rewritten this patch and tested alot. Seems to work with no issues at all. Chests are group looted and master loot works. Cannot reopen chest now to get double loot. Seems perfect. Your line numbers may vary from mine.

[code]
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index d8a040f..3ef105d 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -7997,6 +7997,13 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)

loot = &go->loot;

+ Player *recipient = go->GetLootRecipient();
+ if (!recipient)
+ {
+ go->SetLootRecipient(this);
+ recipient = this;
+ }
+
// generate loot only if ready for open and spawned in world
if (go->getLootState() == GO_READY && go->isSpawned())
{
@@ -8020,12 +8027,65 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
loot->clear();
loot->FillLoot(lootid, LootTemplates_Gameobject, this, false);
loot->generateMoneyLoot(go->GetGOInfo()->MinMoneyLoot, go->GetGOInfo()->MaxMoneyLoot);
+
+ if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules)
+ {
+ if (Group* group = go->GetGroupLootRecipient())
+ {
+ group->UpdateLooterGuid(go, true);
+
+ switch (group->GetLootMethod())
+ {
+ case GROUP_LOOT:
+ // GroupLoot delete items over threshold (threshold even not implemented), and roll them. Items with qualityGroupLoot(go, loot);
+ permission = GROUP_PERMISSION;
+ break;
+ case NEED_BEFORE_GREED:
+ group->NeedBeforeGreed(go, loot);
+ permission = GROUP_PERMISSION;
+ break;
+ case MASTER_LOOT:
+ group->MasterLoot(go, loot);
+ permission = MASTER_PERMISSION;
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
else if (loot_type == LOOT_FISHING)
go->getFishLoot(loot,this);

go->SetLootState(GO_ACTIVATED);
}
+ if (go->getLootState() == GO_ACTIVATED && go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules)
+ {
+ if (Group* group = go->GetGroupLootRecipient())
+ {
+ if (group == GetGroup())
+ {
+ if (group->GetLootMethod() == FREE_FOR_ALL)
+ permission = ALL_PERMISSION;
+ else if (group->GetLooterGuid() == GetObjectGuid())
+ {
+ if (group->GetLootMethod() == MASTER_LOOT)
+ permission = MASTER_PERMISSION;
+ else
+ permission = ALL_PERMISSION;
+ }
+ else
+ permission = GROUP_PERMISSION;
+ }
+ else
+ permission = NONE_PERMISSION;
+ }
+ else if (recipient == this)
+ permission = ALL_PERMISSION;
+ else
+ permission = NONE_PERMISSION;
+ }
break;
}
case HIGHGUID_ITEM:
[/code]