[svn] * Avoid access to bag item prototype for getting bag size, use related item
update field instead as more fast source. source mangos. * Further reduce of DB access in guild handlers. * Multi-locale DBC extracting - source Foks *** Devs not responsible if all your player items drop to the ground and get eaten by ants or rabbits.. or some kind of wierd ant-rabbits.. --HG-- branch : trunk
This commit is contained in:
+98
-152
@@ -3925,10 +3925,9 @@ void Player::DurabilityLossAll(double percent, bool inventory)
|
||||
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if(ItemPrototype const *pBagProto = pBag->GetProto())
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
if(Item* pItem = GetItemByPos( i, j ))
|
||||
DurabilityLoss(pItem,percent);
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
if(Item* pItem = GetItemByPos( i, j ))
|
||||
DurabilityLoss(pItem,percent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3970,10 +3969,9 @@ void Player::DurabilityPointsLossAll(int32 points, bool inventory)
|
||||
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if(ItemPrototype const *pBagProto = pBag->GetProto())
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
if(Item* pItem = GetItemByPos( i, j ))
|
||||
DurabilityPointsLoss(pItem,points);
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
if(Item* pItem = GetItemByPos( i, j ))
|
||||
DurabilityPointsLoss(pItem,points);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8326,24 +8324,19 @@ uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
|
||||
}
|
||||
}
|
||||
Bag *pBag;
|
||||
ItemPrototype const *pBagProto;
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
||||
{
|
||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
{
|
||||
pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8434,15 +8427,11 @@ Item* Player::GetItemByGuid( uint64 guid ) const
|
||||
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
{
|
||||
ItemPrototype const *pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
{
|
||||
Item* pItem = pBag->GetItemByPos( j );
|
||||
if( pItem && pItem->GetGUID() == guid )
|
||||
return pItem;
|
||||
}
|
||||
Item* pItem = pBag->GetItemByPos( j );
|
||||
if( pItem && pItem->GetGUID() == guid )
|
||||
return pItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8451,15 +8440,11 @@ Item* Player::GetItemByGuid( uint64 guid ) const
|
||||
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
{
|
||||
ItemPrototype const *pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
{
|
||||
Item* pItem = pBag->GetItemByPos( j );
|
||||
if( pItem && pItem->GetGUID() == guid )
|
||||
return pItem;
|
||||
}
|
||||
Item* pItem = pBag->GetItemByPos( j );
|
||||
if( pItem && pItem->GetGUID() == guid )
|
||||
return pItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8617,17 +8602,14 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
|
||||
{
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
if(ItemPrototype const *pBagProto = pBag->GetProto())
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
Item* pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
Item* pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
return true;
|
||||
}
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8649,17 +8631,14 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
|
||||
{
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
if(ItemPrototype const *pBagProto = pBag->GetProto())
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
Item* pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
Item* pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
return true;
|
||||
}
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8737,22 +8716,15 @@ bool Player::HasItemTotemCategory( uint32 TotemCategory ) const
|
||||
if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory ))
|
||||
return true;
|
||||
}
|
||||
Bag *pBag;
|
||||
ItemPrototype const *pBagProto;
|
||||
for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; ++j)
|
||||
{
|
||||
pItem = GetItemByPos( i, j );
|
||||
if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory ))
|
||||
return true;
|
||||
}
|
||||
pItem = GetItemByPos( i, j );
|
||||
if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory ))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8846,7 +8818,7 @@ uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototy
|
||||
if( !ItemCanGoIntoBag(pProto,pBagProto) )
|
||||
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
|
||||
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
// skip specific slot already processed in first called _CanStoreItem_InSpecificSlot
|
||||
if(j==skip_slot)
|
||||
@@ -9353,23 +9325,14 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
|
||||
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
||||
{
|
||||
Bag *pBag;
|
||||
ItemPrototype const *pBagProto;
|
||||
|
||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
pBagProto = pBag->GetProto();
|
||||
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
pItem2 = GetItemByPos( i, j );
|
||||
if (pItem2 && !pItem2->IsInTrade())
|
||||
{
|
||||
pItem2 = GetItemByPos( i, j );
|
||||
if (pItem2 && !pItem2->IsInTrade())
|
||||
{
|
||||
inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount();
|
||||
}
|
||||
inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9436,18 +9399,14 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
|
||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
|
||||
if( pBag )
|
||||
{
|
||||
pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
pItem2 = GetItemByPos( t, j );
|
||||
if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable )
|
||||
{
|
||||
pItem2 = GetItemByPos( t, j );
|
||||
if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable )
|
||||
{
|
||||
inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount();
|
||||
b_found = true;
|
||||
break;
|
||||
}
|
||||
inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount();
|
||||
b_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9486,7 +9445,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
|
||||
if( pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) &&
|
||||
ItemCanGoIntoBag(pProto,pBagProto) )
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 )
|
||||
{
|
||||
@@ -9520,17 +9479,13 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
|
||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
|
||||
if( pBag )
|
||||
{
|
||||
pBagProto = pBag->GetProto();
|
||||
if( pBagProto && ItemCanGoIntoBag(pProto,pBagProto))
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 )
|
||||
{
|
||||
if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 )
|
||||
{
|
||||
inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1;
|
||||
b_found = true;
|
||||
break;
|
||||
}
|
||||
inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1;
|
||||
b_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10624,40 +10579,33 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
||||
}
|
||||
|
||||
// in inventory bags
|
||||
Bag *pBag;
|
||||
ItemPrototype const *pBagProto;
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
||||
{
|
||||
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
// all items in bags can be unequipped
|
||||
if( pItem->GetCount() + remcount <= count )
|
||||
{
|
||||
// all items in bags can be unequipped
|
||||
if( pItem->GetCount() + remcount <= count )
|
||||
{
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem( i, j, update );
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem( i, j, update );
|
||||
|
||||
if(remcount >=count)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
pProto = pItem->GetProto();
|
||||
ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
|
||||
pItem->SetCount( pItem->GetCount() - count + remcount );
|
||||
if( IsInWorld() && update )
|
||||
pItem->SendUpdateToPlayer( this );
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
if(remcount >=count)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pProto = pItem->GetProto();
|
||||
ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
|
||||
pItem->SetCount( pItem->GetCount() - count + remcount );
|
||||
if( IsInWorld() && update )
|
||||
pItem->SendUpdateToPlayer( this );
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10719,15 +10667,11 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone )
|
||||
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
{
|
||||
ItemPrototype const *pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
{
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) )
|
||||
DestroyItem( i, j, update);
|
||||
}
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) )
|
||||
DestroyItem( i, j, update);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10763,17 +10707,13 @@ void Player::DestroyConjuredItems( bool update )
|
||||
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
{
|
||||
ItemPrototype const *pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
{
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->GetProto() &&
|
||||
(pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) &&
|
||||
(pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) )
|
||||
DestroyItem( i, j, update);
|
||||
}
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->GetProto() &&
|
||||
(pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) &&
|
||||
(pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) )
|
||||
DestroyItem( i, j, update);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11422,15 +11362,11 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot)
|
||||
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pBag )
|
||||
{
|
||||
ItemPrototype const *pBagProto = pBag->GetProto();
|
||||
if( pBagProto )
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
{
|
||||
for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
|
||||
{
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->GetEnchantmentId(slot) )
|
||||
pItem->ClearEnchantment(slot);
|
||||
}
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if( pItem && pItem->GetEnchantmentId(slot) )
|
||||
pItem->ClearEnchantment(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15716,6 +15652,16 @@ void Player::SendAutoRepeatCancel()
|
||||
GetSession()->SendPacket( &data );
|
||||
}
|
||||
|
||||
void Player::PlaySound(uint32 Sound, bool OnlySelf)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4);
|
||||
data << Sound;
|
||||
if (OnlySelf)
|
||||
GetSession()->SendPacket( &data );
|
||||
else
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
|
||||
void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
|
||||
{
|
||||
WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 );
|
||||
|
||||
Reference in New Issue
Block a user