mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
some housing cleanup and refactoring
This commit is contained in:
parent
b7fcf6080c
commit
a04d01be90
6 changed files with 30 additions and 30 deletions
|
@ -866,13 +866,13 @@ namespace Sapphire::Common
|
|||
Mansion
|
||||
};
|
||||
|
||||
enum HouseState : uint8_t
|
||||
enum HouseStatus : uint8_t
|
||||
{
|
||||
none,
|
||||
forSale,
|
||||
sold,
|
||||
privateHouse,
|
||||
fcHouse,
|
||||
HouseForSale,
|
||||
HouseSold,
|
||||
HousePrivateEstate,
|
||||
HouseFreeCompanyEstate,
|
||||
};
|
||||
|
||||
enum HouseIconAdd : uint8_t
|
||||
|
|
|
@ -179,8 +179,8 @@ void Sapphire::World::Manager::HousingMgr::initLandCache()
|
|||
entry.m_landId = res->getUInt( "LandId" );
|
||||
|
||||
entry.m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) );
|
||||
entry.m_size = res->getUInt8( "Size" );
|
||||
entry.m_status = res->getUInt8( "Status" );
|
||||
entry.m_size = static_cast< Common::HouseSize >( res->getUInt8( "Size" ) );
|
||||
entry.m_status = static_cast< Common::HouseStatus >( res->getUInt8( "Status" ) );
|
||||
entry.m_currentPrice = res->getUInt64( "LandPrice" );
|
||||
entry.m_updateTime = res->getUInt64( "UpdateTime" );
|
||||
entry.m_ownerId = res->getUInt64( "OwnerId" );
|
||||
|
@ -365,7 +365,7 @@ Sapphire::LandPurchaseResult Sapphire::World::Manager::HousingMgr::purchaseLand(
|
|||
if( !pLand )
|
||||
return LandPurchaseResult::ERR_INTERNAL;
|
||||
|
||||
if( pLand->getState() != HouseState::forSale )
|
||||
if( pLand->getStatus() != HouseStatus::HouseForSale )
|
||||
return LandPurchaseResult::ERR_NOT_AVAILABLE;
|
||||
|
||||
if( gilAvailable < plotPrice )
|
||||
|
@ -388,7 +388,7 @@ Sapphire::LandPurchaseResult Sapphire::World::Manager::HousingMgr::purchaseLand(
|
|||
|
||||
player.removeCurrency( CurrencyType::Gil, plotPrice );
|
||||
pLand->setOwnerId( player.getId() );
|
||||
pLand->setState( HouseState::sold );
|
||||
pLand->setStatus( HouseStatus::HouseSold );
|
||||
pLand->setLandType( Common::LandType::Private );
|
||||
|
||||
player.setLandFlags( LandFlagsSlot::Private, 0x00, pLand->getLandIdent() );
|
||||
|
@ -437,7 +437,7 @@ bool Sapphire::World::Manager::HousingMgr::relinquishLand( Entity::Player& playe
|
|||
|
||||
pLand->setCurrentPrice( pLand->getMaxPrice() );
|
||||
pLand->setOwnerId( 0 );
|
||||
pLand->setState( HouseState::forSale );
|
||||
pLand->setStatus( HouseStatus::HouseForSale );
|
||||
pLand->setLandType( Common::LandType::none );
|
||||
pLand->updateLandDb();
|
||||
|
||||
|
@ -477,11 +477,11 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla
|
|||
|
||||
auto& entry = wardInfoPacket->data().houseInfoEntry[ i ];
|
||||
|
||||
// retail always sends the house price in this packet, even after the house has been sold
|
||||
// retail always sends the house price in this packet, even after the house has been HouseSold
|
||||
// so I guess we do the same
|
||||
entry.housePrice = land->getCurrentPrice();
|
||||
|
||||
if( land->getState() == Common::HouseState::forSale )
|
||||
if( land->getStatus() == Common::HouseStatus::HouseForSale )
|
||||
continue;
|
||||
|
||||
if( auto house = land->getHouse() )
|
||||
|
@ -682,7 +682,7 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl
|
|||
|
||||
createHouse( house );
|
||||
|
||||
pLand->setState( HouseState::privateHouse );
|
||||
pLand->setStatus( HouseStatus::HousePrivateEstate );
|
||||
pLand->setLandType( LandType::Private );
|
||||
hZone->sendLandUpdate( plotNum );
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace Sapphire::World::Manager
|
|||
uint16_t m_landId;
|
||||
|
||||
Common::LandType m_type;
|
||||
uint8_t m_size;
|
||||
uint8_t m_status;
|
||||
Common::HouseSize m_size;
|
||||
Common::HouseStatus m_status;
|
||||
|
||||
uint64_t m_currentPrice;
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ void Sapphire::HousingZone::sendLandSet( Entity::Player& player )
|
|||
auto& landData = landsetInitializePacket->data().land[ count ];
|
||||
|
||||
landData.plotSize = pLand->getSize();
|
||||
landData.houseState = pLand->getState();
|
||||
landData.houseState = pLand->getStatus();
|
||||
landData.iconAddIcon = pLand->getSharing();
|
||||
landData.fcId = pLand->getFcId();
|
||||
landData.fcIcon = pLand->getFcIcon();
|
||||
|
@ -256,7 +256,7 @@ void Sapphire::HousingZone::sendLandUpdate( uint8_t landId )
|
|||
auto& landData = landUpdatePacket->data().land;
|
||||
|
||||
landData.plotSize = pLand->getSize();
|
||||
landData.houseState = pLand->getState();
|
||||
landData.houseState = pLand->getStatus();
|
||||
landData.iconAddIcon = pLand->getSharing();
|
||||
landData.fcId = pLand->getFcId();
|
||||
landData.fcIcon = pLand->getFcIcon();
|
||||
|
|
|
@ -54,7 +54,7 @@ Sapphire::Land::Land( uint16_t territoryTypeId, uint8_t wardNum, uint8_t landId,
|
|||
|
||||
Sapphire::Land::~Land() = default;
|
||||
|
||||
void Sapphire::Land::init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice,
|
||||
void Sapphire::Land::init( Common::LandType type, Common::HouseSize size, Common::HouseStatus state, uint32_t currentPrice,
|
||||
uint64_t ownerId, uint64_t houseId )
|
||||
{
|
||||
m_type = type;
|
||||
|
@ -84,12 +84,12 @@ uint32_t Sapphire::Land::getMaxPrice() const
|
|||
}
|
||||
|
||||
//Primary State
|
||||
void Sapphire::Land::setSize( uint8_t size )
|
||||
void Sapphire::Land::setSize( Common::HouseSize size )
|
||||
{
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
void Sapphire::Land::setState( uint8_t state )
|
||||
void Sapphire::Land::setStatus( Common::HouseStatus state )
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
|
@ -104,12 +104,12 @@ void Sapphire::Land::setLandType( Common::LandType type )
|
|||
m_type = type;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Land::getSize() const
|
||||
Sapphire::Common::HouseSize Sapphire::Land::getSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Land::getState() const
|
||||
Sapphire::Common::HouseStatus Sapphire::Land::getStatus() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ void Sapphire::Land::updateLandDb()
|
|||
|
||||
void Sapphire::Land::update( uint32_t currTime )
|
||||
{
|
||||
if( getState() == HouseState::forSale )
|
||||
if( getStatus() == HouseStatus::HouseForSale )
|
||||
{
|
||||
if( m_nextDrop < currTime && m_minPrice < m_currentPrice )
|
||||
{
|
||||
|
|
|
@ -18,20 +18,20 @@ namespace Sapphire
|
|||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId,
|
||||
Sapphire::Data::HousingLandSetPtr info, FrameworkPtr pFw );
|
||||
virtual ~Land();
|
||||
void init( Common::LandType type, uint8_t size, uint8_t state, uint32_t currentPrice, uint64_t ownerId, uint64_t houseId );
|
||||
void init( Common::LandType type, Common::HouseSize size, Common::HouseStatus state, uint32_t currentPrice, uint64_t ownerId, uint64_t houseId );
|
||||
|
||||
using LandInventoryMap = std::unordered_map< uint16_t, ItemContainerPtr >;
|
||||
using InvMaxItemsPair = std::pair< uint16_t, uint16_t >;
|
||||
|
||||
//Primary state
|
||||
void setSize( uint8_t size );
|
||||
void setState( uint8_t state );
|
||||
void setSize( Common::HouseSize size );
|
||||
void setStatus( Common::HouseStatus state );
|
||||
void setSharing( uint8_t state );
|
||||
void setLandType( Common::LandType type );
|
||||
|
||||
//Gerneral
|
||||
uint8_t getSize() const;
|
||||
uint8_t getState() const;
|
||||
Common::HouseSize getSize() const;
|
||||
Common::HouseStatus getStatus() const;
|
||||
uint8_t getSharing() const;
|
||||
uint32_t getLandSetId() const;
|
||||
Common::LandType getLandType() const;
|
||||
|
@ -71,8 +71,8 @@ namespace Sapphire
|
|||
Common::LandIdent m_landIdent;
|
||||
|
||||
uint32_t m_landSetId;
|
||||
uint8_t m_size;
|
||||
uint8_t m_state;
|
||||
Common::HouseSize m_size;
|
||||
Common::HouseStatus m_state;
|
||||
Common::LandType m_type;
|
||||
uint8_t m_iconAddIcon;
|
||||
uint32_t m_fcId; // unclear, may be wrong
|
||||
|
|
Loading…
Add table
Reference in a new issue