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

partially fix inventory loading fuckery

This commit is contained in:
NotAdam 2018-12-22 17:22:24 +11:00
parent 66156a97ca
commit 1b097e4181
3 changed files with 42 additions and 1 deletions

View file

@ -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() ) );
}
}
}

View file

@ -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.
*

View file

@ -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 );
}