diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 69904de5..01f78aad 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -25,3 +25,4 @@ add_subdirectory( "mob_parse" ) add_subdirectory( "pcb_reader" ) add_subdirectory( "nav_export" ) add_subdirectory( "event_object_parser" ) +add_subdirectory( "action_parse" ) diff --git a/src/tools/action_parse/CMakeLists.txt b/src/tools/action_parse/CMakeLists.txt new file mode 100644 index 00000000..6ba0bc47 --- /dev/null +++ b/src/tools/action_parse/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.6) +cmake_policy(SET CMP0015 NEW) +project(Tool_ActionParse) + +file(GLOB SERVER_PUBLIC_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*") +file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") + +add_executable( action_parse ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) + +if (UNIX) + target_link_libraries( action_parse common xivdat pthread mysqlclient dl z stdc++fs ) +else() + target_link_libraries( action_parse common xivdat mysql zlib) +endif() + diff --git a/src/tools/action_parse/main.cpp b/src/tools/action_parse/main.cpp new file mode 100644 index 00000000..74c496c3 --- /dev/null +++ b/src/tools/action_parse/main.cpp @@ -0,0 +1,135 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +Sapphire::Data::ExdDataGenerated g_exdData; + +using namespace Sapphire; + +const std::string datLocation( "/home/mordred/sqpack" ); +//const std::string datLocation( "/mnt/c/Program Files (x86)/Steam/steamapps/common/FINAL FANTASY XIV Online/game/sqpack" ); + +bool invalidChar( char c ) +{ + return !( c >= 0 && c < 128 ); +} +void stripUnicode( std::string& str ) +{ + str.erase( std::remove_if( str.begin(), str.end(), invalidChar ), str.end() ); + str.erase(std::remove_if(str.begin(), str.end(), + [](char c) { return !std::isalpha(c) && !std::isdigit(c) && !std::isspace(c) && !std::ispunct(c); }), + str.end()); +} + +int main() +{ + + Logger::init( "action_parse" ); + + Logger::info( "Setting up EXD data" ); + if( !g_exdData.init( datLocation ) ) + { + Logger::fatal( "Error setting up EXD data " ); + return 0; + } + auto idList = g_exdData.getActionIdList(); + + for( auto id : idList ) + { + auto gld = g_exdData.get< Sapphire::Data::Action >( id ); + auto gld1 = g_exdData.get< Sapphire::Data::ActionTransient >( id ); + if( gld ) + { + Logger::info( "got {0}", gld->name ); + std::string desc = gld1->description; + stripUnicode( desc );; + desc = std::regex_replace( desc, std::regex( "HI" ), "\n" ); + desc = std::regex_replace( desc, std::regex( "IH" ), "" ); +// Logger::info( "got {0}", desc ); + + std::smatch sm; + std::regex r(R"(with a potency of \d*)"); + if( std::regex_search(desc, sm, r ) ) + { + std::string potStr = sm.str(); + auto pos = potStr.find_last_of( " " ); + if( pos != std::string::npos ) + { + potStr = potStr.substr( pos + 1 ); + Logger::info( "Base Potency: {}", potStr); + } + } + + std::smatch sm1; + std::regex r1(R"(\d* when executed from a target's rear)"); + if( std::regex_search(desc, sm1, r1 ) ) + { + std::string potStr = sm1.str(); + auto pos = potStr.find_first_of( " " ); + if( pos != std::string::npos ) + { + potStr = potStr.substr( 0, pos ); + Logger::info( "Rear Potency: {}", potStr); + } + } + + std::smatch sm2; + std::regex r2(R"(\d* when executed from a target's flank)"); + if( std::regex_search(desc, sm2, r2 ) ) + { + std::string potStr = sm2.str(); + auto pos = potStr.find_first_of( " " ); + if( pos != std::string::npos ) + { + potStr = potStr.substr( 0, pos ); + Logger::info( "Flank Potency: {}", potStr); + } + } + + std::smatch sm3; + std::regex r3(R"(\d* when executed in front of target)"); + if( std::regex_search(desc, sm3, r3 ) ) + { + std::string potStr = sm3.str(); + auto pos = potStr.find_first_of( " " ); + if( pos != std::string::npos ) + { + potStr = potStr.substr( 0, pos ); + Logger::info( "Frontal Potency: {}", potStr); + } + } + + std::smatch sm4; + std::regex r4(R"(Combo Potency: \d*)"); + if( std::regex_search(desc, sm4, r4 ) ) + { + std::string potStr = sm4.str(); + auto pos = potStr.find_last_of( " " ); + if( pos != std::string::npos ) + { + potStr = potStr.substr( pos + 1 ); + Logger::info( "Combo Potency: {}", potStr); + } + } + + } + else + Logger::warn( "failed to get classjob {}", 1 ); + } + + return 0; +}