mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-03 01:07:47 +00:00
Handle house removing.
Also restored the house building scene, might still crash sound device though.
This commit is contained in:
parent
991e0551c3
commit
3624b4374f
8 changed files with 114 additions and 5 deletions
|
@ -257,6 +257,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( uint8_t slotId )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( m_itemMap.find( slotId ) == m_itemMap.end() )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return m_itemMap[ slotId ];
|
return m_itemMap[ slotId ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -662,6 +662,14 @@ void Sapphire::World::Manager::HousingMgr::createHouse( Sapphire::HousePtr house
|
||||||
db.execute( stmt );
|
db.execute( stmt );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::World::Manager::HousingMgr::deleteHouse( Sapphire::HousePtr house ) const
|
||||||
|
{
|
||||||
|
auto& db = Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||||
|
auto stmt = db.getPreparedStatement( Db::HOUSING_HOUSE_DEL );
|
||||||
|
stmt->setUInt( 1, house->getId() );
|
||||||
|
db.execute( stmt );
|
||||||
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetCatalogId )
|
void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetCatalogId )
|
||||||
{
|
{
|
||||||
auto hZone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() );
|
auto hZone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() );
|
||||||
|
@ -702,12 +710,10 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl
|
||||||
|
|
||||||
pLand->updateLandDb();
|
pLand->updateLandDb();
|
||||||
|
|
||||||
// start house built event - disabled because it fucks your audio device
|
// start house built event
|
||||||
// CmnDefHousingBuildHouse_00149
|
// CmnDefHousingBuildHouse_00149
|
||||||
//player.eventStart( player.getId(), 0x000B0095, Event::EventHandler::EventType::Housing, 1, 1 );
|
player.eventStart( player.getId(), 0x000B0095, Event::EventHandler::EventType::Housing, 1, 1 );
|
||||||
//player.playScene( 0x000B0095, 0, static_cast< uint32_t >( SET_BASE | HIDE_HOTBAR ) , 0, 1, plotNum, nullptr );
|
player.playScene( 0x000B0095, 0, static_cast< uint32_t >( SET_BASE | HIDE_HOTBAR ) , 0, 1, plotNum, nullptr );
|
||||||
// instead we do a fake zone to unlock the client
|
|
||||||
Common::Service< TerritoryMgr >::ref().movePlayer( player.getCurrentTerritory(), player.getAsPlayer() );
|
|
||||||
|
|
||||||
player.setLandFlags( LandFlagsSlot::Private, EstateBuilt, ident );
|
player.setLandFlags( LandFlagsSlot::Private, EstateBuilt, ident );
|
||||||
player.sendLandFlagsSlot( LandFlagsSlot::Private );
|
player.sendLandFlagsSlot( LandFlagsSlot::Private );
|
||||||
|
@ -1689,3 +1695,66 @@ void Sapphire::World::Manager::HousingMgr::editAppearance( bool isInterior, Sapp
|
||||||
terri->sendLandUpdate( landIdent.landId );
|
terri->sendLandUpdate( landIdent.landId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::World::Manager::HousingMgr::removeHouse( Entity::Player& player, uint16_t plot )
|
||||||
|
{
|
||||||
|
auto terri = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() );
|
||||||
|
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() )[ InventoryType::HousingInteriorAppearance ];
|
||||||
|
auto& invMgr = Service< InventoryMgr >::ref();
|
||||||
|
|
||||||
|
std::unordered_map< 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( HouseStatus::Sold );
|
||||||
|
land->updateLandDb();
|
||||||
|
terri->sendLandUpdate( plot );
|
||||||
|
|
||||||
|
player.setLandFlags( LandFlagsSlot::Private, 0, land->getLandIdent() );
|
||||||
|
|
||||||
|
terri->removeEstateEntranceEObj( plot );
|
||||||
|
|
||||||
|
// missing reply for ClientTrigger RequestEstateHallRemoval
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
|
@ -183,6 +183,8 @@ namespace Sapphire::World::Manager
|
||||||
|
|
||||||
void editAppearance( bool isInterior, Sapphire::Entity::Player& player, const Common::LandIdent landIdent, std::vector< uint16_t > containerList, std::vector< uint8_t > slotList, uint8_t removeFlag );
|
void editAppearance( bool isInterior, Sapphire::Entity::Player& player, const Common::LandIdent landIdent, std::vector< uint16_t > containerList, std::vector< uint8_t > slotList, uint8_t removeFlag );
|
||||||
|
|
||||||
|
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 );
|
||||||
|
@ -274,6 +276,8 @@ namespace Sapphire::World::Manager
|
||||||
*/
|
*/
|
||||||
void createHouse( HousePtr house ) const;
|
void createHouse( HousePtr house ) const;
|
||||||
|
|
||||||
|
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
|
||||||
|
|
|
@ -89,6 +89,9 @@ void Sapphire::World::Manager::InventoryMgr::saveHousingContainer( Common::LandI
|
||||||
|
|
||||||
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() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,6 +475,14 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ClientTriggerType::RequestEstateHallRemoval:
|
||||||
|
{
|
||||||
|
auto& housingMgr = Common::Service< HousingMgr >::ref();
|
||||||
|
|
||||||
|
housingMgr.removeHouse( player, static_cast< uint16_t >( param11 ) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ClientTriggerType::UpdateEstateGuestAccess:
|
case ClientTriggerType::UpdateEstateGuestAccess:
|
||||||
{
|
{
|
||||||
auto canTeleport = ( param2 & 0xFF ) == 1;
|
auto canTeleport = ( param2 & 0xFF ) == 1;
|
||||||
|
|
|
@ -321,6 +321,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() == 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();
|
||||||
|
|
|
@ -53,6 +53,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