diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index a4bc4a1b..becad6ed 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -103,7 +103,7 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories() item->setStain( stain ); // todo: need to set the owner character id on the item - ContainerIdToContainerMap estateInv = m_estateInventories[ ident ]; + ContainerIdToContainerMap& estateInv = m_estateInventories[ ident ]; // check if containerId exists auto container = estateInv.find( containerId ); @@ -660,4 +660,36 @@ Sapphire::World::Manager::HousingMgr::ContainerIdToContainerMap auto u64ident = *reinterpret_cast< uint64_t* >( &ident ); getEstateInventory( u64ident ); +} + +void Sapphire::World::Manager::HousingMgr::updateHouseModels( Sapphire::HousePtr house ) +{ + assert( house ); + + auto getItemData = []( uint32_t itemId ) + { + auto pExdData = g_fw.get< Data::ExdDataGenerated >(); + auto info = pExdData->get< Sapphire::Data::Item >( itemId ); + return info->additionalData; + }; + + auto containers = getEstateInventory( house->getLandIdent() ); + + auto extContainer = containers.find( static_cast< uint16_t >( InventoryType::HousingOutdoorAppearance ) ); + if( extContainer != containers.end() ) + { + for( auto& item : extContainer->second->getItemMap() ) + { + house->setHousePart( static_cast< Common::HousePartSlot >( item.first ), getItemData( item.second->getId() ) ); + } + } + + auto intContainer = containers.find( static_cast< uint16_t >( InventoryType::HousingInteriorAppearance ) ); + if( intContainer != containers.end() ) + { + for( auto& item : intContainer->second->getItemMap() ) + { + house->setHouseInteriorPart( static_cast< Common::HousingInteriorSlot >( item.first ), getItemData( item.second->getId() ) ); + } + } } \ No newline at end of file diff --git a/src/world/Manager/HousingMgr.h b/src/world/Manager/HousingMgr.h index 2f92d10e..3609c173 100644 --- a/src/world/Manager/HousingMgr.h +++ b/src/world/Manager/HousingMgr.h @@ -91,6 +91,14 @@ namespace Sapphire::World::Manager void sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident ); + /*! + * @brief Updates the cached models on a house from the relevant apperance inventories. + * Does not send the subsequent update to clients. + * + * @param house The house to update the models for + */ + void updateHouseModels( HousePtr house ); + /*! * @brief Sends the house inventory for the specified type to a player. * diff --git a/src/world/Territory/HousingZone.cpp b/src/world/Territory/HousingZone.cpp index 292344b4..075059e2 100644 --- a/src/world/Territory/HousingZone.cpp +++ b/src/world/Territory/HousingZone.cpp @@ -85,6 +85,7 @@ bool Sapphire::HousingZone::init() { auto house = make_House( entry.m_houseId, m_landSetId, land->getLandIdent(), entry.m_estateName, entry.m_estateComment ); + housingMgr->updateHouseModels( house ); land->setHouse( house ); }