1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

Array support in exd generator

This commit is contained in:
Mordred Admin 2017-10-13 14:45:14 +02:00
parent 3088d1b66d
commit e490d0c28c
2 changed files with 47 additions and 11 deletions

View file

@ -31,8 +31,8 @@ Core::Logger g_log;
Core::Data::ExdData g_exdData; Core::Data::ExdData g_exdData;
bool skipUnmapped = true; bool skipUnmapped = true;
//const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" ); const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" ); //const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
std::map< uint8_t, std::string > g_typeMap; std::map< uint8_t, std::string > g_typeMap;
@ -56,7 +56,7 @@ std::string generateSetDatAccessCall( const std::string &exd )
if( langs.size() > 1 ) if( langs.size() > 1 )
lang = "xiv::exd::Language::en"; lang = "xiv::exd::Language::en";
return " m_" + exd + "Dat = setupDatAccess( \"" + exd + "\", " + lang + " );"; return " m_" + exd + "Dat = setupDatAccess( \"" + exd + "\", " + lang + " );\n";
} }
std::string generateDirectGetterDef( const std::string& exd ) std::string generateDirectGetterDef( const std::string& exd )
@ -70,22 +70,21 @@ std::string generateDirectGetterDef( const std::string& exd )
" {\n" " {\n"
" auto row = m_" + exd + "Dat.get_row( " + exd + "Id );\n" " auto row = m_" + exd + "Dat.get_row( " + exd + "Id );\n"
" auto info = boost::make_shared< " + exd + " >( " + exd + "Id, this );\n" " auto info = boost::make_shared< " + exd + " >( " + exd + "Id, this );\n"
" return info;\n" " return info;\n"
" }\n" " }\n"
" catch( ... )\n" " catch( ... )\n"
" {\n" " {\n"
" return nullptr;\n" " return nullptr;\n"
" }\n" " }\n"
" return nullptr;\n" " return nullptr;\n"
"}\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;
std::map< uint32_t, bool > indexIsArrayMap;
std::map< uint32_t, uint32_t > indexCountMap;
std::map< std::string, std::string > nameTaken; std::map< std::string, std::string > nameTaken;
@ -111,6 +110,8 @@ std::string generateStruct( const std::string &exd )
{ {
uint32_t index; uint32_t index;
std::string converterTarget = ""; std::string converterTarget = "";
bool isRepeat = false;
int num = 0;
try try
{ {
index = show.second.get< uint32_t >("index"); index = show.second.get< uint32_t >("index");
@ -133,8 +134,18 @@ std::string generateStruct( const std::string &exd )
indexToTarget[index] = converterTarget; indexToTarget[index] = converterTarget;
} }
catch( ... ) {} catch( ... ) {}
try
{
show.second.get< std::string >( "type" );
num = show.second.get< uint8_t >( "count" );
isRepeat = true;
indexIsArrayMap[index] = true;
indexCountMap[index] = num;
std::string fName = show.second.get< std::string >( "definition.name" );
indexToNameMap[index] = fName;
}
catch( ... ) {}
} }
} }
@ -174,7 +185,14 @@ std::string generateStruct( const std::string &exd )
if( indexToTarget.find( count ) != indexToTarget.end() ) if( indexToTarget.find( count ) != indexToTarget.end() )
result += " boost::shared_ptr< " + indexToTarget[count] + "> " + fieldName + ";\n"; result += " boost::shared_ptr< " + indexToTarget[count] + "> " + fieldName + ";\n";
else else
{
if( indexIsArrayMap.find( count ) != indexIsArrayMap.end() )
{
type = "std::vector< " + type + " >";
}
result += " " + type + " " + fieldName + ";\n"; result += " " + type + " " + fieldName + ";\n";
}
count++; count++;
} }
@ -208,7 +226,23 @@ std::string generateConstructorsDecl( const std::string& exd )
result += indent + indexToNameMap[count] + " = boost::make_shared< " + indexToTarget[count] + ">( exdData->getField< " + result += indent + indexToNameMap[count] + " = boost::make_shared< " + indexToTarget[count] + ">( exdData->getField< " +
indexToTypeMap[count] + " >( row, " + std::to_string( count ) + " ), exdData );\n"; indexToTypeMap[count] + " >( row, " + std::to_string( count ) + " ), exdData );\n";
else else
result += indent + indexToNameMap[count] + " = exdData->getField< " + indexToTypeMap[count] + " >( row, " + std::to_string( count ) + " );\n"; {
if( indexIsArrayMap.find( count ) == indexIsArrayMap.end() )
result += indent + indexToNameMap[count] + " = exdData->getField< " + indexToTypeMap[count] + " >( row, " + std::to_string( count ) + " );\n";
else
{
uint32_t amount = indexCountMap[count];
for( int i = 0; i < amount; i++ )
{
result += indent + indexToNameMap[count] + ".push_back( exdData->getField< " + indexToTypeMap[count] + " >( row, " + std::to_string( count + i ) + " ) );\n";
}
}
}
count++; count++;
} }
result += " }\n"; result += " }\n";
@ -216,6 +250,8 @@ std::string generateConstructorsDecl( const std::string& exd )
indexToNameMap.clear(); indexToNameMap.clear();
indexToTypeMap.clear(); indexToTypeMap.clear();
indexToTarget.clear(); indexToTarget.clear();
indexIsArrayMap.clear();
indexCountMap.clear();
return result; return result;
} }

View file

@ -25,8 +25,8 @@ Core::Logger g_log;
Core::Data::ExdDataGenerated g_exdData; Core::Data::ExdDataGenerated g_exdData;
//const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" ); const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" ); //const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
int main() int main()