1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 07:07:45 +00:00

fix shitty inventory impl so it works a bit more than before

This commit is contained in:
NotAdam 2018-12-22 01:00:31 +11:00
parent d6b548afe9
commit 5f6c2d950a

View file

@ -56,7 +56,6 @@ Sapphire::Land::~Land() = default;
void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice, uint64_t ownerId, uint64_t houseId ) void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice, uint64_t ownerId, uint64_t houseId )
{ {
m_type = type; m_type = type;
m_size = size; m_size = size;
m_state = state; m_state = state;
@ -111,7 +110,7 @@ void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, u
setupContainer( InventoryType::HousingInteriorPlacedItems1, m_maxPlacedInternalItems ); setupContainer( InventoryType::HousingInteriorPlacedItems1, m_maxPlacedInternalItems );
setupContainer( InventoryType::HousingInteriorStoreroom1, m_maxPlacedInternalItems ); setupContainer( InventoryType::HousingInteriorStoreroom1, m_maxPlacedInternalItems );
// loadItemContainerContents(); loadItemContainerContents();
} }
void Sapphire::Land::loadItemContainerContents() void Sapphire::Land::loadItemContainerContents()
@ -124,10 +123,12 @@ void Sapphire::Land::loadItemContainerContents()
auto pDB = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); auto pDB = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
// auto stmt = pDB->getPreparedStatement( Db::LAND_INV_SEL_HOUSE ); auto stmt = pDB->getPreparedStatement( Db::LAND_INV_SEL_HOUSE );
// stmt->setUInt64( 1, ident ); stmt->setUInt64( 1, ident );
auto res = pDB->query( "SELECT LandIdent, ContainerId, ItemId, SlotId FROM houseiteminventory WHERE LandIdent = " + std::to_string( ident ) ); auto res = pDB->query( stmt );
std::unordered_map< uint16_t, std::vector< std::pair< uint16_t, uint32_t > > > items;
while( res->next() ) while( res->next() )
{ {
@ -135,13 +136,22 @@ void Sapphire::Land::loadItemContainerContents()
auto itemId = res->getUInt64( "ItemId" ); auto itemId = res->getUInt64( "ItemId" );
auto slotId = res->getUInt( "SlotId" ); auto slotId = res->getUInt( "SlotId" );
auto container = m_landInventoryMap[ containerId ]; items[ containerId ].push_back( std::make_pair( slotId, itemId ) );
auto item = Sapphire::Items::Util::loadItem( itemId );
if( item )
container->setItem( slotId, item );
} }
res.reset();
for( auto it = items.begin(); it != items.end(); it++ )
{
auto container = m_landInventoryMap[ it->first ];
for( auto fuck = it->second.begin(); fuck != it->second.end(); fuck++ )
{
auto item = Sapphire::Items::Util::loadItem( fuck->second );
if( item )
container->setItem( fuck->first, item );
}
}
} }
uint32_t Sapphire::Land::convertItemIdToHousingItemId( uint32_t itemId ) uint32_t Sapphire::Land::convertItemIdToHousingItemId( uint32_t itemId )