mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Merchant buying in flux but it works better now
This commit is contained in:
parent
bbc3733c3a
commit
46cb96a026
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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];
|
||||
};
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -123,229 +123,6 @@ void Database::AddSpeech(const char* from, const char* to, const char* message,
|
||||
|
||||
}
|
||||
|
||||
void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 detailCount) {
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_trade_record` SET `time` = NOW(), "
|
||||
"`char1_id` = '%i', `char1_pp` = '%i', `char1_gp` = '%i', "
|
||||
"`char1_sp` = '%i', `char1_cp` = '%i', `char1_items` = '%i', "
|
||||
"`char2_id` = '%i', `char2_pp` = '%i', `char2_gp` = '%i', "
|
||||
"`char2_sp` = '%i', `char2_cp` = '%i', `char2_items` = '%i'",
|
||||
QS->char1_id, QS->char1_money.platinum, QS->char1_money.gold,
|
||||
QS->char1_money.silver, QS->char1_money.copper, QS->char1_count,
|
||||
QS->char2_id, QS->char2_money.platinum, QS->char2_money.gold,
|
||||
QS->char2_money.silver, QS->char2_money.copper, QS->char2_count);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Trade Log Record Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
if(detailCount == 0)
|
||||
return;
|
||||
|
||||
int lastIndex = results.LastInsertedID();
|
||||
|
||||
for(int i = 0; i < detailCount; i++) {
|
||||
query = StringFormat("INSERT INTO `qs_player_trade_record_entries` SET `event_id` = '%i', "
|
||||
"`from_id` = '%i', `from_slot` = '%i', `to_id` = '%i', `to_slot` = '%i', "
|
||||
"`item_id` = '%i', `charges` = '%i', `aug_1` = '%i', `aug_2` = '%i', "
|
||||
"`aug_3` = '%i', `aug_4` = '%i', `aug_5` = '%i'",
|
||||
lastIndex, QS->items[i].from_id, QS->items[i].from_slot,
|
||||
QS->items[i].to_id, QS->items[i].to_slot, QS->items[i].item_id,
|
||||
QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2,
|
||||
QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5);
|
||||
results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Trade Log Record Entry Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 detailCount) {
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_handin_record` SET `time` = NOW(), "
|
||||
"`quest_id` = '%i', `char_id` = '%i', `char_pp` = '%i', "
|
||||
"`char_gp` = '%i', `char_sp` = '%i', `char_cp` = '%i', "
|
||||
"`char_items` = '%i', `npc_id` = '%i', `npc_pp` = '%i', "
|
||||
"`npc_gp` = '%i', `npc_sp` = '%i', `npc_cp` = '%i', "
|
||||
"`npc_items`='%i'",
|
||||
QS->quest_id, QS->char_id, QS->char_money.platinum,
|
||||
QS->char_money.gold, QS->char_money.silver, QS->char_money.copper,
|
||||
QS->char_count, QS->npc_id, QS->npc_money.platinum,
|
||||
QS->npc_money.gold, QS->npc_money.silver, QS->npc_money.copper,
|
||||
QS->npc_count);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Handin Log Record Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
if(detailCount == 0)
|
||||
return;
|
||||
|
||||
int lastIndex = results.LastInsertedID();
|
||||
|
||||
for(int i = 0; i < detailCount; i++) {
|
||||
query = StringFormat("INSERT INTO `qs_player_handin_record_entries` SET `event_id` = '%i', "
|
||||
"`action_type` = '%s', `char_slot` = '%i', `item_id` = '%i', "
|
||||
"`charges` = '%i', `aug_1` = '%i', `aug_2` = '%i', `aug_3` = '%i', "
|
||||
"`aug_4` = '%i', `aug_5` = '%i'",
|
||||
lastIndex, QS->items[i].action_type, QS->items[i].char_slot,
|
||||
QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1,
|
||||
QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4,
|
||||
QS->items[i].aug_5);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Handin Log Record Entry Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 members){
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_npc_kill_record` "
|
||||
"SET `npc_id` = '%i', `type` = '%i', "
|
||||
"`zone_id` = '%i', `time` = NOW()",
|
||||
QS->s1.NPCID, QS->s1.Type, QS->s1.ZoneID);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed NPC Kill Log Record Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
if(members == 0)
|
||||
return;
|
||||
|
||||
int lastIndex = results.LastInsertedID();
|
||||
|
||||
for (int i = 0; i < members; i++) {
|
||||
query = StringFormat("INSERT INTO `qs_player_npc_kill_record_entries` "
|
||||
"SET `event_id` = '%i', `char_id` = '%i'",
|
||||
lastIndex, QS->Chars[i].char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed NPC Kill Log Entry Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 items) {
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_delete_record` SET `time` = NOW(), "
|
||||
"`char_id` = '%i', `stack_size` = '%i', `char_items` = '%i'",
|
||||
QS->char_id, QS->stack_size, QS->char_count, QS->char_count);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
if(items == 0)
|
||||
return;
|
||||
|
||||
int lastIndex = results.LastInsertedID();
|
||||
|
||||
for(int i = 0; i < items; i++) {
|
||||
query = StringFormat("INSERT INTO `qs_player_delete_record_entries` SET `event_id` = '%i', "
|
||||
"`char_slot` = '%i', `item_id` = '%i', `charges` = '%i', `aug_1` = '%i', "
|
||||
"`aug_2` = '%i', `aug_3` = '%i', `aug_4` = '%i', `aug_5` = '%i'",
|
||||
lastIndex, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges,
|
||||
QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4,
|
||||
QS->items[i].aug_5);
|
||||
results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Entry Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 items) {
|
||||
/* These are item moves */
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_move_record` SET `time` = NOW(), "
|
||||
"`char_id` = '%i', `from_slot` = '%i', `to_slot` = '%i', "
|
||||
"`stack_size` = '%i', `char_items` = '%i', `postaction` = '%i'",
|
||||
QS->char_id, QS->from_slot, QS->to_slot, QS->stack_size,
|
||||
QS->char_count, QS->postaction);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Move Log Record Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
if(items == 0)
|
||||
return;
|
||||
|
||||
int lastIndex = results.LastInsertedID();
|
||||
|
||||
for(int i = 0; i < items; i++) {
|
||||
query = StringFormat("INSERT INTO `qs_player_move_record_entries` SET `event_id` = '%i', "
|
||||
"`from_slot` = '%i', `to_slot` = '%i', `item_id` = '%i', `charges` = '%i', "
|
||||
"`aug_1` = '%i', `aug_2` = '%i', `aug_3` = '%i', `aug_4` = '%i', `aug_5` = '%i'",
|
||||
lastIndex, QS->items[i].from_slot, QS->items[i].to_slot, QS->items[i].item_id,
|
||||
QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2,
|
||||
QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5);
|
||||
results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Move Log Record Entry Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 items) {
|
||||
/* Merchant transactions are from the perspective of the merchant, not the player */
|
||||
std::string query = StringFormat("INSERT INTO `qs_merchant_transaction_record` SET `time` = NOW(), "
|
||||
"`zone_id` = '%i', `merchant_id` = '%i', `merchant_pp` = '%i', "
|
||||
"`merchant_gp` = '%i', `merchant_sp` = '%i', `merchant_cp` = '%i', "
|
||||
"`merchant_items` = '%i', `char_id` = '%i', `char_pp` = '%i', "
|
||||
"`char_gp` = '%i', `char_sp` = '%i', `char_cp` = '%i', "
|
||||
"`char_items` = '%i'",
|
||||
QS->zone_id, QS->merchant_id, QS->merchant_money.platinum,
|
||||
QS->merchant_money.gold, QS->merchant_money.silver,
|
||||
QS->merchant_money.copper, QS->merchant_count, QS->char_id,
|
||||
QS->char_money.platinum, QS->char_money.gold, QS->char_money.silver,
|
||||
QS->char_money.copper, QS->char_count);
|
||||
auto results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Transaction Log Record Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
if(items == 0)
|
||||
return;
|
||||
|
||||
int lastIndex = results.LastInsertedID();
|
||||
|
||||
for(int i = 0; i < items; i++) {
|
||||
query = StringFormat("INSERT INTO `qs_merchant_transaction_record_entries` SET `event_id` = '%i', "
|
||||
"`char_slot` = '%i', `item_id` = '%i', `charges` = '%i', `aug_1` = '%i', "
|
||||
"`aug_2` = '%i', `aug_3` = '%i', `aug_4` = '%i', `aug_5` = '%i'",
|
||||
lastIndex, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges,
|
||||
QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4,
|
||||
QS->items[i].aug_5);
|
||||
results = QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Transaction Log Record Entry Insert: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Database::GeneralQueryReceive(ServerPacket *pack) {
|
||||
/*
|
||||
These are general queries passed from anywhere in zone instead of packing structures and breaking them down again and again
|
||||
|
||||
@ -44,12 +44,6 @@ public:
|
||||
~Database();
|
||||
|
||||
void AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type);
|
||||
void LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 DetailCount);
|
||||
void LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 DetailCount);
|
||||
void LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members);
|
||||
void LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items);
|
||||
void LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items);
|
||||
void LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 Items);
|
||||
void GeneralQueryReceive(ServerPacket *pack);
|
||||
|
||||
void LoadLogSettings(EQEmuLogSys::LogSettings* log_settings);
|
||||
|
||||
@ -81,41 +81,6 @@ void WorldServer::Process()
|
||||
database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogTrades: {
|
||||
QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)pack->pBuffer;
|
||||
database.LogPlayerTrade(QS, QS->_detail_count);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogHandins: {
|
||||
QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)pack->pBuffer;
|
||||
database.LogPlayerHandin(QS, QS->_detail_count);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogNPCKills: {
|
||||
QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
|
||||
uint32 Members = pack->size - sizeof(QSPlayerLogNPCKill_Struct);
|
||||
if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct);
|
||||
database.LogPlayerNPCKill(QS, Members);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogDeletes: {
|
||||
QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count;
|
||||
database.LogPlayerDelete(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogMoves: {
|
||||
QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count;
|
||||
database.LogPlayerMove(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogMerchantTransactions: {
|
||||
QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count + QS->merchant_count;
|
||||
database.LogMerchantTransaction(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QueryServGeneric: {
|
||||
/*
|
||||
The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets
|
||||
|
||||
@ -147,10 +147,10 @@ private:
|
||||
|
||||
void InitInventory()
|
||||
{
|
||||
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, 100));
|
||||
EQEmu::ItemInstance::pointer m_bag(new EQEmu::ItemInstance(&container));
|
||||
EQEmu::ItemInstance::pointer m_armor(new EQEmu::ItemInstance(&armor));
|
||||
EQEmu::ItemInstance::pointer m_augment(new EQEmu::ItemInstance(&augment));
|
||||
EQEmu::ItemInstance::pointer m_stackable(new EQEmu::ItemInstance(&stackable, 100));
|
||||
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1), m_bag);
|
||||
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, 0), m_armor);
|
||||
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, 1), m_augment);
|
||||
@ -294,7 +294,7 @@ private:
|
||||
}
|
||||
|
||||
void InventorySplitStackToCursor2() {
|
||||
std::shared_ptr<EQEmu::ItemInstance> m_stackable_i(new EQEmu::ItemInstance(&stackable, 10));
|
||||
EQEmu::ItemInstance::pointer m_stackable_i(new EQEmu::ItemInstance(&stackable, 10));
|
||||
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral2, 8), m_stackable_i);
|
||||
|
||||
auto swap_result = inv.Swap(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral2, 8),
|
||||
|
||||
@ -1268,15 +1268,8 @@ bool ZoneServer::Process() {
|
||||
UCSLink.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSSendQuery:
|
||||
case ServerOP_QueryServGeneric:
|
||||
case ServerOP_Speech:
|
||||
case ServerOP_QSPlayerLogTrades:
|
||||
case ServerOP_QSPlayerLogHandins:
|
||||
case ServerOP_QSPlayerLogNPCKills:
|
||||
case ServerOP_QSPlayerLogDeletes:
|
||||
case ServerOP_QSPlayerLogMoves:
|
||||
case ServerOP_QSPlayerLogMerchantTransactions:
|
||||
{
|
||||
QSLink.SendPacket(pack);
|
||||
break;
|
||||
|
||||
14
zone/aa.cpp
14
zone/aa.cpp
@ -1035,24 +1035,12 @@ void Client::BuyAA(AA_Action* action)
|
||||
*/
|
||||
|
||||
/* Initial purchase of an AA ability */
|
||||
if (cur_level < 1){
|
||||
if (cur_level < 1) {
|
||||
Message(15, "You have gained the ability \"%s\" at a cost of %d ability %s.", aa2->name, real_cost, (real_cost>1) ? "points" : "point");
|
||||
|
||||
/* QS: Player_Log_AA_Purchases */
|
||||
if (RuleB(QueryServ, PlayerLogAAPurchases)){
|
||||
std::string event_desc = StringFormat("Initial AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
/* Ranked purchase of an AA ability */
|
||||
else{
|
||||
Message(15, "You have improved %s %d at a cost of %d ability %s.", aa2->name, cur_level + 1, real_cost, (real_cost > 1) ? "points" : "point");
|
||||
|
||||
/* QS: Player_Log_AA_Purchases */
|
||||
if (RuleB(QueryServ, PlayerLogAAPurchases)){
|
||||
std::string event_desc = StringFormat("Ranked AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
SendAAStats();
|
||||
|
||||
@ -1706,14 +1706,6 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att
|
||||
GoToDeath();
|
||||
}
|
||||
|
||||
/* QS: PlayerLogDeaths */
|
||||
if (RuleB(QueryServ, PlayerLogDeaths)){
|
||||
const char * killer_name = "";
|
||||
if (killerMob && killerMob->GetCleanName()){ killer_name = killerMob->GetCleanName(); }
|
||||
std::string event_desc = StringFormat("Died in zoneid:%i instid:%i by '%s', spellid:%i, damage:%i", this->GetZoneID(), this->GetInstanceID(), killer_name, spell, damage);
|
||||
QServ->PlayerLogEvent(Player_Log_Deaths, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
parse->EventPlayer(EVENT_DEATH_COMPLETE, this, buffer, 0);
|
||||
return true;
|
||||
}
|
||||
@ -2180,27 +2172,6 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// QueryServ Logging - Raid Kills
|
||||
if(RuleB(QueryServ, PlayerLogNPCKills)){
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, sizeof(QSPlayerLogNPCKill_Struct) + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount));
|
||||
PlayerCount = 0;
|
||||
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
|
||||
QS->s1.NPCID = this->GetNPCTypeID();
|
||||
QS->s1.ZoneID = this->GetZoneID();
|
||||
QS->s1.Type = 2; // Raid Fight
|
||||
for (int i = 0; i < MAX_RAID_MEMBERS; i++) {
|
||||
if (kr->members[i].member != nullptr && kr->members[i].member->IsClient()) { // If Group Member is Client
|
||||
Client *c = kr->members[i].member;
|
||||
QS->Chars[PlayerCount].char_id = c->CharacterID();
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
worldserver.SendPacket(pack); // Send Packet to World
|
||||
safe_delete(pack);
|
||||
}
|
||||
// End QueryServ Logging
|
||||
|
||||
}
|
||||
else if (give_exp_client->IsGrouped() && kg != nullptr)
|
||||
{
|
||||
@ -2227,26 +2198,6 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// QueryServ Logging - Group Kills
|
||||
if(RuleB(QueryServ, PlayerLogNPCKills)){
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, sizeof(QSPlayerLogNPCKill_Struct) + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount));
|
||||
PlayerCount = 0;
|
||||
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
|
||||
QS->s1.NPCID = this->GetNPCTypeID();
|
||||
QS->s1.ZoneID = this->GetZoneID();
|
||||
QS->s1.Type = 1; // Group Fight
|
||||
for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
||||
if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client
|
||||
Client *c = kg->members[i]->CastToClient();
|
||||
QS->Chars[PlayerCount].char_id = c->CharacterID();
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
worldserver.SendPacket(pack); // Send Packet to World
|
||||
safe_delete(pack);
|
||||
}
|
||||
// End QueryServ Logging
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2273,21 +2224,6 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem))
|
||||
give_exp_client->UpdateTasksOnKill(GetNPCTypeID());
|
||||
|
||||
// QueryServ Logging - Solo
|
||||
if(RuleB(QueryServ, PlayerLogNPCKills)){
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, sizeof(QSPlayerLogNPCKill_Struct) + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * 1));
|
||||
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
|
||||
QS->s1.NPCID = this->GetNPCTypeID();
|
||||
QS->s1.ZoneID = this->GetZoneID();
|
||||
QS->s1.Type = 0; // Solo Fight
|
||||
Client *c = give_exp_client;
|
||||
QS->Chars[0].char_id = c->CharacterID();
|
||||
PlayerCount++;
|
||||
worldserver.SendPacket(pack); // Send Packet to World
|
||||
safe_delete(pack);
|
||||
}
|
||||
// End QueryServ Logging
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
150
zone/client.cpp
150
zone/client.cpp
@ -2113,79 +2113,18 @@ bool Client::TakeMoneyFromPP(uint64 copper, bool updateclient) {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::AddMoneyToPP(uint64 copper, bool updateclient){
|
||||
uint64 tmp;
|
||||
uint64 tmp2;
|
||||
tmp = copper;
|
||||
void Client::AddMoneyToPP(uint64 copper, bool updateclient) {
|
||||
|
||||
/* Add Amount of Platinum */
|
||||
tmp2 = tmp/1000;
|
||||
int32 new_val = m_pp.platinum + tmp2;
|
||||
if(new_val < 0) { m_pp.platinum = 0; }
|
||||
else { m_pp.platinum = m_pp.platinum + tmp2; }
|
||||
tmp-=tmp2*1000;
|
||||
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(3,tmp2);
|
||||
|
||||
/* Add Amount of Gold */
|
||||
tmp2 = tmp/100;
|
||||
new_val = m_pp.gold + tmp2;
|
||||
if(new_val < 0) { m_pp.gold = 0; }
|
||||
else { m_pp.gold = m_pp.gold + tmp2; }
|
||||
|
||||
tmp-=tmp2*100;
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(2,tmp2);
|
||||
|
||||
/* Add Amount of Silver */
|
||||
tmp2 = tmp/10;
|
||||
new_val = m_pp.silver + tmp2;
|
||||
if(new_val < 0) {
|
||||
m_pp.silver = 0;
|
||||
} else {
|
||||
m_pp.silver = m_pp.silver + tmp2;
|
||||
}
|
||||
tmp-=tmp2*10;
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(1,tmp2);
|
||||
|
||||
// Add Copper
|
||||
//tmp = tmp - (tmp2* 10);
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(0,tmp);
|
||||
tmp2 = tmp;
|
||||
new_val = m_pp.copper + tmp2;
|
||||
if(new_val < 0) {
|
||||
m_pp.copper = 0;
|
||||
} else {
|
||||
m_pp.copper = m_pp.copper + tmp2;
|
||||
}
|
||||
|
||||
|
||||
//send them all at once, since the above code stopped working.
|
||||
if(updateclient)
|
||||
SendMoneyUpdate();
|
||||
|
||||
RecalcWeight();
|
||||
|
||||
SaveCurrency();
|
||||
|
||||
Log.Out(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
|
||||
uint64 plat = copper / 1000;
|
||||
copper -= plat * 1000;
|
||||
uint64 gold = copper / 100;
|
||||
copper -= gold * 100;
|
||||
uint64 silver = copper / 10;
|
||||
copper -= silver * 10;
|
||||
AddMoneyToPP(copper, silver, gold, plat, updateclient);
|
||||
}
|
||||
|
||||
void Client::ItemScriptStopReturn(){
|
||||
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
|
||||
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
|
||||
*/
|
||||
struct timeval read_time;
|
||||
char buffer[50];
|
||||
gettimeofday(&read_time, 0);
|
||||
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
|
||||
SetEntityVariable("Stop_Return", buffer);
|
||||
}
|
||||
|
||||
void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient){
|
||||
void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient) {
|
||||
ItemScriptStopReturn();
|
||||
|
||||
int32 new_value = m_pp.platinum + platinum;
|
||||
@ -2209,11 +2148,17 @@ void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 plat
|
||||
|
||||
RecalcWeight();
|
||||
SaveCurrency();
|
||||
}
|
||||
|
||||
#if (EQDEBUG>=5)
|
||||
Log.Out(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i",
|
||||
GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
|
||||
#endif
|
||||
void Client::ItemScriptStopReturn() {
|
||||
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
|
||||
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
|
||||
*/
|
||||
struct timeval read_time;
|
||||
char buffer[50];
|
||||
gettimeofday(&read_time, 0);
|
||||
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
|
||||
SetEntityVariable("Stop_Return", buffer);
|
||||
}
|
||||
|
||||
void Client::SendMoneyUpdate() {
|
||||
@ -2517,31 +2462,32 @@ void Client::SetFeigned(bool in_feigned) {
|
||||
|
||||
void Client::LogMerchant(Client* player, Mob* merchant, uint32 quantity, uint32 price, const ItemData* item, bool buying)
|
||||
{
|
||||
if(!player || !merchant || !item)
|
||||
return;
|
||||
|
||||
std::string LogText = "Qty: ";
|
||||
|
||||
char Buffer[255];
|
||||
memset(Buffer, 0, sizeof(Buffer));
|
||||
|
||||
snprintf(Buffer, sizeof(Buffer)-1, "%3i", quantity);
|
||||
LogText += Buffer;
|
||||
snprintf(Buffer, sizeof(Buffer)-1, "%10i", price);
|
||||
LogText += " TotalValue: ";
|
||||
LogText += Buffer;
|
||||
snprintf(Buffer, sizeof(Buffer)-1, " ItemID: %7i", item->ID);
|
||||
LogText += Buffer;
|
||||
LogText += " ";
|
||||
snprintf(Buffer, sizeof(Buffer)-1, " %s", item->Name);
|
||||
LogText += Buffer;
|
||||
|
||||
if (buying==true) {
|
||||
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Buying from Merchant",LogText.c_str(),2);
|
||||
}
|
||||
else {
|
||||
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Selling to Merchant",LogText.c_str(),3);
|
||||
}
|
||||
//Inv2 redo or remove
|
||||
//if(!player || !merchant || !item)
|
||||
// return;
|
||||
//
|
||||
//std::string LogText = "Qty: ";
|
||||
//
|
||||
//char Buffer[255];
|
||||
//memset(Buffer, 0, sizeof(Buffer));
|
||||
//
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, "%3i", quantity);
|
||||
//LogText += Buffer;
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, "%10i", price);
|
||||
//LogText += " TotalValue: ";
|
||||
//LogText += Buffer;
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, " ItemID: %7i", item->ID);
|
||||
//LogText += Buffer;
|
||||
//LogText += " ";
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, " %s", item->Name);
|
||||
//LogText += Buffer;
|
||||
//
|
||||
//if (buying==true) {
|
||||
// database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Buying from Merchant",LogText.c_str(),2);
|
||||
//}
|
||||
//else {
|
||||
// database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Selling to Merchant",LogText.c_str(),3);
|
||||
//}
|
||||
}
|
||||
|
||||
bool Client::BindWound(Mob* bindmob, bool start, bool fail){
|
||||
@ -6922,11 +6868,7 @@ void Client::AddAlternateCurrencyValue(uint32 currency_id, int32 amount, int8 me
|
||||
|
||||
/* Added via Quest, rest of the logging methods may be done inline due to information available in that area of the code */
|
||||
if (method == 1){
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Added via Quest :: Cursor to Item :: alt_currency_id:%i amount:%i in zoneid:%i instid:%i", currency_id, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(amount == 0) {
|
||||
|
||||
@ -245,8 +245,6 @@ public:
|
||||
virtual bool IsClient() const { return true; }
|
||||
void CompleteConnect();
|
||||
bool TryStacking(ItemInst* item, uint8 type = ItemPacketTrade, bool try_worn = true, bool try_cursor = true);
|
||||
bool TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, uint8 type = ItemPacketTrade, bool try_worn = true, bool try_cursor = true);
|
||||
bool TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, const EQEmu::InventorySlot &slot, uint8 type = ItemPacketTrade);
|
||||
void SendTraderPacket(Client* trader, uint32 Unknown72 = 51);
|
||||
void SendBuyerPacket(Client* Buyer);
|
||||
GetItems_Struct* GetTraderItems();
|
||||
@ -818,7 +816,6 @@ public:
|
||||
void DeleteItemInInventory(int16 slot_id, int8 quantity = 0, bool client_update = false, bool update_db = true);
|
||||
bool SwapItem(MoveItemOld_Struct* move_in);
|
||||
void SwapItemResync(MoveItemOld_Struct* move_slots);
|
||||
void QSSwapItemAuditor(MoveItemOld_Struct* move_in, bool postaction_call = false);
|
||||
void PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootItem_Struct** bag_item_data = 0);
|
||||
bool AutoPutLootInInventory(ItemInst& inst, bool try_worn = false, bool try_cursor = true, ServerLootItem_Struct** bag_item_data = 0);
|
||||
bool SummonItem(uint32 item_id, int16 charges = -1,
|
||||
@ -844,7 +841,10 @@ public:
|
||||
uint32 ornament_icon = 0,
|
||||
uint32 ornament_idfile = 0,
|
||||
uint32 ornament_hero_model = 0);
|
||||
bool PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, bool client_update = false);
|
||||
bool PutItemInInventory(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, bool client_update = false);
|
||||
bool CanPutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end);
|
||||
void StackItem(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update);
|
||||
void PutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update);
|
||||
|
||||
//
|
||||
// class Client::TextLink
|
||||
@ -902,7 +902,7 @@ public:
|
||||
bool IsBankSlot(uint32 slot);
|
||||
|
||||
//inv2
|
||||
void SendItemPacket(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, ItemPacketType packet_type);
|
||||
void SendItemPacket(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, ItemPacketType packet_type);
|
||||
|
||||
inline bool IsTrader() const { return(Trader); }
|
||||
inline bool IsBuyer() const { return(Buyer); }
|
||||
|
||||
@ -783,11 +783,6 @@ void Client::CompleteConnect()
|
||||
/* This sub event is for if a player logs in for the first time since entering world. */
|
||||
if (firstlogon == 1){
|
||||
parse->EventPlayer(EVENT_CONNECT, this, "", 0);
|
||||
/* QS: PlayerLogConnectDisconnect */
|
||||
if (RuleB(QueryServ, PlayerLogConnectDisconnect)){
|
||||
std::string event_desc = StringFormat("Connect :: Logged into zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone) {
|
||||
@ -2585,12 +2580,6 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Merchant Purchase */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Merchant Purchase :: Spent alt_currency_id:%i cost:%i for itemid:%i in zoneid:%i instid:%i", alt_cur_id, cost, item->ID, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
AddAlternateCurrencyValue(alt_cur_id, -((int32)cost));
|
||||
int16 charges = 1;
|
||||
if (item->MaxCharges != 0)
|
||||
@ -2628,12 +2617,6 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app)
|
||||
uint32 removed = NukeItem(item_id, invWhereWorn | invWherePersonal | invWhereCursor);
|
||||
if (removed > 0) {
|
||||
AddAlternateCurrencyValue(reclaim->currency_id, removed);
|
||||
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Item to Currency */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Reclaim :: Item to Currency :: alt_currency_id:%i amount:%i to currency tab in zoneid:%i instid:%i", reclaim->currency_id, removed, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Cursor to Item storage */
|
||||
@ -2652,11 +2635,6 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app)
|
||||
SummonItem(item_id, reclaim->count, 0, 0, 0, 0, 0, 0, false, MainCursor);
|
||||
AddAlternateCurrencyValue(reclaim->currency_id, -((int32)reclaim->count));
|
||||
}
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Reclaim :: Cursor to Item :: alt_currency_id:%i amount:-%i in zoneid:%i instid:%i", reclaim->currency_id, reclaim->count, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2746,12 +2724,6 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app)
|
||||
|
||||
sell->cost = cost;
|
||||
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Sold to Merchant*/
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Sold to Merchant :: itemid:%u npcid:%u alt_currency_id:%u cost:%u in zoneid:%u instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
FastQueuePacket(&outapp);
|
||||
AddAlternateCurrencyValue(alt_cur_id, cost);
|
||||
Save(1);
|
||||
@ -12000,22 +11972,23 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
Merchant_Sell_Struct* mp = (Merchant_Sell_Struct*)app->pBuffer;
|
||||
|
||||
|
||||
int merchantid;
|
||||
bool tmpmer_used = false;
|
||||
Mob* tmp = entity_list.GetMob(mp->npcid);
|
||||
|
||||
|
||||
if (!tmp || !tmp->IsNPC() || tmp->GetClass() != MERCHANT)
|
||||
return;
|
||||
|
||||
if (mp->quantity < 1) return;
|
||||
|
||||
|
||||
if (mp->quantity < 1)
|
||||
return;
|
||||
|
||||
//you have to be somewhat close to them to be properly using them
|
||||
if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
|
||||
return;
|
||||
|
||||
|
||||
merchantid = tmp->CastToNPC()->MerchantType;
|
||||
|
||||
|
||||
uint32 item_id = 0;
|
||||
std::list<MerchantList> merlist = zone->merchanttable[merchantid];
|
||||
std::list<MerchantList>::const_iterator itr;
|
||||
@ -12024,18 +11997,18 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
if (GetLevel() < ml.level_required) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int32 fac = tmp->GetPrimaryFaction();
|
||||
if (fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (mp->itemslot == ml.slot){
|
||||
item_id = ml.item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const ItemData* item = nullptr;
|
||||
|
||||
uint32 prevcharges = 0;
|
||||
if (item_id == 0) { //check to see if its on the temporary table
|
||||
std::list<TempMerchantList> tmp_merlist = zone->tmpmerchanttable[tmp->GetNPCTypeID()];
|
||||
@ -12051,7 +12024,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
}
|
||||
}
|
||||
}
|
||||
item = database.GetItem(item_id);
|
||||
|
||||
const ItemData* item = database.GetItem(item_id);
|
||||
if (!item){
|
||||
//error finding item, client didnt get the update packet for whatever reason, roleplay a tad
|
||||
Message(15, "%s tells you 'Sorry, that item is for display purposes only.' as they take the item off the shelf.", tmp->GetCleanName());
|
||||
@ -12065,11 +12039,13 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
safe_delete(delitempacket);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_inventory.CheckLoreConflict(item))
|
||||
{
|
||||
Message(15, "You can only have one of a lore item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tmpmer_used && (mp->quantity > prevcharges || item->MaxCharges > 1))
|
||||
{
|
||||
if (prevcharges > item->MaxCharges && item->MaxCharges > 1)
|
||||
@ -12077,88 +12053,75 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
else
|
||||
mp->quantity = prevcharges;
|
||||
}
|
||||
|
||||
|
||||
// Item's stackable, but the quantity they want to buy exceeds the max stackable quantity.
|
||||
if (item->Stackable && mp->quantity > item->StackSize)
|
||||
mp->quantity = item->StackSize;
|
||||
|
||||
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerBuy, sizeof(Merchant_Sell_Struct));
|
||||
Merchant_Sell_Struct* mpo = (Merchant_Sell_Struct*)outapp->pBuffer;
|
||||
mpo->quantity = mp->quantity;
|
||||
mpo->playerid = mp->playerid;
|
||||
mpo->npcid = mp->npcid;
|
||||
mpo->itemslot = mp->itemslot;
|
||||
|
||||
|
||||
EQEmu::InventorySlot free_slot;
|
||||
int16 charges = 0;
|
||||
int charges = 0;
|
||||
if (item->Stackable || item->MaxCharges > 1)
|
||||
charges = mp->quantity;
|
||||
else
|
||||
charges = item->MaxCharges;
|
||||
|
||||
auto inst = database.CreateItem(item->ID, charges);
|
||||
|
||||
|
||||
int SinglePrice = 0;
|
||||
if (RuleB(Merchant, UsePriceMod))
|
||||
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(tmp, false));
|
||||
else
|
||||
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate);
|
||||
|
||||
|
||||
if (item->MaxCharges > 1)
|
||||
mpo->price = SinglePrice;
|
||||
else
|
||||
mpo->price = SinglePrice * mp->quantity;
|
||||
|
||||
|
||||
if (mpo->price < 0)
|
||||
{
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_inventory.Get(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor))) {
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
auto inst = database.CreateItem(item->ID, charges);
|
||||
|
||||
if(!CanPutItemInInventory(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10)) {
|
||||
Message(13, "You do not have room for any more items.");
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
// this area needs some work..two inventory insertion check failure points
|
||||
// below do not return player's money..is this the intended behavior?
|
||||
|
||||
if (!TakeMoneyFromPP(mpo->price))
|
||||
{
|
||||
char *hacker_str = nullptr;
|
||||
MakeAnyLenString(&hacker_str, "Vendor Cheat: attempted to buy %i of %i: %s that cost %d cp but only has %d pp %d gp %d sp %d cp\n",
|
||||
std::string hacker_str = StringFormat("Vendor Cheat: attempted to buy %i of %i: %s that cost %d cp but only has %d pp %d gp %d sp %d cp\n",
|
||||
mpo->quantity, item->ID, item->Name,
|
||||
mpo->price, m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
|
||||
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
|
||||
safe_delete_array(hacker_str);
|
||||
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str.c_str(), zone->GetShortName());
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
bool stacked = TryStacking(inst);
|
||||
if(!stacked) {
|
||||
free_slot = m_inventory.FindFreeSlot(false, true, item->Size);
|
||||
}
|
||||
|
||||
if(free_slot.IsCursor()) {
|
||||
Message(13, "You do not have room for any more items.");
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!stacked && !free_slot.IsValid())
|
||||
{
|
||||
Message(13, "You do not have room for any more items.");
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string packet;
|
||||
if(!stacked && inst) {
|
||||
PutItemInInventory(free_slot, inst);
|
||||
SendItemPacket(free_slot, inst, ItemPacketTrade);
|
||||
}
|
||||
else if (!stacked){
|
||||
Log.Out(Logs::General, Logs::Error, "OP_ShopPlayerBuy: item->ItemClass Unknown! Type: %i", item->ItemClass);
|
||||
}
|
||||
|
||||
QueuePacket(outapp);
|
||||
if (inst && tmpmer_used){
|
||||
safe_delete(outapp);
|
||||
|
||||
PutItemInInventory(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10, true);
|
||||
|
||||
if (inst && tmpmer_used) {
|
||||
int32 new_charges = prevcharges - mp->quantity;
|
||||
zone->SaveTempItem(merchantid, tmp->GetNPCTypeID(), item_id, new_charges);
|
||||
if (new_charges <= 0){
|
||||
@ -12181,12 +12144,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
SendItemPacket(EQEmu::InventorySlot(EQEmu::InvTypeMerchant, mp->itemslot), inst, ItemPacketMerchant);
|
||||
}
|
||||
}
|
||||
safe_delete(outapp);
|
||||
|
||||
|
||||
if (RuleB(EventLog, RecordBuyFromMerchant))
|
||||
LogMerchant(this, tmp, mpo->quantity, mpo->price, item, true);
|
||||
|
||||
zone->LogEvent(EventLogItemBuy, this, StringFormat("Merc(%i) -> player %s(%i) %i charges for %ic", merchantid, item->Name, item->ID, mpo->quantity, mpo->price));
|
||||
if ((RuleB(Character, EnableDiscoveredItems)))
|
||||
{
|
||||
if (!GetGM() && !IsDiscovered(item_id))
|
||||
@ -12288,38 +12247,38 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
// start QS code
|
||||
if (RuleB(QueryServ, PlayerLogMerchantTransactions)) {
|
||||
ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, sizeof(QSMerchantLogTransaction_Struct)+sizeof(QSTransactionItems_Struct));
|
||||
QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer;
|
||||
|
||||
qsaudit->zone_id = zone->GetZoneID();
|
||||
qsaudit->merchant_id = vendor->CastToNPC()->MerchantType;
|
||||
qsaudit->merchant_money.platinum = (price / 1000);
|
||||
qsaudit->merchant_money.gold = (price / 100) % 10;
|
||||
qsaudit->merchant_money.silver = (price / 10) % 10;
|
||||
qsaudit->merchant_money.copper = price % 10;
|
||||
qsaudit->merchant_count = 0;
|
||||
qsaudit->char_id = character_id;
|
||||
qsaudit->char_money.platinum = 0;
|
||||
qsaudit->char_money.gold = 0;
|
||||
qsaudit->char_money.silver = 0;
|
||||
qsaudit->char_money.copper = 0;
|
||||
qsaudit->char_count = 1;
|
||||
|
||||
qsaudit->items[0].char_slot = mp->itemslot;
|
||||
qsaudit->items[0].item_id = itemid;
|
||||
qsaudit->items[0].charges = charges;
|
||||
qsaudit->items[0].aug_1 = m_inv[mp->itemslot]->GetAugmentItemID(1);
|
||||
qsaudit->items[0].aug_2 = m_inv[mp->itemslot]->GetAugmentItemID(2);
|
||||
qsaudit->items[0].aug_3 = m_inv[mp->itemslot]->GetAugmentItemID(3);
|
||||
qsaudit->items[0].aug_4 = m_inv[mp->itemslot]->GetAugmentItemID(4);
|
||||
qsaudit->items[0].aug_5 = m_inv[mp->itemslot]->GetAugmentItemID(5);
|
||||
|
||||
qspack->Deflate();
|
||||
if (worldserver.Connected()) { worldserver.SendPacket(qspack); }
|
||||
safe_delete(qspack);
|
||||
}
|
||||
// end QS code
|
||||
//if (RuleB(QueryServ, PlayerLogMerchantTransactions)) {
|
||||
// ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, sizeof(QSMerchantLogTransaction_Struct)+sizeof(QSTransactionItems_Struct));
|
||||
// QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer;
|
||||
//
|
||||
// qsaudit->zone_id = zone->GetZoneID();
|
||||
// qsaudit->merchant_id = vendor->CastToNPC()->MerchantType;
|
||||
// qsaudit->merchant_money.platinum = (price / 1000);
|
||||
// qsaudit->merchant_money.gold = (price / 100) % 10;
|
||||
// qsaudit->merchant_money.silver = (price / 10) % 10;
|
||||
// qsaudit->merchant_money.copper = price % 10;
|
||||
// qsaudit->merchant_count = 0;
|
||||
// qsaudit->char_id = character_id;
|
||||
// qsaudit->char_money.platinum = 0;
|
||||
// qsaudit->char_money.gold = 0;
|
||||
// qsaudit->char_money.silver = 0;
|
||||
// qsaudit->char_money.copper = 0;
|
||||
// qsaudit->char_count = 1;
|
||||
//
|
||||
// qsaudit->items[0].char_slot = mp->itemslot;
|
||||
// qsaudit->items[0].item_id = itemid;
|
||||
// qsaudit->items[0].charges = charges;
|
||||
// qsaudit->items[0].aug_1 = m_inv[mp->itemslot]->GetAugmentItemID(1);
|
||||
// qsaudit->items[0].aug_2 = m_inv[mp->itemslot]->GetAugmentItemID(2);
|
||||
// qsaudit->items[0].aug_3 = m_inv[mp->itemslot]->GetAugmentItemID(3);
|
||||
// qsaudit->items[0].aug_4 = m_inv[mp->itemslot]->GetAugmentItemID(4);
|
||||
// qsaudit->items[0].aug_5 = m_inv[mp->itemslot]->GetAugmentItemID(5);
|
||||
//
|
||||
// qspack->Deflate();
|
||||
// if (worldserver.Connected()) { worldserver.SendPacket(qspack); }
|
||||
// safe_delete(qspack);
|
||||
//}
|
||||
//// end QS code
|
||||
|
||||
// Now remove the item from the player, this happens regardless of outcome
|
||||
if (!inst->IsStackable())
|
||||
@ -13107,46 +13066,8 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
|
||||
other->trade->LogTrade();
|
||||
trade->LogTrade();
|
||||
|
||||
// start QS code
|
||||
if (RuleB(QueryServ, PlayerLogTrades)) {
|
||||
QSPlayerLogTrade_Struct event_entry;
|
||||
std::list<void*> event_details;
|
||||
|
||||
memset(&event_entry, 0, sizeof(QSPlayerLogTrade_Struct));
|
||||
|
||||
// Perform actual trade
|
||||
this->FinishTrade(other, true, &event_entry, &event_details);
|
||||
other->FinishTrade(this, false, &event_entry, &event_details);
|
||||
|
||||
event_entry._detail_count = event_details.size();
|
||||
|
||||
ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct)+(sizeof(QSTradeItems_Struct)* event_entry._detail_count));
|
||||
QSPlayerLogTrade_Struct* qs_buf = (QSPlayerLogTrade_Struct*)qs_pack->pBuffer;
|
||||
|
||||
memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogTrade_Struct));
|
||||
|
||||
int offset = 0;
|
||||
|
||||
for (std::list<void*>::iterator iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) {
|
||||
QSTradeItems_Struct* detail = reinterpret_cast<QSTradeItems_Struct*>(*iter);
|
||||
qs_buf->items[offset] = *detail;
|
||||
safe_delete(detail);
|
||||
}
|
||||
|
||||
event_details.clear();
|
||||
|
||||
qs_pack->Deflate();
|
||||
|
||||
if (worldserver.Connected())
|
||||
worldserver.SendPacket(qs_pack);
|
||||
|
||||
safe_delete(qs_pack);
|
||||
// end QS code
|
||||
}
|
||||
else {
|
||||
this->FinishTrade(other);
|
||||
other->FinishTrade(this);
|
||||
}
|
||||
this->FinishTrade(other);
|
||||
other->FinishTrade(this);
|
||||
|
||||
other->trade->Reset();
|
||||
trade->Reset();
|
||||
@ -13163,42 +13084,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
if (with->IsNPC()) {
|
||||
// Audit trade to database for player trade stream
|
||||
if (RuleB(QueryServ, PlayerLogHandins)) {
|
||||
QSPlayerLogHandin_Struct event_entry;
|
||||
std::list<void*> event_details;
|
||||
|
||||
memset(&event_entry, 0, sizeof(QSPlayerLogHandin_Struct));
|
||||
|
||||
FinishTrade(with->CastToNPC(), false, &event_entry, &event_details);
|
||||
|
||||
event_entry._detail_count = event_details.size();
|
||||
|
||||
ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct)+(sizeof(QSHandinItems_Struct)* event_entry._detail_count));
|
||||
QSPlayerLogHandin_Struct* qs_buf = (QSPlayerLogHandin_Struct*)qs_pack->pBuffer;
|
||||
|
||||
memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogHandin_Struct));
|
||||
|
||||
int offset = 0;
|
||||
|
||||
for (std::list<void*>::iterator iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) {
|
||||
QSHandinItems_Struct* detail = reinterpret_cast<QSHandinItems_Struct*>(*iter);
|
||||
qs_buf->items[offset] = *detail;
|
||||
safe_delete(detail);
|
||||
}
|
||||
|
||||
event_details.clear();
|
||||
|
||||
qs_pack->Deflate();
|
||||
|
||||
if (worldserver.Connected())
|
||||
worldserver.SendPacket(qs_pack);
|
||||
|
||||
safe_delete(qs_pack);
|
||||
}
|
||||
else {
|
||||
FinishTrade(with->CastToNPC());
|
||||
}
|
||||
FinishTrade(with->CastToNPC());
|
||||
}
|
||||
#ifdef BOTS
|
||||
// TODO: Log Bot trades
|
||||
|
||||
@ -782,12 +782,6 @@ void Client::OnDisconnect(bool hard_disconnect) {
|
||||
MyRaid->MemberZoned(this);
|
||||
|
||||
parse->EventPlayer(EVENT_DISCONNECT, this, "", 0);
|
||||
|
||||
/* QS: PlayerLogConnectDisconnect */
|
||||
if (RuleB(QueryServ, PlayerLogConnectDisconnect)){
|
||||
std::string event_desc = StringFormat("Disconnect :: in zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
Mob *Other = trade->With();
|
||||
|
||||
@ -547,8 +547,6 @@ int command_realdispatch(Client *c, const char *message)
|
||||
{
|
||||
Seperator sep(message, ' ', 10, 100, true); // "three word argument" should be considered 1 arg
|
||||
|
||||
command_logcommand(c, message);
|
||||
|
||||
std::string cstr(sep.arg[0]+1);
|
||||
|
||||
if(commandlist.count(cstr) != 1) {
|
||||
@ -561,12 +559,6 @@ int command_realdispatch(Client *c, const char *message)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* QS: Player_Log_Issued_Commands */
|
||||
if (RuleB(QueryServ, PlayerLogIssuedCommandes)){
|
||||
std::string event_desc = StringFormat("Issued command :: '%s' in zoneid:%i instid:%i", message, c->GetZoneID(), c->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Issued_Commands, c->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
if(cur->access >= COMMANDS_LOGGING_MIN_STATUS) {
|
||||
Log.Out(Logs::General, Logs::Commands, "%s (%s) used command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE");
|
||||
}
|
||||
@ -582,71 +574,6 @@ int command_realdispatch(Client *c, const char *message)
|
||||
|
||||
}
|
||||
|
||||
void command_logcommand(Client *c, const char *message)
|
||||
{
|
||||
int admin=c->Admin();
|
||||
|
||||
bool continueevents=false;
|
||||
switch (zone->loglevelvar){ //catch failsafe
|
||||
case 9: { // log only LeadGM
|
||||
if ((admin>= 150) && (admin <200))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 8: { // log only GM
|
||||
if ((admin>= 100) && (admin <150))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if ((admin>= 200))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if ((admin>= 150))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if ((admin>= 100))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if ((admin>= 80))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if ((admin>= 20))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if ((admin>= 10))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (continueevents)
|
||||
database.logevents(
|
||||
c->AccountName(),
|
||||
c->AccountID(),
|
||||
admin,c->GetName(),
|
||||
c->GetTarget()?c->GetTarget()->GetName():"None",
|
||||
"Command",
|
||||
message,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* commands go below here
|
||||
*/
|
||||
|
||||
@ -60,7 +60,6 @@ void command_deinit(void);
|
||||
int command_add(const char *command_string, const char *desc, int access, CmdFuncPtr function);
|
||||
int command_notavail(Client *c, const char *message);
|
||||
int command_realdispatch(Client *c, char const *message);
|
||||
void command_logcommand(Client *c, const char *message);
|
||||
|
||||
//commands
|
||||
void command_resetaa(Client* c,const Seperator *sep);
|
||||
|
||||
@ -3520,10 +3520,11 @@ XS(XS__qs_player_event)
|
||||
if (items != 2){
|
||||
Perl_croak(aTHX_ "Usage: qs_player_event(char_id, event_desc)");
|
||||
}
|
||||
else{
|
||||
else {
|
||||
int char_id = (int)SvIV(ST(0));
|
||||
std::string event_desc = (std::string)SvPV_nolen(ST(1));
|
||||
QServ->PlayerLogEvent(Player_Log_Quest, char_id, event_desc);
|
||||
Client *c = entity_list.GetClientByCharID(char_id);
|
||||
zone->LogEvent(EventLogQuest, c, event_desc);
|
||||
}
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
19
zone/exp.cpp
19
zone/exp.cpp
@ -430,13 +430,6 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) {
|
||||
//Message(15, "You have gained %d skill points!!", m_pp.aapoints - last_unspentAA);
|
||||
char val1[20]={0};
|
||||
Message_StringID(MT_Experience, GAIN_ABILITY_POINT,ConvertArray(m_pp.aapoints, val1),m_pp.aapoints == 1 ? "" : "(s)"); //You have gained an ability point! You now have %1 ability point%2.
|
||||
|
||||
/* QS: PlayerLogAARate */
|
||||
if (RuleB(QueryServ, PlayerLogAARate)){
|
||||
int add_points = (m_pp.aapoints - last_unspentAA);
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_aa_rate_hourly` (char_id, aa_count, hour_time) VALUES (%i, %i, UNIX_TIMESTAMP() - MOD(UNIX_TIMESTAMP(), 3600)) ON DUPLICATE KEY UPDATE `aa_count` = `aa_count` + %i", this->CharacterID(), add_points, add_points);
|
||||
QServ->SendQuery(query.c_str());
|
||||
}
|
||||
|
||||
//Message(15, "You now have %d skill points available to spend.", m_pp.aapoints);
|
||||
}
|
||||
@ -571,18 +564,6 @@ void Client::SetLevel(uint8 set_level, bool command)
|
||||
}
|
||||
if(set_level > m_pp.level) {
|
||||
parse->EventPlayer(EVENT_LEVEL_UP, this, "", 0);
|
||||
/* QS: PlayerLogLevels */
|
||||
if (RuleB(QueryServ, PlayerLogLevels)){
|
||||
std::string event_desc = StringFormat("Leveled UP :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
else if (set_level < m_pp.level){
|
||||
/* QS: PlayerLogLevels */
|
||||
if (RuleB(QueryServ, PlayerLogLevels)){
|
||||
std::string event_desc = StringFormat("Leveled DOWN :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
m_pp.level = set_level;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/data_verification.h"
|
||||
#include "../common/item_data.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "worldserver.h"
|
||||
#include "zonedb.h"
|
||||
@ -981,47 +982,6 @@ bool Client::TryStacking(ItemInst* item, uint8 type, bool try_worn, bool try_cur
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Client::TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, uint8 type, bool try_worn, bool try_cursor) {
|
||||
if(!item || !item->IsStackable() || item->GetCharges() >= item->GetItem()->StackSize)
|
||||
return false;
|
||||
|
||||
if(try_worn) {
|
||||
for(int i = EQEmu::PersonalSlotCharm; i <= EQEmu::PersonalSlotAmmo; ++i) {
|
||||
if(TryStacking(item, EQEmu::InventorySlot(EQEmu::InvTypePersonal, i), type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = EQEmu::PersonalSlotGeneral1; i <= EQEmu::PersonalSlotGeneral10; ++i) {
|
||||
if(TryStacking(item, EQEmu::InventorySlot(EQEmu::InvTypePersonal, i), type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(try_cursor) {
|
||||
if(TryStacking(item, EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor), type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Client::TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, const EQEmu::InventorySlot &slot, uint8 type) {
|
||||
//make this a function
|
||||
uint32 item_id = item->GetItem()->ID;
|
||||
auto tmp_inst = m_inventory.Get(slot);
|
||||
if(tmp_inst && tmp_inst->GetItem()->ID == item_id && tmp_inst->GetCharges() < tmp_inst->GetItem()->StackSize) {
|
||||
bool v = m_inventory.TryStacking(item, slot);
|
||||
if(v) {
|
||||
SendItemPacket(slot, item, ItemPacketTrade);
|
||||
}
|
||||
}
|
||||
|
||||
return item->GetCharges() == 0;
|
||||
}
|
||||
|
||||
// Locate an available space in inventory to place an item
|
||||
// and then put the item there
|
||||
// The change will be saved to the database
|
||||
@ -1416,7 +1376,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
}
|
||||
|
||||
if (move_in->from_slot == move_in->to_slot) { // Item summon, no further processing needed
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
if (GetClientVersion() >= ClientVersion::RoF) { return true; } // Can't do RoF+
|
||||
|
||||
if (move_in->to_slot == MainCursor) {
|
||||
@ -1448,7 +1408,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
if (move_in->to_slot == (uint32)INVALID_INDEX) {
|
||||
if (move_in->from_slot == (uint32)MainCursor) {
|
||||
Log.Out(Logs::Detail, Logs::Inventory, "Client destroyed item from cursor slot %d", move_in->from_slot);
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
|
||||
ItemInst *inst = m_inv.GetItem(MainCursor);
|
||||
if(inst) {
|
||||
@ -1462,7 +1422,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Inventory, "Deleted item from slot %d as a result of an inventory container tradeskill combine.", move_in->from_slot);
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
DeleteItemInInventory(move_in->from_slot);
|
||||
return true; // Item deletion
|
||||
}
|
||||
@ -1623,7 +1583,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
safe_delete(inst);
|
||||
}
|
||||
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in, true); } // QS Audit
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1693,7 +1653,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
database.SaveInventory(character_id, m_inv[src_slot_id], src_slot_id);
|
||||
}
|
||||
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in, true); } // QS Audit
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1715,7 +1675,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
|
||||
// Add cursor item to trade bucket
|
||||
// Also sends trade information to other client of trade session
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
|
||||
trade->AddEntity(dst_slot_id, move_in->number_in_stack);
|
||||
if (dstitemid == 0)
|
||||
@ -1725,7 +1685,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
|
||||
SummonItem(src_inst->GetID(), src_inst->GetCharges(), 0);
|
||||
DeleteItemInInventory(MainCursor);
|
||||
@ -1859,7 +1819,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
database.SaveInventory(character_id, m_inv.GetItem(dst_slot_id), dst_slot_id);
|
||||
}
|
||||
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in, true); } // QS Audit
|
||||
|
||||
|
||||
// Step 8: Re-calc stats
|
||||
CalcBonuses();
|
||||
@ -1960,104 +1920,6 @@ void Client::SwapItemResync(MoveItemOld_Struct* move_slots) {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::QSSwapItemAuditor(MoveItemOld_Struct* move_in, bool postaction_call) {
|
||||
int16 from_slot_id = static_cast<int16>(move_in->from_slot);
|
||||
int16 to_slot_id = static_cast<int16>(move_in->to_slot);
|
||||
int16 move_amount = static_cast<int16>(move_in->number_in_stack);
|
||||
|
||||
if(!m_inv[from_slot_id] && !m_inv[to_slot_id]) { return; }
|
||||
|
||||
uint16 move_count = 0;
|
||||
|
||||
if(m_inv[from_slot_id]) { move_count += m_inv[from_slot_id]->GetTotalItemCount(); }
|
||||
if(to_slot_id != from_slot_id) { if(m_inv[to_slot_id]) { move_count += m_inv[to_slot_id]->GetTotalItemCount(); } }
|
||||
|
||||
ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMoves, sizeof(QSPlayerLogMove_Struct) + (sizeof(QSMoveItems_Struct) * move_count));
|
||||
QSPlayerLogMove_Struct* qsaudit = (QSPlayerLogMove_Struct*)qspack->pBuffer;
|
||||
|
||||
qsaudit->char_id = character_id;
|
||||
qsaudit->stack_size = move_amount;
|
||||
qsaudit->char_count = move_count;
|
||||
qsaudit->postaction = postaction_call;
|
||||
qsaudit->from_slot = from_slot_id;
|
||||
qsaudit->to_slot = to_slot_id;
|
||||
|
||||
move_count = 0;
|
||||
|
||||
const ItemInst* from_inst = m_inv[postaction_call?to_slot_id:from_slot_id];
|
||||
|
||||
if(from_inst) {
|
||||
qsaudit->items[move_count].from_slot = from_slot_id;
|
||||
qsaudit->items[move_count].to_slot = to_slot_id;
|
||||
qsaudit->items[move_count].item_id = from_inst->GetID();
|
||||
qsaudit->items[move_count].charges = from_inst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = from_inst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = from_inst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = from_inst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = from_inst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = from_inst->GetAugmentItemID(5);
|
||||
|
||||
if(from_inst->IsType(ItemClassContainer)) {
|
||||
for(uint8 bag_idx = SUB_BEGIN; bag_idx < from_inst->GetItem()->BagSlots; bag_idx++) {
|
||||
const ItemInst* from_baginst = from_inst->GetItem(bag_idx);
|
||||
|
||||
if(from_baginst) {
|
||||
qsaudit->items[move_count].from_slot = InventoryOld::CalcSlotId(from_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].to_slot = InventoryOld::CalcSlotId(to_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].item_id = from_baginst->GetID();
|
||||
qsaudit->items[move_count].charges = from_baginst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = from_baginst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = from_baginst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = from_baginst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = from_baginst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = from_baginst->GetAugmentItemID(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(to_slot_id != from_slot_id) {
|
||||
const ItemInst* to_inst = m_inv[postaction_call?from_slot_id:to_slot_id];
|
||||
|
||||
if(to_inst) {
|
||||
qsaudit->items[move_count].from_slot = to_slot_id;
|
||||
qsaudit->items[move_count].to_slot = from_slot_id;
|
||||
qsaudit->items[move_count].item_id = to_inst->GetID();
|
||||
qsaudit->items[move_count].charges = to_inst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = to_inst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = to_inst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = to_inst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = to_inst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = to_inst->GetAugmentItemID(5);
|
||||
|
||||
if(to_inst->IsType(ItemClassContainer)) {
|
||||
for(uint8 bag_idx = SUB_BEGIN; bag_idx < to_inst->GetItem()->BagSlots; bag_idx++) {
|
||||
const ItemInst* to_baginst = to_inst->GetItem(bag_idx);
|
||||
|
||||
if(to_baginst) {
|
||||
qsaudit->items[move_count].from_slot = InventoryOld::CalcSlotId(to_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].to_slot = InventoryOld::CalcSlotId(from_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].item_id = to_baginst->GetID();
|
||||
qsaudit->items[move_count].charges = to_baginst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = to_baginst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = to_baginst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = to_baginst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = to_baginst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = to_baginst->GetAugmentItemID(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(move_count && worldserver.Connected()) {
|
||||
qspack->Deflate();
|
||||
worldserver.SendPacket(qspack);
|
||||
}
|
||||
|
||||
safe_delete(qspack);
|
||||
}
|
||||
|
||||
void Client::DyeArmor(DyeStruct* dye){
|
||||
int16 slot=0;
|
||||
for (int i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_TINT_END; i++) {
|
||||
@ -2710,7 +2572,7 @@ void Client::SendItemPacket(int16 slot_id, const ItemInst* inst, ItemPacketType
|
||||
// FastQueuePacket(&outapp);
|
||||
}
|
||||
|
||||
void Client::SendItemPacket(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, ItemPacketType packet_type) {
|
||||
void Client::SendItemPacket(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, ItemPacketType packet_type) {
|
||||
if(!inst) {
|
||||
return;
|
||||
}
|
||||
@ -3462,13 +3324,13 @@ bool Client::SummonItem(uint32 item_id,
|
||||
uint32 ornament_idfile,
|
||||
uint32 ornament_hero_model)
|
||||
{
|
||||
std::shared_ptr<EQEmu::ItemInstance> inst = database.CreateItem(item_id, charges);
|
||||
EQEmu::ItemInstance::pointer &inst = database.CreateItem(item_id, charges);
|
||||
if(!inst)
|
||||
return false;
|
||||
|
||||
if(inst->GetBaseItem()->ItemClass == ItemClassCommon) {
|
||||
if(aug1) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug1);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug1);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@ -3478,7 +3340,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug2) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug2);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug2);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@ -3488,7 +3350,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug3) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug3);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug3);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@ -3498,7 +3360,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug4) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug4);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug4);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@ -3508,7 +3370,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug5) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug5);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug5);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@ -3518,7 +3380,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug6) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug6);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug6);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@ -3536,7 +3398,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, bool client_update) {
|
||||
bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, bool client_update) {
|
||||
if(!inst)
|
||||
return false;
|
||||
|
||||
@ -3555,4 +3417,134 @@ bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_pt
|
||||
}
|
||||
|
||||
CalcBonuses();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Client::CanPutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end) {
|
||||
if(inst->IsStackable()) {
|
||||
int charges = m_inventory.FindFreeStackSlots(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10);
|
||||
|
||||
if(charges < inst->GetCharges()) {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
|
||||
if(!slot.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
if(!slot.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Client::StackItem(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update) {
|
||||
auto item_id = inst->GetBaseItem()->ID;
|
||||
|
||||
//not the most efficient of functions but in reality it's fast enough
|
||||
|
||||
//go through the top level slots first
|
||||
for(int i = slot_id_start; i < slot_id_end; ++i) {
|
||||
EQEmu::InventorySlot slot(container_id, i);
|
||||
auto item = m_inventory.Get(slot);
|
||||
|
||||
if(!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item->GetBaseItem()->ID == item_id) {
|
||||
auto free_charges = item->GetItem()->StackSize - item->GetCharges();
|
||||
|
||||
if(inst->GetCharges() > free_charges) {
|
||||
item->SetCharges(item->GetCharges() + free_charges);
|
||||
inst->SetCharges(inst->GetCharges() - free_charges);
|
||||
|
||||
m_inventory.UpdateSlot(slot, item);
|
||||
|
||||
if(client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
} else {
|
||||
item->SetCharges(item->GetCharges() + inst->GetCharges());
|
||||
inst->SetCharges(0);
|
||||
|
||||
m_inventory.UpdateSlot(slot, item);
|
||||
if(client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//go through the top level slots bag slots
|
||||
for(int i = slot_id_start; i < slot_id_end; ++i) {
|
||||
EQEmu::InventorySlot slot(container_id, i);
|
||||
auto item = m_inventory.Get(slot);
|
||||
|
||||
if(!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item->GetBaseItem()->ItemClass != ItemClassContainer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int sz = item->GetBaseItem()->BagSlots;
|
||||
bool update_bag = false;
|
||||
for(int j = 0; j < sz; ++j) {
|
||||
auto sub_item = item->Get(j);
|
||||
|
||||
if(!sub_item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(sub_item->GetBaseItem()->ID == item_id) {
|
||||
EQEmu::InventorySlot bag_slot(container_id, i, j);
|
||||
auto free_charges = sub_item->GetItem()->StackSize - sub_item->GetCharges();
|
||||
|
||||
if(inst->GetCharges() > free_charges) {
|
||||
sub_item->SetCharges(sub_item->GetCharges() + free_charges);
|
||||
inst->SetCharges(inst->GetCharges() - free_charges);
|
||||
|
||||
m_inventory.UpdateSlot(bag_slot, sub_item);
|
||||
update_bag = true;
|
||||
}
|
||||
else {
|
||||
sub_item->SetCharges(sub_item->GetCharges() + inst->GetCharges());
|
||||
inst->SetCharges(0);
|
||||
|
||||
m_inventory.UpdateSlot(bag_slot, sub_item);
|
||||
if(client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(update_bag && client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Client::PutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update) {
|
||||
if(inst->IsStackable()) {
|
||||
StackItem(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10, client_update);
|
||||
|
||||
if(inst->GetCharges() > 0) {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
PutItemInInventory(slot, inst, client_update);
|
||||
}
|
||||
} else {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
PutItemInInventory(slot, inst, client_update);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,10 +42,3 @@ void QueryServ::SendQuery(std::string Query)
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc)
|
||||
{
|
||||
std::string query = StringFormat(
|
||||
"INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))",
|
||||
Event_Type, Character_ID, EscapeString(Event_Desc).c_str());
|
||||
SendQuery(query);
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ class QueryServ{
|
||||
QueryServ();
|
||||
~QueryServ();
|
||||
void SendQuery(std::string Query);
|
||||
void PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc);
|
||||
};
|
||||
|
||||
#endif /* QUERYSERV_ZONE_H */
|
||||
@ -1370,12 +1370,6 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
||||
}
|
||||
|
||||
InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, newvalue, QGVarDuration(duration));
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
std::string event_desc = StringFormat("Update :: qglobal:%s to qvalue:%s zoneid:%i instid:%i", varname, newvalue, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Inserts global variable into quest_globals table */
|
||||
@ -1462,12 +1456,6 @@ void QuestManager::delglobal(const char *varname) {
|
||||
else
|
||||
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
std::string event_desc = StringFormat("Deleted :: qglobal:%s zoneid:%i instid:%i", varname, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
|
||||
std::string query = StringFormat("DELETE FROM quest_globals "
|
||||
"WHERE name = '%s' "
|
||||
"&& (npcid=0 || npcid=%i) "
|
||||
|
||||
@ -1821,11 +1821,6 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T
|
||||
buf[23] = '\0';
|
||||
parse->EventPlayer(EVENT_TASK_STAGE_COMPLETE, c, buf, 0);
|
||||
}
|
||||
/* QS: PlayerLogTaskUpdates :: Update */
|
||||
if (RuleB(QueryServ, PlayerLogTaskUpdates)){
|
||||
std::string event_desc = StringFormat("Task Stage Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID, ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
// If this task is now complete, the Completed tasks will have been
|
||||
@ -1837,12 +1832,6 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T
|
||||
buf[23] = '\0';
|
||||
parse->EventPlayer(EVENT_TASK_COMPLETE, c, buf, 0);
|
||||
|
||||
/* QS: PlayerLogTaskUpdates :: Complete */
|
||||
if (RuleB(QueryServ, PlayerLogTaskUpdates)){
|
||||
std::string event_desc = StringFormat("Task Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID, ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
taskmanager->SendCompletedTasksToClient(c, this);
|
||||
c->SendTaskActivityComplete(ActiveTasks[TaskIndex].TaskID, 0, TaskIndex, false);
|
||||
taskmanager->SaveClientState(c, this);
|
||||
|
||||
@ -1091,12 +1091,6 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
||||
entity_list.MessageGroup(this, true, MT_Skills, "%s has successfully fashioned %s!", GetName(), item->Name);
|
||||
}
|
||||
|
||||
/* QS: Player_Log_Trade_Skill_Events */
|
||||
if (RuleB(QueryServ, PlayerLogTradeSkillEvents)){
|
||||
std::string event_desc = StringFormat("Success :: fashioned recipe_id:%i tskillid:%i trivial:%i chance:%4.2f in zoneid:%i instid:%i", spec->recipe_id, spec->tradeskill, spec->trivial, chance, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Trade_Skill_Events, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem))
|
||||
UpdateTasksForItem(ActivityTradeSkill, itr->first, itr->second);
|
||||
++itr;
|
||||
@ -1119,12 +1113,6 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
||||
|
||||
}
|
||||
|
||||
/* QS: Player_Log_Trade_Skill_Events */
|
||||
if (RuleB(QueryServ, PlayerLogTradeSkillEvents)){
|
||||
std::string event_desc = StringFormat("Failed :: recipe_id:%i tskillid:%i trivial:%i chance:%4.2f in zoneid:%i instid:%i", spec->recipe_id, spec->tradeskill, spec->trivial, chance, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Trade_Skill_Events, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
itr = spec->onfail.begin();
|
||||
while(itr != spec->onfail.end()) {
|
||||
//should we check these arguments?
|
||||
|
||||
442
zone/trading.cpp
442
zone/trading.cpp
@ -189,107 +189,107 @@ void Trade::SendItemData(const ItemInst* inst, int16 dest_slot_id)
|
||||
// Audit trade: The part logged is what travels owner -> with
|
||||
void Trade::LogTrade()
|
||||
{
|
||||
Mob* with = With();
|
||||
if (!owner->IsClient() || !with)
|
||||
return; // Should never happen
|
||||
|
||||
Client* trader = owner->CastToClient();
|
||||
bool logtrade = false;
|
||||
int admin_level = 0;
|
||||
uint8 item_count = 0;
|
||||
|
||||
if (zone->tradevar != 0) {
|
||||
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
if (trader->GetInv().GetItem(i))
|
||||
item_count++;
|
||||
}
|
||||
|
||||
if (((this->cp + this->sp + this->gp + this->pp)>0) || (item_count>0))
|
||||
admin_level = trader->Admin();
|
||||
else
|
||||
admin_level = 999;
|
||||
|
||||
if (zone->tradevar == 7) {
|
||||
logtrade = true;
|
||||
}
|
||||
else if ((admin_level>=10) && (admin_level<20)) {
|
||||
if ((zone->tradevar<8) && (zone->tradevar>5))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=20) {
|
||||
if ((zone->tradevar<8) && (zone->tradevar>4))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=80) {
|
||||
if ((zone->tradevar<8) && (zone->tradevar>3))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=100){
|
||||
if ((zone->tradevar<9) && (zone->tradevar>2))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=150){
|
||||
if (((zone->tradevar<8) && (zone->tradevar>1)) || (zone->tradevar==9))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=255){
|
||||
if ((zone->tradevar<8) && (zone->tradevar>0))
|
||||
logtrade = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (logtrade == true) {
|
||||
char logtext[1000] = {0};
|
||||
uint32 cash = 0;
|
||||
bool comma = false;
|
||||
|
||||
// Log items offered by owner
|
||||
cash = this->cp + this->sp + this->gp + this->pp;
|
||||
if ((cash>0) || (item_count>0)) {
|
||||
sprintf(logtext, "%s gave %s ", trader->GetName(), with->GetName());
|
||||
|
||||
if (item_count > 0) {
|
||||
strcat(logtext, "items {");
|
||||
|
||||
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
const ItemInst* inst = trader->GetInv().GetItem(i);
|
||||
|
||||
if (!comma)
|
||||
comma = true;
|
||||
else {
|
||||
if (inst)
|
||||
strcat(logtext, ",");
|
||||
}
|
||||
|
||||
if (inst) {
|
||||
char item_num[15] = {0};
|
||||
sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
strcat(logtext, item_num);
|
||||
|
||||
if (inst->IsType(ItemClassContainer)) {
|
||||
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
|
||||
inst = trader->GetInv().GetItem(i, j);
|
||||
if (inst) {
|
||||
strcat(logtext, ",");
|
||||
sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
strcat(logtext, item_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cash > 0) {
|
||||
char money[100] = {0};
|
||||
sprintf(money, " %ipp, %igp, %isp, %icp", trader->trade->pp, trader->trade->gp, trader->trade->sp, trader->trade->cp);
|
||||
strcat(logtext, money);
|
||||
}
|
||||
|
||||
database.logevents(trader->AccountName(), trader->AccountID(),
|
||||
trader->Admin(), trader->GetName(), with->GetName(), "Trade", logtext, 6);
|
||||
}
|
||||
}
|
||||
//Mob* with = With();
|
||||
//if (!owner->IsClient() || !with)
|
||||
// return; // Should never happen
|
||||
//
|
||||
//Client* trader = owner->CastToClient();
|
||||
//bool logtrade = false;
|
||||
//int admin_level = 0;
|
||||
//uint8 item_count = 0;
|
||||
//
|
||||
//if (zone->tradevar != 0) {
|
||||
// for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
// if (trader->GetInv().GetItem(i))
|
||||
// item_count++;
|
||||
// }
|
||||
//
|
||||
// if (((this->cp + this->sp + this->gp + this->pp)>0) || (item_count>0))
|
||||
// admin_level = trader->Admin();
|
||||
// else
|
||||
// admin_level = 999;
|
||||
//
|
||||
// if (zone->tradevar == 7) {
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if ((admin_level>=10) && (admin_level<20)) {
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>5))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=20) {
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>4))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=80) {
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>3))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=100){
|
||||
// if ((zone->tradevar<9) && (zone->tradevar>2))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=150){
|
||||
// if (((zone->tradevar<8) && (zone->tradevar>1)) || (zone->tradevar==9))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=255){
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>0))
|
||||
// logtrade = true;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//if (logtrade == true) {
|
||||
// char logtext[1000] = {0};
|
||||
// uint32 cash = 0;
|
||||
// bool comma = false;
|
||||
//
|
||||
// // Log items offered by owner
|
||||
// cash = this->cp + this->sp + this->gp + this->pp;
|
||||
// if ((cash>0) || (item_count>0)) {
|
||||
// sprintf(logtext, "%s gave %s ", trader->GetName(), with->GetName());
|
||||
//
|
||||
// if (item_count > 0) {
|
||||
// strcat(logtext, "items {");
|
||||
//
|
||||
// for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
// const ItemInst* inst = trader->GetInv().GetItem(i);
|
||||
//
|
||||
// if (!comma)
|
||||
// comma = true;
|
||||
// else {
|
||||
// if (inst)
|
||||
// strcat(logtext, ",");
|
||||
// }
|
||||
//
|
||||
// if (inst) {
|
||||
// char item_num[15] = {0};
|
||||
// sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
// strcat(logtext, item_num);
|
||||
//
|
||||
// if (inst->IsType(ItemClassContainer)) {
|
||||
// for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
|
||||
// inst = trader->GetInv().GetItem(i, j);
|
||||
// if (inst) {
|
||||
// strcat(logtext, ",");
|
||||
// sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
// strcat(logtext, item_num);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (cash > 0) {
|
||||
// char money[100] = {0};
|
||||
// sprintf(money, " %ipp, %igp, %isp, %icp", trader->trade->pp, trader->trade->gp, trader->trade->sp, trader->trade->cp);
|
||||
// strcat(logtext, money);
|
||||
// }
|
||||
//
|
||||
// database.logevents(trader->AccountName(), trader->AccountID(),
|
||||
// trader->Admin(), trader->GetName(), with->GetName(), "Trade", logtext, 6);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@ -454,38 +454,12 @@ void Client::ResetTrade() {
|
||||
void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, std::list<void*>* event_details) {
|
||||
if(tradingWith && tradingWith->IsClient()) {
|
||||
Client* other = tradingWith->CastToClient();
|
||||
QSPlayerLogTrade_Struct* qs_audit = nullptr;
|
||||
bool qs_log = false;
|
||||
|
||||
if(other) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Finishing trade with client %s", other->GetName());
|
||||
|
||||
this->AddMoneyToPP(other->trade->cp, other->trade->sp, other->trade->gp, other->trade->pp, true);
|
||||
|
||||
// step 0: pre-processing
|
||||
// QS code
|
||||
if (RuleB(QueryServ, PlayerLogTrades) && event_entry && event_details) {
|
||||
qs_audit = (QSPlayerLogTrade_Struct*)event_entry;
|
||||
qs_log = true;
|
||||
|
||||
if (finalizer) {
|
||||
qs_audit->char2_id = this->character_id;
|
||||
|
||||
qs_audit->char2_money.platinum = this->trade->pp;
|
||||
qs_audit->char2_money.gold = this->trade->gp;
|
||||
qs_audit->char2_money.silver = this->trade->sp;
|
||||
qs_audit->char2_money.copper = this->trade->cp;
|
||||
}
|
||||
else {
|
||||
qs_audit->char1_id = this->character_id;
|
||||
|
||||
qs_audit->char1_money.platinum = this->trade->pp;
|
||||
qs_audit->char1_money.gold = this->trade->gp;
|
||||
qs_audit->char1_money.silver = this->trade->sp;
|
||||
qs_audit->char1_money.copper = this->trade->cp;
|
||||
}
|
||||
}
|
||||
|
||||
// step 1: process bags
|
||||
for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) {
|
||||
const ItemInst* inst = m_inv[trade_slot];
|
||||
@ -500,56 +474,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (free_slot != INVALID_INDEX) {
|
||||
if (other->PutItemInInventory(free_slot, *inst, true)) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Container %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID);
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_id = other->CharacterID();
|
||||
detail->to_slot = free_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = 1;
|
||||
detail->aug_1 = inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
|
||||
//for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) {
|
||||
for (uint8 sub_slot = SUB_BEGIN; (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++sub_slot) { // this is to catch ALL items
|
||||
const ItemInst* bag_inst = inst->GetItem(sub_slot);
|
||||
|
||||
if (bag_inst) {
|
||||
detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = InventoryOld::CalcSlotId(trade_slot, sub_slot);
|
||||
detail->to_id = other->CharacterID();
|
||||
detail->to_slot = InventoryOld::CalcSlotId(free_slot, sub_slot);
|
||||
detail->item_id = bag_inst->GetID();
|
||||
detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges());
|
||||
detail->aug_1 = bag_inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = bag_inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = bag_inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = bag_inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = bag_inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Transfer of container %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName());
|
||||
@ -611,28 +535,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (other->PutItemInInventory(partial_slot, *partial_inst, true)) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Partial stack %s (%d) successfully transferred, deleting %i charges from trade slot.",
|
||||
inst->GetItem()->Name, inst->GetItem()->ID, (old_charges - inst->GetCharges()));
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_id = other->CharacterID();
|
||||
detail->to_slot = partial_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = (old_charges - inst->GetCharges());
|
||||
detail->aug_1 = 0;
|
||||
detail->aug_2 = 0;
|
||||
detail->aug_3 = 0;
|
||||
detail->aug_4 = 0;
|
||||
detail->aug_5 = 0;
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Transfer of partial stack %s (%d) to %s failed, returning %i charges to trade slot.",
|
||||
@ -679,24 +581,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
inst->SetCharges(0);
|
||||
}
|
||||
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_id = this->character_id;
|
||||
detail->to_slot = bias_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = (old_charges - inst->GetCharges());
|
||||
detail->aug_1 = 0;
|
||||
detail->aug_2 = 0;
|
||||
detail->aug_3 = 0;
|
||||
detail->aug_4 = 0;
|
||||
detail->aug_5 = 0;
|
||||
|
||||
event_details->push_back(detail);
|
||||
}
|
||||
|
||||
if (inst->GetCharges() == 0) {
|
||||
DeleteItemInInventory(trade_slot);
|
||||
break;
|
||||
@ -719,57 +603,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (free_slot != INVALID_INDEX) {
|
||||
if (other->PutItemInInventory(free_slot, *inst, true)) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Item %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID);
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_id = other->CharacterID();
|
||||
detail->to_slot = free_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = (!inst->IsStackable() ? 1 : inst->GetCharges());
|
||||
detail->aug_1 = inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
|
||||
// 'step 3' should never really see containers..but, just in case...
|
||||
//for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) {
|
||||
for (uint8 sub_slot = SUB_BEGIN; (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++sub_slot) { // this is to catch ALL items
|
||||
const ItemInst* bag_inst = inst->GetItem(sub_slot);
|
||||
|
||||
if (bag_inst) {
|
||||
detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_id = other->CharacterID();
|
||||
detail->to_slot = free_slot;
|
||||
detail->item_id = bag_inst->GetID();
|
||||
detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges());
|
||||
detail->aug_1 = bag_inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = bag_inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = bag_inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = bag_inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = bag_inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Transfer of Item %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName());
|
||||
@ -794,79 +627,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
}
|
||||
}
|
||||
else if(tradingWith && tradingWith->IsNPC()) {
|
||||
QSPlayerLogHandin_Struct* qs_audit = nullptr;
|
||||
bool qs_log = false;
|
||||
|
||||
// QS code
|
||||
if(RuleB(QueryServ, PlayerLogTrades) && event_entry && event_details) {
|
||||
// Currently provides only basic functionality. Calling method will also
|
||||
// need to be modified before item returns and rewards can be logged.
|
||||
qs_audit = (QSPlayerLogHandin_Struct*)event_entry;
|
||||
qs_log = true;
|
||||
|
||||
qs_audit->quest_id = 0;
|
||||
qs_audit->char_id = character_id;
|
||||
qs_audit->char_money.platinum = trade->pp;
|
||||
qs_audit->char_money.gold = trade->gp;
|
||||
qs_audit->char_money.silver = trade->sp;
|
||||
qs_audit->char_money.copper = trade->cp;
|
||||
qs_audit->char_count = 0;
|
||||
qs_audit->npc_id = tradingWith->GetNPCTypeID();
|
||||
qs_audit->npc_money.platinum = 0;
|
||||
qs_audit->npc_money.gold = 0;
|
||||
qs_audit->npc_money.silver = 0;
|
||||
qs_audit->npc_money.copper = 0;
|
||||
qs_audit->npc_count = 0;
|
||||
}
|
||||
|
||||
if(qs_log) { // This can be incorporated below when revisions are made
|
||||
for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_NPC_END; ++trade_slot) {
|
||||
const ItemInst* trade_inst = m_inv[trade_slot];
|
||||
|
||||
if(trade_inst) {
|
||||
QSHandinItems_Struct* detail = new QSHandinItems_Struct;
|
||||
|
||||
strcpy(detail->action_type, "HANDIN");
|
||||
|
||||
detail->char_slot = trade_slot;
|
||||
detail->item_id = trade_inst->GetID();
|
||||
detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges());
|
||||
detail->aug_1 = trade_inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = trade_inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = trade_inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = trade_inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = trade_inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
qs_audit->char_count += detail->charges;
|
||||
|
||||
if(trade_inst->IsType(ItemClassContainer)) {
|
||||
for (uint8 sub_slot = SUB_BEGIN; sub_slot < trade_inst->GetItem()->BagSlots; ++sub_slot) {
|
||||
const ItemInst* trade_baginst = trade_inst->GetItem(sub_slot);
|
||||
|
||||
if(trade_baginst) {
|
||||
detail = new QSHandinItems_Struct;
|
||||
|
||||
strcpy(detail->action_type, "HANDIN");
|
||||
|
||||
detail->char_slot = InventoryOld::CalcSlotId(trade_slot, sub_slot);
|
||||
detail->item_id = trade_baginst->GetID();
|
||||
detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges());
|
||||
detail->aug_1 = trade_baginst->GetAugmentItemID(1);
|
||||
detail->aug_2 = trade_baginst->GetAugmentItemID(2);
|
||||
detail->aug_3 = trade_baginst->GetAugmentItemID(3);
|
||||
detail->aug_4 = trade_baginst->GetAugmentItemID(4);
|
||||
detail->aug_5 = trade_baginst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
qs_audit->char_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool quest_npc = false;
|
||||
if(parse->HasQuestSub(tradingWith->GetNPCTypeID(), EVENT_TRADE)) {
|
||||
// This is a quest NPC
|
||||
|
||||
104
zone/zone.cpp
104
zone/zone.cpp
@ -51,6 +51,7 @@
|
||||
#include "worldserver.h"
|
||||
#include "zone.h"
|
||||
#include "zone_config.h"
|
||||
#include "queryserv.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <ctime>
|
||||
@ -62,8 +63,6 @@
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern bool staticzone;
|
||||
extern NetConnection net;
|
||||
extern PetitionList petition_list;
|
||||
@ -72,6 +71,7 @@ extern uint16 adverrornum;
|
||||
extern uint32 numclients;
|
||||
extern WorldServer worldserver;
|
||||
extern Zone* zone;
|
||||
extern QueryServ* QServ;
|
||||
|
||||
Mutex MZoneShutdown;
|
||||
|
||||
@ -104,34 +104,6 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
||||
zone->zonemap = Map::LoadMapFile(zone->map_name);
|
||||
zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name);
|
||||
zone->pathing = PathManager::LoadPathFile(zone->map_name);
|
||||
|
||||
char tmp[10];
|
||||
if (database.GetVariable("loglevel",tmp, 9)) {
|
||||
int log_levels[4];
|
||||
if (atoi(tmp)>9){ //Server is using the new code
|
||||
for(int i=0;i<4;i++){
|
||||
if (((int)tmp[i]>=48) && ((int)tmp[i]<=57))
|
||||
log_levels[i]=(int)tmp[i]-48; //get the value to convert it to an int from the ascii value
|
||||
else
|
||||
log_levels[i]=0; //set to zero on a bogue char
|
||||
}
|
||||
zone->loglevelvar = log_levels[0];
|
||||
Log.Out(Logs::General, Logs::Status, "General logging level: %i", zone->loglevelvar);
|
||||
zone->merchantvar = log_levels[1];
|
||||
Log.Out(Logs::General, Logs::Status, "Merchant logging level: %i", zone->merchantvar);
|
||||
zone->tradevar = log_levels[2];
|
||||
Log.Out(Logs::General, Logs::Status, "Trade logging level: %i", zone->tradevar);
|
||||
zone->lootvar = log_levels[3];
|
||||
Log.Out(Logs::General, Logs::Status, "Loot logging level: %i", zone->lootvar);
|
||||
}
|
||||
else {
|
||||
zone->loglevelvar = uint8(atoi(tmp)); //continue supporting only command logging (for now)
|
||||
zone->merchantvar = 0;
|
||||
zone->tradevar = 0;
|
||||
zone->lootvar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ZoneLoaded = true;
|
||||
|
||||
worldserver.SetZone(iZoneID, iInstanceID);
|
||||
@ -762,11 +734,6 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
|
||||
|
||||
is_zone_time_localized = false;
|
||||
|
||||
loglevelvar = 0;
|
||||
merchantvar = 0;
|
||||
tradevar = 0;
|
||||
lootvar = 0;
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
taskmanager->LoadProximities(zoneid);
|
||||
}
|
||||
@ -2299,3 +2266,70 @@ void Zone::UpdateHotzone()
|
||||
is_hotzone = atoi(row[0]) == 0 ? false: true;
|
||||
}
|
||||
|
||||
void Zone::LogEvent(EventLogTypes type, Client *c, const std::string &desc) {
|
||||
if(!c)
|
||||
return;
|
||||
|
||||
int zone_id = GetZoneID();
|
||||
int zone_instance = GetInstanceID();
|
||||
int zone_version = GetInstanceVersion();
|
||||
|
||||
int account_id = c->AccountID();
|
||||
std::string name = c->GetName();
|
||||
int id = c->CharacterID();
|
||||
|
||||
int target_account_id;
|
||||
std::string target_name;
|
||||
int target_id;
|
||||
|
||||
Mob *target = c->GetTarget();
|
||||
if(target && target->IsClient()) {
|
||||
Client *target_c = target->CastToClient();
|
||||
|
||||
target_account_id = target_c->AccountID();
|
||||
target_name = target_c->GetName();
|
||||
target_id = target_c->CharacterID();
|
||||
}
|
||||
else if(target && target->IsNPC()) {
|
||||
NPC *target_n = target->CastToNPC();
|
||||
|
||||
target_account_id = 0;
|
||||
target_name = target_n->GetName();
|
||||
target_id = target_n->GetNPCTypeID();
|
||||
}
|
||||
else if(target) {
|
||||
target_account_id = 0;
|
||||
target_name = target->GetName();
|
||||
target_id = 0;
|
||||
}
|
||||
else {
|
||||
target_account_id = 0;
|
||||
target_name = "";
|
||||
target_id = 0;
|
||||
}
|
||||
|
||||
|
||||
std::string query = StringFormat("INSERT INTO event_log "
|
||||
"(type, zone_id, zone_instance, zone_version, player_account_id, "
|
||||
"player_id, player_name, target_account_id, target_id, target_name, `desc`)"
|
||||
" VALUES "
|
||||
"(%i, %i, %i, %i, %i, %i, '%s', %i, %i, '%s', '%s')",
|
||||
(int)type,
|
||||
zone_id,
|
||||
zone_instance,
|
||||
zone_version,
|
||||
account_id,
|
||||
id,
|
||||
EscapeString(name).c_str(),
|
||||
target_account_id,
|
||||
target_id,
|
||||
EscapeString(target_name).c_str(),
|
||||
EscapeString(desc).c_str()
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::General, Logs::Error, "Log Error: %s", results.ErrorMessage().c_str());
|
||||
}
|
||||
//QServ->SendQuery(query);
|
||||
}
|
||||
15
zone/zone.h
15
zone/zone.h
@ -69,6 +69,14 @@ struct item_tick_struct {
|
||||
std::string qglobal;
|
||||
};
|
||||
|
||||
enum EventLogTypes
|
||||
{
|
||||
EventLogItemSummon = 0,
|
||||
EventLogItemBuy = 1,
|
||||
EventLogQuest = 500,
|
||||
EventLogMax
|
||||
};
|
||||
|
||||
class Client;
|
||||
class Map;
|
||||
class Mob;
|
||||
@ -227,11 +235,6 @@ public:
|
||||
uint8 weather_intensity;
|
||||
uint8 zone_weather;
|
||||
|
||||
uint8 loglevelvar;
|
||||
uint8 merchantvar;
|
||||
uint8 tradevar;
|
||||
uint8 lootvar;
|
||||
|
||||
bool HasGraveyard();
|
||||
void SetGraveyard(uint32 zoneid, const glm::vec4& graveyardPosition);
|
||||
|
||||
@ -282,6 +285,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void LogEvent(EventLogTypes type, Client *c, const std::string &desc);
|
||||
|
||||
//MODDING HOOKS
|
||||
void mod_init();
|
||||
void mod_repop();
|
||||
|
||||
@ -311,33 +311,6 @@ void ZoneDatabase::UpdateSpawn2Status(uint32 id, uint8 new_status)
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
bool ZoneDatabase::logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname, const char* target,const char* descriptiontype, const char* description,int event_nid){
|
||||
|
||||
uint32 len = strlen(description);
|
||||
uint32 len2 = strlen(target);
|
||||
char* descriptiontext = new char[2*len+1];
|
||||
char* targetarr = new char[2*len2+1];
|
||||
memset(descriptiontext, 0, 2*len+1);
|
||||
memset(targetarr, 0, 2*len2+1);
|
||||
DoEscapeString(descriptiontext, description, len);
|
||||
DoEscapeString(targetarr, target, len2);
|
||||
|
||||
std::string query = StringFormat("INSERT INTO eventlog (accountname, accountid, status, "
|
||||
"charname, target, descriptiontype, description, event_nid) "
|
||||
"VALUES('%s', %i, %i, '%s', '%s', '%s', '%s', '%i')",
|
||||
accountname, accountid, status, charname, targetarr,
|
||||
descriptiontype, descriptiontext, event_nid);
|
||||
safe_delete_array(descriptiontext);
|
||||
safe_delete_array(targetarr);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ZoneDatabase::UpdateBug(BugStruct* bug) {
|
||||
|
||||
uint32 len = strlen(bug->bug);
|
||||
|
||||
@ -488,7 +488,6 @@ public:
|
||||
* PLEASE DO NOT ADD TO THIS COLLECTION OF CRAP UNLESS YOUR METHOD
|
||||
* REALLY HAS NO BETTER SECTION
|
||||
*/
|
||||
bool logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid);
|
||||
void GetEventLogs(const char* name,char* target,uint32 account_id=0,uint8 eventid=0,char* detail=0,char* timestamp=0, CharacterEventLog_Struct* cel=0);
|
||||
uint32 GetKarma(uint32 acct_id);
|
||||
void UpdateKarma(uint32 acct_id, uint32 amount);
|
||||
|
||||
@ -335,12 +335,6 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
|
||||
|
||||
SendLogoutPackets();
|
||||
|
||||
/* QS: PlayerLogZone */
|
||||
if (RuleB(QueryServ, PlayerLogZone)){
|
||||
std::string event_desc = StringFormat("Zoning :: zoneid:%u instid:%u x:%4.2f y:%4.2f z:%4.2f h:%4.2f zonemode:%d from zoneid:%u instid:%i", zone_id, instance_id, dest_x, dest_y, dest_z, dest_h, zone_mode, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Zoning, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
/* Dont clear aggro until the zone is successful */
|
||||
entity_list.RemoveFromHateLists(this);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user