mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-19 21:08:20 +00:00
Merchant buying in flux but it works better now
This commit is contained in:
+93
-55
@@ -155,7 +155,7 @@ void EQEmu::Inventory::SetDataModel(InventoryDataModel *dm) {
|
||||
impl_->data_model_ = std::unique_ptr<InventoryDataModel>(dm);
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::Inventory::Get(const InventorySlot &slot) {
|
||||
EQEmu::ItemInstance::pointer EQEmu::Inventory::Get(const InventorySlot &slot) {
|
||||
auto iter = impl_->containers_.find(slot.Type());
|
||||
if(iter != impl_->containers_.end()) {
|
||||
auto item = iter->second.Get(slot.Slot());
|
||||
@@ -175,10 +175,10 @@ std::shared_ptr<EQEmu::ItemInstance> EQEmu::Inventory::Get(const InventorySlot &
|
||||
}
|
||||
}
|
||||
|
||||
return std::shared_ptr<ItemInstance>(nullptr);
|
||||
return ItemInstance::pointer(nullptr);
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) {
|
||||
bool EQEmu::Inventory::Put(const InventorySlot &slot, ItemInstance::pointer &inst) {
|
||||
if(impl_->containers_.count(slot.Type()) == 0) {
|
||||
if(slot.Type() == 0) {
|
||||
impl_->containers_.insert(std::pair<int, ItemContainer>(slot.Type(), ItemContainer(new ItemContainerPersonalSerialization())));
|
||||
@@ -321,6 +321,7 @@ bool EQEmu::Inventory::Swap(const InventorySlot &src, const InventorySlot &dest,
|
||||
}
|
||||
|
||||
i_dest->SetCharges(i_dest->GetCharges() + charges);
|
||||
impl_->data_model_->Delete(dest);
|
||||
impl_->data_model_->Insert(dest, i_dest);
|
||||
impl_->data_model_->Commit();
|
||||
return true;
|
||||
@@ -335,6 +336,8 @@ bool EQEmu::Inventory::Swap(const InventorySlot &src, const InventorySlot &dest,
|
||||
}
|
||||
|
||||
Put(dest, split);
|
||||
impl_->data_model_->Delete(src);
|
||||
impl_->data_model_->Delete(dest);
|
||||
impl_->data_model_->Insert(src, i_src);
|
||||
impl_->data_model_->Insert(dest, split);
|
||||
impl_->data_model_->Commit();
|
||||
@@ -366,44 +369,7 @@ bool EQEmu::Inventory::Swap(const InventorySlot &src, const InventorySlot &dest,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::TryStacking(std::shared_ptr<EQEmu::ItemInstance> inst, const InventorySlot &slot) {
|
||||
auto target_inst = Get(slot);
|
||||
|
||||
if(!inst || !target_inst ||
|
||||
!inst->IsStackable() || !target_inst->IsStackable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(inst->GetBaseItem()->ID != target_inst->GetBaseItem()->ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int stack_avail = target_inst->GetBaseItem()->StackSize - target_inst->GetCharges();
|
||||
|
||||
if(stack_avail <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
impl_->data_model_->Begin();
|
||||
if(inst->GetCharges() <= stack_avail) {
|
||||
inst->SetCharges(0);
|
||||
target_inst->SetCharges(target_inst->GetCharges() + inst->GetCharges());
|
||||
impl_->data_model_->Delete(slot);
|
||||
impl_->data_model_->Insert(slot, target_inst);
|
||||
} else {
|
||||
inst->SetCharges(inst->GetCharges() - stack_avail);
|
||||
target_inst->SetCharges(target_inst->GetCharges() + stack_avail);
|
||||
impl_->data_model_->Delete(slot);
|
||||
impl_->data_model_->Insert(slot, target_inst);
|
||||
}
|
||||
|
||||
impl_->data_model_->Commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::Summon(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) {
|
||||
bool EQEmu::Inventory::Summon(const InventorySlot &slot, ItemInstance::pointer &inst) {
|
||||
if(!inst)
|
||||
return false;
|
||||
|
||||
@@ -432,7 +398,7 @@ bool EQEmu::Inventory::Summon(const InventorySlot &slot, std::shared_ptr<ItemIns
|
||||
return v;
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::PushToCursorBuffer(std::shared_ptr<ItemInstance> inst) {
|
||||
bool EQEmu::Inventory::PushToCursorBuffer(ItemInstance::pointer &inst) {
|
||||
if(impl_->containers_.count(InvTypeCursorBuffer) == 0) {
|
||||
impl_->containers_.insert(std::pair<int, ItemContainer>(InvTypeCursorBuffer, ItemContainer()));
|
||||
}
|
||||
@@ -506,18 +472,23 @@ bool EQEmu::Inventory::PopFromCursorBuffer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
EQEmu::InventorySlot EQEmu::Inventory::FindFreeSlot(bool for_bag, bool try_cursor, int min_size, bool is_arrow) {
|
||||
//check basic inventory
|
||||
for(int i = EQEmu::PersonalSlotGeneral1; i < EQEmu::PersonalSlotGeneral10; ++i) {
|
||||
EQEmu::InventorySlot slot(EQEmu::InvTypePersonal, i);
|
||||
EQEmu::InventorySlot EQEmu::Inventory::FindFreeSlot(ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end) {
|
||||
bool for_bag = inst->GetItem()->ItemClass == ItemClassContainer;
|
||||
int min_size = inst->GetItem()->Size;
|
||||
bool is_arrow = inst->GetItem()->ItemType == ItemTypeArrow;
|
||||
|
||||
//check upper level inventory
|
||||
for(int i = slot_id_start; i <= slot_id_end; ++i) {
|
||||
EQEmu::InventorySlot slot(container_id, i);
|
||||
if(!Get(slot)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
//if not for a bag then check inside bags
|
||||
if (!for_bag) {
|
||||
for(int i = EQEmu::PersonalSlotGeneral1; i < EQEmu::PersonalSlotGeneral10; ++i) {
|
||||
EQEmu::InventorySlot slot(EQEmu::InvTypePersonal, i);
|
||||
for(int i = slot_id_start; i <= slot_id_end; ++i) {
|
||||
EQEmu::InventorySlot slot(container_id, i);
|
||||
auto inst = Get(slot);
|
||||
|
||||
if(inst && inst->GetBaseItem()->ItemClass == ItemClassContainer && inst->GetBaseItem()->BagSize >= min_size)
|
||||
@@ -529,7 +500,7 @@ EQEmu::InventorySlot EQEmu::Inventory::FindFreeSlot(bool for_bag, bool try_curso
|
||||
|
||||
int slots = inst->GetBaseItem()->BagSlots;
|
||||
for(int b_i = 0; b_i < slots; ++b_i) {
|
||||
EQEmu::InventorySlot bag_slot(EQEmu::InvTypePersonal, i, b_i);
|
||||
EQEmu::InventorySlot bag_slot(container_id, i, b_i);
|
||||
|
||||
if(!Get(bag_slot)) {
|
||||
return bag_slot;
|
||||
@@ -539,11 +510,77 @@ EQEmu::InventorySlot EQEmu::Inventory::FindFreeSlot(bool for_bag, bool try_curso
|
||||
}
|
||||
}
|
||||
|
||||
if(try_cursor) {
|
||||
EQEmu::InventorySlot slot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor);
|
||||
return EQEmu::InventorySlot();
|
||||
}
|
||||
|
||||
int EQEmu::Inventory::FindFreeStackSlots(ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end) {
|
||||
if(!inst->IsStackable()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EQEmu::InventorySlot();
|
||||
bool is_arrow = inst->GetItem()->ItemType == ItemTypeArrow;
|
||||
int item_id = inst->GetItem()->ID;
|
||||
|
||||
int charges_to_check = inst->GetCharges();
|
||||
int charges = 0;
|
||||
|
||||
auto iter = impl_->containers_.find(container_id);
|
||||
if(iter == impl_->containers_.end()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto &container = iter->second;
|
||||
for(int i = slot_id_start; i <= slot_id_end; ++i) {
|
||||
auto current = container.Get(i);
|
||||
if(!current) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(current->GetItem()->ID == item_id) {
|
||||
int free_charges = current->GetItem()->StackSize - current->GetCharges();
|
||||
if(free_charges)
|
||||
charges += free_charges;
|
||||
|
||||
if(charges >= charges_to_check) {
|
||||
return charges_to_check;
|
||||
}
|
||||
} else if(current->GetItem()->ItemClass == ItemClassContainer) {
|
||||
int sz = current->GetItem()->BagSlots;
|
||||
for(int i = 0; i < sz; ++i) {
|
||||
auto sub_item = current->Get(i);
|
||||
if(!sub_item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(sub_item->GetItem()->ID == item_id) {
|
||||
int free_charges = sub_item->GetItem()->StackSize - sub_item->GetCharges();
|
||||
if(free_charges)
|
||||
charges += free_charges;
|
||||
|
||||
if(charges >= charges_to_check) {
|
||||
return charges_to_check;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(charges >= charges_to_check) {
|
||||
return charges_to_check;
|
||||
}
|
||||
|
||||
return charges;
|
||||
}
|
||||
|
||||
void EQEmu::Inventory::UpdateSlot(const InventorySlot &slot, ItemInstance::pointer &inst) {
|
||||
impl_->data_model_->Begin();
|
||||
|
||||
impl_->data_model_->Delete(slot);
|
||||
if(inst) {
|
||||
impl_->data_model_->Insert(slot, inst);
|
||||
}
|
||||
|
||||
impl_->data_model_->Commit();
|
||||
}
|
||||
|
||||
int EQEmu::Inventory::CalcMaterialFromSlot(const InventorySlot &slot) {
|
||||
@@ -600,7 +637,7 @@ EQEmu::InventorySlot EQEmu::Inventory::CalcSlotFromMaterial(int material) {
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::CanEquip(std::shared_ptr<EQEmu::ItemInstance> inst, const EQEmu::InventorySlot &slot) {
|
||||
bool EQEmu::Inventory::CanEquip(EQEmu::ItemInstance::pointer &inst, const EQEmu::InventorySlot &slot) {
|
||||
if(!inst) {
|
||||
return false;
|
||||
}
|
||||
@@ -640,7 +677,8 @@ bool EQEmu::Inventory::CanEquip(std::shared_ptr<EQEmu::ItemInstance> inst, const
|
||||
auto iter = inst->GetContainer()->Begin();
|
||||
auto end = inst->GetContainer()->End();
|
||||
while(iter != end) {
|
||||
if(!CanEquip(iter->second, InventorySlot(slot.Type(), slot.Slot(), slot.BagIndex(), iter->first))) {
|
||||
EQEmu::ItemInstance::pointer itm = iter->second;
|
||||
if(!CanEquip(itm, InventorySlot(slot.Type(), slot.Slot(), slot.BagIndex(), iter->first))) {
|
||||
return false;
|
||||
}
|
||||
++iter;
|
||||
@@ -738,7 +776,7 @@ bool EQEmu::Inventory::_swap(const InventorySlot &src, const InventorySlot &dest
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::_destroy(const InventorySlot &slot) {
|
||||
bool v = Put(slot, std::shared_ptr<EQEmu::ItemInstance>(nullptr));
|
||||
bool v = Put(slot, EQEmu::ItemInstance::pointer(nullptr));
|
||||
impl_->data_model_->Delete(slot);
|
||||
return v;
|
||||
}
|
||||
|
||||
+8
-7
@@ -133,19 +133,20 @@ namespace EQEmu
|
||||
void SetDeity(int deity);
|
||||
void SetDataModel(InventoryDataModel *dm);
|
||||
|
||||
std::shared_ptr<ItemInstance> Get(const InventorySlot &slot);
|
||||
bool Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
|
||||
ItemInstance::pointer Get(const InventorySlot &slot);
|
||||
bool Put(const InventorySlot &slot, ItemInstance::pointer &inst);
|
||||
bool Swap(const InventorySlot &src, const InventorySlot &dest, int charges);
|
||||
bool TryStacking(std::shared_ptr<EQEmu::ItemInstance> inst, const InventorySlot &slot);
|
||||
bool Summon(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
|
||||
bool PushToCursorBuffer(std::shared_ptr<ItemInstance> inst);
|
||||
bool Summon(const InventorySlot &slot, ItemInstance::pointer &inst);
|
||||
bool PushToCursorBuffer(ItemInstance::pointer &inst);
|
||||
bool PopFromCursorBuffer();
|
||||
InventorySlot FindFreeSlot(bool for_bag, bool try_cursor, int min_size = 0, bool is_arrow = false);
|
||||
InventorySlot FindFreeSlot(ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end);
|
||||
int FindFreeStackSlots(ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end);
|
||||
void UpdateSlot(const InventorySlot &slot, ItemInstance::pointer &inst);
|
||||
|
||||
//utility
|
||||
static int CalcMaterialFromSlot(const InventorySlot &slot);
|
||||
static InventorySlot CalcSlotFromMaterial(int material);
|
||||
bool CanEquip(std::shared_ptr<EQEmu::ItemInstance> inst, const EQEmu::InventorySlot &slot);
|
||||
bool CanEquip(EQEmu::ItemInstance::pointer &inst, const EQEmu::InventorySlot &slot);
|
||||
bool CheckLoreConflict(const ItemData *item);
|
||||
bool Serialize(MemoryBuffer &buf);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace EQEmu
|
||||
virtual void Begin() = 0;
|
||||
virtual bool Commit() = 0;
|
||||
virtual void Rollback() = 0;
|
||||
virtual void Insert(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) = 0;
|
||||
virtual void Insert(const InventorySlot &slot, ItemInstance::pointer &inst) = 0;
|
||||
virtual void Delete(const InventorySlot &slot) = 0;
|
||||
};
|
||||
} // EQEmu
|
||||
|
||||
@@ -14,7 +14,7 @@ struct DataEvent
|
||||
{
|
||||
DataEventTypes evt;
|
||||
EQEmu::InventorySlot slot;
|
||||
std::shared_ptr<EQEmu::ItemInstance> inst;
|
||||
EQEmu::ItemInstance::pointer inst;
|
||||
};
|
||||
|
||||
struct EQEmu::InventoryDatabaseDataModel::impl {
|
||||
@@ -135,7 +135,7 @@ void EQEmu::InventoryDatabaseDataModel::Rollback() {
|
||||
impl_->events_.clear();
|
||||
}
|
||||
|
||||
void EQEmu::InventoryDatabaseDataModel::Insert(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) {
|
||||
void EQEmu::InventoryDatabaseDataModel::Insert(const InventorySlot &slot, ItemInstance::pointer &inst) {
|
||||
DataEvent evt;
|
||||
evt.evt = DB_Insert;
|
||||
evt.inst = inst;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace EQEmu
|
||||
virtual void Begin();
|
||||
virtual bool Commit();
|
||||
virtual void Rollback();
|
||||
virtual void Insert(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
|
||||
virtual void Insert(const InventorySlot &slot, ItemInstance::pointer &inst);
|
||||
virtual void Delete(const InventorySlot &slot);
|
||||
private:
|
||||
struct impl;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace EQEmu
|
||||
virtual void Begin() { }
|
||||
virtual bool Commit() { return true; }
|
||||
virtual void Rollback() { }
|
||||
virtual void Insert(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) { }
|
||||
virtual void Insert(const InventorySlot &slot, ItemInstance::pointer &inst) { }
|
||||
virtual void Delete(const InventorySlot &slot) { }
|
||||
};
|
||||
} // EQEmu
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
struct EQEmu::ItemContainer::impl
|
||||
{
|
||||
std::map<int, std::shared_ptr<ItemInstance>> items_;
|
||||
std::map<int, ItemInstance::pointer> items_;
|
||||
ItemContainerSerializationStrategy *serialize_strat_;
|
||||
};
|
||||
|
||||
@@ -41,16 +41,16 @@ EQEmu::ItemContainer& EQEmu::ItemContainer::operator=(ItemContainer &&other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemContainer::Get(const int slot_id) {
|
||||
EQEmu::ItemInstance::pointer EQEmu::ItemContainer::Get(const int slot_id) {
|
||||
auto iter = impl_->items_.find(slot_id);
|
||||
if(iter != impl_->items_.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
return EQEmu::ItemInstance::pointer(nullptr);
|
||||
}
|
||||
|
||||
bool EQEmu::ItemContainer::Put(const int slot_id, std::shared_ptr<ItemInstance> inst) {
|
||||
bool EQEmu::ItemContainer::Put(const int slot_id, ItemInstance::pointer &inst) {
|
||||
if(!inst) {
|
||||
impl_->items_.erase(slot_id);
|
||||
return true;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace EQEmu
|
||||
class ItemContainer
|
||||
{
|
||||
public:
|
||||
typedef std::map<int, std::shared_ptr<ItemInstance>>::const_iterator ItemContainerIter;
|
||||
typedef std::map<int, ItemInstance::pointer>::const_iterator ItemContainerIter;
|
||||
|
||||
ItemContainer();
|
||||
ItemContainer(ItemContainerSerializationStrategy *strategy);
|
||||
@@ -39,8 +39,8 @@ namespace EQEmu
|
||||
ItemContainer(ItemContainer &&other);
|
||||
ItemContainer& operator=(ItemContainer &&other);
|
||||
|
||||
std::shared_ptr<ItemInstance> Get(const int slot_id);
|
||||
bool Put(const int slot_id, std::shared_ptr<ItemInstance> inst);
|
||||
ItemInstance::pointer Get(const int slot_id);
|
||||
bool Put(const int slot_id, ItemInstance::pointer &inst);
|
||||
bool Delete(const int slot_id);
|
||||
|
||||
//Utility
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "item_container_default_serialization.h"
|
||||
|
||||
bool EQEmu::ItemContainerDefaultSerialization::Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, std::shared_ptr<ItemInstance>>& items) {
|
||||
bool EQEmu::ItemContainerDefaultSerialization::Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, ItemInstance::pointer>& items) {
|
||||
if(items.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace EQEmu
|
||||
public:
|
||||
ItemContainerDefaultSerialization() { }
|
||||
virtual ~ItemContainerDefaultSerialization() { }
|
||||
virtual bool Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, std::shared_ptr<ItemInstance>>& items);
|
||||
virtual bool Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, ItemInstance::pointer>& items);
|
||||
};
|
||||
} // EQEmu
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "item_container_personal_serialization.h"
|
||||
|
||||
bool EQEmu::ItemContainerPersonalSerialization::Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, std::shared_ptr<ItemInstance>>& items) {
|
||||
bool EQEmu::ItemContainerPersonalSerialization::Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, ItemInstance::pointer>& items) {
|
||||
if(items.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace EQEmu
|
||||
public:
|
||||
ItemContainerPersonalSerialization() { }
|
||||
virtual ~ItemContainerPersonalSerialization() { }
|
||||
virtual bool Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, std::shared_ptr<ItemInstance>>& items);
|
||||
virtual bool Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, ItemInstance::pointer>& items);
|
||||
};
|
||||
} // EQEmu
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace EQEmu
|
||||
public:
|
||||
ItemContainerSerializationStrategy() { }
|
||||
virtual ~ItemContainerSerializationStrategy() { }
|
||||
virtual bool Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, std::shared_ptr<ItemInstance>>& items) = 0;
|
||||
virtual bool Serialize(MemoryBuffer &buf, const int container_number, const std::map<int, ItemInstance::pointer>& items) = 0;
|
||||
};
|
||||
} // EQEmu
|
||||
|
||||
|
||||
@@ -86,21 +86,21 @@ EQEmu::ItemInstance::~ItemInstance() {
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::Split(int charges) {
|
||||
EQEmu::ItemInstance::pointer EQEmu::ItemInstance::Split(int charges) {
|
||||
if(!IsStackable()) {
|
||||
//Can't split non stackable items!
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
return pointer(nullptr);
|
||||
}
|
||||
|
||||
if(charges >= GetCharges()) {
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
return pointer(nullptr);
|
||||
}
|
||||
|
||||
if(impl_->contents_.Size() > 0) {
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
return pointer(nullptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> split = std::shared_ptr<EQEmu::ItemInstance>(new EQEmu::ItemInstance(impl_->base_item_, charges));
|
||||
pointer split = pointer(new EQEmu::ItemInstance(impl_->base_item_, charges));
|
||||
split->SetSerialNumber(EQEmu::GetNextItemInstanceSerial());
|
||||
//Set Tracking here
|
||||
split->impl_->attuned_ = impl_->attuned_;
|
||||
@@ -130,20 +130,20 @@ const ItemData *EQEmu::ItemInstance::GetBaseItem() const {
|
||||
return impl_->base_item_;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::Get(const int index) {
|
||||
EQEmu::ItemInstance::pointer EQEmu::ItemInstance::Get(const int index) {
|
||||
if(EQEmu::ValueWithin(index, 0, 255)) {
|
||||
return impl_->contents_.Get(index);
|
||||
}
|
||||
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
return pointer(nullptr);
|
||||
}
|
||||
|
||||
bool EQEmu::ItemInstance::Put(const int index, std::shared_ptr<ItemInstance> inst) {
|
||||
bool EQEmu::ItemInstance::Put(const int index, pointer &inst) {
|
||||
if(!impl_->base_item_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto *item = impl_->base_item_;
|
||||
auto item = impl_->base_item_;
|
||||
if(item->ItemClass == ItemClassContainer) { // Bag
|
||||
if(!EQEmu::ValueWithin(index, 0, item->BagSlots)) {
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace EQEmu
|
||||
class ItemInstance
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<ItemInstance> pointer;
|
||||
ItemInstance(const ItemData* idata);
|
||||
ItemInstance(const ItemData* idata, const int16 charges);
|
||||
~ItemInstance();
|
||||
@@ -38,11 +39,11 @@ namespace EQEmu
|
||||
const ItemData *GetBaseItem();
|
||||
const ItemData *GetBaseItem() const;
|
||||
|
||||
std::shared_ptr<ItemInstance> Split(int charges);
|
||||
pointer Split(int charges);
|
||||
|
||||
//Container
|
||||
std::shared_ptr<ItemInstance> Get(const int index);
|
||||
bool Put(const int index, std::shared_ptr<ItemInstance> inst);
|
||||
pointer Get(const int index);
|
||||
bool Put(const int index, pointer &inst);
|
||||
|
||||
//Persistent State
|
||||
int16 GetCharges();
|
||||
@@ -108,6 +109,8 @@ namespace EQEmu
|
||||
bool IsNoDrop();
|
||||
bool IsNoDrop() const;
|
||||
|
||||
void CheckStackRemaining(pointer &insert, int &charges);
|
||||
|
||||
//Internal state
|
||||
//Used for low level operations such as encode/decode
|
||||
ItemContainer *GetContainer();
|
||||
|
||||
@@ -584,27 +584,6 @@ RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(QueryServ)
|
||||
RULE_BOOL(QueryServ, PlayerLogChat, false) // Logs Player Chat
|
||||
RULE_BOOL(QueryServ, PlayerLogTrades, false) // Logs Player Trades
|
||||
RULE_BOOL(QueryServ, PlayerLogHandins, false) // Logs Player Handins
|
||||
RULE_BOOL(QueryServ, PlayerLogNPCKills, false) // Logs Player NPC Kills
|
||||
RULE_BOOL(QueryServ, PlayerLogDeletes, false) // Logs Player Deletes
|
||||
RULE_BOOL(QueryServ, PlayerLogMoves, false) // Logs Player Moves
|
||||
RULE_BOOL(QueryServ, PlayerLogMerchantTransactions, false) // Logs Merchant Transactions
|
||||
RULE_BOOL(QueryServ, PlayerLogPCCoordinates, false) // Logs Player Coordinates with certain events
|
||||
RULE_BOOL(QueryServ, PlayerLogDropItem, false) // Logs Player Drop Item
|
||||
RULE_BOOL(QueryServ, PlayerLogZone, false) // Logs Player Zone Events
|
||||
RULE_BOOL(QueryServ, PlayerLogDeaths, false) // Logs Player Deaths
|
||||
RULE_BOOL(QueryServ, PlayerLogConnectDisconnect, false) // Logs Player Connect Disconnect State
|
||||
RULE_BOOL(QueryServ, PlayerLogLevels, false) // Logs Player Leveling/Deleveling
|
||||
RULE_BOOL(QueryServ, PlayerLogAARate, false) // Logs Player AA Experience Rates
|
||||
RULE_BOOL(QueryServ, PlayerLogQGlobalUpdate, false) // Logs Player QGlobal Updates
|
||||
RULE_BOOL(QueryServ, PlayerLogTaskUpdates, false) // Logs Player Task Updates
|
||||
RULE_BOOL(QueryServ, PlayerLogKeyringAddition, false) // Log PLayer Keyring additions
|
||||
RULE_BOOL(QueryServ, PlayerLogAAPurchases, false) // Log Player AA Purchases
|
||||
RULE_BOOL(QueryServ, PlayerLogTradeSkillEvents, false) // Log Player Tradeskill Transactions
|
||||
RULE_BOOL(QueryServ, PlayerLogIssuedCommandes, false) // Log Player Issued Commands
|
||||
RULE_BOOL(QueryServ, PlayerLogMoneyTransactions, false) // Log Player Money Transaction/Splits
|
||||
RULE_BOOL(QueryServ, PlayerLogAlternateCurrencyTransactions, false) // Log Ploayer Alternate Currency Transactions
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Inventory)
|
||||
|
||||
+1
-134
@@ -181,14 +181,7 @@
|
||||
#define ServerOP_CZMessagePlayer 0x4008
|
||||
#define ServerOP_ReloadWorld 0x4009
|
||||
#define ServerOP_ReloadLogs 0x4010
|
||||
/* Query Server OP Codes */
|
||||
#define ServerOP_QSPlayerLogTrades 0x5010
|
||||
#define ServerOP_QSPlayerLogHandins 0x5011
|
||||
#define ServerOP_QSPlayerLogNPCKills 0x5012
|
||||
#define ServerOP_QSPlayerLogDeletes 0x5013
|
||||
#define ServerOP_QSPlayerLogMoves 0x5014
|
||||
#define ServerOP_QSPlayerLogMerchantTransactions 0x5015
|
||||
#define ServerOP_QSSendQuery 0x5016
|
||||
#define ServerOP_QSSendQuery 0x5000
|
||||
#define ServerOP_CZSignalNPC 0x5017
|
||||
#define ServerOP_CZSetEntityVariableByNPCTypeID 0x5018
|
||||
|
||||
@@ -1113,132 +1106,6 @@ struct CZClientSignalByName_Struct {
|
||||
uint32 data;
|
||||
};
|
||||
|
||||
struct QSTradeItems_Struct {
|
||||
uint32 from_id;
|
||||
uint16 from_slot;
|
||||
uint32 to_id;
|
||||
uint16 to_slot;
|
||||
uint32 item_id;
|
||||
uint16 charges;
|
||||
uint32 aug_1;
|
||||
uint32 aug_2;
|
||||
uint32 aug_3;
|
||||
uint32 aug_4;
|
||||
uint32 aug_5;
|
||||
};
|
||||
|
||||
struct QSPlayerLogTrade_Struct {
|
||||
uint32 char1_id;
|
||||
MoneyUpdate_Struct char1_money;
|
||||
uint16 char1_count;
|
||||
uint32 char2_id;
|
||||
MoneyUpdate_Struct char2_money;
|
||||
uint16 char2_count;
|
||||
uint16 _detail_count;
|
||||
QSTradeItems_Struct items[0];
|
||||
};
|
||||
|
||||
struct QSHandinItems_Struct {
|
||||
char action_type[7]; // handin, return or reward
|
||||
uint16 char_slot;
|
||||
uint32 item_id;
|
||||
uint16 charges;
|
||||
uint32 aug_1;
|
||||
uint32 aug_2;
|
||||
uint32 aug_3;
|
||||
uint32 aug_4;
|
||||
uint32 aug_5;
|
||||
};
|
||||
|
||||
struct QSPlayerLogHandin_Struct {
|
||||
uint32 quest_id;
|
||||
uint32 char_id;
|
||||
MoneyUpdate_Struct char_money;
|
||||
uint16 char_count;
|
||||
uint32 npc_id;
|
||||
MoneyUpdate_Struct npc_money;
|
||||
uint16 npc_count;
|
||||
uint16 _detail_count;
|
||||
QSHandinItems_Struct items[0];
|
||||
};
|
||||
|
||||
struct QSPlayerLogNPCKillSub_Struct{
|
||||
uint32 NPCID;
|
||||
uint32 ZoneID;
|
||||
uint32 Type;
|
||||
};
|
||||
|
||||
struct QSPlayerLogNPCKillsPlayers_Struct{
|
||||
uint32 char_id;
|
||||
};
|
||||
|
||||
struct QSPlayerLogNPCKill_Struct{
|
||||
QSPlayerLogNPCKillSub_Struct s1;
|
||||
QSPlayerLogNPCKillsPlayers_Struct Chars[0];
|
||||
};
|
||||
|
||||
struct QSDeleteItems_Struct {
|
||||
uint16 char_slot;
|
||||
uint32 item_id;
|
||||
uint16 charges;
|
||||
uint32 aug_1;
|
||||
uint32 aug_2;
|
||||
uint32 aug_3;
|
||||
uint32 aug_4;
|
||||
uint32 aug_5;
|
||||
};
|
||||
|
||||
struct QSPlayerLogDelete_Struct {
|
||||
uint32 char_id;
|
||||
uint16 stack_size; // '0' indicates full stack or non-stackable item move
|
||||
uint16 char_count;
|
||||
QSDeleteItems_Struct items[0];
|
||||
};
|
||||
|
||||
struct QSMoveItems_Struct {
|
||||
uint16 from_slot;
|
||||
uint16 to_slot;
|
||||
uint32 item_id;
|
||||
uint16 charges;
|
||||
uint32 aug_1;
|
||||
uint32 aug_2;
|
||||
uint32 aug_3;
|
||||
uint32 aug_4;
|
||||
uint32 aug_5;
|
||||
};
|
||||
|
||||
struct QSPlayerLogMove_Struct {
|
||||
uint32 char_id;
|
||||
uint16 from_slot;
|
||||
uint16 to_slot;
|
||||
uint16 stack_size; // '0' indicates full stack or non-stackable item move
|
||||
uint16 char_count;
|
||||
bool postaction;
|
||||
QSMoveItems_Struct items[0];
|
||||
};
|
||||
|
||||
struct QSTransactionItems_Struct {
|
||||
uint16 char_slot;
|
||||
uint32 item_id;
|
||||
uint16 charges;
|
||||
uint32 aug_1;
|
||||
uint32 aug_2;
|
||||
uint32 aug_3;
|
||||
uint32 aug_4;
|
||||
uint32 aug_5;
|
||||
};
|
||||
|
||||
struct QSMerchantLogTransaction_Struct {
|
||||
uint32 zone_id;
|
||||
uint32 merchant_id;
|
||||
MoneyUpdate_Struct merchant_money;
|
||||
uint16 merchant_count;
|
||||
uint32 char_id;
|
||||
MoneyUpdate_Struct char_money;
|
||||
uint16 char_count;
|
||||
QSTransactionItems_Struct items[0];
|
||||
};
|
||||
|
||||
struct QSGeneralQuery_Struct {
|
||||
char QueryString[0];
|
||||
};
|
||||
|
||||
+3
-3
@@ -1255,7 +1255,7 @@ ItemInst* SharedDatabase::CreateBaseItemOld(const ItemData* item, int16 charges)
|
||||
return inst;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> SharedDatabase::CreateItem(uint32 item_id, int16 charges, bool unique) {
|
||||
EQEmu::ItemInstance::pointer SharedDatabase::CreateItem(uint32 item_id, int16 charges, bool unique) {
|
||||
const ItemData* item = GetItem(item_id);
|
||||
if(item) {
|
||||
if(charges == 0 && item->MaxCharges == -1) {
|
||||
@@ -1266,7 +1266,7 @@ std::shared_ptr<EQEmu::ItemInstance> SharedDatabase::CreateItem(uint32 item_id,
|
||||
charges = 1;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQEmu::ItemInstance> inst = std::shared_ptr<EQEmu::ItemInstance>(new EQEmu::ItemInstance(item, charges));
|
||||
EQEmu::ItemInstance::pointer inst = EQEmu::ItemInstance::pointer(new EQEmu::ItemInstance(item, charges));
|
||||
if(unique) {
|
||||
inst->SetSerialNumber(EQEmu::GetNextItemInstanceSerial());
|
||||
//Set Tracking here
|
||||
@@ -1274,7 +1274,7 @@ std::shared_ptr<EQEmu::ItemInstance> SharedDatabase::CreateItem(uint32 item_id,
|
||||
return inst;
|
||||
}
|
||||
|
||||
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
|
||||
return EQEmu::ItemInstance::pointer(nullptr);
|
||||
}
|
||||
|
||||
int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ class SharedDatabase : public Database
|
||||
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, bool unique = true);
|
||||
EQEmu::ItemInstance::pointer CreateItem(uint32 item_id, int16 charges = 0, bool unique = true);
|
||||
|
||||
/*
|
||||
Shared Memory crap
|
||||
|
||||
Reference in New Issue
Block a user