1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Added land type storage / loading / usage

This commit is contained in:
Mordred 2018-11-13 19:48:22 +01:00
parent a3fd364837
commit a8040d9236
6 changed files with 48 additions and 22 deletions

1
sql/update_land.sql Normal file
View file

@ -0,0 +1 @@
ALTER TABLE `land` ADD `Type` SMALLINT(6) NOT NULL DEFAULT '0' AFTER `LandId`;

View file

@ -781,6 +781,13 @@ namespace Core::Common
SharedHouse2 SharedHouse2
}; };
enum class LandType : uint8_t
{
none = 0,
FreeCompany = 1,
Private = 2,
};
struct LandPermissionSet struct LandPermissionSet
{ {
int16_t landId; //00 int16_t landId; //00

View file

@ -379,8 +379,8 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId ); std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId );
//memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 ); //memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 );
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() ); //memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
//landInfoSignPacket->data().houseSize = land->getPlotSize(); landInfoSignPacket->data().houseSize = land->getPlotSize();
landInfoSignPacket->data().houseType = 2; // we really need to save this in the plot landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
landInfoSignPacket->data().landId = land->getLandId(); landInfoSignPacket->data().landId = land->getLandId();
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId() landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() ); memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() );

View file

@ -190,6 +190,7 @@ Core::LandPurchaseResult Core::HousingZone::purchseLand( Entity::Player& player,
player.removeCurrency( CurrencyType::Gil, plotPrice ); player.removeCurrency( CurrencyType::Gil, plotPrice );
pLand->setPlayerOwner( player.getId() ); pLand->setPlayerOwner( player.getId() );
pLand->setState( HouseState::sold ); pLand->setState( HouseState::sold );
pLand->setLandType( Common::LandType::Private );
player.setLandPermissions( LandPermissionSlot::Private, 0x00, plot, player.setLandPermissions( LandPermissionSlot::Private, 0x00, plot,
pHousing->getWardNum(), pHousing->getTerritoryTypeId() ); pHousing->getWardNum(), pHousing->getTerritoryTypeId() );
player.sendLandPermissions(); player.sendLandPermissions();

View file

@ -35,7 +35,8 @@ Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t lan
m_nextDrop( static_cast< uint32_t >( 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 ),
m_type( Common::LandType::Private )
{ {
memset( &m_land, 0x00, sizeof( LandStruct ) ); memset( &m_land, 0x00, sizeof( LandStruct ) );
memset( &m_tag, 0x00, 3 ); memset( &m_tag, 0x00, 3 );
@ -57,8 +58,9 @@ void Core::Land::load()
"AND LandId = " + std::to_string( m_landId ) ); "AND LandId = " + std::to_string( m_landId ) );
if( !res->next() ) if( !res->next() )
{ {
pDb->directExecute( "INSERT INTO land ( landsetid, landid, size, status, landprice ) " pDb->directExecute( "INSERT INTO land ( landsetid, landid, type, size, status, landprice ) "
"VALUES ( " + std::to_string( m_landSetId ) + "," + std::to_string( m_landId ) + "," "VALUES ( " + std::to_string( m_landSetId ) + "," + std::to_string( m_landId ) + ","
+ std::to_string( static_cast< uint8_t >( m_type ) ) + ","
+ std::to_string( m_landInfo->sizes[ m_landId ] ) + "," + std::to_string( m_landInfo->sizes[ m_landId ] ) + ","
+ " 1, " + std::to_string( m_landInfo->prices[ m_landId ] ) + " );" ); + " 1, " + std::to_string( m_landInfo->prices[ m_landId ] ) + " );" );
@ -69,6 +71,7 @@ void Core::Land::load()
} }
else else
{ {
m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) );
m_land.plotSize = res->getUInt( "Size" ); m_land.plotSize = res->getUInt( "Size" );
m_land.houseState = res->getUInt( "Status" ); m_land.houseState = res->getUInt( "Status" );
m_currentPrice = res->getUInt( "LandPrice" ); m_currentPrice = res->getUInt( "LandPrice" );
@ -161,51 +164,61 @@ void Core::Land::setLandName( const std::string& name )
memcpy( &m_landName, name.c_str(), 20 ); memcpy( &m_landName, name.c_str(), 20 );
} }
uint8_t Core::Land::getPlotSize() void Core::Land::setLandType( Common::LandType type )
{
m_type = type;
}
uint8_t Core::Land::getPlotSize() const
{ {
return m_land.plotSize; return m_land.plotSize;
} }
uint8_t Core::Land::getState() uint8_t Core::Land::getState() const
{ {
return m_land.houseState; return m_land.houseState;
} }
uint8_t Core::Land::getOwnership() uint8_t Core::Land::getOwnership() const
{ {
return m_land.iconColor; return m_land.iconColor;
} }
uint8_t Core::Land::getSharing() uint8_t Core::Land::getSharing() const
{ {
return m_land.iconAddIcon; return m_land.iconAddIcon;
} }
uint32_t Core::Land::getLandSetId() uint32_t Core::Land::getLandSetId() const
{ {
return m_landSetId; return m_landSetId;
} }
uint8_t Core::Land::getWardNum() uint8_t Core::Land::getWardNum() const
{ {
return m_wardNum; return m_wardNum;
} }
uint8_t Core::Land::getLandId() uint8_t Core::Land::getLandId() const
{ {
return m_landId; return m_landId;
} }
uint16_t Core::Land::getZoneId() uint16_t Core::Land::getZoneId() const
{ {
return m_zoneId; return m_zoneId;
} }
std::string Core::Land::getLandName() std::string Core::Land::getLandName() const
{ {
return std::string( m_landName ); return std::string( m_landName );
} }
Core::Common::LandType Core::Land::getLandType() const
{
return m_type;
}
//Free Comapny //Free Comapny
void Core::Land::setFreeCompany( uint32_t id, uint32_t icon, uint32_t color ) void Core::Land::setFreeCompany( uint32_t id, uint32_t icon, uint32_t color )
{ {
@ -314,6 +327,7 @@ void Core::Land::UpdateLandDb()
+ ", UpdateTime = " + std::to_string( getDevaluationTime() ) + ", UpdateTime = " + std::to_string( getDevaluationTime() )
+ ", OwnerId = " + std::to_string( getPlayerOwner() ) + ", OwnerId = " + std::to_string( getPlayerOwner() )
+ ", HouseId = " + std::to_string( 0 ) //TODO: add house id + ", HouseId = " + std::to_string( 0 ) //TODO: add house id
+ ", Type = " + std::to_string( static_cast< uint32_t >( m_type ) ) //TODO: add house id
+ " WHERE LandSetId = " + std::to_string( m_landSetId ) + " WHERE LandSetId = " + std::to_string( m_landSetId )
+ " AND LandId = " + std::to_string( m_landId ) + ";" ); + " AND LandId = " + std::to_string( m_landId ) + ";" );
} }

