diff options
author | Subv <s.v.h21@hotmail.com> | 2012-08-03 20:47:09 -0500 |
---|---|---|
committer | Subv <s.v.h21@hotmail.com> | 2012-08-03 20:48:47 -0500 |
commit | 17e852d9b3c7a28a66934e7ec9d7ab00a770d06d (patch) | |
tree | 67bfb2ce377f0243b9cd270228df487b84841b74 /src/server/game/Handlers/ItemHandler.cpp | |
parent | 48db4b2b7da984258fede9cfa13ea8c0ea2dc788 (diff) |
Items/Reforge: Partially implemented reforge, still ToDo: Apply real stat modifiers to the player
Diffstat (limited to 'src/server/game/Handlers/ItemHandler.cpp')
-rwxr-xr-x | src/server/game/Handlers/ItemHandler.cpp | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index ce5729a7b40..4b349857c96 100755 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -1617,7 +1617,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) itemTransmogrifier->SetNotRefundable(player); itemTransmogrifier->ClearSoulboundTradeable(player); - cost += itemTransmogrified->GetTransmogrifyCost(); + cost += itemTransmogrified->GetSpecialPrice(); } } @@ -1631,3 +1631,83 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) delete[] newEntries; delete[] slots; } + +void WorldSession::SendReforgeResult(bool success) +{ + WorldPacket data(SMSG_REFORGE_RESULT, 1); + data.WriteBit(success); + SendPacket(&data); +} + +void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData) +{ + uint32 slot, reforgeEntry; + ObjectGuid guid; + uint32 bag; + Player* player = GetPlayer(); + + recvData >> reforgeEntry >> slot >> bag; + + guid[2] = recvData.ReadBit(); + guid[6] = recvData.ReadBit(); + guid[3] = recvData.ReadBit(); + guid[4] = recvData.ReadBit(); + guid[1] = recvData.ReadBit(); + guid[0] = recvData.ReadBit(); + guid[7] = recvData.ReadBit(); + guid[5] = recvData.ReadBit(); + + recvData.ReadByteSeq(guid[2]); + recvData.ReadByteSeq(guid[3]); + recvData.ReadByteSeq(guid[6]); + recvData.ReadByteSeq(guid[4]); + recvData.ReadByteSeq(guid[1]); + recvData.ReadByteSeq(guid[0]); + recvData.ReadByteSeq(guid[7]); + recvData.ReadByteSeq(guid[5]); + + if (!player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_REFORGER)) + { + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Unit (GUID: %u) not found or player can't interact with it.", GUID_LOPART(guid)); + SendReforgeResult(false); + return; + } + + Item* item = player->GetItemByPos(bag, slot); + + if (!item) + { + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an invalid/non-existant item.", player->GetGUIDLow(), player->GetName()); + SendReforgeResult(false); + return; + } + + if (!reforgeEntry) + { + // Reset the item + item->ClearEnchantment(REFORGE_ENCHANTMENT_SLOT); + SendReforgeResult(true); + return; + } + + if (!sItemReforgeStore.LookupEntry(reforgeEntry)) + { + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an item with invalid reforge entry (%u).", player->GetGUIDLow(), player->GetName(), reforgeEntry); + SendReforgeResult(false); + return; + } + + if (player->HasEnoughMoney(item->GetSpecialPrice())) // cheating + { + SendReforgeResult(false); + return; + } + + player->ModifyMoney(-int64(item->GetSpecialPrice())); + + item->SetEnchantment(REFORGE_ENCHANTMENT_SLOT, reforgeEntry, 0, 0); + + SendReforgeResult(true); + + // ToDo: Apply and remove the destination/source stats to the player +} |