mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-06-12 18:37:46 +00:00
use cache in getterritorydetail; remove unused bgpath; avoid throwing exceptions when possible;
This commit is contained in:
parent
4f3f866531
commit
d5c4739a77
2 changed files with 60 additions and 47 deletions
|
@ -77,12 +77,11 @@ uint32_t TerritoryMgr::getNextInstanceId()
|
|||
|
||||
Excel::ExcelStructPtr< Excel::TerritoryType > TerritoryMgr::getTerritoryDetail( uint32_t territoryTypeId ) const
|
||||
{
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
auto teri1 = exdData.getRow< Excel::TerritoryType >( territoryTypeId );
|
||||
if( !teri1 )
|
||||
auto it = m_territoryTypeDetailCacheMap.find( territoryTypeId );
|
||||
if( it == m_territoryTypeDetailCacheMap.end() )
|
||||
return nullptr;
|
||||
|
||||
return teri1;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool TerritoryMgr::isInstanceContentTerritory( uint32_t territoryTypeId ) const
|
||||
|
@ -198,8 +197,6 @@ bool TerritoryMgr::createDefaultTerritories()
|
|||
pPlaceName->getString( pPlaceName->data().Text.SGL ) );
|
||||
pZone->init();
|
||||
|
||||
std::string bgPath = territoryInfo->getString( territoryData.LVB );
|
||||
|
||||
bool hasNaviMesh = pZone->getNaviProvider() != nullptr;
|
||||
|
||||
Logger::info( "{0}\t{1}\t{2}\t{3:<10}\t{4}\t{5}\t{6}",
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include <ExdCat.h>
|
||||
#include <Exd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <execution>
|
||||
|
||||
#include <Logging/Logger.h>
|
||||
#include <Service.h>
|
||||
#include <Util/UtilMath.h>
|
||||
|
@ -22,7 +25,7 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
|
|||
auto idList = exdData.getIdList< Excel::TerritoryType >();
|
||||
|
||||
size_t count = 0;
|
||||
for( const auto& id : idList )
|
||||
std::for_each( std::execution::seq, idList.begin(), idList.end() , [ & ]( int id )
|
||||
{
|
||||
// show some loading indication...
|
||||
if( count++ % 10 == 0 )
|
||||
|
@ -30,12 +33,12 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
|
|||
|
||||
auto territoryType = exdData.getRow< Excel::TerritoryType >( id );
|
||||
if( !territoryType )
|
||||
continue;
|
||||
return;
|
||||
|
||||
auto path = territoryType->getString( territoryType->data().LVB );
|
||||
|
||||
if( path.empty() )
|
||||
continue;
|
||||
return;
|
||||
|
||||
path = std::string( "bg/" ) + path.substr( 0, path.find( "/level/" ) );
|
||||
|
||||
|
@ -56,14 +59,18 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
|
|||
|
||||
try
|
||||
{
|
||||
bgFile = exdData.getGameData()->getFile( bgLgbPath );
|
||||
if( exdData.getGameData()->doesFileExist( bgLgbPath ) )
|
||||
bgFile = exdData.getGameData()->getFile( bgLgbPath );
|
||||
else
|
||||
return;
|
||||
|
||||
planmap_file = exdData.getGameData()->getFile( planmapLgbPath );
|
||||
planevent_file = exdData.getGameData()->getFile( planeventLgbPath );
|
||||
}
|
||||
catch( std::runtime_error& )
|
||||
{
|
||||
// ignore files that aren't found
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
bgSection = bgFile->access_data_sections().at( 0 );
|
||||
|
@ -101,49 +108,58 @@ Sapphire::InstanceObjectCache::InstanceObjectCache()
|
|||
{
|
||||
for( const auto& pEntry : group.entries )
|
||||
{
|
||||
switch( pEntry->getType() )
|
||||
{
|
||||
case LgbEntryType::MapRange:
|
||||
{
|
||||
auto pMapRange = std::reinterpret_pointer_cast< LGB_MAP_RANGE_ENTRY >( pEntry );
|
||||
m_mapRangeCache.insert( id, pMapRange );
|
||||
|
||||
if( pEntry->getType() == LgbEntryType::MapRange )
|
||||
{
|
||||
auto pMapRange = std::reinterpret_pointer_cast< LGB_MAP_RANGE_ENTRY >( pEntry );
|
||||
m_mapRangeCache.insert( id, pMapRange );
|
||||
}
|
||||
else if( pEntry->getType() == LgbEntryType::ExitRange )
|
||||
{
|
||||
auto pExitRange = std::reinterpret_pointer_cast< LGB_EXIT_RANGE_ENTRY >( pEntry );
|
||||
m_exitRangeCache.insert( id, pExitRange );
|
||||
}
|
||||
else if( pEntry->getType() == LgbEntryType::PopRange )
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LgbEntryType::ExitRange:
|
||||
{
|
||||
auto pExitRange = std::reinterpret_pointer_cast< LGB_EXIT_RANGE_ENTRY >( pEntry );
|
||||
m_exitRangeCache.insert( id, pExitRange );
|
||||
|
||||
auto pPopRange = std::reinterpret_pointer_cast< LGB_POP_RANGE_ENTRY >( pEntry );
|
||||
m_popRangeCache.insert( id, pPopRange );
|
||||
}
|
||||
else if( pEntry->getType() == LgbEntryType::CollisionBox )
|
||||
{
|
||||
//auto pEObj = std::reinterpret_pointer_cast< LGB_ENPC_ENTRY >( pEntry );
|
||||
break;
|
||||
}
|
||||
case LgbEntryType::PopRange:
|
||||
{
|
||||
auto pPopRange = std::reinterpret_pointer_cast< LGB_POP_RANGE_ENTRY >( pEntry );
|
||||
m_popRangeCache.insert( id, pPopRange );
|
||||
break;
|
||||
}
|
||||
case LgbEntryType::CollisionBox:
|
||||
{
|
||||
//auto pEObj = std::reinterpret_pointer_cast< LGB_ENPC_ENTRY >( pEntry );
|
||||
|
||||
//Logger::debug( "CollisionBox {}", pEntry->header.nameOffset );
|
||||
}
|
||||
else if( pEntry->getType() == LgbEntryType::EventObject )
|
||||
{
|
||||
auto pEObj = std::reinterpret_pointer_cast< LGB_EOBJ_ENTRY >( pEntry );
|
||||
m_eobjCache.insert( id, pEObj );
|
||||
}
|
||||
else if( pEntry->getType() == LgbEntryType::EventNpc )
|
||||
{
|
||||
auto pENpc = std::reinterpret_pointer_cast< LGB_ENPC_ENTRY >( pEntry );
|
||||
m_enpcCache.insert( id, pENpc );
|
||||
}
|
||||
else if( pEntry->getType() == LgbEntryType::EventRange )
|
||||
{
|
||||
auto pEventRange = std::reinterpret_pointer_cast< LGB_EVENT_RANGE_ENTRY >( pEntry );
|
||||
m_eventRangeCache.insert( 0, pEventRange );
|
||||
//Logger::debug( "CollisionBox {}", pEntry->header.nameOffset );
|
||||
break;
|
||||
}
|
||||
case LgbEntryType::EventObject:
|
||||
{
|
||||
auto pEObj = std::reinterpret_pointer_cast< LGB_EOBJ_ENTRY >( pEntry );
|
||||
m_eobjCache.insert( id, pEObj );
|
||||
break;
|
||||
}
|
||||
case LgbEntryType::EventNpc:
|
||||
{
|
||||
auto pENpc = std::reinterpret_pointer_cast< LGB_ENPC_ENTRY >( pEntry );
|
||||
m_enpcCache.insert( id, pENpc );
|
||||
break;
|
||||
}
|
||||
case LgbEntryType::EventRange:
|
||||
{
|
||||
auto pEventRange = std::reinterpret_pointer_cast< LGB_EVENT_RANGE_ENTRY >( pEntry );
|
||||
m_eventRangeCache.insert( 0, pEventRange );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << "\n";
|
||||
} );
|
||||
|
||||
Logger::debug(
|
||||
"InstanceObjectCache Cached: MapRange: {} ExitRange: {} PopRange: {} EventObj: {} EventNpc: {} EventRange: {}",
|
||||
|
|
Loading…
Add table
Reference in a new issue