diff options
-rw-r--r-- | sql/characters.sql | 16 | ||||
-rw-r--r-- | sql/updates/7611_characters_item_refund_instance.sql | 14 | ||||
-rw-r--r-- | src/game/Item.cpp | 11 | ||||
-rw-r--r-- | src/game/Item.h | 17 | ||||
-rw-r--r-- | src/game/ItemHandler.cpp | 43 | ||||
-rw-r--r-- | src/game/Player.cpp | 72 |
6 files changed, 76 insertions, 97 deletions
diff --git a/sql/characters.sql b/sql/characters.sql index 2ef0a8553d6..66c1f028204 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -1617,6 +1617,22 @@ LOCK TABLES `item_instance` WRITE; UNLOCK TABLES; -- +-- Table structure for table `item_refund_instance` +-- + +DROP TABLE IF EXISTS `item_refund_instance`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `item_refund_instance` ( + `item_guid` int(11) unsigned NOT NULL COMMENT 'Item GUID', + `player_guid` int(11) unsigned NOT NULL COMMENT 'Player GUID', + `paidMoney` int(11) unsigned NOT NULL DEFAULT '0', + `paidExtendedCost` int(11) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`item_guid`,`player_guid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Item Refund System'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- -- Table structure for table `item_text` -- diff --git a/sql/updates/7611_characters_item_refund_instance.sql b/sql/updates/7611_characters_item_refund_instance.sql new file mode 100644 index 00000000000..c75a180f731 --- /dev/null +++ b/sql/updates/7611_characters_item_refund_instance.sql @@ -0,0 +1,14 @@ +ALTER TABLE `item_refund_instance` +DROP COLUMN `paidHonor`, +DROP COLUMN `paidArena`, +DROP COLUMN `paidItem_1`, +DROP COLUMN `paidItemCount_1`, +DROP COLUMN `paidItem_2`, +DROP COLUMN `paidItemCount_2`, +DROP COLUMN `paidItem_3`, +DROP COLUMN `paidItemCount_3`, +DROP COLUMN `paidItem_4`, +DROP COLUMN `paidItemCount_4`, +DROP COLUMN `paidItem_5`, +DROP COLUMN `paidItemCount_5`, +ADD COLUMN `paidExtendedCost` int(11) unsigned NOT NULL DEFAULT '0';
\ No newline at end of file diff --git a/src/game/Item.cpp b/src/game/Item.cpp index eaf4ed776e7..217013e8e22 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -1059,16 +1059,7 @@ void Item::SaveRefundDataToDB() ss << GetGUIDLow() << ","; ss << RefundData->eligibleFor << ","; ss << RefundData->paidMoney << ","; - ss << RefundData->paidHonorPoints << ","; - ss << RefundData->paidArenaPoints << ","; - - for (uint8 i=0; i<5; ++i) - { - ss << RefundData->paidItemId[i] << ","; - ss << RefundData->paidItemCount[i]; - if (i < 4) - ss << ","; - } + ss << RefundData->paidExtendedCost; ss << ")"; CharacterDatabase.Execute(ss.str().c_str()); diff --git a/src/game/Item.h b/src/game/Item.h index 60d04559e79..cc6cfe2208d 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -220,23 +220,10 @@ bool ItemCanGoIntoBag(ItemPrototype const *proto, ItemPrototype const *pBagProto struct ItemRefund { - ItemRefund() - { - paidMoney = 0; - paidHonorPoints = 0; - paidArenaPoints = 0; - for (uint8 i=0;i<5;++i) - { - paidItemId[i] = 0; - paidItemCount[i] = 0; - } - } + ItemRefund() : paidMoney(0), paidExtendedCost(0) {} uint32 eligibleFor; uint32 paidMoney; - uint32 paidHonorPoints; - uint32 paidArenaPoints; - uint32 paidItemId[5]; - uint32 paidItemCount[5]; + uint32 paidExtendedCost; }; class Item : public Object diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 1afe43f43a9..5952f73062e 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -1382,18 +1382,24 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data) item->SetNotRefundable(GetPlayer()); return; } + + ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(RefundData->paidExtendedCost); + if (!iece) + { + sLog.outDebug("Item refund: cannot find extendedcost data."); + return; + } item->UpdatePlayedTime(GetPlayer()); - WorldPacket data(SMSG_ITEM_REFUND_INFO_RESPONSE, 8+4+4+4+4*4+4*4+4+4); data << uint64(guid); // item guid data << uint32(RefundData->paidMoney); // money cost - data << uint32(RefundData->paidHonorPoints); // honor point cost - data << uint32(RefundData->paidArenaPoints); // arena point cost + data << uint32(iece->reqhonorpoints); // honor point cost + data << uint32(iece->reqarenapoints); // arena point cost for (uint8 i = 0; i < 5; ++i) // item cost data { - data << RefundData->paidItemId[i]; - data << RefundData->paidItemCount[i]; + data << iece->reqitem[i]; + data << iece->reqitemcount[i]; } data << uint32(0); data << uint32(GetPlayer()->GetTotalPlayedTime() - item->GetPlayedTime()); @@ -1444,11 +1450,18 @@ void WorldSession::HandleItemRefund(WorldPacket &recv_data) return; } + ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(RefundData->paidExtendedCost); + if (!iece) + { + sLog.outDebug("Item refund: cannot find extendedcost data."); + return; + } + bool store_error = false; for (uint8 i = 0; i < 5; ++i) { - uint32 count = RefundData->paidItemCount[i]; - uint32 itemid = RefundData->paidItemId[i]; + uint32 count = iece->reqitemcount[i]; + uint32 itemid = iece->reqitem[i]; if (count && itemid) { @@ -1475,12 +1488,12 @@ void WorldSession::HandleItemRefund(WorldPacket &recv_data) data << uint64(guid); // item guid data << uint32(0); // 0, or error code data << uint32(RefundData->paidMoney); // money cost - data << uint32(RefundData->paidHonorPoints); // honor point cost - data << uint32(RefundData->paidArenaPoints); // arena point cost + data << uint32(iece->reqhonorpoints); // honor point cost + data << uint32(iece->reqarenapoints); // arena point cost for (uint8 i = 0; i < 5; ++i) // item cost data { - data << RefundData->paidItemId[i]; - data << RefundData->paidItemCount[i]; + data << iece->reqitem[i]; + data << iece->reqitemcount[i]; } SendPacket(&data); @@ -1493,8 +1506,8 @@ void WorldSession::HandleItemRefund(WorldPacket &recv_data) // Grant back extendedcost items for (uint8 i = 0; i < 5; ++i) { - uint32 count = RefundData->paidItemCount[i]; - uint32 itemid = RefundData->paidItemId[i]; + uint32 count = iece->reqitemcount[i]; + uint32 itemid = iece->reqitem[i]; if (count && itemid) { ItemPosCountVec dest; @@ -1511,12 +1524,12 @@ void WorldSession::HandleItemRefund(WorldPacket &recv_data) _player->ModifyMoney(moneyRefund); // Grant back Honor points - uint32 honorRefund = RefundData->paidHonorPoints; + uint32 honorRefund = iece->reqhonorpoints; if (honorRefund) _player->ModifyHonorPoints(honorRefund); // Grant back Arena points - uint32 arenaRefund = RefundData->paidArenaPoints; + uint32 arenaRefund = iece->reqarenapoints; if (arenaRefund) _player->ModifyArenaPoints(arenaRefund); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 25d57128664..bd486e29d0b 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16389,10 +16389,7 @@ void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff) else { QueryResult_AutoPtr result2 = CharacterDatabase.PQuery( - "SELECT player_guid,paidMoney,paidHonor,paidArena," - "paidItem_1,paidItemCount_1,paidItem_2,paidItemCount_2,paidItem_3,paidItemCount_3,paidItem_4,paidItemCount_4," - "paidItem_5,paidItemCount_5 FROM item_refund_instance WHERE item_guid = '%u' LIMIT 1", - item->GetGUIDLow()); + "SELECT player_guid,paidMoney,paidExtendedCost FROM `item_refund_instance` WHERE item_guid = '%u' LIMIT 1", item->GetGUIDLow()); if (!result2) { sLog.outDebug("Item::LoadFromDB, " @@ -16406,13 +16403,7 @@ void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff) ItemRefund* RefundData = new ItemRefund(); RefundData->eligibleFor = fields[0].GetUInt32(); RefundData->paidMoney = fields[1].GetUInt32(); - RefundData->paidHonorPoints = fields[2].GetUInt32(); - RefundData->paidArenaPoints = fields[3].GetUInt32(); - for (uint8 i=0, j=4; i<5; ++i, j+=2) - { - RefundData->paidItemId[i] = fields[j].GetUInt32(); - RefundData->paidItemCount[i] = fields[j+1].GetUInt32(); - } + RefundData->paidExtendedCost = fields[2].GetUInt32(); item->SetRefundData(RefundData); AddRefundReference(item); } @@ -19322,11 +19313,6 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint return false; } - uint32 honorPoints = 0; - uint32 arenaPoints = 0; - uint32 itemCostId[5] = {0,0,0,0,0}; - uint32 itemCostCount[5] = {0,0,0,0,0}; - if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot)) { ItemPosCountVec dest; @@ -19343,23 +19329,15 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint { ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); if (iece->reqhonorpoints) - { - honorPoints = iece->reqhonorpoints; - ModifyHonorPoints( - int32(honorPoints) ); - } + ModifyHonorPoints( - int32(iece->reqhonorpoints * count) ); + if (iece->reqarenapoints) - { - arenaPoints = iece->reqarenapoints; - ModifyArenaPoints( - int32(arenaPoints) ); - } + ModifyArenaPoints( - int32(iece->reqarenapoints * count) ); + for (uint8 i = 0; i < 5; ++i) { if (iece->reqitem[i]) - { DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true); - itemCostId[i] = iece->reqitem[i]; - itemCostCount[i] = iece->reqitemcount[i]; - } } } @@ -19375,18 +19353,12 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint GetSession()->SendPacket(&data); SendNewItem(it, pProto->BuyCount*count, true, false, false); - if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE)) + if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost) { ItemRefund* RefundData = new ItemRefund(); RefundData->eligibleFor = GetGUIDLow(); RefundData->paidMoney = price; - RefundData->paidHonorPoints = honorPoints; - RefundData->paidArenaPoints = arenaPoints; - for (uint8 i=0; i<5; ++i) - { - RefundData->paidItemId[i] = itemCostId[i]; - RefundData->paidItemCount[i] = itemCostCount[i] ; - } + RefundData->paidExtendedCost = crItem->ExtendedCost; it->SetRefundData(RefundData); it->SaveRefundDataToDB(); AddRefundReference(it); @@ -19414,23 +19386,15 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint { ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); if (iece->reqhonorpoints) - { - honorPoints = iece->reqhonorpoints; - ModifyHonorPoints( - int32(honorPoints) ); - } + ModifyHonorPoints( - int32(iece->reqhonorpoints * count) ); + if (iece->reqarenapoints) - { - arenaPoints = iece->reqarenapoints; - ModifyArenaPoints( - int32(arenaPoints)); - } + ModifyArenaPoints( - int32(iece->reqarenapoints * count) ); + for (uint8 i = 0; i < 5; ++i) { if(iece->reqitem[i]) - { - DestroyItemCount(iece->reqitem[i], iece->reqitemcount[i], true); - itemCostId[i] = iece->reqitem[i]; - itemCostCount[i] = iece->reqitemcount[i]; - } + DestroyItemCount(iece->reqitem[i], iece->reqitemcount[i] * count, true); } } @@ -19449,18 +19413,12 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint AutoUnequipOffhandIfNeed(); - if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE)) + if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost) { ItemRefund* RefundData = new ItemRefund(); RefundData->eligibleFor = GetGUIDLow(); RefundData->paidMoney = price; - RefundData->paidHonorPoints = honorPoints; - RefundData->paidArenaPoints = arenaPoints; - for (uint8 i=0; i<5; ++i) - { - RefundData->paidItemId[i] = itemCostId[i]; - RefundData->paidItemCount[i] = itemCostCount[i] ; - } + RefundData->paidExtendedCost = crItem->ExtendedCost; it->SetRefundData(RefundData); it->SaveRefundDataToDB(); AddRefundReference(it); |