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

instance zoning and returning implemented

instancecontent uses instancecontent class instead of zone too
This commit is contained in:
Adam 2018-01-29 13:05:33 +11:00
parent 9e830ac677
commit 20ee459e26
7 changed files with 75 additions and 3 deletions

View file

@ -365,13 +365,56 @@ void Core::Entity::Player::returnToHomepoint()
void Core::Entity::Player::setZone( uint32_t zoneId )
{
if( !g_territoryMgr.movePlayer( zoneId, getAsPlayer() ) )
return;
sendZonePackets();
}
bool Core::Entity::Player::setInstance( uint32_t instanceContentId )
{
auto instance = g_territoryMgr.getTerritoryZonePtr( instanceContentId );
if( !instance )
return false;
return setInstance( instance );
}
bool Core::Entity::Player::setInstance( ZonePtr instance )
{
if( !instance )
return false;
// zoning within the same zone won't cause the prev data to be overwritten
if( instance->getTerritoryId() != m_zoneId )
{
m_prevPos = m_pos;
m_prevRot = m_rot;
m_prevZoneId = m_zoneId;
}
if( !g_territoryMgr.movePlayer( instance, getAsPlayer() ) )
return false;
sendZonePackets();
return true;
}
bool Core::Entity::Player::exitInstance()
{
if( !g_territoryMgr.movePlayer( m_prevZoneId, getAsPlayer() ) )
return false;
m_pos = m_prevPos;
m_rot = m_prevRot;
m_zoneId = m_prevZoneId;
sendZonePackets();
return true;
}
uint32_t Core::Entity::Player::getPlayTime() const
{
return m_playTime;

View file

@ -309,6 +309,12 @@ public:
Common::OnlineStatus getOnlineStatus();
/*! sets the players zone, initiating a zoning process */
void setZone( uint32_t zoneId );
/*! sets the players instance & initiates zoning process */
bool setInstance( uint32_t instanceContentId );
/*! sets the players instance & initiates zoning process */
bool setInstance( ZonePtr instance );
/*! returns the player to their position before zoning into an instance */
bool exitInstance();
/*! sets the players territoryId */
void setTerritoryId( uint32_t territoryId );
/*! gets the players territoryId */

View file

@ -697,4 +697,8 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
else
player.sendDebug( "Failed to remove instance with id: " + std::to_string( terriId ) );
}
else if( subCommand == "return" || subCommand == "ret" )
{
player.exitInstance();
}
}

View file

@ -406,6 +406,8 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
if( auto instance = g_territoryMgr.getTerritoryZonePtr( param1 ) )
{
player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) );
player.setInstance( instance );
}
else if( !g_territoryMgr.isValidTerritory( param1 ) )
{

View file

@ -1 +1,12 @@
#include "InstanceContent.h"
Core::InstanceContent::InstanceContent( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName, bool bPrivate = false )
: Zone( territoryId, guId, internalName, placeName, bPrivate )
{
}
Core::InstanceContent::~InstanceContent()
{
}

View file

@ -17,7 +17,7 @@ public:
DutyFinished
};
InstanceContent( uint32_t instanceContentId, uint32_t guid );
InstanceContent( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName, bool bPrivate );
virtual ~InstanceContent();
private:

View file

@ -8,6 +8,7 @@
#include "Zone.h"
#include "ZonePosition.h"
#include "InstanceContent.h"
extern Core::Logger g_log;
extern Core::Data::ExdData g_exdData;
@ -143,7 +144,12 @@ Core::ZonePtr Core::TerritoryMgr::createTerritoryInstance( uint32_t territoryTyp
g_log.debug( "Starting instance for territory: " + std::to_string( territoryTypeId ) + " (" + pPlaceName->name + ")" );
ZonePtr pZone( new Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name, false ) );
ZonePtr pZone;
if( isInstanceContentTerritory( territoryTypeId ) )
pZone = ZonePtr( new InstanceContent( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name, false ) );
else
pZone = ZonePtr( new Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name, false ) );
pZone->init();
m_territoryInstanceMap[pZone->getTerritoryId()][pZone->getGuId()] = pZone;