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

create all estate inventories on launch

This commit is contained in:
NotAdam 2018-12-25 21:05:13 +11:00
parent d9dd3a5114
commit a66b937200
4 changed files with 76 additions and 28 deletions

View file

@ -225,13 +225,15 @@ namespace Sapphire::Common
// housing interior containers // housing interior containers
HousingInteriorAppearance = 25002, HousingInteriorAppearance = 25002,
// 50 in each container max, 300 slots max // 50 in each container max, 400 slots max
HousingInteriorPlacedItems1 = 25003, HousingInteriorPlacedItems1 = 25003,
HousingInteriorPlacedItems2 = 25004, HousingInteriorPlacedItems2 = 25004,
HousingInteriorPlacedItems3 = 25005, HousingInteriorPlacedItems3 = 25005,
HousingInteriorPlacedItems4 = 25006, HousingInteriorPlacedItems4 = 25006,
HousingInteriorPlacedItems5 = 25007, HousingInteriorPlacedItems5 = 25007,
HousingInteriorPlacedItems6 = 25008, HousingInteriorPlacedItems6 = 25008,
HousingInteriorPlacedItems7 = 25009,
HousingInteriorPlacedItems8 = 25010,
// 50 max per container, 400 slots max // 50 max per container, 400 slots max
// slot limit increased 'temporarily' for relocation for all estates // slot limit increased 'temporarily' for relocation for all estates
@ -247,9 +249,9 @@ namespace Sapphire::Common
// housing exterior containers // housing exterior containers
HousingOutdoorPlacedItems = 25001, HousingExteriorPlacedItems = 25001,
HousingExteriorAppearance = 25000, HousingExteriorAppearance = 25000,
HousingOutdoorStoreroom = 27000, HousingExteriorStoreroom = 27000,
}; };

View file

