| 59 | |
| 60 | std::unordered_map< std::string, std::string > g_nameMap; |
| 61 | std::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 | |
| 103 | void loadEobjNames() |
| 104 | { |