MCPcopy Create free account
hub / github.com/SapphireServer/Sapphire / zoneNameToPath

Function zoneNameToPath

src/tools/event_object_parser/main.cpp:61–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60std::unordered_map< std::string, std::string > g_nameMap;
61std::string zoneNameToPath( const std::string& name )
62{
63 std::string path;
64
65 auto it = g_nameMap.find( Common::Util::toLowerCopy( name ) );
66 if( it != g_nameMap.end() )
67 return it->second;
68
69 auto teriIdList = g_exdData.getTerritoryTypeIdList();
70 for( auto teriId : teriIdList )
71 {
72 auto teri = g_exdData.get< Sapphire::Data::TerritoryType >( teriId );
73 if( !teri )
74 continue;
75
76 auto teriName = teri->name;
77 auto teriPath = teri->bg;
78
79 if( teriName.empty() )
80 continue;
81
82 if( Common::Util::toLowerCopy( name ) == Common::Util::toLowerCopy( teriName ) )
83 {
84 path = teriPath;
85 break;
86 }
87 }
88
89 if( !path.empty() )
90 {
91 path = std::string( "bg/" ) + path.substr( 0, path.find( "/level/" ) );
92 Logger::debug( "Found path for {0}: {1}", name, path );
93 g_nameMap[ Common::Util::toLowerCopy( name ) ] = path;
94 }
95 else
96 {
97 throw std::runtime_error( "Unable to find path for " + name );
98 }
99
100 return path;
101}
102
103void loadEobjNames()
104{

Callers 1

mainFunction · 0.70

Calls 2

endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected