InventoryOld in client has been unhooked from loading/saving

This commit is contained in:
KimLS 2015-02-18 20:29:58 -08:00
parent fc2492a859
commit a5274b9b6e
10 changed files with 331 additions and 254 deletions

View File

@ -27,6 +27,7 @@
#include "dbcore.h" #include "dbcore.h"
#include "linked_list.h" #include "linked_list.h"
#include "eq_packet_structs.h" #include "eq_packet_structs.h"
#include "inventory.h"
#include <cmath> #include <cmath>
#include <string> #include <string>

View File

@ -18,3 +18,21 @@
#include "inventory.h" #include "inventory.h"
EQEmu::Inventory::Inventory() {
}
EQEmu::Inventory::~Inventory() {
}
std::shared_ptr<EQEmu::ItemInstance> EQEmu::Inventory::GetItem(InventoryType type, int16 slot) {
auto area = items_.find(type);
if(area != items_.end()) {
auto item = area->second.find(slot);
if(item != area->second.end()) {
return item->second;
}
}
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
}

View File

@ -19,12 +19,36 @@
#ifndef COMMON_INVENTORY_H #ifndef COMMON_INVENTORY_H
#define COMMON_INVENTORY_H #define COMMON_INVENTORY_H
#include "item_instance.h"
#include <map>
#include <memory>
#include <tuple>
namespace EQEmu namespace EQEmu
{ {
enum InventoryType : int16
{
InvTypePersonal,
InvTypeBank,
InvTypeSharedBank,
InvTypeTrade,
InvTypeWorld,
InvTypeCursorBuffer,
InvTypeTribute,
InvTypeTrophyTribute,
InvTypeGuildTribute
};
class Inventory class Inventory
{ {
public: public:
Inventory();
~Inventory();
std::shared_ptr<ItemInstance> GetItem(InventoryType type, int16 slot);
private: private:
std::map<int16, std::map<int16, std::shared_ptr<ItemInstance>>> items_;
}; };
} // EQEmu } // EQEmu

View File

@ -17,3 +17,54 @@
*/ */
#include "item_instance.h" #include "item_instance.h"
#include "data_verification.h"
EQEmu::ItemInstance::ItemInstance() {
base_item_ = nullptr;
modified_item_ = nullptr;
charges_ = -1;
color_ = 0;
attuned_ = false;
ornament_idfile_ = 0;
ornament_icon_ = 0;
ornament_hero_model_ = 0;
tracking_id_ = 0;
}
EQEmu::ItemInstance::ItemInstance(const ItemData* idata) {
base_item_ = idata;
modified_item_ = nullptr;
charges_ = -1;
color_ = 0;
attuned_ = false;
ornament_idfile_ = 0;
ornament_icon_ = 0;
ornament_hero_model_ = 0;
tracking_id_ = 0;
}
EQEmu::ItemInstance::ItemInstance(const ItemData* idata, int16 charges) {
base_item_ = idata;
modified_item_ = nullptr;
charges_ = charges;
color_ = 0;
attuned_ = false;
ornament_idfile_ = 0;
ornament_icon_ = 0;
ornament_hero_model_ = 0;
tracking_id_ = 0;
}
EQEmu::ItemInstance::~ItemInstance() {
}
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::GetItem(int index) {
if(EQEmu::ValueWithin(index, 0, 200)) {
auto iter = contents_.find(index);
if(iter != contents_.end()) {
return iter->second;
}
}
return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
}

View File

@ -19,12 +19,34 @@
#ifndef COMMON_ITEM_INSTANCE_H #ifndef COMMON_ITEM_INSTANCE_H
#define COMMON_ITEM_INSTANCE_H #define COMMON_ITEM_INSTANCE_H
#include "item_data.h"
#include <string>
#include <memory>
#include <map>
namespace EQEmu namespace EQEmu
{ {
class ItemInstance class ItemInstance
{ {
public: public:
ItemInstance();
ItemInstance(const ItemData* idata);
ItemInstance(const ItemData* idata, int16 charges);
~ItemInstance();
std::shared_ptr<ItemInstance> GetItem(int index);
private: private:
const ItemData *base_item_;
ItemData *modified_item_;
int16 charges_;
uint32 color_;
bool attuned_;
std::string custom_data_;
uint32 ornament_idfile_;
uint32 ornament_icon_;
uint32 ornament_hero_model_;
uint64 tracking_id_;
std::map<int, std::shared_ptr<ItemInstance>> contents_;
}; };
} // EQEmu } // EQEmu

View File

@ -151,74 +151,77 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite
bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) { bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) {
// If we never save tribute slots..how are we to ever benefit from them!!? The client return true;
// object is destroyed upon zoning - including its inventory object..and if tributes //// If we never save tribute slots..how are we to ever benefit from them!!? The client
// don't exist in the database, then they will never be loaded when the new client //// object is destroyed upon zoning - including its inventory object..and if tributes
// object is created in the new zone object... Something to consider... -U //// don't exist in the database, then they will never be loaded when the new client
//// object is created in the new zone object... Something to consider... -U
////
//// (we could add them to the 'NoRent' checks and dispose of after 30 minutes offline)
// //
// (we could add them to the 'NoRent' checks and dispose of after 30 minutes offline) ////never save tribute slots:
//if(slot_id >= EmuConstants::TRIBUTE_BEGIN && slot_id <= EmuConstants::TRIBUTE_END)
//never save tribute slots: // return true;
if(slot_id >= EmuConstants::TRIBUTE_BEGIN && slot_id <= EmuConstants::TRIBUTE_END) //
return true; //if (slot_id >= EmuConstants::SHARED_BANK_BEGIN && slot_id <= EmuConstants::SHARED_BANK_BAGS_END) {
// // Shared bank inventory
if (slot_id >= EmuConstants::SHARED_BANK_BEGIN && slot_id <= EmuConstants::SHARED_BANK_BAGS_END) { // if (!inst)
// Shared bank inventory // return DeleteSharedBankSlot(char_id, slot_id);
if (!inst) // else
return DeleteSharedBankSlot(char_id, slot_id); // return UpdateSharedBankSlot(char_id, inst, slot_id);
else //}
return UpdateSharedBankSlot(char_id, inst, slot_id); //else if (!inst) { // All other inventory
} // return DeleteInventorySlot(char_id, slot_id);
else if (!inst) { // All other inventory //}
return DeleteInventorySlot(char_id, slot_id); //
} //return UpdateInventorySlot(char_id, inst, slot_id);
return UpdateInventorySlot(char_id, inst, slot_id);
} }
bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id) { bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id) {
// need to check 'inst' argument for valid pointer
uint32 augslot[EmuConstants::ITEM_COMMON_SIZE] = { NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM };
if (inst->IsType(ItemClassCommon)) {
for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
ItemInst *auginst = inst->GetItem(i);
augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : NO_ITEM;
}
}
uint16 charges = 0;
if(inst->GetCharges() >= 0)
charges = inst->GetCharges();
else
charges = 0x7FFF;
// Update/Insert item
std::string query = StringFormat("REPLACE INTO inventory "
"(charid, slotid, itemid, charges, instnodrop, custom_data, color, "
"augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, ornamenticon, ornamentidfile, ornament_hero_model) "
"VALUES( %lu, %lu, %lu, %lu, %lu, '%s', %lu, "
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu)",
(unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID,
(unsigned long)charges, (unsigned long)(inst->IsAttuned()? 1: 0),
inst->GetCustomDataString().c_str(), (unsigned long)inst->GetColor(),
(unsigned long)augslot[0], (unsigned long)augslot[1], (unsigned long)augslot[2],
(unsigned long)augslot[3], (unsigned long)augslot[4], (unsigned long)augslot[5], (unsigned long)inst->GetOrnamentationIcon(),
(unsigned long)inst->GetOrnamentationIDFile(), (unsigned long)inst->GetOrnamentHeroModel());
auto results = QueryDatabase(query);
// Save bag contents, if slot supports bag contents
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, InventoryOld::CalcSlotId(slot_id, idx));
}
if (!results.Success()) {
return false;
}
return true; return true;
// need to check 'inst' argument for valid pointer
//
//uint32 augslot[EmuConstants::ITEM_COMMON_SIZE] = { NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM };
//if (inst->IsType(ItemClassCommon)) {
// for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
// ItemInst *auginst = inst->GetItem(i);
// augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : NO_ITEM;
// }
//}
//
//uint16 charges = 0;
//if(inst->GetCharges() >= 0)
// charges = inst->GetCharges();
//else
// charges = 0x7FFF;
//
//// Update/Insert item
//std::string query = StringFormat("REPLACE INTO inventory "
// "(charid, slotid, itemid, charges, instnodrop, custom_data, color, "
// "augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, ornamenticon, ornamentidfile, ornament_hero_model) "
// "VALUES( %lu, %lu, %lu, %lu, %lu, '%s', %lu, "
// "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu)",
// (unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID,
// (unsigned long)charges, (unsigned long)(inst->IsAttuned()? 1: 0),
// inst->GetCustomDataString().c_str(), (unsigned long)inst->GetColor(),
// (unsigned long)augslot[0], (unsigned long)augslot[1], (unsigned long)augslot[2],
// (unsigned long)augslot[3], (unsigned long)augslot[4], (unsigned long)augslot[5], (unsigned long)inst->GetOrnamentationIcon(),
// (unsigned long)inst->GetOrnamentationIDFile(), (unsigned long)inst->GetOrnamentHeroModel());
//auto results = QueryDatabase(query);
//
//// Save bag contents, if slot supports bag contents
//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, InventoryOld::CalcSlotId(slot_id, idx));
// }
//
//if (!results.Success()) {
// return false;
//}
//
//return true;
} }
bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id) { bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id) {
@ -482,146 +485,147 @@ bool SharedDatabase::GetSharedBank(uint32 id, InventoryOld *inv, bool is_charid)
} }
// Overloaded: Retrieve character inventory based on character id // Overloaded: Retrieve character inventory based on character id
bool SharedDatabase::GetInventory(uint32 char_id, InventoryOld *inv) bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::Inventory *inv)
{ {
// Retrieve character inventory return false;
std::string query = //// Retrieve character inventory
StringFormat("SELECT slotid, itemid, charges, color, augslot1, augslot2, augslot3, augslot4, augslot5, " //std::string query =
"augslot6, instnodrop, custom_data, ornamenticon, ornamentidfile, ornament_hero_model FROM " // StringFormat("SELECT slotid, itemid, charges, color, augslot1, augslot2, augslot3, augslot4, augslot5, "
"inventory WHERE charid = %i ORDER BY slotid", // "augslot6, instnodrop, custom_data, ornamenticon, ornamentidfile, ornament_hero_model FROM "
char_id); // "inventory WHERE charid = %i ORDER BY slotid",
auto results = QueryDatabase(query); // char_id);
if (!results.Success()) { //auto results = QueryDatabase(query);
Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " //if (!results.Success()) {
"following SQL Queries:\nalter table inventory add instnodrop " // Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the "
"tinyint(1) unsigned default 0 not null;\n"); // "following SQL Queries:\nalter table inventory add instnodrop "
return false; // "tinyint(1) unsigned default 0 not null;\n");
} // return false;
//}
auto timestamps = GetItemRecastTimestamps(char_id); //
//auto timestamps = GetItemRecastTimestamps(char_id);
for (auto row = results.begin(); row != results.end(); ++row) { //
int16 slot_id = atoi(row[0]); //for (auto row = results.begin(); row != results.end(); ++row) {
uint32 item_id = atoi(row[1]); // int16 slot_id = atoi(row[0]);
uint16 charges = atoi(row[2]); // uint32 item_id = atoi(row[1]);
uint32 color = atoul(row[3]); // uint16 charges = atoi(row[2]);
// uint32 color = atoul(row[3]);
uint32 aug[EmuConstants::ITEM_COMMON_SIZE]; //
// uint32 aug[EmuConstants::ITEM_COMMON_SIZE];
aug[0] = (uint32)atoul(row[4]); //
aug[1] = (uint32)atoul(row[5]); // aug[0] = (uint32)atoul(row[4]);
aug[2] = (uint32)atoul(row[6]); // aug[1] = (uint32)atoul(row[5]);
aug[3] = (uint32)atoul(row[7]); // aug[2] = (uint32)atoul(row[6]);
aug[4] = (uint32)atoul(row[8]); // aug[3] = (uint32)atoul(row[7]);
aug[5] = (uint32)atoul(row[9]); // aug[4] = (uint32)atoul(row[8]);
// aug[5] = (uint32)atoul(row[9]);
bool instnodrop = (row[10] && (uint16)atoi(row[10])) ? true : false; //
// bool instnodrop = (row[10] && (uint16)atoi(row[10])) ? true : false;
uint32 ornament_icon = (uint32)atoul(row[12]); //
uint32 ornament_idfile = (uint32)atoul(row[13]); // uint32 ornament_icon = (uint32)atoul(row[12]);
uint32 ornament_hero_model = (uint32)atoul(row[14]); // uint32 ornament_idfile = (uint32)atoul(row[13]);
// uint32 ornament_hero_model = (uint32)atoul(row[14]);
const ItemData *item = GetItem(item_id); //
// const ItemData *item = GetItem(item_id);
if (!item) { //
Log.Out(Logs::General, Logs::Error, // if (!item) {
"Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, // Log.Out(Logs::General, Logs::Error,
slot_id); // "Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id,
continue; // slot_id);
} // continue;
// }
int16 put_slot_id = INVALID_INDEX; //
// int16 put_slot_id = INVALID_INDEX;
ItemInst *inst = CreateBaseItem(item, charges); //
// ItemInst *inst = CreateBaseItem(item, charges);
if (inst == nullptr) //
continue; // if (inst == nullptr)
// continue;
if (row[11]) { //
std::string data_str(row[11]); // if (row[11]) {
std::string idAsString; // std::string data_str(row[11]);
std::string value; // std::string idAsString;
bool use_id = true; // std::string value;
// bool use_id = true;
for (int i = 0; i < data_str.length(); ++i) { //
if (data_str[i] == '^') { // for (int i = 0; i < data_str.length(); ++i) {
if (!use_id) { // if (data_str[i] == '^') {
inst->SetCustomData(idAsString, value); // if (!use_id) {
idAsString.clear(); // inst->SetCustomData(idAsString, value);
value.clear(); // idAsString.clear();
} // value.clear();
// }
use_id = !use_id; //
continue; // use_id = !use_id;
} // continue;
// }
char v = data_str[i]; //
if (use_id) // char v = data_str[i];
idAsString.push_back(v); // if (use_id)
else // idAsString.push_back(v);
value.push_back(v); // else
} // value.push_back(v);
} // }
// }
inst->SetOrnamentIcon(ornament_icon); //
inst->SetOrnamentationIDFile(ornament_idfile); // inst->SetOrnamentIcon(ornament_icon);
inst->SetOrnamentHeroModel(ornament_hero_model); // inst->SetOrnamentationIDFile(ornament_idfile);
// inst->SetOrnamentHeroModel(ornament_hero_model);
if (instnodrop || //
(((slot_id >= EmuConstants::EQUIPMENT_BEGIN && slot_id <= EmuConstants::EQUIPMENT_END) || // if (instnodrop ||
slot_id == MainPowerSource) && // (((slot_id >= EmuConstants::EQUIPMENT_BEGIN && slot_id <= EmuConstants::EQUIPMENT_END) ||
inst->GetItem()->Attuneable)) // slot_id == MainPowerSource) &&
inst->SetAttuned(true); // inst->GetItem()->Attuneable))
// inst->SetAttuned(true);
if (color > 0) //
inst->SetColor(color); // if (color > 0)
// inst->SetColor(color);
if (charges == 0x7FFF) //
inst->SetCharges(-1); // if (charges == 0x7FFF)
else if (charges == 0 && // inst->SetCharges(-1);
inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable. // else if (charges == 0 &&
inst->SetCharges(1); // inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable.
else // inst->SetCharges(1);
inst->SetCharges(charges); // else
// inst->SetCharges(charges);
if (item->RecastDelay) { //
if (timestamps.count(item->RecastType)) // if (item->RecastDelay) {
inst->SetRecastTimestamp(timestamps.at(item->RecastType)); // if (timestamps.count(item->RecastType))
else // inst->SetRecastTimestamp(timestamps.at(item->RecastType));
inst->SetRecastTimestamp(0); // else
} // inst->SetRecastTimestamp(0);
// }
if (item->ItemClass == ItemClassCommon) { //
for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) { // if (item->ItemClass == ItemClassCommon) {
if (aug[i]) // for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
inst->PutAugment(this, i, aug[i]); // if (aug[i])
} // inst->PutAugment(this, i, aug[i]);
} // }
// }
if (slot_id >= 8000 && slot_id <= 8999) { //
put_slot_id = inv->PushCursor(*inst); // if (slot_id >= 8000 && slot_id <= 8999) {
} else if (slot_id >= 3111 && slot_id <= 3179) { // put_slot_id = inv->PushCursor(*inst);
// Admins: please report any occurrences of this error // } else if (slot_id >= 3111 && slot_id <= 3179) {
Log.Out(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: " // // Admins: please report any occurrences of this error
"charid=%i, item_id=%i, slot_id=%i .. pushing to cursor...", // Log.Out(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: "
char_id, item_id, slot_id); // "charid=%i, item_id=%i, slot_id=%i .. pushing to cursor...",
put_slot_id = inv->PushCursor(*inst); // char_id, item_id, slot_id);
} else { // put_slot_id = inv->PushCursor(*inst);
put_slot_id = inv->PutItem(slot_id, *inst); // } else {
} // put_slot_id = inv->PutItem(slot_id, *inst);
// }
safe_delete(inst); //
// safe_delete(inst);
// Save ptr to item in inventory //
if (put_slot_id == INVALID_INDEX) { // // Save ptr to item in inventory
Log.Out(Logs::General, Logs::Error, // if (put_slot_id == INVALID_INDEX) {
"Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i", // Log.Out(Logs::General, Logs::Error,
char_id, item_id, slot_id); // "Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i",
} // char_id, item_id, slot_id);
} // }
//}
// Retrieve shared inventory //
return GetSharedBank(char_id, inv, true); //// Retrieve shared inventory
//return GetSharedBank(char_id, inv, true);
} }
// Overloaded: Retrieve character inventory based on account_id and character name // Overloaded: Retrieve character inventory based on account_id and character name

