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

housing edit interior

This commit is contained in:
collett 2021-07-29 02:01:02 +09:00
parent 37fabec6f5
commit b014b9265d
7 changed files with 62 additions and 24 deletions

View file

@ -194,7 +194,7 @@ namespace Sapphire::Network::Packets
EventPlay128 = 0x026E, // updated 5.58 EventPlay128 = 0x026E, // updated 5.58
EventPlay255 = 0x039E, // updated 5.58 EventPlay255 = 0x039E, // updated 5.58
EventYield = 0x02CB, // updated 5.55 hotfix EventYield = 0x0123, // updated 5.58
//EventYield4 = 0x0000, //EventYield4 = 0x0000,
//EventYield8 = 0x0000, //EventYield8 = 0x0000,
//EventYield16 = 0x0000, //EventYield16 = 0x0000,
@ -216,7 +216,7 @@ namespace Sapphire::Network::Packets
MSQTrackerComplete = 0x01C1, // updated 5.58 MSQTrackerComplete = 0x01C1, // updated 5.58
MSQTrackerProgress = 0xF1CD, // updated 4.5 ? this actually looks like the two opcodes have been combined, see #474 MSQTrackerProgress = 0xF1CD, // updated 4.5 ? this actually looks like the two opcodes have been combined, see #474
QuestMessage = 0x036E, // updated 5.55 hotfix QuestMessage = 0x0128, // updated 5.58
QuestTracker = 0x038E, // updated 5.58 QuestTracker = 0x038E, // updated 5.58
@ -243,7 +243,7 @@ namespace Sapphire::Network::Packets
EquipDisplayFlags = 0x0199, // updated 5.58 EquipDisplayFlags = 0x0199, // updated 5.58
MiniCactpotInit = 0x0286, // added 5.31 MiniCactpotInit = 0x0286, // added 5.31
ShopMessage = 0x0162, // updated 5.55 hotfix ShopMessage = 0x00D0, // updated 5.58
LootMessage = 0x038C, // updated 5.58 LootMessage = 0x038C, // updated 5.58
ResultDialog = 0x00DF, // updated 5.58 ResultDialog = 0x00DF, // updated 5.58
DesynthResult = 0x038F, // updated 5.58 DesynthResult = 0x038F, // updated 5.58
@ -395,7 +395,7 @@ namespace Sapphire::Network::Packets
OutOfRangeEventHandler = 0x0294, // updated 5.58 OutOfRangeEventHandler = 0x0294, // updated 5.58
EnterTeriEventHandler = 0x00C1, // updated 5.58 EnterTeriEventHandler = 0x00C1, // updated 5.58
ShopEventHandler = 0x02B8, // updated 5.58 ShopEventHandler = 0x02B8, // updated 5.58
EventYieldHandler = 0x02A0, // updated 5.55 hotfix EventYieldHandler = 0x03A2, // updated 5.58
ReturnEventHandler = 0x0333, // updated 5.58 ReturnEventHandler = 0x0333, // updated 5.58
TradeReturnEventHandler = 0x0179, // updated 5.58 TradeReturnEventHandler = 0x0179, // updated 5.58
TradeReturnEventHandler2 = 0x0169, // updated 5.55 hotfix TradeReturnEventHandler2 = 0x0169, // updated 5.55 hotfix
@ -408,7 +408,8 @@ namespace Sapphire::Network::Packets
LandRenameHandler = 0x0083, // updated 5.58 LandRenameHandler = 0x0083, // updated 5.58
HousingUpdateHouseGreeting = 0x031A, // updated 5.58 HousingUpdateHouseGreeting = 0x031A, // updated 5.58
HousingUpdateObjectPosition = 0x010E, // updated 5.58 HousingUpdateObjectPosition = 0x010E, // updated 5.58
HousingEditAppearance = 0x00D7, // updated 5.55 hotfix HousingEditExterior = 0x0324, // updated 5.58
HousingEditInterior = 0x02F7, // updated 5.58
SetSharedEstateSettings = 0x0342, // updated 5.58 SetSharedEstateSettings = 0x0342, // updated 5.58

