mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
fix exd generation with new separated definition files
This commit is contained in:
parent
3730ed74e7
commit
7ef93ea02f
1 changed files with 86 additions and 70 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <Exd/ExdDataGenerated.h>
|
#include <Exd/ExdDataGenerated.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
|
#include <experimental/filesystem>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
@ -21,6 +22,8 @@
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
|
|
||||||
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
Sapphire::Data::ExdDataGenerated g_exdData;
|
Sapphire::Data::ExdDataGenerated g_exdData;
|
||||||
bool skipUnmapped = true;
|
bool skipUnmapped = true;
|
||||||
|
|
||||||
|
@ -111,15 +114,16 @@ std::string generateStruct( const std::string& exd )
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
auto json = nlohmann::json();
|
auto path = fmt::format( "Definitions/{}.json", exd );
|
||||||
|
if( !fs::exists( path ) )
|
||||||
std::ifstream exJson( "ex.json" );
|
|
||||||
exJson >> json;
|
|
||||||
|
|
||||||
for( auto& sheet : json[ "sheets" ] )
|
|
||||||
{
|
{
|
||||||
if( sheet[ "sheet" ] != exd )
|
Logger::warn( "No definition for exd: {}", exd );
|
||||||
continue;
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sheet = nlohmann::json();
|
||||||
|
std::ifstream defJson( path );
|
||||||
|
defJson >> sheet;
|
||||||
|
|
||||||
for( auto& definition : sheet[ "definitions" ] )
|
for( auto& definition : sheet[ "definitions" ] )
|
||||||
{
|
{
|
||||||
|
@ -169,9 +173,6 @@ std::string generateStruct( const std::string& exd )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result = "struct " + exd + "\n{\n";
|
std::string result = "struct " + exd + "\n{\n";
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,11 +352,6 @@ int main( int argc, char** argv )
|
||||||
std::istreambuf_iterator< char >() );
|
std::istreambuf_iterator< char >() );
|
||||||
|
|
||||||
|
|
||||||
std::ifstream exJson( "ex.json" );
|
|
||||||
|
|
||||||
auto json = nlohmann::json();
|
|
||||||
exJson >> json;
|
|
||||||
|
|
||||||
Logger::info( "Setting up EXD data" );
|
Logger::info( "Setting up EXD data" );
|
||||||
if( !g_exdData.init( datLocation ) )
|
if( !g_exdData.init( datLocation ) )
|
||||||
{
|
{
|
||||||
|
@ -380,9 +376,25 @@ int main( int argc, char** argv )
|
||||||
//nameTaken[name] = "1";
|
//nameTaken[name] = "1";
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
for( auto& sheet : json[ "sheets" ] )
|
|
||||||
|
if( !fs::exists( "Definitions" ) )
|
||||||
{
|
{
|
||||||
std::string name = sheet[ "sheet" ];
|
Logger::error( "Missing definitions directory. Copy it from SaintCoinach to the working directory." );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t entryCount = 0;
|
||||||
|
for( auto& entry : fs::directory_iterator( "./Definitions/" ) )
|
||||||
|
{
|
||||||
|
auto& path = entry.path();
|
||||||
|
|
||||||
|
if( path.extension() != ".json" )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
entryCount++;
|
||||||
|
|
||||||
|
auto name = path.stem().string();
|
||||||
|
|
||||||
forwards += "struct " + name + ";\n";
|
forwards += "struct " + name + ";\n";
|
||||||
structDefs += generateStruct( name );
|
structDefs += generateStruct( name );
|
||||||
dataDecl += generateDatAccessDecl( name );
|
dataDecl += generateDatAccessDecl( name );
|
||||||
|
@ -393,6 +405,8 @@ int main( int argc, char** argv )
|
||||||
idListGetters += generateIdListGetter( name );
|
idListGetters += generateIdListGetter( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::info( "Processed {} definition files, writing files...", entryCount );
|
||||||
|
|
||||||
getterDecl +=
|
getterDecl +=
|
||||||
"\n template< class T >\n"
|
"\n template< class T >\n"
|
||||||
" std::shared_ptr< T > get( uint32_t id )\n"
|
" std::shared_ptr< T > get( uint32_t id )\n"
|
||||||
|
@ -438,5 +452,7 @@ int main( int argc, char** argv )
|
||||||
|
|
||||||
// g_log.info( result );
|
// g_log.info( result );
|
||||||
|
|
||||||
|
Logger::info( "done." );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue