Renamed Inventory to InventoryOld

This commit is contained in:
KimLS
2015-02-17 13:42:21 -08:00
parent b48a712887
commit b75e6308dd
31 changed files with 209 additions and 209 deletions
+1 -1
View File
@@ -677,7 +677,7 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
}
/* This only for new Character creation storing */
bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv) {
bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, InventoryOld* inv) {
uint32 charid = 0;
char zone[50];
float x, y, z;
+2 -2
View File
@@ -36,7 +36,7 @@
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
class Inventory;
class InventoryOld;
class MySQLRequestResult;
class Client;
@@ -102,7 +102,7 @@ public:
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
bool SetHackerFlag(const char* accountname, const char* charactername, const char* hacked);
bool SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone);
bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv);
bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, InventoryOld* inv);
bool UpdateName(const char* oldname, const char* newname);
/* General Information Queries */
+83 -83
View File
@@ -105,9 +105,9 @@ ItemInst* ItemInstQueue::peek_front() const
//
// class Inventory
// class InventoryOld
//
Inventory::~Inventory()
InventoryOld::~InventoryOld()
{
for (auto iter = m_worn.begin(); iter != m_worn.end(); ++iter) {
safe_delete(iter->second);
@@ -135,7 +135,7 @@ Inventory::~Inventory()
m_trade.clear();
}
void Inventory::CleanDirty() {
void InventoryOld::CleanDirty() {
auto iter = dirty_inst.begin();
while (iter != dirty_inst.end()) {
delete (*iter);
@@ -144,14 +144,14 @@ void Inventory::CleanDirty() {
dirty_inst.clear();
}
void Inventory::MarkDirty(ItemInst *inst) {
void InventoryOld::MarkDirty(ItemInst *inst) {
if (inst) {
dirty_inst.push_back(inst);
}
}
// Retrieve item at specified slot; returns false if item not found
ItemInst* Inventory::GetItem(int16 slot_id) const
ItemInst* InventoryOld::GetItem(int16 slot_id) const
{
ItemInst* result = nullptr;
@@ -186,37 +186,37 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
// Inner bag slots
else if (slot_id >= EmuConstants::TRADE_BAGS_BEGIN && slot_id <= EmuConstants::TRADE_BAGS_END) {
// Trade bag slots
ItemInst* inst = _GetItem(m_trade, Inventory::CalcSlotId(slot_id));
ItemInst* inst = _GetItem(m_trade, InventoryOld::CalcSlotId(slot_id));
if (inst && inst->IsType(ItemClassContainer)) {
result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
result = inst->GetItem(InventoryOld::CalcBagIdx(slot_id));
}
}
else if (slot_id >= EmuConstants::SHARED_BANK_BAGS_BEGIN && slot_id <= EmuConstants::SHARED_BANK_BAGS_END) {
// Shared Bank bag slots
ItemInst* inst = _GetItem(m_shbank, Inventory::CalcSlotId(slot_id));
ItemInst* inst = _GetItem(m_shbank, InventoryOld::CalcSlotId(slot_id));
if (inst && inst->IsType(ItemClassContainer)) {
result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
result = inst->GetItem(InventoryOld::CalcBagIdx(slot_id));
}
}
else if (slot_id >= EmuConstants::BANK_BAGS_BEGIN && slot_id <= EmuConstants::BANK_BAGS_END) {
// Bank bag slots
ItemInst* inst = _GetItem(m_bank, Inventory::CalcSlotId(slot_id));
ItemInst* inst = _GetItem(m_bank, InventoryOld::CalcSlotId(slot_id));
if (inst && inst->IsType(ItemClassContainer)) {
result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
result = inst->GetItem(InventoryOld::CalcBagIdx(slot_id));
}
}
else if (slot_id >= EmuConstants::CURSOR_BAG_BEGIN && slot_id <= EmuConstants::CURSOR_BAG_END) {
// Cursor bag slots
ItemInst* inst = m_cursor.peek_front();
if (inst && inst->IsType(ItemClassContainer)) {
result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
result = inst->GetItem(InventoryOld::CalcBagIdx(slot_id));
}
}
else if (slot_id >= EmuConstants::GENERAL_BAGS_BEGIN && slot_id <= EmuConstants::GENERAL_BAGS_END) {
// Personal inventory bag slots
ItemInst* inst = _GetItem(m_inv, Inventory::CalcSlotId(slot_id));
ItemInst* inst = _GetItem(m_inv, InventoryOld::CalcSlotId(slot_id));
if (inst && inst->IsType(ItemClassContainer)) {
result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
result = inst->GetItem(InventoryOld::CalcBagIdx(slot_id));
}
}
@@ -224,13 +224,13 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
}
// Retrieve item at specified position within bag
ItemInst* Inventory::GetItem(int16 slot_id, uint8 bagidx) const
ItemInst* InventoryOld::GetItem(int16 slot_id, uint8 bagidx) const
{
return GetItem(Inventory::CalcSlotId(slot_id, bagidx));
return GetItem(InventoryOld::CalcSlotId(slot_id, bagidx));
}
// Put an item snto specified slot
int16 Inventory::PutItem(int16 slot_id, const ItemInst& inst)
int16 InventoryOld::PutItem(int16 slot_id, const ItemInst& inst)
{
// Clean up item already in slot (if exists)
DeleteItem(slot_id);
@@ -245,19 +245,19 @@ int16 Inventory::PutItem(int16 slot_id, const ItemInst& inst)
return _PutItem(slot_id, inst.Clone());
}
int16 Inventory::PushCursor(const ItemInst& inst)
int16 InventoryOld::PushCursor(const ItemInst& inst)
{
m_cursor.push(inst.Clone());
return MainCursor;
}
ItemInst* Inventory::GetCursorItem()
ItemInst* InventoryOld::GetCursorItem()
{
return m_cursor.peek_front();
}
// Swap items in inventory
bool Inventory::SwapItem(int16 slot_a, int16 slot_b)
bool InventoryOld::SwapItem(int16 slot_a, int16 slot_b)
{
// Temp holding areas for a and b
ItemInst* inst_a = GetItem(slot_a);
@@ -273,7 +273,7 @@ bool Inventory::SwapItem(int16 slot_a, int16 slot_b)
}
// Remove item from inventory (with memory delete)
bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
bool InventoryOld::DeleteItem(int16 slot_id, uint8 quantity)
{
// Pop item out of inventory map (or queue)
ItemInst* item_to_delete = PopItem(slot_id);
@@ -293,7 +293,7 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))
) {
// Item can now be destroyed
Inventory::MarkDirty(item_to_delete);
InventoryOld::MarkDirty(item_to_delete);
return true;
}
}
@@ -303,19 +303,19 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
return false;
}
Inventory::MarkDirty(item_to_delete);
InventoryOld::MarkDirty(item_to_delete);
return true;
}
// Checks All items in a bag for No Drop
bool Inventory::CheckNoDrop(int16 slot_id) {
bool InventoryOld::CheckNoDrop(int16 slot_id) {
ItemInst* inst = GetItem(slot_id);
if (!inst) return false;
if (!inst->GetItem()->NoDrop) return true;
if (inst->GetItem()->ItemClass == 1) {
for (uint8 i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) {
ItemInst* bagitem = GetItem(Inventory::CalcSlotId(slot_id, i));
ItemInst* bagitem = GetItem(InventoryOld::CalcSlotId(slot_id, i));
if (bagitem && !bagitem->GetItem()->NoDrop)
return true;
}
@@ -325,7 +325,7 @@ bool Inventory::CheckNoDrop(int16 slot_id) {
// Remove item from bucket without memory delete
// Returns item pointer if full delete was successful
ItemInst* Inventory::PopItem(int16 slot_id)
ItemInst* InventoryOld::PopItem(int16 slot_id)
{
ItemInst* p = nullptr;
@@ -358,9 +358,9 @@ ItemInst* Inventory::PopItem(int16 slot_id)
}
else {
// Is slot inside bag?
ItemInst* baginst = GetItem(Inventory::CalcSlotId(slot_id));
ItemInst* baginst = GetItem(InventoryOld::CalcSlotId(slot_id));
if (baginst != nullptr && baginst->IsType(ItemClassContainer)) {
p = baginst->PopItem(Inventory::CalcBagIdx(slot_id));
p = baginst->PopItem(InventoryOld::CalcBagIdx(slot_id));
}
}
@@ -368,7 +368,7 @@ ItemInst* Inventory::PopItem(int16 slot_id)
return p;
}
bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
bool InventoryOld::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
if (ItemToTry->Stackable) {
@@ -388,7 +388,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
}
if (InvItem && InvItem->IsType(ItemClassContainer)) {
int16 BaseSlotID = Inventory::CalcSlotId(i, SUB_BEGIN);
int16 BaseSlotID = InventoryOld::CalcSlotId(i, SUB_BEGIN);
uint8 BagSize = InvItem->GetItem()->BagSlots;
for (uint8 BagSlot = SUB_BEGIN; BagSlot < BagSize; BagSlot++) {
@@ -432,7 +432,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
}
else if (InvItem->IsType(ItemClassContainer) && CanItemFitInContainer(ItemToTry, InvItem->GetItem())) {
int16 BaseSlotID = Inventory::CalcSlotId(i, SUB_BEGIN);
int16 BaseSlotID = InventoryOld::CalcSlotId(i, SUB_BEGIN);
uint8 BagSize = InvItem->GetItem()->BagSlots;
@@ -468,7 +468,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
//This function has a flaw in that it only returns the last stack that it looked at
//when quantity is greater than 1 and not all of quantity can be found in 1 stack.
int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where)
int16 InventoryOld::HasItem(uint32 item_id, uint8 quantity, uint8 where)
{
int16 slot_id = INVALID_INDEX;
@@ -518,7 +518,7 @@ int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where)
}
//this function has the same quantity flaw mentioned above in HasItem()
int16 Inventory::HasItemByUse(uint8 use, uint8 quantity, uint8 where)
int16 InventoryOld::HasItemByUse(uint8 use, uint8 quantity, uint8 where)
{
int16 slot_id = INVALID_INDEX;
@@ -564,7 +564,7 @@ int16 Inventory::HasItemByUse(uint8 use, uint8 quantity, uint8 where)
return slot_id;
}
int16 Inventory::HasItemByLoreGroup(uint32 loregroup, uint8 where)
int16 InventoryOld::HasItemByLoreGroup(uint32 loregroup, uint8 where)
{
int16 slot_id = INVALID_INDEX;
@@ -612,7 +612,7 @@ int16 Inventory::HasItemByLoreGroup(uint32 loregroup, uint8 where)
// Locate an available inventory slot
// Returns slot_id when there's one available, else SLOT_INVALID
int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, bool is_arrow)
int16 InventoryOld::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, bool is_arrow)
{
// Check basic inventory
for (int16 i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++) {
@@ -631,7 +631,7 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
continue;
}
int16 base_slot_id = Inventory::CalcSlotId(i, SUB_BEGIN);
int16 base_slot_id = InventoryOld::CalcSlotId(i, SUB_BEGIN);
uint8 slots = inst->GetItem()->BagSlots;
uint8 j;
@@ -656,9 +656,9 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
}
// This is a mix of HasSpaceForItem and FindFreeSlot..due to existing coding behavior, it was better to add a new helper function...
int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) {
int16 InventoryOld::FindFreeSlotForTradeItem(const ItemInst* inst) {
// Do not arbitrarily use this function..it is designed for use with Client::ResetTrade() and Client::FinishTrade().
// If you have a need, use it..but, understand it is not a compatible replacement for Inventory::FindFreeSlot().
// If you have a need, use it..but, understand it is not a compatible replacement for InventoryOld::FindFreeSlot().
//
// I'll probably implement a bitmask in the new inventory system to avoid having to adjust stack bias -U
@@ -701,7 +701,7 @@ int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) {
continue;
if ((sub_inst->GetID() == inst->GetID()) && (sub_inst->GetCharges() < sub_inst->GetItem()->StackSize))
return Inventory::CalcSlotId(free_slot, free_bag_slot);
return InventoryOld::CalcSlotId(free_slot, free_bag_slot);
}
}
}
@@ -717,7 +717,7 @@ int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) {
for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) {
if (!main_inst->GetItem(free_bag_slot))
return Inventory::CalcSlotId(free_slot, free_bag_slot);
return InventoryOld::CalcSlotId(free_slot, free_bag_slot);
}
}
}
@@ -732,7 +732,7 @@ int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) {
for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) {
if (!main_inst->GetItem(free_bag_slot))
return Inventory::CalcSlotId(free_slot, free_bag_slot);
return InventoryOld::CalcSlotId(free_slot, free_bag_slot);
}
}
}
@@ -754,7 +754,7 @@ int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) {
for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) {
if (!main_inst->GetItem(free_bag_slot))
return Inventory::CalcSlotId(free_slot, free_bag_slot);
return InventoryOld::CalcSlotId(free_slot, free_bag_slot);
}
}
}
@@ -764,7 +764,7 @@ int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) {
}
// Opposite of below: Get parent bag slot_id from a slot inside of bag
int16 Inventory::CalcSlotId(int16 slot_id) {
int16 InventoryOld::CalcSlotId(int16 slot_id) {
int16 parent_slot_id = INVALID_INDEX;
// this is not a bag range... using this risks over-writing existing items
@@ -792,8 +792,8 @@ int16 Inventory::CalcSlotId(int16 slot_id) {
}
// Calculate slot_id for an item within a bag
int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx) {
if (!Inventory::SupportsContainers(bagslot_id))
int16 InventoryOld::CalcSlotId(int16 bagslot_id, uint8 bagidx) {
if (!InventoryOld::SupportsContainers(bagslot_id))
return INVALID_INDEX;
int16 slot_id = INVALID_INDEX;
@@ -817,7 +817,7 @@ int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx) {
return slot_id;
}
uint8 Inventory::CalcBagIdx(int16 slot_id) {
uint8 InventoryOld::CalcBagIdx(int16 slot_id) {
uint8 index = 0;
// this is not a bag range... using this risks over-writing existing items
@@ -846,7 +846,7 @@ uint8 Inventory::CalcBagIdx(int16 slot_id) {
return index;
}
int16 Inventory::CalcSlotFromMaterial(uint8 material)
int16 InventoryOld::CalcSlotFromMaterial(uint8 material)
{
switch (material)
{
@@ -873,7 +873,7 @@ int16 Inventory::CalcSlotFromMaterial(uint8 material)
}
}
uint8 Inventory::CalcMaterialFromSlot(int16 equipslot)
uint8 InventoryOld::CalcMaterialFromSlot(int16 equipslot)
{
switch (equipslot)
{
@@ -901,7 +901,7 @@ uint8 Inventory::CalcMaterialFromSlot(int16 equipslot)
}
}
bool Inventory::CanItemFitInContainer(const Item_Struct *ItemToTry, const Item_Struct *Container) {
bool InventoryOld::CanItemFitInContainer(const Item_Struct *ItemToTry, const Item_Struct *Container) {
if (!ItemToTry || !Container)
return false;
@@ -918,7 +918,7 @@ bool Inventory::CanItemFitInContainer(const Item_Struct *ItemToTry, const Item_S
return true;
}
bool Inventory::SupportsClickCasting(int16 slot_id)
bool InventoryOld::SupportsClickCasting(int16 slot_id)
{
// there are a few non-potion items that identify as ItemTypePotion..so, we still need to ubiquitously include the equipment range
if ((uint16)slot_id <= EmuConstants::GENERAL_END || slot_id == MainPowerSource)
@@ -934,7 +934,7 @@ bool Inventory::SupportsClickCasting(int16 slot_id)
return false;
}
bool Inventory::SupportsPotionBeltCasting(int16 slot_id)
bool InventoryOld::SupportsPotionBeltCasting(int16 slot_id)
{
if ((uint16)slot_id <= EmuConstants::GENERAL_END || slot_id == MainPowerSource || (slot_id >= EmuConstants::GENERAL_BAGS_BEGIN && slot_id <= EmuConstants::GENERAL_BAGS_END))
return true;
@@ -943,7 +943,7 @@ bool Inventory::SupportsPotionBeltCasting(int16 slot_id)
}
// Test whether a given slot can support a container item
bool Inventory::SupportsContainers(int16 slot_id)
bool InventoryOld::SupportsContainers(int16 slot_id)
{
if ((slot_id == MainCursor) ||
(slot_id >= EmuConstants::GENERAL_BEGIN && slot_id <= EmuConstants::GENERAL_END) ||
@@ -957,7 +957,7 @@ bool Inventory::SupportsContainers(int16 slot_id)
return false;
}
int Inventory::GetSlotByItemInst(ItemInst *inst) {
int InventoryOld::GetSlotByItemInst(ItemInst *inst) {
if (!inst)
return INVALID_INDEX;
@@ -993,7 +993,7 @@ int Inventory::GetSlotByItemInst(ItemInst *inst) {
return INVALID_INDEX;
}
uint8 Inventory::FindHighestLightValue()
uint8 InventoryOld::FindHighestLightValue()
{
uint8 light_value = NOT_USED;
@@ -1023,7 +1023,7 @@ uint8 Inventory::FindHighestLightValue()
return light_value;
}
void Inventory::dumpEntireInventory() {
void InventoryOld::dumpEntireInventory() {
dumpWornItems();
dumpInventory();
@@ -1033,29 +1033,29 @@ void Inventory::dumpEntireInventory() {
std::cout << std::endl;
}
void Inventory::dumpWornItems() {
void InventoryOld::dumpWornItems() {
std::cout << "Worn items:" << std::endl;
dumpItemCollection(m_worn);
}
void Inventory::dumpInventory() {
void InventoryOld::dumpInventory() {
std::cout << "Inventory items:" << std::endl;
dumpItemCollection(m_inv);
}
void Inventory::dumpBankItems() {
void InventoryOld::dumpBankItems() {
std::cout << "Bank items:" << std::endl;
dumpItemCollection(m_bank);
}
void Inventory::dumpSharedBankItems() {
void InventoryOld::dumpSharedBankItems() {
std::cout << "Shared Bank items:" << std::endl;
dumpItemCollection(m_shbank);
}
int Inventory::GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &collection, ItemInst *inst) {
int InventoryOld::GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &collection, ItemInst *inst) {
for (auto iter = collection.begin(); iter != collection.end(); ++iter) {
ItemInst *t_inst = iter->second;
if (t_inst == inst) {
@@ -1065,7 +1065,7 @@ int Inventory::GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &col
if (t_inst && !t_inst->IsType(ItemClassContainer)) {
for (auto b_iter = t_inst->_cbegin(); b_iter != t_inst->_cend(); ++b_iter) {
if (b_iter->second == inst) {
return Inventory::CalcSlotId(iter->first, b_iter->first);
return InventoryOld::CalcSlotId(iter->first, b_iter->first);
}
}
}
@@ -1074,7 +1074,7 @@ int Inventory::GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &col
return -1;
}
void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection)
void InventoryOld::dumpItemCollection(const std::map<int16, ItemInst*> &collection)
{
for (auto it = collection.cbegin(); it != collection.cend(); ++it) {
auto inst = it->second;
@@ -1088,7 +1088,7 @@ void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection)
}
}
void Inventory::dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::const_iterator *it)
void InventoryOld::dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::const_iterator *it)
{
if (!inst || !inst->IsType(ItemClassContainer))
return;
@@ -1099,7 +1099,7 @@ void Inventory::dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::cons
if (!baginst || !baginst->GetItem())
continue;
std::string subSlot = StringFormat(" Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
std::string subSlot = StringFormat(" Slot %d: %s (%d)", InventoryOld::CalcSlotId((*it)->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges() <= 0) ? 1 : baginst->GetCharges());
std::cout << subSlot << std::endl;
}
@@ -1107,7 +1107,7 @@ void Inventory::dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::cons
}
// Internal Method: Retrieves item within an inventory bucket
ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
ItemInst* InventoryOld::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
{
auto it = bucket.find(slot_id);
if (it != bucket.end()) {
@@ -1120,7 +1120,7 @@ ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 sl
// Internal Method: "put" item into bucket, without regard for what is currently in bucket
// Assumes item has already been allocated
int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
int16 InventoryOld::_PutItem(int16 slot_id, ItemInst* inst)
{
// What happens here when we _PutItem(MainCursor)? Bad things..really bad things...
//
@@ -1166,25 +1166,25 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
}
else {
// Slot must be within a bag
parentSlot = Inventory::CalcSlotId(slot_id);
parentSlot = InventoryOld::CalcSlotId(slot_id);
ItemInst* baginst = GetItem(parentSlot); // Get parent bag
if (baginst && baginst->IsType(ItemClassContainer))
{
baginst->_PutItem(Inventory::CalcBagIdx(slot_id), inst);
baginst->_PutItem(InventoryOld::CalcBagIdx(slot_id), inst);
result = slot_id;
}
}
if (result == INVALID_INDEX) {
Log.Out(Logs::General, Logs::Error, "Inventory::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot);
Inventory::MarkDirty(inst); // Slot not found, clean up
Log.Out(Logs::General, Logs::Error, "InventoryOld::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot);
InventoryOld::MarkDirty(inst); // Slot not found, clean up
}
return result;
}
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
int16 InventoryOld::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
{
uint8 quantity_found = 0;
@@ -1212,7 +1212,7 @@ int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, ui
if (bag_inst->GetID() == item_id) {
quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(iter->first, bag_iter->first);
return InventoryOld::CalcSlotId(iter->first, bag_iter->first);
}
for (int index = AUG_BEGIN; index < EmuConstants::ITEM_COMMON_SIZE; ++index) {
@@ -1226,7 +1226,7 @@ int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, ui
}
// Internal Method: Checks an inventory queue type bucket for a particular item
int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
int16 InventoryOld::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
{
// The downfall of this (these) queue procedure is that callers presume that when an item is
// found, it is presented as being available on the cursor. In cases of a parity check, this
@@ -1260,7 +1260,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
if (bag_inst->GetID() == item_id) {
quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(MainCursor, bag_iter->first);
return InventoryOld::CalcSlotId(MainCursor, bag_iter->first);
}
for (int index = AUG_BEGIN; index < EmuConstants::ITEM_COMMON_SIZE; ++index) {
@@ -1277,7 +1277,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
}
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
int16 InventoryOld::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
{
uint8 quantity_found = 0;
@@ -1300,7 +1300,7 @@ int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, ui
if (bag_inst->IsType(ItemClassCommon) && bag_inst->GetItem()->ItemType == use) {
quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(iter->first, bag_iter->first);
return InventoryOld::CalcSlotId(iter->first, bag_iter->first);
}
}
}
@@ -1309,7 +1309,7 @@ int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, ui
}
// Internal Method: Checks an inventory queue type bucket for a particular item
int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
int16 InventoryOld::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
{
uint8 quantity_found = 0;
@@ -1332,7 +1332,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
if (bag_inst->IsType(ItemClassCommon) && bag_inst->GetItem()->ItemType == use) {
quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(MainCursor, bag_iter->first);
return InventoryOld::CalcSlotId(MainCursor, bag_iter->first);
}
}
@@ -1343,7 +1343,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
return INVALID_INDEX;
}
int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup)
int16 InventoryOld::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup)
{
for (auto iter = bucket.begin(); iter != bucket.end(); ++iter) {
auto inst = iter->second;
@@ -1367,7 +1367,7 @@ int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32
if (bag_inst == nullptr) { continue; }
if (bag_inst->IsType(ItemClassCommon) && bag_inst->GetItem()->LoreGroup == loregroup)
return Inventory::CalcSlotId(iter->first, bag_iter->first);
return InventoryOld::CalcSlotId(iter->first, bag_iter->first);
for (int index = AUG_BEGIN; index < EmuConstants::ITEM_COMMON_SIZE; ++index) {
auto aug_inst = bag_inst->GetAugment(index);
@@ -1383,7 +1383,7 @@ int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32
}
// Internal Method: Checks an inventory queue type bucket for a particular item
int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
int16 InventoryOld::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
{
for (auto iter = iqueue.cbegin(); iter != iqueue.cend(); ++iter) {
auto inst = *iter;
@@ -1407,7 +1407,7 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
if (bag_inst == nullptr) { continue; }
if (bag_inst->IsType(ItemClassCommon) && bag_inst->GetItem()->LoreGroup == loregroup)
return Inventory::CalcSlotId(MainCursor, bag_iter->first);
return InventoryOld::CalcSlotId(MainCursor, bag_iter->first);
for (int index = AUG_BEGIN; index < EmuConstants::ITEM_COMMON_SIZE; ++index) {
auto aug_inst = bag_inst->GetAugment(index);
@@ -2150,7 +2150,7 @@ ItemInst* ItemInst::Clone() const
bool ItemInst::IsSlotAllowed(int16 slot_id) const {
// 'SupportsContainers' and 'slot_id > 21' previously saw the reassigned PowerSource slot (9999 to 22) as valid -U
if (!m_item) { return false; }
else if (Inventory::SupportsContainers(slot_id)) { return true; }
else if (InventoryOld::SupportsContainers(slot_id)) { return true; }
else if (m_item->Slots & (1 << slot_id)) { return true; }
else if (slot_id == MainPowerSource && (m_item->Slots & (1 << 22))) { return true; } // got lazy... <watch>
else if (slot_id != MainPowerSource && slot_id > EmuConstants::EQUIPMENT_END) { return true; }
+5 -5
View File
@@ -104,9 +104,9 @@ protected:
};
// ########################################
// Class: Inventory
// Class: InventoryOld
// Character inventory
class Inventory
class InventoryOld
{
friend class ItemInst;
public:
@@ -114,8 +114,8 @@ public:
// Public Methods
///////////////////////////////
Inventory() { m_version = ClientVersion::Unknown; m_versionset = false; }
~Inventory();
InventoryOld() { m_version = ClientVersion::Unknown; m_versionset = false; }
~InventoryOld();
// Inventory v2 creep
bool SetInventoryVersion(ClientVersion version) {
@@ -425,7 +425,7 @@ protected:
std::map<uint8, ItemInst*>::const_iterator _cbegin() { return m_contents.cbegin(); }
std::map<uint8, ItemInst*>::const_iterator _cend() { return m_contents.cend(); }
friend class Inventory;
friend class InventoryOld;
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
+2 -2
View File
@@ -5031,7 +5031,7 @@ namespace RoF
ss.write(tmp, strlen(tmp));
ss.write((const char*)&null_term, sizeof(uint8));
ornaIcon = inst->GetOrnamentationIcon();
heroModel = inst->GetOrnamentHeroModel(Inventory::CalcMaterialFromSlot(slot_id_in));
heroModel = inst->GetOrnamentHeroModel(InventoryOld::CalcMaterialFromSlot(slot_id_in));
}
else
{
@@ -5474,7 +5474,7 @@ namespace RoF
/*
// TEST CODE: <watch>
SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
SubSlotNumber = InventoryOld::CalcSlotID(slot_id_in, x);
*/
SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1);
+2 -2
View File
@@ -5194,7 +5194,7 @@ namespace RoF2
ss.write(tmp, strlen(tmp));
ss.write((const char*)&null_term, sizeof(uint8));
ornaIcon = inst->GetOrnamentationIcon();
heroModel = inst->GetOrnamentHeroModel(Inventory::CalcMaterialFromSlot(slot_id_in));
heroModel = inst->GetOrnamentHeroModel(InventoryOld::CalcMaterialFromSlot(slot_id_in));
}
else
{
@@ -5650,7 +5650,7 @@ namespace RoF2
/*
// TEST CODE: <watch>
SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
SubSlotNumber = InventoryOld::CalcSlotID(slot_id_in, x);
*/
SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1, packet_type);
+1 -1
View File
@@ -3913,7 +3913,7 @@ namespace SoD
/*
// TEST CODE: <watch>
SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
SubSlotNumber = InventoryOld::CalcSlotID(slot_id_in, x);
*/
SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1);
+1 -1
View File
@@ -3235,7 +3235,7 @@ namespace SoF
/*
// TEST CODE: <watch>
SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
SubSlotNumber = InventoryOld::CalcSlotID(slot_id_in, x);
*/
SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1);
+1 -1
View File
@@ -4214,7 +4214,7 @@ namespace UF
/*
// TEST CODE: <watch>
SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
SubSlotNumber = InventoryOld::CalcSlotID(slot_id_in, x);
*/
SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1);
+12 -12
View File
@@ -208,10 +208,10 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, i
auto results = QueryDatabase(query);
// Save bag contents, if slot supports bag contents
if (inst->IsType(ItemClassContainer) && Inventory::SupportsContainers(slot_id))
if (inst->IsType(ItemClassContainer) && InventoryOld::SupportsContainers(slot_id))
for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) {
const ItemInst* baginst = inst->GetItem(idx);
SaveInventory(char_id, baginst, Inventory::CalcSlotId(slot_id, idx));
SaveInventory(char_id, baginst, InventoryOld::CalcSlotId(slot_id, idx));
}
if (!results.Success()) {
@@ -252,10 +252,10 @@ bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst,
auto results = QueryDatabase(query);
// Save bag contents, if slot supports bag contents
if (inst->IsType(ItemClassContainer) && Inventory::SupportsContainers(slot_id)) {
if (inst->IsType(ItemClassContainer) && InventoryOld::SupportsContainers(slot_id)) {
for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) {
const ItemInst* baginst = inst->GetItem(idx);
SaveInventory(char_id, baginst, Inventory::CalcSlotId(slot_id, idx));
SaveInventory(char_id, baginst, InventoryOld::CalcSlotId(slot_id, idx));
}
}
@@ -276,10 +276,10 @@ bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id) {
}
// Delete bag slots, if need be
if (!Inventory::SupportsContainers(slot_id))
if (!InventoryOld::SupportsContainers(slot_id))
return true;
int16 base_slot_id = Inventory::CalcSlotId(slot_id, SUB_BEGIN);
int16 base_slot_id = InventoryOld::CalcSlotId(slot_id, SUB_BEGIN);
query = StringFormat("DELETE FROM inventory WHERE charid = %i AND slotid >= %i AND slotid < %i",
char_id, base_slot_id, (base_slot_id+10));
results = QueryDatabase(query);
@@ -302,10 +302,10 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) {
}
// Delete bag slots, if need be
if (!Inventory::SupportsContainers(slot_id))
if (!InventoryOld::SupportsContainers(slot_id))
return true;
int16 base_slot_id = Inventory::CalcSlotId(slot_id, SUB_BEGIN);
int16 base_slot_id = InventoryOld::CalcSlotId(slot_id, SUB_BEGIN);
query = StringFormat("DELETE FROM sharedbank WHERE acctid = %i "
"AND slotid >= %i AND slotid < %i",
account_id, base_slot_id, (base_slot_id+10));
@@ -345,7 +345,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) {
return true;
}
bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level) {
bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, InventoryOld* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level) {
const Item_Struct* myitem;
@@ -382,7 +382,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv,
// Retrieve shared bank inventory based on either account or character
bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
bool SharedDatabase::GetSharedBank(uint32 id, InventoryOld *inv, bool is_charid)
{
std::string query;
@@ -482,7 +482,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid)
}
// Overloaded: Retrieve character inventory based on character id
bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
bool SharedDatabase::GetInventory(uint32 char_id, InventoryOld *inv)
{
// Retrieve character inventory
std::string query =
@@ -625,7 +625,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv)
}
// Overloaded: Retrieve character inventory based on account_id and character name
bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv)
bool SharedDatabase::GetInventory(uint32 account_id, char *name, InventoryOld *inv)
{
// Retrieve character inventory
std::string query =
+5 -5
View File
@@ -14,7 +14,7 @@
#include <map>
class EvolveInfo;
class Inventory;
class InventoryOld;
class ItemInst;
struct BaseDataStruct;
struct InspectMessage_Struct;
@@ -65,15 +65,15 @@ class SharedDatabase : public Database
bool UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id);
bool UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id);
bool VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst);
bool GetSharedBank(uint32 id, Inventory* inv, bool is_charid);
bool GetSharedBank(uint32 id, InventoryOld* inv, bool is_charid);
int32 GetSharedPlatinum(uint32 account_id);
bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add);
bool GetInventory(uint32 char_id, Inventory* inv);
bool GetInventory(uint32 account_id, char* name, Inventory* inv);
bool GetInventory(uint32 char_id, InventoryOld* inv);
bool GetInventory(uint32 account_id, char* name, InventoryOld* inv);
std::map<uint32, uint32> GetItemRecastTimestamps(uint32 char_id);
uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type);
void ClearOldRecastTimestamps(uint32 char_id);
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
bool SetStartingItems(PlayerProfile_Struct* pp, InventoryOld* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
std::string GetBook(const char *txtfile);