1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-24 13:47:46 +00:00

correctly remove InstanceContent zones

This commit is contained in:
Adam 2018-01-29 20:40:32 +11:00
parent e9d0e5cbb8
commit 95bf84ca6d
3 changed files with 25 additions and 8 deletions

View file

@ -3,9 +3,11 @@
Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceContent,
uint32_t guId,
const std::string& internalName,
const std::string& placeName )
const std::string& placeName,
const uint32_t instanceContentId )
: Zone( pInstanceContent->territoryType, guId, internalName, placeName ),
m_instanceContentRow( pInstanceContent )
m_instanceContentRow( pInstanceContent ),
m_instanceContentId( instanceContentId )
{
}

View file

@ -21,7 +21,8 @@ public:
InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceContent,
uint32_t guId,
const std::string& internalName,
const std::string& placeName );
const std::string& placeName,
const uint32_t instanceContentId );
virtual ~InstanceContent();
boost::shared_ptr< Core::Data::InstanceContent > getInstanceContentRow() const
@ -29,9 +30,15 @@ public:
return m_instanceContentRow;
}
const uint32_t getInstanceContentId()
{
return m_instanceContentId;
}
private:
Event::DirectorPtr m_pDirector;
boost::shared_ptr< Core::Data::InstanceContent > m_instanceContentRow;
uint32_t m_instanceContentId;
};

View file

@ -174,7 +174,7 @@ Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceConten
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 ) );
ZonePtr pZone = ZonePtr( new InstanceContent( pInstanceContent, getNextInstanceId(), pTeri->name, pPlaceName->name, instanceContentId ) );
pZone->init();
m_instanceContentToInstanceMap[instanceContentId][pZone->getGuId()] = pZone;
@ -185,12 +185,20 @@ Core::ZonePtr Core::TerritoryMgr::createInstanceContent( uint32_t instanceConten
bool Core::TerritoryMgr::removeTerritoryInstance( uint32_t instanceId )
{
ZonePtr instance;
if( ( instance = getInstanceZonePtr( instanceId ) ) == nullptr )
ZonePtr pZone;
if( ( pZone = getInstanceZonePtr( instanceId ) ) == nullptr )
return false;
m_instanceIdToZonePtrMap.erase( instance->getGuId() );
m_territoryInstanceMap[instance->getTerritoryId()].erase( instance->getGuId() );
m_instanceIdToZonePtrMap.erase( pZone->getGuId() );
if( isInstanceContentTerritory( pZone->getTerritoryId() ) )
{
auto instance = boost::dynamic_pointer_cast< InstanceContent >( pZone );
m_instanceContentToInstanceMap[instance->getInstanceContentId()].erase( pZone->getGuId() );
}
else
m_territoryInstanceMap[pZone->getTerritoryId()].erase( pZone->getGuId() );
return true;
}