diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 95771f77e..a9bcf0082 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -11353,19 +11353,19 @@ void Player::SwapItem( uint16 src, uint16 dst ) RemoveItem(srcbag, srcslot, false); // add to dest - if( IsInventoryPos( dst ) ) + if (IsInventoryPos(dst)) StoreItem(sDest, pSrcItem, true); - else if( IsBankPos( dst ) ) + else if (IsBankPos(dst)) BankItem(sDest, pSrcItem, true); - else if( IsEquipmentPos( dst ) ) + else if (IsEquipmentPos(dst)) EquipItem(eDest, pSrcItem, true); // add to src - if( IsInventoryPos( src ) ) + if (IsInventoryPos(src)) StoreItem(sDest2, pDstItem, true); - else if( IsBankPos( src ) ) + else if (IsBankPos(src)) BankItem(sDest2, pDstItem, true); - else if( IsEquipmentPos( src ) ) + else if (IsEquipmentPos(src)) EquipItem(eDest2, pDstItem, true); AutoUnequipOffhandIfNeed(); @@ -11373,11 +11373,11 @@ void Player::SwapItem( uint16 src, uint16 dst ) void Player::AddItemToBuyBackSlot( Item *pItem ) { - if( pItem ) + if (pItem) { uint32 slot = m_currentBuybackSlot; // if current back slot non-empty search oldest or free - if(m_items[slot]) + if (m_items[slot]) { uint32 oldest_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 ); uint32 oldest_slot = BUYBACK_SLOT_START; @@ -11385,7 +11385,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) for(uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i ) { // found empty - if(!m_items[i]) + if (!m_items[i]) { slot = i; break; @@ -11393,7 +11393,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 i_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START); - if(oldest_time > i_time) + if (oldest_time > i_time) { oldest_time = i_time; oldest_slot = i; @@ -11413,15 +11413,14 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 eslot = slot - BUYBACK_SLOT_START; SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID() ); - ItemPrototype const *pProto = pItem->GetProto(); - if( pProto ) + if (ItemPrototype const *pProto = pItem->GetProto()) SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); else SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime ); // move to next (for non filled list is move most optimized choice) - if(m_currentBuybackSlot < BUYBACK_SLOT_END - 1) + if (m_currentBuybackSlot < BUYBACK_SLOT_END - 1) ++m_currentBuybackSlot; } } @@ -11429,7 +11428,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) Item* Player::GetItemFromBuyBackSlot( uint32 slot ) { sLog.outDebug( "STORAGE: GetItemFromBuyBackSlot slot = %u", slot); - if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) + if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) return m_items[slot]; return NULL; } @@ -11437,10 +11436,10 @@ Item* Player::GetItemFromBuyBackSlot( uint32 slot ) void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) { sLog.outDebug( "STORAGE: RemoveItemFromBuyBackSlot slot = %u", slot); - if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) + if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) { Item *pItem = m_items[slot]; - if( pItem ) + if (pItem) { pItem->RemoveFromWorld(); if(del) pItem->SetState(ITEM_REMOVED, this); @@ -11454,7 +11453,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); // if current backslot is filled set to now free slot - if(m_items[m_currentBuybackSlot]) + if (m_items[m_currentBuybackSlot]) m_currentBuybackSlot = slot; } } @@ -11462,21 +11461,21 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ) { sLog.outDebug( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg); - WorldPacket data( SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18) ); + WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : (msg == EQUIP_ERR_OK ? 1 : 18))); data << uint8(msg); - if(msg) + if (msg != EQUIP_ERR_OK) { data << uint64(pItem ? pItem->GetGUID() : 0); data << uint64(pItem2 ? pItem2->GetGUID() : 0); data << uint8(0); // not 0 there... - if(msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) + if (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) { uint32 level = 0; - if(pItem) - if(ItemPrototype const* proto = pItem->GetProto()) + if (pItem) + if (ItemPrototype const* proto = pItem->GetProto()) level = proto->RequiredLevel; data << uint32(level); // new 2.4.0 @@ -11491,7 +11490,7 @@ void Player::SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 p WorldPacket data( SMSG_BUY_FAILED, (8+4+4+1) ); data << uint64(pCreature ? pCreature->GetGUID() : 0); data << uint32(item); - if( param > 0 ) + if (param > 0) data << uint32(param); data << uint8(msg); GetSession()->SendPacket(&data); @@ -11503,7 +11502,7 @@ void Player::SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 data << uint64(pCreature ? pCreature->GetGUID() : 0); data << uint64(guid); - if( param > 0 ) + if (param > 0) data << uint32(param); data << uint8(msg); GetSession()->SendPacket(&data); @@ -11519,15 +11518,15 @@ void Player::ClearTrade() void Player::TradeCancel(bool sendback) { - if(pTrader) + if (pTrader) { // send yellow "Trade canceled" message to both traders WorldSession* ws; ws = GetSession(); - if(sendback) + if (sendback) ws->SendCancelTrade(); ws = pTrader->GetSession(); - if(!ws->PlayerLogout()) + if (!ws->PlayerLogout()) ws->SendCancelTrade(); // cleanup @@ -11541,7 +11540,7 @@ void Player::TradeCancel(bool sendback) void Player::UpdateItemDuration(uint32 time, bool realtimeonly) { - if(m_itemDuration.empty()) + if (m_itemDuration.empty()) return; sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); @@ -11562,17 +11561,17 @@ void Player::UpdateEnchantTime(uint32 time) { assert(itr->item); next = itr; - if(!itr->item->GetEnchantmentId(itr->slot)) + if (!itr->item->GetEnchantmentId(itr->slot)) { next = m_enchantDuration.erase(itr); } - else if(itr->leftduration <= time) + else if (itr->leftduration <= time) { ApplyEnchantment(itr->item, itr->slot, false, false); itr->item->ClearEnchantment(itr->slot); next = m_enchantDuration.erase(itr); } - else if(itr->leftduration > time) + else if (itr->leftduration > time) { itr->leftduration -= time; ++next; @@ -11584,11 +11583,11 @@ void Player::AddEnchantmentDurations(Item *item) { for(int x = 0; x < MAX_ENCHANTMENT_SLOT; ++x) { - if(!item->GetEnchantmentId(EnchantmentSlot(x))) + if (!item->GetEnchantmentId(EnchantmentSlot(x))) continue; uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); - if( duration > 0 ) + if (duration > 0) AddEnchantmentDuration(item, EnchantmentSlot(x), duration); } } @@ -11597,7 +11596,7 @@ void Player::RemoveEnchantmentDurations(Item *item) { for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) { - if(itr->item == item) + if (itr->item == item) { // save duration in item item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration); @@ -11614,9 +11613,9 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) for(EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) { next = itr; - if(itr->slot == slot) + if (itr->slot == slot) { - if(itr->item && itr->item->GetEnchantmentId(slot)) + if (itr->item && itr->item->GetEnchantmentId(slot)) { // remove from stats ApplyEnchantment(itr->item, slot, false, false); @@ -11634,47 +11633,38 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) // NOTE: no need to remove these from stats, since these aren't equipped // in inventory for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEnchantmentId(slot) ) - pItem->ClearEnchantment(slot); - } + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (pItem->GetEnchantmentId(slot)) + pItem->ClearEnchantment(slot); // in inventory bags for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { + if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) for(uint32 j = 0; j < pBag->GetBagSize(); ++j) - { - Item* pItem = pBag->GetItemByPos(j); - if( pItem && pItem->GetEnchantmentId(slot) ) - pItem->ClearEnchantment(slot); - } - } - } + if (Item* pItem = pBag->GetItemByPos(j)) + if (pItem->GetEnchantmentId(slot)) + pItem->ClearEnchantment(slot); } // duration == 0 will remove item enchant void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration) { - if(!item) + if (!item) return; - if(slot >= MAX_ENCHANTMENT_SLOT) + if (slot >= MAX_ENCHANTMENT_SLOT) return; for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { - if(itr->item == item && itr->slot == slot) + if (itr->item == item && itr->slot == slot) { itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration); m_enchantDuration.erase(itr); break; } } - if(item && duration > 0 ) + if (item && duration > 0 ) { GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); @@ -11689,24 +11679,24 @@ void Player::ApplyEnchantment(Item *item,bool apply) void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { - if(!item) + if (!item) return; - if(!item->IsEquipped()) + if (!item->IsEquipped()) return; - if(slot >= MAX_ENCHANTMENT_SLOT) + if (slot >= MAX_ENCHANTMENT_SLOT) return; uint32 enchant_id = item->GetEnchantmentId(slot); - if(!enchant_id) + if (!enchant_id) return; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) + if (!pEnchant) return; - if(!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) + if (!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) return; if (!item->IsBroken()) @@ -11733,9 +11723,9 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(enchant_amount), apply); break; case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: - if(enchant_spell_id) + if (enchant_spell_id) { - if(apply) + if (apply) { int32 basepoints = 0; // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4805b8b57..d68ff4b51 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 "8500" + #define REVISION_NR "8501" #endif // __REVISION_NR_H__