View file

@ -26,17 +26,19 @@ namespace Core
void setOwnership( uint8_t state ); void setOwnership( uint8_t state );
void setSharing( uint8_t state ); void setSharing( uint8_t state );
void setLandName( const std::string& name ); void setLandName( const std::string& name );
void setLandType( Common::LandType type );
//Gerneral //Gerneral
uint8_t getPlotSize(); uint8_t getPlotSize() const;
uint8_t getState(); uint8_t getState() const;
uint8_t getOwnership(); uint8_t getOwnership() const;
uint8_t getSharing(); uint8_t getSharing() const;
uint32_t getLandSetId(); uint32_t getLandSetId() const;
uint8_t getWardNum(); uint8_t getWardNum() const;
uint8_t getLandId(); uint8_t getLandId() const;
uint16_t getZoneId(); uint16_t getZoneId() const;
std::string getLandName(); std::string getLandName() const;
Common::LandType getLandType() const;
//Free Comapny //Free Comapny
void setFreeCompany( uint32_t id, uint32_t icon, uint32_t color ); void setFreeCompany( uint32_t id, uint32_t icon, uint32_t color );
@ -79,6 +81,7 @@ namespace Core
uint32_t m_landSetId; uint32_t m_landSetId;
uint16_t m_zoneId; uint16_t m_zoneId;
Common::LandStruct m_land; Common::LandStruct m_land;
Common::LandType m_type;
uint32_t m_ownerPlayerId; uint32_t m_ownerPlayerId;
Core::Data::HousingLandSetPtr m_landInfo; Core::Data::HousingLandSetPtr m_landInfo;