From d7994c1df44437bd3d69a5594e0aebf61a70e94c Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Mon, 13 Sep 2010 10:34:18 +0200 Subject: [PATCH] [10480] Fix a bug causing creature dynamic flags to be removed at normal loot preparation. In addition add use of UNIT_DYNFLAG_TAPPED_BY_PLAYER Added check to see if creature is tapped for isAllowedToLoot() Signed-off-by: NoFantasy --- src/game/Creature.cpp | 4 +++- src/game/Object.cpp | 14 ++++++++++---- src/game/Player.cpp | 6 +++++- src/shared/revision_nr.h | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index dd58c2c14..6158db31a 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -870,7 +870,7 @@ void Creature::PrepareBodyLootState() // ... or can have skinning after GetCreatureInfo()->SkinLootId && sWorld.getConfig(CONFIG_BOOL_CORPSE_EMPTY_LOOT_SHOW)) { - SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); return; } } @@ -954,6 +954,7 @@ void Creature::SetLootRecipient(Unit *unit) m_lootRecipientGuid.Clear(); m_lootGroupRecipientId = 0; RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED); + RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED_BY_PLAYER); return; } @@ -969,6 +970,7 @@ void Creature::SetLootRecipient(Unit *unit) m_lootGroupRecipientId = group->GetId(); SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED); + SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED_BY_PLAYER); } void Creature::SaveToDB() diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 2a5d193a7..405930846 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -654,12 +654,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * *data << (m_uint32Values[ index ] & ~UNIT_FLAG_NOT_SELECTABLE); } // hide lootable animation for unallowed players - else if(index == UNIT_DYNAMIC_FLAGS && GetTypeId() == TYPEID_UNIT) + else if (index == UNIT_DYNAMIC_FLAGS && GetTypeId() == TYPEID_UNIT) { - if(!target->isAllowedToLoot((Creature*)this)) - *data << (m_uint32Values[ index ] & ~UNIT_DYNFLAG_LOOTABLE); + if (!target->isAllowedToLoot((Creature*)this)) + *data << (m_uint32Values[ index ] & ~(UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED_BY_PLAYER)); else - *data << (m_uint32Values[ index ] & ~UNIT_DYNFLAG_TAPPED); + { + // flag only for original loot recipent + if (target == ((Creature*)this)->GetOriginalLootRecipient()) + *data << m_uint32Values[ index ]; + else + *data << (m_uint32Values[ index ] & ~(UNIT_DYNFLAG_TAPPED | UNIT_DYNFLAG_TAPPED_BY_PLAYER)); + } } else { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 3d29ebb59..c0138be70 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -15615,7 +15615,11 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) bool Player::isAllowedToLoot(Creature* creature) { - if(Player* recipient = creature->GetLootRecipient()) + // never tapped by any (mob solo kill) + if (!creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED)) + return false; + + if (Player* recipient = creature->GetLootRecipient()) { if (recipient == this) return true; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a9ad28f5a..917846fab 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 "10479" + #define REVISION_NR "10480" #endif // __REVISION_NR_H__