diff options
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 285 |
1 files changed, 133 insertions, 152 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2e96a13dc61..1c4cf8a5b40 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1536,7 +1536,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) const ItemPrototype * proto = objmgr.GetItemPrototype(item_id); SpellItemEnchantmentEntry const *enchant = NULL; - for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot<=TEMP_ENCHANTMENT_SLOT; enchantSlot++) + for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot) { uint32 enchantId = GetUInt32Value(visualbase+1+enchantSlot); if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId)) @@ -3071,7 +3071,7 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const switch(spellInfo->Id) { - // some spells not have stance data expacted cast at form change or present + // some spells not have stance data expected cast at form change or present case 5420: need_cast = (m_form == FORM_TREE); break; case 5419: need_cast = (m_form == FORM_TRAVEL); break; case 7376: need_cast = (m_form == FORM_DEFENSIVESTANCE); break; @@ -3318,7 +3318,7 @@ void Player::RemoveSpellCooldown( uint32 spell_id, bool update /* = false */ ) if(update) { - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(spell_id); data << uint64(GetGUID()); SendDirectMessage(&data); @@ -3349,7 +3349,7 @@ void Player::RemoveArenaSpellCooldowns() entry->CategoryRecoveryTime <= 15 * MINUTE * IN_MILISECONDS ) { // notify player - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(itr->first); data << uint64(GetGUID()); GetSession()->SendPacket(&data); @@ -3365,7 +3365,7 @@ void Player::RemoveAllSpellCooldown() { for(SpellCooldowns::const_iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); ++itr) { - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(itr->first); data << uint64(GetGUID()); GetSession()->SendPacket(&data); @@ -8967,7 +8967,7 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV if(slot >= VANITYPET_SLOT_START && slot < VANITYPET_SLOT_END) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - // currencytoken case (disabled until proper implement) + // currencytoken case if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -9635,7 +9635,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } // check free space for all items - for (int k=0;k<count;k++) + for (int k = 0; k < count; ++k) { Item *pItem = pItems[k]; @@ -9666,7 +9666,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const { bool b_found = false; - for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; t++) + for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; ++t) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9678,7 +9678,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; t++) + for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_tokens[t-CURRENCYTOKEN_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9690,7 +9690,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) + for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_slot_items[t-INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9702,7 +9702,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag && ItemCanGoIntoBag(pItem->GetProto(), pBag->GetProto())) @@ -9757,7 +9757,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag ) @@ -9785,7 +9785,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const // search free slot bool b_found = false; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) + for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { if( inv_slot_items[t-INVENTORY_SLOT_ITEM_START] == 0 ) { @@ -9797,7 +9797,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; // search free slot in bags - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag ) @@ -10106,14 +10106,14 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p } else { - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); + if(res != EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); - if(res!=EQUIP_ERR_OK) + if(res != EQUIP_ERR_OK) return res; - if(count==0) + if(count == 0) return EQUIP_ERR_OK; } } @@ -10125,10 +10125,10 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p { // in slots res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if(res != EQUIP_ERR_OK) return res; - if(count==0) + if(count == 0) return EQUIP_ERR_OK; // in special bags @@ -10398,7 +10398,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (!pItem2) { if (clone) - pItem = pItem->CloneItem(count,this); + pItem = pItem->CloneItem(count, this); else pItem->SetCount(count); @@ -10413,7 +10413,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (bag == INVENTORY_SLOT_BAG_0) { m_items[slot] = pItem; - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); + SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); @@ -10422,7 +10422,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo // need update known currency if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) - UpdateKnownCurrencies(pItem->GetEntry(),true); + UpdateKnownCurrencies(pItem->GetEntry(), true); if (IsInWorld() && update) { @@ -10517,7 +10517,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) // item set bonuses applied only at equip and removed at unequip, and still active for broken items if(pProto && pProto->ItemSet) - AddItemsSetItem(this,pItem); + AddItemsSetItem(this, pItem); _ApplyItemMods(pItem, slot, true); @@ -10611,15 +10611,6 @@ void Player::QuickEquipItem( uint16 pos, Item *pItem) void Player::SetVisibleItemSlot(uint8 slot, Item *pItem) { - // PLAYER_VISIBLE_ITEM_i_CREATOR // Size: 2 - // PLAYER_VISIBLE_ITEM_i_0 // Size: 12 - // entry // Size: 1 - // inspected enchantments // Size: 6 - // ? // Size: 5 - // PLAYER_VISIBLE_ITEM_i_PROPERTIES // Size: 1 (property,suffix factor) - // PLAYER_VISIBLE_ITEM_i_PAD // Size: 1 - // // = 16 - if(pItem) { SetUInt64Value(PLAYER_VISIBLE_ITEM_1_CREATOR + (slot * MAX_VISIBLE_ITEM_OFFSET), pItem->GetUInt64Value(ITEM_FIELD_CREATOR)); @@ -10661,14 +10652,14 @@ void Player::VisualizeItem( uint8 slot, Item *pItem) sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); m_items[slot] = pItem; - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); + SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); pItem->SetSlot( slot ); pItem->SetContainer( NULL ); if( slot < EQUIPMENT_SLOT_END ) - SetVisibleItemSlot(slot,pItem); + SetVisibleItemSlot(slot, pItem); pItem->SetState(ITEM_CHANGED, this); } @@ -10696,7 +10687,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) // item set bonuses applied only at equip and removed at unequip, and still active for broken items if(pProto && pProto->ItemSet) - RemoveItemsSetItem(this,pProto); + RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); @@ -10727,13 +10718,13 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) } // need update known currency else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) - UpdateKnownCurrencies(pItem->GetEntry(),false); + UpdateKnownCurrencies(pItem->GetEntry(), false); m_items[slot] = NULL; - SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); + SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); if ( slot < EQUIPMENT_SLOT_END ) - SetVisibleItemSlot(slot,NULL); + SetVisibleItemSlot(slot, NULL); } else { @@ -10754,8 +10745,8 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) { if(Item* it = GetItemByPos(bag,slot)) { - ItemRemovedQuestCheck(it->GetEntry(),it->GetCount()); - RemoveItem( bag,slot,update); + ItemRemovedQuestCheck(it->GetEntry(), it->GetCount()); + RemoveItem(bag, slot, update); it->RemoveFromUpdateQueueOf(this); if(it->IsInWorld()) { @@ -10769,13 +10760,13 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB) { // update quest counters - ItemAddedQuestCheck(pItem->GetEntry(),pItem->GetCount()); + ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount()); // store item - Item* pLastItem = StoreItem( dest, pItem, update); + Item* pLastItem = StoreItem(dest, pItem, update); // only set if not merged to existed stack (pItem can be deleted already but we can compare pointers any way) - if(pLastItem==pItem) + if(pLastItem == pItem) { // update owner for last item (this can be original item with wrong owner if(pLastItem->GetOwnerGUID() != GetGUID()) @@ -10797,8 +10788,8 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) // start from destroy contained items (only equipped bag can have its) if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag==slot { - for (int i = 0; i < MAX_BAG_SIZE; i++) - DestroyItem(slot,i,update); + for (int i = 0; i < MAX_BAG_SIZE; ++i) + DestroyItem(slot, i, update); } if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) @@ -10811,7 +10802,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) if( bag == INVENTORY_SLOT_BAG_0 ) { - SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); + SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); // equipment and equipped bags can have applied bonuses if ( slot < INVENTORY_SLOT_BAG_END ) @@ -10820,7 +10811,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) // item set bonuses applied only at equip and removed at unequip, and still active for broken items if(pProto && pProto->ItemSet) - RemoveItemsSetItem(this,pProto); + RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); } @@ -10837,11 +10828,11 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) UpdateExpertise(OFF_ATTACK); // equipment visual show - SetVisibleItemSlot(slot,NULL); + SetVisibleItemSlot(slot, NULL); } // need update known currency else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) - UpdateKnownCurrencies(pItem->GetEntry(),false); + UpdateKnownCurrencies(pItem->GetEntry(), false); m_items[slot] = NULL; } @@ -10879,7 +10870,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq remcount += pItem->GetCount(); DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - if (remcount >=count) + if (remcount >= count) return; } else @@ -10907,7 +10898,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq remcount += pItem->GetCount(); DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - if (remcount >=count) + if (remcount >= count) return; } else @@ -10940,7 +10931,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq remcount += pItem->GetCount(); DestroyItem( i, j, update ); - if (remcount >=count) + if (remcount >= count) return; } else @@ -10967,12 +10958,12 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq { if (pItem->GetCount() + remcount <= count) { - if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i,false) == EQUIP_ERR_OK ) + if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false) == EQUIP_ERR_OK ) { remcount += pItem->GetCount(); DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - if (remcount >=count) + if (remcount >= count) return; } } @@ -10997,12 +10988,12 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) // in inventory for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem( INVENTORY_SLOT_BAG_0, i, update); for(int i = KEYRING_SLOT_START; i < QUESTBAG_SLOT_END; i++) if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem( INVENTORY_SLOT_BAG_0, i, update); // in inventory bags @@ -11010,13 +11001,13 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) for(uint32 j = 0; j < pBag->GetBagSize(); j++) if (Item* pItem = pBag->GetItemByPos(j)) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) - DestroyItem( i, j, update); + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) + DestroyItem(i, j, update); // in equipment and bag list for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) + if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem( INVENTORY_SLOT_BAG_0, i, update); } @@ -11056,7 +11047,7 @@ void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update ) if( pItem->GetCount() <= count ) { - count-= pItem->GetCount(); + count -= pItem->GetCount(); DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update); } @@ -11295,7 +11286,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) } RemoveItem(srcbag, srcslot, true); - EquipItem( dest, pSrcItem, true); + EquipItem(dest, pSrcItem, true); AutoUnequipOffhandIfNeed(); } @@ -11425,7 +11416,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) ItemPrototype const* bagItemProto = bagItem->GetProto(); if (!bagItemProto || !ItemCanGoIntoBag(bagItemProto, emotyProto)) { - // one from items not go to empry target bag + // one from items not go to empty target bag SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); return; } @@ -11443,7 +11434,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) // Items swap count = 0; // will pos in new bag - for(int i=0; i< fullBag->GetBagSize(); ++i) + for(int i = 0; i< fullBag->GetBagSize(); ++i) { Item *bagItem = fullBag->GetItemByPos(i); if (!bagItem) @@ -11522,7 +11513,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, pItem->GetGUID() ); + SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID() ); ItemPrototype const *pProto = pItem->GetProto(); if( pProto ) SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); @@ -11531,7 +11522,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) 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; } } @@ -11559,7 +11550,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) m_items[slot] = NULL; uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, 0 ); + SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); @@ -11571,7 +11562,7 @@ 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); + 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) ); data << uint8(msg); @@ -11654,9 +11645,9 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) if(m_itemDuration.empty()) return; - sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time,realtimeonly); + sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ) + for(ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ) { Item* item = *itr; ++itr; // current element can be erased in UpdateDuration @@ -11671,14 +11662,14 @@ void Player::UpdateEnchantTime(uint32 time) for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) { assert(itr->item); - next=itr; + next = itr; if(!itr->item->GetEnchantmentId(itr->slot)) { next = m_enchantDuration.erase(itr); } else if(itr->leftduration <= time) { - ApplyEnchantment(itr->item,itr->slot,false,false); + ApplyEnchantment(itr->item, itr->slot, false, false); itr->item->ClearEnchantment(itr->slot); next = m_enchantDuration.erase(itr); } @@ -11692,25 +11683,25 @@ void Player::UpdateEnchantTime(uint32 time) void Player::AddEnchantmentDurations(Item *item) { - for(int x=0;x<MAX_ENCHANTMENT_SLOT;++x) + for(int x = 0; x < MAX_ENCHANTMENT_SLOT; ++x) { if(!item->GetEnchantmentId(EnchantmentSlot(x))) continue; uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); if( duration > 0 ) - AddEnchantmentDuration(item,EnchantmentSlot(x),duration); + AddEnchantmentDuration(item, EnchantmentSlot(x), duration); } } void Player::RemoveEnchantmentDurations(Item *item) { - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();) + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) { if(itr->item == item) { // save duration in item - item->SetEnchantmentDuration(EnchantmentSlot(itr->slot),itr->leftduration); + item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration); itr = m_enchantDuration.erase(itr); } else @@ -11721,10 +11712,10 @@ void Player::RemoveEnchantmentDurations(Item *item) void Player::RemoveArenaEnchantments(EnchantmentSlot slot) { // remove enchantments from equipped items first to clean up the m_enchantDuration list - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) + 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)) { @@ -11735,7 +11726,7 @@ void Player::RemoveArenaEnchantments(EnchantmentSlot slot) continue; } // remove from stats - ApplyEnchantment(itr->item,slot,false,false); + ApplyEnchantment(itr->item, slot, false, false); // remove visual itr->item->ClearEnchantment(slot); } @@ -11781,19 +11772,19 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat if(slot >= MAX_ENCHANTMENT_SLOT) return; - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { if(itr->item == item && itr->slot == slot) { - itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); + itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration); m_enchantDuration.erase(itr); break; } } if(item && duration > 0 ) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(),slot,uint32(duration/1000)); - m_enchantDuration.push_back(EnchantDuration(item,slot,duration)); + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000)); + m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); } } @@ -11803,7 +11794,7 @@ void Player::ApplyEnchantment(Item *item,bool apply) ApplyEnchantment(item, EnchantmentSlot(slot), apply); } -void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur, bool ignore_condition) +void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { if(!item) return; @@ -11827,7 +11818,7 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a if (!item->IsBroken()) { - for (int s=0; s<3; s++) + for (int s = 0; s < 3; ++s) { uint32 enchant_display_type = pEnchant->type[s]; uint32 enchant_amount = pEnchant->amount[s]; @@ -11861,11 +11852,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a if (item_rand) { // Search enchant_amount - for (int k=0; k<3; k++) + for (int k = 0; k < 3; ++k) { if(item_rand->enchant_id[k] == enchant_id) { - basepoints = int32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + basepoints = int32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); break; } } @@ -11873,12 +11864,12 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a } // Cast custom spell vs all equal basepoints getted from enchant_amount if (basepoints) - CastCustomSpell(this,enchant_spell_id,&basepoints,&basepoints,&basepoints,true,item); + CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item); else - CastSpell(this,enchant_spell_id,true,item); + CastSpell(this, enchant_spell_id, true, item); } else - RemoveAurasDueToItemSpell(item,enchant_spell_id); + RemoveAurasDueToItemSpell(item, enchant_spell_id); } break; case ITEM_ENCHANTMENT_TYPE_RESISTANCE: @@ -11887,11 +11878,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if(item_rand) { - for (int k=0; k<3; k++) + for (int k = 0; k < 3; ++k) { if(item_rand->enchant_id[k] == enchant_id) { - enchant_amount = uint32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + enchant_amount = uint32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); break; } } @@ -11907,11 +11898,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if(item_rand_suffix) { - for (int k=0; k<3; k++) + for (int k = 0; k < 3; ++k) { if(item_rand_suffix->enchant_id[k] == enchant_id) { - enchant_amount = uint32((item_rand_suffix->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + enchant_amount = uint32((item_rand_suffix->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); break; } } @@ -12108,12 +12099,12 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a float addValue = 0.0f; if(item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); } else if(item->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); } } @@ -12146,27 +12137,27 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a // set duration uint32 duration = item->GetEnchantmentDuration(slot); if(duration > 0) - AddEnchantmentDuration(item,slot,duration); + AddEnchantmentDuration(item, slot, duration); } else { // duration == 0 will remove EnchantDuration - AddEnchantmentDuration(item,slot,0); + AddEnchantmentDuration(item, slot, 0); } } } void Player::SendEnchantmentDurations() { - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + for(EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(),itr->slot,uint32(itr->leftduration)/1000); + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(), itr->slot, uint32(itr->leftduration) / 1000); } } void Player::SendItemDurations() { - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end();++itr) + for(ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) { (*itr)->SendTimeUpdate(this); } @@ -12179,18 +12170,18 @@ void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, // last check 2.0.10 WorldPacket data( SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4) ); - data << GetGUID(); // player GUID + data << uint64(GetGUID()); // player GUID data << uint32(received); // 0=looted, 1=from npc data << uint32(created); // 0=received, 1=created data << uint32(1); // always 0x01 (probably meant to be count of listed items) - data << (uint8)item->GetBagSlot(); // bagslot + data << uint8(item->GetBagSlot()); // bagslot // item slot, but when added to stack: 0xFFFFFFFF - data << (uint32) ((item->GetCount()==count) ? item->GetSlot() : -1); + data << uint32((item->GetCount() == count) ? item->GetSlot() : -1); data << uint32(item->GetEntry()); // item id data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemRandomPropertyId()); // random item property id data << uint32(count); // count of items - data << GetItemCount(item->GetEntry()); // count of items in inventory + data << uint32(GetItemCount(item->GetEntry())); // count of items in inventory if (broadcast && GetGroup()) GetGroup()->BroadcastPacket(&data, true); @@ -12209,7 +12200,7 @@ void Player::PrepareQuestMenu( uint64 guid ) QuestRelations* pObjectQIR; // pets also can have quests - Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid); + Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid); if( pCreature ) { pObject = (Object*)pCreature; @@ -12275,10 +12266,11 @@ void Player::SendPreparedQuest( uint64 guid ) // Auto open -- maybe also should verify there is no greeting uint32 quest_id = qmi0.m_qId; Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); + if ( pQuest ) { if( status == DIALOG_STATUS_REWARD_REP && !GetQuestRewardStatus( quest_id ) ) - PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest,false), true ); + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest, false), true ); else if( status == DIALOG_STATUS_INCOMPLETE ) PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, false, true ); // Send completable on repeatable quest if player don't have quest @@ -14219,7 +14211,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(!LoadValues( fields[2].GetString())) { - sLog.outError("Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); + sLog.outError("Player #%d have broken data in `data` field. Can't be loaded.", GUID_LOPART(guid)); delete result; return false; } @@ -14230,8 +14222,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), 0 ); - SetVisibleItemSlot(slot,NULL); + SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0 ); + SetVisibleItemSlot(slot, NULL); if (m_items[slot]) { @@ -14645,7 +14637,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) { if(!HasTitle(curTitle)) - SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + SetUInt32Value(PLAYER_CHOSEN_TITLE, 0); } // Not finish taxi flight path @@ -15271,18 +15263,18 @@ void Player::_LoadQuestStatus(QueryResult *result) // add to quest log if( slot < MAX_QUEST_LOG_SIZE && - ( questStatusData.m_status==QUEST_STATUS_INCOMPLETE || - questStatusData.m_status==QUEST_STATUS_COMPLETE && + ( questStatusData.m_status == QUEST_STATUS_INCOMPLETE || + questStatusData.m_status == QUEST_STATUS_COMPLETE && (!questStatusData.m_rewarded || pQuest->IsDaily()) ) ) { - SetQuestSlot(slot,quest_id,quest_time); + SetQuestSlot(slot, quest_id, quest_time); if(questStatusData.m_status == QUEST_STATUS_COMPLETE) - SetQuestSlotState(slot,QUEST_STATE_COMPLETE); + SetQuestSlotState(slot, QUEST_STATE_COMPLETE); for(uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) if(questStatusData.m_creatureOrGOcount[idx]) - SetQuestSlotCounter(slot,idx,questStatusData.m_creatureOrGOcount[idx]); + SetQuestSlotCounter(slot, idx, questStatusData.m_creatureOrGOcount[idx]); ++slot; } @@ -15300,7 +15292,7 @@ void Player::_LoadQuestStatus(QueryResult *result) } if(pQuest->GetBonusTalents()) - m_questRewardTalentCount+=pQuest->GetBonusTalents(); + m_questRewardTalentCount += pQuest->GetBonusTalents(); } sLog.outDebug("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); @@ -15313,7 +15305,7 @@ void Player::_LoadQuestStatus(QueryResult *result) // clear quest log tail for ( uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i ) - SetQuestSlot(i,0); + SetQuestSlot(i, 0); } void Player::_LoadDailyQuestStatus(QueryResult *result) @@ -15548,7 +15540,7 @@ void Player::SendRaidInfo() } } } - data.put<uint32>(p_counter,counter); + data.put<uint32>(p_counter, counter); GetSession()->SendPacket(&data); } @@ -16791,7 +16783,7 @@ void Player::PetSpellInitialize() CharmInfo *charmInfo = pet->GetCharmInfo(); - WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+10*4); + WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+1); data << uint64(pet->GetGUID()); data << uint32(pet->GetCreatureInfo()->family); // creature family (required for pet talents) data << uint32(0); @@ -16866,22 +16858,16 @@ void Player::PossessSpellInitialize() return; } - WorldPacket data(SMSG_PET_SPELLS, 20+40+1+1); - - //basic info 20 + WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+1); data << uint64(charm->GetGUID()); - data << uint32(0x00000000); + data << uint32(0); data << uint32(0); data << uint32(0); - //action bar 40 - charmInfo->BuildActionBar(&data); //40 - - //addlist 1 - data << uint8(0); + charmInfo->BuildActionBar(&data); - //cooldown 1 - data << uint8(0); + data << uint8(0); // spells count + data << uint8(0); // cooldowns count GetSession()->SendPacket(&data); } @@ -16952,23 +16938,20 @@ void Player::CharmSpellInitialize() } } - WorldPacket data(SMSG_PET_SPELLS, 20+40+1+4*addlist+1);// first line + actionbar + spellcount + spells + last adds - - //basic info 20 + WorldPacket data(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+4*addlist+1); data << uint64(charm->GetGUID()); data << uint32(0); data << uint32(0); + if(charm->GetTypeId() != TYPEID_PLAYER) data << uint8(((Creature*)charm)->GetReactState()) << uint8(charmInfo->GetCommandState()); else - data << uint8(0) << uint8(0); - data << uint16(0); + data << uint8(0) << uint8(0) << uint16(0); + + charmInfo->BuildActionBar(&data); - //action bar 40 - charmInfo->BuildActionBar(&data); //40 + data << uint8(addlist); - //add list - data << uint8(addlist); //1 if(addlist) { for(uint32 i = 0; i < MAX_SPELL_CHARM; ++i) @@ -16982,9 +16965,7 @@ void Player::CharmSpellInitialize() } } - //cooldown - uint8 count = 0; - data << uint8(count); // cooldowns count + data << uint8(0); // cooldowns count GetSession()->SendPacket(&data); } @@ -17436,8 +17417,8 @@ void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs ) if((idSchoolMask & GetSpellSchoolMask(spellInfo)) && GetSpellCooldownDelay(unSpellId) < unTimeMs ) { - data << unSpellId; - data << unTimeMs; // in m.secs + data << uint32(unSpellId); + data << uint32(unTimeMs); // in m.secs AddSpellCooldown(unSpellId, 0, curTime + unTimeMs/IN_MILISECONDS); } } @@ -19982,16 +19963,16 @@ bool Player::HasTitle(uint32 bitIndex) if (bitIndex > 128) return false; - uint32 fieldIndexOffset = bitIndex/32; - uint32 flag = 1 << (bitIndex%32); - return HasFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag); + uint32 fieldIndexOffset = bitIndex / 32; + uint32 flag = 1 << (bitIndex % 32); + return HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } void Player::SetTitle(CharTitlesEntry const* title) { - uint32 fieldIndexOffset = title->bit_index/32; - uint32 flag = 1 << (title->bit_index%32); - SetFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag); + uint32 fieldIndexOffset = title->bit_index / 32; + uint32 flag = 1 << (title->bit_index % 32); + SetFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } /*-----------------------TRINITY--------------------------*/ |