diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 0b07f5c8b..4f06058dc 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -1366,11 +1366,38 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data) CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1); - uint8 dstbag, dstslot; - recv_data >> dstbag >> dstslot; + uint8 srcbag, srcslot; + recv_data >> srcbag >> srcslot; - // so we have itemGuid, bag and slot here... - // if guid == 1, unequip item? + sLog.outDebug("Item " I64FMT ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot); + + Item *item = _player->GetItemByGuid(itemGuid); + + uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8); + + if(!item) + { + Item *uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if(!uItem) + continue; + + ItemPosCountVec sDest; + uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, sDest, uItem, false ); + if(msg == EQUIP_ERR_OK) + { + _player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true); + _player->StoreItem( sDest, uItem, true ); + } + else + _player->SendEquipError(msg, uItem, NULL); + + continue; + } + + if(item->GetPos() == dstpos) + continue; + + _player->SwapItem(item->GetPos(), dstpos); } WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1); diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 3dfd6e521..278478308 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -30,8 +30,8 @@ Corpse::Corpse(CorpseType type) : WorldObject() { m_objectType |= TYPEMASK_CORPSE; m_objectTypeId = TYPEID_CORPSE; - // 3.1.0 - 0x148 - m_updateFlag = (UPDATEFLAG_LOWGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_UNK1); + + m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION); m_valuesCount = CORPSE_END; diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index b6c8aa2db..e9adad27c 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -30,8 +30,8 @@ DynamicObject::DynamicObject() : WorldObject() { m_objectType |= TYPEMASK_DYNAMICOBJECT; m_objectTypeId = TYPEID_DYNAMICOBJECT; - // 3.1.0 - 0x48 - m_updateFlag = (UPDATEFLAG_LOWGUID | UPDATEFLAG_HAS_POSITION); + + m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION); m_valuesCount = DYNAMICOBJECT_END; } diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 16ea07d22..6490163ca 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -40,8 +40,8 @@ GameObject::GameObject() : WorldObject() { m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; - // 3.1.0 - 0x348 - m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_UNK1 | UPDATEFLAG_UNK2); + + m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION | UPDATEFLAG_ROTATION); m_valuesCount = GAMEOBJECT_END; m_respawnTime = 0; diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 82c022679..ccddbdbc7 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -748,8 +748,7 @@ void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID } } - // We may wish a better check, perhaps checking the real quest requirements - if (RequestItemsText.empty()) + if (!pQuest->GetReqItemsCount() && Completable) { SendQuestGiverOfferReward(pQuest, npcGUID, true); return; diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 359be6c4f..b1f2a00b7 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -233,7 +233,7 @@ Item::Item( ) { m_objectType |= TYPEMASK_ITEM; m_objectTypeId = TYPEID_ITEM; - // 3.1.0 - 0x08 + // 3.1.2 - 0x10 m_updateFlag = UPDATEFLAG_HIGHGUID; m_valuesCount = ITEM_END; diff --git a/src/game/Item.h b/src/game/Item.h index 2f7376aae..c49d3a946 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -163,7 +163,7 @@ enum EnchantmentSlot MAX_ENCHANTMENT_SLOT = 12 }; -#define MAX_VISIBLE_ITEM_OFFSET 18 // 18 fields per visible item (creator(2) + enchantments(13) + properties(1) + seed(1) + pad(1)) +#define MAX_VISIBLE_ITEM_OFFSET 2 // 2 fields per visible item (entry+enchantment) #define MAX_GEM_SOCKETS MAX_ITEM_PROTO_SOCKETS// (BONUS_ENCHANTMENT_SLOT-SOCK_ENCHANTMENT_SLOT) and item proto size, equal value expected diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 3f9cb66d9..4bebaa849 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -453,7 +453,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2 } else { - if(flags & UPDATEFLAG_UNK1) + if(flags & UPDATEFLAG_POSITION) { *data << uint8(0); // unk PGUID! *data << ((WorldObject*)this)->GetPositionX(); @@ -572,7 +572,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2 } // 0x200 - if(flags & UPDATEFLAG_UNK2) + if(flags & UPDATEFLAG_ROTATION) { *data << uint64(((GameObject*)this)->GetRotation()); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 4569389ec..aae03dd9f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1478,9 +1478,9 @@ 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); + uint32 enchantId = GetUInt16Value(visualbase + 1, enchantSlot); if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId)) break; } @@ -9262,7 +9262,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } // check free space for all items - for (int k=0;kGetEntry() == pItem->GetEntry() && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) @@ -9305,7 +9305,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()) @@ -9317,7 +9317,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()) @@ -9329,7 +9329,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 ) @@ -9384,7 +9384,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 ) @@ -9412,7 +9412,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 ) { @@ -9424,7 +9424,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 ) @@ -9731,14 +9731,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; } } @@ -9750,10 +9750,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 @@ -10012,7 +10012,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); @@ -10027,7 +10027,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() ); @@ -10036,7 +10036,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) { @@ -10131,7 +10131,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); @@ -10225,19 +10225,11 @@ 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) { SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), pItem->GetEntry()); - SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (slot * 2), pItem->GetEnchantmentId(EnchantmentSlot(0))); + SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (slot * 2), 0, pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)); + SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (slot * 2), 1, pItem->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)); } else { @@ -10258,14 +10250,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); } @@ -10293,7 +10285,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); @@ -10324,13 +10316,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 { @@ -10351,8 +10343,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()) { @@ -10366,13 +10358,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()) @@ -10395,7 +10387,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) 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); + DestroyItem(slot, i, update); } if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) @@ -10408,7 +10400,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 ) @@ -10417,7 +10409,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); } @@ -10434,11 +10426,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; } @@ -10476,7 +10468,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 @@ -10504,7 +10496,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 @@ -10537,7 +10529,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 @@ -10564,12 +10556,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; } } @@ -10594,12 +10586,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 < CURRENCYTOKEN_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 @@ -10607,13 +10599,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)) + 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); } @@ -10653,7 +10645,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); } @@ -10892,7 +10884,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) } RemoveItem(srcbag, srcslot, true); - EquipItem( dest, pSrcItem, true); + EquipItem(dest, pSrcItem, true); AutoUnequipOffhandIfNeed(); } @@ -11022,7 +11014,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; } @@ -11040,7 +11032,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) @@ -11119,7 +11111,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() ); @@ -11128,7 +11120,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; } } @@ -11156,7 +11148,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 ); @@ -11168,7 +11160,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); @@ -11251,9 +11243,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::const_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 @@ -11268,14 +11260,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); } @@ -11289,25 +11281,25 @@ void Player::UpdateEnchantTime(uint32 time) void Player::AddEnchantmentDurations(Item *item) { - for(int x=0;xGetEnchantmentId(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 @@ -11318,15 +11310,15 @@ void Player::RemoveEnchantmentDurations(Item *item) void Player::RemoveAllEnchantments(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)) { // remove from stats - ApplyEnchantment(itr->item,slot,false,false); + ApplyEnchantment(itr->item, slot, false, false); // remove visual itr->item->ClearEnchantment(slot); } @@ -11372,19 +11364,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)); } } @@ -11394,7 +11386,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; @@ -11418,7 +11410,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]; @@ -11452,11 +11444,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; } } @@ -11464,12 +11456,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: @@ -11478,11 +11470,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; } } @@ -11498,11 +11490,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; } } @@ -11691,12 +11683,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); } } @@ -11717,9 +11709,11 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a // visualize enchantment at player and equipped items if(slot == PERM_ENCHANTMENT_SLOT) - { - SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), apply ? item->GetEnchantmentId(slot) : 0); - } + SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), 0, apply ? item->GetEnchantmentId(slot) : 0); + + if(slot == TEMP_ENCHANTMENT_SLOT) + SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), 1, apply ? item->GetEnchantmentId(slot) : 0); + if(apply_dur) { @@ -11728,27 +11722,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::const_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::const_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); } @@ -11761,18 +11755,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); @@ -11791,7 +11785,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; @@ -11857,12 +11851,13 @@ 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 ); - else if( status == DIALOG_STATUS_INCOMPLETE ) - PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, false, true ); + if( status == DIALOG_STATUS_UNK2 && !GetQuestRewardStatus( quest_id ) ) + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest, false), true ); + else if( status == DIALOG_STATUS_UNK2 ) + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest, false), true ); // Send completable on repeatable quest if player don't have quest else if( pQuest->IsRepeatable() && !pQuest->IsDaily() ) PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanCompleteRepeatableQuest(pQuest), true ); @@ -13796,7 +13791,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; } @@ -13807,8 +13802,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]) { diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 9814bb4a6..8ea355b8d 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -132,8 +132,7 @@ void MapManager::LoadTransports() Transport::Transport() : GameObject() { - // 3.1.0 - 0x34A - m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_UNK2); + m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION); } bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index e265c2f0b..fc461ebd4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -74,7 +74,7 @@ Unit::Unit() { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; - // 3.1.0 - 0x60 + m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION); m_attackTimer[BASE_ATTACK] = 0; @@ -289,7 +289,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 ty data << uint32(MovementFlags); if(MovementFlags & MONSTER_MOVE_WALK) - moveTime *= 1.4f; + moveTime *= 1.05f; data << uint32(moveTime); // Time in between points data << uint32(1); // 1 single waypoint diff --git a/src/game/UpdateData.h b/src/game/UpdateData.h index 718ae96f4..e31140e7d 100644 --- a/src/game/UpdateData.h +++ b/src/game/UpdateData.h @@ -42,8 +42,8 @@ enum OBJECT_UPDATE_FLAGS UPDATEFLAG_LIVING = 0x0020, UPDATEFLAG_HAS_POSITION = 0x0040, UPDATEFLAG_VEHICLE = 0x0080, - UPDATEFLAG_UNK1 = 0x0100, - UPDATEFLAG_UNK2 = 0x0200 + UPDATEFLAG_POSITION = 0x0100, + UPDATEFLAG_ROTATION = 0x0200 }; class UpdateData diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index b97efa7c2..68f47e510 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -345,12 +345,12 @@ void WorldSession::LogoutPlayer(bool Save) if(Save) { uint32 eslot; - for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++) + for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j) { eslot = j - BUYBACK_SLOT_START; - _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+eslot*2,0); - _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+eslot,0); - _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+eslot,0); + _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); + _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); + _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); } _player->SaveToDB(); }