mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-30 16:17:46 +00:00
Merge pull request #449 from NotAdam/housing
Cleanup and some improvements/fixes
This commit is contained in:
commit
c58edb540d
13 changed files with 195 additions and 109 deletions
|
@ -212,7 +212,7 @@ CREATE TABLE `charaitemgearset` (
|
||||||
`CharacterId` int(20) NOT NULL,
|
`CharacterId` int(20) NOT NULL,
|
||||||
`storageId` int(10) NOT NULL,
|
`storageId` int(10) NOT NULL,
|
||||||
`type` int(5) DEFAULT '0',
|
`type` int(5) DEFAULT '0',
|
||||||
`idx` int(5) NOT NULL,
|
`idx` int(5) DEFAULT '0',
|
||||||
`container_0` int(20) DEFAULT '0',
|
`container_0` int(20) DEFAULT '0',
|
||||||
`container_1` int(20) DEFAULT '0',
|
`container_1` int(20) DEFAULT '0',
|
||||||
`container_2` int(20) DEFAULT '0',
|
`container_2` int(20) DEFAULT '0',
|
||||||
|
@ -235,7 +235,7 @@ CREATE TABLE `charaiteminventory` (
|
||||||
`CharacterId` int(20) NOT NULL,
|
`CharacterId` int(20) NOT NULL,
|
||||||
`storageId` int(10) NOT NULL,
|
`storageId` int(10) NOT NULL,
|
||||||
`type` int(5) DEFAULT '0',
|
`type` int(5) DEFAULT '0',
|
||||||
`idx` int(5) NOT NULL,
|
`idx` int(5) DEFAULT '0',
|
||||||
`container_0` int(20) DEFAULT '0',
|
`container_0` int(20) DEFAULT '0',
|
||||||
`container_1` int(20) DEFAULT '0',
|
`container_1` int(20) DEFAULT '0',
|
||||||
`container_2` int(20) DEFAULT '0',
|
`container_2` int(20) DEFAULT '0',
|
||||||
|
|
|
@ -311,12 +311,13 @@ enum ActorControlType : uint16_t
|
||||||
RequestLandSignOwned = 0x452,
|
RequestLandSignOwned = 0x452,
|
||||||
RequestWardLandInfo = 0x453,
|
RequestWardLandInfo = 0x453,
|
||||||
RequestLandRelinquish = 0x454,
|
RequestLandRelinquish = 0x454,
|
||||||
|
RequestLandInventory = 0x0458,
|
||||||
RequestEstateRename = 0x45A,
|
RequestEstateRename = 0x45A,
|
||||||
RequestEstateEditGreeting = 0x45B,
|
RequestEstateEditGreeting = 0x45B,
|
||||||
RequestEstateGreeting = 0x45C, // sends FFXIVIpcHousingEstateGreeting in return
|
RequestEstateGreeting = 0x45C, // sends FFXIVIpcHousingEstateGreeting in return
|
||||||
RequestEstateEditGuestAccessSettings = 0x45D,
|
RequestEstateEditGuestAccessSettings = 0x45D,
|
||||||
RequestEstateTagSettings = 0x45F,
|
RequestEstateTagSettings = 0x45F,
|
||||||
|
RequestEstateInventory = 0x0461,
|
||||||
RequestHousingItemUI = 0x463,
|
RequestHousingItemUI = 0x463,
|
||||||
RequestSharedEstateSettings = 0x46F,
|
RequestSharedEstateSettings = 0x46F,
|
||||||
UpdateEstateLightingLevel = 0x471,
|
UpdateEstateLightingLevel = 0x471,
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
extern Sapphire::Framework g_fw;
|
extern Sapphire::Framework g_fw;
|
||||||
|
|
||||||
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName,
|
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName,
|
||||||
bool isMultiStorage, bool isPersistentStorage ) :
|
bool isMultiStorage, bool isPersistentStorage ) :
|
||||||
m_id( storageId ),
|
m_id( storageId ),
|
||||||
m_size( maxSize ),
|
m_size( maxSize ),
|
||||||
m_tableName( tableName ),
|
m_tableName( tableName ),
|
||||||
|
@ -32,12 +32,12 @@ uint16_t Sapphire::ItemContainer::getId() const
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Sapphire::ItemContainer::getEntryCount() const
|
uint16_t Sapphire::ItemContainer::getEntryCount() const
|
||||||
{
|
{
|
||||||
return static_cast< uint8_t >( m_itemMap.size() );
|
return static_cast< uint16_t >( m_itemMap.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::ItemContainer::removeItem( uint8_t slotId )
|
void Sapphire::ItemContainer::removeItem( uint16_t slotId )
|
||||||
{
|
{
|
||||||
auto pLog = g_fw.get< Logger >();
|
auto pLog = g_fw.get< Logger >();
|
||||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||||
|
@ -68,9 +68,9 @@ const Sapphire::ItemMap& Sapphire::ItemContainer::getItemMap() const
|
||||||
return m_itemMap;
|
return m_itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Sapphire::ItemContainer::getFreeSlot()
|
int16_t Sapphire::ItemContainer::getFreeSlot()
|
||||||
{
|
{
|
||||||
for( uint8_t slotId = 0; slotId < m_size; slotId++ )
|
for( uint16_t slotId = 0; slotId < m_size; slotId++ )
|
||||||
{
|
{
|
||||||
ItemMap::iterator it = m_itemMap.find( slotId );
|
ItemMap::iterator it = m_itemMap.find( slotId );
|
||||||
if( it == m_itemMap.end() ||
|
if( it == m_itemMap.end() ||
|
||||||
|
@ -80,7 +80,7 @@ int8_t Sapphire::ItemContainer::getFreeSlot()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint8_t slotId )
|
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( ( slotId > m_size ) )
|
if( ( slotId > m_size ) )
|
||||||
|
@ -93,7 +93,7 @@ Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint8_t slotId )
|
||||||
return m_itemMap[ slotId ];
|
return m_itemMap[ slotId ];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
|
void Sapphire::ItemContainer::setItem( uint16_t slotId, ItemPtr pItem )
|
||||||
{
|
{
|
||||||
if( slotId > m_size )
|
if( slotId > m_size )
|
||||||
return;
|
return;
|
||||||
|
@ -101,7 +101,7 @@ void Sapphire::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
|
||||||
m_itemMap[ slotId ] = pItem;
|
m_itemMap[ slotId ] = pItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Sapphire::ItemContainer::getMaxSize() const
|
uint16_t Sapphire::ItemContainer::getMaxSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,34 +8,34 @@
|
||||||
namespace Sapphire
|
namespace Sapphire
|
||||||
{
|
{
|
||||||
|
|
||||||
using ItemMap = std::map< uint8_t, ItemPtr >;
|
using ItemMap = std::map< uint16_t, ItemPtr >;
|
||||||
|
|
||||||
class ItemContainer
|
class ItemContainer
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage,
|
ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName, bool isMultiStorage,
|
||||||
bool isPersistentStorage = true );
|
bool isPersistentStorage = true );
|
||||||
|
|
||||||
~ItemContainer();
|
~ItemContainer();
|
||||||
|
|
||||||
uint16_t getId() const;
|
uint16_t getId() const;
|
||||||
|
|
||||||
uint8_t getEntryCount() const;
|
uint16_t getEntryCount() const;
|
||||||
|
|
||||||
void removeItem( uint8_t slotId );
|
void removeItem( uint16_t slotId );
|
||||||
|
|
||||||
ItemMap& getItemMap();
|
ItemMap& getItemMap();
|
||||||
|
|
||||||
const ItemMap& getItemMap() const;
|
const ItemMap& getItemMap() const;
|
||||||
|
|
||||||
ItemPtr getItem( uint8_t slotId );
|
ItemPtr getItem( uint16_t slotId );
|
||||||
|
|
||||||
void setItem( uint8_t slotId, ItemPtr item );
|
void setItem( uint16_t slotId, ItemPtr item );
|
||||||
|
|
||||||
int8_t getFreeSlot();
|
int16_t getFreeSlot();
|
||||||
|
|
||||||
uint8_t getMaxSize() const;
|
uint16_t getMaxSize() const;
|
||||||
|
|
||||||
std::string getTableName() const;
|
std::string getTableName() const;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace Sapphire
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t m_id;
|
uint16_t m_id;
|
||||||
uint8_t m_size;
|
uint16_t m_size;
|
||||||
std::string m_tableName;
|
std::string m_tableName;
|
||||||
bool m_bMultiStorage;
|
bool m_bMultiStorage;
|
||||||
bool m_isPersistentStorage;
|
bool m_isPersistentStorage;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "TerritoryMgr.h"
|
#include "TerritoryMgr.h"
|
||||||
#include "Territory/Zone.h"
|
#include "Territory/Zone.h"
|
||||||
#include "Territory/HousingZone.h"
|
#include "Territory/HousingZone.h"
|
||||||
|
#include "Territory/Housing/HousingInteriorTerritory.h"
|
||||||
#include "HousingMgr.h"
|
#include "HousingMgr.h"
|
||||||
#include "Territory/Land.h"
|
#include "Territory/Land.h"
|
||||||
#include "Framework.h"
|
#include "Framework.h"
|
||||||
|
@ -73,17 +74,17 @@ Sapphire::LandPtr Sapphire::World::Manager::HousingMgr::getLandByOwnerId( uint32
|
||||||
return hZone->getLand( res->getUInt( 2 ) );
|
return hZone->getLand( res->getUInt( 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident )
|
||||||
{
|
{
|
||||||
player.setActiveLand( plotId, wardId );
|
player.setActiveLand( ident.landId, ident.wardNum );
|
||||||
|
|
||||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plotId );
|
auto land = hZone->getLand( ident.landId );
|
||||||
if( !land )
|
if( !land )
|
||||||
{
|
{
|
||||||
land = getLandByOwnerId( player.getId() );
|
land = getLandByOwnerId( player.getId() );
|
||||||
|
@ -96,10 +97,7 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl
|
||||||
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
|
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
|
||||||
landInfoSignPacket->data().houseSize = land->getSize();
|
landInfoSignPacket->data().houseSize = land->getSize();
|
||||||
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
|
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
|
||||||
landInfoSignPacket->data().landIdent.landId = land->getLandId();
|
landInfoSignPacket->data().landIdent = ident;
|
||||||
landInfoSignPacket->data().landIdent.wardNum = land->getWardNum();
|
|
||||||
landInfoSignPacket->data().landIdent.worldId = 67;
|
|
||||||
landInfoSignPacket->data().landIdent.territoryTypeId = land->getTerritoryTypeId();
|
|
||||||
landInfoSignPacket->data().houseIconAdd = land->getSharing();
|
landInfoSignPacket->data().houseIconAdd = land->getSharing();
|
||||||
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
|
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
|
||||||
|
|
||||||
|
@ -114,17 +112,17 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl
|
||||||
player.queuePacket( landInfoSignPacket );
|
player.queuePacket( landInfoSignPacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& player, const Common::LandIdent ident )
|
||||||
{
|
{
|
||||||
player.setActiveLand( plotId, wardId );
|
player.setActiveLand( ident.landId, ident.wardNum );
|
||||||
|
|
||||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plotId );
|
auto land = hZone->getLand( ident.landId );
|
||||||
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
|
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
|
||||||
plotPricePacket->data().price = land->getCurrentPrice();
|
plotPricePacket->data().price = land->getCurrentPrice();
|
||||||
plotPricePacket->data().timeLeft = land->getDevaluationTime();
|
plotPricePacket->data().timeLeft = land->getDevaluationTime();
|
||||||
|
@ -358,19 +356,18 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl
|
||||||
player.setLandFlags( LandFlagsSlot::Private, EstateBuilt, pLand->getLandId(), pLand->getWardNum(), pLand->getTerritoryTypeId() );
|
player.setLandFlags( LandFlagsSlot::Private, EstateBuilt, pLand->getLandId(), pLand->getWardNum(), pLand->getTerritoryTypeId() );
|
||||||
player.sendLandFlagsSlot( LandFlagsSlot::Private );
|
player.sendLandFlagsSlot( LandFlagsSlot::Private );
|
||||||
|
|
||||||
auto eobj = hZone->registerEObj( "entrance", 2002737, 0, 4, pLand->getMapMarkerPosition(), 1.f, 0.f );
|
hZone->registerHouseEntranceEObj( plotNum );
|
||||||
eobj->setHousingLink( plotNum << 8 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& player, const Common::LandIdent ident )
|
||||||
{
|
{
|
||||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plotId );
|
auto land = hZone->getLand( ident.landId );
|
||||||
|
|
||||||
auto house = land->getHouse();
|
auto house = land->getHouse();
|
||||||
if( !house )
|
if( !house )
|
||||||
|
@ -378,24 +375,21 @@ void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player&
|
||||||
|
|
||||||
auto landRenamePacket = makeZonePacket< Server::FFXIVIpcLandRename >( player.getId() );
|
auto landRenamePacket = makeZonePacket< Server::FFXIVIpcLandRename >( player.getId() );
|
||||||
|
|
||||||
landRenamePacket->data().landIdent.landId = land->getLandId();
|
landRenamePacket->data().landIdent = ident;
|
||||||
landRenamePacket->data().landIdent.wardNum = land->getWardNum();
|
|
||||||
landRenamePacket->data().landIdent.worldId = 67;
|
|
||||||
landRenamePacket->data().landIdent.territoryTypeId = land->getTerritoryTypeId();
|
|
||||||
memcpy( &landRenamePacket->data().houseName, house->getHouseName().c_str(), 20 );
|
memcpy( &landRenamePacket->data().houseName, house->getHouseName().c_str(), 20 );
|
||||||
|
|
||||||
player.queuePacket( landRenamePacket );
|
player.queuePacket( landRenamePacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident )
|
||||||
{
|
{
|
||||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plotId );
|
auto land = hZone->getLand( ident.landId );
|
||||||
if( !land )
|
if( !land )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -405,16 +399,13 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Pl
|
||||||
|
|
||||||
auto estateGreetingPacket = makeZonePacket< Server::FFXIVIpcHousingEstateGreeting >( player.getId() );
|
auto estateGreetingPacket = makeZonePacket< Server::FFXIVIpcHousingEstateGreeting >( player.getId() );
|
||||||
|
|
||||||
estateGreetingPacket->data().landIdent.landId = land->getLandId();
|
estateGreetingPacket->data().landIdent = ident;
|
||||||
estateGreetingPacket->data().landIdent.wardNum = land->getWardNum();
|
|
||||||
estateGreetingPacket->data().landIdent.worldId = 67;
|
|
||||||
estateGreetingPacket->data().landIdent.territoryTypeId = land->getTerritoryTypeId();
|
|
||||||
memcpy( &estateGreetingPacket->data().message, house->getHouseGreeting().c_str(), sizeof( estateGreetingPacket->data().message ) );
|
memcpy( &estateGreetingPacket->data().message, house->getHouseGreeting().c_str(), sizeof( estateGreetingPacket->data().message ) );
|
||||||
|
|
||||||
player.queuePacket( estateGreetingPacket );
|
player.queuePacket( estateGreetingPacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent& ident, const std::string& greeting )
|
void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting )
|
||||||
{
|
{
|
||||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||||
auto zone = getHousingZoneByLandSetId( landSetId );
|
auto zone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
@ -440,15 +431,15 @@ void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player&
|
||||||
player.sendLogMessage( 3381 );
|
player.sendLogMessage( 3381 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident )
|
||||||
{
|
{
|
||||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plotId );
|
auto land = hZone->getLand( ident.landId );
|
||||||
if( !land )
|
if( !land )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -457,11 +448,59 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto packet = makeZonePacket< FFXIVIpcHousingShowEstateGuestAccess >( player.getId() );
|
auto packet = makeZonePacket< FFXIVIpcHousingShowEstateGuestAccess >( player.getId() );
|
||||||
|
packet->data().ident = ident;
|
||||||
packet->data().ident.landId = plotId;
|
|
||||||
packet->data().ident.territoryTypeId = territoryTypeId;
|
|
||||||
packet->data().ident.wardNum = wardId;
|
|
||||||
packet->data().ident.worldId = worldId;
|
|
||||||
|
|
||||||
player.queuePacket( packet );
|
player.queuePacket( packet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sapphire::Common::LandIdent Sapphire::World::Manager::HousingMgr::clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12 ) const
|
||||||
|
{
|
||||||
|
Common::LandIdent ident;
|
||||||
|
ident.worldId = param11 >> 16;
|
||||||
|
ident.territoryTypeId = param11 & 0xFFFF;
|
||||||
|
ident.wardNum = param12 >> 16;
|
||||||
|
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() );
|
||||||
|
}
|
|
@ -26,25 +26,37 @@ namespace Sapphire::World::Manager
|
||||||
Sapphire::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
Sapphire::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
||||||
Sapphire::LandPtr getLandByOwnerId( uint32_t id );
|
Sapphire::LandPtr getLandByOwnerId( uint32_t id );
|
||||||
|
|
||||||
void sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
void sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident );
|
||||||
void sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
void sendLandSignFree( Entity::Player& player, const Common::LandIdent ident );
|
||||||
LandPurchaseResult purchaseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
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 );
|
void sendWardLandInfo( Entity::Player& player, uint8_t wardId, uint16_t territoryTypeId );
|
||||||
|
|
||||||
bool relinquishLand( Entity::Player& player, uint8_t plot );
|
bool relinquishLand( Entity::Player& player, uint8_t plot );
|
||||||
|
|
||||||
void buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetItem );
|
void buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetItem );
|
||||||
|
|
||||||
void requestEstateRename( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId );
|
void requestEstateRename( Entity::Player& player, const Common::LandIdent ident );
|
||||||
|
|
||||||
void requestEstateEditGreeting( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId );
|
void requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident );
|
||||||
void updateEstateGreeting( Entity::Player& player, const Common::LandIdent& ident, const std::string& greeting );
|
void updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting );
|
||||||
|
|
||||||
void requestEstateEditGuestAccess( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId );
|
void requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident );
|
||||||
|
|
||||||
void sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident );
|
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 );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,22 +325,20 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestLandSignFree:
|
case ClientTriggerType::RequestLandSignFree:
|
||||||
{
|
{
|
||||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
|
||||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
|
||||||
auto territoryId = static_cast< uint16_t >( param11 & 0xFFFF );
|
|
||||||
|
|
||||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||||
pHousingMgr->sendLandSignFree( player, ward, plot, territoryId );
|
|
||||||
|
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||||
|
pHousingMgr->sendLandSignFree( player, ident );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestLandSignOwned:
|
case ClientTriggerType::RequestLandSignOwned:
|
||||||
{
|
{
|
||||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
|
||||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
|
||||||
auto territoryId = static_cast< uint16_t >( param11 & 0xFFFF );
|
|
||||||
|
|
||||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||||
pHousingMgr->sendLandSignOwned( player, ward, plot, territoryId );
|
|
||||||
|
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||||
|
pHousingMgr->sendLandSignOwned( player, ident );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestWardLandInfo:
|
case ClientTriggerType::RequestWardLandInfo:
|
||||||
|
@ -363,49 +361,34 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestEstateRename:
|
case ClientTriggerType::RequestEstateRename:
|
||||||
{
|
{
|
||||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
|
||||||
uint16_t worldId = param11 >> 16;
|
|
||||||
|
|
||||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
|
||||||
uint8_t plot = ( param12 & 0xFF );
|
|
||||||
|
|
||||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||||
if( !pHousingMgr )
|
if( !pHousingMgr )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pHousingMgr->requestEstateRename( player, territoryTypeId, worldId, ward, plot );
|
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||||
|
pHousingMgr->requestEstateRename( player, ident );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestEstateEditGreeting:
|
case ClientTriggerType::RequestEstateEditGreeting:
|
||||||
{
|
{
|
||||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
|
||||||
uint16_t worldId = param11 >> 16;
|
|
||||||
|
|
||||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
|
||||||
uint8_t plot = ( param12 & 0xFF );
|
|
||||||
|
|
||||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||||
if( !pHousingMgr )
|
if( !pHousingMgr )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pHousingMgr->requestEstateEditGreeting( player, territoryTypeId, worldId, ward, plot );
|
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||||
|
pHousingMgr->requestEstateEditGreeting( player, ident );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestEstateEditGuestAccessSettings:
|
case ClientTriggerType::RequestEstateEditGuestAccessSettings:
|
||||||
{
|
{
|
||||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
|
||||||
uint16_t worldId = param11 >> 16;
|
|
||||||
|
|
||||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
|
||||||
uint8_t plot = ( param12 & 0xFF );
|
|
||||||
|
|
||||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||||
if( !pHousingMgr )
|
if( !pHousingMgr )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pHousingMgr->requestEstateEditGuestAccess( player, territoryTypeId, worldId, ward, plot );
|
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||||
|
pHousingMgr->requestEstateEditGuestAccess( player, ident );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -429,23 +412,41 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestEstateGreeting:
|
case ClientTriggerType::RequestEstateGreeting:
|
||||||
{
|
{
|
||||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
auto housingMgr = g_fw.get< HousingMgr >();
|
||||||
uint16_t worldId = param11 >> 16;
|
if( !housingMgr )
|
||||||
|
break;
|
||||||
|
|
||||||
|
auto ident = housingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||||
|
housingMgr->sendEstateGreeting( player, ident );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ClientTriggerType::RequestLandInventory:
|
||||||
|
{
|
||||||
|
if( param2 != 1 )
|
||||||
|
return;
|
||||||
|
|
||||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
|
||||||
uint8_t plot = ( param12 & 0xFF );
|
uint8_t plot = ( param12 & 0xFF );
|
||||||
|
|
||||||
auto housingMgr = g_fw.get< HousingMgr >();
|
auto housingMgr = g_fw.get< HousingMgr >();
|
||||||
if( !housingMgr )
|
if( !housingMgr )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Common::LandIdent ident;
|
housingMgr->sendHousingInventory( player, Common::InventoryType::HousingOutdoorItemStoreroom, plot );
|
||||||
ident.territoryTypeId = territoryTypeId;
|
|
||||||
ident.worldId = worldId;
|
|
||||||
ident.wardNum = ward;
|
|
||||||
ident.landId = plot;
|
|
||||||
|
|
||||||
housingMgr->sendEstateGreeting( player, ident );
|
break;
|
||||||
|
}
|
||||||
|
case ClientTriggerType::RequestEstateInventory:
|
||||||
|
{
|
||||||
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ void Housing::HousingInteriorTerritory::onPlayerZoneIn( Entity::Player& player )
|
||||||
|
|
||||||
for( auto i = 0; i < 10; i++ )
|
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 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,3 +103,8 @@ uint32_t Housing::HousingInteriorTerritory::getLastActivityTime() const
|
||||||
{
|
{
|
||||||
return m_lastActivityTime;
|
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;
|
uint32_t getLastActivityTime() const;
|
||||||
|
|
||||||
|
const Common::LandIdent getIdent() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::LandIdent m_landIdent;
|
Common::LandIdent m_landIdent;
|
||||||
uint32_t m_lastActivityTime;
|
uint32_t m_lastActivityTime;
|
||||||
|
|
|
@ -69,8 +69,7 @@ bool Sapphire::HousingZone::init()
|
||||||
|
|
||||||
if( auto house = pLand->getHouse() )
|
if( auto house = pLand->getHouse() )
|
||||||
{
|
{
|
||||||
auto eobj = registerEObj( "entrance", 2002737, 0, 4, pLand->getMapMarkerPosition(), 1.f, 0.f );
|
registerHouseEntranceEObj( landId << 8 );
|
||||||
eobj->setHousingLink( landId << 8 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,3 +230,17 @@ Sapphire::LandPtr Sapphire::HousingZone::getLand( uint8_t id )
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sapphire::Entity::EventObjectPtr Sapphire::HousingZone::registerHouseEntranceEObj( uint8_t plotId )
|
||||||
|
{
|
||||||
|
auto land = getLand( plotId );
|
||||||
|
assert( land );
|
||||||
|
|
||||||
|
auto eObj = Entity::make_EventObject( getNextEObjId(), 2002737, 0, 4, land->getMapMarkerPosition(), 0.f, "entrance" );
|
||||||
|
eObj->setHousingLink( plotId << 8 );
|
||||||
|
eObj->setScale( 1.f );
|
||||||
|
|
||||||
|
registerEObj( eObj );
|
||||||
|
|
||||||
|
return eObj;
|
||||||
|
}
|
|
@ -50,6 +50,8 @@ namespace Sapphire
|
||||||
uint32_t getLandSetId() const;
|
uint32_t getLandSetId() const;
|
||||||
Sapphire::LandPtr getLand( uint8_t id );
|
Sapphire::LandPtr getLand( uint8_t id );
|
||||||
|
|
||||||
|
Entity::EventObjectPtr registerHouseEntranceEObj( uint8_t plotId );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using LandPtrMap = std::unordered_map< uint8_t, Sapphire::LandPtr >;
|
using LandPtrMap = std::unordered_map< uint8_t, Sapphire::LandPtr >;
|
||||||
const uint32_t m_landSetMax = 18;
|
const uint32_t m_landSetMax = 18;
|
||||||
|
|
|
@ -355,3 +355,12 @@ bool Sapphire::Land::setPreset( uint32_t itemId )
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sapphire::ItemContainerPtr Sapphire::Land::getItemContainer( 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 );
|
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId, Sapphire::Data::HousingLandSetPtr info );
|
||||||
virtual ~Land();
|
virtual ~Land();
|
||||||
|
|
||||||
using LandInventoryMap = std::unordered_map< uint32_t, ItemContainerPtr >;
|
using LandInventoryMap = std::unordered_map< uint16_t, ItemContainerPtr >;
|
||||||
|
|
||||||
//Primary state
|
//Primary state
|
||||||
void setSize( uint8_t size );
|
void setSize( uint8_t size );
|
||||||
|
@ -61,6 +61,8 @@ namespace Sapphire
|
||||||
void setLandTag( uint8_t slot, uint8_t tag );
|
void setLandTag( uint8_t slot, uint8_t tag );
|
||||||
uint8_t getLandTag( uint8_t slot );
|
uint8_t getLandTag( uint8_t slot );
|
||||||
|
|
||||||
|
ItemContainerPtr getItemContainer( uint16_t inventoryType ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t convertItemIdToHousingItemId( uint32_t itemId );
|
uint32_t convertItemIdToHousingItemId( uint32_t itemId );
|
||||||
void init();
|
void init();
|
||||||
|
|
Loading…
Add table
Reference in a new issue