1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 00:47:45 +00:00

when exiting an instance, return the player to correct ward

This commit is contained in:
NotAdam 2018-12-02 15:32:22 +11:00
parent e198705503
commit aded517eb0
9 changed files with 45 additions and 30 deletions

View file

@ -64,7 +64,7 @@ void PlayerMinimal::load( uint32_t charId )
m_guardianDeity = res->getUInt8( "GuardianDeity" ); m_guardianDeity = res->getUInt8( "GuardianDeity" );
m_class = res->getUInt8( "Class" ); m_class = res->getUInt8( "Class" );
m_contentId = res->getUInt64( "ContentId" ); m_contentId = res->getUInt64( "ContentId" );
m_zoneId = res->getUInt16( "TerritoryType" ); m_territoryTypeId = res->getUInt16( "TerritoryType" );
res.reset(); res.reset();

View file

@ -131,7 +131,7 @@ namespace Sapphire
uint32_t getZoneId() const uint32_t getZoneId() const
{ {
return m_zoneId; return m_territoryTypeId;
} }
uint32_t getTribe() const uint32_t getTribe() const
@ -185,7 +185,7 @@ namespace Sapphire
uint8_t m_tribe; uint8_t m_tribe;
uint16_t m_zoneId; uint16_t m_territoryTypeId;
uint64_t m_modelMainWeapon; uint64_t m_modelMainWeapon;
uint64_t m_modelSubWeapon; uint64_t m_modelSubWeapon;

View file

@ -30,7 +30,7 @@ namespace Sapphire::Entity
/*! Type of the actor */ /*! Type of the actor */
Common::ObjKind m_objKind; Common::ObjKind m_objKind;
/*! Id of the zone the actor currently is in */ /*! Id of the zone the actor currently is in */
uint32_t m_zoneId; uint32_t m_territoryTypeId;
/*! Ptr to the ZoneObj the actor belongs to */ /*! Ptr to the ZoneObj the actor belongs to */
ZonePtr m_pCurrentZone; ZonePtr m_pCurrentZone;

View file

