1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 07:07:45 +00:00

Merge pull request #455 from NotAdam/housing

Minor refactoring and bugfix
This commit is contained in:
Mordred 2018-12-19 11:06:43 +01:00 committed by GitHub
commit dbd6804d7d
5 changed files with 21 additions and 21 deletions

View file

@ -8,7 +8,7 @@
<script> <script>
function doLogin(){ function doLogin(){
var url = "sapphire-api/lobby/insertSession"; var url = "sapphire-api/lobby/insertSession";
var params = "{\"sId\":\"" + document.getElementsByName('sid')[0].value + "\",\"secret\":\"" + document.getElementsByName('secret')[0].value + "\",\"accountId\":\"" + document.getElementsByName('accountId')[0].value + "\"}"; var params = "{\"sId\":\"" + document.getElementsByName('sid')[0].value + "\",\"secret\":\"" + document.getElementsByName('secret')[0].value + "\",\"accountId\":" + document.getElementsByName('accountId')[0].value + "}";
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", url, true); xhr.open("POST", url, true);

View file

@ -102,7 +102,7 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl
std::strcpy( landInfoSignPacket->data().estateGreeting, house->getHouseGreeting().c_str() ); std::strcpy( landInfoSignPacket->data().estateGreeting, house->getHouseGreeting().c_str() );
} }
uint32_t playerId = land->getPlayerOwner(); uint32_t playerId = land->getOwnerId();
std::string playerName = g_fw.get< Sapphire::ServerMgr >()->getPlayerNameFromDb( playerId ); std::string playerName = g_fw.get< Sapphire::ServerMgr >()->getPlayerNameFromDb( playerId );
memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() ); memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() );
@ -160,7 +160,7 @@ Sapphire::LandPurchaseResult Sapphire::World::Manager::HousingMgr::purchaseLand(
return LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR; return LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR;
player.removeCurrency( CurrencyType::Gil, plotPrice ); player.removeCurrency( CurrencyType::Gil, plotPrice );
pLand->setPlayerOwner( player.getId() ); pLand->setOwnerId( player.getId() );
pLand->setState( HouseState::sold ); pLand->setState( HouseState::sold );
pLand->setLandType( Common::LandType::Private ); pLand->setLandType( Common::LandType::Private );
@ -190,7 +190,7 @@ bool Sapphire::World::Manager::HousingMgr::relinquishLand( Entity::Player& playe
auto pLand = pHousing->getLand( plot ); auto pLand = pHousing->getLand( plot );
auto plotMaxPrice = pLand->getCurrentPrice(); auto plotMaxPrice = pLand->getCurrentPrice();
auto landOwnerId = pLand->getPlayerOwner(); auto landOwnerId = pLand->getOwnerId();
// can't relinquish when you are not the owner // can't relinquish when you are not the owner
// TODO: actually use permissions here for FC houses // TODO: actually use permissions here for FC houses
@ -211,7 +211,7 @@ bool Sapphire::World::Manager::HousingMgr::relinquishLand( Entity::Player& playe
} }
pLand->setCurrentPrice( pLand->getMaxPrice() ); pLand->setCurrentPrice( pLand->getMaxPrice() );
pLand->setPlayerOwner( 0 ); pLand->setOwnerId( 0 );
pLand->setState( HouseState::forSale ); pLand->setState( HouseState::forSale );
pLand->setLandType( Common::LandType::none ); pLand->setLandType( Common::LandType::none );
pLand->updateLandDb(); pLand->updateLandDb();
@ -275,7 +275,7 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla
case LandType::Private: case LandType::Private:
entry.infoFlags |= Common::WardlandFlags::IsEstateOwned; entry.infoFlags |= Common::WardlandFlags::IsEstateOwned;
auto owner = land->getPlayerOwner(); auto owner = land->getOwnerId();
auto playerName = g_fw.get< Sapphire::ServerMgr >()->getPlayerNameFromDb( owner ); auto playerName = g_fw.get< Sapphire::ServerMgr >()->getPlayerNameFromDb( owner );
memcpy( &entry.estateOwnerName, playerName.c_str(), playerName.size() ); memcpy( &entry.estateOwnerName, playerName.c_str(), playerName.size() );
@ -327,7 +327,7 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl
return; return;
// todo: when doing FC houses, look up the type from the original purchase and check perms from FC and set state accordingly // todo: when doing FC houses, look up the type from the original purchase and check perms from FC and set state accordingly
if( pLand->getPlayerOwner() != player.getId() ) if( pLand->getOwnerId() != player.getId() )
return; return;
// todo: check if permit is in inventory and remove one // todo: check if permit is in inventory and remove one
@ -415,7 +415,7 @@ void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player&
return; return;
// todo: implement proper permissions checks // todo: implement proper permissions checks
if( land->getPlayerOwner() != player.getId() ) if( land->getOwnerId() != player.getId() )
return; return;
auto house = land->getHouse(); auto house = land->getHouse();
@ -441,7 +441,7 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity:
return; return;
// todo: add proper permission check // todo: add proper permission check
if( land->getPlayerOwner() != player.getId() ) if( land->getOwnerId() != player.getId() )
return; return;
auto packet = makeZonePacket< FFXIVIpcHousingShowEstateGuestAccess >( player.getId() ); auto packet = makeZonePacket< FFXIVIpcHousingShowEstateGuestAccess >( player.getId() );
@ -505,7 +505,7 @@ void Sapphire::World::Manager::HousingMgr::sendHousingInventory( Entity::Player&
return; return;
// todo: add proper permissions checks // todo: add proper permissions checks
if( targetLand->getPlayerOwner() != player.getId() ) if( targetLand->getOwnerId() != player.getId() )
return; return;
player.sendDebug( "got inventory for plot: " + targetLand->getHouse()->getHouseName() ); player.sendDebug( "got inventory for plot: " + targetLand->getHouse()->getHouseName() );

View file

@ -672,7 +672,7 @@ void Sapphire::Network::GameConnection::landRenameHandler( const Packets::FFXIVA
return; return;
// todo: check perms for fc houses and shit // todo: check perms for fc houses and shit
if( pLand->getPlayerOwner() != player.getId() ) if( pLand->getOwnerId() != player.getId() )
return; return;
auto pHouse = pLand->getHouse(); auto pHouse = pLand->getHouse();

View file

@ -34,7 +34,7 @@ Sapphire::Land::Land( uint16_t territoryTypeId, uint8_t wardNum, uint8_t landId,
m_currentPrice( 0 ), m_currentPrice( 0 ),
m_minPrice( 0 ), m_minPrice( 0 ),
m_nextDrop( static_cast< uint32_t >( Util::getTimeSeconds() ) + 21600 ), m_nextDrop( static_cast< uint32_t >( Util::getTimeSeconds() ) + 21600 ),
m_ownerPlayerId( 0 ), m_ownerId( 0 ),
m_landSetId( landSetId ), m_landSetId( landSetId ),
m_landInfo( info ), m_landInfo( info ),
m_type( Common::LandType::none ), m_type( Common::LandType::none ),
@ -77,7 +77,7 @@ void Sapphire::Land::init()
m_size = res->getUInt( "Size" ); m_size = res->getUInt( "Size" );
m_state = res->getUInt( "Status" ); m_state = res->getUInt( "Status" );
m_currentPrice = res->getUInt( "LandPrice" ); m_currentPrice = res->getUInt( "LandPrice" );
m_ownerPlayerId = res->getUInt64( "OwnerId" ); m_ownerId = res->getUInt64( "OwnerId" );
m_minPrice = m_landInfo->minPrice[ m_landId ]; m_minPrice = m_landInfo->minPrice[ m_landId ];
m_maxPrice = m_landInfo->initialPrice[ m_landId ]; m_maxPrice = m_landInfo->initialPrice[ m_landId ];
@ -240,14 +240,14 @@ uint32_t Sapphire::Land::getFcColor()
} }
//Player //Player
void Sapphire::Land::setPlayerOwner( uint64_t id ) void Sapphire::Land::setOwnerId( uint64_t id )
{ {
m_ownerPlayerId = id; m_ownerId = id;
} }
uint64_t Sapphire::Land::getPlayerOwner() uint64_t Sapphire::Land::getOwnerId()
{ {
return m_ownerPlayerId; return m_ownerId;
} }
uint32_t Sapphire::Land::getDevaluationTime() uint32_t Sapphire::Land::getDevaluationTime()
@ -282,7 +282,7 @@ void Sapphire::Land::updateLandDb()
pDb->directExecute( "UPDATE land SET status = " + std::to_string( m_state ) pDb->directExecute( "UPDATE land SET status = " + std::to_string( m_state )
+ ", LandPrice = " + std::to_string( getCurrentPrice() ) + ", LandPrice = " + std::to_string( getCurrentPrice() )
+ ", UpdateTime = " + std::to_string( getDevaluationTime() ) + ", UpdateTime = " + std::to_string( getDevaluationTime() )
+ ", OwnerId = " + std::to_string( getPlayerOwner() ) + ", OwnerId = " + std::to_string( getOwnerId() )
+ ", HouseId = " + std::to_string( houseId ) + ", HouseId = " + std::to_string( houseId )
+ ", Type = " + std::to_string( static_cast< uint32_t >( m_type ) ) //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 )

View file

@ -45,8 +45,8 @@ namespace Sapphire
uint32_t getFcColor(); uint32_t getFcColor();
//Player //Player
void setPlayerOwner( uint64_t id ); void setOwnerId( uint64_t id );
uint64_t getPlayerOwner(); uint64_t getOwnerId();
//Housing Functions //Housing Functions
void setCurrentPrice( uint32_t currentPrice ); void setCurrentPrice( uint32_t currentPrice );
bool setPreset( uint32_t itemId ); bool setPreset( uint32_t itemId );
@ -82,7 +82,7 @@ namespace Sapphire
Common::FFXIVARR_POSITION3 m_mapMarkerPosition; Common::FFXIVARR_POSITION3 m_mapMarkerPosition;
uint64_t m_ownerPlayerId; uint64_t m_ownerId;
Sapphire::Data::HousingLandSetPtr m_landInfo; Sapphire::Data::HousingLandSetPtr m_landInfo;
Sapphire::HousePtr m_pHouse; Sapphire::HousePtr m_pHouse;