mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-27 02:12:25 +00:00
Basic arch work, doesn't make a ton of sense yet but it will
This commit is contained in:
parent
a5274b9b6e
commit
551c0ef368
@ -31,8 +31,10 @@ SET(common_sources
|
|||||||
guild_base.cpp
|
guild_base.cpp
|
||||||
guilds.cpp
|
guilds.cpp
|
||||||
inventory.cpp
|
inventory.cpp
|
||||||
|
inventory_database_controller.cpp
|
||||||
ipc_mutex.cpp
|
ipc_mutex.cpp
|
||||||
item.cpp
|
item.cpp
|
||||||
|
item_container.cpp
|
||||||
item_instance.cpp
|
item_instance.cpp
|
||||||
md5.cpp
|
md5.cpp
|
||||||
memory_mapped_file.cpp
|
memory_mapped_file.cpp
|
||||||
@ -138,8 +140,10 @@ SET(common_headers
|
|||||||
guild_base.h
|
guild_base.h
|
||||||
guilds.h
|
guilds.h
|
||||||
inventory.h
|
inventory.h
|
||||||
|
inventory_database_controller.h
|
||||||
ipc_mutex.h
|
ipc_mutex.h
|
||||||
item.h
|
item.h
|
||||||
|
item_container.h
|
||||||
item_data.h
|
item_data.h
|
||||||
item_fieldlist.h
|
item_fieldlist.h
|
||||||
item_instance.h
|
item_instance.h
|
||||||
|
|||||||
@ -23,16 +23,3 @@ EQEmu::Inventory::Inventory() {
|
|||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
@ -19,16 +19,15 @@
|
|||||||
#ifndef COMMON_INVENTORY_H
|
#ifndef COMMON_INVENTORY_H
|
||||||
#define COMMON_INVENTORY_H
|
#define COMMON_INVENTORY_H
|
||||||
|
|
||||||
#include "item_instance.h"
|
#include "item_container.h"
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
#include <string>
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
namespace EQEmu
|
namespace EQEmu
|
||||||
{
|
{
|
||||||
enum InventoryType : int16
|
enum InventoryType : int
|
||||||
{
|
{
|
||||||
InvTypePersonal,
|
InvTypePersonal = 0,
|
||||||
InvTypeBank,
|
InvTypeBank,
|
||||||
InvTypeSharedBank,
|
InvTypeSharedBank,
|
||||||
InvTypeTrade,
|
InvTypeTrade,
|
||||||
@ -45,10 +44,8 @@ namespace EQEmu
|
|||||||
Inventory();
|
Inventory();
|
||||||
~Inventory();
|
~Inventory();
|
||||||
|
|
||||||
std::shared_ptr<ItemInstance> GetItem(InventoryType type, int16 slot);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<int16, std::map<int16, std::shared_ptr<ItemInstance>>> items_;
|
std::map<int, ItemContainer> containers_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // EQEmu
|
} // EQEmu
|
||||||
|
|||||||
0
common/inventory_database_controller.cpp
Normal file
0
common/inventory_database_controller.cpp
Normal file
24
common/inventory_database_controller.h
Normal file
24
common/inventory_database_controller.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* EQEMu: Everquest Server Emulator
|
||||||
|
Copyright (C) 2001-2015 EQEMu Development Team (http://eqemulator.net)
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
are required to give you total support for your newly bought product;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_INVENTORY_DATABASE_CONTROLLER_H
|
||||||
|
#define COMMON_INVENTORY_DATABASE_CONTROLLER_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
52
common/item_container.cpp
Normal file
52
common/item_container.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include "item_container.h"
|
||||||
|
#include <map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
struct EQEmu::ItemContainer::impl
|
||||||
|
{
|
||||||
|
std::map<int, std::shared_ptr<ItemInstance>> items;
|
||||||
|
};
|
||||||
|
|
||||||
|
EQEmu::ItemContainer::ItemContainer()
|
||||||
|
{
|
||||||
|
impl_ = new impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
EQEmu::ItemContainer::~ItemContainer()
|
||||||
|
{
|
||||||
|
delete impl_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemContainer::Get(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EQEmu::ItemContainer::Put(int slot_id, std::shared_ptr<ItemInstance> inst) {
|
||||||
|
if(!inst)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto iter = impl_->items.find(slot_id);
|
||||||
|
if(iter == impl_->items.end()) {
|
||||||
|
impl_->items[slot_id] = inst;
|
||||||
|
//trigger put in slot_id
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EQEmu::ItemContainer::Delete(int slot_id) {
|
||||||
|
auto iter = impl_->items.find(slot_id);
|
||||||
|
if(iter == impl_->items.end()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
impl_->items.erase(iter);
|
||||||
|
//trigger delete in slotid
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
42
common/item_container.h
Normal file
42
common/item_container.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* EQEMu: Everquest Server Emulator
|
||||||
|
Copyright (C) 2001-2015 EQEMu Development Team (http://eqemulator.net)
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
are required to give you total support for your newly bought product;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_ITEM_CONTAINER_H
|
||||||
|
#define COMMON_ITEM_CONTAINER_H
|
||||||
|
|
||||||
|
#include "item_instance.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace EQEmu
|
||||||
|
{
|
||||||
|
class ItemContainer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ItemContainer();
|
||||||
|
~ItemContainer();
|
||||||
|
|
||||||
|
std::shared_ptr<ItemInstance> Get(int slot_id);
|
||||||
|
bool Put(int slot_id, std::shared_ptr<ItemInstance> inst);
|
||||||
|
bool Delete(int slot_id);
|
||||||
|
private:
|
||||||
|
struct impl;
|
||||||
|
impl *impl_;
|
||||||
|
};
|
||||||
|
} // EQEmu
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
namespace EQEmu
|
namespace EQEmu
|
||||||
{
|
{
|
||||||
|
class ItemContainer;
|
||||||
class ItemInstance
|
class ItemInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -35,6 +36,7 @@ namespace EQEmu
|
|||||||
~ItemInstance();
|
~ItemInstance();
|
||||||
|
|
||||||
std::shared_ptr<ItemInstance> GetItem(int index);
|
std::shared_ptr<ItemInstance> GetItem(int index);
|
||||||
|
void SetContainer(ItemContainer *parent) { parent_ = parent; }
|
||||||
private:
|
private:
|
||||||
const ItemData *base_item_;
|
const ItemData *base_item_;
|
||||||
ItemData *modified_item_;
|
ItemData *modified_item_;
|
||||||
@ -46,7 +48,9 @@ namespace EQEmu
|
|||||||
uint32 ornament_icon_;
|
uint32 ornament_icon_;
|
||||||
uint32 ornament_hero_model_;
|
uint32 ornament_hero_model_;
|
||||||
uint64 tracking_id_;
|
uint64 tracking_id_;
|
||||||
|
|
||||||
std::map<int, std::shared_ptr<ItemInstance>> contents_;
|
std::map<int, std::shared_ptr<ItemInstance>> contents_;
|
||||||
|
ItemContainer *parent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // EQEmu
|
} // EQEmu
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user