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

cleanup and unfuck the perms/state bullshit

This commit is contained in:
NotAdam 2018-11-27 22:18:50 +11:00
parent 2e3a98f9de
commit f83d6ae35b
5 changed files with 47 additions and 35 deletions

View file

@ -774,6 +774,15 @@ namespace Core::Common
Private = 2, Private = 2,
}; };
enum LandEstateFlags : uint32_t
{
ESTATE_BUILT = 0x1,
ESTATE_HAS_AETHERYTE = 0x2,
UNKNOWN_1 = 0x4,
UNKNOWN_2 = 0x8,
UNKNOWN_3 = 0x10,
};
struct LandIdent struct LandIdent
{ {
int16_t landId; //00 int16_t landId; //00
@ -785,7 +794,7 @@ namespace Core::Common
struct LandStateSet struct LandStateSet
{ {
LandIdent landIdent; LandIdent landIdent;
uint32_t permissionMask; //08 uint32_t estateFlags; //08
uint32_t unkown1; //12 uint32_t unkown1; //12
}; };

View file

@ -95,7 +95,7 @@ Core::Entity::Player::Player() :
for ( uint8_t i = 0; i < 5; i++ ) for ( uint8_t i = 0; i < 5; i++ )
{ {
memset( &m_landPermission[i], 0xFF, 8 ); memset( &m_landPermission[i], 0xFF, 8 );
memset( &m_landPermission[i].permissionMask, 0, 8 ); memset( &m_landPermission[i].estateFlags, 0, 8 );
} }
m_objSpawnIndexAllocator.init( MAX_DISPLAYED_EOBJS ); m_objSpawnIndexAllocator.init( MAX_DISPLAYED_EOBJS );
@ -1587,10 +1587,20 @@ void Core::Entity::Player::sendZonePackets()
auto pHousingMgr = g_fw.get< HousingMgr >(); auto pHousingMgr = g_fw.get< HousingMgr >();
if( Core::LandPtr pLand = pHousingMgr->getLandByOwnerId( getId() ) ) if( Core::LandPtr pLand = pHousingMgr->getLandByOwnerId( getId() ) )
{ {
setLandState( LandStateSlot::Private, 0x00, pLand->getLandId(), pLand->getWardNum(), pLand->getTerritoryTypeId() ); uint32_t state = 0;
if( pLand->getHouse() )
{
state |= ESTATE_BUILT;
// todo: remove this, debug for now
state |= ESTATE_HAS_AETHERYTE;
}
setLandState( LandStateSlot::Private, state, pLand->getLandId(), pLand->getWardNum(), pLand->getTerritoryTypeId() );
} }
sendLandPermissions(); sendLandStates();
auto initZonePacket = makeZonePacket< FFXIVIpcInitZone >( getId() ); auto initZonePacket = makeZonePacket< FFXIVIpcInitZone >( getId() );
initZonePacket->data().zoneId = getCurrentZone()->getTerritoryTypeId(); initZonePacket->data().zoneId = getCurrentZone()->getTerritoryTypeId();
@ -1768,47 +1778,38 @@ bool Core::Entity::Player::isOnEnterEventDone() const
return m_onEnterEventDone; return m_onEnterEventDone;
} }
void Core::Entity::Player::setLandState( uint8_t permissionSet, uint32_t permissionMask, void Core::Entity::Player::setLandState( uint8_t permissionSet, uint32_t estateFlags,
int16_t landId, int16_t wardNum, int16_t zoneId ) int16_t landId, int16_t wardNum, int16_t zoneId )
{ {
m_landPermission[ permissionSet ].landIdent.landId = landId; m_landPermission[ permissionSet ].landIdent.landId = landId;
m_landPermission[ permissionSet ].landIdent.wardNum = wardNum; m_landPermission[ permissionSet ].landIdent.wardNum = wardNum;
m_landPermission[ permissionSet ].landIdent.territoryTypeId = zoneId; m_landPermission[ permissionSet ].landIdent.territoryTypeId = zoneId;
m_landPermission[ permissionSet ].landIdent.worldId = 67; m_landPermission[ permissionSet ].landIdent.worldId = 67;
m_landPermission[ permissionSet ].permissionMask = permissionMask; m_landPermission[ permissionSet ].estateFlags = estateFlags;
m_landPermission[ permissionSet ].unkown1 = 0; m_landPermission[ permissionSet ].unkown1 = 0;
} }
void Core::Entity::Player::sendLandPermissions() void Core::Entity::Player::sendLandStates()
{ {
auto landPermissions = makeZonePacket< FFXIVIpcLandPermission >( getId() ); auto landPermissions = makeZonePacket< FFXIVIpcLandPermission >( getId() );
landPermissions->data().freeCompanyHouse = m_landPermission[Common::LandStateSlot::FreeCompany]; landPermissions->data().freeCompanyHouse = m_landPermission[ Common::LandStateSlot::FreeCompany ];
landPermissions->data().privateHouse = m_landPermission[Common::LandStateSlot::Private]; landPermissions->data().privateHouse = m_landPermission[ Common::LandStateSlot::Private ];
landPermissions->data().apartment = m_landPermission[Common::LandStateSlot::Apartment]; landPermissions->data().apartment = m_landPermission[ Common::LandStateSlot::Apartment ];
landPermissions->data().sharedHouse[0] = m_landPermission[Common::LandStateSlot::SharedHouse1]; landPermissions->data().sharedHouse[ 0 ] = m_landPermission[ Common::LandStateSlot::SharedHouse1 ];
landPermissions->data().sharedHouse[1] = m_landPermission[Common::LandStateSlot::SharedHouse2]; landPermissions->data().sharedHouse[ 1 ] = m_landPermission[ Common::LandStateSlot::SharedHouse2 ];
memset( &landPermissions->data().unkownHouse, 0xFF, 8 );
memset( &landPermissions->data().unkownHouse.permissionMask, 0, 8 );
landPermissions->data().unkownHouse.permissionMask = 2;
landPermissions->data().unkown1 = 0;
landPermissions->data().unkown2 = 0;
landPermissions->data().unkown3 = 0;
landPermissions->data().unkown4 = 0;
landPermissions->data().unkown5 = 0;
queuePacket( landPermissions ); queuePacket( landPermissions );
} }
void Core::Entity::Player::sendLandStateSlot( uint8_t slotId, uint8_t landId, uint8_t wardId, uint16_t zoneId ) void Core::Entity::Player::sendLandStateSlot( Common::LandStateSlot slot )
{ {
auto landPermissions = makeZonePacket< FFXIVIpcLandStateSlot >( getId() ); auto landPermissions = makeZonePacket< FFXIVIpcLandStateSlot >( getId() );
landPermissions->data().type = slotId;
landPermissions->data().permissionSet.landIdent.landId = landId; auto slotId = static_cast< uint8_t >( slot );
landPermissions->data().permissionSet.landIdent.wardNum = wardId;
landPermissions->data().permissionSet.landIdent.territoryTypeId = zoneId; landPermissions->data().type = slotId;
landPermissions->data().permissionSet.landIdent.worldId = 67; landPermissions->data().permissionSet = m_landPermission[ slotId ];
landPermissions->data().permissionSet.permissionMask = 0;
queuePacket( landPermissions ); queuePacket( landPermissions );
} }

View file

@ -763,10 +763,10 @@ namespace Core::Entity
// Housing Handling // Housing Handling
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
void setLandState( uint8_t permissionSet, uint32_t permissionMask, int16_t landId, int16_t wardNum, int16_t zoneId ); void setLandState( uint8_t permissionSet, uint32_t estateFlags, int16_t landId, int16_t wardNum, int16_t zoneId );
void sendLandPermissions(); void sendLandStates();
void sendLandStateSlot( uint8_t slotId, uint8_t landId, uint8_t wardId, uint16_t zoneId ); void sendLandStateSlot( Common::LandStateSlot slot );
// Player Battle Handling // Player Battle Handling
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -730,7 +730,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player& player, std:
for( auto it = scripts.begin(); it != scripts.end(); ++it ) for( auto it = scripts.begin(); it != scripts.end(); ++it )
{ {
auto script = *it; auto script = *it;
player.sendDebug( " - '" + script->library_name + player.sendDebug( " - '" + script->library_name +
", num scripts: " + std::to_string( script->scripts.size() ) ); ", num scripts: " + std::to_string( script->scripts.size() ) );
} }
} }
@ -1019,7 +1019,7 @@ void Core::DebugCommandHandler::housing( char* data, Entity::Player& player, std
if( pHousing ) if( pHousing )
{ {
player.setLandState( permissionSet, 0, pHousing->getLandSetId(), pHousing->getWardNum(), pHousing->getTerritoryTypeId() ); player.setLandState( permissionSet, 0, pHousing->getLandSetId(), pHousing->getWardNum(), pHousing->getTerritoryTypeId() );
player.sendLandPermissions(); player.sendLandStates();
} }
else else
player.sendDebug( "You aren't in a housing Zone." ); player.sendDebug( "You aren't in a housing Zone." );

View file

@ -170,8 +170,7 @@ Core::LandPurchaseResult Core::HousingMgr::purchaseLand( Entity::Player& player,
player.setLandState( LandStateSlot::Private, 0x00, plot, player.setLandState( LandStateSlot::Private, 0x00, plot,
pHousing->getWardNum(), pHousing->getTerritoryTypeId() ); pHousing->getWardNum(), pHousing->getTerritoryTypeId() );
player.sendLandStateSlot( static_cast< uint8_t >( LandType::Private ), plot, pHousing->getWardNum(), player.sendLandStateSlot( LandStateSlot::Private );
pHousing->getTerritoryTypeId() );
//pLand->setLandName( "Private Estate" + std::to_string( pHousing->getWardNum() ) + "-" + std::to_string( plot ) ); //pLand->setLandName( "Private Estate" + std::to_string( pHousing->getWardNum() ) + "-" + std::to_string( plot ) );
pLand->updateLandDb(); pLand->updateLandDb();
@ -222,7 +221,7 @@ bool Core::HousingMgr::relinquishLand( Entity::Player& player, uint8_t plot )
player.setLandState( LandStateSlot::Private, 0x00, 0xFF, 0xFF, 0xFF ); player.setLandState( LandStateSlot::Private, 0x00, 0xFF, 0xFF, 0xFF );
player.sendLandStateSlot( static_cast< uint8_t >( LandType::Private ), 0xFF, 0xFF, 0xFF ); player.sendLandStateSlot( LandStateSlot::Private );
auto screenMsgPkt2 = makeActorControl143( player.getId(), ActorControl::LogMsg, 3351, 0x1AA, auto screenMsgPkt2 = makeActorControl143( player.getId(), ActorControl::LogMsg, 3351, 0x1AA,
pLand->getWardNum() + 1, plot + 1 ); pLand->getWardNum() + 1, plot + 1 );
@ -321,4 +320,7 @@ void Core::HousingMgr::buildPresetEstate( Entity::Player& player, uint8_t plotNu
player.playScene( 0x000B0095, 0, 4164955899, 0, 1, plotNum, nullptr ); player.playScene( 0x000B0095, 0, 4164955899, 0, 1, plotNum, nullptr );
// todo: send perms/flags for house // todo: send perms/flags for house
player.setLandState( LandStateSlot::Private, ESTATE_BUILT, pLand->getLandId(), pLand->getWardNum(), pLand->getTerritoryTypeId() );
player.sendLandStateSlot( LandStateSlot::Private );
} }