1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

Inventory Overhaul wrapup

This commit is contained in:
Mordred 2018-07-26 23:40:46 +02:00
parent e10a998f4e
commit 42bf23e7dc
3 changed files with 68 additions and 97 deletions

View file

@ -618,16 +618,15 @@ public:
ItemPtr getItemAt( uint16_t containerId, uint8_t slotId ); ItemPtr getItemAt( uint16_t containerId, uint8_t slotId );
bool updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem ); bool updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem );
/*! calculate and return player ilvl based off equipped gear */ /*! calculate and return player ilvl based off equipped gear */
uint16_t calculateEquippedGearItemLevel(); uint16_t calculateEquippedGearItemLevel();
/*! return the current amount of currency of type */ /*! return the current amount of currency of type */
uint32_t getCurrency( Common::CurrencyType type ); uint32_t getCurrency( Common::CurrencyType type );
void updateBagDb( Common::InventoryType type ); void writeInventory( Common::InventoryType type );
void updateMannequinDb( Common::InventoryType type ); void writeItem( ItemPtr pItem ) const;
void updateItemDb( ItemPtr pItem ) const;
void deleteItemDb( ItemPtr pItem ) const; void deleteItemDb( ItemPtr pItem ) const;
/*! return the crystal amount of currency of type */ /*! return the crystal amount of currency of type */
@ -645,7 +644,6 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
uint64_t m_lastMoveTime; uint64_t m_lastMoveTime;
uint8_t m_lastMoveflag; uint8_t m_lastMoveflag;
private: private:
@ -667,7 +665,7 @@ private:
private: private:
using InventoryMap = std::map< uint16_t, Core::ItemContainerPtr >; using InventoryMap = std::map< uint16_t, Core::ItemContainerPtr >;
InventoryMap m_inventoryMap; InventoryMap m_storageMap;
Common::FFXIVARR_POSITION3 m_prevPos; Common::FFXIVARR_POSITION3 m_prevPos;
uint32_t m_prevZoneType; uint32_t m_prevZoneType;

View file