@ -35,7 +35,18 @@ using namespace Sapphire::Network::Packets::Server;
extern Sapphire::Framework g_fw; extern Sapphire::Framework g_fw;
Sapphire::World::Manager::HousingMgr::HousingMgr() = default; Sapphire::World::Manager::HousingMgr::HousingMgr()
{
m_containerMap[ 0 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 1 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 2 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 3 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 4 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 5 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 6 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
m_containerMap[ 7 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 );
}
Sapphire::World::Manager::HousingMgr::~HousingMgr() = default; Sapphire::World::Manager::HousingMgr::~HousingMgr() = default;
bool Sapphire::World::Manager::HousingMgr::init() bool Sapphire::World::Manager::HousingMgr::init()
@ -117,19 +128,11 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories()
ContainerIdToContainerMap& estateInv = m_estateInventories[ ident ]; ContainerIdToContainerMap& estateInv = m_estateInventories[ ident ];
// check if containerId exists // check if containerId exists, it always should - if it doesn't, something went wrong
auto container = estateInv.find( containerId ); auto container = estateInv.find( containerId );
if( container == estateInv.end() ) assert( container != estateInv.end() );
{
// create container
// todo: how to handle this max slot stuff? override it on land init?
auto ic = make_ItemContainer( containerId, 400, "houseiteminventory", true );
ic->setItem( slot, item );
estateInv[ containerId ] = ic; container->second->setItem( slot, item );
}
else
container->second->setItem( slot, item );
itemCount++; itemCount++;
} }
@ -153,7 +156,7 @@ void Sapphire::World::Manager::HousingMgr::initLandCache()
// land stuff // land stuff
entry.m_landSetId = res->getUInt64( "LandSetId" ); entry.m_landSetId = res->getUInt64( "LandSetId" );
entry.m_landId = res->getUInt64( "LandId" ); entry.m_landId = res->getUInt( "LandId" );
entry.m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) ); entry.m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) );
entry.m_size = res->getUInt8( "Size" ); entry.m_size = res->getUInt8( "Size" );
@ -180,25 +183,63 @@ void Sapphire::World::Manager::HousingMgr::initLandCache()
switch( entry.m_size ) switch( entry.m_size )
{ {
case HouseSize::Cottage: case HouseSize::Cottage:
maxExternalItems = 20; entry.m_maxPlacedExternalItems = 20;
maxInternalItems = 200; entry.m_maxPlacedInternalItems = 200;
break; break;
case HouseSize::House: case HouseSize::House:
maxExternalItems = 30; entry.m_maxPlacedExternalItems = 30;
maxInternalItems = 300; entry.m_maxPlacedInternalItems = 300;
break; break;
case HouseSize::Mansion: case HouseSize::Mansion:
maxExternalItems = 40; entry.m_maxPlacedExternalItems = 40;
maxInternalItems = 400; entry.m_maxPlacedInternalItems = 400;
break; break;
default: default:
// this should never ever happen, if it does the db is fucked // this should never ever happen, if it does the db is fucked
log->error( "HousingMgr: Plot " + std::to_string( entry.m_landId ) + " in landset " + std::to_string( entry.m_landSetId ) + log->error( "HousingMgr: Plot " + std::to_string( entry.m_landId ) + " in landset " + std::to_string( entry.m_landSetId ) +
" has an invalid land size, defaulting to cottage." ); " has an invalid land size, defaulting to cottage." );
maxExternalItems = 20; entry.m_maxPlacedExternalItems = 20;
maxInternalItems = 200; entry.m_maxPlacedInternalItems = 200;
break; break;
} }
// setup containers
// todo: this is pretty garbage
Common::LandIdent ident;
ident.territoryTypeId = entry.m_landSetId >> 16;
ident.wardNum = entry.m_landSetId & 0xFFFF;
ident.landId = entry.m_landId;
ident.worldId = 67;
auto& containers = getEstateInventory( ident );
auto makeContainer = [ &containers ]( Common::InventoryType type, uint16_t size )
{
containers[ type ] = make_ItemContainer( type, size, "houseiteminventory", true );
};
uint16_t count = 0;
for( int i = 0; i < 8; ++i )
{
if( count >= entry.m_maxPlacedInternalItems )
break;
auto& pair = m_containerMap[ i ];
makeContainer( pair.first, 50 );
makeContainer( pair.second, 50 );
count += 50;
}
// exterior
makeContainer( InventoryType::HousingExteriorPlacedItems, entry.m_maxPlacedExternalItems );
makeContainer( InventoryType::HousingExteriorStoreroom, entry.m_maxPlacedExternalItems );
// fixed containers
makeContainer( InventoryType::HousingInteriorAppearance, 10 );
makeContainer( InventoryType::HousingExteriorAppearance, 8 );
} }
} }
@ -855,7 +896,7 @@ uint32_t Sapphire::World::Manager::HousingMgr::getItemAdditionalData( uint32_t c
bool Sapphire::World::Manager::HousingMgr::isPlacedItemsInventory( Sapphire::Common::InventoryType type ) bool Sapphire::World::Manager::HousingMgr::isPlacedItemsInventory( Sapphire::Common::InventoryType type )
{ {
return type == InventoryType::HousingOutdoorPlacedItems || return type == InventoryType::HousingExteriorPlacedItems ||
type == InventoryType::HousingInteriorPlacedItems1 || type == InventoryType::HousingInteriorPlacedItems1 ||
type == InventoryType::HousingInteriorPlacedItems2 || type == InventoryType::HousingInteriorPlacedItems2 ||
type == InventoryType::HousingInteriorPlacedItems3 || type == InventoryType::HousingInteriorPlacedItems3 ||

View file

@ -26,7 +26,7 @@ namespace Sapphire::World::Manager
{ {
// land table // land table
uint64_t m_landSetId; uint64_t m_landSetId;
uint64_t m_landId; uint16_t m_landId;
Common::LandType m_type; Common::LandType m_type;
uint8_t m_size; uint8_t m_size;
@ -46,6 +46,9 @@ namespace Sapphire::World::Manager
uint64_t m_buildTime; uint64_t m_buildTime;
uint64_t m_endorsements; uint64_t m_endorsements;
uint16_t m_maxPlacedExternalItems;
uint16_t m_maxPlacedInternalItems;
}; };
/*! /*!
@ -190,6 +193,8 @@ namespace Sapphire::World::Manager
LandSetLandCacheMap m_landCache; LandSetLandCacheMap m_landCache;
LandIdentToInventoryContainerMap m_estateInventories; LandIdentToInventoryContainerMap m_estateInventories;
std::array< std::pair< Common::InventoryType, Common::InventoryType >, 8 > m_containerMap;
}; };
} }

View file

@ -430,9 +430,9 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
if( !housingMgr ) if( !housingMgr )
break; break;
uint16_t inventoryType = Common::InventoryType::HousingOutdoorPlacedItems; uint16_t inventoryType = Common::InventoryType::HousingExteriorPlacedItems;
if( param2 == 1 ) if( param2 == 1 )
inventoryType = Common::InventoryType::HousingOutdoorStoreroom; inventoryType = Common::InventoryType::HousingExteriorStoreroom;
housingMgr->sendEstateInventory( player, inventoryType, plot ); housingMgr->sendEstateInventory( player, inventoryType, plot );