Attempt to fix quests. Some other fixes.

This commit is contained in:
tomrus88 2009-05-07 02:04:43 +04:00
parent 2d61cc1e76
commit 908f41b031
13 changed files with 158 additions and 138 deletions

View file

@ -1366,11 +1366,38 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data)
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1); CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1);
uint8 dstbag, dstslot; uint8 srcbag, srcslot;
recv_data >> dstbag >> dstslot; recv_data >> srcbag >> srcslot;
// so we have itemGuid, bag and slot here... sLog.outDebug("Item " I64FMT ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot);
// if guid == 1, unequip item?
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); WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1);

View file

@ -30,8 +30,8 @@ Corpse::Corpse(CorpseType type) : WorldObject()
{ {
m_objectType |= TYPEMASK_CORPSE; m_objectType |= TYPEMASK_CORPSE;
m_objectTypeId = TYPEID_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; m_valuesCount = CORPSE_END;

View file

@ -30,8 +30,8 @@ DynamicObject::DynamicObject() : WorldObject()
{ {
m_objectType |= TYPEMASK_DYNAMICOBJECT; m_objectType |= TYPEMASK_DYNAMICOBJECT;
m_objectTypeId = TYPEID_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; m_valuesCount = DYNAMICOBJECT_END;
} }

View file

@ -40,8 +40,8 @@ GameObject::GameObject() : WorldObject()
{ {
m_objectType |= TYPEMASK_GAMEOBJECT; m_objectType |= TYPEMASK_GAMEOBJECT;
m_objectTypeId = TYPEID_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_valuesCount = GAMEOBJECT_END;
m_respawnTime = 0; m_respawnTime = 0;

View file

@ -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 (!pQuest->GetReqItemsCount() && Completable)
if (RequestItemsText.empty())
{ {
SendQuestGiverOfferReward(pQuest, npcGUID, true); SendQuestGiverOfferReward(pQuest, npcGUID, true);
return; return;

View file

@ -233,7 +233,7 @@ Item::Item( )
{ {
m_objectType |= TYPEMASK_ITEM; m_objectType |= TYPEMASK_ITEM;
m_objectTypeId = TYPEID_ITEM; m_objectTypeId = TYPEID_ITEM;
// 3.1.0 - 0x08 // 3.1.2 - 0x10
m_updateFlag = UPDATEFLAG_HIGHGUID; m_updateFlag = UPDATEFLAG_HIGHGUID;
m_valuesCount = ITEM_END; m_valuesCount = ITEM_END;

View file

@ -163,7 +163,7 @@ enum EnchantmentSlot
MAX_ENCHANTMENT_SLOT = 12 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 #define MAX_GEM_SOCKETS MAX_ITEM_PROTO_SOCKETS// (BONUS_ENCHANTMENT_SLOT-SOCK_ENCHANTMENT_SLOT) and item proto size, equal value expected

View file

@ -453,7 +453,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2
} }
else else
{ {
if(flags & UPDATEFLAG_UNK1) if(flags & UPDATEFLAG_POSITION)
{ {
*data << uint8(0); // unk PGUID! *data << uint8(0); // unk PGUID!
*data << ((WorldObject*)this)->GetPositionX(); *data << ((WorldObject*)this)->GetPositionX();
@ -572,7 +572,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2
} }
// 0x200 // 0x200
if(flags & UPDATEFLAG_UNK2) if(flags & UPDATEFLAG_ROTATION)
{ {
*data << uint64(((GameObject*)this)->GetRotation()); *data << uint64(((GameObject*)this)->GetRotation());
} }

View file

@ -1478,9 +1478,9 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
const ItemPrototype * proto = objmgr.GetItemPrototype(item_id); const ItemPrototype * proto = objmgr.GetItemPrototype(item_id);
SpellItemEnchantmentEntry const *enchant = NULL; 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)) if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId))
break; break;
} }
@ -9262,7 +9262,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
} }
// check free space for all items // check free space for all items
for (int k=0;k<count;k++) for (int k = 0; k < count; ++k)
{ {
Item *pItem = pItems[k]; Item *pItem = pItems[k];
@ -9293,7 +9293,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
{ {
bool b_found = false; 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 ); pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) if( pItem2 && pItem2->GetEntry() == 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; 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 ); pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_tokens[t-CURRENCYTOKEN_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) 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; 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 ); 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()) 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; 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 ); pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pBag ) if( pBag )
@ -9384,7 +9384,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
if (b_found) continue; 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 ); pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pBag ) if( pBag )
@ -9412,7 +9412,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
// search free slot // search free slot
bool b_found = false; 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 ) 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; if (b_found) continue;
// search free slot in bags // 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 ); pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pBag ) if( pBag )
@ -9731,14 +9731,14 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
} }
else else
{ {
res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot);
if(res!=EQUIP_ERR_OK) 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, true, pItem, NULL_BAG, slot);
if(res!=EQUIP_ERR_OK) if(res != EQUIP_ERR_OK)
return res; return res;
if(count==0) if(count == 0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
} }
} }
@ -9750,10 +9750,10 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
{ {
// in slots // in slots
res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); 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; return res;
if(count==0) if(count == 0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
// in special bags // in special bags
@ -10012,7 +10012,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
if (!pItem2) if (!pItem2)
{ {
if (clone) if (clone)
pItem = pItem->CloneItem(count,this); pItem = pItem->CloneItem(count, this);
else else
pItem->SetCount(count); 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) if (bag == INVENTORY_SLOT_BAG_0)
{ {
m_items[slot] = pItem; 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_CONTAINED, GetGUID() );
pItem->SetUInt64Value( ITEM_FIELD_OWNER, 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 // need update known currency
if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(),true); UpdateKnownCurrencies(pItem->GetEntry(), true);
if (IsInWorld() && update) 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 // item set bonuses applied only at equip and removed at unequip, and still active for broken items
if(pProto && pProto->ItemSet) if(pProto && pProto->ItemSet)
AddItemsSetItem(this,pItem); AddItemsSetItem(this, pItem);
_ApplyItemMods(pItem, slot, true); _ApplyItemMods(pItem, slot, true);
@ -10225,19 +10225,11 @@ void Player::QuickEquipItem( uint16 pos, Item *pItem)
void Player::SetVisibleItemSlot(uint8 slot, 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) if(pItem)
{ {
SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), pItem->GetEntry()); 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 else
{ {
@ -10258,14 +10250,14 @@ void Player::VisualizeItem( uint8 slot, Item *pItem)
sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry());
m_items[slot] = pItem; 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_CONTAINED, GetGUID() );
pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() );
pItem->SetSlot( slot ); pItem->SetSlot( slot );
pItem->SetContainer( NULL ); pItem->SetContainer( NULL );
if( slot < EQUIPMENT_SLOT_END ) if( slot < EQUIPMENT_SLOT_END )
SetVisibleItemSlot(slot,pItem); SetVisibleItemSlot(slot, pItem);
pItem->SetState(ITEM_CHANGED, this); 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 // item set bonuses applied only at equip and removed at unequip, and still active for broken items
if(pProto && pProto->ItemSet) if(pProto && pProto->ItemSet)
RemoveItemsSetItem(this,pProto); RemoveItemsSetItem(this, pProto);
_ApplyItemMods(pItem, slot, false); _ApplyItemMods(pItem, slot, false);
@ -10324,13 +10316,13 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
} }
// need update known currency // need update known currency
else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(),false); UpdateKnownCurrencies(pItem->GetEntry(), false);
m_items[slot] = NULL; 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 ) if ( slot < EQUIPMENT_SLOT_END )
SetVisibleItemSlot(slot,NULL); SetVisibleItemSlot(slot, NULL);
} }
else else
{ {
@ -10351,8 +10343,8 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update)
{ {
if(Item* it = GetItemByPos(bag,slot)) if(Item* it = GetItemByPos(bag,slot))
{ {
ItemRemovedQuestCheck(it->GetEntry(),it->GetCount()); ItemRemovedQuestCheck(it->GetEntry(), it->GetCount());
RemoveItem( bag,slot,update); RemoveItem(bag, slot, update);
it->RemoveFromUpdateQueueOf(this); it->RemoveFromUpdateQueueOf(this);
if(it->IsInWorld()) 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) void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB)
{ {
// update quest counters // update quest counters
ItemAddedQuestCheck(pItem->GetEntry(),pItem->GetCount()); ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
// store item // 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) // 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 // update owner for last item (this can be original item with wrong owner
if(pLastItem->GetOwnerGUID() != GetGUID()) 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 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) 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)) 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 ) 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 // equipment and equipped bags can have applied bonuses
if ( slot < INVENTORY_SLOT_BAG_END ) 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 // item set bonuses applied only at equip and removed at unequip, and still active for broken items
if(pProto && pProto->ItemSet) if(pProto && pProto->ItemSet)
RemoveItemsSetItem(this,pProto); RemoveItemsSetItem(this, pProto);
_ApplyItemMods(pItem, slot, false); _ApplyItemMods(pItem, slot, false);
} }
@ -10434,11 +10426,11 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
UpdateExpertise(OFF_ATTACK); UpdateExpertise(OFF_ATTACK);
// equipment visual show // equipment visual show
SetVisibleItemSlot(slot,NULL); SetVisibleItemSlot(slot, NULL);
} }
// need update known currency // need update known currency
else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(),false); UpdateKnownCurrencies(pItem->GetEntry(), false);
m_items[slot] = NULL; m_items[slot] = NULL;
} }
@ -10476,7 +10468,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
remcount += pItem->GetCount(); remcount += pItem->GetCount();
DestroyItem( INVENTORY_SLOT_BAG_0, i, update); DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
if (remcount >=count) if (remcount >= count)
return; return;
} }
else else
@ -10504,7 +10496,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
remcount += pItem->GetCount(); remcount += pItem->GetCount();
DestroyItem( INVENTORY_SLOT_BAG_0, i, update); DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
if (remcount >=count) if (remcount >= count)
return; return;
} }
else else
@ -10537,7 +10529,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
remcount += pItem->GetCount(); remcount += pItem->GetCount();
DestroyItem( i, j, update ); DestroyItem( i, j, update );
if (remcount >=count) if (remcount >= count)
return; return;
} }
else else
@ -10564,12 +10556,12 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
{ {
if (pItem->GetCount() + remcount <= count) 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(); remcount += pItem->GetCount();
DestroyItem( INVENTORY_SLOT_BAG_0, i, update); DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
if (remcount >=count) if (remcount >= count)
return; return;
} }
} }
@ -10594,12 +10586,12 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone )
// in inventory // in inventory
for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, 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); DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, 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); DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
// in inventory bags // 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 )) if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
for(uint32 j = 0; j < pBag->GetBagSize(); ++j) for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
if (Item* pItem = pBag->GetItemByPos(j)) if (Item* pItem = pBag->GetItemByPos(j))
if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone)) if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone))
DestroyItem( i, j, update); DestroyItem( i, j, update);
// in equipment and bag list // in equipment and bag list
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, 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); DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
} }
@ -10653,7 +10645,7 @@ void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update )
if( pItem->GetCount() <= count ) if( pItem->GetCount() <= count )
{ {
count-= pItem->GetCount(); count -= pItem->GetCount();
DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update); DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update);
} }
@ -10892,7 +10884,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
} }
RemoveItem(srcbag, srcslot, true); RemoveItem(srcbag, srcslot, true);
EquipItem( dest, pSrcItem, true); EquipItem(dest, pSrcItem, true);
AutoUnequipOffhandIfNeed(); AutoUnequipOffhandIfNeed();
} }
@ -11022,7 +11014,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
ItemPrototype const* bagItemProto = bagItem->GetProto(); ItemPrototype const* bagItemProto = bagItem->GetProto();
if (!bagItemProto || !ItemCanGoIntoBag(bagItemProto, emotyProto)) 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 ); SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem );
return; return;
} }
@ -11040,7 +11032,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
// Items swap // Items swap
count = 0; // will pos in new bag 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); Item *bagItem = fullBag->GetItemByPos(i);
if (!bagItem) if (!bagItem)
@ -11119,7 +11111,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem )
uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 etime = uint32(base - m_logintime + (30 * 3600));
uint32 eslot = slot - BUYBACK_SLOT_START; 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(); ItemPrototype const *pProto = pItem->GetProto();
if( pProto ) if( pProto )
SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); 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 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime );
// move to next (for non filled list is move most optimized choice) // 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; ++m_currentBuybackSlot;
} }
} }
@ -11156,7 +11148,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del )
m_items[slot] = NULL; m_items[slot] = NULL;
uint32 eslot = slot - BUYBACK_SLOT_START; 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_PRICE_1 + eslot, 0 );
SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_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 ) 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) ); WorldPacket data( SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18) );
data << uint8(msg); data << uint8(msg);
@ -11251,9 +11243,9 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly)
if(m_itemDuration.empty()) if(m_itemDuration.empty())
return; 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; Item* item = *itr;
++itr; // current element can be erased in UpdateDuration ++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) for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next)
{ {
assert(itr->item); assert(itr->item);
next=itr; next = itr;
if(!itr->item->GetEnchantmentId(itr->slot)) if(!itr->item->GetEnchantmentId(itr->slot))
{ {
next = m_enchantDuration.erase(itr); next = m_enchantDuration.erase(itr);
} }
else if(itr->leftduration <= time) else if(itr->leftduration <= time)
{ {
ApplyEnchantment(itr->item,itr->slot,false,false); ApplyEnchantment(itr->item, itr->slot, false, false);
itr->item->ClearEnchantment(itr->slot); itr->item->ClearEnchantment(itr->slot);
next = m_enchantDuration.erase(itr); next = m_enchantDuration.erase(itr);
} }
@ -11289,25 +11281,25 @@ void Player::UpdateEnchantTime(uint32 time)
void Player::AddEnchantmentDurations(Item *item) 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))) if(!item->GetEnchantmentId(EnchantmentSlot(x)))
continue; continue;
uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x));
if( duration > 0 ) if( duration > 0 )
AddEnchantmentDuration(item,EnchantmentSlot(x),duration); AddEnchantmentDuration(item, EnchantmentSlot(x), duration);
} }
} }
void Player::RemoveEnchantmentDurations(Item *item) 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) if(itr->item == item)
{ {
// save duration in item // save duration in item
item->SetEnchantmentDuration(EnchantmentSlot(itr->slot),itr->leftduration); item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration);
itr = m_enchantDuration.erase(itr); itr = m_enchantDuration.erase(itr);
} }
else else
@ -11318,15 +11310,15 @@ void Player::RemoveEnchantmentDurations(Item *item)
void Player::RemoveAllEnchantments(EnchantmentSlot slot) void Player::RemoveAllEnchantments(EnchantmentSlot slot)
{ {
// remove enchantments from equipped items first to clean up the m_enchantDuration list // 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; 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 // remove from stats
ApplyEnchantment(itr->item,slot,false,false); ApplyEnchantment(itr->item, slot, false, false);
// remove visual // remove visual
itr->item->ClearEnchantment(slot); itr->item->ClearEnchantment(slot);
} }
@ -11372,19 +11364,19 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat
if(slot >= MAX_ENCHANTMENT_SLOT) if(slot >= MAX_ENCHANTMENT_SLOT)
return; 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) 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); m_enchantDuration.erase(itr);
break; break;
} }
} }
if(item && duration > 0 ) if(item && duration > 0 )
{ {
GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(),slot,uint32(duration/1000)); GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000));
m_enchantDuration.push_back(EnchantDuration(item,slot,duration)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration));
} }
} }
@ -11394,7 +11386,7 @@ void Player::ApplyEnchantment(Item *item,bool apply)
ApplyEnchantment(item, EnchantmentSlot(slot), 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) if(!item)
return; return;
@ -11418,7 +11410,7 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a
if (!item->IsBroken()) 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_display_type = pEnchant->type[s];
uint32 enchant_amount = pEnchant->amount[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) if (item_rand)
{ {
// Search enchant_amount // 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) 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; 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 // Cast custom spell vs all equal basepoints getted from enchant_amount
if (basepoints) if (basepoints)
CastCustomSpell(this,enchant_spell_id,&basepoints,&basepoints,&basepoints,true,item); CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item);
else else
CastSpell(this,enchant_spell_id,true,item); CastSpell(this, enchant_spell_id, true, item);
} }
else else
RemoveAurasDueToItemSpell(item,enchant_spell_id); RemoveAurasDueToItemSpell(item, enchant_spell_id);
} }
break; break;
case ITEM_ENCHANTMENT_TYPE_RESISTANCE: 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())); ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if(item_rand) 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) 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; 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())); ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if(item_rand_suffix) 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) 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; break;
} }
} }
@ -11691,12 +11683,12 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a
float addValue = 0.0f; float addValue = 0.0f;
if(item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) 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); HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply);
} }
else if(item->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) 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); 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 // visualize enchantment at player and equipped items
if(slot == PERM_ENCHANTMENT_SLOT) if(slot == PERM_ENCHANTMENT_SLOT)
{ SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), 0, apply ? item->GetEnchantmentId(slot) : 0);
SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), 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) if(apply_dur)
{ {
@ -11728,27 +11722,27 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a
// set duration // set duration
uint32 duration = item->GetEnchantmentDuration(slot); uint32 duration = item->GetEnchantmentDuration(slot);
if(duration > 0) if(duration > 0)
AddEnchantmentDuration(item,slot,duration); AddEnchantmentDuration(item, slot, duration);
} }
else else
{ {
// duration == 0 will remove EnchantDuration // duration == 0 will remove EnchantDuration
AddEnchantmentDuration(item,slot,0); AddEnchantmentDuration(item, slot, 0);
} }
} }
} }
void Player::SendEnchantmentDurations() 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() 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); (*itr)->SendTimeUpdate(this);
} }
@ -11761,18 +11755,18 @@ void Player::SendNewItem(Item *item, uint32 count, bool received, bool created,
// last check 2.0.10 // last check 2.0.10
WorldPacket data( SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4) ); 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(received); // 0=looted, 1=from npc
data << uint32(created); // 0=received, 1=created data << uint32(created); // 0=received, 1=created
data << uint32(1); // always 0x01 (probably meant to be count of listed items) 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 // 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->GetEntry()); // item id
data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemSuffixFactor()); // SuffixFactor
data << uint32(item->GetItemRandomPropertyId()); // random item property id data << uint32(item->GetItemRandomPropertyId()); // random item property id
data << uint32(count); // count of items 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()) if (broadcast && GetGroup())
GetGroup()->BroadcastPacket(&data, true); GetGroup()->BroadcastPacket(&data, true);
@ -11791,7 +11785,7 @@ void Player::PrepareQuestMenu( uint64 guid )
QuestRelations* pObjectQIR; QuestRelations* pObjectQIR;
// pets also can have quests // pets also can have quests
Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid); Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
if( pCreature ) if( pCreature )
{ {
pObject = (Object*)pCreature; pObject = (Object*)pCreature;
@ -11857,12 +11851,13 @@ void Player::SendPreparedQuest( uint64 guid )
// Auto open -- maybe also should verify there is no greeting // Auto open -- maybe also should verify there is no greeting
uint32 quest_id = qmi0.m_qId; uint32 quest_id = qmi0.m_qId;
Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); Quest const* pQuest = objmgr.GetQuestTemplate(quest_id);
if ( pQuest ) if ( pQuest )
{ {
if( status == DIALOG_STATUS_REWARD_REP && !GetQuestRewardStatus( quest_id ) ) if( status == DIALOG_STATUS_UNK2 && !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 ) else if( status == DIALOG_STATUS_UNK2 )
PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, false, true ); PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest, false), true );
// Send completable on repeatable quest if player don't have quest // Send completable on repeatable quest if player don't have quest
else if( pQuest->IsRepeatable() && !pQuest->IsDaily() ) else if( pQuest->IsRepeatable() && !pQuest->IsDaily() )
PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanCompleteRepeatableQuest(pQuest), true ); PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanCompleteRepeatableQuest(pQuest), true );
@ -13796,7 +13791,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(!LoadValues( fields[2].GetString())) 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; delete result;
return false; 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) // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
{ {
SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), 0 ); SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0 );
SetVisibleItemSlot(slot,NULL); SetVisibleItemSlot(slot, NULL);
if (m_items[slot]) if (m_items[slot])
{ {

View file

@ -132,8 +132,7 @@ void MapManager::LoadTransports()
Transport::Transport() : GameObject() Transport::Transport() : GameObject()
{ {
// 3.1.0 - 0x34A m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION);
m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_UNK2);
} }
bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags) bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)

