mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-06 18:57:45 +00:00
instance zoning and returning implemented
instancecontent uses instancecontent class instead of zone too
This commit is contained in:
parent
97e2c08a9f
commit
7de0885b54
7 changed files with 75 additions and 3 deletions
|
@ -365,13 +365,56 @@ void Core::Entity::Player::returnToHomepoint()
|
||||||
|
|
||||||
void Core::Entity::Player::setZone( uint32_t zoneId )
|
void Core::Entity::Player::setZone( uint32_t zoneId )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !g_territoryMgr.movePlayer( zoneId, getAsPlayer() ) )
|
if( !g_territoryMgr.movePlayer( zoneId, getAsPlayer() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendZonePackets();
|
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
|
uint32_t Core::Entity::Player::getPlayTime() const
|
||||||
{
|
{
|
||||||
return m_playTime;
|
return m_playTime;
|
||||||
|
|
|
@ -309,6 +309,12 @@ public:
|
||||||
Common::OnlineStatus getOnlineStatus();
|
Common::OnlineStatus getOnlineStatus();
|
||||||
/*! sets the players zone, initiating a zoning process */
|
/*! sets the players zone, initiating a zoning process */
|
||||||
void setZone( uint32_t zoneId );
|
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 */
|
/*! sets the players territoryId */
|
||||||
void setTerritoryId( uint32_t territoryId );
|
void setTerritoryId( uint32_t territoryId );
|
||||||
/*! gets the players territoryId */
|
/*! gets the players territoryId */
|
||||||
|
|
|
@ -697,4 +697,8 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
|
||||||
else
|
else
|
||||||
player.sendDebug( "Failed to remove instance with id: " + std::to_string( terriId ) );
|
player.sendDebug( "Failed to remove instance with id: " + std::to_string( terriId ) );
|
||||||
}
|
}
|
||||||
|
else if( subCommand == "return" || subCommand == "ret" )
|
||||||
|
{
|
||||||
|
player.exitInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,6 +406,8 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
if( auto instance = g_territoryMgr.getTerritoryZonePtr( param1 ) )
|
if( auto instance = g_territoryMgr.getTerritoryZonePtr( param1 ) )
|
||||||
{
|
{
|
||||||
player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) );
|
player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) );
|
||||||
|
|
||||||
|
player.setInstance( instance );
|
||||||
}
|
}
|
||||||
else if( !g_territoryMgr.isValidTerritory( param1 ) )
|
else if( !g_territoryMgr.isValidTerritory( param1 ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +1,12 @@
|
||||||
#include "InstanceContent.h"
|
#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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ public:
|
||||||
DutyFinished
|
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();
|
virtual ~InstanceContent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "Zone.h"
|
#include "Zone.h"
|
||||||
#include "ZonePosition.h"
|
#include "ZonePosition.h"
|
||||||
|
#include "InstanceContent.h"
|
||||||
|
|
||||||
extern Core::Logger g_log;
|
extern Core::Logger g_log;
|
||||||
extern Core::Data::ExdData g_exdData;
|
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 + ")" );
|
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();
|
pZone->init();
|
||||||
|
|
||||||
m_territoryInstanceMap[pZone->getTerritoryId()][pZone->getGuId()] = pZone;
|
m_territoryInstanceMap[pZone->getTerritoryId()][pZone->getGuId()] = pZone;
|
||||||
|
|
Loading…
Add table
Reference in a new issue