mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-12 05:27:45 +00:00
Removed extra qualifier
This commit is contained in:
parent
d10cb2e3e3
commit
11660773c2
1 changed files with 273 additions and 367 deletions
|
@ -9,84 +9,62 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <Exd/ExdDataGenerated.h>
|
#include <common/Exd/ExdData.h>
|
||||||
#include <Logging/Logger.h>
|
#include <common/Logging/Logger.h>
|
||||||
#include <filesystem>
|
#include <boost/range/algorithm/remove_if.hpp>
|
||||||
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include <nlohmann/json.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
|
#include <boost/property_tree/xml_parser.hpp>
|
||||||
|
#include <boost/property_tree/ptree.hpp>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace Sapphire;
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
Core::Logger g_log;
|
||||||
|
Core::Data::ExdData g_exdData;
|
||||||
Sapphire::Data::ExdDataGenerated g_exdData;
|
|
||||||
bool skipUnmapped = true;
|
bool skipUnmapped = true;
|
||||||
|
|
||||||
std::shared_ptr< xiv::dat::GameData > m_data;
|
//const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
|
||||||
std::shared_ptr< xiv::exd::ExdData > m_exd_data;
|
const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
|
||||||
|
|
||||||
std::map< char, std::string > numberToStringMap
|
|
||||||
{
|
|
||||||
{ '0', "zero" },
|
|
||||||
{ '1', "one" },
|
|
||||||
{ '2', "two" },
|
|
||||||
{ '3', "three" },
|
|
||||||
{ '4', "four" },
|
|
||||||
{ '5', "five" },
|
|
||||||
{ '6', "six" },
|
|
||||||
{ '7', "seven" },
|
|
||||||
{ '8', "eight" },
|
|
||||||
{ '9', "nine" },
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector< std::string > reservedWords
|
|
||||||
{
|
|
||||||
"new",
|
|
||||||
"class",
|
|
||||||
"long",
|
|
||||||
"short"
|
|
||||||
};
|
|
||||||
|
|
||||||
//std::string datLocation( "/home/mordred/sqpack" );
|
|
||||||
std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
|
|
||||||
std::map< uint8_t, std::string > g_typeMap;
|
std::map< uint8_t, std::string > g_typeMap;
|
||||||
|
|
||||||
|
|
||||||
std::string generateDatAccessDecl( const std::string& exd )
|
std::string generateDatAccessDecl( const std::string &exd )
|
||||||
{
|
{
|
||||||
return " xiv::exd::Exd m_" + exd + "Dat;\n";
|
return " xiv::exd::Exd m_" + exd + "Dat;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateIdListDecl( const std::string& exd )
|
std::string generateIdListDecl( const std::string &exd )
|
||||||
{
|
{
|
||||||
return " std::set< uint32_t > m_" + exd + "IdList;\n";
|
return " std::set< uint32_t > m_" + exd + "IdList;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateDirectGetters( const std::string& exd )
|
std::string generateDirectGetters( const std::string& exd )
|
||||||
{
|
{
|
||||||
return " using " + exd + "Ptr = std::shared_ptr< " + exd + " >;\n";
|
return " boost::shared_ptr< " + exd + " > get" + exd + "( uint32_t " + exd + "Id );\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateIdListGetter( const std::string& exd )
|
std::string generateIdListGetter( const std::string &exd )
|
||||||
{
|
{
|
||||||
std::string IdListGetter = "const std::set< uint32_t >& get" + exd + "IdList()\n"
|
std::string IdListGetter = "const std::set< uint32_t >& get" + exd + "IdList()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if( m_" + exd + "IdList.size() == 0 )\n"
|
" if( m_" + exd + "IdList.size() == 0 )\n"
|
||||||
" loadIdList( m_" +
|
" loadIdList( m_" + exd + "Dat, m_" + exd + "IdList );\n"
|
||||||
exd + "Dat, m_" + exd + "IdList );\n"
|
|
||||||
" return m_" + exd + "IdList;\n"
|
" return m_" + exd + "IdList;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
return IdListGetter;
|
return IdListGetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateSetDatAccessCall( const std::string& exd )
|
std::string generateSetDatAccessCall( const std::string &exd )
|
||||||
{
|
{
|
||||||
auto& cat = m_exd_data->get_category( exd );
|
auto& cat = g_exdData.m_exd_data->get_category( exd );
|
||||||
auto exh = cat.get_header();
|
auto exh = cat.get_header();
|
||||||
|
|
||||||
std::string lang = "xiv::exd::Language::none";
|
std::string lang = "xiv::exd::Language::none";
|
||||||
|
@ -97,12 +75,27 @@ std::string generateSetDatAccessCall( const std::string& exd )
|
||||||
return " m_" + exd + "Dat = setupDatAccess( \"" + exd + "\", " + lang + " );\n";
|
return " m_" + exd + "Dat = setupDatAccess( \"" + exd + "\", " + lang + " );\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateDirectGetterDef()
|
std::string generateDirectGetterDef( const std::string& exd )
|
||||||
{
|
{
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
result =
|
||||||
|
"boost::shared_ptr< Core::Data::" + exd + " >\n"
|
||||||
|
" get" + exd + "( uint32_t " + exd + "Id )\n"
|
||||||
|
"{\n"
|
||||||
|
" try\n"
|
||||||
|
" {\n"
|
||||||
|
" auto row = m_" + exd + "Dat.get_row( " + exd + "Id );\n"
|
||||||
|
" auto info = boost::make_shared< " + exd + " >( " + exd + "Id, this );\n"
|
||||||
|
" return info;\n"
|
||||||
|
" }\n"
|
||||||
|
" catch( ... )\n"
|
||||||
|
" {\n"
|
||||||
|
" return nullptr;\n"
|
||||||
|
" }\n"
|
||||||
|
" return nullptr;\n"
|
||||||
|
"}\n";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map< uint32_t, std::string > indexToNameMap;
|
std::map< uint32_t, std::string > indexToNameMap;
|
||||||
std::map< uint32_t, std::string > indexToTypeMap;
|
std::map< uint32_t, std::string > indexToTypeMap;
|
||||||
std::map< uint32_t, std::string > indexToTarget;
|
std::map< uint32_t, std::string > indexToTarget;
|
||||||
|
@ -111,35 +104,25 @@ std::map< uint32_t, uint32_t > indexCountMap;
|
||||||
|
|
||||||
std::map< std::string, std::string > nameTaken;
|
std::map< std::string, std::string > nameTaken;
|
||||||
|
|
||||||
std::string generateStruct( const std::string& exd )
|
std::string generateStruct( const std::string &exd )
|
||||||
{
|
{
|
||||||
auto& cat = m_exd_data->get_category( exd );
|
auto& cat = g_exdData.m_exd_data->get_category( exd );
|
||||||
auto exh = cat.get_header();
|
auto exh = cat.get_header();
|
||||||
auto exhMem = exh.get_exh_members();
|
auto exhMem = exh.get_exh_members();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
auto path = fmt::format( "Definitions/{}.json", exd );
|
using boost::property_tree::ptree;
|
||||||
if( !fs::exists( path ) )
|
ptree m_propTree;
|
||||||
{
|
boost::property_tree::read_json( "ex.json", m_propTree );
|
||||||
Logger::warn( "No definition for exd: {}", exd );
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sheet = nlohmann::json();
|
BOOST_FOREACH( boost::property_tree::ptree::value_type &sheet, m_propTree.get_child( "sheets" ) )
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
std::ifstream defJson( path );
|
std::string name = sheet.second.get< std::string >( "sheet" );
|
||||||
defJson >> sheet;
|
if( name != exd )
|
||||||
}
|
continue;
|
||||||
catch( const std::exception& ex )
|
|
||||||
{
|
|
||||||
Logger::error( "Failed parsing json definition, err: {} file: {}", ex.what(), path );
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
for( auto& definition : sheet[ "definitions" ] )
|
BOOST_FOREACH( boost::property_tree::ptree::value_type &show, sheet.second.get_child( "definitions" ) )
|
||||||
{
|
{
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
std::string converterTarget = "";
|
std::string converterTarget = "";
|
||||||
|
@ -147,47 +130,43 @@ std::string generateStruct( const std::string& exd )
|
||||||
int num = 0;
|
int num = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
index = definition.at( "index" );
|
index = show.second.get< uint32_t >("index");
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string fieldName = show.second.get< std::string >( "name" );
|
||||||
|
indexToNameMap[index] = fieldName;
|
||||||
|
}
|
||||||
|
catch( ... ) {}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string fieldName = std::string( definition.at( "name" ) );
|
converterTarget = show.second.get< std::string >( "converter.target" );
|
||||||
indexToNameMap[ index ] = fieldName;
|
|
||||||
}
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
converterTarget = std::string( definition.at( "converter" ).at( "target" ) );
|
|
||||||
if( nameTaken.find( converterTarget ) != nameTaken.end() )
|
if( nameTaken.find( converterTarget ) != nameTaken.end() )
|
||||||
indexToTarget[ index ] = converterTarget;
|
indexToTarget[index] = converterTarget;
|
||||||
}
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
catch( ... ) {}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
num = definition.at( "count" );
|
show.second.get< std::string >( "type" );
|
||||||
|
num = show.second.get< uint8_t >( "count" );
|
||||||
isRepeat = true;
|
isRepeat = true;
|
||||||
indexIsArrayMap[ index ] = true;
|
indexIsArrayMap[index] = true;
|
||||||
indexCountMap[ index ] = num;
|
indexCountMap[index] = num;
|
||||||
std::string fName = definition.at( "definition" ).at( "name" );
|
std::string fName = show.second.get< std::string >( "definition.name" );
|
||||||
indexToNameMap[ index ] = fName;
|
indexToNameMap[index] = fName;
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... ) {}
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string result = "struct " + exd + "\n{\n";
|
std::string result = "struct " + exd +"\n{\n";
|
||||||
|
|
||||||
|
|
||||||
for( auto member : exhMem )
|
for( auto member : exhMem )
|
||||||
|
@ -209,39 +188,18 @@ std::string generateStruct( const std::string& exd )
|
||||||
count++;
|
count++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
indexToNameMap[ count ] = fieldName;
|
indexToNameMap[count] = fieldName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fieldName = indexToNameMap[ count ];
|
fieldName = indexToNameMap[count];
|
||||||
}
|
}
|
||||||
fieldName[ 0 ] = std::tolower( fieldName[ 0 ] );
|
fieldName[0] = std::tolower( fieldName[0] );
|
||||||
|
fieldName.erase( boost::remove_if( fieldName, boost::is_any_of(",-':![](){}<>% \x02\x1f\x01\x03") ), fieldName.end() );
|
||||||
std::string badChars = ",-':![](){}/<>% \x02\x1f\x01\x03";
|
indexToNameMap[count] = fieldName;
|
||||||
std::for_each( badChars.begin(), badChars.end(), [ &fieldName ]( const char c )
|
indexToTypeMap[count] = type;
|
||||||
{
|
|
||||||
fieldName.erase( std::remove( fieldName.begin(), fieldName.end(), c ), fieldName.end() );
|
|
||||||
});
|
|
||||||
|
|
||||||
for( auto entry : numberToStringMap )
|
|
||||||
{
|
|
||||||
if( fieldName[ 0 ] == entry.first )
|
|
||||||
{
|
|
||||||
fieldName.erase( 0, 1 );
|
|
||||||
fieldName.insert( 0, entry.second );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for( std::string keyword : reservedWords )
|
|
||||||
{
|
|
||||||
if( fieldName == keyword )
|
|
||||||
fieldName = fmt::format( "_{}", fieldName );
|
|
||||||
}
|
|
||||||
|
|
||||||
indexToNameMap[ count ] = fieldName;
|
|
||||||
indexToTypeMap[ count ] = type;
|
|
||||||
if( indexToTarget.find( count ) != indexToTarget.end() )
|
if( indexToTarget.find( count ) != indexToTarget.end() )
|
||||||
result += " std::shared_ptr< " + indexToTarget[ count ] + "> " + fieldName + ";\n";
|
result += " boost::shared_ptr< " + indexToTarget[count] + "> " + fieldName + ";\n";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( indexIsArrayMap.find( count ) != indexIsArrayMap.end() )
|
if( indexIsArrayMap.find( count ) != indexIsArrayMap.end() )
|
||||||
|
@ -255,15 +213,7 @@ std::string generateStruct( const std::string& exd )
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto exhHead = exh.get_header();
|
result += "\n " + exd + "( uint32_t row_id, Core::Data::ExdDataGenerated* exdData );\n";
|
||||||
if( exhHead.variant == 2 )
|
|
||||||
{
|
|
||||||
result += "\n " + exd + "( uint32_t row_id, uint32_t subRow, Sapphire::Data::ExdDataGenerated* exdData );\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result += "\n " + exd + "( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData );\n";
|
|
||||||
}
|
|
||||||
result += "};\n\n";
|
result += "};\n\n";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -273,51 +223,36 @@ std::string generateConstructorsDecl( const std::string& exd )
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
auto& cat = m_exd_data->get_category( exd );
|
auto& cat = g_exdData.m_exd_data->get_category( exd );
|
||||||
auto exh = cat.get_header();
|
auto exh = cat.get_header();
|
||||||
auto exhMem = exh.get_exh_members();
|
auto exhMem = exh.get_exh_members();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
result += "\n Core::Data::" + exd + "::" + exd + "( uint32_t row_id, Core::Data::ExdDataGenerated* exdData )\n";
|
||||||
|
result += " {\n";
|
||||||
std::string indent = " ";
|
std::string indent = " ";
|
||||||
auto exhHead = exh.get_header();
|
|
||||||
if( exhHead.variant == 2 )
|
|
||||||
{
|
|
||||||
result += "\nSapphire::Data::" + exd + "::" + exd + "( uint32_t row_id, uint32_t subRow, Sapphire::Data::ExdDataGenerated* exdData )\n";
|
|
||||||
result += "{\n";
|
|
||||||
result += indent + "auto row = exdData->m_" + exd + "Dat.get_row( row_id, subRow );\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result += "\nSapphire::Data::" + exd + "::" + exd + "( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData )\n";
|
|
||||||
result += "{\n";
|
|
||||||
result += indent + "auto row = exdData->m_" + exd + "Dat.get_row( row_id );\n";
|
result += indent + "auto row = exdData->m_" + exd + "Dat.get_row( row_id );\n";
|
||||||
}
|
|
||||||
for( auto member : exhMem )
|
for( auto member : exhMem )
|
||||||
{
|
{
|
||||||
if( indexToNameMap.find( count ) == indexToNameMap.end() )
|
if( indexToNameMap.find( count ) == indexToNameMap.end() )
|
||||||
{
|
{ count++; continue; }
|
||||||
count++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( indexToTarget.find( count ) != indexToTarget.end() )
|
if( indexToTarget.find( count ) != indexToTarget.end() )
|
||||||
result += indent + indexToNameMap[ count ] + " = std::make_shared< " + indexToTarget[ count ] +
|
result += indent + indexToNameMap[count] + " = boost::make_shared< " + indexToTarget[count] + ">( exdData->getField< " +
|
||||||
">( exdData->getField< " +
|
indexToTypeMap[count] + " >( row, " + std::to_string( count ) + " ), exdData );\n";
|
||||||
indexToTypeMap[ count ] + " >( row, " + std::to_string( count ) + " ), exdData );\n";
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( indexIsArrayMap.find( count ) == indexIsArrayMap.end() )
|
if( indexIsArrayMap.find( count ) == indexIsArrayMap.end() )
|
||||||
result += indent + indexToNameMap[ count ] + " = exdData->getField< " + indexToTypeMap[ count ] + " >( row, " +
|
result += indent + indexToNameMap[count] + " = exdData->getField< " + indexToTypeMap[count] + " >( row, " + std::to_string( count ) + " );\n";
|
||||||
std::to_string( count ) + " );\n";
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
uint32_t amount = indexCountMap[ count ];
|
uint32_t amount = indexCountMap[count];
|
||||||
for( int i = 0; i < amount; i++ )
|
for( int i = 0; i < amount; i++ )
|
||||||
{
|
{
|
||||||
|
|
||||||
result += indent + indexToNameMap[ count ] + ".push_back( exdData->getField< " + indexToTypeMap[ count ] +
|
result += indent + indexToNameMap[count] + ".push_back( exdData->getField< " + indexToTypeMap[count] + " >( row, " + std::to_string( count + i ) + " ) );\n";
|
||||||
" >( row, " + std::to_string( count + i ) + " ) );\n";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +261,7 @@ std::string generateConstructorsDecl( const std::string& exd )
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
result += "}\n";
|
result += " }\n";
|
||||||
|
|
||||||
indexToNameMap.clear();
|
indexToNameMap.clear();
|
||||||
indexToTypeMap.clear();
|
indexToTypeMap.clear();
|
||||||
|
@ -336,43 +271,41 @@ std::string generateConstructorsDecl( const std::string& exd )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main()
|
||||||
{
|
{
|
||||||
Logger::init( "struct_gen" );
|
g_typeMap[0] = "std::string";
|
||||||
if( argc > 1 )
|
g_typeMap[1] = "bool";
|
||||||
{
|
g_typeMap[2] = "int8_t";
|
||||||
Logger::info( "using dat path: {0}", std::string( argv[ 1 ] ) );
|
g_typeMap[3] = "uint8_t";
|
||||||
datLocation = std::string( argv[ 1 ] );
|
g_typeMap[4] = "int16_t";
|
||||||
}
|
g_typeMap[5] = "uint16_t";
|
||||||
|
g_typeMap[6] = "int32_t";
|
||||||
|
g_typeMap[7] = "uint32_t";
|
||||||
g_typeMap[ 0 ] = "std::string";
|
g_typeMap[9] = "float";
|
||||||
g_typeMap[ 1 ] = "bool";
|
g_typeMap[11] = "uint64_t";
|
||||||
g_typeMap[ 2 ] = "int8_t";
|
|
||||||
g_typeMap[ 3 ] = "uint8_t";
|
|
||||||
g_typeMap[ 4 ] = "int16_t";
|
|
||||||
g_typeMap[ 5 ] = "uint16_t";
|
|
||||||
g_typeMap[ 6 ] = "int32_t";
|
|
||||||
g_typeMap[ 7 ] = "uint32_t";
|
|
||||||
g_typeMap[ 9 ] = "float";
|
|
||||||
g_typeMap[ 11 ] = "uint64_t";
|
|
||||||
|
|
||||||
std::ifstream t( "ExdData.h.tmpl" );
|
std::ifstream t( "ExdData.h.tmpl" );
|
||||||
std::string exdH( ( std::istreambuf_iterator< char >( t ) ),
|
std::string exdH( ( std::istreambuf_iterator<char>( t ) ),
|
||||||
std::istreambuf_iterator< char >() );
|
std::istreambuf_iterator<char>() );
|
||||||
|
|
||||||
std::ifstream s( "ExdData.cpp.tmpl" );
|
std::ifstream s( "ExdData.cpp.tmpl" );
|
||||||
std::string exdC( ( std::istreambuf_iterator< char >( s ) ),
|
std::string exdC( ( std::istreambuf_iterator<char>( s ) ),
|
||||||
std::istreambuf_iterator< char >() );
|
std::istreambuf_iterator<char>() );
|
||||||
|
|
||||||
|
|
||||||
Logger::info( "Setting up EXD data" );
|
using boost::property_tree::ptree;
|
||||||
|
ptree m_propTree;
|
||||||
|
boost::property_tree::read_json( "ex.json", m_propTree );
|
||||||
|
g_log.init();
|
||||||
|
|
||||||
m_data = std::make_shared< xiv::dat::GameData >( datLocation );
|
g_log.info( "Setting up EXD data" );
|
||||||
m_exd_data = std::make_shared< xiv::exd::ExdData >( *m_data );
|
if( !g_exdData.init( datLocation ) )
|
||||||
|
{
|
||||||
Logger::info( "Generating structs, this may take several minutes..." );
|
g_log.fatal( "Error setting up EXD data " );
|
||||||
Logger::info( "Go grab a coffee..." );
|
return 0;
|
||||||
|
}
|
||||||
|
g_log.info( "Generating structs, this may take several minutes..." );
|
||||||
|
g_log.info( "Go grab a coffee..." );
|
||||||
|
|
||||||
std::string structDefs;
|
std::string structDefs;
|
||||||
std::string idListsDecl;
|
std::string idListsDecl;
|
||||||
|
@ -386,50 +319,25 @@ int main( int argc, char** argv )
|
||||||
|
|
||||||
//BOOST_FOREACH( boost::property_tree::ptree::value_type &sheet, m_propTree.get_child( "sheets" ) )
|
//BOOST_FOREACH( boost::property_tree::ptree::value_type &sheet, m_propTree.get_child( "sheets" ) )
|
||||||
//{
|
//{
|
||||||
|
//std::string name = sheet.second.get< std::string >( "sheet" );
|
||||||
//nameTaken[name] = "1";
|
//nameTaken[name] = "1";
|
||||||
//}
|
//}
|
||||||
//
|
|
||||||
|
|
||||||
if( !fs::exists( "Definitions" ) )
|
BOOST_FOREACH( boost::property_tree::ptree::value_type &sheet, m_propTree.get_child( "sheets" ) )
|
||||||
{
|
{
|
||||||
Logger::error( "Missing definitions directory. Copy it from SaintCoinach to the working directory." );
|
std::string name = sheet.second.get< std::string >( "sheet" );
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& cats = m_exd_data->get_cat_names();
|
forwards += "struct " + name +";\n";
|
||||||
|
|
||||||
uint32_t entryCount = 0;
|
|
||||||
for( auto& entry : fs::directory_iterator( "./Definitions/" ) )
|
|
||||||
{
|
|
||||||
auto& path = entry.path();
|
|
||||||
|
|
||||||
if( path.extension() != ".json" )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto name = path.stem().string();
|
|
||||||
|
|
||||||
if( std::find( cats.begin(), cats.end(), name ) == cats.end() )
|
|
||||||
{
|
|
||||||
Logger::warn( "have definition for {} but the sheet doesn't exist", name );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
forwards += "struct " + name + ";\n";
|
|
||||||
structDefs += generateStruct( name );
|
structDefs += generateStruct( name );
|
||||||
dataDecl += generateDatAccessDecl( name );
|
dataDecl += generateDatAccessDecl( name );
|
||||||
idListsDecl += generateIdListDecl( name );
|
idListsDecl += generateIdListDecl( name );
|
||||||
getterDecl += generateDirectGetters( name );
|
getterDecl += generateDirectGetters( name );
|
||||||
datAccCall += generateSetDatAccessCall( name );
|
datAccCall += generateSetDatAccessCall( name );
|
||||||
|
getterDef += generateDirectGetterDef( name );
|
||||||
constructorDecl += generateConstructorsDecl( name );
|
constructorDecl += generateConstructorsDecl( name );
|
||||||
idListGetters += generateIdListGetter( name );
|
idListGetters += generateIdListGetter( name );
|
||||||
|
|
||||||
entryCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::info( "Processed {} definition files, writing files...", entryCount );
|
|
||||||
|
|
||||||
getterDef += generateDirectGetterDef();
|
|
||||||
|
|
||||||
// for all sheets in the json i guess....
|
// for all sheets in the json i guess....
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
|
@ -443,7 +351,7 @@ int main( int argc, char** argv )
|
||||||
|
|
||||||
// g_log.info( result );
|
// g_log.info( result );
|
||||||
|
|
||||||
std::ofstream outH( "ExdDataGenerated.h" );
|
std::ofstream outH("ExdDataGenerated.h");
|
||||||
outH << result;
|
outH << result;
|
||||||
outH.close();
|
outH.close();
|
||||||
|
|
||||||
|
@ -451,13 +359,11 @@ int main( int argc, char** argv )
|
||||||
result = std::regex_replace( result, std::regex( "\\DIRECTGETTERS" ), getterDef );
|
result = std::regex_replace( result, std::regex( "\\DIRECTGETTERS" ), getterDef );
|
||||||
result = std::regex_replace( result, std::regex( "\\CONSTRUCTORS" ), constructorDecl );
|
result = std::regex_replace( result, std::regex( "\\CONSTRUCTORS" ), constructorDecl );
|
||||||
|
|
||||||
std::ofstream outC( "ExdDataGenerated.cpp" );
|
std::ofstream outC("ExdDataGenerated.cpp");
|
||||||
outC << result;
|
outC << result;
|
||||||
outC.close();
|
outC.close();
|
||||||
|
|
||||||
// g_log.info( result );
|
// g_log.info( result );
|
||||||
|
|
||||||
Logger::info( "done." );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue