From 0cac614b962dfb6544fa45b94e8d0202f32cc555 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Tue, 23 Jan 2018 13:13:35 +0000 Subject: [PATCH] reenabled pcb_reader build, removed dumb requirement of territorytype extraction on xivdat build for pcb_reader --- CMakeLists.txt | 2 +- src/tools/pcb_reader/main.cpp | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fe6f474..b30cf137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,6 @@ add_subdirectory("src/tools/exd_common_gen") add_subdirectory("src/tools/exd_struct_gen") add_subdirectory("src/tools/exd_struct_test") add_subdirectory("src/tools/quest_parser") -#add_subdirectory("src/tools/pcb_reader") +add_subdirectory("src/tools/pcb_reader") add_subdirectory("scripts/native") diff --git a/src/tools/pcb_reader/main.cpp b/src/tools/pcb_reader/main.cpp index 91d36963..77276c40 100644 --- a/src/tools/pcb_reader/main.cpp +++ b/src/tools/pcb_reader/main.cpp @@ -17,9 +17,15 @@ #include #include #include -//#include +#include #endif +enum class TerritoryTypeExdIndexes : size_t +{ + TerritoryType = 0, + Path = 1 +}; + std::string gamePath( "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" ); using namespace std::chrono_literals; @@ -88,6 +94,7 @@ int parseBlockEntry( char* data, std::vector& entries, int gOff std::string zoneNameToPath( const std::string& name ) { std::string path; +#ifdef STANDALONE auto inFile = std::ifstream( "territorytype.exh.csv" ); if( inFile.good() ) { @@ -107,6 +114,26 @@ std::string zoneNameToPath( const std::string& name ) } inFile.close(); } +#else + xiv::dat::GameData dat( gamePath ); + xiv::exd::ExdData eData( dat ); + auto& cat = eData.get_category( "TerritoryType" ); + auto exd = static_cast< xiv::exd::Exd >( cat.get_data_ln( xiv::exd::Language::none ) ); + for( auto& row : exd.get_rows() ) + { + auto& fields = row.second; + auto teriName = *boost::get< std::string >( &fields.at( static_cast< size_t >( TerritoryTypeExdIndexes::TerritoryType ) ) ); + if( teriName.empty() ) + continue; + auto teriPath = *boost::get< std::string >( &fields.at( static_cast< size_t >( TerritoryTypeExdIndexes::Path ) ) ); + if( boost::iequals( name, teriName ) ) + { + path = teriPath; + break; + } + } +#endif + if( !path.empty() ) { //path = path.substr( path.find_first_of( "/" ) + 1, path.size() - path.find_first_of( "/" ));