mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
commit
93ee3d1e27
8 changed files with 70 additions and 23 deletions
|
@ -184,7 +184,7 @@ enum ActorControlType :
|
||||||
|
|
||||||
AchievementPopup = 0x203,
|
AchievementPopup = 0x203,
|
||||||
|
|
||||||
Unk7 = 0x205, // LogMessage?
|
LogMsg = 0x205, // LogMessage?
|
||||||
AchievementMsg = 0x206,
|
AchievementMsg = 0x206,
|
||||||
|
|
||||||
SetItemLevel = 0x209,
|
SetItemLevel = 0x209,
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include <Actor/Player.h>
|
#include <Actor/Player.h>
|
||||||
#include <Zone/Zone.h>
|
#include <Zone/Zone.h>
|
||||||
#include <Zone/HousingZone.h>
|
#include <Zone/HousingZone.h>
|
||||||
|
#include <Network/PacketWrappers/ActorControlPacket143.h>
|
||||||
|
#include <Network/CommonActorControl.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
@ -25,7 +28,27 @@ 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 );
|
||||||
|
|
||||||
pHousing->playerPurchseLand( player, activeLand.plot, result.param2 );
|
PurchaseResult res = pHousing->purchseLand( player, activeLand.plot,
|
||||||
|
static_cast< uint8_t >( result.param2 ) );
|
||||||
|
|
||||||
|
|
||||||
|
switch( res )
|
||||||
|
{
|
||||||
|
case PurchaseResult::SUCCESS:
|
||||||
|
{
|
||||||
|
auto screenMsgPkt = Network::Packets::Server::makeActorControl143( player.getId(),
|
||||||
|
Network::ActorControl::DutyQuestScreenMsg,
|
||||||
|
m_id, 0x98 );
|
||||||
|
player.queuePacket( screenMsgPkt );
|
||||||
|
}
|
||||||
|
case PurchaseResult::ERR_NOT_ENOUGH_GIL:
|
||||||
|
{
|
||||||
|
auto errorMsg = Network::Packets::Server::makeActorControl143( player.getId(),
|
||||||
|
Network::ActorControl::LogMsg,
|
||||||
|
4027 );
|
||||||
|
player.queuePacket( errorMsg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -106,7 +106,7 @@ Core::Entity::Player::~Player()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::injectPacket( std::string path )
|
void Core::Entity::Player::injectPacket( const std::string& path )
|
||||||
{
|
{
|
||||||
auto pServerZone = g_fw.get< ServerZone >();
|
auto pServerZone = g_fw.get< ServerZone >();
|
||||||
auto session = pServerZone->getSession( getId() );
|
auto session = pServerZone->getSession( getId() );
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace Core::Entity
|
||||||
|
|
||||||
void autoAttack( CharaPtr pTarget ) override;
|
void autoAttack( CharaPtr pTarget ) override;
|
||||||
|
|
||||||
void injectPacket( std::string path );
|
void injectPacket( const std::string& path );
|
||||||
|
|
||||||
// EventHandlers
|
// EventHandlers
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -58,7 +58,7 @@ Core::LandPtr Core::HousingMgr::getLandByOwnerId( uint32_t id )
|
||||||
for( const auto& hZoneIt : m_housingZonePtrMap )
|
for( const auto& hZoneIt : m_housingZonePtrMap )
|
||||||
{
|
{
|
||||||
auto pHousingZone = hZoneIt.second;
|
auto pHousingZone = hZoneIt.second;
|
||||||
for( uint8_t landId = 0;landId < 60;landId++ )
|
for( uint8_t landId = 0; landId < 60; landId++ )
|
||||||
{
|
{
|
||||||
if( pHousingZone->getLand( landId )->getPlayerOwner() == id )
|
if( pHousingZone->getLand( landId )->getPlayerOwner() == id )
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,29 +154,45 @@ bool Core::HousingZone::isPlayerSubInstance( Entity::Player& player )
|
||||||
return player.getPos().x < -15000.0f; //ToDo: get correct pos
|
return player.getPos().x < -15000.0f; //ToDo: get correct pos
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::HousingZone::playerPurchseLand( Entity::Player & player, uint8_t plot, uint8_t state )
|
Core::PurchaseResult Core::HousingZone::purchseLand( Entity::Player& player, uint8_t plot, uint8_t state )
|
||||||
{
|
{
|
||||||
uint32_t plotPrice = getLand( plot )->getCurrentPrice();
|
|
||||||
if( plotPrice <= player.getCurrency( CurrencyType::Gil ) )
|
auto plotPrice = getLand( plot )->getCurrentPrice();
|
||||||
{
|
auto gilAvailable = player.getCurrency( CurrencyType::Gil );
|
||||||
|
auto pLand = getLand( plot );
|
||||||
|
|
||||||
|
if( !pLand )
|
||||||
|
return PurchaseResult::ERR_INTERNAL;
|
||||||
|
|
||||||
|
if( pLand->getState() != HouseState::forSale )
|
||||||
|
return PurchaseResult::ERR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
if( gilAvailable < plotPrice )
|
||||||
|
return PurchaseResult::ERR_NOT_ENOUGH_GIL;
|
||||||
|
|
||||||
auto pHousing = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
|
auto pHousing = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
|
||||||
if( state == 1 ) //TODO: add Free company purchase
|
|
||||||
player.sendDebug( "Free company house purchase aren't supported at this time." );
|
switch( state )
|
||||||
if( state == 2 ) //Private Purchase
|
|
||||||
{
|
{
|
||||||
getLand( plot )->setPlayerOwner( player.getId() );
|
case 1:
|
||||||
getLand( plot )->setState( HouseState::sold );
|
player.sendDebug( "Free company house purchase aren't supported at this time." );
|
||||||
|
return PurchaseResult::ERR_INTERNAL;
|
||||||
|
|
||||||
|
case 2:
|
||||||
player.removeCurrency( CurrencyType::Gil, plotPrice );
|
player.removeCurrency( CurrencyType::Gil, plotPrice );
|
||||||
player.setLandPermissions( LandPermissionSlot::Private, 0x0B, plot, pHousing->getWardNum(), pHousing->getTerritoryTypeId() );
|
pLand->setPlayerOwner( player.getId() );
|
||||||
|
pLand->setState( HouseState::sold );
|
||||||
|
player.setLandPermissions( LandPermissionSlot::Private, 0x0B, plot,
|
||||||
|
pHousing->getWardNum(), pHousing->getTerritoryTypeId() );
|
||||||
player.sendLandPermissions();
|
player.sendLandPermissions();
|
||||||
|
pLand->UpdateLandDb();
|
||||||
getLand( plot )->UpdateLandDb();
|
|
||||||
sendLandUpdate( plot );
|
sendLandUpdate( plot );
|
||||||
|
return PurchaseResult::SUCCESS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return PurchaseResult::ERR_INTERNAL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//else
|
|
||||||
//TOD: add error msg - insufficient gil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::HousingZone::onUpdate( uint32_t currTime )
|
void Core::HousingZone::onUpdate( uint32_t currTime )
|
||||||
|
|
|
@ -6,6 +6,14 @@
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
enum class PurchaseResult
|
||||||
|
{
|
||||||
|
SUCCESS,
|
||||||
|
ERR_NOT_ENOUGH_GIL,
|
||||||
|
ERR_NOT_AVAILABLE,
|
||||||
|
ERR_INTERNAL,
|
||||||
|
};
|
||||||
|
|
||||||
class HousingZone : public Zone
|
class HousingZone : public Zone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -26,7 +34,7 @@ namespace Core
|
||||||
void sendLandUpdate( uint8_t landId );
|
void sendLandUpdate( uint8_t landId );
|
||||||
bool isPlayerSubInstance( Entity::Player& player );
|
bool isPlayerSubInstance( Entity::Player& player );
|
||||||
|
|
||||||
void playerPurchseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
PurchaseResult purchseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
||||||
|
|
||||||
/* returns current ward number for this zone */
|
/* returns current ward number for this zone */
|
||||||
uint8_t getWardNum() const;
|
uint8_t getWardNum() const;
|
||||||
|
|
|
@ -32,7 +32,7 @@ Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t lan
|
||||||
m_landId( landId ),
|
m_landId( landId ),
|
||||||
m_currentPrice( 0 ),
|
m_currentPrice( 0 ),
|
||||||
m_minPrice( 0 ),
|
m_minPrice( 0 ),
|
||||||
m_nextDrop( Util::getTimeSeconds() + 21600 ),
|
m_nextDrop( static_cast< uint32_t >( Util::getTimeSeconds() ) + 21600 ),
|
||||||
m_ownerPlayerId( 0 ),
|
m_ownerPlayerId( 0 ),
|
||||||
m_landSetId( landSetId ),
|
m_landSetId( landSetId ),
|
||||||
m_landInfo( info )
|
m_landInfo( info )
|
||||||
|
@ -260,7 +260,7 @@ uint32_t Core::Land::getMaxItems()
|
||||||
|
|
||||||
uint32_t Core::Land::getDevaluationTime()
|
uint32_t Core::Land::getDevaluationTime()
|
||||||
{
|
{
|
||||||
return m_nextDrop - Util::getTimeSeconds();
|
return m_nextDrop - static_cast< uint32_t >( Util::getTimeSeconds() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Land::setLandTag( uint8_t slot, uint8_t tag )
|
void Core::Land::setLandTag( uint8_t slot, uint8_t tag )
|
||||||
|
|
Loading…
Add table
Reference in a new issue