View file

@ -427,7 +427,7 @@ struct FFXIVIpcDive :
}; };
struct FFXIVIpcHousingEditExterior : struct FFXIVIpcHousingEditExterior :
FFXIVIpcBasePacket< HousingEditAppearance > FFXIVIpcBasePacket< HousingEditExterior >
{ {
uint16_t landId; uint16_t landId;
uint8_t unknown[6]; uint8_t unknown[6];
@ -438,6 +438,14 @@ struct FFXIVIpcHousingEditExterior :
uint16_t padding; uint16_t padding;
}; };
struct FFXIVIpcHousingEditInterior :
FFXIVIpcBasePacket< HousingEditInterior >
{
uint64_t unknown;
uint16_t container[10];
uint16_t slot[10];
};
} }
#endif //_CORE_NETWORK_PACKETS_ZONE_CLIENT_IPC_H #endif //_CORE_NETWORK_PACKETS_ZONE_CLIENT_IPC_H

View file

@ -1632,24 +1632,23 @@ Sapphire::Inventory::HousingItemPtr Sapphire::World::Manager::HousingMgr::getHou
return Inventory::make_HousingItem( tmpItem->getUId(), tmpItem->getId() ); 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, uint8_t removeFlag ) void Sapphire::World::Manager::HousingMgr::editAppearance( bool isInterior, Sapphire::Entity::Player& player, const Common::LandIdent& landIdent, std::vector< uint16_t > containerList, std::vector< uint8_t> slotList, uint8_t removeFlag )
{ {
auto terri = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() ); auto landSetId = toLandSetId( static_cast< uint16_t >( landIdent.territoryTypeId ), static_cast< uint8_t >( landIdent.wardNum ) );
if( !terri ) auto terri = getHousingZoneByLandSetId( landSetId );
return;
auto land = terri->getLand( static_cast< uint8_t >( plot ) ); auto land = terri->getLand( static_cast< uint8_t >( landIdent.landId ) );
if( !land ) if( !land )
return; return;
if( !hasPermission( player, *land, 0 ) ) if( !hasPermission( player, *land, 0 ) )
return; return;
auto& exteriorAppearenceContainer = getEstateInventory( land->getLandIdent() )[ InventoryType::HousingExteriorAppearance ]; auto& housingContainer = getEstateInventory( landIdent )[ isInterior ? InventoryType::HousingInteriorAppearance : InventoryType::HousingExteriorAppearance ];
auto& invMgr = Service< InventoryMgr >::ref(); auto& invMgr = Service< InventoryMgr >::ref();
for( int i = 0; i < 9; i++ ) for( int i = 0; i < ( isInterior ? 10 : 9 ); i++ )
{ {
auto container = containerList.at( i ); auto container = containerList.at( i );
auto slot = slotList.at( i ); auto slot = slotList.at( i );
@ -1660,11 +1659,11 @@ void Sapphire::World::Manager::HousingMgr::editExterior( Sapphire::Entity::Playe
auto removed = ( ( removeFlag >> ( i - 5 ) ) & 1 ) > 0; auto removed = ( ( removeFlag >> ( i - 5 ) ) & 1 ) > 0;
if( removed ) if( removed )
{ {
auto oldItem = exteriorAppearenceContainer->getItem( i ); auto oldItem = housingContainer->getItem( i );
if( oldItem ) if( oldItem )
{ {
exteriorAppearenceContainer->removeItem( i ); housingContainer->removeItem( i );
invMgr.removeItemFromHousingContainer( land->getLandIdent(), exteriorAppearenceContainer->getId(), i ); invMgr.removeItemFromHousingContainer( land->getLandIdent(), housingContainer->getId(), i );
player.addItem( oldItem, false, false, false ); player.addItem( oldItem, false, false, false );
} }
} }
@ -1674,16 +1673,19 @@ void Sapphire::World::Manager::HousingMgr::editExterior( Sapphire::Entity::Playe
auto item = getHousingItemFromPlayer( player, static_cast< Sapphire::Common::InventoryType >( container ), slot ); auto item = getHousingItemFromPlayer( player, static_cast< Sapphire::Common::InventoryType >( container ), slot );
if( item ) if( item )
{ {
auto oldItem = exteriorAppearenceContainer->getItem( i ); auto oldItem = housingContainer->getItem( i );
exteriorAppearenceContainer->setItem( i, item ); housingContainer->setItem( i, item );
if( oldItem ) if( oldItem )
{ {
player.insertInventoryItem( static_cast< Sapphire::Common::InventoryType >( container ), slot, oldItem ); player.insertInventoryItem( static_cast< Sapphire::Common::InventoryType >( container ), slot, oldItem );
} }
} }
} }
invMgr.sendInventoryContainer( player, exteriorAppearenceContainer ); invMgr.sendInventoryContainer( player, housingContainer );
invMgr.saveHousingContainer( land->getLandIdent(), exteriorAppearenceContainer ); invMgr.saveHousingContainer( land->getLandIdent(), housingContainer );
updateHouseModels( land->getHouse() ); updateHouseModels( land->getHouse() );
std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() )->sendLandUpdate( plot ); if( !isInterior )
{
terri->sendLandUpdate( landIdent.landId );
}
} }