@ -128,7 +128,7 @@ uint32_t Sapphire::Entity::Player::getMaxMp()
uint16_t Sapphire::Entity::Player::getZoneId() const uint16_t Sapphire::Entity::Player::getZoneId() const
{ {
return m_zoneId; return m_territoryTypeId;
} }
uint32_t Sapphire::Entity::Player::getTerritoryId() const uint32_t Sapphire::Entity::Player::getTerritoryId() const
@ -414,9 +414,9 @@ void Sapphire::Entity::Player::setZone( uint32_t zoneId )
// todo: this will require proper handling, for now just return the player to their previous area // todo: this will require proper handling, for now just return the player to their previous area
m_pos = m_prevPos; m_pos = m_prevPos;
m_rot = m_prevRot; m_rot = m_prevRot;
m_zoneId = m_prevZoneId; m_territoryTypeId = m_prevTerritoryTypeId;
if( !pTeriMgr->movePlayer( m_zoneId, getAsPlayer() ) ) if( !pTeriMgr->movePlayer( m_territoryTypeId, getAsPlayer() ) )
return; return;
} }
@ -442,12 +442,15 @@ bool Sapphire::Entity::Player::setInstance( ZonePtr instance )
auto pTeriMgr = g_fw.get< TerritoryMgr >(); auto pTeriMgr = g_fw.get< TerritoryMgr >();
auto currentZone = getCurrentZone();
// zoning within the same zone won't cause the prev data to be overwritten // zoning within the same zone won't cause the prev data to be overwritten
if( instance->getTerritoryTypeId() != m_zoneId ) if( instance->getTerritoryTypeId() != m_territoryTypeId )
{ {
m_prevPos = m_pos; m_prevPos = m_pos;
m_prevRot = m_rot; m_prevRot = m_rot;
m_prevZoneId = m_zoneId; m_prevTerritoryTypeId = currentZone->getTerritoryTypeId();
m_prevTerritoryId = getTerritoryId();
} }
if( !pTeriMgr->movePlayer( instance, getAsPlayer() ) ) if( !pTeriMgr->movePlayer( instance, getAsPlayer() ) )
@ -461,12 +464,23 @@ bool Sapphire::Entity::Player::setInstance( ZonePtr instance )
bool Sapphire::Entity::Player::exitInstance() bool Sapphire::Entity::Player::exitInstance()
{ {
auto pTeriMgr = g_fw.get< TerritoryMgr >(); auto pTeriMgr = g_fw.get< TerritoryMgr >();
if( !pTeriMgr->movePlayer( m_prevZoneId, getAsPlayer() ) )
// check if housing zone
if( pTeriMgr->isHousingTerritory( m_prevTerritoryTypeId ) )
{
if( !pTeriMgr->movePlayer( pTeriMgr->getZoneByLandSetId( m_prevTerritoryId ), getAsPlayer() ) )
return false; return false;
}
else
{
if( !pTeriMgr->movePlayer( m_prevTerritoryTypeId, getAsPlayer() ) )
return false;
}
m_pos = m_prevPos; m_pos = m_prevPos;
m_rot = m_prevRot; m_rot = m_prevRot;
m_zoneId = m_prevZoneId; m_territoryTypeId = m_prevTerritoryTypeId;
m_territoryId = m_prevTerritoryId;
sendZonePackets(); sendZonePackets();
@ -1232,7 +1246,7 @@ void Sapphire::Entity::Player::setLoadingComplete( bool bComplete )
void Sapphire::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3& pos, float rotation ) void Sapphire::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3& pos, float rotation )
{ {
m_pos = pos; m_pos = pos;
m_zoneId = zoneId; m_territoryTypeId = zoneId;
m_bMarkedForZoning = true; m_bMarkedForZoning = true;
setRot( rotation ); setRot( rotation );
setZone( zoneId ); setZone( zoneId );
@ -1530,12 +1544,12 @@ void Sapphire::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp )
void Sapphire::Entity::Player::setTerritoryTypeId( uint32_t territoryTypeId ) void Sapphire::Entity::Player::setTerritoryTypeId( uint32_t territoryTypeId )
{ {
m_zoneId = territoryTypeId; m_territoryTypeId = territoryTypeId;
} }
uint32_t Sapphire::Entity::Player::getTerritoryTypeId() const uint32_t Sapphire::Entity::Player::getTerritoryTypeId() const
{ {
return m_zoneId; return m_territoryTypeId;
} }
void Sapphire::Entity::Player::sendZonePackets() void Sapphire::Entity::Player::sendZonePackets()

View file

@ -945,8 +945,8 @@ namespace Sapphire::Entity
InventoryMap m_storageMap; InventoryMap m_storageMap;
Common::FFXIVARR_POSITION3 m_prevPos; Common::FFXIVARR_POSITION3 m_prevPos;
uint32_t m_prevZoneType; uint32_t m_prevTerritoryTypeId;
uint32_t m_prevZoneId; uint32_t m_prevTerritoryId;
float m_prevRot; float m_prevRot;
uint8_t m_voice; uint8_t m_voice;

View file

@ -52,7 +52,8 @@ bool Sapphire::Entity::Player::load( uint32_t charId, SessionPtr pSession )
auto zoneId = res->getUInt( "TerritoryType" ); auto zoneId = res->getUInt( "TerritoryType" );
m_territoryId = res->getUInt( "TerritoryId" ); m_territoryId = res->getUInt( "TerritoryId" );
m_prevZoneId = res->getUInt( "OTerritoryType" ); m_prevTerritoryTypeId = res->getUInt( "OTerritoryType" );
m_prevTerritoryId = res->getUInt( "OTerritoryId" );
// Position // Position
m_pos.x = res->getFloat( "PosX" ); m_pos.x = res->getFloat( "PosX" );
@ -75,7 +76,7 @@ bool Sapphire::Entity::Player::load( uint32_t charId, SessionPtr pSession )
// if none found, revert to previous zone and position // if none found, revert to previous zone and position
if( !pCurrZone ) if( !pCurrZone )
{ {
zoneId = m_prevZoneId; zoneId = m_prevTerritoryTypeId;
m_pos.x = m_prevPos.x; m_pos.x = m_prevPos.x;
m_pos.y = m_prevPos.y; m_pos.y = m_prevPos.y;
m_pos.z = m_prevPos.z; m_pos.z = m_prevPos.z;
@ -92,7 +93,7 @@ bool Sapphire::Entity::Player::load( uint32_t charId, SessionPtr pSession )
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId ); pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
} }
m_zoneId = zoneId; m_territoryTypeId = zoneId;
// TODO: logic for instances needs to be added here // TODO: logic for instances needs to be added here
// see if a valid zone could be found for the character // see if a valid zone could be found for the character
@ -370,15 +371,15 @@ void Sapphire::Entity::Player::updateSql()
stmt->setInt( 16, static_cast< uint32_t >( m_bNewGame ) ); stmt->setInt( 16, static_cast< uint32_t >( m_bNewGame ) );
stmt->setInt( 17, static_cast< uint32_t >( m_bNewAdventurer ) ); stmt->setInt( 17, static_cast< uint32_t >( m_bNewAdventurer ) );
stmt->setInt( 18, m_zoneId ); // TerritoryType stmt->setInt( 18, m_territoryTypeId ); // TerritoryType
stmt->setInt( 19, m_territoryId ); // TerritoryId stmt->setInt( 19, m_territoryId ); // TerritoryId
stmt->setDouble( 20, m_pos.x ); stmt->setDouble( 20, m_pos.x );
stmt->setDouble( 21, m_pos.y ); stmt->setDouble( 21, m_pos.y );
stmt->setDouble( 22, m_pos.z ); stmt->setDouble( 22, m_pos.z );
stmt->setDouble( 23, getRot() ); stmt->setDouble( 23, getRot() );
stmt->setInt( 24, m_prevZoneId ); // OTerritoryType stmt->setInt( 24, m_prevTerritoryTypeId ); // OTerritoryType
stmt->setInt( 25, m_prevZoneType ); // OTerritoryId stmt->setInt( 25, m_prevTerritoryId ); // OTerritoryId
stmt->setDouble( 26, m_prevPos.x ); stmt->setDouble( 26, m_prevPos.x );
stmt->setDouble( 27, m_prevPos.y ); stmt->setDouble( 27, m_prevPos.y );
stmt->setDouble( 28, m_prevPos.z ); stmt->setDouble( 28, m_prevPos.z );

