2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "WorldPacket.h"
21 #include "WorldSession.h"
24 #include "ObjectMgr.h"
27 #include "UpdateData.h"
28 #include "ObjectAccessor.h"
30 void WorldSession::HandleSplitItemOpcode( WorldPacket
& recv_data
)
32 CHECK_PACKET_SIZE(recv_data
,1+1+1+1+1);
34 //sLog.outDebug("WORLD: CMSG_SPLIT_ITEM");
35 uint8 srcbag
, srcslot
, dstbag
, dstslot
, count
;
37 recv_data
>> srcbag
>> srcslot
>> dstbag
>> dstslot
>> count
;
38 //sLog.outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u, dstslot = %u, count = %u", srcbag, srcslot, dstbag, dstslot, count);
40 uint16 src
= ( (srcbag
<< 8) | srcslot
);
41 uint16 dst
= ( (dstbag
<< 8) | dstslot
);
47 return; //check count - if zero it's fake packet
49 if(!_player
->IsValidPos(srcbag
,srcslot
))
51 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
55 if(!_player
->IsValidPos(dstbag
,dstslot
))
57 _player
->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT
, NULL
, NULL
);
61 _player
->SplitItem( src
, dst
, count
);
64 void WorldSession::HandleSwapInvItemOpcode( WorldPacket
& recv_data
)
66 CHECK_PACKET_SIZE(recv_data
,1+1);
68 //sLog.outDebug("WORLD: CMSG_SWAP_INV_ITEM");
69 uint8 srcslot
, dstslot
;
71 recv_data
>> srcslot
>> dstslot
;
72 //sLog.outDebug("STORAGE: receive srcslot = %u, dstslot = %u", srcslot, dstslot);
74 // prevent attempt swap same item to current position generated by client at special checting sequence
78 if(!_player
->IsValidPos(INVENTORY_SLOT_BAG_0
,srcslot
))
80 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
84 if(!_player
->IsValidPos(INVENTORY_SLOT_BAG_0
,dstslot
))
86 _player
->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT
, NULL
, NULL
);
90 uint16 src
= ( (INVENTORY_SLOT_BAG_0
<< 8) | srcslot
);
91 uint16 dst
= ( (INVENTORY_SLOT_BAG_0
<< 8) | dstslot
);
93 _player
->SwapItem( src
, dst
);
96 void WorldSession::HandleAutoEquipItemSlotOpcode( WorldPacket
& recv_data
)
98 CHECK_PACKET_SIZE(recv_data
,8+1);
101 recv_data
>> itemguid
>> dstslot
;
103 // cheating attempt, client should never send opcode in that case
104 if(!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0
, dstslot
))
107 Item
* item
= _player
->GetItemByGuid(itemguid
);
108 uint16 dstpos
= dstslot
| (INVENTORY_SLOT_BAG_0
<< 8);
110 if(!item
|| item
->GetPos() == dstpos
)
113 _player
->SwapItem(item
->GetPos(), dstpos
);
116 void WorldSession::HandleSwapItem( WorldPacket
& recv_data
)
118 CHECK_PACKET_SIZE(recv_data
,1+1+1+1);
120 //sLog.outDebug("WORLD: CMSG_SWAP_ITEM");
121 uint8 dstbag
, dstslot
, srcbag
, srcslot
;
123 recv_data
>> dstbag
>> dstslot
>> srcbag
>> srcslot
;
124 //sLog.outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u, dstslot = %u", srcbag, srcslot, dstbag, dstslot);
126 uint16 src
= ( (srcbag
<< 8) | srcslot
);
127 uint16 dst
= ( (dstbag
<< 8) | dstslot
);
129 // prevent attempt swap same item to current position generated by client at special checting sequence
133 if(!_player
->IsValidPos(srcbag
,srcslot
))
135 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
139 if(!_player
->IsValidPos(dstbag
,dstslot
))
141 _player
->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT
, NULL
, NULL
);
145 _player
->SwapItem( src
, dst
);
148 void WorldSession::HandleAutoEquipItemOpcode( WorldPacket
& recv_data
)
150 CHECK_PACKET_SIZE(recv_data
,1+1);
152 //sLog.outDebug("WORLD: CMSG_AUTOEQUIP_ITEM");
153 uint8 srcbag
, srcslot
;
155 recv_data
>> srcbag
>> srcslot
;
156 //sLog.outDebug("STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot);
158 Item
*pSrcItem
= _player
->GetItemByPos( srcbag
, srcslot
);
160 return; // only at cheat
162 if(pSrcItem
->m_lootGenerated
) // prevent swap looting item
164 //best error message found for attempting to swap while looting
165 _player
->SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW
, pSrcItem
, NULL
);
170 uint8 msg
= _player
->CanEquipItem( NULL_SLOT
, dest
, pSrcItem
, !pSrcItem
->IsBag() );
171 if( msg
!= EQUIP_ERR_OK
)
173 _player
->SendEquipError( msg
, pSrcItem
, NULL
);
177 uint16 src
= pSrcItem
->GetPos();
178 if(dest
==src
) // prevent equip in same slot, only at cheat
181 Item
*pDstItem
= _player
->GetItemByPos( dest
);
182 if( !pDstItem
) // empty slot, simple case
184 _player
->RemoveItem( srcbag
, srcslot
, true );
185 _player
->EquipItem( dest
, pSrcItem
, true );
186 _player
->AutoUnequipOffhandIfNeed();
188 else // have currently equipped item, not simple case
190 uint8 dstbag
= pDstItem
->GetBagSlot();
191 uint8 dstslot
= pDstItem
->GetSlot();
193 msg
= _player
->CanUnequipItem( dest
, !pSrcItem
->IsBag() );
194 if( msg
!= EQUIP_ERR_OK
)
196 _player
->SendEquipError( msg
, pDstItem
, NULL
);
200 // check dest->src move possibility
201 ItemPosCountVec sSrc
;
203 if( _player
->IsInventoryPos( src
) )
205 msg
= _player
->CanStoreItem( srcbag
, srcslot
, sSrc
, pDstItem
, true );
206 if( msg
!= EQUIP_ERR_OK
)
207 msg
= _player
->CanStoreItem( srcbag
, NULL_SLOT
, sSrc
, pDstItem
, true );
208 if( msg
!= EQUIP_ERR_OK
)
209 msg
= _player
->CanStoreItem( NULL_BAG
, NULL_SLOT
, sSrc
, pDstItem
, true );
211 else if( _player
->IsBankPos( src
) )
213 msg
= _player
->CanBankItem( srcbag
, srcslot
, sSrc
, pDstItem
, true );
214 if( msg
!= EQUIP_ERR_OK
)
215 msg
= _player
->CanBankItem( srcbag
, NULL_SLOT
, sSrc
, pDstItem
, true );
216 if( msg
!= EQUIP_ERR_OK
)
217 msg
= _player
->CanBankItem( NULL_BAG
, NULL_SLOT
, sSrc
, pDstItem
, true );
219 else if( _player
->IsEquipmentPos( src
) )
221 msg
= _player
->CanEquipItem( srcslot
, eSrc
, pDstItem
, true);
222 if( msg
== EQUIP_ERR_OK
)
223 msg
= _player
->CanUnequipItem( eSrc
, true);
226 if( msg
!= EQUIP_ERR_OK
)
228 _player
->SendEquipError( msg
, pDstItem
, pSrcItem
);
232 // now do moves, remove...
233 _player
->RemoveItem(dstbag
, dstslot
, false);
234 _player
->RemoveItem(srcbag
, srcslot
, false);
237 _player
->EquipItem(dest
, pSrcItem
, true);
240 if( _player
->IsInventoryPos( src
) )
241 _player
->StoreItem(sSrc
, pDstItem
, true);
242 else if( _player
->IsBankPos( src
) )
243 _player
->BankItem(sSrc
, pDstItem
, true);
244 else if( _player
->IsEquipmentPos( src
) )
245 _player
->EquipItem(eSrc
, pDstItem
, true);
247 _player
->AutoUnequipOffhandIfNeed();
251 void WorldSession::HandleDestroyItemOpcode( WorldPacket
& recv_data
)
253 CHECK_PACKET_SIZE(recv_data
,1+1+1+1+1+1);
255 //sLog.outDebug("WORLD: CMSG_DESTROYITEM");
256 uint8 bag
, slot
, count
, data1
, data2
, data3
;
258 recv_data
>> bag
>> slot
>> count
>> data1
>> data2
>> data3
;
259 //sLog.outDebug("STORAGE: receive bag = %u, slot = %u, count = %u", bag, slot, count);
261 uint16 pos
= (bag
<< 8) | slot
;
263 // prevent drop unequipable items (in combat, for example) and non-empty bags
264 if(_player
->IsEquipmentPos(pos
) || _player
->IsBagPos(pos
))
266 uint8 msg
= _player
->CanUnequipItem( pos
, false );
267 if( msg
!= EQUIP_ERR_OK
)
269 _player
->SendEquipError( msg
, _player
->GetItemByPos(pos
), NULL
);
274 Item
*pItem
= _player
->GetItemByPos( bag
, slot
);
277 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
283 uint32 i_count
= count
;
284 _player
->DestroyItemCount( pItem
, i_count
, true );
287 _player
->DestroyItem( bag
, slot
, true );
290 // Only _static_ data send in this packet !!!
291 void WorldSession::HandleItemQuerySingleOpcode( WorldPacket
& recv_data
)
293 CHECK_PACKET_SIZE(recv_data
, 4);
295 //sLog.outDebug("WORLD: CMSG_ITEM_QUERY_SINGLE");
299 sLog
.outDetail("STORAGE: Item Query = %u", item
);
301 ItemPrototype
const *pProto
= objmgr
.GetItemPrototype( item
);
304 std::string Name
= pProto
->Name1
;
305 std::string Description
= pProto
->Description
;
307 int loc_idx
= GetSessionDbLocaleIndex();
310 ItemLocale
const *il
= objmgr
.GetItemLocale(pProto
->ItemId
);
313 if (il
->Name
.size() > size_t(loc_idx
) && !il
->Name
[loc_idx
].empty())
314 Name
= il
->Name
[loc_idx
];
315 if (il
->Description
.size() > size_t(loc_idx
) && !il
->Description
[loc_idx
].empty())
316 Description
= il
->Description
[loc_idx
];
320 WorldPacket
data( SMSG_ITEM_QUERY_SINGLE_RESPONSE
, 600);
321 data
<< pProto
->ItemId
;
322 data
<< pProto
->Class
;
323 data
<< pProto
->SubClass
;
324 data
<< int32(pProto
->Unk0
); // new 2.0.3, not exist in wdb cache?
326 data
<< uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name...
327 data
<< uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00);
328 data
<< uint8(0x00); //pProto->Name4; // blizz not send name there, just uint8(0x00);
329 data
<< pProto
->DisplayInfoID
;
330 data
<< pProto
->Quality
;
331 data
<< pProto
->Flags
;
332 data
<< pProto
->BuyPrice
;
333 data
<< pProto
->SellPrice
;
334 data
<< pProto
->InventoryType
;
335 data
<< pProto
->AllowableClass
;
336 data
<< pProto
->AllowableRace
;
337 data
<< pProto
->ItemLevel
;
338 data
<< pProto
->RequiredLevel
;
339 data
<< pProto
->RequiredSkill
;
340 data
<< pProto
->RequiredSkillRank
;
341 data
<< pProto
->RequiredSpell
;
342 data
<< pProto
->RequiredHonorRank
;
343 data
<< pProto
->RequiredCityRank
;
344 data
<< pProto
->RequiredReputationFaction
;
345 data
<< pProto
->RequiredReputationRank
;
346 data
<< int32(pProto
->MaxCount
);
347 data
<< int32(pProto
->Stackable
);
348 data
<< pProto
->ContainerSlots
;
349 data
<< pProto
->StatsCount
; // item stats count
350 for(uint32 i
= 0; i
< pProto
->StatsCount
; ++i
)
352 data
<< pProto
->ItemStat
[i
].ItemStatType
;
353 data
<< pProto
->ItemStat
[i
].ItemStatValue
;
355 data
<< pProto
->ScalingStatDistribution
; // scaling stats distribution
356 data
<< pProto
->ScalingStatValue
; // some kind of flags used to determine stat values column
357 for(int i
= 0; i
< MAX_ITEM_PROTO_DAMAGES
; ++i
)
359 data
<< pProto
->Damage
[i
].DamageMin
;
360 data
<< pProto
->Damage
[i
].DamageMax
;
361 data
<< pProto
->Damage
[i
].DamageType
;
365 data
<< pProto
->Armor
;
366 data
<< pProto
->HolyRes
;
367 data
<< pProto
->FireRes
;
368 data
<< pProto
->NatureRes
;
369 data
<< pProto
->FrostRes
;
370 data
<< pProto
->ShadowRes
;
371 data
<< pProto
->ArcaneRes
;
373 data
<< pProto
->Delay
;
374 data
<< pProto
->AmmoType
;
375 data
<< pProto
->RangedModRange
;
377 for(int s
= 0; s
< MAX_ITEM_PROTO_SPELLS
; ++s
)
379 // send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
380 // use `item_template` or if not set then only use spell cooldowns
381 SpellEntry
const* spell
= sSpellStore
.LookupEntry(pProto
->Spells
[s
].SpellId
);
384 bool db_data
= pProto
->Spells
[s
].SpellCooldown
>= 0 || pProto
->Spells
[s
].SpellCategoryCooldown
>= 0;
386 data
<< pProto
->Spells
[s
].SpellId
;
387 data
<< pProto
->Spells
[s
].SpellTrigger
;
388 data
<< uint32(-abs(pProto
->Spells
[s
].SpellCharges
));
392 data
<< uint32(pProto
->Spells
[s
].SpellCooldown
);
393 data
<< uint32(pProto
->Spells
[s
].SpellCategory
);
394 data
<< uint32(pProto
->Spells
[s
].SpellCategoryCooldown
);
398 data
<< uint32(spell
->RecoveryTime
);
399 data
<< uint32(spell
->Category
);
400 data
<< uint32(spell
->CategoryRecoveryTime
);
413 data
<< pProto
->Bonding
;
415 data
<< pProto
->PageText
;
416 data
<< pProto
->LanguageID
;
417 data
<< pProto
->PageMaterial
;
418 data
<< pProto
->StartQuest
;
419 data
<< pProto
->LockID
;
420 data
<< int32(pProto
->Material
);
421 data
<< pProto
->Sheath
;
422 data
<< pProto
->RandomProperty
;
423 data
<< pProto
->RandomSuffix
;
424 data
<< pProto
->Block
;
425 data
<< pProto
->ItemSet
;
426 data
<< pProto
->MaxDurability
;
427 data
<< pProto
->Area
;
428 data
<< pProto
->Map
; // Added in 1.12.x & 2.0.1 client branch
429 data
<< pProto
->BagFamily
;
430 data
<< pProto
->TotemCategory
;
431 for(int s
= 0; s
< MAX_ITEM_PROTO_SOCKETS
; ++s
)
433 data
<< pProto
->Socket
[s
].Color
;
434 data
<< pProto
->Socket
[s
].Content
;
436 data
<< pProto
->socketBonus
;
437 data
<< pProto
->GemProperties
;
438 data
<< pProto
->RequiredDisenchantSkill
;
439 data
<< pProto
->ArmorDamageModifier
;
440 data
<< pProto
->Duration
; // added in 2.4.2.8209, duration (seconds)
441 data
<< pProto
->ItemLimitCategory
; // WotLK, ItemLimitCategory
442 data
<< uint32(0); // Holiday.dbc?
447 sLog
.outDebug( "WORLD: CMSG_ITEM_QUERY_SINGLE - NO item INFO! (ENTRY: %u)", item
);
448 WorldPacket
data( SMSG_ITEM_QUERY_SINGLE_RESPONSE
, 4);
449 data
<< uint32(item
| 0x80000000);
454 void WorldSession::HandleReadItem( WorldPacket
& recv_data
)
456 CHECK_PACKET_SIZE(recv_data
,1+1);
458 //sLog.outDebug( "WORLD: CMSG_READ_ITEM");
461 recv_data
>> bag
>> slot
;
463 //sLog.outDetail("STORAGE: Read bag = %u, slot = %u", bag, slot);
464 Item
*pItem
= _player
->GetItemByPos( bag
, slot
);
466 if( pItem
&& pItem
->GetProto()->PageText
)
470 uint8 msg
= _player
->CanUseItem( pItem
);
471 if( msg
== EQUIP_ERR_OK
)
473 data
.Initialize (SMSG_READ_ITEM_OK
, 8);
474 sLog
.outDetail("STORAGE: Item page sent");
478 data
.Initialize( SMSG_READ_ITEM_FAILED
, 8 );
479 sLog
.outDetail("STORAGE: Unable to read item");
480 _player
->SendEquipError( msg
, pItem
, NULL
);
482 data
<< pItem
->GetGUID();
486 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, NULL
, NULL
);
489 void WorldSession::HandlePageQuerySkippedOpcode( WorldPacket
& recv_data
)
491 CHECK_PACKET_SIZE(recv_data
,4+8);
493 sLog
.outDebug( "WORLD: Received CMSG_PAGE_TEXT_QUERY" );
498 recv_data
>> itemid
>> guid
;
500 sLog
.outDetail( "Packet Info: itemid: %u guidlow: %u guidentry: %u guidhigh: %u",
501 itemid
, GUID_LOPART(guid
), GUID_ENPART(guid
), GUID_HIPART(guid
));
504 void WorldSession::HandleSellItemOpcode( WorldPacket
& recv_data
)
506 CHECK_PACKET_SIZE(recv_data
,8+8+1);
508 sLog
.outDebug( "WORLD: Received CMSG_SELL_ITEM" );
509 uint64 vendorguid
, itemguid
;
512 recv_data
>> vendorguid
>> itemguid
>> _count
;
514 // prevent possible overflow, as mangos uses uint32 for item count
515 uint32 count
= _count
;
520 Creature
*pCreature
= GetPlayer()->GetNPCIfCanInteractWith(vendorguid
,UNIT_NPC_FLAG_VENDOR
);
523 sLog
.outDebug( "WORLD: HandleSellItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid
)) );
524 _player
->SendSellError( SELL_ERR_CANT_FIND_VENDOR
, NULL
, itemguid
, 0);
529 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED
))
530 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH
);
532 Item
*pItem
= _player
->GetItemByGuid( itemguid
);
535 // prevent sell not owner item
536 if(_player
->GetGUID()!=pItem
->GetOwnerGUID())
538 _player
->SendSellError( SELL_ERR_CANT_SELL_ITEM
, pCreature
, itemguid
, 0);
542 // prevent sell non empty bag by drag-and-drop at vendor's item list
543 if(pItem
->IsBag() && !((Bag
*)pItem
)->IsEmpty())
545 _player
->SendSellError( SELL_ERR_CANT_SELL_ITEM
, pCreature
, itemguid
, 0);
549 // prevent sell currently looted item
550 if(_player
->GetLootGUID()==pItem
->GetGUID())
552 _player
->SendSellError( SELL_ERR_CANT_SELL_ITEM
, pCreature
, itemguid
, 0);
556 // special case at auto sell (sell all)
559 count
= pItem
->GetCount();
563 // prevent sell more items that exist in stack (possable only not from client)
564 if(count
> pItem
->GetCount())
566 _player
->SendSellError( SELL_ERR_CANT_SELL_ITEM
, pCreature
, itemguid
, 0);
571 ItemPrototype
const *pProto
= pItem
->GetProto();
574 if( pProto
->SellPrice
> 0 )
576 if(count
< pItem
->GetCount()) // need split items
578 Item
*pNewItem
= pItem
->CloneItem( count
, _player
);
581 sLog
.outError("WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem
->GetEntry(), count
);
582 _player
->SendSellError( SELL_ERR_CANT_SELL_ITEM
, pCreature
, itemguid
, 0);
586 pItem
->SetCount( pItem
->GetCount() - count
);
587 _player
->ItemRemovedQuestCheck( pItem
->GetEntry(), count
);
588 if( _player
->IsInWorld() )
589 pItem
->SendUpdateToPlayer( _player
);
590 pItem
->SetState(ITEM_CHANGED
, _player
);
592 _player
->AddItemToBuyBackSlot( pNewItem
);
593 if( _player
->IsInWorld() )
594 pNewItem
->SendUpdateToPlayer( _player
);
598 _player
->ItemRemovedQuestCheck( pItem
->GetEntry(), pItem
->GetCount());
599 _player
->RemoveItem( pItem
->GetBagSlot(), pItem
->GetSlot(), true);
600 pItem
->RemoveFromUpdateQueueOf(_player
);
601 _player
->AddItemToBuyBackSlot( pItem
);
604 _player
->ModifyMoney( pProto
->SellPrice
* count
);
607 _player
->SendSellError( SELL_ERR_CANT_SELL_ITEM
, pCreature
, itemguid
, 0);
611 _player
->SendSellError( SELL_ERR_CANT_FIND_ITEM
, pCreature
, itemguid
, 0);
615 void WorldSession::HandleBuybackItem(WorldPacket
& recv_data
)
617 CHECK_PACKET_SIZE(recv_data
,8+4);
619 sLog
.outDebug( "WORLD: Received CMSG_BUYBACK_ITEM" );
623 recv_data
>> vendorguid
>> slot
;
625 Creature
*pCreature
= GetPlayer()->GetNPCIfCanInteractWith(vendorguid
,UNIT_NPC_FLAG_VENDOR
);
628 sLog
.outDebug( "WORLD: HandleBuybackItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid
)) );
629 _player
->SendSellError( SELL_ERR_CANT_FIND_VENDOR
, NULL
, 0, 0);
634 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED
))
635 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH
);
637 Item
*pItem
= _player
->GetItemFromBuyBackSlot( slot
);
640 uint32 price
= _player
->GetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1
+ slot
- BUYBACK_SLOT_START
);
641 if( _player
->GetMoney() < price
)
643 _player
->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY
, pCreature
, pItem
->GetEntry(), 0);
647 ItemPosCountVec dest
;
648 uint8 msg
= _player
->CanStoreItem( NULL_BAG
, NULL_SLOT
, dest
, pItem
, false );
649 if( msg
== EQUIP_ERR_OK
)
651 _player
->ModifyMoney( -(int32
)price
);
652 _player
->RemoveItemFromBuyBackSlot( slot
, false );
653 _player
->ItemAddedQuestCheck( pItem
->GetEntry(), pItem
->GetCount());
654 _player
->StoreItem( dest
, pItem
, true );
657 _player
->SendEquipError( msg
, pItem
, NULL
);
661 _player
->SendBuyError( BUY_ERR_CANT_FIND_ITEM
, pCreature
, 0, 0);
664 void WorldSession::HandleBuyItemInSlotOpcode( WorldPacket
& recv_data
)
666 CHECK_PACKET_SIZE(recv_data
,8+4+4+8+1+4);
668 sLog
.outDebug( "WORLD: Received CMSG_BUY_ITEM_IN_SLOT" );
669 uint64 vendorguid
, bagguid
;
670 uint32 item
, slot
, count
;
673 recv_data
>> vendorguid
>> item
>> slot
>> bagguid
>> bagslot
>> count
;
675 GetPlayer()->BuyItemFromVendor(vendorguid
,item
,count
,bagguid
,slot
);
678 void WorldSession::HandleBuyItemOpcode( WorldPacket
& recv_data
)
680 CHECK_PACKET_SIZE(recv_data
,8+4+4+4+1);
682 sLog
.outDebug( "WORLD: Received CMSG_BUY_ITEM" );
684 uint32 item
, slot
, count
;
687 recv_data
>> vendorguid
>> item
>> slot
>> count
>> unk1
;
689 GetPlayer()->BuyItemFromVendor(vendorguid
,item
,count
,NULL_BAG
,NULL_SLOT
);
692 void WorldSession::HandleListInventoryOpcode( WorldPacket
& recv_data
)
694 CHECK_PACKET_SIZE(recv_data
,8);
700 if(!GetPlayer()->isAlive())
703 sLog
.outDebug( "WORLD: Recvd CMSG_LIST_INVENTORY" );
705 SendListInventory( guid
);
708 void WorldSession::SendListInventory( uint64 vendorguid
)
710 sLog
.outDebug( "WORLD: Sent SMSG_LIST_INVENTORY" );
712 Creature
*pCreature
= GetPlayer()->GetNPCIfCanInteractWith(vendorguid
,UNIT_NPC_FLAG_VENDOR
);
715 sLog
.outDebug( "WORLD: SendListInventory - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid
)) );
716 _player
->SendSellError( SELL_ERR_CANT_FIND_VENDOR
, NULL
, 0, 0);
721 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED
))
722 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH
);
724 // Stop the npc if moving
725 pCreature
->StopMoving();
727 VendorItemData
const* vItems
= pCreature
->GetVendorItems();
730 _player
->SendSellError( SELL_ERR_CANT_FIND_VENDOR
, NULL
, 0, 0);
734 uint8 numitems
= vItems
->GetItemCount();
737 WorldPacket
data( SMSG_LIST_INVENTORY
, (8+1+numitems
*8*4) );
738 data
<< uint64(vendorguid
);
739 data
<< uint8(numitems
);
741 float discountMod
= _player
->GetReputationPriceDiscount(pCreature
);
743 for(int i
= 0; i
< numitems
; ++i
)
745 if(VendorItem
const* crItem
= vItems
->GetItem(i
))
747 if(ItemPrototype
const *pProto
= objmgr
.GetItemPrototype(crItem
->item
))
749 if((pProto
->AllowableClass
& _player
->getClassMask()) == 0 && pProto
->Bonding
== BIND_WHEN_PICKED_UP
&& !_player
->isGameMaster())
754 // reputation discount
755 uint32 price
= uint32(floor(pProto
->BuyPrice
* discountMod
));
757 data
<< uint32(count
);
758 data
<< uint32(crItem
->item
);
759 data
<< uint32(pProto
->DisplayInfoID
);
760 data
<< uint32(crItem
->maxcount
<= 0 ? 0xFFFFFFFF : pCreature
->GetVendorItemCurrentCount(crItem
));
761 data
<< uint32(price
);
762 data
<< uint32(pProto
->MaxDurability
);
763 data
<< uint32(pProto
->BuyCount
);
764 data
<< uint32(crItem
->ExtendedCost
);
769 if ( count
== 0 || data
.size() != 8 + 1 + size_t(count
) * 8 * 4 )
772 data
.put
<uint8
>(8, count
);
776 void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket
& recv_data
)
778 CHECK_PACKET_SIZE(recv_data
,1+1+1);
780 //sLog.outDebug("WORLD: CMSG_AUTOSTORE_BAG_ITEM");
781 uint8 srcbag
, srcslot
, dstbag
;
783 recv_data
>> srcbag
>> srcslot
>> dstbag
;
784 //sLog.outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u", srcbag, srcslot, dstbag);
786 Item
*pItem
= _player
->GetItemByPos( srcbag
, srcslot
);
790 if(!_player
->IsValidPos(dstbag
,NULL_SLOT
))
792 _player
->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT
, NULL
, NULL
);
796 uint16 src
= pItem
->GetPos();
798 // check unequip potability for equipped items and bank bags
799 if(_player
->IsEquipmentPos ( src
) || _player
->IsBagPos ( src
))
801 uint8 msg
= _player
->CanUnequipItem( src
, !_player
->IsBagPos ( src
));
802 if(msg
!= EQUIP_ERR_OK
)
804 _player
->SendEquipError( msg
, pItem
, NULL
);
809 ItemPosCountVec dest
;
810 uint8 msg
= _player
->CanStoreItem( dstbag
, NULL_SLOT
, dest
, pItem
, false );
811 if( msg
!= EQUIP_ERR_OK
)
813 _player
->SendEquipError( msg
, pItem
, NULL
);
817 // no-op: placed in same slot
818 if(dest
.size()==1 && dest
[0].pos
==src
)
820 // just remove grey item state
821 _player
->SendEquipError( EQUIP_ERR_NONE
, pItem
, NULL
);
825 _player
->RemoveItem(srcbag
, srcslot
, true );
826 _player
->StoreItem( dest
, pItem
, true );
829 void WorldSession::HandleBuyBankSlotOpcode(WorldPacket
& recvPacket
)
831 CHECK_PACKET_SIZE(recvPacket
, 8);
833 sLog
.outDebug("WORLD: CMSG_BUY_BANK_SLOT");
838 // cheating protection
839 Creature
*pCreature
= GetPlayer()->GetNPCIfCanInteractWith(guid
, UNIT_NPC_FLAG_BANKER
);
842 sLog
.outDebug( "WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid
)) );
846 uint32 slot
= _player
->GetByteValue(PLAYER_BYTES_2
, 2);
851 sLog
.outDetail("PLAYER: Buy bank bag slot, slot number = %u", slot
);
853 BankBagSlotPricesEntry
const* slotEntry
= sBankBagSlotPricesStore
.LookupEntry(slot
);
858 uint32 price
= slotEntry
->price
;
860 if (_player
->GetMoney() < price
)
863 _player
->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT
, slot
);
864 _player
->SetByteValue(PLAYER_BYTES_2
, 2, slot
);
865 _player
->ModifyMoney(-int32(price
));
868 void WorldSession::HandleAutoBankItemOpcode(WorldPacket
& recvPacket
)
870 CHECK_PACKET_SIZE(recvPacket
,1+1);
872 sLog
.outDebug("WORLD: CMSG_AUTOBANK_ITEM");
873 uint8 srcbag
, srcslot
;
875 recvPacket
>> srcbag
>> srcslot
;
876 sLog
.outDebug("STORAGE: receive srcbag = %u, srcslot = %u", srcbag
, srcslot
);
878 Item
*pItem
= _player
->GetItemByPos( srcbag
, srcslot
);
882 ItemPosCountVec dest
;
883 uint8 msg
= _player
->CanBankItem( NULL_BAG
, NULL_SLOT
, dest
, pItem
, false );
884 if( msg
!= EQUIP_ERR_OK
)
886 _player
->SendEquipError( msg
, pItem
, NULL
);
890 _player
->RemoveItem(srcbag
, srcslot
, true);
891 _player
->BankItem( dest
, pItem
, true );
894 void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket
& recvPacket
)
896 CHECK_PACKET_SIZE(recvPacket
,1+1);
898 sLog
.outDebug("WORLD: CMSG_AUTOSTORE_BANK_ITEM");
899 uint8 srcbag
, srcslot
;
901 recvPacket
>> srcbag
>> srcslot
;
902 sLog
.outDebug("STORAGE: receive srcbag = %u, srcslot = %u", srcbag
, srcslot
);
904 Item
*pItem
= _player
->GetItemByPos( srcbag
, srcslot
);
908 if(_player
->IsBankPos(srcbag
, srcslot
)) // moving from bank to inventory
910 ItemPosCountVec dest
;
911 uint8 msg
= _player
->CanStoreItem( NULL_BAG
, NULL_SLOT
, dest
, pItem
, false );
912 if( msg
!= EQUIP_ERR_OK
)
914 _player
->SendEquipError( msg
, pItem
, NULL
);
918 _player
->RemoveItem(srcbag
, srcslot
, true);
919 _player
->StoreItem( dest
, pItem
, true );
921 else // moving from inventory to bank
923 ItemPosCountVec dest
;
924 uint8 msg
= _player
->CanBankItem( NULL_BAG
, NULL_SLOT
, dest
, pItem
, false );
925 if( msg
!= EQUIP_ERR_OK
)
927 _player
->SendEquipError( msg
, pItem
, NULL
);
931 _player
->RemoveItem(srcbag
, srcslot
, true);
932 _player
->BankItem( dest
, pItem
, true );
936 void WorldSession::HandleSetAmmoOpcode(WorldPacket
& recv_data
)
938 CHECK_PACKET_SIZE(recv_data
,4);
940 if(!GetPlayer()->isAlive())
942 GetPlayer()->SendEquipError( EQUIP_ERR_YOU_ARE_DEAD
, NULL
, NULL
);
946 sLog
.outDebug("WORLD: CMSG_SET_AMMO");
952 GetPlayer()->RemoveAmmo();
954 GetPlayer()->SetAmmo(item
);
957 void WorldSession::SendEnchantmentLog(uint64 Target
, uint64 Caster
,uint32 ItemID
,uint32 SpellID
)
959 WorldPacket
data(SMSG_ENCHANTMENTLOG
, (8+8+4+4+1)); // last check 2.0.10
968 void WorldSession::SendItemEnchantTimeUpdate(uint64 Playerguid
, uint64 Itemguid
,uint32 slot
,uint32 Duration
)
971 WorldPacket
data(SMSG_ITEM_ENCHANT_TIME_UPDATE
, (8+4+4+8));
972 data
<< uint64(Itemguid
);
973 data
<< uint32(slot
);
974 data
<< uint32(Duration
);
975 data
<< uint64(Playerguid
);
979 void WorldSession::HandleItemNameQueryOpcode(WorldPacket
& recv_data
)
981 CHECK_PACKET_SIZE(recv_data
,4);
985 sLog
.outDebug("WORLD: CMSG_ITEM_NAME_QUERY %u", itemid
);
986 ItemPrototype
const *pProto
= objmgr
.GetItemPrototype( itemid
);
990 Name
= pProto
->Name1
;
992 int loc_idx
= GetSessionDbLocaleIndex();
995 ItemLocale
const *il
= objmgr
.GetItemLocale(pProto
->ItemId
);
998 if (il
->Name
.size() > size_t(loc_idx
) && !il
->Name
[loc_idx
].empty())
999 Name
= il
->Name
[loc_idx
];
1003 WorldPacket
data(SMSG_ITEM_NAME_QUERY_RESPONSE
, (4+10));
1004 data
<< uint32(pProto
->ItemId
);
1006 data
<< uint32(pProto
->InventoryType
);
1011 sLog
.outDebug("WORLD: CMSG_ITEM_NAME_QUERY for item %u failed (unknown item)", itemid
);
1014 void WorldSession::HandleWrapItemOpcode(WorldPacket
& recv_data
)
1016 CHECK_PACKET_SIZE(recv_data
,1+1+1+1);
1018 sLog
.outDebug("Received opcode CMSG_WRAP_ITEM");
1020 uint8 gift_bag
, gift_slot
, item_bag
, item_slot
;
1021 //recv_data.hexlike();
1023 recv_data
>> gift_bag
>> gift_slot
; // paper
1024 recv_data
>> item_bag
>> item_slot
; // item
1026 sLog
.outDebug("WRAP: receive gift_bag = %u, gift_slot = %u, item_bag = %u, item_slot = %u", gift_bag
, gift_slot
, item_bag
, item_slot
);
1028 Item
*gift
= _player
->GetItemByPos( gift_bag
, gift_slot
);
1031 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, gift
, NULL
);
1035 if(!gift
->HasFlag(ITEM_FIELD_FLAGS
, ITEM_FLAGS_WRAPPER
))// cheating: non-wrapper wrapper
1037 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, gift
, NULL
);
1041 Item
*item
= _player
->GetItemByPos( item_bag
, item_slot
);
1045 _player
->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND
, item
, NULL
);
1049 if(item
==gift
) // not possable with pacjket from real client
1051 _player
->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED
, item
, NULL
);
1055 if(item
->IsEquipped())
1057 _player
->SendEquipError( EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED
, item
, NULL
);
1061 if(item
->GetUInt64Value(ITEM_FIELD_GIFTCREATOR
)) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED);
1063 _player
->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED
, item
, NULL
);
1069 _player
->SendEquipError( EQUIP_ERR_BAGS_CANT_BE_WRAPPED
, item
, NULL
);
1073 if(item
->IsSoulBound())
1075 _player
->SendEquipError( EQUIP_ERR_BOUND_CANT_BE_WRAPPED
, item
, NULL
);
1079 if(item
->GetMaxStackCount() != 1)
1081 _player
->SendEquipError( EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED
, item
, NULL
);
1085 // maybe not correct check (it is better than nothing)
1086 if(item
->GetProto()->MaxCount
>0)
1088 _player
->SendEquipError( EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED
, item
, NULL
);
1092 CharacterDatabase
.BeginTransaction();
1093 CharacterDatabase
.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item
->GetOwnerGUID()), item
->GetGUIDLow(), item
->GetEntry(), item
->GetUInt32Value(ITEM_FIELD_FLAGS
));
1094 item
->SetEntry(gift
->GetEntry());
1096 switch (item
->GetEntry())
1098 case 5042: item
->SetEntry( 5043); break;
1099 case 5048: item
->SetEntry( 5044); break;
1100 case 17303: item
->SetEntry(17302); break;
1101 case 17304: item
->SetEntry(17305); break;
1102 case 17307: item
->SetEntry(17308); break;
1103 case 21830: item
->SetEntry(21831); break;
1105 item
->SetUInt64Value(ITEM_FIELD_GIFTCREATOR
, _player
->GetGUID());
1106 item
->SetUInt32Value(ITEM_FIELD_FLAGS
, ITEM_FLAGS_WRAPPED
);
1107 item
->SetState(ITEM_CHANGED
, _player
);
1109 if(item
->GetState()==ITEM_NEW
) // save new item, to have alway for `character_gifts` record in `item_instance`
1111 // after save it will be impossible to remove the item from the queue
1112 item
->RemoveFromUpdateQueueOf(_player
);
1113 item
->SaveToDB(); // item gave inventory record unchanged and can be save standalone
1115 CharacterDatabase
.CommitTransaction();
1118 _player
->DestroyItemCount(gift
, count
, true);
1121 void WorldSession::HandleSocketOpcode(WorldPacket
& recv_data
)
1123 sLog
.outDebug("WORLD: CMSG_SOCKET_GEMS");
1125 CHECK_PACKET_SIZE(recv_data
,8+8*MAX_GEM_SOCKETS
);
1128 uint64 gem_guids
[MAX_GEM_SOCKETS
];
1130 recv_data
>> item_guid
;
1134 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
)
1135 recv_data
>> gem_guids
[i
];
1137 //cheat -> tried to socket same gem multiple times
1138 if ((gem_guids
[0] && (gem_guids
[0] == gem_guids
[1] || gem_guids
[0] == gem_guids
[2])) ||
1139 (gem_guids
[1] && (gem_guids
[1] == gem_guids
[2])))
1142 Item
*itemTarget
= _player
->GetItemByGuid(item_guid
);
1143 if(!itemTarget
) //missing item to socket
1146 ItemPrototype
const* itemProto
= itemTarget
->GetProto();
1150 //this slot is excepted when applying / removing meta gem bonus
1151 uint8 slot
= itemTarget
->IsEquipped() ? itemTarget
->GetSlot() : uint8(NULL_SLOT
);
1153 Item
*Gems
[MAX_GEM_SOCKETS
];
1154 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
)
1155 Gems
[i
] = gem_guids
[i
] ? _player
->GetItemByGuid(gem_guids
[i
]) : NULL
;
1157 GemPropertiesEntry
const *GemProps
[MAX_GEM_SOCKETS
];
1158 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
) //get geminfo from dbc storage
1159 GemProps
[i
] = (Gems
[i
]) ? sGemPropertiesStore
.LookupEntry(Gems
[i
]->GetProto()->GemProperties
) : NULL
;
1161 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
) //check for hack maybe
1166 // tried to put gem in socket where no socket exists (take care about prismatic sockets)
1167 if (!itemProto
->Socket
[i
].Color
)
1169 // no prismatic socket
1170 if(!itemTarget
->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT
))
1173 // not first not-colored (not normaly used) socket
1174 if(i
!=0 && !itemProto
->Socket
[i
-1].Color
&& (i
+1 >= MAX_GEM_SOCKETS
|| itemProto
->Socket
[i
+1].Color
))
1177 // ok, this is first not colored socket for item with prismatic socket
1180 // tried to put normal gem in meta socket
1181 if (itemProto
->Socket
[i
].Color
== SOCKET_COLOR_META
&& GemProps
[i
]->color
!= SOCKET_COLOR_META
)
1184 // tried to put meta gem in normal socket
1185 if (itemProto
->Socket
[i
].Color
!= SOCKET_COLOR_META
&& GemProps
[i
]->color
== SOCKET_COLOR_META
)
1189 uint32 GemEnchants
[MAX_GEM_SOCKETS
];
1190 uint32 OldEnchants
[MAX_GEM_SOCKETS
];
1191 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
) //get new and old enchantments
1193 GemEnchants
[i
] = (GemProps
[i
]) ? GemProps
[i
]->spellitemenchantement
: 0;
1194 OldEnchants
[i
] = itemTarget
->GetEnchantmentId(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT
+i
));
1197 // check unique-equipped conditions
1198 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
)
1203 // continue check for case when attempt add 2 similar unique equipped gems in one item.
1204 ItemPrototype
const* iGemProto
= Gems
[i
]->GetProto();
1206 // unique item (for new and already placed bit removed enchantments
1207 if (iGemProto
->Flags
& ITEM_FLAGS_UNIQUE_EQUIPPED
)
1209 for (int j
= 0; j
< MAX_GEM_SOCKETS
; ++j
)
1211 if(i
==j
) // skip self
1216 if (iGemProto
->ItemId
== Gems
[j
]->GetEntry())
1218 _player
->SendEquipError( EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED
, itemTarget
, NULL
);
1222 else if(OldEnchants
[j
])
1224 if(SpellItemEnchantmentEntry
const* enchantEntry
= sSpellItemEnchantmentStore
.LookupEntry(OldEnchants
[j
]))
1226 if (iGemProto
->ItemId
== enchantEntry
->GemID
)
1228 _player
->SendEquipError( EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED
, itemTarget
, NULL
);
1237 // unique limit type item
1238 int32 limit_newcount
= 0;
1239 if (iGemProto
->ItemLimitCategory
)
1241 if(ItemLimitCategoryEntry
const* limitEntry
= sItemLimitCategoryStore
.LookupEntry(iGemProto
->ItemLimitCategory
))
1243 for (int j
= 0; j
< MAX_GEM_SOCKETS
; ++j
)
1250 if(SpellItemEnchantmentEntry
const* enchantEntry
= sSpellItemEnchantmentStore
.LookupEntry(OldEnchants
[j
]))
1251 if(ItemPrototype
const* jProto
= ObjectMgr::GetItemPrototype(enchantEntry
->GemID
))
1252 if (iGemProto
->ItemLimitCategory
== jProto
->ItemLimitCategory
)
1257 if (iGemProto
->ItemLimitCategory
== Gems
[j
]->GetProto()->ItemLimitCategory
)
1261 else if(OldEnchants
[j
])
1263 if(SpellItemEnchantmentEntry
const* enchantEntry
= sSpellItemEnchantmentStore
.LookupEntry(OldEnchants
[j
]))
1264 if(ItemPrototype
const* jProto
= ObjectMgr::GetItemPrototype(enchantEntry
->GemID
))
1265 if (iGemProto
->ItemLimitCategory
== jProto
->ItemLimitCategory
)
1270 if(limit_newcount
> 0 && uint32(limit_newcount
) > limitEntry
->maxCount
)
1272 _player
->SendEquipError( EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED
, itemTarget
, NULL
);
1278 // for equipped item check all equipment for duplicate equipped gems
1279 if(itemTarget
->IsEquipped())
1281 if(uint8 res
= _player
->CanEquipUniqueItem(Gems
[i
],slot
,limit_newcount
>= 0 ? limit_newcount
: 0))
1283 _player
->SendEquipError( res
, itemTarget
, NULL
);
1289 bool SocketBonusActivated
= itemTarget
->GemsFitSockets(); //save state of socketbonus
1290 _player
->ToggleMetaGemsActive(slot
, false); //turn off all metagems (except for the target item)
1292 //if a meta gem is being equipped, all information has to be written to the item before testing if the conditions for the gem are met
1294 //remove ALL enchants
1295 for(uint32 enchant_slot
= SOCK_ENCHANTMENT_SLOT
; enchant_slot
< SOCK_ENCHANTMENT_SLOT
+MAX_GEM_SOCKETS
; ++enchant_slot
)
1296 _player
->ApplyEnchantment(itemTarget
,EnchantmentSlot(enchant_slot
),false);
1298 for(int i
= 0; i
< MAX_GEM_SOCKETS
; ++i
)
1302 itemTarget
->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT
+i
), GemEnchants
[i
],0,0);
1303 if(Item
* guidItem
= _player
->GetItemByGuid(gem_guids
[i
]))
1304 _player
->DestroyItem(guidItem
->GetBagSlot(), guidItem
->GetSlot(), true );
1308 for(uint32 enchant_slot
= SOCK_ENCHANTMENT_SLOT
; enchant_slot
< SOCK_ENCHANTMENT_SLOT
+MAX_GEM_SOCKETS
; ++enchant_slot
)
1309 _player
->ApplyEnchantment(itemTarget
,EnchantmentSlot(enchant_slot
),true);
1311 bool SocketBonusToBeActivated
= itemTarget
->GemsFitSockets();//current socketbonus state
1312 if(SocketBonusActivated
^ SocketBonusToBeActivated
) //if there was a change...
1314 _player
->ApplyEnchantment(itemTarget
,BONUS_ENCHANTMENT_SLOT
,false);
1315 itemTarget
->SetEnchantment(BONUS_ENCHANTMENT_SLOT
, (SocketBonusToBeActivated
? itemTarget
->GetProto()->socketBonus
: 0), 0, 0);
1316 _player
->ApplyEnchantment(itemTarget
,BONUS_ENCHANTMENT_SLOT
,true);
1317 //it is not displayed, client has an inbuilt system to determine if the bonus is activated
1320 _player
->ToggleMetaGemsActive(slot
, true); //turn on all metagems (except for target item)
1323 void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket
& recv_data
)
1325 sLog
.outDebug("WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT");
1327 CHECK_PACKET_SIZE(recv_data
,4);
1333 // apply only to equipped item
1334 if(!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0
,eslot
))
1337 Item
* item
= GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0
, eslot
);
1342 if(!item
->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT
))
1345 GetPlayer()->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,false);
1346 item
->ClearEnchantment(TEMP_ENCHANTMENT_SLOT
);