From 7164ca3ddd3ef8a2e2d5dc92ec7cd7ca437ab1d2 Mon Sep 17 00:00:00 2001 From: Mordred Date: Sat, 17 Nov 2018 01:16:44 +0100 Subject: [PATCH] Basic land relinquishing added --- .../Scripts/common/CmnDefHousingSignboard.cpp | 3 +-- .../Network/Handlers/ClientTriggerHandler.cpp | 4 +-- src/servers/sapphire_zone/Zone/HousingMgr.cpp | 27 +++++++++++++++++++ src/servers/sapphire_zone/Zone/HousingMgr.h | 2 ++ src/servers/sapphire_zone/Zone/Land.cpp | 11 ++++++++ src/servers/sapphire_zone/Zone/Land.h | 3 +++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp index 5e5e13d9..4fa2d53f 100644 --- a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp +++ b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp @@ -38,7 +38,7 @@ public: auto pHouMgr = pFw->get< Core::HousingMgr >(); LandPurchaseResult res = pHouMgr->purchseLand( player, activeLand.plot, - static_cast< uint8_t >( result.param2 ) ); + static_cast< uint8_t >( result.param2 ) ); switch( res ) { @@ -73,7 +73,6 @@ public: break; } - case LandPurchaseResult::ERR_INTERNAL: { auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 1995 ); diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index 74a1cbc6..aed5e18b 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -346,12 +346,10 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR } case ClientTriggerType::RequestLandRelinquish: { - auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 ); auto plot = static_cast< uint8_t >( param12 & 0xFF ); auto pHousingMgr = g_fw.get< HousingMgr >(); + pHousingMgr->relinquishLand( player, plot ); - pLog->debug( "Request to relinquish plot " + std::to_string( plot ) ); - // TODO: do stuff! break; } case ClientTriggerType::RequestEstateRename: diff --git a/src/servers/sapphire_zone/Zone/HousingMgr.cpp b/src/servers/sapphire_zone/Zone/HousingMgr.cpp index f698c8b3..d4521106 100644 --- a/src/servers/sapphire_zone/Zone/HousingMgr.cpp +++ b/src/servers/sapphire_zone/Zone/HousingMgr.cpp @@ -205,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; +} + diff --git a/src/servers/sapphire_zone/Zone/HousingMgr.h b/src/servers/sapphire_zone/Zone/HousingMgr.h index 39537767..156fd18c 100644 --- a/src/servers/sapphire_zone/Zone/HousingMgr.h +++ b/src/servers/sapphire_zone/Zone/HousingMgr.h @@ -33,6 +33,8 @@ namespace Core 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 ); + bool relinquishLand( Entity::Player& player, uint8_t plot ); + private: using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >; uint16_t m_lastLandId; diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index 1b263e8f..62e8242f 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -74,6 +74,7 @@ void Core::Land::load() m_currentPrice = res->getUInt( "LandPrice" ); m_ownerPlayerId = res->getUInt( "OwnerId" ); m_minPrice = m_landInfo->minPrices[ m_landId ]; + m_maxPrice = m_landInfo->prices[ m_landId ]; } init(); } @@ -90,6 +91,11 @@ uint32_t Core::Land::getCurrentPrice() const return m_currentPrice; } +uint32_t Core::Land::getMaxPrice() const +{ + return m_maxPrice; +} + //Primary State 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() ); } +void Core::Land::setCurrentPrice( uint32_t currentPrice ) +{ + m_currentPrice = currentPrice; +} + void Core::Land::setLandTag( uint8_t slot, uint8_t tag ) { m_tag[ slot ] = tag; diff --git a/src/servers/sapphire_zone/Zone/Land.h b/src/servers/sapphire_zone/Zone/Land.h index 5522255b..95f4b6ce 100644 --- a/src/servers/sapphire_zone/Zone/Land.h +++ b/src/servers/sapphire_zone/Zone/Land.h @@ -46,12 +46,14 @@ namespace Core void setPlayerOwner( uint32_t id ); uint32_t getPlayerOwner(); //Housing Functions + void setCurrentPrice( uint32_t currentPrice ); void setPreset( uint32_t itemId ); void updateLandDb(); void update( uint32_t currTime ); uint32_t getMaxItems(); uint32_t getCurrentPrice() const; + uint32_t getMaxPrice() const; uint32_t getDevaluationTime(); //House tags @@ -86,6 +88,7 @@ namespace Core uint32_t m_nextDrop; uint32_t m_currentPrice; uint32_t m_minPrice; + uint32_t m_maxPrice; //information char fcTag[7];