mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
adjust size type in itemcontainer to accommodate larger inventories
This commit is contained in:
parent
899b4aead3
commit
4b8783aeca
2 changed files with 18 additions and 18 deletions
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
extern Sapphire::Framework g_fw;
|
extern Sapphire::Framework g_fw;
|
||||||
|
|
||||||
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName,
|
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName,
|
||||||
bool isMultiStorage, bool isPersistentStorage ) :
|
bool isMultiStorage, bool isPersistentStorage ) :
|
||||||
m_id( storageId ),
|
m_id( storageId ),
|
||||||
m_size( maxSize ),
|
m_size( maxSize ),
|
||||||
|
@ -32,12 +32,12 @@ uint16_t Sapphire::ItemContainer::getId() const
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Sapphire::ItemContainer::getEntryCount() const
|
uint16_t Sapphire::ItemContainer::getEntryCount() const
|
||||||
{
|
{
|
||||||
return static_cast< uint8_t >( m_itemMap.size() );
|
return static_cast< uint16_t >( m_itemMap.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::ItemContainer::removeItem( uint8_t slotId )
|
void Sapphire::ItemContainer::removeItem( uint16_t slotId )
|
||||||
{
|
{
|
||||||
auto pLog = g_fw.get< Logger >();
|
auto pLog = g_fw.get< Logger >();
|
||||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||||
|
@ -68,9 +68,9 @@ const Sapphire::ItemMap& Sapphire::ItemContainer::getItemMap() const
|
||||||
return m_itemMap;
|
return m_itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Sapphire::ItemContainer::getFreeSlot()
|
int16_t Sapphire::ItemContainer::getFreeSlot()
|
||||||
{
|
{
|
||||||
for( uint8_t slotId = 0; slotId < m_size; slotId++ )
|
for( uint16_t slotId = 0; slotId < m_size; slotId++ )
|
||||||
{
|
{
|
||||||
ItemMap::iterator it = m_itemMap.find( slotId );
|
ItemMap::iterator it = m_itemMap.find( slotId );
|
||||||
if( it == m_itemMap.end() ||
|
if( it == m_itemMap.end() ||
|
||||||
|
@ -80,7 +80,7 @@ int8_t Sapphire::ItemContainer::getFreeSlot()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint8_t slotId )
|
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( ( slotId > m_size ) )
|
if( ( slotId > m_size ) )
|
||||||
|
@ -93,7 +93,7 @@ Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint8_t slotId )
|
||||||
return m_itemMap[ slotId ];
|
return m_itemMap[ slotId ];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
|
void Sapphire::ItemContainer::setItem( uint16_t slotId, ItemPtr pItem )
|
||||||
{
|
{
|
||||||
if( slotId > m_size )
|
if( slotId > m_size )
|
||||||
return;
|
return;
|
||||||
|
@ -101,7 +101,7 @@ void Sapphire::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
|
||||||
m_itemMap[ slotId ] = pItem;
|
m_itemMap[ slotId ] = pItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Sapphire::ItemContainer::getMaxSize() const
|
uint16_t Sapphire::ItemContainer::getMaxSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,34 +8,34 @@
|
||||||
namespace Sapphire
|
namespace Sapphire
|
||||||
{
|
{
|
||||||
|
|
||||||
using ItemMap = std::map< uint8_t, ItemPtr >;
|
using ItemMap = std::map< uint16_t, ItemPtr >;
|
||||||
|
|
||||||
class ItemContainer
|
class ItemContainer
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage,
|
ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName, bool isMultiStorage,
|
||||||
bool isPersistentStorage = true );
|
bool isPersistentStorage = true );
|
||||||
|
|
||||||
~ItemContainer();
|
~ItemContainer();
|
||||||
|
|
||||||
uint16_t getId() const;
|
uint16_t getId() const;
|
||||||
|
|
||||||
uint8_t getEntryCount() const;
|
uint16_t getEntryCount() const;
|
||||||
|
|
||||||
void removeItem( uint8_t slotId );
|
void removeItem( uint16_t slotId );
|
||||||
|
|
||||||
ItemMap& getItemMap();
|
ItemMap& getItemMap();
|
||||||
|
|
||||||
const ItemMap& getItemMap() const;
|
const ItemMap& getItemMap() const;
|
||||||
|
|
||||||
ItemPtr getItem( uint8_t slotId );
|
ItemPtr getItem( uint16_t slotId );
|
||||||
|
|
||||||
void setItem( uint8_t slotId, ItemPtr item );
|
void setItem( uint16_t slotId, ItemPtr item );
|
||||||
|
|
||||||
int8_t getFreeSlot();
|
int16_t getFreeSlot();
|
||||||
|
|
||||||
uint8_t getMaxSize() const;
|
uint16_t getMaxSize() const;
|
||||||
|
|
||||||
std::string getTableName() const;
|
std::string getTableName() const;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace Sapphire
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t m_id;
|
uint16_t m_id;
|
||||||
uint8_t m_size;
|
uint16_t m_size;
|
||||||
std::string m_tableName;
|
std::string m_tableName;
|
||||||
bool m_bMultiStorage;
|
bool m_bMultiStorage;
|
||||||
bool m_isPersistentStorage;
|
bool m_isPersistentStorage;
|
||||||
|
|
Loading…
Add table
Reference in a new issue