mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
commit
282e6acbfc
6 changed files with 71 additions and 21 deletions
|
@ -35,10 +35,10 @@ public:
|
||||||
|
|
||||||
auto pTerritory = player.getCurrentZone();
|
auto pTerritory = player.getCurrentZone();
|
||||||
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pTerritory );
|
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pTerritory );
|
||||||
auto pHouMgr = pFw->get< Core::HousingMgr >();
|
auto pHouMgr = pFw->get< Core::HousingMgr >();
|
||||||
|
|
||||||
LandPurchaseResult res = pHouMgr->purchseLand( player, activeLand.plot,
|
LandPurchaseResult res = pHouMgr->purchseLand( player, activeLand.plot,
|
||||||
static_cast< uint8_t >( result.param2 ) );
|
static_cast< uint8_t >( result.param2 ) );
|
||||||
|
|
||||||
switch( res )
|
switch( res )
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,6 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case LandPurchaseResult::ERR_INTERNAL:
|
case LandPurchaseResult::ERR_INTERNAL:
|
||||||
{
|
{
|
||||||
auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 1995 );
|
auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 1995 );
|
||||||
|
|
|
@ -328,25 +328,28 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
|
||||||
{
|
{
|
||||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
||||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
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 );
|
pHousingMgr->sendLandSignFree( player, ward, plot, territoryId );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestLandSignOwned:
|
case ClientTriggerType::RequestLandSignOwned:
|
||||||
{
|
{
|
||||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
||||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
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 );
|
pHousingMgr->sendLandSignOwned( player, ward, plot, territoryId );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestLandRelinquish:
|
case ClientTriggerType::RequestLandRelinquish:
|
||||||
{
|
{
|
||||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
|
||||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
||||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||||
pLog->debug( "Request to relinquish plot " + std::to_string( plot ) );
|
pHousingMgr->relinquishLand( player, plot );
|
||||||
// TODO: do stuff!
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::RequestEstateRename:
|
case ClientTriggerType::RequestEstateRename:
|
||||||
|
|
|
@ -48,6 +48,11 @@ uint16_t Core::HousingMgr::getNexLandId()
|
||||||
return ++m_lastLandId;
|
return ++m_lastLandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Core::HousingMgr::toLandSetId( uint16_t territoryTypeId, uint8_t wardId ) const
|
||||||
|
{
|
||||||
|
return ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardId;
|
||||||
|
}
|
||||||
|
|
||||||
void Core::HousingMgr::insertHousingZone( Core::Data::HousingZonePtr hZone )
|
void Core::HousingMgr::insertHousingZone( Core::Data::HousingZonePtr hZone )
|
||||||
{
|
{
|
||||||
uint16_t id = getNexLandId();
|
uint16_t id = getNexLandId();
|
||||||
|
@ -95,18 +100,17 @@ Core::LandPtr Core::HousingMgr::getLandByOwnerId( uint32_t id )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t ward, uint8_t plot )
|
void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
||||||
{
|
{
|
||||||
player.setActiveLand( plot, ward );
|
player.setActiveLand( plotId, wardId );
|
||||||
|
|
||||||
auto zone = player.getCurrentZone();
|
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||||
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
|
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plot );
|
auto land = hZone->getLand( plotId );
|
||||||
if( !land )
|
if( !land )
|
||||||
{
|
{
|
||||||
land = getLandByOwnerId( player.getId() );
|
land = getLandByOwnerId( player.getId() );
|
||||||
|
@ -128,17 +132,17 @@ void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t ward,
|
||||||
player.queuePacket( landInfoSignPacket );
|
player.queuePacket( landInfoSignPacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t ward, uint8_t plot )
|
void Core::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
||||||
{
|
{
|
||||||
player.setActiveLand( plot, ward );
|
player.setActiveLand( plotId, wardId );
|
||||||
|
|
||||||
auto zone = player.getCurrentZone();
|
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||||
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
|
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||||
|
|
||||||
if( !hZone )
|
if( !hZone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto land = hZone->getLand( plot );
|
auto land = hZone->getLand( plotId );
|
||||||
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();
|
||||||
|
@ -201,3 +205,30 @@ Core::LandPurchaseResult Core::HousingMgr::purchseLand( Entity::Player& player,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Core::HousingMgr::relinquishLand( Entity::Player& player, uint8_t plot )
|
||||||
|
{
|
||||||
|
// TODO: Fix "permissions" being sent incorrectly
|
||||||
|
// TODO: Add checks for land state before relinquishing
|
||||||
|
auto pHousing = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
|
||||||
|
|
||||||
|
auto pLand = pHousing->getLand( plot );
|
||||||
|
auto plotMaxPrice = pLand->getCurrentPrice();
|
||||||
|
|
||||||
|
pLand->setCurrentPrice( pLand->getMaxPrice() );
|
||||||
|
pLand->setPlayerOwner( 0 );
|
||||||
|
pLand->setState( HouseState::forSale );
|
||||||
|
pLand->setLandType( Common::LandType::none );
|
||||||
|
pLand->updateLandDb();
|
||||||
|
|
||||||
|
player.setLandPermissions( LandPermissionSlot::Private, 0x00, 0xFF, 0xFF, 0xFF );
|
||||||
|
|
||||||
|
player.sendLandPermissionSlot( static_cast< uint8_t >( LandType::Private ), 0xFF, 0xFF, 0xFF );
|
||||||
|
|
||||||
|
auto screenMsgPkt2 = makeActorControl143( player.getId(), ActorControl::LogMsg, 3351, 0x1AA,
|
||||||
|
pLand->getWardNum() + 1, plot + 1 );
|
||||||
|
player.queuePacket( screenMsgPkt2 );
|
||||||
|
pHousing->sendLandUpdate( plot );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,19 @@ namespace Core
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
|
uint32_t toLandSetId( uint16_t territoryTypeId, uint8_t wardId ) const;
|
||||||
uint16_t getNexLandId();
|
uint16_t getNexLandId();
|
||||||
void insertHousingZone( Core::Data::HousingZonePtr hZone );
|
void insertHousingZone( Core::Data::HousingZonePtr hZone );
|
||||||
Core::Data::HousingZonePtr getHousingZone( uint16_t id );
|
Core::Data::HousingZonePtr getHousingZone( uint16_t id );
|
||||||
Core::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
Core::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
||||||
Core::LandPtr getLandByOwnerId( uint32_t id );
|
Core::LandPtr getLandByOwnerId( uint32_t id );
|
||||||
|
|
||||||
void sendLandSignOwned( Entity::Player& player, uint8_t ward, uint8_t plot );
|
void sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
||||||
void sendLandSignFree( Entity::Player& player, uint8_t ward, uint8_t plot );
|
void sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
||||||
LandPurchaseResult purchseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
LandPurchaseResult purchseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
||||||
|
|
||||||
|
bool relinquishLand( Entity::Player& player, uint8_t plot );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >;
|
using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >;
|
||||||
uint16_t m_lastLandId;
|
uint16_t m_lastLandId;
|
||||||
|
|
|
@ -74,6 +74,7 @@ void Core::Land::load()
|
||||||
m_currentPrice = res->getUInt( "LandPrice" );
|
m_currentPrice = res->getUInt( "LandPrice" );
|
||||||
m_ownerPlayerId = res->getUInt( "OwnerId" );
|
m_ownerPlayerId = res->getUInt( "OwnerId" );
|
||||||
m_minPrice = m_landInfo->minPrices[ m_landId ];
|
m_minPrice = m_landInfo->minPrices[ m_landId ];
|
||||||
|
m_maxPrice = m_landInfo->prices[ m_landId ];
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +91,11 @@ uint32_t Core::Land::getCurrentPrice() const
|
||||||
return m_currentPrice;
|
return m_currentPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Core::Land::getMaxPrice() const
|
||||||
|
{
|
||||||
|
return m_maxPrice;
|
||||||
|
}
|
||||||
|
|
||||||
//Primary State
|
//Primary State
|
||||||
void Core::Land::setSize( uint8_t size )
|
void Core::Land::setSize( uint8_t size )
|
||||||
{
|
{
|
||||||
|
@ -195,6 +201,11 @@ uint32_t Core::Land::getDevaluationTime()
|
||||||
return m_nextDrop - static_cast< uint32_t >( Util::getTimeSeconds() );
|
return m_nextDrop - static_cast< uint32_t >( Util::getTimeSeconds() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Land::setCurrentPrice( uint32_t currentPrice )
|
||||||
|
{
|
||||||
|
m_currentPrice = currentPrice;
|
||||||
|
}
|
||||||
|
|
||||||
void Core::Land::setLandTag( uint8_t slot, uint8_t tag )
|
void Core::Land::setLandTag( uint8_t slot, uint8_t tag )
|
||||||
{
|
{
|
||||||
m_tag[ slot ] = tag;
|
m_tag[ slot ] = tag;
|
||||||
|
|
|
@ -46,12 +46,14 @@ namespace Core
|
||||||
void setPlayerOwner( uint32_t id );
|
void setPlayerOwner( uint32_t id );
|
||||||
uint32_t getPlayerOwner();
|
uint32_t getPlayerOwner();
|
||||||
//Housing Functions
|
//Housing Functions
|
||||||
|
void setCurrentPrice( uint32_t currentPrice );
|
||||||
void setPreset( uint32_t itemId );
|
void setPreset( uint32_t itemId );
|
||||||
void updateLandDb();
|
void updateLandDb();
|
||||||
void update( uint32_t currTime );
|
void update( uint32_t currTime );
|
||||||
|
|
||||||
uint32_t getMaxItems();
|
uint32_t getMaxItems();
|
||||||
uint32_t getCurrentPrice() const;
|
uint32_t getCurrentPrice() const;
|
||||||
|
uint32_t getMaxPrice() const;
|
||||||
uint32_t getDevaluationTime();
|
uint32_t getDevaluationTime();
|
||||||
|
|
||||||
//House tags
|
//House tags
|
||||||
|
@ -86,6 +88,7 @@ namespace Core
|
||||||
uint32_t m_nextDrop;
|
uint32_t m_nextDrop;
|
||||||
uint32_t m_currentPrice;
|
uint32_t m_currentPrice;
|
||||||
uint32_t m_minPrice;
|
uint32_t m_minPrice;
|
||||||
|
uint32_t m_maxPrice;
|
||||||
|
|
||||||
//information
|
//information
|
||||||
char fcTag[7];
|
char fcTag[7];
|
||||||
|
|
Loading…
Add table
Reference in a new issue