From caf82976333bd3990cac76b1eff5d08711f8884f Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 11 Apr 2019 22:18:18 +1000 Subject: [PATCH] correctly load all lgb entries even if there's no struct for them --- deps/datReader/DatCategories/bg/lgb.h | 7 +-- src/tools/exd_struct_test/main.cpp | 86 +++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/deps/datReader/DatCategories/bg/lgb.h b/deps/datReader/DatCategories/bg/lgb.h index 89105fea..50097735 100644 --- a/deps/datReader/DatCategories/bg/lgb.h +++ b/deps/datReader/DatCategories/bg/lgb.h @@ -252,7 +252,7 @@ public: struct LGB_GROUP_HEADER { - uint32_t unknown; + uint32_t id; int32_t groupNameOffset; int32_t entriesOffset; int32_t entryCount; @@ -310,12 +310,11 @@ struct LGB_GROUP { entries.push_back( std::make_shared< LGB_MAPRANGE_ENTRY >( buf, entryOffset ) ); } - /* else { - entries[i] = nullptr; + entries.push_back( std::make_shared< LGB_ENTRY >( buf, entryOffset ) ); } - */ + } catch( std::exception& e ) diff --git a/src/tools/exd_struct_test/main.cpp b/src/tools/exd_struct_test/main.cpp index 1a524ae8..88ad0d46 100644 --- a/src/tools/exd_struct_test/main.cpp +++ b/src/tools/exd_struct_test/main.cpp @@ -56,6 +56,49 @@ void exportFile( const std::string& path ) } } +const std::string getTypeString( uint32_t type ) +{ + switch( type ) + { + case 1: return "BgParts"; + case 3: return "Light"; + case 4: return "Vfx"; + case 5: return "PositionMarker"; + case 6: return "Gimmick/SharedGroup6"; + case 7: return "Sound"; + case 8: return "EventNpc"; + case 9: return "BattleNpc"; + case 12: return "Aetheryte"; + case 13: return "EnvSpace"; + case 14: return "Gathering"; + case 15: return "SharedGroup15"; + case 16: return "Treasure"; + case 39: return "Weapon"; + case 40: return "PopRange"; + case 41: return "ExitRange"; + case 43: return "MapRange"; + case 44: return "NaviMeshRange"; + case 45: return "EventObject"; + case 47: return "EnvLocation"; + case 49: return "EventRange"; + case 51: return "QuestMarker"; + case 57: return "CollisionBox"; + case 58: return "DoorRange"; + case 59: return "LineVfx"; + case 65: return "ClientPath"; + case 66: return "ServerPath"; + case 67: return "GimmickRange"; + case 68: return "TargetMarker"; + case 69: return "ChairMarker"; + case 70: return "ClickableRange"; + case 71: return "PrefetchRange"; + case 72: return "FateRange"; + case 75: return "SphereCastRange"; + + default: return ""; + } +} + struct DupeResult { std::string groupName; @@ -93,6 +136,7 @@ int main( int argc, char* argv[] ) std::vector< uint32_t > lgbGroupIds; std::vector< DupeResult > lgbGroupDupes; + std::vector< uint32_t > foundTypes; paths.emplace_back( "level/bg.lgb" ); paths.emplace_back( "level/planmap.lgb" ); @@ -137,15 +181,36 @@ int main( int argc, char* argv[] ) for( const auto& group : lgb.groups ) { - Logger::info( " - {:<7} {:<25} children: {}", group.header.unknown, group.name, group.header.entryCount ); + std::vector< uint32_t > types; - if( std::find( lgbGroupIds.begin(), lgbGroupIds.end(), group.header.unknown ) == lgbGroupIds.end() ) + for( const auto& entry : group.entries ) { - lgbGroupIds.emplace_back( group.header.unknown ); + types.emplace_back( static_cast< uint32_t >( entry->getType() ) ); + } + + std::string typeStr; + + std::sort( types.begin(), types.end() ); + auto end = std::unique( types.begin(), types.end() ); + types.erase( end, types.end() ); + + foundTypes.insert( foundTypes.end(), types.begin(), types.end() ); + + for( auto type : types ) + { + typeStr.append( " " + std::to_string( type ) ); + } + + Logger::info( " - {:<7} {:<25} groups: {:<3} types:{}", + group.header.id, group.name, group.header.entryCount, typeStr ); + + if( std::find( lgbGroupIds.begin(), lgbGroupIds.end(), group.header.id ) == lgbGroupIds.end() ) + { + lgbGroupIds.emplace_back( group.header.id ); } else { - lgbGroupDupes.push_back( { group.name, filePath, group.header.unknown } ); + lgbGroupDupes.push_back( { group.name, filePath, group.header.id } ); } } Logger::info( "" ); @@ -163,9 +228,20 @@ int main( int argc, char* argv[] ) for( const auto& result : lgbGroupDupes ) { - Logger::info( " - file: {:<50} group: {:<30} id: {}", result.lgb, result.groupName, result.id ); + Logger::info( " - id: {:<7} group: {:<30} file: {} ", result.id, result.groupName, result.lgb ); } } + Logger::info( "Found LGB entry types:" ); + + std::sort( foundTypes.begin(), foundTypes.end() ); + auto end = std::unique( foundTypes.begin(), foundTypes.end() ); + foundTypes.erase( end, foundTypes.end() ); + + for( auto type : foundTypes ) + { + Logger::info( " - {:<3} {}", type, getTypeString( type ) ); + } + return 0; }