View file

@ -74,7 +74,7 @@ Unit::Unit()
{ {
m_objectType |= TYPEMASK_UNIT; m_objectType |= TYPEMASK_UNIT;
m_objectTypeId = TYPEID_UNIT; m_objectTypeId = TYPEID_UNIT;
// 3.1.0 - 0x60
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION); m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION);
m_attackTimer[BASE_ATTACK] = 0; m_attackTimer[BASE_ATTACK] = 0;
@ -289,7 +289,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 ty
data << uint32(MovementFlags); data << uint32(MovementFlags);
if(MovementFlags & MONSTER_MOVE_WALK) if(MovementFlags & MONSTER_MOVE_WALK)
moveTime *= 1.4f; moveTime *= 1.05f;
data << uint32(moveTime); // Time in between points data << uint32(moveTime); // Time in between points
data << uint32(1); // 1 single waypoint data << uint32(1); // 1 single waypoint

View file

@ -42,8 +42,8 @@ enum OBJECT_UPDATE_FLAGS
UPDATEFLAG_LIVING = 0x0020, UPDATEFLAG_LIVING = 0x0020,
UPDATEFLAG_HAS_POSITION = 0x0040, UPDATEFLAG_HAS_POSITION = 0x0040,
UPDATEFLAG_VEHICLE = 0x0080, UPDATEFLAG_VEHICLE = 0x0080,
UPDATEFLAG_UNK1 = 0x0100, UPDATEFLAG_POSITION = 0x0100,
UPDATEFLAG_UNK2 = 0x0200 UPDATEFLAG_ROTATION = 0x0200
}; };
class UpdateData class UpdateData

View file

@ -345,12 +345,12 @@ void WorldSession::LogoutPlayer(bool Save)
if(Save) if(Save)
{ {
uint32 eslot; 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; eslot = j - BUYBACK_SLOT_START;
_player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+eslot*2,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_PRICE_1 + eslot, 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+eslot,0); _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
} }
_player->SaveToDB(); _player->SaveToDB();
} }