@ -46,7 +46,7 @@ using namespace Core::Network::ActorControl;
void Core::Entity::Player::initInventory() void Core::Entity::Player::initInventory()
{ {
auto setupContainer = [this]( InventoryType type, uint8_t maxSize, const std::string& tableName, bool isMultiStorage ) auto setupContainer = [this]( InventoryType type, uint8_t maxSize, const std::string& tableName, bool isMultiStorage )
{ m_inventoryMap[type] = make_ItemContainer( type, maxSize, tableName, isMultiStorage ); }; { m_storageMap[type] = make_ItemContainer( type, maxSize, tableName, isMultiStorage ); };
// main bags // main bags
setupContainer( Bag0, 34, "charaiteminventory", true ); setupContainer( Bag0, 34, "charaiteminventory", true );
@ -220,18 +220,18 @@ void Core::Entity::Player::unequipItem( Common::EquipSlot equipSlotId, ItemPtr p
void Core::Entity::Player::addCurrency( CurrencyType type, uint32_t amount ) void Core::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
{ {
auto slot = static_cast< uint8_t >( static_cast< uint8_t >( type ) - 1 ); auto slot = static_cast< uint8_t >( static_cast< uint8_t >( type ) - 1 );
auto currItem = m_inventoryMap[Currency]->getItem( slot ); auto currItem = m_storageMap[Currency]->getItem( slot );
if( !currItem ) if( !currItem )
{ {
// TODO: map currency type to itemid // TODO: map currency type to itemid
currItem = createItem( 1 ); currItem = createItem( 1 );
m_inventoryMap[Currency]->setItem( slot, currItem ); m_storageMap[Currency]->setItem( slot, currItem );
} }
uint32_t currentAmount = currItem->getStackSize(); uint32_t currentAmount = currItem->getStackSize();
currItem->setStackSize( currentAmount + amount ); currItem->setStackSize( currentAmount + amount );
updateItemDb( currItem ); writeItem(currItem);
updateContainer( Currency, slot, currItem ); updateContainer( Currency, slot, currItem );
@ -245,7 +245,7 @@ void Core::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
void Core::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t amount ) void Core::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t amount )
{ {
auto currItem = m_inventoryMap[Currency]->getItem( static_cast< uint8_t >( type ) - 1 ); auto currItem = m_storageMap[Currency]->getItem( static_cast< uint8_t >( type ) - 1 );
if( !currItem ) if( !currItem )
return; return;
@ -255,7 +255,7 @@ void Core::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t a
currItem->setStackSize( 0 ); currItem->setStackSize( 0 );
else else
currItem->setStackSize( currentAmount - amount ); currItem->setStackSize( currentAmount - amount );
updateItemDb( currItem ); writeItem(currItem);
auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(),
static_cast< uint8_t >( type ) - 1, static_cast< uint8_t >( type ) - 1,
@ -267,22 +267,22 @@ void Core::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t a
void Core::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount ) void Core::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount )
{ {
auto currItem = m_inventoryMap[Crystal]->getItem( static_cast< uint8_t >( type ) - 1 ); auto currItem = m_storageMap[Crystal]->getItem( static_cast< uint8_t >( type ) - 1 );
if( !currItem ) if( !currItem )
{ {
// TODO: map currency type to itemid // TODO: map currency type to itemid
currItem = createItem( static_cast< uint8_t >( type ) + 1 ); currItem = createItem( static_cast< uint8_t >( type ) + 1 );
m_inventoryMap[Crystal]->setItem( static_cast< uint8_t >( type ) - 1, currItem ); m_storageMap[Crystal]->setItem( static_cast< uint8_t >( type ) - 1, currItem );
} }
uint32_t currentAmount = currItem->getStackSize(); uint32_t currentAmount = currItem->getStackSize();
currItem->setStackSize( currentAmount + amount ); currItem->setStackSize( currentAmount + amount );
updateItemDb( currItem ); writeItem(currItem);
updateBagDb( Crystal ); writeInventory( Crystal );
auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(),
@ -296,7 +296,7 @@ void Core::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount
void Core::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t amount ) void Core::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t amount )
{ {
auto currItem = m_inventoryMap[Crystal]->getItem( static_cast< uint8_t >( type ) - 1 ); auto currItem = m_storageMap[Crystal]->getItem( static_cast< uint8_t >( type ) - 1 );
if( !currItem ) if( !currItem )
return; return;
@ -307,7 +307,7 @@ void Core::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t amo
else else
currItem->setStackSize( currentAmount - amount ); currItem->setStackSize( currentAmount - amount );
updateItemDb( currItem ); writeItem(currItem);
auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(),
static_cast< uint8_t >( type ) - 1, static_cast< uint8_t >( type ) - 1,
@ -332,7 +332,7 @@ void Core::Entity::Player::sendInventory()
InventoryMap::iterator it; InventoryMap::iterator it;
int32_t count = 0; int32_t count = 0;
for( it = m_inventoryMap.begin(); it != m_inventoryMap.end(); ++it, count++ ) for( it = m_storageMap.begin(); it != m_storageMap.end(); ++it, count++ )
{ {
auto pMap = it->second->getItemMap(); auto pMap = it->second->getItemMap();
@ -385,7 +385,7 @@ Core::Entity::Player::InvSlotPairVec Core::Entity::Player::getSlotsOfItemsInInve
InvSlotPairVec outVec; InvSlotPairVec outVec;
for( auto i : { Bag0, Bag1, Bag2, Bag3 } ) for( auto i : { Bag0, Bag1, Bag2, Bag3 } )
{ {
auto inv = m_inventoryMap[i]; auto inv = m_storageMap[i];
for( auto item : inv->getItemMap() ) for( auto item : inv->getItemMap() )
{ {
if( item.second && item.second->getId() == catalogId ) if( item.second && item.second->getId() == catalogId )
@ -399,7 +399,7 @@ Core::Entity::Player::InvSlotPair Core::Entity::Player::getFreeBagSlot()
{ {
for( auto i : { Bag0, Bag1, Bag2, Bag3 } ) for( auto i : { Bag0, Bag1, Bag2, Bag3 } )
{ {
auto freeSlot = static_cast< int8_t >( m_inventoryMap[i]->getFreeSlot() ); auto freeSlot = static_cast< int8_t >( m_storageMap[i]->getFreeSlot() );
if( freeSlot != -1 ) if( freeSlot != -1 )
return std::make_pair( i, freeSlot ); return std::make_pair( i, freeSlot );
@ -410,14 +410,14 @@ Core::Entity::Player::InvSlotPair Core::Entity::Player::getFreeBagSlot()
Core::ItemPtr Core::Entity::Player::getItemAt( uint16_t containerId, uint8_t slotId ) Core::ItemPtr Core::Entity::Player::getItemAt( uint16_t containerId, uint8_t slotId )
{ {
return m_inventoryMap[containerId]->getItem( slotId ); return m_storageMap[containerId]->getItem( slotId );
} }
uint32_t Core::Entity::Player::getCurrency( CurrencyType type ) uint32_t Core::Entity::Player::getCurrency( CurrencyType type )
{ {
auto currItem = m_inventoryMap[Currency]->getItem( static_cast< uint8_t >( type ) - 1 ); auto currItem = m_storageMap[Currency]->getItem( static_cast< uint8_t >( type ) - 1 );
if( !currItem ) if( !currItem )
return 0; return 0;
@ -429,7 +429,7 @@ uint32_t Core::Entity::Player::getCurrency( CurrencyType type )
uint32_t Core::Entity::Player::getCrystal( CrystalType type ) uint32_t Core::Entity::Player::getCrystal( CrystalType type )
{ {
auto currItem = m_inventoryMap[Crystal]->getItem( static_cast< uint8_t >( type ) - 1 ); auto currItem = m_storageMap[Crystal]->getItem( static_cast< uint8_t >( type ) - 1 );
if( !currItem ) if( !currItem )
return 0; return 0;
@ -438,41 +438,18 @@ uint32_t Core::Entity::Player::getCrystal( CrystalType type )
} }
void Core::Entity::Player::updateBagDb( InventoryType type ) void Core::Entity::Player::writeInventory( InventoryType type )
{
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
std::string query = "UPDATE charaiteminventory SET ";
auto container = m_inventoryMap[type];
for( int32_t i = 0; i <= container->getMaxSize(); i++ )
{
auto currItem = container->getItem( i );
if( i > 0 )
query += ", ";
query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem ? currItem->getUId() : 0 );
}
query += " WHERE CharacterId = " + std::to_string( getId() ) +
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
pDb->execute( query );
}
void Core::Entity::Player::updateMannequinDb( InventoryType type )
{ {
auto pLog = g_fw.get< Logger >(); auto pLog = g_fw.get< Logger >();
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
std::string query = "UPDATE charaitemgearset SET ";
auto container = m_inventoryMap[type]; auto storage = m_storageMap[type];
for( int32_t i = 0; i <= container->getMaxSize(); i++ ) std::string query = "UPDATE " + storage->getTableName() + " SET ";
for( int32_t i = 0; i <= storage->getMaxSize(); i++ )
{ {
auto currItem = container->getItem( i ); auto currItem = storage->getItem( i );
if( i > 0 ) if( i > 0 )
query += ", "; query += ", ";
@ -480,15 +457,16 @@ void Core::Entity::Player::updateMannequinDb( InventoryType type )
query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem ? currItem->getUId() : 0 ); query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem ? currItem->getUId() : 0 );
} }
query += " WHERE CharacterId = " + std::to_string( getId() ) + query += " WHERE CharacterId = " + std::to_string( getId() );
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
if( storage->isMultiStorage() )
query += " AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
pLog->debug( query ); pLog->debug( query );
pDb->execute( query ); pDb->execute( query );
} }
void Core::Entity::Player::writeItem( Core::ItemPtr pItem ) const
void Core::Entity::Player::updateItemDb( Core::ItemPtr pItem ) const
{ {
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
pDb->execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " + pDb->execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
@ -547,9 +525,11 @@ int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint
if( rSlotId != -1 ) if( rSlotId != -1 )
{ {
m_inventoryMap[inventoryId]->setItem( rSlotId, item ); auto storage = m_storageMap[inventoryId];
storage->setItem( rSlotId, item );
pDb->execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) + pDb->execute( "UPDATE " + storage->getTableName() + " SET container_" +
std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) +
" WHERE storageId = " + std::to_string( inventoryId ) + " WHERE storageId = " + std::to_string( inventoryId ) +
" AND CharacterId = " + std::to_string( getId() ) ); " AND CharacterId = " + std::to_string( getId() ) );
@ -573,42 +553,35 @@ int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint
void Core::Entity::Player::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot ) void Core::Entity::Player::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot )
{ {
auto tmpItem = m_inventoryMap[fromInventoryId]->getItem( fromSlotId ); auto tmpItem = m_storageMap[fromInventoryId]->getItem( fromSlotId );
auto& itemMap = m_inventoryMap[fromInventoryId]->getItemMap(); auto& itemMap = m_storageMap[fromInventoryId]->getItemMap();
if( tmpItem == nullptr ) if( tmpItem == nullptr )
return; return;
itemMap[fromSlotId].reset(); itemMap[fromSlotId].reset();
m_inventoryMap[toInventoryId]->setItem( toSlot, tmpItem ); m_storageMap[toInventoryId]->setItem( toSlot, tmpItem );
if( toInventoryId != GearSet0 ) writeInventory( static_cast< InventoryType >( toInventoryId ) );
updateBagDb( static_cast< InventoryType >( toInventoryId ) );
if( fromInventoryId != GearSet0 && fromInventoryId != toInventoryId ) if( fromInventoryId != toInventoryId )
updateBagDb( static_cast< InventoryType >( fromInventoryId ) ); writeInventory( static_cast< InventoryType >( fromInventoryId ) );
if( static_cast< InventoryType >( toInventoryId ) == GearSet0 ) if( static_cast< InventoryType >( toInventoryId ) == GearSet0 )
{
equipItem( static_cast< EquipSlot >( toSlot ), tmpItem, true ); equipItem( static_cast< EquipSlot >( toSlot ), tmpItem, true );
updateMannequinDb( static_cast< InventoryType >( toInventoryId ) );
}
if( static_cast< InventoryType >( fromInventoryId ) == GearSet0 ) if( static_cast< InventoryType >( fromInventoryId ) == GearSet0 )
{
unequipItem( static_cast< EquipSlot >( fromSlotId ), tmpItem ); unequipItem( static_cast< EquipSlot >( fromSlotId ), tmpItem );
updateMannequinDb( static_cast< InventoryType >( fromInventoryId ) );
}
} }
bool Core::Entity::Player::updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem ) bool Core::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem )
{ {
auto containerType = Items::Util::getContainerType( containerId ); auto containerType = Items::Util::getContainerType( storageId );
m_inventoryMap[containerId]->setItem( slotId, pItem ); m_storageMap[storageId]->setItem( slotId, pItem );
switch( containerType ) switch( containerType )
{ {
@ -616,7 +589,7 @@ bool Core::Entity::Player::updateContainer( uint16_t containerId, uint8_t slotId
case Bag: case Bag:
case CurrencyCrystal: case CurrencyCrystal:
{ {
updateBagDb( static_cast< InventoryType >( containerId ) ); writeInventory( static_cast< InventoryType >( storageId ) );
break; break;
} }
@ -627,7 +600,7 @@ bool Core::Entity::Player::updateContainer( uint16_t containerId, uint8_t slotId
else else
unequipItem( static_cast< EquipSlot >( slotId ), pItem ); unequipItem( static_cast< EquipSlot >( slotId ), pItem );
updateMannequinDb( static_cast< InventoryType >( containerId ) ); writeInventory( static_cast< InventoryType >( storageId ) );
break; break;
} }
default: default:
@ -640,7 +613,7 @@ bool Core::Entity::Player::updateContainer( uint16_t containerId, uint8_t slotId
void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlotId, void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlotId,
uint16_t toInventoryId, uint8_t toSlot, uint16_t itemCount ) uint16_t toInventoryId, uint8_t toSlot, uint16_t itemCount )
{ {
auto fromItem = m_inventoryMap[fromInventoryId]->getItem( fromSlotId ); auto fromItem = m_storageMap[fromInventoryId]->getItem( fromSlotId );
if( !fromItem ) if( !fromItem )
return; return;
@ -651,7 +624,7 @@ void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlot
return; return;
// make sure toInventoryId & toSlot are actually free so we don't orphan an item // make sure toInventoryId & toSlot are actually free so we don't orphan an item
if( m_inventoryMap[toInventoryId]->getItem( toSlot ) ) if( m_storageMap[toInventoryId]->getItem( toSlot ) )
// todo: correct invalid move? again, not sure what retail does here // todo: correct invalid move? again, not sure what retail does here
return; return;
@ -659,21 +632,21 @@ void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlot
if( newSlot == -1 ) if( newSlot == -1 )
return; return;
auto newItem = m_inventoryMap[toInventoryId]->getItem( static_cast< uint8_t >( newSlot ) ); auto newItem = m_storageMap[toInventoryId]->getItem( static_cast< uint8_t >( newSlot ) );
fromItem->setStackSize( fromItem->getStackSize() - itemCount ); fromItem->setStackSize( fromItem->getStackSize() - itemCount );
updateContainer( fromInventoryId, fromSlotId, fromItem ); updateContainer( fromInventoryId, fromSlotId, fromItem );
updateContainer( toInventoryId, toSlot, newItem ); updateContainer( toInventoryId, toSlot, newItem );
updateItemDb( fromItem ); writeItem(fromItem);
} }
void Core::Entity::Player::mergeItem( uint16_t fromInventoryId, uint8_t fromSlotId, void Core::Entity::Player::mergeItem( uint16_t fromInventoryId, uint8_t fromSlotId,
uint16_t toInventoryId, uint8_t toSlot ) uint16_t toInventoryId, uint8_t toSlot )
{ {
auto fromItem = m_inventoryMap[fromInventoryId]->getItem( fromSlotId ); auto fromItem = m_storageMap[fromInventoryId]->getItem( fromSlotId );
auto toItem = m_inventoryMap[toInventoryId]->getItem( toSlot ); auto toItem = m_storageMap[toInventoryId]->getItem( toSlot );
if( !fromItem || !toItem ) if( !fromItem || !toItem )
return; return;
@ -687,18 +660,18 @@ void Core::Entity::Player::mergeItem( uint16_t fromInventoryId, uint8_t fromSlot
// we can destroy the original stack if there's no overflow // we can destroy the original stack if there's no overflow
if( stackOverflow == 0 ) if( stackOverflow == 0 )
{ {
m_inventoryMap[fromInventoryId]->removeItem( fromSlotId ); m_storageMap[fromInventoryId]->removeItem( fromSlotId );
deleteItemDb( fromItem ); deleteItemDb( fromItem );
} }
else else
{ {
fromItem->setStackSize( stackOverflow ); fromItem->setStackSize( stackOverflow );
updateItemDb( fromItem ); writeItem(fromItem);
} }
toItem->setStackSize( stackSize ); toItem->setStackSize( stackSize );
updateItemDb( toItem ); writeItem(toItem);
updateContainer( fromInventoryId, fromSlotId, fromItem ); updateContainer( fromInventoryId, fromSlotId, fromItem );
updateContainer( toInventoryId, toSlot, toItem ); updateContainer( toInventoryId, toSlot, toItem );
@ -707,9 +680,9 @@ void Core::Entity::Player::mergeItem( uint16_t fromInventoryId, uint8_t fromSlot
void Core::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, void Core::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId,
uint16_t toInventoryId, uint8_t toSlot ) uint16_t toInventoryId, uint8_t toSlot )
{ {
auto fromItem = m_inventoryMap[fromInventoryId]->getItem( fromSlotId ); auto fromItem = m_storageMap[fromInventoryId]->getItem( fromSlotId );
auto toItem = m_inventoryMap[toInventoryId]->getItem( toSlot ); auto toItem = m_storageMap[toInventoryId]->getItem( toSlot );
auto& itemMap = m_inventoryMap[fromInventoryId]->getItemMap(); auto& itemMap = m_storageMap[fromInventoryId]->getItemMap();
if( fromItem == nullptr || toItem == nullptr ) if( fromItem == nullptr || toItem == nullptr )
return; return;
@ -722,7 +695,7 @@ void Core::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromSlotI
{ {
updateContainer( fromInventoryId, fromSlotId, nullptr ); updateContainer( fromInventoryId, fromSlotId, nullptr );
fromInventoryId = Items::Util::getArmoryToEquipSlot( toSlot ); fromInventoryId = Items::Util::getArmoryToEquipSlot( toSlot );
fromSlotId = static_cast < uint8_t >( m_inventoryMap[fromInventoryId]->getFreeSlot() ); fromSlotId = static_cast < uint8_t >( m_storageMap[fromInventoryId]->getFreeSlot() );
} }
auto containerTypeFrom = Items::Util::getContainerType( fromInventoryId ); auto containerTypeFrom = Items::Util::getContainerType( fromInventoryId );
@ -737,11 +710,11 @@ void Core::Entity::Player::discardItem( uint16_t fromInventoryId, uint8_t fromSl
// i am not entirely sure how this should be generated or if it even is important for us... // i am not entirely sure how this should be generated or if it even is important for us...
uint32_t transactionId = 1; uint32_t transactionId = 1;
auto fromItem = m_inventoryMap[fromInventoryId]->getItem( fromSlotId ); auto fromItem = m_storageMap[fromInventoryId]->getItem( fromSlotId );
deleteItemDb( fromItem ); deleteItemDb( fromItem );
m_inventoryMap[fromInventoryId]->removeItem( fromSlotId ); m_storageMap[fromInventoryId]->removeItem( fromSlotId );
updateContainer( fromInventoryId, fromSlotId, nullptr ); updateContainer( fromInventoryId, fromSlotId, nullptr );
auto invTransPacket = makeZonePacket< FFXIVIpcInventoryTransaction >( getId() ); auto invTransPacket = makeZonePacket< FFXIVIpcInventoryTransaction >( getId() );
@ -764,7 +737,7 @@ uint16_t Core::Entity::Player::calculateEquippedGearItemLevel()
{ {
uint32_t iLvlResult = 0; uint32_t iLvlResult = 0;
auto gearSetMap = m_inventoryMap[GearSet0]->getItemMap(); auto gearSetMap = m_storageMap[GearSet0]->getItemMap();
auto it = gearSetMap.begin(); auto it = gearSetMap.begin();
@ -795,7 +768,7 @@ uint8_t Core::Entity::Player::getFreeSlotsInBags()
uint8_t slots = 0; uint8_t slots = 0;
for( uint8_t container : { Bag0, Bag1, Bag2, Bag3 } ) for( uint8_t container : { Bag0, Bag1, Bag2, Bag3 } )
{ {
const auto& storage = m_inventoryMap[container]; const auto& storage = m_storageMap[container];
slots += ( storage->getMaxSize() - storage->getEntryCount() ); slots += ( storage->getMaxSize() - storage->getEntryCount() );
} }
return slots; return slots;

View file

@ -616,7 +616,7 @@ bool Core::Entity::Player::loadInventory()
if( pItem == nullptr ) if( pItem == nullptr )
continue; continue;
m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem; m_storageMap[storageId]->getItemMap()[i - 1] = pItem;
equipItem( static_cast< EquipSlot >( i - 1 ), pItem, false ); equipItem( static_cast< EquipSlot >( i - 1 ), pItem, false );
} }
} }
@ -638,7 +638,7 @@ bool Core::Entity::Player::loadInventory()
while( bagRes->next() ) while( bagRes->next() )
{ {
uint16_t storageId = bagRes->getUInt16( 1 ); uint16_t storageId = bagRes->getUInt16( 1 );
for( uint32_t i = 1; i <= m_inventoryMap[storageId]->getMaxSize(); i++ ) for( uint32_t i = 1; i <= m_storageMap[storageId]->getMaxSize(); i++ )
{ {
uint64_t uItemId = bagRes->getUInt64( i + 1 ); uint64_t uItemId = bagRes->getUInt64( i + 1 );
if( uItemId == 0 ) if( uItemId == 0 )
@ -649,7 +649,7 @@ bool Core::Entity::Player::loadInventory()
if( pItem == nullptr ) if( pItem == nullptr )
continue; continue;
m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem; m_storageMap[storageId]->getItemMap()[i - 1] = pItem;
} }
} }