View File

@ -9,6 +9,7 @@
#include "base_data.h" #include "base_data.h"
#include "fixed_memory_hash_set.h" #include "fixed_memory_hash_set.h"
#include "fixed_memory_variable_hash_set.h" #include "fixed_memory_variable_hash_set.h"
#include "inventory.h"
#include <list> #include <list>
#include <map> #include <map>
@ -68,7 +69,7 @@ class SharedDatabase : public Database
bool GetSharedBank(uint32 id, InventoryOld* inv, bool is_charid); bool GetSharedBank(uint32 id, InventoryOld* inv, bool is_charid);
int32 GetSharedPlatinum(uint32 account_id); int32 GetSharedPlatinum(uint32 account_id);
bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add); bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add);
bool GetInventory(uint32 char_id, InventoryOld* inv); bool GetInventory(uint32 char_id, EQEmu::Inventory* inv);
bool GetInventory(uint32 account_id, char* name, InventoryOld* inv); bool GetInventory(uint32 account_id, char* name, InventoryOld* inv);
std::map<uint32, uint32> GetItemRecastTimestamps(uint32 char_id); std::map<uint32, uint32> GetItemRecastTimestamps(uint32 char_id);
uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type); uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type);

View File

@ -1271,7 +1271,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
m_pp.platinum_shared = database.GetSharedPlatinum(this->AccountID()); m_pp.platinum_shared = database.GetSharedPlatinum(this->AccountID());
database.ClearOldRecastTimestamps(cid); /* Clear out our old recast timestamps to keep the DB clean */ database.ClearOldRecastTimestamps(cid); /* Clear out our old recast timestamps to keep the DB clean */
loaditems = database.GetInventory(cid, &m_inv); /* Load Character Inventory */ loaditems = database.GetInventory(cid, &m_inventory); /* Load Character Inventory */
database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */ database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */
database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */ database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */
database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */ database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */

View File

@ -814,11 +814,6 @@ void Client::OnDisconnect(bool hard_disconnect) {
Disconnect(); Disconnect();
} }
// Sends the client complete inventory used in character login
// DO WE STILL NEED THE 'ITEMCOMBINED' CONDITIONAL CODE? -U
//#ifdef ITEMCOMBINED
void Client::BulkSendInventoryItems() { void Client::BulkSendInventoryItems() {
int16 slot_id = 0; int16 slot_id = 0;
@ -919,51 +914,6 @@ void Client::BulkSendInventoryItems() {
QueuePacket(outapp); QueuePacket(outapp);
safe_delete(outapp); safe_delete(outapp);
} }
/*#else
void Client::BulkSendInventoryItems()
{
// Search all inventory buckets for items
bool deletenorent=database.NoRentExpired(GetName());
// Worn items and Inventory items
int16 slot_id = 0;
if(deletenorent){//client was offline for more than 30 minutes, delete no rent items
RemoveNoRent();
}
for (slot_id=EmuConstants::POSSESSIONS_BEGIN; slot_id<=EmuConstants::POSSESSIONS_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst){
SendItemPacket(slot_id, inst, ItemPacketCharInventory);
}
}
// Bank items
for (slot_id=EmuConstants::BANK_BEGIN; slot_id<=EmuConstants::BANK_END; slot_id++) { // 2015...
const ItemInst* inst = m_inv[slot_id];
if (inst){
SendItemPacket(slot_id, inst, ItemPacketCharInventory);
}
}
// Shared Bank items
for (slot_id=EmuConstants::SHARED_BANK_BEGIN; slot_id<=EmuConstants::SHARED_BANK_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst){
SendItemPacket(slot_id, inst, ItemPacketCharInventory);
}
}
// LINKDEAD TRADE ITEMS
// If player went LD during a trade, they have items in the trade inventory
// slots. These items are now being put into their inventory (then queue up on cursor)
for (int16 trade_slot_id=EmuConstants::TRADE_BEGIN; trade_slot_id<=EmuConstants::TRADE_END; trade_slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst) {
int16 free_slot_id = m_inv.FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size);
DeleteItemInInventory(trade_slot_id, 0, false);
PutItemInInventory(free_slot_id, *inst, true);
}
}
}
#endif*/
void Client::BulkSendMerchantInventory(int merchant_id, int npcid) { void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
const ItemData* handyitem = nullptr; const ItemData* handyitem = nullptr;

View File

@ -18,6 +18,7 @@
#ifndef MOB_H #ifndef MOB_H
#define MOB_H #define MOB_H
#include "../common/inventory.h"
#include "common.h" #include "common.h"
#include "entity.h" #include "entity.h"
#include "hate_list.h" #include "hate_list.h"
@ -940,6 +941,9 @@ public:
void Tune_FindAccuaryByHitChance(Mob* defender, Mob *attacker, float hit_chance, int interval, int max_loop, int avoid_override, int Msg = 0); void Tune_FindAccuaryByHitChance(Mob* defender, Mob *attacker, float hit_chance, int interval, int max_loop, int avoid_override, int Msg = 0);
void Tune_FindAvoidanceByHitChance(Mob* defender, Mob *attacker, float hit_chance, int interval, int max_loop, int acc_override, int Msg = 0); void Tune_FindAvoidanceByHitChance(Mob* defender, Mob *attacker, float hit_chance, int interval, int max_loop, int acc_override, int Msg = 0);
inline EQEmu::Inventory& GetInventory() { return m_inventory; }
inline const EQEmu::Inventory& GetInventory() const { return m_inventory; }
protected: protected:
void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillUseTypes attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic); void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillUseTypes attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic);
static uint16 GetProcID(uint16 spell_id, uint8 effect_index); static uint16 GetProcID(uint16 spell_id, uint8 effect_index);
@ -1273,6 +1277,8 @@ protected:
bool bEnraged; bool bEnraged;
bool destructibleobject; bool destructibleobject;
EQEmu::Inventory m_inventory;
private: private:
void _StopSong(); //this is not what you think it is void _StopSong(); //this is not what you think it is
Mob* target; Mob* target;