2017-10-03 11:51:38 +02:00
|
|
|
|
|
|
|
#include <GameData.h>
|
|
|
|
#include <File.h>
|
|
|
|
#include <DatCat.h>
|
|
|
|
#include <ExdData.h>
|
|
|
|
#include <ExdCat.h>
|
|
|
|
#include <Exd.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cctype>
|
|
|
|
#include <set>
|
2018-10-25 12:21:22 +11:00
|
|
|
#include <Exd/ExdDataGenerated.h>
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Logging/Logger.h>
|
2018-10-25 12:21:22 +11:00
|
|
|
#include <algorithm>
|
2018-10-27 22:51:16 +02:00
|
|
|
#include <Util/Util.h>
|
2018-10-25 12:21:22 +11:00
|
|
|
|
2017-10-03 11:51:38 +02:00
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
|
|
Core::Logger g_log;
|
2018-10-25 12:21:22 +11:00
|
|
|
Core::Data::ExdDataGenerated g_exdData;
|
2017-10-03 11:51:38 +02:00
|
|
|
|
|
|
|
|
2017-11-18 01:25:55 +01:00
|
|
|
//const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
|
2018-08-29 21:40:59 +02:00
|
|
|
const std::string datLocation(
|
|
|
|
"C:\\Data\\Games\\Final Fantasy XIV\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
|
2017-10-03 11:51:38 +02:00
|
|
|
|
|
|
|
std::string generateEnum( const std::string& exd, int8_t nameIndex, const std::string& type, bool useLang = true )
|
|
|
|
{
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
xiv::dat::GameData data( datLocation );
|
|
|
|
xiv::exd::ExdData eData( data );
|
|
|
|
|
|
|
|
std::map< std::string, uint32_t > nameMap;
|
|
|
|
|
|
|
|
std::string result = "\n ///////////////////////////////////////////////////////////\n";
|
|
|
|
result += " //" + exd + ".exd\n";
|
|
|
|
result += " enum class " + exd + " : " + type + "\n";
|
|
|
|
result += " {\n";
|
|
|
|
auto lang = useLang ? xiv::exd::Language::en : xiv::exd::Language::none;
|
|
|
|
auto access = g_exdData.setupDatAccess( exd, lang );
|
|
|
|
auto rows = access.get_rows();
|
|
|
|
|
|
|
|
for( auto row : rows )
|
|
|
|
{
|
|
|
|
auto& fields = row.second;
|
|
|
|
uint32_t id = row.first;
|
2018-10-27 22:51:16 +02:00
|
|
|
|
|
|
|
std::string value;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
value = std::get< std::string >( fields.at( nameIndex ) );
|
|
|
|
}
|
|
|
|
catch( std::bad_variant_access& )
|
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
continue;
|
2018-10-27 22:51:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string remove = ",_-':!(){} \x02\x1f\x01\x03";
|
|
|
|
Core::Util::eraseAllIn( value, remove );
|
|
|
|
|
|
|
|
value[ 0 ] = std::toupper( value[ 0 ] );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-27 22:51:16 +02:00
|
|
|
auto it = nameMap.find( value );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( it != nameMap.end() )
|
|
|
|
{
|
2018-10-27 22:51:16 +02:00
|
|
|
nameMap[ value ]++;
|
|
|
|
value = value + std::to_string( nameMap[ value ] );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-27 22:51:16 +02:00
|
|
|
nameMap[ value ] = 0;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
2018-10-27 22:51:16 +02:00
|
|
|
result += " " + value + " = " + std::to_string( id ) + ",\n";
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
result +=
|
|
|
|
" bool operator==( const " + exd + "& t, const " + type + "& g ) { return static_cast< " + type + " >( t ) == g; }\n"
|
|
|
|
" bool operator==( const " + type + "& g, const " + exd + "& t ) { return static_cast< " + type + " >( t ) == g; }\n";
|
|
|
|
*/
|
|
|
|
|
|
|
|
result += " };\n";
|
|
|
|
|
|
|
|
return result;
|
2017-10-03 11:51:38 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
g_log.init();
|
|
|
|
|
|
|
|
|
|
|
|
g_log.info( "Setting up EXD data" );
|
|
|
|
if( !g_exdData.init( datLocation ) )
|
|
|
|
{
|
|
|
|
g_log.fatal( "Error setting up EXD data " );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string result = "#ifndef _COMMON_GEN_H_\n#define _COMMON_GEN_H_\n";
|
|
|
|
|
|
|
|
result += "\n#include <stdint.h>\n\n";
|
|
|
|
|
|
|
|
result +=
|
|
|
|
"/* This file has been automatically generated.\n Changes will be lost upon regeneration.\n To change the content edit tools/exd_common_gen */\n";
|
|
|
|
|
|
|
|
|
|
|
|
result += "namespace Core {\n";
|
|
|
|
result += "namespace Common {\n";
|
|
|
|
result += generateEnum( "ActionCategory", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "BeastReputationRank", 1, "uint8_t" );
|
|
|
|
result += generateEnum( "BeastTribe", 11, "uint8_t" );
|
|
|
|
result += generateEnum( "ClassJob", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "ContentType", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "EmoteCategory", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "ExVersion", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "GrandCompany", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "GuardianDeity", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "ItemUICategory", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "ItemSearchCategory", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "OnlineStatus", 2, "uint8_t" );
|
|
|
|
result += generateEnum( "Race", 1, "uint8_t" );
|
|
|
|
result += generateEnum( "Tribe", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "Town", 0, "uint8_t" );
|
|
|
|
result += generateEnum( "Weather", 1, "uint8_t" );
|
2018-11-20 17:15:23 +01:00
|
|
|
result += generateEnum( "HousingAppeal", 0, "uint8_t" );
|
2018-08-29 21:40:59 +02:00
|
|
|
result += "}\n";
|
|
|
|
result += "}\n#endif\n";
|
|
|
|
g_log.info( result );
|
|
|
|
return 0;
|
2017-10-03 11:51:38 +02:00
|
|
|
}
|