1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

update generated exd data, fix formatting outputted by exd_struct_gen

This commit is contained in:
NotAdam 2019-06-15 20:56:19 +10:00
parent 6cb3e787ef
commit 19e325dcba
6 changed files with 8209 additions and 7914 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,5 @@
#include "ExdDataGenerated.h"
#include <boost/make_shared.hpp>
#include <boost/variant.hpp>
#include <memory>
CONSTRUCTORS
Sapphire::Data::ExdDataGenerated::ExdDataGenerated()
@ -16,37 +12,37 @@ Sapphire::Data::ExdDataGenerated::~ExdDataGenerated()
xiv::exd::Exd Sapphire::Data::ExdDataGenerated::setupDatAccess( const std::string& name, xiv::exd::Language lang )
{
auto& cat = m_exd_data->get_category( name );
return static_cast< xiv::exd::Exd >( cat.get_data_ln( lang ) );
auto& cat = m_exd_data->get_category( name );
return static_cast< xiv::exd::Exd >( cat.get_data_ln( lang ) );
};
void Sapphire::Data::ExdDataGenerated::loadIdList( xiv::exd::Exd& data, std::set< uint32_t >& outIdList )
{
auto pDataRows = data.get_rows();
auto pDataRows = data.get_rows();
for( auto row : pDataRows )
{
uint32_t id = row.first;
outIdList.insert( id );
}
for( auto row : pDataRows )
{
uint32_t id = row.first;
outIdList.insert( id );
}
}
bool Sapphire::Data::ExdDataGenerated::init( const std::string& path )
{
try
{
m_data = std::make_shared< xiv::dat::GameData >( path );
m_exd_data = std::make_shared< xiv::exd::ExdData >( *m_data );
try
{
m_data = std::make_shared< xiv::dat::GameData >( path );
m_exd_data = std::make_shared< xiv::exd::ExdData >( *m_data );
SETUPDATACCESS
}
catch( std::runtime_error )
{
return false;
}
}
catch( std::runtime_error )
{
return false;
}
return true;
return true;
}
///////////////////////////////////////////////////////////////

View file

@ -25,23 +25,53 @@ STRUCTS
class ExdDataGenerated
{
public:
ExdDataGenerated();
~ExdDataGenerated();
ExdDataGenerated();
~ExdDataGenerated();
bool init( const std::string& path );
bool init( const std::string& path );
xiv::exd::Exd setupDatAccess( const std::string& name, xiv::exd::Language lang );
xiv::exd::Exd setupDatAccess( const std::string& name, xiv::exd::Language lang );
template< class T >
T getField( std::vector< xiv::exd::Field >& fields, uint32_t index )
{
return std::get< T >( fields.at( index ) );
}
template< class T >
T getField( std::vector< xiv::exd::Field >& fields, uint32_t index )
{
return std::get< T >( fields.at( index ) );
}
void loadIdList( xiv::exd::Exd& data, std::set< uint32_t >& outIdList );
void loadIdList( xiv::exd::Exd& data, std::set< uint32_t >& outIdList );
std::shared_ptr< xiv::dat::GameData > m_data;
std::shared_ptr< xiv::exd::ExdData > m_exd_data;
std::shared_ptr< xiv::dat::GameData > m_data;
std::shared_ptr< xiv::exd::ExdData > m_exd_data;
template< class T >
std::shared_ptr< T > get( uint32_t id )
{
try
{
auto info = std::make_shared< T >( id, this );
return info;
}
catch( ... )
{
return nullptr;
}
return nullptr;
}
template< class T >
std::shared_ptr< T > get( uint32_t id, uint32_t slotId )
{
try
{
auto info = std::make_shared< T >( id, slotId, this );
return info;
}
catch( ... )
{
return nullptr;
}
return nullptr;
}
DATACCESS

View file

@ -41,10 +41,12 @@ std::map< char, std::string > numberToStringMap
{ '9', "nine" },
};
std::vector< std::string > cppKeyWords
std::vector< std::string > reservedWords
{
"new",
"class"
"class",
"long",
"short"
};
//std::string datLocation( "/home/mordred/sqpack" );
@ -89,7 +91,7 @@ std::string generateSetDatAccessCall( const std::string& exd )
if( langs.size() > 1 )
lang = "xiv::exd::Language::en";
return " m_" + exd + "Dat = setupDatAccess( \"" + exd + "\", " + lang + " );\n";
return " m_" + exd + "Dat = setupDatAccess( \"" + exd + "\", " + lang + " );\n";
}
std::string generateDirectGetterDef()
@ -203,7 +205,7 @@ std::string generateStruct( const std::string& exd )
}
fieldName[ 0 ] = std::tolower( fieldName[ 0 ] );
std::string badChars = ",-':![](){}<>% \x02\x1f\x01\x03";
std::string badChars = ",-':![](){}/<>% \x02\x1f\x01\x03";
std::for_each( badChars.begin(), badChars.end(), [ &fieldName ]( const char c )
{
fieldName.erase( std::remove( fieldName.begin(), fieldName.end(), c ), fieldName.end() );
@ -218,23 +220,23 @@ std::string generateStruct( const std::string& exd )
}
}
for( std::string keyword : cppKeyWords )
for( std::string keyword : reservedWords )
{
if( fieldName == keyword )
fieldName[ 0 ] = toupper( fieldName[ 0 ] );
fieldName = fmt::format( "_{}", fieldName );
}
indexToNameMap[ count ] = fieldName;
indexToTypeMap[ count ] = type;
if( indexToTarget.find( count ) != indexToTarget.end() )
result += " std::shared_ptr< " + indexToTarget[ count ] + "> " + fieldName + ";\n";
result += " std::shared_ptr< " + indexToTarget[ count ] + "> " + fieldName + ";\n";
else
{
if( indexIsArrayMap.find( count ) != indexIsArrayMap.end() )
{
type = "std::vector< " + type + " >";
}
result += " " + type + " " + fieldName + ";\n";
result += " " + type + " " + fieldName + ";\n";
}
@ -244,11 +246,11 @@ std::string generateStruct( const std::string& exd )
auto exhHead = exh.get_header();
if( exhHead.variant == 2 )
{
result += "\n " + exd + "( uint32_t row_id, uint32_t subRow, Sapphire::Data::ExdDataGenerated* exdData );\n";
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 " + exd + "( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData );\n";
}
result += "};\n\n";
@ -265,7 +267,7 @@ std::string generateConstructorsDecl( const std::string& exd )
int count = 0;
std::string indent = " ";
std::string indent = " ";
auto exhHead = exh.get_header();
if( exhHead.variant == 2 )
{
@ -407,22 +409,6 @@ int main( int argc, char** argv )
Logger::info( "Processed {} definition files, writing files...", entryCount );
getterDecl +=
"\n template< class T >\n"
" std::shared_ptr< T > get( uint32_t id )\n"
" {\n"
" try\n"
" {\n"
" auto info = std::make_shared< T >( id, this );\n"
" return info;\n"
" }\n"
" catch( ... )\n"
" {\n"
" return nullptr;\n"
" }\n"
" return nullptr;\n"
" }\n";
getterDef += generateDirectGetterDef();
// for all sheets in the json i guess....

View file

@ -99,8 +99,8 @@ bool Action::Action::init()
}
}
m_primaryCostType = static_cast< Common::ActionPrimaryCostType >( m_actionData->costType );
m_primaryCost = m_actionData->cost;
m_primaryCostType = static_cast< Common::ActionPrimaryCostType >( m_actionData->primaryCostType );
m_primaryCost = m_actionData->primaryCostValue;
/*if( !m_actionData->targetArea )
{