mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57:44 +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 );
|
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( pTeriMgr->isHousingTerritory( zoneId ) )
|
||||||
|
{
|
||||||
|
pCurrZone = pTeriMgr->getZoneByLandSetId( m_territoryId );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
|
pCurrZone = pTeriMgr->getZoneByTerritoryTypeId( zoneId );
|
||||||
|
|
|
@ -100,6 +100,29 @@ bool Core::TerritoryMgr::isPrivateTerritory( uint32_t territoryTypeId ) const
|
||||||
pTeri->territoryIntendedUse == TerritoryIntendedUse::MSQPrivateArea;
|
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()
|
bool Core::TerritoryMgr::createDefaultTerritories()
|
||||||
{
|
{
|
||||||
|
@ -181,6 +204,7 @@ bool Core::TerritoryMgr::createHousingTerritories()
|
||||||
instanceMap[ guid ] = pHousingZone;
|
instanceMap[ guid ] = pHousingZone;
|
||||||
m_instanceIdToZonePtrMap[ guid ] = pHousingZone;
|
m_instanceIdToZonePtrMap[ guid ] = pHousingZone;
|
||||||
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ][ guid ] = pHousingZone;
|
m_territoryTypeIdToInstanceGuidMap[ territoryTypeId ][ guid ] = pHousingZone;
|
||||||
|
m_landSetIdToZonePtrMap[ pHousingZone->getLandSetId() ] = pHousingZone;
|
||||||
m_zoneSet.insert( { 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
|
Core::ZonePositionPtr Core::TerritoryMgr::getTerritoryPosition( uint32_t territoryPositionId ) const
|
||||||
{
|
{
|
||||||
auto it = m_territoryPositionMap.find( territoryPositionId );
|
auto it = m_territoryPositionMap.find( territoryPositionId );
|
||||||
|
@ -350,6 +350,15 @@ Core::ZonePtr Core::TerritoryMgr::getZoneByTerritoryTypeId( uint32_t territoryTy
|
||||||
return zoneMap->second.begin()->second;
|
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 )
|
void Core::TerritoryMgr::updateTerritoryInstances( uint32_t currentTime )
|
||||||
{
|
{
|
||||||
for( auto& zone : m_zoneSet )
|
for( auto& zone : m_zoneSet )
|
||||||
|
@ -398,6 +407,17 @@ bool Core::TerritoryMgr::movePlayer( ZonePtr pZone, Core::Entity::PlayerPtr pPla
|
||||||
|
|
||||||
pPlayer->setTerritoryTypeId( pZone->getTerritoryTypeId() );
|
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
|
// mark character as zoning in progress
|
||||||
pPlayer->setLoadingComplete( false );
|
pPlayer->setLoadingComplete( false );
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,20 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::Data
|
||||||
namespace Data {
|
{
|
||||||
// TODO: this should actually not be here but should be generated in exdData aswell
|
// TODO: this should actually not be here but should be generated in exdData aswell
|
||||||
struct PlaceName;
|
struct PlaceName;
|
||||||
struct TerritoryType;
|
struct TerritoryType;
|
||||||
struct InstanceContent;
|
struct InstanceContent;
|
||||||
|
|
||||||
using PlaceNamePtr = std::shared_ptr< PlaceName >;
|
using PlaceNamePtr = std::shared_ptr< PlaceName >;
|
||||||
using TerritoryTypePtr = std::shared_ptr< TerritoryType >;
|
using TerritoryTypePtr = std::shared_ptr< TerritoryType >;
|
||||||
using InstanceContentPtr = std::shared_ptr< InstanceContent >;
|
using InstanceContentPtr = std::shared_ptr< InstanceContent >;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
/*!
|
/*!
|
||||||
\class TerritoryMgr_c
|
\class TerritoryMgr_c
|
||||||
\brief A class managing zones
|
\brief A class managing zones
|
||||||
|
@ -115,6 +117,9 @@ public:
|
||||||
/*! returns a default Zone by territoryTypeId
|
/*! returns a default Zone by territoryTypeId
|
||||||
TODO: Mind multiple instances?! */
|
TODO: Mind multiple instances?! */
|
||||||
ZonePtr getZoneByTerritoryTypeId( uint32_t territoryTypeId ) const;
|
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 );
|
bool movePlayer( uint32_t territoryTypeId, Entity::PlayerPtr pPlayer );
|
||||||
|
|
||||||
|
@ -144,6 +149,7 @@ public:
|
||||||
private:
|
private:
|
||||||
using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >;
|
using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >;
|
||||||
using InstanceIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >;
|
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 TerritoryTypeIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||||
using InstanceContentIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
using InstanceContentIdToInstanceMap = std::unordered_map< uint16_t, InstanceIdToZonePtrMap >;
|
||||||
using PlayerIdToInstanceIdMap = std::unordered_map< uint32_t, uint32_t >;
|
using PlayerIdToInstanceIdMap = std::unordered_map< uint32_t, uint32_t >;
|
||||||
|
@ -156,6 +162,9 @@ private:
|
||||||
/*! map holding actual instances of default territories */
|
/*! map holding actual instances of default territories */
|
||||||
TerritoryTypeIdToInstanceMap m_territoryTypeIdToInstanceGuidMap;
|
TerritoryTypeIdToInstanceMap m_territoryTypeIdToInstanceGuidMap;
|
||||||
|
|
||||||
|
/*! map holding actual instances of default territories */
|
||||||
|
LandSetIdToZonePtrMap m_landSetIdToZonePtrMap;
|
||||||
|
|
||||||
/*! map holding actual instances of InstanceContent */
|
/*! map holding actual instances of InstanceContent */
|
||||||
InstanceContentIdToInstanceMap m_instanceContentToInstanceMap;
|
InstanceContentIdToInstanceMap m_instanceContentToInstanceMap;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue