mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-22 02:12:26 +00:00
Refactoring
This commit is contained in:
parent
2d617f0ea7
commit
a90e9cf4c6
@ -33,36 +33,62 @@ EQEmu::Inventory::~Inventory() {
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::Inventory::Get(int container_id, int slot_id) {
|
||||
auto iter = impl_->containers_.find(container_id);
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::Inventory::Get(const InventorySlot &slot) {
|
||||
auto iter = impl_->containers_.find(slot.type_);
|
||||
if(iter != impl_->containers_.end()) {
|
||||
return iter->second.Get(slot_id);
|
||||
}
|
||||
|
||||
return std::shared_ptr<ItemInstance>(nullptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::Inventory::Get(int container_id, int slot_id, int bag_idx) {
|
||||
auto iter = impl_->containers_.find(container_id);
|
||||
if(iter != impl_->containers_.end()) {
|
||||
auto item = iter->second.Get(slot_id);
|
||||
auto item = iter->second.Get(slot.slot_);
|
||||
if(item) {
|
||||
return item->GetItem(bag_idx);
|
||||
if(slot.bag_index_ > -1) {
|
||||
auto sub_item = item->Get(slot.bag_index_);
|
||||
if(sub_item) {
|
||||
if(slot.aug_index_ > -1) {
|
||||
return sub_item->Get(slot.aug_index_);
|
||||
} else {
|
||||
return sub_item;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::shared_ptr<ItemInstance>(nullptr);
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::Put(int container_id, int slot_id, std::shared_ptr<ItemInstance> inst) {
|
||||
if(impl_->containers_.count(container_id) == 0) {
|
||||
auto &container = impl_->containers_[container_id];
|
||||
return container.Put(slot_id, inst);
|
||||
} else {
|
||||
ItemContainer container;
|
||||
bool v = container.Put(slot_id, inst);
|
||||
impl_->containers_[container_id] = container;
|
||||
|
||||
return v;
|
||||
bool EQEmu::Inventory::Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) {
|
||||
if(impl_->containers_.count(slot.type_) == 0) {
|
||||
impl_->containers_.insert(std::pair<int, ItemContainer>(slot.type_, ItemContainer()));
|
||||
}
|
||||
|
||||
auto &container = impl_->containers_[slot.type_];
|
||||
if(slot.bag_index_ > -1) {
|
||||
auto item = container.Get(slot.slot_);
|
||||
if(!item)
|
||||
return false;
|
||||
|
||||
if(slot.aug_index_ > -1) {
|
||||
auto bag_item = item->Get(slot.bag_index_);
|
||||
if(!bag_item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return bag_item->Put(slot.aug_index_, inst);
|
||||
} else {
|
||||
return item->Put(slot.bag_index_, inst);
|
||||
}
|
||||
} else {
|
||||
if(slot.aug_index_ > -1) {
|
||||
auto item = container.Get(slot.slot_);
|
||||
if(!item)
|
||||
return false;
|
||||
|
||||
return item->Put(slot.aug_index_, inst);
|
||||
}
|
||||
|
||||
return container.Put(slot.slot_, inst);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -23,6 +23,21 @@
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
struct InventorySlot
|
||||
{
|
||||
InventorySlot(int type, int slot)
|
||||
: type_(type), slot_(slot), bag_index_(-1), aug_index_(-1) { }
|
||||
InventorySlot(int type, int slot, int bag_index)
|
||||
: type_(type), slot_(slot), bag_index_(bag_index), aug_index_(-1) { }
|
||||
InventorySlot(int type, int slot, int bag_index, int aug_index)
|
||||
: type_(type), slot_(slot), bag_index_(bag_index), aug_index_(aug_index) { }
|
||||
|
||||
int type_;
|
||||
int slot_;
|
||||
int bag_index_;
|
||||
int aug_index_;
|
||||
};
|
||||
|
||||
enum InventoryType : int
|
||||
{
|
||||
InvTypePersonal = 0,
|
||||
@ -42,9 +57,9 @@ namespace EQEmu
|
||||
Inventory();
|
||||
~Inventory();
|
||||
|
||||
std::shared_ptr<ItemInstance> Get(int container_id, int slot_id);
|
||||
std::shared_ptr<ItemInstance> Get(int container_id, int slot_id, int bag_idx);
|
||||
bool Put(int container_id, int slot_id, std::shared_ptr<ItemInstance> inst);
|
||||
std::shared_ptr<ItemInstance> Get(const InventorySlot &slot);
|
||||
bool Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
|
||||
bool Swap(const InventorySlot &src, const InventorySlot &dest);
|
||||
private:
|
||||
struct impl;
|
||||
impl *impl_;
|
||||
|
||||
@ -1994,7 +1994,7 @@ void ItemInst::PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id)
|
||||
if (item_id == NO_ITEM) { return; }
|
||||
if (db == nullptr) { return; /* TODO: add log message for nullptr */ }
|
||||
|
||||
const ItemInst* aug = db->CreateItem(item_id);
|
||||
const ItemInst* aug = db->CreateItemOld(item_id);
|
||||
if (aug) {
|
||||
PutAugment(slot, *aug);
|
||||
safe_delete(aug);
|
||||
|
||||
@ -9,12 +9,18 @@ struct EQEmu::ItemContainer::impl
|
||||
|
||||
EQEmu::ItemContainer::ItemContainer()
|
||||
{
|
||||
impl_ = new impl;
|
||||
impl_ = new impl();
|
||||
}
|
||||
|
||||
EQEmu::ItemContainer::~ItemContainer()
|
||||
{
|
||||
delete impl_;
|
||||
if(impl_)
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
EQEmu::ItemContainer::ItemContainer(ItemContainer &&other) {
|
||||
impl_ = other.impl_;
|
||||
other.impl_ = nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemContainer::Get(int slot_id) {
|
||||
|
||||
@ -29,11 +29,15 @@ namespace EQEmu
|
||||
public:
|
||||
ItemContainer();
|
||||
~ItemContainer();
|
||||
ItemContainer(ItemContainer &&other);
|
||||
|
||||
std::shared_ptr<ItemInstance> Get(int slot_id);
|
||||
bool Put(int slot_id, std::shared_ptr<ItemInstance> inst);
|
||||
bool Delete(int slot_id);
|
||||
private:
|
||||
ItemContainer(const ItemContainer &other);
|
||||
ItemContainer& operator=(const ItemContainer &other);
|
||||
|
||||
struct impl;
|
||||
impl *impl_;
|
||||
};
|
||||
|
||||
@ -81,7 +81,7 @@ const ItemData *EQEmu::ItemInstance::GetItem() {
|
||||
return impl_->modified_item_ ? impl_->modified_item_ : impl_->base_item_;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::GetItem(int index) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::Get(int index) {
|
||||
if(EQEmu::ValueWithin(index, 0, 255)) {
|
||||
return impl_->contents_.Get(index);
|
||||
}
|
||||
@ -89,7 +89,7 @@ std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::GetItem(int index) {
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
}
|
||||
|
||||
bool EQEmu::ItemInstance::PutItem(int index, std::shared_ptr<ItemInstance> inst) {
|
||||
bool EQEmu::ItemInstance::Put(int index, std::shared_ptr<ItemInstance> inst) {
|
||||
if(!inst || !inst->GetItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -33,8 +33,8 @@ namespace EQEmu
|
||||
~ItemInstance();
|
||||
|
||||
const ItemData *GetItem();
|
||||
std::shared_ptr<ItemInstance> GetItem(int index);
|
||||
bool PutItem(int index, std::shared_ptr<ItemInstance> inst);
|
||||
std::shared_ptr<ItemInstance> Get(int index);
|
||||
bool Put(int index, std::shared_ptr<ItemInstance> inst);
|
||||
private:
|
||||
struct impl;
|
||||
impl *impl_;
|
||||
|
||||
@ -371,7 +371,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, InventoryOld* in
|
||||
if(!myitem)
|
||||
continue;
|
||||
|
||||
ItemInst* myinst = CreateBaseItem(myitem, charges);
|
||||
ItemInst* myinst = CreateBaseItemOld(myitem, charges);
|
||||
|
||||
if(slot < 0)
|
||||
slot = inv->FindFreeSlot(0, 0);
|
||||
@ -433,7 +433,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, InventoryOld *inv, bool is_charid)
|
||||
|
||||
int16 put_slot_id = INVALID_INDEX;
|
||||
|
||||
ItemInst *inst = CreateBaseItem(item, charges);
|
||||
ItemInst *inst = CreateBaseItemOld(item, charges);
|
||||
if (inst && item->ItemClass == ItemClassCommon) {
|
||||
for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
|
||||
if (aug[i])
|
||||
@ -536,7 +536,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::Inventory *inv)
|
||||
//
|
||||
// int16 put_slot_id = INVALID_INDEX;
|
||||
//
|
||||
// ItemInst *inst = CreateBaseItem(item, charges);
|
||||
// ItemInst *inst = CreateBaseItemOld(item, charges);
|
||||
//
|
||||
// if (inst == nullptr)
|
||||
// continue;
|
||||
@ -671,7 +671,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, InventoryOld *i
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
ItemInst *inst = CreateBaseItem(item, charges);
|
||||
ItemInst *inst = CreateBaseItemOld(item, charges);
|
||||
|
||||
if (inst == nullptr)
|
||||
continue;
|
||||
@ -1257,14 +1257,14 @@ bool SharedDatabase::LoadNPCFactionLists() {
|
||||
}
|
||||
|
||||
// Create appropriate ItemInst class
|
||||
ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
ItemInst* SharedDatabase::CreateItemOld(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
{
|
||||
const ItemData* item = nullptr;
|
||||
ItemInst* inst = nullptr;
|
||||
|
||||
item = GetItem(item_id);
|
||||
if (item) {
|
||||
inst = CreateBaseItem(item, charges);
|
||||
inst = CreateBaseItemOld(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
@ -1286,14 +1286,14 @@ ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1,
|
||||
|
||||
|
||||
// Create appropriate ItemInst class
|
||||
ItemInst* SharedDatabase::CreateItem(const ItemData* item, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
ItemInst* SharedDatabase::CreateItemOld(const ItemData* item, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, uint32 aug6, uint8 attuned)
|
||||
{
|
||||
ItemInst* inst = nullptr;
|
||||
if (item) {
|
||||
inst = CreateBaseItem(item, charges);
|
||||
inst = CreateBaseItemOld(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItemOld()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1310,7 +1310,7 @@ ItemInst* SharedDatabase::CreateItem(const ItemData* item, int16 charges, uint32
|
||||
return inst;
|
||||
}
|
||||
|
||||
ItemInst* SharedDatabase::CreateBaseItem(const ItemData* item, int16 charges) {
|
||||
ItemInst* SharedDatabase::CreateBaseItemOld(const ItemData* item, int16 charges) {
|
||||
ItemInst* inst = nullptr;
|
||||
if (item) {
|
||||
// if maxcharges is -1 that means it is an unlimited use item.
|
||||
@ -1324,7 +1324,7 @@ ItemInst* SharedDatabase::CreateBaseItem(const ItemData* item, int16 charges) {
|
||||
inst = new ItemInst(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateBaseItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateBaseItemOld()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1336,6 +1336,23 @@ ItemInst* SharedDatabase::CreateBaseItem(const ItemData* item, int16 charges) {
|
||||
return inst;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> SharedDatabase::CreateItem(uint32 item_id, int16 charges) {
|
||||
const ItemData* item = GetItem(item_id);
|
||||
if(item) {
|
||||
if(charges == 0 && item->MaxCharges == -1) {
|
||||
charges = 1;
|
||||
}
|
||||
|
||||
if(charges <= 0 && item->Stackable) {
|
||||
charges = 1;
|
||||
}
|
||||
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(new EQEmu::ItemInstance(item, charges));
|
||||
}
|
||||
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
}
|
||||
|
||||
int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
if(RuleB(Zone, EnableShadowrest)) {
|
||||
std::string query = StringFormat(
|
||||
|
||||
@ -82,9 +82,10 @@ class SharedDatabase : public Database
|
||||
/*
|
||||
Item Methods
|
||||
*/
|
||||
ItemInst* CreateItem(uint32 item_id, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
ItemInst* CreateItem(const ItemData* item, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
ItemInst* CreateBaseItem(const ItemData* item, int16 charges = 0);
|
||||
ItemInst* CreateItemOld(uint32 item_id, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
ItemInst* CreateItemOld(const ItemData* item, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
|
||||
ItemInst* CreateBaseItemOld(const ItemData* item, int16 charges = 0);
|
||||
std::shared_ptr<EQEmu::ItemInstance> CreateItem(uint32 item_id, int16 charges = 0);
|
||||
|
||||
/*
|
||||
Shared Memory crap
|
||||
|
||||
@ -139,36 +139,43 @@ public:
|
||||
|
||||
void InitInventory()
|
||||
{
|
||||
std::shared_ptr<EQEmu::ItemInstance> bag(new EQEmu::ItemInstance(&container));
|
||||
bag->PutItem(0, std::shared_ptr<EQEmu::ItemInstance>(new EQEmu::ItemInstance(&armor)));
|
||||
bag->PutItem(1, std::shared_ptr<EQEmu::ItemInstance>(new EQEmu::ItemInstance(&augment)));
|
||||
bag->PutItem(7, std::shared_ptr<EQEmu::ItemInstance>(new EQEmu::ItemInstance(&stackable, 45)));
|
||||
inv.Put(0, 23, bag); //23 first inv slot
|
||||
std::shared_ptr<EQEmu::ItemInstance> m_bag(new EQEmu::ItemInstance(&container));
|
||||
std::shared_ptr<EQEmu::ItemInstance> m_armor(new EQEmu::ItemInstance(&armor));
|
||||
std::shared_ptr<EQEmu::ItemInstance> m_augment(new EQEmu::ItemInstance(&augment));
|
||||
std::shared_ptr<EQEmu::ItemInstance> m_stackable(new EQEmu::ItemInstance(&stackable, 45));
|
||||
inv.Put(EQEmu::InventorySlot(0, 23), m_bag);
|
||||
inv.Put(EQEmu::InventorySlot(0, 23, 0), m_armor);
|
||||
inv.Put(EQEmu::InventorySlot(0, 23, 1), m_augment);
|
||||
inv.Put(EQEmu::InventorySlot(0, 23, 7), m_stackable);
|
||||
}
|
||||
|
||||
void InventoryVerifyInitialItemsTest()
|
||||
{
|
||||
auto m_bag = inv.Get(0, 23);
|
||||
auto m_bag = inv.Get(EQEmu::InventorySlot(0, 23));
|
||||
TEST_ASSERT(m_bag);
|
||||
TEST_ASSERT(m_bag->GetItem());
|
||||
TEST_ASSERT(m_bag->GetItem()->ID == 1000);
|
||||
|
||||
auto m_armor = m_bag->GetItem(0);
|
||||
|
||||
auto m_armor = m_bag->Get(0);
|
||||
TEST_ASSERT(m_armor);
|
||||
TEST_ASSERT(m_armor->GetItem());
|
||||
TEST_ASSERT(m_armor->GetItem()->ID == 1001);
|
||||
|
||||
auto m_augment = m_bag->GetItem(1);
|
||||
|
||||
auto m_augment = m_bag->Get(1);
|
||||
TEST_ASSERT(m_augment);
|
||||
TEST_ASSERT(m_augment->GetItem());
|
||||
TEST_ASSERT(m_augment->GetItem()->ID == 1002);
|
||||
|
||||
auto m_stackable = m_bag->GetItem(7);
|
||||
|
||||
auto m_stackable = m_bag->Get(7);
|
||||
TEST_ASSERT(m_stackable);
|
||||
TEST_ASSERT(m_stackable->GetItem());
|
||||
TEST_ASSERT(m_stackable->GetItem()->ID == 1003);
|
||||
}
|
||||
|
||||
void InventorySwapItemsTest()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
EQEmu::Inventory inv;
|
||||
ItemData container;
|
||||
|
||||
@ -4219,7 +4219,7 @@ void Bot::GetBotItems(std::string* errorMessage, InventoryOld &inv) {
|
||||
aug[4] = (uint32)atoul(row[8]);
|
||||
bool instnodrop = (row[9] && (uint16)atoi(row[9])) ? true : false;
|
||||
|
||||
ItemInst* inst = database.CreateItem(item_id, charges, aug[0], aug[1], aug[2], aug[3], aug[4]);
|
||||
ItemInst* inst = database.CreateItemOld(item_id, charges, aug[0], aug[1], aug[2], aug[3], aug[4]);
|
||||
if (!inst) {
|
||||
Log.Out(Logs::General, Logs::Error, "Warning: botid %i has an invalid item_id %i in inventory slot %i", this->GetBotID(), item_id, slot_id);
|
||||
continue;
|
||||
|
||||
@ -5423,7 +5423,7 @@ bool Client::TryReward(uint32 claim_id) {
|
||||
}
|
||||
|
||||
InternalVeteranReward ivr = (*iter);
|
||||
ItemInst *claim = database.CreateItem(ivr.items[0].item_id, ivr.items[0].charges);
|
||||
ItemInst *claim = database.CreateItemOld(ivr.items[0].item_id, ivr.items[0].charges);
|
||||
if(!claim) {
|
||||
Save();
|
||||
return true;
|
||||
@ -5433,7 +5433,7 @@ bool Client::TryReward(uint32 claim_id) {
|
||||
|
||||
for(int y = 1; y < 8; y++)
|
||||
if(ivr.items[y].item_id && claim->GetItem()->ItemClass == 1) {
|
||||
ItemInst *item_temp = database.CreateItem(ivr.items[y].item_id, ivr.items[y].charges);
|
||||
ItemInst *item_temp = database.CreateItemOld(ivr.items[y].item_id, ivr.items[y].charges);
|
||||
if(item_temp) {
|
||||
if(CheckLoreConflict(item_temp->GetItem())) {
|
||||
lore_conflict = true;
|
||||
|
||||
@ -2056,7 +2056,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app)
|
||||
if (item->MaxCharges != 0)
|
||||
charges = item->MaxCharges;
|
||||
|
||||
ItemInst *inst = database.CreateItem(item, charges);
|
||||
ItemInst *inst = database.CreateItemOld(item, charges);
|
||||
if (!AutoPutLootInInventory(*inst, true, true))
|
||||
{
|
||||
PutLootInInventory(MainCursor, *inst);
|
||||
@ -2579,7 +2579,7 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app)
|
||||
if (item->MaxCharges != 0)
|
||||
charges = item->MaxCharges;
|
||||
|
||||
ItemInst *inst = database.CreateItem(item, charges);
|
||||
ItemInst *inst = database.CreateItemOld(item, charges);
|
||||
if (!AutoPutLootInInventory(*inst, true, true))
|
||||
{
|
||||
PutLootInInventory(MainCursor, *inst);
|
||||
@ -3383,7 +3383,7 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app)
|
||||
Message(13, "Error: This item does not exist!");
|
||||
else
|
||||
{
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
if (inst)
|
||||
{
|
||||
SendItemPacket(0, inst, ItemPacketViewLink);
|
||||
@ -3416,7 +3416,7 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app)
|
||||
Message(13, "Error: This item does not exist!");
|
||||
else
|
||||
{
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
if (inst)
|
||||
{
|
||||
SendItemPacket(0, inst, ItemPacketViewLink);
|
||||
@ -3456,7 +3456,7 @@ void Client::Handle_OP_BazaarInspect(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
|
||||
if (inst) {
|
||||
SendItemPacket(0, inst, ItemPacketViewLink);
|
||||
@ -8081,7 +8081,7 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app)
|
||||
|
||||
}
|
||||
|
||||
ItemInst* inst = database.CreateItem(item, item->MaxCharges, ivrs->augments[0], ivrs->augments[1], ivrs->augments[2], ivrs->augments[3], ivrs->augments[4], ivrs->augments[5]);
|
||||
ItemInst* inst = database.CreateItemOld(item, item->MaxCharges, ivrs->augments[0], ivrs->augments[1], ivrs->augments[2], ivrs->augments[3], ivrs->augments[4], ivrs->augments[5]);
|
||||
if (inst) {
|
||||
SendItemPacket(0, inst, ItemPacketViewLink);
|
||||
safe_delete(inst);
|
||||
@ -8096,7 +8096,7 @@ void Client::Handle_OP_ItemLinkResponse(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
LDONItemViewRequest_Struct* item = (LDONItemViewRequest_Struct*)app->pBuffer;
|
||||
ItemInst* inst = database.CreateItem(item->item_id);
|
||||
ItemInst* inst = database.CreateItemOld(item->item_id);
|
||||
if (inst) {
|
||||
SendItemPacket(0, inst, ItemPacketViewLink);
|
||||
safe_delete(inst);
|
||||
@ -12064,7 +12064,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
else
|
||||
charges = item->MaxCharges;
|
||||
|
||||
ItemInst* inst = database.CreateItem(item, charges);
|
||||
ItemInst* inst = database.CreateItemOld(item, charges);
|
||||
|
||||
int SinglePrice = 0;
|
||||
if (RuleB(Merchant, UsePriceMod))
|
||||
|
||||
@ -962,7 +962,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
|
||||
int charges = 1;
|
||||
if (item->ItemClass == ItemClassCommon)
|
||||
charges = item->MaxCharges;
|
||||
ItemInst* inst = database.CreateItem(item, charges);
|
||||
ItemInst* inst = database.CreateItemOld(item, charges);
|
||||
if (inst) {
|
||||
if (RuleB(Merchant, UsePriceMod)) {
|
||||
inst->SetPrice((item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(merch, false)));
|
||||
@ -1003,7 +1003,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
|
||||
// charges=ml.charges;
|
||||
//else
|
||||
charges = item->MaxCharges;
|
||||
ItemInst* inst = database.CreateItem(item, charges);
|
||||
ItemInst* inst = database.CreateItemOld(item, charges);
|
||||
if (inst) {
|
||||
if (RuleB(Merchant, UsePriceMod)) {
|
||||
inst->SetPrice((item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(merch, false)));
|
||||
|
||||
@ -10201,7 +10201,7 @@ void command_zopp(Client *c, const Seperator *sep)
|
||||
c->Message(0, "Processing request..results may cause unpredictable behavior.");
|
||||
}
|
||||
|
||||
ItemInst* FakeItemInst = database.CreateItem(FakeItem, charges);
|
||||
ItemInst* FakeItemInst = database.CreateItemOld(FakeItem, charges);
|
||||
c->SendItemPacket(slotid, FakeItemInst, packettype);
|
||||
c->Message(0, "Sending zephyr op packet to client - [%s] %s (%u) with %i %s to slot %i.",
|
||||
packettype == ItemPacketTrade ? "Trade" : "Summon", FakeItem->Name, itemid, charges,
|
||||
|
||||
@ -972,7 +972,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
|
||||
if(Loot_Request_Type == 5) {
|
||||
int pkitem = GetPlayerKillItem();
|
||||
const ItemData* item = database.GetItem(pkitem);
|
||||
ItemInst* inst = database.CreateItem(item, item->MaxCharges);
|
||||
ItemInst* inst = database.CreateItemOld(item, item->MaxCharges);
|
||||
if(inst) {
|
||||
if (item->RecastDelay)
|
||||
inst->SetRecastTimestamp(timestamps.count(item->RecastType) ? timestamps.at(item->RecastType) : 0);
|
||||
@ -1005,7 +1005,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
|
||||
if(i < corpselootlimit) {
|
||||
item = database.GetItem(item_data->item_id);
|
||||
if(client && item) {
|
||||
ItemInst* inst = database.CreateItem(item, item_data->charges, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);
|
||||
ItemInst* inst = database.CreateItemOld(item, item_data->charges, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);
|
||||
if(inst) {
|
||||
if (item->RecastDelay)
|
||||
inst->SetRecastTimestamp(timestamps.count(item->RecastType) ? timestamps.at(item->RecastType) : 0);
|
||||
@ -1122,10 +1122,10 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) {
|
||||
|
||||
if (item != 0) {
|
||||
if (item_data){
|
||||
inst = database.CreateItem(item, item_data ? item_data->charges : 0, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);
|
||||
inst = database.CreateItemOld(item, item_data ? item_data->charges : 0, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);
|
||||
}
|
||||
else {
|
||||
inst = database.CreateItem(item);
|
||||
inst = database.CreateItemOld(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -298,7 +298,7 @@ void Client::GoFish()
|
||||
const ItemData* food_item = database.GetItem(food_id);
|
||||
|
||||
Message_StringID(MT_Skills, FISHING_SUCCESS);
|
||||
ItemInst* inst = database.CreateItem(food_item, 1);
|
||||
ItemInst* inst = database.CreateItemOld(food_item, 1);
|
||||
if(inst != nullptr) {
|
||||
if(CheckLoreConflict(inst->GetItem()))
|
||||
{
|
||||
@ -414,7 +414,7 @@ void Client::ForageItem(bool guarantee) {
|
||||
}
|
||||
|
||||
Message_StringID(MT_Skills, stringid);
|
||||
ItemInst* inst = database.CreateItem(food_item, 1);
|
||||
ItemInst* inst = database.CreateItemOld(food_item, 1);
|
||||
if(inst != nullptr) {
|
||||
// check to make sure it isn't a foraged lore item
|
||||
if(CheckLoreConflict(inst->GetItem()))
|
||||
|
||||
@ -1021,7 +1021,7 @@ ItemInst* GuildBankManager::GetItem(uint32 GuildID, uint16 Area, uint16 SlotID,
|
||||
if((SlotID > (GUILD_BANK_DEPOSIT_AREA_SIZE - 1)))
|
||||
return nullptr;
|
||||
|
||||
inst = database.CreateItem((*Iterator)->Items.DepositArea[SlotID].ItemID);
|
||||
inst = database.CreateItemOld((*Iterator)->Items.DepositArea[SlotID].ItemID);
|
||||
|
||||
if(!inst)
|
||||
return nullptr;
|
||||
@ -1034,7 +1034,7 @@ ItemInst* GuildBankManager::GetItem(uint32 GuildID, uint16 Area, uint16 SlotID,
|
||||
if((SlotID > (GUILD_BANK_MAIN_AREA_SIZE - 1)))
|
||||
return nullptr;
|
||||
|
||||
inst = database.CreateItem((*Iterator)->Items.MainArea[SlotID].ItemID);
|
||||
inst = database.CreateItemOld((*Iterator)->Items.MainArea[SlotID].ItemID);
|
||||
|
||||
if(!inst)
|
||||
return nullptr;
|
||||
|
||||
@ -528,7 +528,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2,
|
||||
|
||||
// in any other situation just use charges as passed
|
||||
|
||||
ItemInst* inst = database.CreateItem(item, charges);
|
||||
ItemInst* inst = database.CreateItemOld(item, charges);
|
||||
|
||||
if(inst == nullptr) {
|
||||
Message(13, "An unknown server error has occurred and your item was not created.");
|
||||
@ -900,7 +900,7 @@ void Client::PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootI
|
||||
for(int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) {
|
||||
if(bag_item_data[i] == nullptr)
|
||||
continue;
|
||||
const ItemInst *bagitem = database.CreateItem(bag_item_data[i]->item_id, bag_item_data[i]->charges, bag_item_data[i]->aug_1, bag_item_data[i]->aug_2, bag_item_data[i]->aug_3, bag_item_data[i]->aug_4, bag_item_data[i]->aug_5, bag_item_data[i]->aug_6, bag_item_data[i]->attuned);
|
||||
const ItemInst *bagitem = database.CreateItemOld(bag_item_data[i]->item_id, bag_item_data[i]->charges, bag_item_data[i]->aug_1, bag_item_data[i]->aug_2, bag_item_data[i]->aug_3, bag_item_data[i]->aug_4, bag_item_data[i]->aug_5, bag_item_data[i]->aug_6, bag_item_data[i]->attuned);
|
||||
interior_slot = InventoryOld::CalcSlotId(slot_id, i);
|
||||
Log.Out(Logs::Detail, Logs::Inventory, "Putting bag loot item %s (%d) into slot %d (bag slot %d)", inst.GetItem()->Name, inst.GetItem()->ID, interior_slot, i);
|
||||
PutLootInInventory(interior_slot, *bagitem);
|
||||
@ -1707,7 +1707,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
|
||||
// Split into two
|
||||
src_inst->SetCharges(src_inst->GetCharges() - move_in->number_in_stack);
|
||||
Log.Out(Logs::Detail, Logs::Inventory, "Split stack of %s (%d) from slot %d to %d with stack size %d. Src keeps %d.", src_inst->GetItem()->Name, src_inst->GetItem()->ID, src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetCharges());
|
||||
ItemInst* inst = database.CreateItem(src_inst->GetItem(), move_in->number_in_stack);
|
||||
ItemInst* inst = database.CreateItemOld(src_inst->GetItem(), move_in->number_in_stack);
|
||||
m_inv.PutItem(dst_slot_id, *inst);
|
||||
safe_delete(inst);
|
||||
}
|
||||
@ -1802,7 +1802,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
|
||||
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
|
||||
// This prevents the client from crashing when closing any 'phantom' bags -U
|
||||
const ItemData* token_struct = database.GetItem(22292); // 'Copper Coin'
|
||||
ItemInst* token_inst = database.CreateItem(token_struct, 1);
|
||||
ItemInst* token_inst = database.CreateItemOld(token_struct, 1);
|
||||
|
||||
SendItemPacket(resync_slot, token_inst, ItemPacketTrade);
|
||||
|
||||
@ -1827,7 +1827,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
|
||||
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
|
||||
if(m_inv[resync_slot]) {
|
||||
const ItemData* token_struct = database.GetItem(22292); // 'Copper Coin'
|
||||
ItemInst* token_inst = database.CreateItem(token_struct, 1);
|
||||
ItemInst* token_inst = database.CreateItemOld(token_struct, 1);
|
||||
|
||||
SendItemPacket(resync_slot, token_inst, ItemPacketTrade);
|
||||
SendItemPacket(resync_slot, m_inv[resync_slot], ItemPacketTrade);
|
||||
@ -1844,7 +1844,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
|
||||
int16 resync_slot = (InventoryOld::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : InventoryOld::CalcSlotId(move_slots->to_slot);
|
||||
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
|
||||
const ItemData* token_struct = database.GetItem(22292); // 'Copper Coin'
|
||||
ItemInst* token_inst = database.CreateItem(token_struct, 1);
|
||||
ItemInst* token_inst = database.CreateItemOld(token_struct, 1);
|
||||
|
||||
SendItemPacket(resync_slot, token_inst, ItemPacketTrade);
|
||||
|
||||
@ -1869,7 +1869,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
|
||||
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
|
||||
if(m_inv[resync_slot]) {
|
||||
const ItemData* token_struct = database.GetItem(22292); // 'Copper Coin'
|
||||
ItemInst* token_inst = database.CreateItem(token_struct, 1);
|
||||
ItemInst* token_inst = database.CreateItemOld(token_struct, 1);
|
||||
|
||||
SendItemPacket(resync_slot, token_inst, ItemPacketTrade);
|
||||
SendItemPacket(resync_slot, m_inv[resync_slot], ItemPacketTrade);
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
#include "lua_item.h"
|
||||
|
||||
Lua_ItemInst::Lua_ItemInst(int item_id) {
|
||||
SetLuaPtrData(database.CreateItem(item_id));
|
||||
SetLuaPtrData(database.CreateItemOld(item_id));
|
||||
cloned_ = true;
|
||||
}
|
||||
|
||||
Lua_ItemInst::Lua_ItemInst(int item_id, int charges) {
|
||||
SetLuaPtrData(database.CreateItem(item_id, charges));
|
||||
SetLuaPtrData(database.CreateItemOld(item_id, charges));
|
||||
cloned_ = true;
|
||||
}
|
||||
|
||||
|
||||
@ -3665,7 +3665,7 @@ void Mob::TrySympatheticProc(Mob *target, uint32 spell_id)
|
||||
|
||||
int32 Mob::GetItemStat(uint32 itemid, const char *identifier)
|
||||
{
|
||||
const ItemInst* inst = database.CreateItem(itemid);
|
||||
const ItemInst* inst = database.CreateItemOld(itemid);
|
||||
if (!inst)
|
||||
return 0;
|
||||
|
||||
|
||||
@ -1378,7 +1378,7 @@ void NPC::PickPocket(Client* thief) {
|
||||
const ItemData* item = database.GetItem(citem->item_id);
|
||||
if (item)
|
||||
{
|
||||
inst = database.CreateItem(item, citem->charges);
|
||||
inst = database.CreateItemOld(item, citem->charges);
|
||||
bool is_arrow = (item->ItemType == ItemTypeArrow) ? true : false;
|
||||
int slot_id = thief->GetInv().FindFreeSlot(false, true, inst->GetItem()->Size, is_arrow);
|
||||
if (/*!Equipped(item->ID) &&*/
|
||||
@ -1398,7 +1398,7 @@ void NPC::PickPocket(Client* thief) {
|
||||
if (x > 0)
|
||||
{
|
||||
int random = zone->random.Int(0, x-1);
|
||||
inst = database.CreateItem(steal_items[random], charges[random]);
|
||||
inst = database.CreateItemOld(steal_items[random], charges[random]);
|
||||
if (inst)
|
||||
{
|
||||
const ItemData* item = inst->GetItem();
|
||||
|
||||
@ -876,7 +876,7 @@ void Object::SetItemID(uint32 itemid)
|
||||
|
||||
if (itemid)
|
||||
{
|
||||
this->m_inst = database.CreateItem(itemid);
|
||||
this->m_inst = database.CreateItemOld(itemid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1171,7 +1171,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
|
||||
c->SendItemPacket(MainCursor, SummonedItem, ItemPacketSummonItem);
|
||||
safe_delete(SummonedItem);
|
||||
}
|
||||
SummonedItem = database.CreateItem(spell.base[i], charges);
|
||||
SummonedItem = database.CreateItemOld(spell.base[i], charges);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1208,7 +1208,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
|
||||
if (charges < 1)
|
||||
charges = 1;
|
||||
|
||||
ItemInst *SubItem = database.CreateItem(spell.base[i], charges);
|
||||
ItemInst *SubItem = database.CreateItemOld(spell.base[i], charges);
|
||||
if (SubItem != nullptr) {
|
||||
SummonedItem->PutItem(slot, *SubItem);
|
||||
safe_delete(SubItem);
|
||||
|
||||
@ -1165,7 +1165,7 @@ void Client::SendTraderItem(uint32 ItemID, uint16 Quantity) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemInst* inst = database.CreateItem(item, Quantity);
|
||||
ItemInst* inst = database.CreateItemOld(item, Quantity);
|
||||
|
||||
if (inst)
|
||||
{
|
||||
@ -1204,7 +1204,7 @@ void Client::BulkSendTraderInventory(uint32 char_id) {
|
||||
item=database.GetItem(TraderItems->ItemID[i]);
|
||||
|
||||
if (item && (item->NoDrop!=0)) {
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
if (inst) {
|
||||
inst->SetSerialNumber(TraderItems->SerialNumber[i]);
|
||||
if(TraderItems->Charges[i] > 0)
|
||||
@ -2025,7 +2025,7 @@ static void UpdateTraderCustomerItemsAdded(uint32 CustomerID, TraderCharges_Stru
|
||||
|
||||
if(!item) return;
|
||||
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
|
||||
if(!inst) return;
|
||||
|
||||
@ -2106,7 +2106,7 @@ static void UpdateTraderCustomerPriceChanged(uint32 CustomerID, TraderCharges_St
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Sending price updates to customer %s", Customer->GetName());
|
||||
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
|
||||
if(!inst) return;
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ void Client::DoTributeUpdate() {
|
||||
uint32 item_id = tier.tribute_item_id;
|
||||
|
||||
//summon the item for them
|
||||
const ItemInst* inst = database.CreateItem(item_id, 1);
|
||||
const ItemInst* inst = database.CreateItemOld(item_id, 1);
|
||||
if(inst == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ bool Zone::LoadZoneObjects() {
|
||||
}
|
||||
else {
|
||||
// Groundspawn object
|
||||
inst = database.CreateItem(itemid);
|
||||
inst = database.CreateItemOld(itemid);
|
||||
}
|
||||
|
||||
//Father Nitwit's fix... not perfect...
|
||||
@ -295,7 +295,7 @@ bool Zone::LoadGroundSpawns() {
|
||||
for(gsindex=0;gsindex<50;gsindex++){
|
||||
if(groundspawn.spawn[gsindex].item>0 && groundspawn.spawn[gsindex].item<500000){
|
||||
ItemInst* inst = nullptr;
|
||||
inst = database.CreateItem(groundspawn.spawn[gsindex].item);
|
||||
inst = database.CreateItemOld(groundspawn.spawn[gsindex].item);
|
||||
gsnumber=groundspawn.spawn[gsindex].max_allowed;
|
||||
ix=0;
|
||||
if(inst){
|
||||
|
||||
@ -495,7 +495,7 @@ void ZoneDatabase::LoadWorldContainer(uint32 parentid, ItemInst* container)
|
||||
aug[4] = (uint32)atoi(row[7]);
|
||||
aug[5] = (uint32)atoi(row[8]);
|
||||
|
||||
ItemInst* inst = database.CreateItem(item_id, charges);
|
||||
ItemInst* inst = database.CreateItemOld(item_id, charges);
|
||||
if (inst && inst->GetItem()->ItemClass == ItemClassCommon) {
|
||||
for(int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++)
|
||||
if (aug[i])
|
||||
@ -640,7 +640,7 @@ ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) {
|
||||
if (item->NoDrop == 0)
|
||||
return nullptr;
|
||||
|
||||
ItemInst* inst = database.CreateItem(item);
|
||||
ItemInst* inst = database.CreateItemOld(item);
|
||||
if(!inst) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Unable to create item instance\n");
|
||||
fflush(stdout);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user