diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index 34737379..2162a577 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -1095,4 +1095,55 @@ Sapphire::Common::YardObject Sapphire::World::Manager::HousingMgr::getYardObject obj.itemId = item->getAdditionalData(); return obj; +} + +void Sapphire::World::Manager::HousingMgr::sendInternalEstateInventoryBatch( Sapphire::Entity::Player& player, + bool storeroom ) +{ + auto zone = std::dynamic_pointer_cast< Territory::Housing::HousingInteriorTerritory >( player.getCurrentZone() ); + if( !zone ) + return; + + std::vector< uint16_t > containerIds; + + if( !storeroom ) + { + containerIds = { + InventoryType::HousingInteriorPlacedItems1, + InventoryType::HousingInteriorPlacedItems2, + InventoryType::HousingInteriorPlacedItems3, + InventoryType::HousingInteriorPlacedItems4, + InventoryType::HousingInteriorPlacedItems5, + InventoryType::HousingInteriorPlacedItems6, + InventoryType::HousingInteriorPlacedItems7, + InventoryType::HousingInteriorPlacedItems8, + }; + } + else + { + containerIds = { + InventoryType::HousingInteriorStoreroom1, + InventoryType::HousingInteriorStoreroom2, + InventoryType::HousingInteriorStoreroom3, + InventoryType::HousingInteriorStoreroom4, + InventoryType::HousingInteriorStoreroom5, + InventoryType::HousingInteriorStoreroom6, + InventoryType::HousingInteriorStoreroom7, + InventoryType::HousingInteriorStoreroom8, + }; + } + + // todo: perms check + + auto invMgr = g_fw.get< Manager::InventoryMgr >(); + auto& containers = getEstateInventory( zone->getLandIdent() ); + + for( auto containerId : containerIds ) + { + auto container = containers.find( containerId ); + if( container == containers.end() ) + break; + + invMgr->sendInventoryContainer( player, container->second ); + } } \ No newline at end of file diff --git a/src/world/Manager/HousingMgr.h b/src/world/Manager/HousingMgr.h index e7bc4251..93fd8f40 100644 --- a/src/world/Manager/HousingMgr.h +++ b/src/world/Manager/HousingMgr.h @@ -114,6 +114,13 @@ namespace Sapphire::World::Manager */ void sendEstateInventory( Entity::Player& player, uint16_t inventoryType, uint8_t plotNum ); + /*! + * @brief Sends all the available internal inventories in one go. Used to initially populate the menu. + * @param player The player to send the containers to + * @param storeroom True if we should send the storeroom, false we send the placed items + */ + void sendInternalEstateInventoryBatch( Entity::Player& player, bool storeroom = false ); + /*! * @brief Get the land & house data that was cached on world startup. * @return diff --git a/src/world/Network/Handlers/ClientTriggerHandler.cpp b/src/world/Network/Handlers/ClientTriggerHandler.cpp index 092c47a0..0140b78d 100644 --- a/src/world/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/world/Network/Handlers/ClientTriggerHandler.cpp @@ -440,17 +440,17 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX } case ClientTriggerType::RequestEstateInventory: { - // only sent if param1 is 1, because the client sends this with 0 when you open the ui for whatever reason - if( param1 != 1 ) - return; - auto housingMgr = g_fw.get< HousingMgr >(); if( !housingMgr ) break; + // param1 = 1 - storeroom + // param1 = 0 - placed items - - // housingMgr->sendHousingInventory( player, Common::InventoryType::HousingInd, 255 ); + if( param1 == 1 ) + housingMgr->sendInternalEstateInventoryBatch( player, true ); + else + housingMgr->sendInternalEstateInventoryBatch( player ); break; }