Core/ObjectMgr: Refactor sItemStorage
This commit is contained in:
@@ -965,7 +965,7 @@ public:
|
||||
return false;
|
||||
|
||||
handler->GetSession()->GetPlayer()->DestroyItem(i->GetBagSlot(), i->GetSlot(), true);
|
||||
sScriptMgr->OnItemExpire(handler->GetSession()->GetPlayer(), i->GetProto());
|
||||
sScriptMgr->OnItemExpire(handler->GetSession()->GetPlayer(), i->GetTemplate());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -201,9 +201,9 @@ public:
|
||||
|
||||
sObjectMgr->AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost);
|
||||
|
||||
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId);
|
||||
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
|
||||
|
||||
handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost);
|
||||
handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,itemTemplate->Name1,maxcount,incrtime,extendedcost);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -419,9 +419,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId);
|
||||
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
|
||||
|
||||
handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1);
|
||||
handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,itemTemplate->Name1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1299,7 +1299,7 @@ public:
|
||||
uint32 ItemID = atoi(pItemID);
|
||||
uint32 SlotID = atoi(pSlotID);
|
||||
|
||||
ItemPrototype* tmpItem = ObjectMgr::GetItemPrototype(ItemID);
|
||||
ItemPrototype* tmpItem = sObjectMgr->GetItemTemplate(ItemID);
|
||||
|
||||
bool added = false;
|
||||
if (tmpItem)
|
||||
|
||||
@@ -76,18 +76,14 @@ public:
|
||||
}
|
||||
|
||||
// check item starting quest (it can work incorrectly if added without item in inventory)
|
||||
for (uint32 id = 0; id < sItemStorage.MaxEntry; id++)
|
||||
{
|
||||
ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id);
|
||||
if (!pProto)
|
||||
continue;
|
||||
ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore();
|
||||
ItemTemplateContainer::const_iterator result = find_if(itc->begin(), itc->end(), Finder<uint32, ItemTemplate>(entry, &ItemTemplate::StartQuest));
|
||||
|
||||
if (pProto->StartQuest == entry)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
if (result != itc->end())
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, result->second.ItemId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// ok, normal (creature/GO starting) quest
|
||||
|
||||
@@ -189,7 +189,7 @@ class item_mysterious_egg : public ItemScript
|
||||
{
|
||||
public:
|
||||
item_mysterious_egg() : ItemScript("item_mysterious_egg") { }
|
||||
bool OnExpire(Player *pPlayer, ItemPrototype const * /*pItemProto*/)
|
||||
bool OnExpire(Player *pPlayer, ItemTemplate const * /*pItemProto*/)
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 39883, 1); // Cracked Egg
|
||||
@@ -209,7 +209,7 @@ class item_disgusting_jar : public ItemScript
|
||||
public:
|
||||
item_disgusting_jar() : ItemScript("item_disgusting_jar") {}
|
||||
|
||||
bool OnExpire(Player *pPlayer, ItemPrototype const * /*pItemProto*/)
|
||||
bool OnExpire(Player *pPlayer, ItemTemplate const * /*pItemProto*/)
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 44718, 1); // Ripe Disgusting Jar
|
||||
|
||||
@@ -233,10 +233,10 @@ bool EquippedOk(Player* pPlayer, uint32 spellId)
|
||||
{
|
||||
pItem = pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, j);
|
||||
if (pItem)
|
||||
if (pItem->GetProto()->RequiredSpell == reqSpell)
|
||||
if (pItem->GetTemplate()->RequiredSpell == reqSpell)
|
||||
{
|
||||
//player has item equipped that require specialty. Not allow to unlearn, player has to unequip first
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetProto()->ItemId);
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetTemplate()->ItemId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user