mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
handle internal/external housing storeroom inventory requests
This commit is contained in:
parent
c1b3e5d393
commit
899b4aead3
8 changed files with 103 additions and 3 deletions
|
@ -311,12 +311,13 @@ enum ActorControlType : uint16_t
|
|||
RequestLandSignOwned = 0x452,
|
||||
RequestWardLandInfo = 0x453,
|
||||
RequestLandRelinquish = 0x454,
|
||||
RequestExternalHousingInventory = 0x0458,
|
||||
RequestEstateRename = 0x45A,
|
||||
RequestEstateEditGreeting = 0x45B,
|
||||
RequestEstateGreeting = 0x45C, // sends FFXIVIpcHousingEstateGreeting in return
|
||||
RequestEstateEditGuestAccessSettings = 0x45D,
|
||||
RequestEstateTagSettings = 0x45F,
|
||||
|
||||
RequestInternalHousingInventory = 0x0461,
|
||||
RequestHousingItemUI = 0x463,
|
||||
RequestSharedEstateSettings = 0x46F,
|
||||
UpdateEstateLightingLevel = 0x471,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "TerritoryMgr.h"
|
||||
#include "Territory/Zone.h"
|
||||
#include "Territory/HousingZone.h"
|
||||
#include "Territory/Housing/HousingInteriorTerritory.h"
|
||||
#include "HousingMgr.h"
|
||||
#include "Territory/Land.h"
|
||||
#include "Framework.h"
|
||||
|
@ -462,4 +463,45 @@ Sapphire::Common::LandIdent Sapphire::World::Manager::HousingMgr::clientTriggerP
|
|||
ident.landId = param12 & 0xFFFF;
|
||||
|
||||
return ident;
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::sendHousingInventory( Entity::Player& player, uint16_t inventoryType, uint8_t plotNum )
|
||||
{
|
||||
Sapphire::LandPtr targetLand;
|
||||
|
||||
// plotNum will be 255 in the event that it's an internal zone
|
||||
// and we have to switch up our way of getting the LandPtr
|
||||
if( plotNum == 255 )
|
||||
{
|
||||
auto internalZone = std::dynamic_pointer_cast< Territory::Housing::HousingInteriorTerritory >( player.getCurrentZone() );
|
||||
if( !internalZone )
|
||||
return;
|
||||
|
||||
auto ident = internalZone->getIdent();
|
||||
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto exteriorZone = getHousingZoneByLandSetId( landSetId );
|
||||
|
||||
if( !exteriorZone )
|
||||
return;
|
||||
|
||||
targetLand = exteriorZone->getLand( ident.landId );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
|
||||
if( !zone )
|
||||
return;
|
||||
|
||||
targetLand = zone->getLand( plotNum );
|
||||
}
|
||||
|
||||
if( !targetLand )
|
||||
return;
|
||||
|
||||
// todo: add proper permissions checks
|
||||
if( targetLand->getPlayerOwner() != player.getId() )
|
||||
return;
|
||||
|
||||
player.sendDebug( "got inventory for plot: " + targetLand->getHouse()->getHouseName() );
|
||||
}
|
|
@ -30,6 +30,9 @@ namespace Sapphire::World::Manager
|
|||
void sendLandSignFree( Entity::Player& player, const Common::LandIdent ident );
|
||||
LandPurchaseResult purchaseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
||||
|
||||
/*!
|
||||
* @brief Converts param1 of a client trigger into a Common::LandIndent
|
||||
*/
|
||||
Common::LandIdent clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12 ) const;
|
||||
|
||||
void sendWardLandInfo( Entity::Player& player, uint8_t wardId, uint16_t territoryTypeId );
|
||||
|
@ -47,6 +50,13 @@ namespace Sapphire::World::Manager
|
|||
|
||||
void sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident );
|
||||
|
||||
/*!
|
||||
* @brief Sends the house inventory for the specified type to a player.
|
||||
*
|
||||
* This enforces permissions on the inventory too so random players can't request a houses items
|
||||
*/
|
||||
void sendHousingInventory( Entity::Player& player, uint16_t inventoryType, uint8_t plotNum );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -421,6 +421,35 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
|||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestExternalHousingInventory:
|
||||
{
|
||||
if( param2 != 1 )
|
||||
return;
|
||||
|
||||
uint8_t plot = ( param12 & 0xFF );
|
||||
|
||||
auto housingMgr = g_fw.get< HousingMgr >();
|
||||
if( !housingMgr )
|
||||
break;
|
||||
|
||||
housingMgr->sendHousingInventory( player, Common::InventoryType::HousingOutdoorItemStoreroom, plot );
|
||||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestInternalHousingInventory:
|
||||
{
|
||||
// only sent if param1 is 1, because the client sends this with 0 when you open the ui for whatever reason
|
||||
if( param1 != 1 )
|
||||
return;
|
||||
|
||||
auto housingMgr = g_fw.get< HousingMgr >();
|
||||
if( !housingMgr )
|
||||
break;
|
||||
|
||||
housingMgr->sendHousingInventory( player, Common::InventoryType::HousingIndoorItemStoreroom, 255 );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ void Housing::HousingInteriorTerritory::onPlayerZoneIn( Entity::Player& player )
|
|||
|
||||
for( auto i = 0; i < 10; i++ )
|
||||
{
|
||||
indoorInitPacket->data().indoorItems[ i ] = pHouse->getHouseInteriorPart( (Common::HousingInteriorSlot)i );
|
||||
indoorInitPacket->data().indoorItems[ i ] = pHouse->getHouseInteriorPart( static_cast< Common::HousingInteriorSlot >( i ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,4 +102,9 @@ void Housing::HousingInteriorTerritory::onUpdate( uint32_t currTime )
|
|||
uint32_t Housing::HousingInteriorTerritory::getLastActivityTime() const
|
||||
{
|
||||
return m_lastActivityTime;
|
||||
}
|
||||
|
||||
const Common::LandIdent Housing::HousingInteriorTerritory::getIdent() const
|
||||
{
|
||||
return m_landIdent;
|
||||
}
|
|
@ -20,6 +20,8 @@ namespace Sapphire::World::Territory::Housing
|
|||
|
||||
uint32_t getLastActivityTime() const;
|
||||
|
||||
const Common::LandIdent getIdent() const;
|
||||
|
||||
private:
|
||||
Common::LandIdent m_landIdent;
|
||||
uint32_t m_lastActivityTime;
|
||||
|
|
|
@ -355,3 +355,12 @@ bool Sapphire::Land::setPreset( uint32_t itemId )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
Sapphire::ItemContainerPtr Sapphire::Land::getInventory( uint16_t inventoryType ) const
|
||||
{
|
||||
auto container = m_landInventoryMap.find( inventoryType );
|
||||
if( container == m_landInventoryMap.end() )
|
||||
return nullptr;
|
||||
|
||||
return container->second;
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace Sapphire
|
|||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId, Sapphire::Data::HousingLandSetPtr info );
|
||||
virtual ~Land();
|
||||
|
||||
using LandInventoryMap = std::unordered_map< uint32_t, ItemContainerPtr >;
|
||||
using LandInventoryMap = std::unordered_map< uint16_t, ItemContainerPtr >;
|
||||
|
||||
//Primary state
|
||||
void setSize( uint8_t size );
|
||||
|
@ -61,6 +61,8 @@ namespace Sapphire
|
|||
void setLandTag( uint8_t slot, uint8_t tag );
|
||||
uint8_t getLandTag( uint8_t slot );
|
||||
|
||||
ItemContainerPtr getInventory( uint16_t inventoryType ) const;
|
||||
|
||||
private:
|
||||
uint32_t convertItemIdToHousingItemId( uint32_t itemId );
|
||||
void init();
|
||||
|
|
Loading…
Add table
Reference in a new issue