Skip to content

Commit

Permalink
[10480] Fix a bug causing creature dynamic flags to be removed at nor…
Browse files Browse the repository at this point in the history
…mal 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 <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Sep 13, 2010
1 parent 95cfcc8 commit afc3e20
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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()
Expand Down
14 changes: 10 additions & 4 deletions src/game/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 5 additions & 1 deletion src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10479"
#define REVISION_NR "10480"
#endif // __REVISION_NR_H__

0 comments on commit afc3e20

Please sign in to comment.