View file

@ -181,7 +181,7 @@ 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 editExterior( Sapphire::Entity::Player& player, uint16_t plot, 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 );
private: private:

View file

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

View file

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

View file

@ -21,6 +21,7 @@
#include "Territory/Territory.h" #include "Territory/Territory.h"
#include "Territory/HousingZone.h" #include "Territory/HousingZone.h"
#include "Territory/Housing/HousingInteriorTerritory.h"
#include "Territory/Land.h" #include "Territory/Land.h"
#include "Territory/ZonePosition.h" #include "Territory/ZonePosition.h"
#include "Territory/House.h" #include "Territory/House.h"
@ -695,6 +696,9 @@ void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXI
{ {
auto& housingMgr = Common::Service< HousingMgr >::ref(); auto& housingMgr = Common::Service< HousingMgr >::ref();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcHousingEditExterior >( inPacket ); const auto packet = ZoneChannelPacket< Client::FFXIVIpcHousingEditExterior >( inPacket );
auto terri = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() );
if( !terri )
return;
std::vector< uint16_t > containerList; std::vector< uint16_t > containerList;
std::vector< uint8_t > slotList; std::vector< uint8_t > slotList;
@ -705,7 +709,27 @@ void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXI
slotList.push_back( container != 0x270F ? static_cast< uint8_t >( packet.data().slot[i] ) : 0xFF ); slotList.push_back( container != 0x270F ? static_cast< uint8_t >( packet.data().slot[i] ) : 0xFF );
} }
housingMgr.editExterior( player, packet.data().landId, containerList, slotList, packet.data().removeFlag ); housingMgr.editAppearance( false, player, terri->getLand( packet.data().landId )->getLandIdent(), containerList, slotList, packet.data().removeFlag );
}
void Sapphire::Network::GameConnection::housingEditInterior( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{
auto& housingMgr = Common::Service< HousingMgr >::ref();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcHousingEditInterior >( inPacket );
auto terri = std::dynamic_pointer_cast< World::Territory::Housing::HousingInteriorTerritory >( player.getCurrentTerritory() );
if( !terri )
return;
std::vector< uint16_t > containerList;
std::vector< uint8_t > slotList;
for( int i = 0; i < 10; 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.editAppearance( true, player, terri->getLandIdent(), containerList, slotList, 0 );
} }
void Sapphire::Network::GameConnection::marketBoardSearch( const Packets::FFXIVARR_PACKET_RAW& inPacket, void Sapphire::Network::GameConnection::marketBoardSearch( const Packets::FFXIVARR_PACKET_RAW& inPacket,