diff --git a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp index 083ad183..0b4b41b6 100644 --- a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp +++ b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp @@ -31,30 +31,46 @@ public: auto pTerritory = player.getCurrentZone(); auto pHousing = std::dynamic_pointer_cast< HousingZone >( pTerritory ); - PurchaseResult res = pHousing->purchseLand( player, activeLand.plot, - static_cast< uint8_t >( result.param2 ) ); + LandPurchaseResult res = pHousing->purchseLand( player, activeLand.plot, + static_cast< uint8_t >( result.param2 ) ); switch( res ) { - case PurchaseResult::SUCCESS: + case LandPurchaseResult::SUCCESS: { auto screenMsgPkt = makeActorControl143( player.getId(), ActorControl::DutyQuestScreenMsg, m_id, 0x98 ); player.queuePacket( screenMsgPkt ); break; } - case PurchaseResult::ERR_NOT_ENOUGH_GIL: + case LandPurchaseResult::ERR_NOT_ENOUGH_GIL: { - auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 4027 ); + auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 3314 ); player.queuePacket( errorMsg ); break; } - case PurchaseResult::ERR_NOT_AVAILABLE: + case LandPurchaseResult::ERR_NOT_AVAILABLE: + { + auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 3312 ); + player.queuePacket( errorMsg ); break; + } - case PurchaseResult::ERR_INTERNAL: + case LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR: + { + auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 3313 ); + player.queuePacket( errorMsg ); break; + } + + + case LandPurchaseResult::ERR_INTERNAL: + { + auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 1995 ); + player.queuePacket( errorMsg ); + break; + } } } diff --git a/src/servers/sapphire_zone/Zone/HousingZone.cpp b/src/servers/sapphire_zone/Zone/HousingZone.cpp index 685cf8c9..0752622d 100644 --- a/src/servers/sapphire_zone/Zone/HousingZone.cpp +++ b/src/servers/sapphire_zone/Zone/HousingZone.cpp @@ -154,7 +154,7 @@ bool Core::HousingZone::isPlayerSubInstance( Entity::Player& player ) return player.getPos().x < -15000.0f; //ToDo: get correct pos } -Core::PurchaseResult Core::HousingZone::purchseLand( Entity::Player& player, uint8_t plot, uint8_t state ) +Core::LandPurchaseResult Core::HousingZone::purchseLand( Entity::Player& player, uint8_t plot, uint8_t state ) { auto plotPrice = getLand( plot )->getCurrentPrice(); @@ -162,23 +162,31 @@ Core::PurchaseResult Core::HousingZone::purchseLand( Entity::Player& player, uin auto pLand = getLand( plot ); if( !pLand ) - return PurchaseResult::ERR_INTERNAL; + return LandPurchaseResult::ERR_INTERNAL; if( pLand->getState() != HouseState::forSale ) - return PurchaseResult::ERR_NOT_AVAILABLE; + return LandPurchaseResult::ERR_NOT_AVAILABLE; if( gilAvailable < plotPrice ) - return PurchaseResult::ERR_NOT_ENOUGH_GIL; + return LandPurchaseResult::ERR_NOT_ENOUGH_GIL; auto pHousing = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() ); - switch( state ) + switch( static_cast< LandPurchaseMode >( state ) ) { - case 1: + case LandPurchaseMode::FC: player.sendDebug( "Free company house purchase aren't supported at this time." ); - return PurchaseResult::ERR_INTERNAL; + return LandPurchaseResult::ERR_INTERNAL; + + case LandPurchaseMode::PRIVATE: + { + + auto pHousingMgr = g_fw.get< HousingMgr >(); + auto pOldLand = pHousingMgr->getLandByOwnerId( player.getId() ); + + if( pOldLand ) + return LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR; - case 2: player.removeCurrency( CurrencyType::Gil, plotPrice ); pLand->setPlayerOwner( player.getId() ); pLand->setState( HouseState::sold ); @@ -187,10 +195,11 @@ Core::PurchaseResult Core::HousingZone::purchseLand( Entity::Player& player, uin player.sendLandPermissions(); pLand->UpdateLandDb(); sendLandUpdate( plot ); - return PurchaseResult::SUCCESS; + return LandPurchaseResult::SUCCESS; + } default: - return PurchaseResult::ERR_INTERNAL; + return LandPurchaseResult::ERR_INTERNAL; } } diff --git a/src/servers/sapphire_zone/Zone/HousingZone.h b/src/servers/sapphire_zone/Zone/HousingZone.h index a93be9d2..ef321b98 100644 --- a/src/servers/sapphire_zone/Zone/HousingZone.h +++ b/src/servers/sapphire_zone/Zone/HousingZone.h @@ -6,14 +6,22 @@ namespace Core { - enum class PurchaseResult + enum class LandPurchaseResult { SUCCESS, ERR_NOT_ENOUGH_GIL, ERR_NOT_AVAILABLE, + ERR_NO_MORE_LANDS_FOR_CHAR, ERR_INTERNAL, }; + enum class LandPurchaseMode + { + FC = 1, + PRIVATE = 2, + RELOCATE = 4, + }; + class HousingZone : public Zone { public: @@ -34,7 +42,7 @@ namespace Core void sendLandUpdate( uint8_t landId ); bool isPlayerSubInstance( Entity::Player& player ); - PurchaseResult purchseLand( Entity::Player& player, uint8_t plot, uint8_t state ); + LandPurchaseResult purchseLand( Entity::Player& player, uint8_t plot, uint8_t state ); /* returns current ward number for this zone */ uint8_t getWardNum() const;