mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Only allow buying one private land
This commit is contained in:
parent
ec6aa1d4d6
commit
1c3dbe6542
3 changed files with 52 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue