mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-12 21:47:45 +00:00
WiP Added house removal, taken from collets commit.
This commit is contained in:
parent
a280f9c3b8
commit
6ef3c0b071
8 changed files with 118 additions and 0 deletions
|
@ -291,6 +291,10 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
|
||||||
"UPDATE house SET BuildTime = ?, Aetheryte = ?, Comment = ?, HouseName = ?, Endorsements = ? WHERE HouseId = ?;",
|
"UPDATE house SET BuildTime = ?, Aetheryte = ?, Comment = ?, HouseName = ?, Endorsements = ? WHERE HouseId = ?;",
|
||||||
CONNECTION_BOTH );
|
CONNECTION_BOTH );
|
||||||
|
|
||||||
|
prepareStatement( HOUSING_HOUSE_DEL,
|
||||||
|
"DELETE from house WHERE HouseId = ?;",
|
||||||
|
CONNECTION_BOTH );
|
||||||
|
|
||||||
prepareStatement( LAND_INV_SEL_ALL,
|
prepareStatement( LAND_INV_SEL_ALL,
|
||||||
"SELECT houseiteminventory.*, charaglobalitem.catalogId, charaglobalitem.stain, charaglobalitem.CharacterId, "
|
"SELECT houseiteminventory.*, charaglobalitem.catalogId, charaglobalitem.stain, charaglobalitem.CharacterId, "
|
||||||
"landplaceditems.PosX, landplaceditems.PosY, landplaceditems.PosZ, landplaceditems.Rotation "
|
"landplaceditems.PosX, landplaceditems.PosY, landplaceditems.PosZ, landplaceditems.Rotation "
|
||||||
|
|
|
@ -86,6 +86,9 @@ Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( m_itemMap.find( slotId ) == m_itemMap.end() )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return m_itemMap[ slotId ];
|
return m_itemMap[ slotId ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -680,6 +680,14 @@ void HousingMgr::createHouse( Sapphire::HousePtr house ) const
|
||||||
db.execute( stmt );
|
db.execute( stmt );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HousingMgr::deleteHouse( Sapphire::HousePtr house ) const
|
||||||
|
{
|
||||||
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||||
|
auto stmt = db.getPreparedStatement( Db::HOUSING_HOUSE_DEL );
|
||||||
|
stmt->setUInt( 1, house->getId() );
|
||||||
|
db.execute( stmt );
|
||||||
|
}
|
||||||
|
|
||||||
void HousingMgr::buildPresetEstate( Entity::Player& player, HousingZone& zone, uint8_t plotNum, uint32_t presetCatalogId )
|
void HousingMgr::buildPresetEstate( Entity::Player& player, HousingZone& zone, uint8_t plotNum, uint32_t presetCatalogId )
|
||||||
{
|
{
|
||||||
auto& server = Common::Service< World::WorldServer >::ref();
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
|
@ -1691,3 +1699,67 @@ Inventory::HousingItemPtr HousingMgr::getHousingItemFromPlayer( Entity::Player&
|
||||||
|
|
||||||
return Inventory::make_HousingItem( tmpItem->getUId(), tmpItem->getId() );
|
return Inventory::make_HousingItem( tmpItem->getUId(), tmpItem->getId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HousingMgr::removeHouse( Entity::Player& player, uint16_t plot )
|
||||||
|
{
|
||||||
|
auto& teriMgr = Common::Service< TerritoryMgr >::ref();
|
||||||
|
auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() );
|
||||||
|
if( !pZone )
|
||||||
|
return;
|
||||||
|
auto terri = std::dynamic_pointer_cast< HousingZone >( pZone );
|
||||||
|
if( !terri )
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto land = terri->getLand( static_cast< uint8_t >( plot ) );
|
||||||
|
if( !land || !land->getHouse() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !hasPermission( player, *land, 0 ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto& interiorContainer = getEstateInventory( land->getLandIdent() )[ Common::InventoryType::HousingInteriorAppearance ];
|
||||||
|
auto& invMgr = Common::Service< InventoryMgr >::ref();
|
||||||
|
|
||||||
|
std::unordered_map< Common::InventoryType, ItemContainerPtr > changedContainerSet = {};
|
||||||
|
|
||||||
|
for( int i = 0; i < interiorContainer->getMaxSize(); i++ )
|
||||||
|
{
|
||||||
|
auto item = interiorContainer->getItem( i );
|
||||||
|
if( !item )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Inventory::InventoryContainerPair freeSlotPair;
|
||||||
|
auto freeContainer = getFreeEstateInventorySlot( land->getLandIdent(), freeSlotPair, m_internalStoreroomContainers );
|
||||||
|
if ( !freeContainer )
|
||||||
|
{
|
||||||
|
// not sure what to do
|
||||||
|
interiorContainer->removeItem( i, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
interiorContainer->removeItem( i, false );
|
||||||
|
freeContainer->setItem( freeSlotPair.second , item );
|
||||||
|
changedContainerSet[ freeSlotPair.first ] = freeContainer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
invMgr.sendInventoryContainer( player, interiorContainer );
|
||||||
|
invMgr.saveHousingContainer( land->getLandIdent(), interiorContainer );
|
||||||
|
for( auto entry : changedContainerSet )
|
||||||
|
{
|
||||||
|
invMgr.sendInventoryContainer( player, entry.second );
|
||||||
|
invMgr.saveHousingContainer( land->getLandIdent(), entry.second );
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteHouse( land->getHouse() );
|
||||||
|
land->setHouse( nullptr );
|
||||||
|
|
||||||
|
land->setStatus( Common::HouseStatus::Sold );
|
||||||
|
land->updateLandDb();
|
||||||
|
terri->sendLandUpdate( plot );
|
||||||
|
|
||||||
|
player.setLandFlags( Common::LandFlagsSlot::Private, 0, land->getLandIdent() );
|
||||||
|
|
||||||
|
terri->removeEstateEntranceEObj( plot );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -178,6 +178,8 @@ namespace Sapphire::World::Manager
|
||||||
|
|
||||||
bool hasPermission( Entity::Player& player, Land& land, uint32_t permission );
|
bool hasPermission( Entity::Player& player, Land& land, uint32_t permission );
|
||||||
|
|
||||||
|
void removeHouse( Entity::Player& player, uint16_t plot );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Inventory::HousingItemPtr getHousingItemFromPlayer( Entity::Player& player, Common::InventoryType type, uint8_t slot );
|
Inventory::HousingItemPtr getHousingItemFromPlayer( Entity::Player& player, Common::InventoryType type, uint8_t slot );
|
||||||
|
@ -269,6 +271,15 @@ namespace Sapphire::World::Manager
|
||||||
*/
|
*/
|
||||||
void createHouse( HousePtr house ) const;
|
void createHouse( HousePtr house ) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Deletes a house
|
||||||
|
*
|
||||||
|
* Any other changes will be covered by the usual saving logic and can be safely ignored here.
|
||||||
|
*
|
||||||
|
* @param house The house to create in the house table
|
||||||
|
*/
|
||||||
|
void deleteHouse( HousePtr house ) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets the next available house id
|
* @brief Gets the next available house id
|
||||||
* @return The next available house id
|
* @return The next available house id
|
||||||
|
|
|
@ -98,6 +98,8 @@ void InventoryMgr::saveHousingContainer( Common::LandIdent ident, ItemContainerP
|
||||||
|
|
||||||
for( auto& item : container->getItemMap() )
|
for( auto& item : container->getItemMap() )
|
||||||
{
|
{
|
||||||
|
if( !item.second )
|
||||||
|
continue;
|
||||||
saveHousingContainerItem( u64ident, container->getId(), item.first, item.second->getUId() );
|
saveHousingContainerItem( u64ident, container->getId(), item.first, item.second->getUId() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -763,6 +763,14 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PacketCommand::HOUSING_LOCK_LAND_BY_BREAK:
|
||||||
|
{
|
||||||
|
auto& housingMgr = Service< HousingMgr >::ref();
|
||||||
|
housingMgr.removeHouse( player, static_cast< uint16_t >( param11 ) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* case PacketCommand::RequestLandInventory:
|
/* case PacketCommand::RequestLandInventory:
|
||||||
{
|
{
|
||||||
uint8_t plot = ( param12 & 0xFF );
|
uint8_t plot = ( param12 & 0xFF );
|
||||||
|
|
|
@ -308,6 +308,23 @@ Sapphire::Entity::EventObjectPtr Sapphire::HousingZone::registerEstateEntranceEO
|
||||||
return eObj;
|
return eObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::HousingZone::removeEstateEntranceEObj( uint8_t landId )
|
||||||
|
{
|
||||||
|
auto land = getLand( landId );
|
||||||
|
assert( land );
|
||||||
|
|
||||||
|
for( auto entry : m_eventObjects )
|
||||||
|
{
|
||||||
|
auto eObj = entry.second;
|
||||||
|
if( eObj->getHousingLink() == static_cast< uint32_t >( landId ) << 8 )
|
||||||
|
{
|
||||||
|
removeActor( eObj );
|
||||||
|
m_eventObjects.erase( entry.first );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Sapphire::HousingZone::updateYardObjects( Sapphire::Common::LandIdent ident )
|
void Sapphire::HousingZone::updateYardObjects( Sapphire::Common::LandIdent ident )
|
||||||
{
|
{
|
||||||
auto& housingMgr = Common::Service< World::Manager::HousingMgr >::ref();
|
auto& housingMgr = Common::Service< World::Manager::HousingMgr >::ref();
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace Sapphire
|
||||||
Sapphire::LandPtr getLand( uint8_t id );
|
Sapphire::LandPtr getLand( uint8_t id );
|
||||||
|
|
||||||
Entity::EventObjectPtr registerEstateEntranceEObj( uint8_t landId );
|
Entity::EventObjectPtr registerEstateEntranceEObj( uint8_t landId );
|
||||||
|
void removeEstateEntranceEObj( uint8_t landId );
|
||||||
|
|
||||||
void updateYardObjects( Common::LandIdent ident );
|
void updateYardObjects( Common::LandIdent ident );
|
||||||
void spawnYardObject( uint8_t landId, uint16_t slotId, Sapphire::Inventory::HousingItem& item );
|
void spawnYardObject( uint8_t landId, uint16_t slotId, Sapphire::Inventory::HousingItem& item );
|
||||||
|
|
Loading…
Add table
Reference in a new issue