View file

@ -32,7 +32,7 @@ Sapphire::HousingZone::HousingZone( uint8_t wardNum,
const std::string& contentName ) : const std::string& contentName ) :
Zone( territoryTypeId, guId, internalName, contentName ), Zone( territoryTypeId, guId, internalName, contentName ),
m_wardNum( wardNum ), m_wardNum( wardNum ),
m_zoneId( territoryTypeId ), m_territoryTypeId( territoryTypeId ),
m_landSetId( ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardNum ) m_landSetId( ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardNum )
{ {
@ -49,13 +49,13 @@ bool Sapphire::HousingZone::init()
} }
int housingIndex; int housingIndex;
if( m_zoneId == 339 ) if( m_territoryTypeId == 339 )
housingIndex = 0; housingIndex = 0;
else if( m_zoneId == 340 ) else if( m_territoryTypeId == 340 )
housingIndex = 1; housingIndex = 1;
else if( m_zoneId == 341 ) else if( m_territoryTypeId == 341 )
housingIndex = 2; housingIndex = 2;
else if( m_zoneId == 641 ) else if( m_territoryTypeId == 641 )
housingIndex = 3; housingIndex = 3;
auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto pExdData = g_fw.get< Data::ExdDataGenerated >();

View file

@ -56,7 +56,7 @@ namespace Sapphire
LandPtrMap m_landPtrMap; LandPtrMap m_landPtrMap;
uint8_t m_wardNum; uint8_t m_wardNum;
uint32_t m_landSetId; uint32_t m_landSetId;
uint32_t m_zoneId; uint32_t m_territoryTypeId;
}; };
} }