mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 00:47:45 +00:00
Create lookup for housing zones by landsetId, load housing zone from stored territoryId in player
This commit is contained in:
parent
02e968fbc2
commit
4f296b0fb3
3 changed files with 66 additions and 33 deletions
|
@ -82,6 +82,10 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
|||
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
|
||||
}
|
||||
}
|
||||
else if( pTeriMgr->isHousingTerritory( zoneId ) )
|
||||
{
|
||||
pCurrZone = pTeriMgr->getZoneByLandSetId( m_territoryId );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
|
||||
|
|
|
@ -100,6 +100,29 @@ bool Core::TerritoryMgr::isPrivateTerritory( uint32_t territoryTypeId ) const
|
|||
pTeri->territoryIntendedUse == TerritoryIntendedUse::MSQPrivateArea;
|
||||
}
|
||||
|
||||
bool Core::TerritoryMgr::isDefaultTerritory( uint32_t territoryTypeId ) const
|
||||
{
|
||||
auto pTeri = getTerritoryDetail( territoryTypeId );
|
||||
|
||||
if( !pTeri )
|
||||
return false;
|
||||
|
||||
return pTeri->territoryIntendedUse == TerritoryIntendedUse::Inn ||
|
||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::Town ||
|
||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::OpenWorld ||
|
||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::OpeningArea;
|
||||
|
||||
}
|
||||
|
||||
bool Core::TerritoryMgr::isHousingTerritory( uint32_t territoryTypeId ) const
|
||||
{
|
||||
auto pTeri = getTerritoryDetail( territoryTypeId );
|
||||
|
||||
if( !pTeri )
|
||||
return false;
|
||||
|
||||
return pTeri->territoryIntendedUse == TerritoryIntendedUse::HousingArea;
|
||||
}
|
||||
|
||||
bool Core::TerritoryMgr::createDefaultTerritories()
|
||||
{
|
||||
|
@ -181,6 +204,7 @@ bool Core::TerritoryMgr::createHousingTerritories()
|
|||
instanceMap[ guid ] = pHousingZone;
|
||||
m_instanceIdToZonePtrMap[ guid ] = pHousingZone;
|
||||
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ][ guid ] = pHousingZone;
|
||||
m_landSetIdToZonePtrMap[ pHousingZone->getLandSetId() ] = pHousingZone;
|
||||
m_zoneSet.insert( { pHousingZone } );
|
||||
}
|
||||
|
||||
|
@ -306,30 +330,6 @@ void Core::TerritoryMgr::loadTerritoryPositionMap()
|
|||
}
|
||||
}
|
||||
|
||||
bool Core::TerritoryMgr::isDefaultTerritory( uint32_t territoryTypeId ) const
|
||||
{
|
||||
auto pTeri = getTerritoryDetail( territoryTypeId );
|
||||
|
||||
if( !pTeri )
|
||||
return false;
|
||||
|
||||
return pTeri->territoryIntendedUse == TerritoryIntendedUse::Inn ||
|
||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::Town ||
|
||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::OpenWorld ||
|
||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::OpeningArea;
|
||||
|
||||
}
|
||||
|
||||
bool Core::TerritoryMgr::isHousingTerritory( uint32_t territoryTypeId ) const
|
||||
{
|
||||
auto pTeri = getTerritoryDetail( territoryTypeId );
|
||||
|
||||
if( !pTeri )
|
||||
return false;
|
||||
|
||||
return pTeri->territoryIntendedUse == TerritoryIntendedUse::HousingArea;
|
||||
}
|
||||
|
||||
Core::ZonePositionPtr Core::TerritoryMgr::getTerritoryPosition( uint32_t territoryPositionId ) const
|
||||
{
|
||||
auto it = m_territoryPositionMap.find( territoryPositionId );
|
||||
|
@ -350,6 +350,15 @@ Core::ZonePtr Core::TerritoryMgr::getZoneByTerritoryTypeId( uint32_t territoryTy
|
|||
return zoneMap->second.begin()->second;
|
||||
}
|
||||
|
||||
Core::ZonePtr Core::TerritoryMgr::getZoneByLandSetId( uint32_t landSetId ) const
|
||||
{
|
||||
auto zoneMap = m_landSetIdToZonePtrMap.find( landSetId );
|
||||
if( zoneMap == m_landSetIdToZonePtrMap.end() )
|
||||
return nullptr;
|
||||
|
||||
return zoneMap->second;
|
||||
}
|
||||
|
||||
void Core::TerritoryMgr::updateTerritoryInstances( uint32_t currentTime )
|
||||
{
|
||||
for( auto& zone : m_zoneSet )
|
||||
|
@ -398,6 +407,17 @@ bool Core::TerritoryMgr::movePlayer( ZonePtr pZone, Core::Entity::PlayerPtr pPla
|
|||
|
||||
pPlayer->setTerritoryTypeId( pZone->getTerritoryTypeId() );
|
||||
|
||||
if( isHousingTerritory( pZone->getTerritoryTypeId() ) )
|
||||
{
|
||||
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pZone );
|
||||
if( pHousing )
|
||||
pPlayer->setTerritoryId( pHousing->getLandSetId() );
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->setTerritoryId( 0 );
|
||||
}
|
||||
|
||||
// mark character as zoning in progress
|
||||
pPlayer->setLoadingComplete( false );
|
||||
|
||||
|
|
|
@ -5,18 +5,20 @@
|
|||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Core {
|
||||
namespace Data {
|
||||
// TODO: this should actually not be here but should be generated in exdData aswell
|
||||
struct PlaceName;
|
||||
struct TerritoryType;
|
||||
struct InstanceContent;
|
||||
namespace Core::Data
|
||||
{
|
||||
// TODO: this should actually not be here but should be generated in exdData aswell
|
||||
struct PlaceName;
|
||||
struct TerritoryType;
|
||||
struct InstanceContent;
|
||||
|
||||
using PlaceNamePtr = std::shared_ptr< PlaceName >;
|
||||
using TerritoryTypePtr = std::shared_ptr< TerritoryType >;
|
||||
using InstanceContentPtr = std::shared_ptr< InstanceContent >;
|
||||
using PlaceNamePtr = std::shared_ptr< PlaceName >;
|
||||
using TerritoryTypePtr = std::shared_ptr< TerritoryType >;
|
||||
using InstanceContentPtr = std::shared_ptr< InstanceContent >;
|
||||
}
|
||||
|
||||
namespace Core
|
||||
{
|
||||
/*!
|
||||
\class TerritoryMgr_c
|
||||
\brief A class managing zones
|
||||
|
@ -115,6 +117,9 @@ public:
|
|||
/*! returns a default Zone by territoryTypeId
|
||||
TODO: Mind multiple instances?! */
|
||||
ZonePtr getZoneByTerritoryTypeId( uint32_t territoryTypeId ) const;
|
||||
|
||||
/*! returns a Zone by landSetId */
|
||||
ZonePtr getZoneByLandSetId( uint32_t landSetId ) const;
|
||||
|
||||
bool movePlayer( uint32_t territoryTypeId, Entity::PlayerPtr pPlayer );
|
||||
|
||||
|
@ -144,6 +149,7 @@ public:
|
|||
private:
|
||||
using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >;
|
||||
using InstanceIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >;
|
||||
using LandSetIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >;
|
||||
using TerritoryTypeIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||
using InstanceContentIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||
using PlayerIdToInstanceIdMap = std::unordered_map< uint32_t, uint32_t >;
|
||||
|
@ -156,6 +162,9 @@ private:
|
|||
/*! map holding actual instances of default territories */
|
||||
TerritoryTypeIdToInstanceMap m_territoryTypeIdToInstanceGuidMap;
|
||||
|
||||
/*! map holding actual instances of default territories */
|
||||
LandSetIdToZonePtrMap m_landSetIdToZonePtrMap;
|
||||
|
||||
/*! map holding actual instances of InstanceContent */
|
||||
InstanceContentIdToInstanceMap m_instanceContentToInstanceMap;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue