mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 23:27:45 +00:00
change itemcontainer back to use u8s for slots, some cleanup
This commit is contained in:
parent
a1b4f98032
commit
d3e6514af1
3 changed files with 48 additions and 48 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "Forwards.h"
|
||||
#include "ItemContainer.h"
|
||||
|
||||
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName,
|
||||
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName,
|
||||
bool isMultiStorage, FrameworkPtr pFw, bool isPersistentStorage ) :
|
||||
m_id( storageId ),
|
||||
m_size( maxSize ),
|
||||
|
@ -31,15 +31,15 @@ uint16_t Sapphire::ItemContainer::getId() const
|
|||
return m_id;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::ItemContainer::getEntryCount() const
|
||||
uint8_t Sapphire::ItemContainer::getEntryCount() const
|
||||
{
|
||||
return static_cast< uint16_t >( m_itemMap.size() );
|
||||
return static_cast< uint8_t >( m_itemMap.size() );
|
||||
}
|
||||
|
||||
void Sapphire::ItemContainer::removeItem( uint16_t slotId, bool removeFromDb )
|
||||
void Sapphire::ItemContainer::removeItem( uint8_t slotId, bool removeFromDb )
|
||||
{
|
||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
ItemMap::iterator it = m_itemMap.find( slotId );
|
||||
auto it = m_itemMap.find( slotId );
|
||||
|
||||
if( it != m_itemMap.end() )
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ const Sapphire::ItemMap& Sapphire::ItemContainer::getItemMap() const
|
|||
return m_itemMap;
|
||||
}
|
||||
|
||||
int16_t Sapphire::ItemContainer::getFreeSlot()
|
||||
int8_t Sapphire::ItemContainer::getFreeSlot()
|
||||
{
|
||||
for( uint16_t slotId = 0; slotId < m_size; slotId++ )
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ int16_t Sapphire::ItemContainer::getFreeSlot()
|
|||
return -1;
|
||||
}
|
||||
|
||||
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
|
||||
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint8_t slotId )
|
||||
{
|
||||
|
||||
if( ( slotId > m_size ) )
|
||||
|
@ -90,7 +90,7 @@ Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
|
|||
return m_itemMap[ slotId ];
|
||||
}
|
||||
|
||||
void Sapphire::ItemContainer::setItem( uint16_t slotId, ItemPtr pItem )
|
||||
void Sapphire::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
|
||||
{
|
||||
if( slotId > m_size )
|
||||
return;
|
||||
|
@ -98,7 +98,7 @@ void Sapphire::ItemContainer::setItem( uint16_t slotId, ItemPtr pItem )
|
|||
m_itemMap[ slotId ] = pItem;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::ItemContainer::getMaxSize() const
|
||||
uint8_t Sapphire::ItemContainer::getMaxSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
|
|
@ -8,34 +8,34 @@
|
|||
namespace Sapphire
|
||||
{
|
||||
|
||||
using ItemMap = std::map< uint16_t, ItemPtr >;
|
||||
using ItemMap = std::map< uint8_t, ItemPtr >;
|
||||
|
||||
class ItemContainer
|
||||
{
|
||||
|
||||
public:
|
||||
ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName, bool isMultiStorage,
|
||||
ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage,
|
||||
FrameworkPtr pFw, bool isPersistentStorage = true );
|
||||
|
||||
~ItemContainer();
|
||||
|
||||
uint16_t getId() const;
|
||||
|
||||
uint16_t getEntryCount() const;
|
||||
uint8_t getEntryCount() const;
|
||||
|
||||
void removeItem( uint16_t slotId, bool removeFromDb = true );
|
||||
void removeItem( uint8_t slotId, bool removeFromDb = true );
|
||||
|
||||
ItemMap& getItemMap();
|
||||
|
||||
const ItemMap& getItemMap() const;
|
||||
|
||||
ItemPtr getItem( uint16_t slotId );
|
||||
ItemPtr getItem( uint8_t slotId );
|
||||
|
||||
void setItem( uint16_t slotId, ItemPtr item );
|
||||
void setItem( uint8_t slotId, ItemPtr item );
|
||||
|
||||
int16_t getFreeSlot();
|
||||
int8_t getFreeSlot();
|
||||
|
||||
uint16_t getMaxSize() const;
|
||||
uint8_t getMaxSize() const;
|
||||
|
||||
std::string getTableName() const;
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace Sapphire
|
|||
|
||||
private:
|
||||
uint16_t m_id;
|
||||
uint16_t m_size;
|
||||
uint8_t m_size;
|
||||
std::string m_tableName;
|
||||
bool m_bMultiStorage;
|
||||
FrameworkPtr m_pFw;
|
||||
|
|
|
@ -860,12 +860,12 @@ void Sapphire::World::Manager::HousingMgr::sendEstateInventory( Entity::Player&
|
|||
return;
|
||||
|
||||
auto& containers = getEstateInventory( targetLand->getLandIdent() );
|
||||
auto needle = containers.find( inventoryType );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( inventoryType );
|
||||
if( it == containers.end() )
|
||||
return;
|
||||
|
||||
auto invMgr = framework()->get< Manager::InventoryMgr >();
|
||||
invMgr->sendInventoryContainer( player, needle->second );
|
||||
invMgr->sendInventoryContainer( player, it->second );
|
||||
}
|
||||
|
||||
const Sapphire::World::Manager::HousingMgr::LandSetLandCacheMap&
|
||||
|
@ -1085,11 +1085,11 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity
|
|||
{
|
||||
for( auto houseContainer : m_internalStoreroomContainers )
|
||||
{
|
||||
auto needle = containers.find( houseContainer );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( houseContainer );
|
||||
if( it == containers.end() )
|
||||
continue;
|
||||
|
||||
auto container = needle->second;
|
||||
auto container = it->second;
|
||||
auto freeSlot = container->getFreeSlot();
|
||||
if( freeSlot == -1 )
|
||||
{
|
||||
|
@ -1157,11 +1157,11 @@ bool Sapphire::World::Manager::HousingMgr::placeInteriorItem( Entity::Player& pl
|
|||
uint8_t containerIdx = 0;
|
||||
for( auto containerId : m_internalPlacedItemContainers )
|
||||
{
|
||||
auto needle = containers.find( containerId );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( containerId );
|
||||
if( it == containers.end() )
|
||||
continue;
|
||||
|
||||
auto container = needle->second;
|
||||
auto container = it->second;
|
||||
auto freeSlot = container->getFreeSlot();
|
||||
if( freeSlot == -1 )
|
||||
{
|
||||
|
@ -1272,11 +1272,11 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla
|
|||
|
||||
auto& containers = getEstateInventory( ident );
|
||||
|
||||
auto needle = containers.find( containerId );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( containerId );
|
||||
if( it == containers.end() )
|
||||
return false;
|
||||
|
||||
auto container = needle->second;
|
||||
auto container = it->second;
|
||||
|
||||
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slotIdx ) );
|
||||
if( !item )
|
||||
|
@ -1310,11 +1310,11 @@ bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& pla
|
|||
return false;
|
||||
|
||||
auto& containers = getEstateInventory( ident );
|
||||
auto needle = containers.find( InventoryType::HousingExteriorPlacedItems );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( InventoryType::HousingExteriorPlacedItems );
|
||||
if( it == containers.end() )
|
||||
return false;
|
||||
|
||||
auto container = needle->second;
|
||||
auto container = it->second;
|
||||
|
||||
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slot ) );
|
||||
if( !item )
|
||||
|
@ -1394,11 +1394,11 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p
|
|||
// eg, remove a permit and reuse it elsewhere
|
||||
// I'm not going to bother fixing it for now, but worth noting for future reference
|
||||
|
||||
auto needle = containers.find( containerId );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( containerId );
|
||||
if( it == containers.end() )
|
||||
return false;
|
||||
|
||||
auto container = needle->second;
|
||||
auto container = it->second;
|
||||
|
||||
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slotId ) );
|
||||
if( !item )
|
||||
|
@ -1461,11 +1461,11 @@ bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& p
|
|||
{
|
||||
auto& containers = getEstateInventory( land.getLandIdent() );
|
||||
|
||||
auto needle = containers.find( containerType );
|
||||
if( needle == containers.end() )
|
||||
auto it = containers.find( containerType );
|
||||
if( it == containers.end() )
|
||||
return false;
|
||||
|
||||
auto& sourceContainer = needle->second;
|
||||
auto& sourceContainer = it->second;
|
||||
|
||||
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( sourceContainer->getItem( slotId ) );
|
||||
if( !item )
|
||||
|
@ -1522,11 +1522,11 @@ Sapphire::ItemContainerPtr Sapphire::World::Manager::HousingMgr::getFreeEstateIn
|
|||
|
||||
for( auto bag : bagList )
|
||||
{
|
||||
auto needle = estateContainers.find( bag );
|
||||
if( needle == estateContainers.end() )
|
||||
auto it = estateContainers.find( bag );
|
||||
if( it == estateContainers.end() )
|
||||
continue;
|
||||
|
||||
auto container = needle->second;
|
||||
auto container = it->second;
|
||||
|
||||
auto freeSlot = container->getFreeSlot();
|
||||
|
||||
|
@ -1554,13 +1554,13 @@ void Sapphire::World::Manager::HousingMgr::reqEstateExteriorRemodel( Sapphire::E
|
|||
return;
|
||||
|
||||
auto& inv = getEstateInventory( land->getLandIdent() );
|
||||
auto needle = inv.find( InventoryType::HousingExteriorAppearance );
|
||||
if( needle == inv.end() )
|
||||
auto it = inv.find( InventoryType::HousingExteriorAppearance );
|
||||
if( it == inv.end() )
|
||||
return;
|
||||
|
||||
auto invMgr = framework()->get< InventoryMgr >();
|
||||
|
||||
invMgr->sendInventoryContainer( player, needle->second );
|
||||
invMgr->sendInventoryContainer( player, it->second );
|
||||
|
||||
auto pkt = Server::makeActorControl143( player.getId(), Network::ActorControl::ShowEstateExternalAppearanceUI, plot );
|
||||
player.queuePacket( pkt );
|
||||
|
@ -1584,13 +1584,13 @@ void Sapphire::World::Manager::HousingMgr::reqEstateInteriorRemodel( Sapphire::E
|
|||
return;
|
||||
|
||||
auto& inv = getEstateInventory( land->getLandIdent() );
|
||||
auto needle = inv.find( InventoryType::HousingInteriorAppearance );
|
||||
if( needle == inv.end() )
|
||||
auto it = inv.find( InventoryType::HousingInteriorAppearance );
|
||||
if( it == inv.end() )
|
||||
return;
|
||||
|
||||
auto invMgr = framework()->get< InventoryMgr >();
|
||||
|
||||
invMgr->sendInventoryContainer( player, needle->second );
|
||||
invMgr->sendInventoryContainer( player, it->second );
|
||||
|
||||
auto pkt = Server::makeActorControl143( player.getId(), Network::ActorControl::ShowEstateInternalAppearanceUI );
|
||||
player.queuePacket( pkt );
|
||||
|
|
Loading…
Add table
Reference in a new issue