mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
cleanup housing ClientTrigger handling
This commit is contained in:
parent
66c3aba1f6
commit
c1b3e5d393
4 changed files with 60 additions and 88 deletions
|
@ -803,10 +803,10 @@ namespace Sapphire::Common
|
|||
|
||||
struct LandIdent
|
||||
{
|
||||
int16_t landId; //00
|
||||
int16_t wardNum; //02
|
||||
int16_t territoryTypeId; //04
|
||||
int16_t worldId; //06
|
||||
uint16_t landId; //00
|
||||
uint16_t wardNum; //02
|
||||
uint16_t territoryTypeId; //04
|
||||
uint16_t worldId; //06
|
||||
};
|
||||
|
||||
struct LandFlagSet
|
||||
|
|
|
@ -73,17 +73,17 @@ Sapphire::LandPtr Sapphire::World::Manager::HousingMgr::getLandByOwnerId( uint32
|
|||
return hZone->getLand( res->getUInt( 2 ) );
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
||||
void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident )
|
||||
{
|
||||
player.setActiveLand( plotId, wardId );
|
||||
player.setActiveLand( ident.landId, ident.wardNum );
|
||||
|
||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||
|
||||
if( !hZone )
|
||||
return;
|
||||
|
||||
auto land = hZone->getLand( plotId );
|
||||
auto land = hZone->getLand( ident.landId );
|
||||
if( !land )
|
||||
{
|
||||
land = getLandByOwnerId( player.getId() );
|
||||
|
@ -96,10 +96,7 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl
|
|||
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
|
||||
landInfoSignPacket->data().houseSize = land->getSize();
|
||||
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
|
||||
landInfoSignPacket->data().landIdent.landId = land->getLandId();
|
||||
landInfoSignPacket->data().landIdent.wardNum = land->getWardNum();
|
||||
landInfoSignPacket->data().landIdent.worldId = 67;
|
||||
landInfoSignPacket->data().landIdent.territoryTypeId = land->getTerritoryTypeId();
|
||||
landInfoSignPacket->data().landIdent = ident;
|
||||
landInfoSignPacket->data().houseIconAdd = land->getSharing();
|
||||
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
|
||||
|
||||
|
@ -114,17 +111,17 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl
|
|||
player.queuePacket( landInfoSignPacket );
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId )
|
||||
void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& player, const Common::LandIdent ident )
|
||||
{
|
||||
player.setActiveLand( plotId, wardId );
|
||||
player.setActiveLand( ident.landId, ident.wardNum );
|
||||
|
||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||
|
||||
if( !hZone )
|
||||
return;
|
||||
|
||||
auto land = hZone->getLand( plotId );
|
||||
auto land = hZone->getLand( ident.landId );
|
||||
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
|
||||
plotPricePacket->data().price = land->getCurrentPrice();
|
||||
plotPricePacket->data().timeLeft = land->getDevaluationTime();
|
||||
|
@ -362,15 +359,15 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl
|
|||
eobj->setHousingLink( plotNum << 8 );
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
||||
void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& player, const Common::LandIdent ident )
|
||||
{
|
||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||
|
||||
if( !hZone )
|
||||
return;
|
||||
|
||||
auto land = hZone->getLand( plotId );
|
||||
auto land = hZone->getLand( ident.landId );
|
||||
|
||||
auto house = land->getHouse();
|
||||
if( !house )
|
||||
|
@ -378,24 +375,21 @@ void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player&
|
|||
|
||||
auto landRenamePacket = makeZonePacket< Server::FFXIVIpcLandRename >( player.getId() );
|
||||
|
||||
landRenamePacket->data().landIdent.landId = land->getLandId();
|
||||
landRenamePacket->data().landIdent.wardNum = land->getWardNum();
|
||||
landRenamePacket->data().landIdent.worldId = 67;
|
||||
landRenamePacket->data().landIdent.territoryTypeId = land->getTerritoryTypeId();
|
||||
landRenamePacket->data().landIdent = ident;
|
||||
memcpy( &landRenamePacket->data().houseName, house->getHouseName().c_str(), 20 );
|
||||
|
||||
player.queuePacket( landRenamePacket );
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
||||
void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident )
|
||||
{
|
||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||
|
||||
if( !hZone )
|
||||
return;
|
||||
|
||||
auto land = hZone->getLand( plotId );
|
||||
auto land = hZone->getLand( ident.landId );
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
|
@ -405,16 +399,13 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Pl
|
|||
|
||||
auto estateGreetingPacket = makeZonePacket< Server::FFXIVIpcHousingEstateGreeting >( player.getId() );
|
||||
|
||||
estateGreetingPacket->data().landIdent.landId = land->getLandId();
|
||||
estateGreetingPacket->data().landIdent.wardNum = land->getWardNum();
|
||||
estateGreetingPacket->data().landIdent.worldId = 67;
|
||||
estateGreetingPacket->data().landIdent.territoryTypeId = land->getTerritoryTypeId();
|
||||
estateGreetingPacket->data().landIdent = ident;
|
||||
memcpy( &estateGreetingPacket->data().message, house->getHouseGreeting().c_str(), sizeof( estateGreetingPacket->data().message ) );
|
||||
|
||||
player.queuePacket( estateGreetingPacket );
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent& ident, const std::string& greeting )
|
||||
void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting )
|
||||
{
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto zone = getHousingZoneByLandSetId( landSetId );
|
||||
|
@ -440,15 +431,15 @@ void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player&
|
|||
player.sendLogMessage( 3381 );
|
||||
}
|
||||
|
||||
void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
||||
void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident )
|
||||
{
|
||||
auto landSetId = toLandSetId( territoryTypeId, wardId );
|
||||
auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum );
|
||||
auto hZone = getHousingZoneByLandSetId( landSetId );
|
||||
|
||||
if( !hZone )
|
||||
return;
|
||||
|
||||
auto land = hZone->getLand( plotId );
|
||||
auto land = hZone->getLand( ident.landId );
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
|
@ -457,11 +448,18 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity:
|
|||
return;
|
||||
|
||||
auto packet = makeZonePacket< FFXIVIpcHousingShowEstateGuestAccess >( player.getId() );
|
||||
|
||||
packet->data().ident.landId = plotId;
|
||||
packet->data().ident.territoryTypeId = territoryTypeId;
|
||||
packet->data().ident.wardNum = wardId;
|
||||
packet->data().ident.worldId = worldId;
|
||||
packet->data().ident = ident;
|
||||
|
||||
player.queuePacket( packet );
|
||||
}
|
||||
|
||||
Sapphire::Common::LandIdent Sapphire::World::Manager::HousingMgr::clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12 ) const
|
||||
{
|
||||
Common::LandIdent ident;
|
||||
ident.worldId = param11 >> 16;
|
||||
ident.territoryTypeId = param11 & 0xFFFF;
|
||||
ident.wardNum = param12 >> 16;
|
||||
ident.landId = param12 & 0xFFFF;
|
||||
|
||||
return ident;
|
||||
}
|
|
@ -26,22 +26,24 @@ namespace Sapphire::World::Manager
|
|||
Sapphire::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
|
||||
Sapphire::LandPtr getLandByOwnerId( uint32_t id );
|
||||
|
||||
void sendLandSignOwned( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
||||
void sendLandSignFree( Entity::Player& player, uint8_t wardId, uint8_t plotId, uint16_t territoryTypeId );
|
||||
void sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident );
|
||||
void sendLandSignFree( Entity::Player& player, const Common::LandIdent ident );
|
||||
LandPurchaseResult purchaseLand( Entity::Player& player, uint8_t plot, uint8_t state );
|
||||
|
||||
Common::LandIdent clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12 ) const;
|
||||
|
||||
void sendWardLandInfo( Entity::Player& player, uint8_t wardId, uint16_t territoryTypeId );
|
||||
|
||||
bool relinquishLand( Entity::Player& player, uint8_t plot );
|
||||
|
||||
void buildPresetEstate( Entity::Player& player, uint8_t plotNum, uint32_t presetItem );
|
||||
|
||||
void requestEstateRename( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId );
|
||||
void requestEstateRename( Entity::Player& player, const Common::LandIdent ident );
|
||||
|
||||
void requestEstateEditGreeting( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId );
|
||||
void updateEstateGreeting( Entity::Player& player, const Common::LandIdent& ident, const std::string& greeting );
|
||||
void requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident );
|
||||
void updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting );
|
||||
|
||||
void requestEstateEditGuestAccess( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId );
|
||||
void requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident );
|
||||
|
||||
void sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident );
|
||||
|
||||
|
|
|
@ -325,22 +325,20 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
|||
}
|
||||
case ClientTriggerType::RequestLandSignFree:
|
||||
{
|
||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
||||
auto territoryId = static_cast< uint16_t >( param11 & 0xFFFF );
|
||||
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
pHousingMgr->sendLandSignFree( player, ward, plot, territoryId );
|
||||
|
||||
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||
pHousingMgr->sendLandSignFree( player, ident );
|
||||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestLandSignOwned:
|
||||
{
|
||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
||||
auto territoryId = static_cast< uint16_t >( param11 & 0xFFFF );
|
||||
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
pHousingMgr->sendLandSignOwned( player, ward, plot, territoryId );
|
||||
|
||||
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||
pHousingMgr->sendLandSignOwned( player, ident );
|
||||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestWardLandInfo:
|
||||
|
@ -363,49 +361,34 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
|||
}
|
||||
case ClientTriggerType::RequestEstateRename:
|
||||
{
|
||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
||||
uint16_t worldId = param11 >> 16;
|
||||
|
||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
||||
uint8_t plot = ( param12 & 0xFF );
|
||||
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
if( !pHousingMgr )
|
||||
break;
|
||||
|
||||
pHousingMgr->requestEstateRename( player, territoryTypeId, worldId, ward, plot );
|
||||
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||
pHousingMgr->requestEstateRename( player, ident );
|
||||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestEstateEditGreeting:
|
||||
{
|
||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
||||
uint16_t worldId = param11 >> 16;
|
||||
|
||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
||||
uint8_t plot = ( param12 & 0xFF );
|
||||
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
if( !pHousingMgr )
|
||||
break;
|
||||
|
||||
pHousingMgr->requestEstateEditGreeting( player, territoryTypeId, worldId, ward, plot );
|
||||
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||
pHousingMgr->requestEstateEditGreeting( player, ident );
|
||||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestEstateEditGuestAccessSettings:
|
||||
{
|
||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
||||
uint16_t worldId = param11 >> 16;
|
||||
|
||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
||||
uint8_t plot = ( param12 & 0xFF );
|
||||
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
if( !pHousingMgr )
|
||||
break;
|
||||
|
||||
pHousingMgr->requestEstateEditGuestAccess( player, territoryTypeId, worldId, ward, plot );
|
||||
auto ident = pHousingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||
pHousingMgr->requestEstateEditGuestAccess( player, ident );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -429,22 +412,11 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
|
|||
}
|
||||
case ClientTriggerType::RequestEstateGreeting:
|
||||
{
|
||||
uint16_t territoryTypeId = param11 & 0xFFFF;
|
||||
uint16_t worldId = param11 >> 16;
|
||||
|
||||
uint8_t ward = ( param12 >> 16 ) & 0xFF;
|
||||
uint8_t plot = ( param12 & 0xFF );
|
||||
|
||||
auto housingMgr = g_fw.get< HousingMgr >();
|
||||
if( !housingMgr )
|
||||
break;
|
||||
|
||||
Common::LandIdent ident;
|
||||
ident.territoryTypeId = territoryTypeId;
|
||||
ident.worldId = worldId;
|
||||
ident.wardNum = ward;
|
||||
ident.landId = plot;
|
||||
|
||||
auto ident = housingMgr->clientTriggerParamsToLandIdent( param11, param12 );
|
||||
housingMgr->sendEstateGreeting( player, ident );
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue