mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
createInstanceContent and some minor refactoring
This commit is contained in:
parent
cbefc4cc1f
commit
56c6b38966
7 changed files with 68 additions and 20 deletions
|
@ -373,7 +373,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
|
||||||
|
|
||||||
bool Core::Entity::Player::setInstance( uint32_t instanceContentId )
|
bool Core::Entity::Player::setInstance( uint32_t instanceContentId )
|
||||||
{
|
{
|
||||||
auto instance = g_territoryMgr.getTerritoryZonePtr( instanceContentId );
|
auto instance = g_territoryMgr.getInstanceZonePtr( instanceContentId );
|
||||||
if( !instance )
|
if( !instance )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -681,11 +681,14 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
|
||||||
|
|
||||||
if( subCommand == "create" || subCommand == "cr" )
|
if( subCommand == "create" || subCommand == "cr" )
|
||||||
{
|
{
|
||||||
uint32_t terriId;
|
uint32_t instanceContentId;
|
||||||
sscanf( params.c_str(), "%d", &terriId );
|
sscanf( params.c_str(), "%d", &instanceContentId );
|
||||||
|
|
||||||
auto instance = g_territoryMgr.createTerritoryInstance( terriId );
|
auto instance = g_territoryMgr.createInstanceContent( instanceContentId );
|
||||||
player.sendDebug( "Created instance with guid: " + std::to_string( instance->getGuId() ) );
|
if( instance )
|
||||||
|
player.sendDebug( "Created instance with id: " + std::to_string( instance->getGuId() ) + " -> " + instance->getName() );
|
||||||
|
else
|
||||||
|
player.sendDebug( "Failed to create instance with id: " + std::to_string( instanceContentId ) );
|
||||||
}
|
}
|
||||||
else if( subCommand == "remove" || subCommand == "rm" )
|
else if( subCommand == "remove" || subCommand == "rm" )
|
||||||
{
|
{
|
||||||
|
|
|
@ -403,7 +403,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
}
|
}
|
||||||
case GmCommand::Teri:
|
case GmCommand::Teri:
|
||||||
{
|
{
|
||||||
if( auto instance = g_territoryMgr.getTerritoryZonePtr( param1 ) )
|
if( auto instance = g_territoryMgr.getInstanceZonePtr( param1 ) )
|
||||||
{
|
{
|
||||||
player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) );
|
player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) );
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#include "InstanceContent.h"
|
#include "InstanceContent.h"
|
||||||
|
|
||||||
Core::InstanceContent::InstanceContent( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName )
|
Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceContent,
|
||||||
: Zone( territoryId, guId, internalName, placeName )
|
uint32_t guId,
|
||||||
|
const std::string& internalName,
|
||||||
|
const std::string& placeName )
|
||||||
|
: Zone( pInstanceContent->territoryType, guId, internalName, placeName ),
|
||||||
|
m_instanceContentRow( pInstanceContent )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "Zone.h"
|
#include "Zone.h"
|
||||||
#include "Forwards.h"
|
#include "Forwards.h"
|
||||||
|
#include <common/Exd/ExdDataGenerated.h>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
@ -17,11 +18,20 @@ public:
|
||||||
DutyFinished
|
DutyFinished
|
||||||
};
|
};
|
||||||
|
|
||||||
InstanceContent( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName );
|
InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceContent,
|
||||||
|
uint32_t guId,
|
||||||
|
const std::string& internalName,
|
||||||
|
const std::string& placeName );
|
||||||
virtual ~InstanceContent();
|
virtual ~InstanceContent();
|
||||||
|
|
||||||
|
boost::shared_ptr< Core::Data::InstanceContent > getInstanceContentRow() const
|
||||||
|
{
|
||||||
|
return m_instanceContentRow;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Event::DirectorPtr m_pDirector;
|
Event::DirectorPtr m_pDirector;
|
||||||
|
boost::shared_ptr< Core::Data::InstanceContent > m_instanceContentRow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,8 @@ bool Core::TerritoryMgr::isInstanceContentTerritory( uint32_t territoryTypeId )
|
||||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::OpenWorldInstanceBattle ||
|
pTeri->territoryIntendedUse == TerritoryIntendedUse::OpenWorldInstanceBattle ||
|
||||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::PalaceOfTheDead ||
|
pTeri->territoryIntendedUse == TerritoryIntendedUse::PalaceOfTheDead ||
|
||||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::RaidFights ||
|
pTeri->territoryIntendedUse == TerritoryIntendedUse::RaidFights ||
|
||||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::Raids;
|
pTeri->territoryIntendedUse == TerritoryIntendedUse::Raids ||
|
||||||
|
pTeri->territoryIntendedUse == TerritoryIntendedUse::TreasureMapInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::TerritoryMgr::isPrivateTerritory( uint32_t territoryTypeId ) const
|
bool Core::TerritoryMgr::isPrivateTerritory( uint32_t territoryTypeId ) const
|
||||||
|
@ -136,6 +137,9 @@ Core::ZonePtr Core::TerritoryMgr::createTerritoryInstance( uint32_t territoryTyp
|
||||||
if( !isValidTerritory( territoryTypeId ) )
|
if( !isValidTerritory( territoryTypeId ) )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if( isInstanceContentTerritory( territoryTypeId ) )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
auto pTeri = getTerritoryDetail( territoryTypeId );
|
auto pTeri = getTerritoryDetail( territoryTypeId );
|
||||||
auto pPlaceName = g_exdDataGen.getPlaceName( pTeri->placeName );
|
auto pPlaceName = g_exdDataGen.getPlaceName( pTeri->placeName );
|
||||||
|
|
||||||
|
@ -144,12 +148,7 @@ 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;
|
ZonePtr pZone = ZonePtr( new Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name ) );
|
||||||
if( isInstanceContentTerritory( territoryTypeId ) )
|
|
||||||
pZone = ZonePtr( new InstanceContent( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name ) );
|
|
||||||
else
|
|
||||||
pZone = ZonePtr( new Zone( territoryTypeId, getNextInstanceId(), pTeri->name, pPlaceName->name ) );
|
|
||||||
|
|
||||||
pZone->init();
|
pZone->init();
|
||||||
|
|
||||||
m_territoryInstanceMap[pZone->getTerritoryId()][pZone->getGuId()] = pZone;
|
m_territoryInstanceMap[pZone->getTerritoryId()][pZone->getGuId()] = pZone;
|
||||||
|
@ -158,10 +157,36 @@ Core::ZonePtr Core::TerritoryMgr::createTerritoryInstance( uint32_t territoryTyp
|
||||||
return pZone;
|
return pZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::TerritoryMgr::removeTerritoryInstance( uint32_t territoryTypeId )
|
Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceContentId )
|
||||||
|
{
|
||||||
|
auto pInstanceContent = g_exdDataGen.getInstanceContent( instanceContentId );
|
||||||
|
if( !pInstanceContent )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if( !isInstanceContentTerritory( pInstanceContent->territoryType ) )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto pTeri = getTerritoryDetail( pInstanceContent->territoryType );
|
||||||
|
auto pPlaceName = g_exdDataGen.getPlaceName( pTeri->placeName );
|
||||||
|
|
||||||
|
if( !pTeri || !pPlaceName )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
g_log.debug( "Starting instance for InstanceContent id: " + std::to_string( instanceContentId ) + " (" + pPlaceName->name + ")" );
|
||||||
|
|
||||||
|
ZonePtr pZone = ZonePtr( new InstanceContent( pInstanceContent, getNextInstanceId(), pTeri->name, pPlaceName->name ) );
|
||||||
|
pZone->init();
|
||||||
|
|
||||||
|
m_instanceContentToInstanceMap[instanceContentId][pZone->getGuId()] = pZone;
|
||||||
|
m_instanceIdToZonePtrMap[pZone->getGuId()] = pZone;
|
||||||
|
|
||||||
|
return pZone;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::TerritoryMgr::removeTerritoryInstance( uint32_t instanceId )
|
||||||
{
|
{
|
||||||
ZonePtr instance;
|
ZonePtr instance;
|
||||||
if( ( instance = getTerritoryZonePtr( territoryTypeId ) ) == nullptr )
|
if( ( instance = getInstanceZonePtr( instanceId ) ) == nullptr )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_instanceIdToZonePtrMap.erase( instance->getGuId() );
|
m_instanceIdToZonePtrMap.erase( instance->getGuId() );
|
||||||
|
@ -170,7 +195,7 @@ bool Core::TerritoryMgr::removeTerritoryInstance( uint32_t territoryTypeId )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::ZonePtr Core::TerritoryMgr::getTerritoryZonePtr( uint32_t instanceId ) const
|
Core::ZonePtr Core::TerritoryMgr::getInstanceZonePtr( uint32_t instanceId ) const
|
||||||
{
|
{
|
||||||
auto it = m_instanceIdToZonePtrMap.find( instanceId );
|
auto it = m_instanceIdToZonePtrMap.find( instanceId );
|
||||||
if( it == m_instanceIdToZonePtrMap.end() )
|
if( it == m_instanceIdToZonePtrMap.end() )
|
||||||
|
@ -239,6 +264,12 @@ void Core::TerritoryMgr::updateTerritoryInstances( uint32_t currentTime )
|
||||||
for( auto zone : zoneMap.second )
|
for( auto zone : zoneMap.second )
|
||||||
zone.second->runZoneLogic( currentTime );
|
zone.second->runZoneLogic( currentTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for( auto zoneMap : m_instanceContentToInstanceMap )
|
||||||
|
{
|
||||||
|
for( auto zone: zoneMap.second )
|
||||||
|
zone.second->runZoneLogic( currentTime );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::TerritoryMgr::InstanceIdList Core::TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const
|
Core::TerritoryMgr::InstanceIdList Core::TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace Core
|
||||||
bool removeTerritoryInstance( uint32_t territoryTypeId );
|
bool removeTerritoryInstance( uint32_t territoryTypeId );
|
||||||
|
|
||||||
/*! returns a ZonePtr to the instance or nullptr if not found */
|
/*! returns a ZonePtr to the instance or nullptr if not found */
|
||||||
ZonePtr getTerritoryZonePtr( uint32_t instanceId ) const;
|
ZonePtr getInstanceZonePtr( uint32_t instanceId ) const;
|
||||||
|
|
||||||
/*! returns the cached detail of a territory, nullptr if not found */
|
/*! returns the cached detail of a territory, nullptr if not found */
|
||||||
Data::TerritoryTypePtr getTerritoryDetail( uint32_t territoryTypeId ) const;
|
Data::TerritoryTypePtr getTerritoryDetail( uint32_t territoryTypeId ) const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue