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

More cleanup of event_object_parser

This commit is contained in:
mordred 2019-04-11 13:23:01 +02:00
parent 13ce1b47d0
commit 2a3e0d7c19

View file

@ -59,14 +59,12 @@ std::vector< instanceContent > contentList;
std::set< std::string > zoneDumpList; std::set< std::string > zoneDumpList;
xiv::dat::GameData* data1 = nullptr; xiv::dat::GameData* data1 = nullptr;
xiv::exd::ExdData* eData = nullptr;
using namespace std::chrono_literals; using namespace std::chrono_literals;
void initExd( const std::string& gamePath ) void initExd( const std::string& gamePath )
{ {
data1 = data1 ? data1 : new xiv::dat::GameData( gamePath ); data1 = data1 ? data1 : new xiv::dat::GameData( gamePath );
eData = eData ? eData : new xiv::exd::ExdData( *data1 );
} }
int parseBlockEntry( char* data, std::vector< PCB_BLOCK_ENTRY >& entries, int gOff ) int parseBlockEntry( char* data, std::vector< PCB_BLOCK_ENTRY >& entries, int gOff )
@ -125,11 +123,16 @@ int parseBlockEntry( char* data, std::vector< PCB_BLOCK_ENTRY >& entries, int gO
return 0; return 0;
} }
std::unordered_map< std::string, std::string > g_nameMap;
std::string zoneNameToPath( const std::string& name ) std::string zoneNameToPath( const std::string& name )
{ {
std::string path; std::string path;
bool found = false; bool found = false;
auto it = g_nameMap.find( Sapphire::Util::toLowerCopy( name ) );
if( it != g_nameMap.end() )
return it->second;
auto teriIdList = g_exdData.getTerritoryTypeIdList(); auto teriIdList = g_exdData.getTerritoryTypeIdList();
for( auto teriId : teriIdList ) for( auto teriId : teriIdList )
{ {
@ -155,6 +158,7 @@ std::string zoneNameToPath( const std::string& name )
{ {
path = std::string( "bg/" ) + path.substr( 0, path.find( "/level/" ) ); path = std::string( "bg/" ) + path.substr( 0, path.find( "/level/" ) );
Logger::debug( "Found path for {0}: {1}", name, path ); Logger::debug( "Found path for {0}: {1}", name, path );
g_nameMap[ Sapphire::Util::toLowerCopy( name ) ] = path;
} }
else else
{ {
@ -166,16 +170,15 @@ std::string zoneNameToPath( const std::string& name )
void loadEobjNames() void loadEobjNames()
{ {
auto& cat = eData->get_category( "EObjName" ); auto nameIdList = g_exdData.getEObjNameIdList();
auto exd = static_cast< xiv::exd::Exd >( cat.get_data_ln( xiv::exd::Language::en ) ); for( auto id : nameIdList )
for( auto& row : exd.get_rows() )
{ {
auto id = row.first; auto eObjName = g_exdData.get< Sapphire::Data::EObjName >( id );
auto& fields = row.second; if( !eObjName )
auto name = std::get< std::string >( fields.at( 0 ) ); continue;
if( !name.empty() ) if( !eObjName->singular.empty() )
eobjNameMap[ id ] = name; eobjNameMap[ id ] = eObjName->singular;
} }
} }
@ -332,9 +335,7 @@ int main( int argc, char* argv[] )
} }
loadAllInstanceContentEntries(); loadAllInstanceContentEntries();
loadEobjNames();
auto& catQuestBattle = eData->get_category( "QuestBattle" );
auto questBattleData = static_cast< xiv::exd::Exd >( catQuestBattle.get_data_ln( xiv::exd::Language::none ) );
for( auto entry : contentList ) for( auto entry : contentList )
{ {
@ -366,7 +367,6 @@ int main( int argc, char* argv[] )
uint32_t offset1 = 0x20; uint32_t offset1 = 0x20;
loadEobjNames();
LGB_FILE bgLgb( &section[ 0 ], "bg" ); LGB_FILE bgLgb( &section[ 0 ], "bg" );
LGB_FILE planmapLgb( &section2[ 0 ], "planmap" ); LGB_FILE planmapLgb( &section2[ 0 ], "planmap" );
@ -576,14 +576,17 @@ int main( int argc, char* argv[] )
if( entry.id > 200 ) if( entry.id > 200 )
continue; continue;
auto qb = g_exdData.get< Sapphire::Data::QuestBattle >( entry.id );
if( !qb )
continue;
std::string instruction; std::string instruction;
auto row = questBattleData.get_row( entry.id );
for( int i = 0; i < 149; ++i ) for( int i = 0; i < 149; ++i )
{ {
if( std::get< std::string >( row.at( 4 + i ) ).empty() ) if( qb->scriptInstruction[ i ].empty() )
continue; continue;
instruction += " static constexpr auto " + std::get< std::string >( row.at( 4 + i ) ) + " = " + instruction += " static constexpr auto " + qb->scriptInstruction[ i ] + " = " +
std::to_string( std::get< uint32_t >( row.at( 154 + i ) ) )+ ";\n"; std::to_string( qb->scriptValue[ i ] ) + ";\n";
} }
result = std::regex_replace( result, std::regex( "\\SCRIPT_INSTRUCTIONS" ), instruction ); result = std::regex_replace( result, std::regex( "\\SCRIPT_INSTRUCTIONS" ), instruction );
@ -612,8 +615,6 @@ int main( int argc, char* argv[] )
// getchar(); // getchar();
if( eData )
delete eData;
if( data1 ) if( data1 )
delete data1; delete data1;
return 0; return 0;