mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 16:37:45 +00:00
when exiting an instance, return the player to correct ward
This commit is contained in:
parent
e198705503
commit
aded517eb0
9 changed files with 45 additions and 30 deletions
|
@ -64,7 +64,7 @@ void PlayerMinimal::load( uint32_t charId )
|
|||
m_guardianDeity = res->getUInt8( "GuardianDeity" );
|
||||
m_class = res->getUInt8( "Class" );
|
||||
m_contentId = res->getUInt64( "ContentId" );
|
||||
m_zoneId = res->getUInt16( "TerritoryType" );
|
||||
m_territoryTypeId = res->getUInt16( "TerritoryType" );
|
||||
|
||||
res.reset();
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace Sapphire
|
|||
|
||||
uint32_t getZoneId() const
|
||||
{
|
||||
return m_zoneId;
|
||||
return m_territoryTypeId;
|
||||
}
|
||||
|
||||
uint32_t getTribe() const
|
||||
|
@ -185,7 +185,7 @@ namespace Sapphire
|
|||
|
||||
uint8_t m_tribe;
|
||||
|
||||
uint16_t m_zoneId;
|
||||
uint16_t m_territoryTypeId;
|
||||
|
||||
uint64_t m_modelMainWeapon;
|
||||
uint64_t m_modelSubWeapon;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Sapphire::Entity
|
|||
/*! Type of the actor */
|
||||
Common::ObjKind m_objKind;
|
||||
/*! 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 */
|
||||
ZonePtr m_pCurrentZone;
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ uint32_t Sapphire::Entity::Player::getMaxMp()
|
|||
|
||||
uint16_t Sapphire::Entity::Player::getZoneId() const
|
||||
{
|
||||
return m_zoneId;
|
||||
return m_territoryTypeId;
|
||||
}
|
||||
|
||||
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
|
||||
m_pos = m_prevPos;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -442,12 +442,15 @@ bool Sapphire::Entity::Player::setInstance( ZonePtr instance )
|
|||
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
|
||||
auto currentZone = getCurrentZone();
|
||||
|
||||
// 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_prevRot = m_rot;
|
||||
m_prevZoneId = m_zoneId;
|
||||
m_prevTerritoryTypeId = currentZone->getTerritoryTypeId();
|
||||
m_prevTerritoryId = getTerritoryId();
|
||||
}
|
||||
|
||||
if( !pTeriMgr->movePlayer( instance, getAsPlayer() ) )
|
||||
|
@ -461,12 +464,23 @@ bool Sapphire::Entity::Player::setInstance( ZonePtr instance )
|
|||
bool Sapphire::Entity::Player::exitInstance()
|
||||
{
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
if( !pTeriMgr->movePlayer( m_prevZoneId, getAsPlayer() ) )
|
||||
return false;
|
||||
|
||||
// check if housing zone
|
||||
if( pTeriMgr->isHousingTerritory( m_prevTerritoryTypeId ) )
|
||||
{
|
||||
if( !pTeriMgr->movePlayer( pTeriMgr->getZoneByLandSetId( m_prevTerritoryId ), getAsPlayer() ) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !pTeriMgr->movePlayer( m_prevTerritoryTypeId, getAsPlayer() ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pos = m_prevPos;
|
||||
m_rot = m_prevRot;
|
||||
m_zoneId = m_prevZoneId;
|
||||
m_territoryTypeId = m_prevTerritoryTypeId;
|
||||
m_territoryId = m_prevTerritoryId;
|
||||
|
||||
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 )
|
||||
{
|
||||
m_pos = pos;
|
||||
m_zoneId = zoneId;
|
||||
m_territoryTypeId = zoneId;
|
||||
m_bMarkedForZoning = true;
|
||||
setRot( rotation );
|
||||
setZone( zoneId );
|
||||
|
@ -1530,12 +1544,12 @@ void Sapphire::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp )
|
|||
|
||||
void Sapphire::Entity::Player::setTerritoryTypeId( uint32_t territoryTypeId )
|
||||
{
|
||||
m_zoneId = territoryTypeId;
|
||||
m_territoryTypeId = territoryTypeId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Player::getTerritoryTypeId() const
|
||||
{
|
||||
return m_zoneId;
|
||||
return m_territoryTypeId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::sendZonePackets()
|
||||
|
|
|
@ -945,8 +945,8 @@ namespace Sapphire::Entity
|
|||
InventoryMap m_storageMap;
|
||||
|
||||
Common::FFXIVARR_POSITION3 m_prevPos;
|
||||
uint32_t m_prevZoneType;
|
||||
uint32_t m_prevZoneId;
|
||||
uint32_t m_prevTerritoryTypeId;
|
||||
uint32_t m_prevTerritoryId;
|
||||
float m_prevRot;
|
||||
|
||||
uint8_t m_voice;
|
||||
|
|
|
@ -52,7 +52,8 @@ bool Sapphire::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
|
||||
auto zoneId = res->getUInt( "TerritoryType" );
|
||||
m_territoryId = res->getUInt( "TerritoryId" );
|
||||
m_prevZoneId = res->getUInt( "OTerritoryType" );
|
||||
m_prevTerritoryTypeId = res->getUInt( "OTerritoryType" );
|
||||
m_prevTerritoryId = res->getUInt( "OTerritoryId" );
|
||||
|
||||
// Position
|
||||
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( !pCurrZone )
|
||||
{
|
||||
zoneId = m_prevZoneId;
|
||||
zoneId = m_prevTerritoryTypeId;
|
||||
m_pos.x = m_prevPos.x;
|
||||
m_pos.y = m_prevPos.y;
|
||||
m_pos.z = m_prevPos.z;
|
||||
|
@ -92,7 +93,7 @@ bool Sapphire::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
|
||||
}
|
||||
|
||||
m_zoneId = zoneId;
|
||||
m_territoryTypeId = zoneId;
|
||||
|
||||
// TODO: logic for instances needs to be added here
|
||||
// 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( 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->setDouble( 20, m_pos.x );
|
||||
stmt->setDouble( 21, m_pos.y );
|
||||
stmt->setDouble( 22, m_pos.z );
|
||||
stmt->setDouble( 23, getRot() );
|
||||
|
||||
stmt->setInt( 24, m_prevZoneId ); // OTerritoryType
|
||||
stmt->setInt( 25, m_prevZoneType ); // OTerritoryId
|
||||
stmt->setInt( 24, m_prevTerritoryTypeId ); // OTerritoryType
|
||||
stmt->setInt( 25, m_prevTerritoryId ); // OTerritoryId
|
||||
stmt->setDouble( 26, m_prevPos.x );
|
||||
stmt->setDouble( 27, m_prevPos.y );
|
||||
stmt->setDouble( 28, m_prevPos.z );
|
||||
|
|
|
@ -32,7 +32,7 @@ Sapphire::HousingZone::HousingZone( uint8_t wardNum,
|
|||
const std::string& contentName ) :
|
||||
Zone( territoryTypeId, guId, internalName, contentName ),
|
||||
m_wardNum( wardNum ),
|
||||
m_zoneId( territoryTypeId ),
|
||||
m_territoryTypeId( territoryTypeId ),
|
||||
m_landSetId( ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardNum )
|
||||
{
|
||||
|
||||
|
@ -49,13 +49,13 @@ bool Sapphire::HousingZone::init()
|
|||
}
|
||||
|
||||
int housingIndex;
|
||||
if( m_zoneId == 339 )
|
||||
if( m_territoryTypeId == 339 )
|
||||
housingIndex = 0;
|
||||
else if( m_zoneId == 340 )
|
||||
else if( m_territoryTypeId == 340 )
|
||||
housingIndex = 1;
|
||||
else if( m_zoneId == 341 )
|
||||
else if( m_territoryTypeId == 341 )
|
||||
housingIndex = 2;
|
||||
else if( m_zoneId == 641 )
|
||||
else if( m_territoryTypeId == 641 )
|
||||
housingIndex = 3;
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Sapphire
|
|||
LandPtrMap m_landPtrMap;
|
||||
uint8_t m_wardNum;
|
||||
uint32_t m_landSetId;
|
||||
uint32_t m_zoneId;
|
||||
uint32_t m_territoryTypeId;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire
|
||||
{
|
||||
|
||||
class Session;
|
||||
|
|
Loading…
Add table
Reference in a new issue