From da4f4cdd157401f85d4c92f5390d7012e79d9234 Mon Sep 17 00:00:00 2001 From: mordred Date: Mon, 15 Apr 2019 17:32:51 +0200 Subject: [PATCH] More cleanup for event object parser --- src/tools/event_object_parser/main.cpp | 29 ++++++++++---------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/tools/event_object_parser/main.cpp b/src/tools/event_object_parser/main.cpp index 155587e2..8e1c8a4e 100644 --- a/src/tools/event_object_parser/main.cpp +++ b/src/tools/event_object_parser/main.cpp @@ -50,11 +50,11 @@ struct instanceContent }; std::vector< instanceContent > contentList; -xiv::dat::GameData* data1 = nullptr; +xiv::dat::GameData* g_gameData = nullptr; void initExd( const std::string& gamePath ) { - data1 = data1 ? data1 : new xiv::dat::GameData( gamePath ); + g_gameData = g_gameData ? g_gameData : new xiv::dat::GameData( gamePath ); } std::unordered_map< std::string, std::string > g_nameMap; @@ -237,23 +237,16 @@ int main( int argc, char* argv[] ) try { const auto& zonePath = zoneNameToPath( zoneName ); - - std::string listPcbPath( zonePath + "/collision/list.pcb" ); std::string bgLgbPath( zonePath + "/level/bg.lgb" ); std::string planmapLgbPath( zonePath + "/level/planmap.lgb" ); - std::string collisionFilePath( zonePath + "/collision/" ); - std::vector< char > section; - std::vector< char > section2; - const xiv::dat::Cat& test = data1->getCategory( "bg" ); + auto bgFile = g_gameData->getFile( bgLgbPath ); + auto planmapFile = g_gameData->getFile( planmapLgbPath ); + auto bgData = bgFile->access_data_sections().at( 0 ); + auto planmapData = planmapFile->access_data_sections().at( 0 ); - auto test_file = data1->getFile( bgLgbPath ); - auto planmap_file = data1->getFile( planmapLgbPath ); - section = test_file->access_data_sections().at( 0 ); - section2 = planmap_file->access_data_sections().at( 0 ); - - LGB_FILE bgLgb( §ion[ 0 ], "bg" ); - LGB_FILE planmapLgb( §ion2[ 0 ], "planmap" ); + LGB_FILE bgLgb( &bgData[ 0 ], "bg" ); + LGB_FILE planmapLgb( &planmapData[ 0 ], "planmap" ); std::vector< LGB_FILE > lgbList{ bgLgb, planmapLgb }; @@ -298,7 +291,7 @@ int main( int argc, char* argv[] ) auto pGObjR = reinterpret_cast< LGB_GIMMICK_ENTRY* >( pGObj ); char* dataSection = nullptr; - auto file = data1->getFile( pGObjR->gimmickFileName ); + auto file = g_gameData->getFile( pGObjR->gimmickFileName ); auto sections = file->get_data_sections(); dataSection = §ions.at( 0 )[ 0 ]; auto sgbFile = SGB_FILE( &dataSection[ 0 ] ); @@ -434,7 +427,7 @@ int main( int argc, char* argv[] ) Logger::info( "Finished all tasks in {} seconds", std::chrono::duration_cast< std::chrono::seconds >( std::chrono::system_clock::now() - startTime ).count() ); - if( data1 ) - delete data1; + if( g_gameData ) + delete g_gameData; return 0; }