1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-25 02:57:45 +00:00

implement housing edit exterior

This commit is contained in:
collett 2021-02-06 00:25:39 +09:00
parent 7f2c58bdfa
commit 6b95c00d29
9 changed files with 75 additions and 8 deletions

View file

@ -396,6 +396,7 @@ namespace Sapphire::Network::Packets
LandRenameHandler = 0x0155, // updated 5.35 hotfix
HousingUpdateHouseGreeting = 0x02EA, // updated 5.35 hotfix
HousingUpdateObjectPosition = 0x00D5, // updated 5.35 hotfix
HousingEditExterior = 0x0098, // updated 5.35 hotfix
SetSharedEstateSettings = 0x017B, // updated 5.0

View file

@ -426,6 +426,16 @@ struct FFXIVIpcDive :
uint32_t padding;
};
struct FFXIVIpcHousingEditExterior :
FFXIVIpcBasePacket< HousingEditExterior >
{
uint16_t landId;
uint8_t unknown[8];
uint16_t container[9];
uint16_t slot[9];
uint16_t padding;
};
}
#endif //_CORE_NETWORK_PACKETS_ZONE_CLIENT_IPC_H

View file

@ -1631,3 +1631,42 @@ Sapphire::Inventory::HousingItemPtr Sapphire::World::Manager::HousingMgr::getHou
return Inventory::make_HousingItem( tmpItem->getUId(), tmpItem->getId() );
}
void Sapphire::World::Manager::HousingMgr::editExterior( Sapphire::Entity::Player& player, uint16_t plot, std::vector< uint16_t > containerList, std::vector< uint8_t> slotList )
{
auto terri = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() );
if( !terri )
return;
auto land = terri->getLand( static_cast< uint8_t >( plot ) );
if( !land )
return;
if( !hasPermission( player, *land, 0 ) )
return;
auto& exteriorAppearenceContainer = getEstateInventory( land->getLandIdent() )[ InventoryType::HousingExteriorAppearance ];
auto& invMgr = Service< InventoryMgr >::ref();
for( int i = 0; i < 9; i++ )
{
auto container = containerList.at( i );
auto slot = slotList.at( i );
if( container == 0x270F || slot == 0xFF )
continue;
auto item = getHousingItemFromPlayer( player, static_cast< Sapphire::Common::InventoryType >( container ), slot );
if( item )
{
auto oldItem = exteriorAppearenceContainer->getItem( i );
if( oldItem )
{
player.addItem( oldItem, false, false, false );
}
exteriorAppearenceContainer->setItem( i, item );
}
}
invMgr.saveHousingContainer( land->getLandIdent(), exteriorAppearenceContainer );
updateHouseModels( land->getHouse() );
std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() )->sendLandUpdate( plot );
}

View file

@ -181,6 +181,8 @@ namespace Sapphire::World::Manager
bool hasPermission( Entity::Player& player, Land& land, uint32_t permission );
void editExterior( Sapphire::Entity::Player& player, uint16_t plot, std::vector< uint16_t > containerList, std::vector< uint8_t> slotList );
private:
Inventory::HousingItemPtr getHousingItemFromPlayer( Entity::Player& player, Common::InventoryType type, uint8_t slot );

View file

@ -90,6 +90,7 @@ Sapphire::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pH
setZoneHandler( ClientZoneIpcType::ReqPlaceHousingItem, "ReqPlaceHousingItem", &GameConnection::reqPlaceHousingItem );
setZoneHandler( ClientZoneIpcType::HousingUpdateObjectPosition, "HousingUpdateObjectPosition",
&GameConnection::reqMoveHousingItem );
setZoneHandler( ClientZoneIpcType::HousingEditExterior, "HousingEditExterior", &GameConnection::housingEditExterior );
setZoneHandler( ClientZoneIpcType::TalkEventHandler, "EventHandlerTalk", &GameConnection::eventHandlerTalk );
setZoneHandler( ClientZoneIpcType::EmoteEventHandler, "EventHandlerEmote", &GameConnection::eventHandlerEmote );

View file

@ -183,6 +183,8 @@ namespace Sapphire::Network
DECLARE_HANDLER( reqMoveHousingItem );
DECLARE_HANDLER( housingEditExterior );
DECLARE_HANDLER( marketBoardSearch );
DECLARE_HANDLER( marketBoardRequestItemInfo );

View file

@ -729,6 +729,23 @@ void Sapphire::Network::GameConnection::reqMoveHousingItem( const Packets::FFXIV
housingMgr.reqMoveHousingItem( player, data.ident, data.slot, data.pos, data.rotation );
}
void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{
auto& housingMgr = Common::Service< HousingMgr >::ref();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcHousingEditExterior >( inPacket );
std::vector< uint16_t > containerList;
std::vector< uint8_t > slotList;
for( int i = 0; i < 9; i++ )
{
auto container = packet.data().container[i];
containerList.push_back( container );
slotList.push_back( container != 0x270F ? static_cast< uint8_t >( packet.data().slot[i] ) : 0xFF );
}
housingMgr.editExterior( player, packet.data().landId, containerList, slotList );
}
void Sapphire::Network::GameConnection::marketBoardSearch( const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player )
{

View file

@ -240,18 +240,17 @@ void Sapphire::Land::update( uint64_t tickCount )
Sapphire::Land::InvMaxItemsPair Sapphire::Land::getInventoryItemMax() const
{
//return std::make_pair( m_maxPlacedExternalItems, m_maxPlacedInternalItems );
switch( m_size )
{
case 0:
case HouseSize::Cottage:
{
return std::make_pair( 20, 200 );
}
case 1:
case HouseSize::House:
{
return std::make_pair( 30, 300 );
}
case 2:
case HouseSize::Mansion:
{
return std::make_pair( 40, 400 );
}

View file

@ -86,10 +86,6 @@ namespace Sapphire
Sapphire::HousePtr m_pHouse;
//item storage
//uint16_t m_maxPlacedExternalItems;
//uint16_t m_maxPlacedInternalItems;
//price
uint32_t m_initPrice;
uint32_t m_nextDrop;