Core/ObjectMgr: Refactor sItemStorage

This commit is contained in:
leak
2011-04-28 22:42:33 +02:00
parent 03365e9a57
commit a82654debd
49 changed files with 785 additions and 639 deletions
@@ -182,7 +182,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
return;
}
if (it->GetProto()->Flags & ITEM_PROTO_FLAG_CONJURED || it->GetUInt32Value(ITEM_FIELD_DURATION))
if (it->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
@@ -207,7 +207,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),count);
GetPlayerName(),GetAccountId(),it->GetTemplate()->Name1,it->GetEntry(),count);
}
pl->ModifyMoney(-int32(deposit));
@@ -261,7 +261,7 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket & recv_data)
return;
}
if (pItem->GetProto()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
if (pItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
{
_player->SendEquipError(EQUIP_ERR_CANT_DROP_SOULBOUND, NULL, NULL);
return;
@@ -285,7 +285,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data)
sLog->outDetail("STORAGE: Item Query = %u", item);
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item);
ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item);
if (pProto)
{
std::string Name = pProto->Name1;
@@ -446,7 +446,7 @@ void WorldSession::HandleReadItem(WorldPacket & recv_data)
//sLog->outDetail("STORAGE: Read bag = %u, slot = %u", bag, slot);
Item *pItem = _player->GetItemByPos(bag, slot);
if (pItem && pItem->GetProto()->PageText)
if (pItem && pItem->GetTemplate()->PageText)
{
WorldPacket data;
@@ -550,7 +550,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data)
}
}
ItemPrototype const *pProto = pItem->GetProto();
ItemTemplate const *pProto = pItem->GetTemplate();
if (pProto)
{
if (pProto->SellPrice > 0)
@@ -764,7 +764,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
{
if (VendorItem const* crItem = vItems->GetItem(vendorslot))
{
if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(crItem->item))
if (ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(crItem->item))
{
if ((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster())
continue;
@@ -1058,7 +1058,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
return;
}
if (!(gift->GetProto()->Flags & ITEM_PROTO_FLAG_WRAPPER)) // cheating: non-wrapper wrapper
if (!(gift->GetTemplate()->Flags & ITEM_PROTO_FLAG_WRAPPER)) // cheating: non-wrapper wrapper
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
return;
@@ -1109,7 +1109,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
}
// maybe not correct check (it is better than nothing)
if (item->GetProto()->MaxCount>0)
if (item->GetTemplate()->MaxCount>0)
{
_player->SendEquipError(EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED, item, NULL);
return;
@@ -1167,7 +1167,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
if (!itemTarget) //missing item to socket
return;
ItemPrototype const* itemProto = itemTarget->GetProto();
ItemTemplate const* itemProto = itemTarget->GetTemplate();
if (!itemProto)
return;
@@ -1180,7 +1180,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
GemPropertiesEntry const *GemProps[MAX_GEM_SOCKETS];
for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //get geminfo from dbc storage
GemProps[i] = (Gems[i]) ? sGemPropertiesStore.LookupEntry(Gems[i]->GetProto()->GemProperties) : NULL;
GemProps[i] = (Gems[i]) ? sGemPropertiesStore.LookupEntry(Gems[i]->GetTemplate()->GemProperties) : NULL;
for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //check for hack maybe
{
@@ -1225,7 +1225,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
continue;
// continue check for case when attempt add 2 similar unique equipped gems in one item.
ItemPrototype const* iGemProto = Gems[i]->GetProto();
ItemTemplate const* iGemProto = Gems[i]->GetTemplate();
// unique item (for new and already placed bit removed enchantments
if (iGemProto->Flags & ITEM_PROTO_FLAG_UNIQUE_EQUIPPED)
@@ -1270,14 +1270,14 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
if (Gems[j])
{
// new gem
if (iGemProto->ItemLimitCategory == Gems[j]->GetProto()->ItemLimitCategory)
if (iGemProto->ItemLimitCategory == Gems[j]->GetTemplate()->ItemLimitCategory)
++limit_newcount;
}
else if (OldEnchants[j])
{
// existing gem
if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(OldEnchants[j]))
if (ItemPrototype const* jProto = ObjectMgr::GetItemPrototype(enchantEntry->GemID))
if (ItemTemplate const* jProto = sObjectMgr->GetItemTemplate(enchantEntry->GemID))
if (iGemProto->ItemLimitCategory == jProto->ItemLimitCategory)
++limit_newcount;
}
@@ -1328,7 +1328,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
if (SocketBonusActivated ^ SocketBonusToBeActivated) //if there was a change...
{
_player->ApplyEnchantment(itemTarget,BONUS_ENCHANTMENT_SLOT,false);
itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetProto()->socketBonus : 0), 0, 0);
itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->socketBonus : 0), 0, 0);
_player->ApplyEnchantment(itemTarget,BONUS_ENCHANTMENT_SLOT,true);
//it is not displayed, client has an inbuilt system to determine if the bonus is activated
}
@@ -201,13 +201,13 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data
data << uint8(qRew->GetRewItemsCount());
if (qRew->GetRewItemsCount())
{
ItemPrototype const* iProto = NULL;
ItemTemplate const* iProto = NULL;
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
if (!qRew->RewItemId[i])
continue;
iProto = ObjectMgr::GetItemPrototype(qRew->RewItemId[i]);
iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]);
data << uint32(qRew->RewItemId[i]);
data << uint32(iProto ? iProto->DisplayInfoID : 0);
@@ -491,13 +491,13 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr
data << uint8(itemNum);
if (itemNum)
{
ItemPrototype const* iProto = NULL;
ItemTemplate const* iProto = NULL;
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
if (!qRew->RewItemId[i])
continue;
iProto = ObjectMgr::GetItemPrototype(qRew->RewItemId[i]);
iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]);
data << uint32(qRew->RewItemId[i]);
data << uint32(iProto ? iProto->DisplayInfoID : 0);
@@ -344,7 +344,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
if (!pItem)
return;
ItemPrototype const* proto = pItem->GetProto();
ItemTemplate const* proto = pItem->GetTemplate();
// destroy only 5 items from stack in case prospecting and milling
if (proto->Flags & (ITEM_PROTO_FLAG_PROSPECTABLE | ITEM_PROTO_FLAG_MILLABLE))
@@ -151,7 +151,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
Item* item = pl->GetItemByGuid(itemGUIDs[i]);
if (item)
{
ItemPrototype const* itemProto = item->GetProto();
ItemTemplate const* itemProto = item->GetTemplate();
if(!itemProto || !(itemProto->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT))
{
accountBound = false;
@@ -207,7 +207,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
return;
}
if (item->GetProto()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
@@ -249,7 +249,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
GetPlayerName(), GetAccountId(), item->GetTemplate()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
}
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
@@ -460,7 +460,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data)
sender_name = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
}
sLog->outCommand(GetAccountId(),"GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId);
GetPlayerName(),GetAccountId(),it->GetTemplate()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId);
}
else if (!receive)
sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid);
@@ -772,4 +772,4 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/)
data << uint32(0x00000000);
}
SendPacket(&data);
}
}
@@ -179,7 +179,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
}
}
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(charterid);
ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(charterid);
if (!pProto)
{
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0);
@@ -202,7 +202,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
bool destroyItem = true;
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetProto()->MaxCount > 0))
if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetTemplate()->MaxCount > 0))
{
destroyItem = false;
break;
@@ -95,7 +95,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
sLog->outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, castCount: %u, spellId: %u, Item: %u, glyphIndex: %u, data length = %i", bagIndex, slot, castCount, spellId, pItem->GetEntry(), glyphIndex, (uint32)recvPacket.size());
ItemPrototype const *proto = pItem->GetProto();
ItemTemplate const *proto = pItem->GetTemplate();
if (!proto)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
@@ -146,7 +146,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
}
// check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory)
if (pItem->GetProto()->Bonding == BIND_WHEN_USE || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM)
if (pItem->GetTemplate()->Bonding == BIND_WHEN_USE || pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM)
{
if (!pItem->IsSoulBound())
{
@@ -214,7 +214,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
return;
}
ItemPrototype const *proto = pItem->GetProto();
ItemTemplate const *proto = pItem->GetTemplate();
if (!proto)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
@@ -618,7 +618,7 @@ void WorldSession::HandleMirrrorImageDataRequest(WorldPacket & recv_data)
else if (*itr == EQUIPMENT_SLOT_BACK && pCreator->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK))
data << uint32(0);
else if (Item const *item = pCreator->GetItemByPos(INVENTORY_SLOT_BAG_0, *itr))
data << uint32(item->GetProto()->DisplayInfoID);
data << uint32(item->GetTemplate()->DisplayInfoID);
else
data << uint32(0);
}
@@ -97,8 +97,8 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
if (Item* item = view_trade->GetItem(TradeSlots(i)))
{
data << uint32(item->GetProto()->ItemId); // entry
data << uint32(item->GetProto()->DisplayInfoID);// display id
data << uint32(item->GetTemplate()->ItemId); // entry
data << uint32(item->GetTemplate()->DisplayInfoID);// display id
data << uint32(item->GetCount()); // stack count
// wrapped: hide stats but show giftcreator name
data << uint32(item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED) ? 1 : 0);
@@ -112,7 +112,7 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
data << uint32(item->GetSpellCharges()); // charges
data << uint32(item->GetItemSuffixFactor()); // SuffixFactor
data << uint32(item->GetItemRandomPropertyId());// random properties id
data << uint32(item->GetProto()->LockID); // lock id
data << uint32(item->GetTemplate()->LockID); // lock id
// max durability
data << uint32(item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY));
// durability
@@ -155,7 +155,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
{
sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
_player->GetName(), _player->GetSession()->GetAccountId(),
myItems[i]->GetProto()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(),
myItems[i]->GetTemplate()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(),
trader->GetName(), trader->GetSession()->GetAccountId());
}
@@ -173,7 +173,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
{
sLog->outCommand(trader->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
trader->GetName(), trader->GetSession()->GetAccountId(),
hisItems[i]->GetProto()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(),
hisItems[i]->GetTemplate()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(),
_player->GetName(), _player->GetSession()->GetAccountId());
}