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

Merge pull request #245 from takhlaq/pcb_reader

added instancecontent.csv dump to pcb_reader
This commit is contained in:
Mordred 2018-02-08 07:53:25 +01:00 committed by GitHub
commit aa9ca62e6b
2 changed files with 50 additions and 21 deletions

View file

@ -194,8 +194,9 @@ public:
struct LGB_MAPRANGE_HEADER : public LGB_ENTRY_HEADER struct LGB_MAPRANGE_HEADER : public LGB_ENTRY_HEADER
{ {
uint32_t type; uint32_t type;
uint32_t unknown2; uint16_t unknown2;
uint8_t unknown3[0x10]; uint16_t unknown3;
uint8_t unknown4[0x10];
}; };
struct LGB_MAPRANGE_ENTRY : public LGB_ENTRY struct LGB_MAPRANGE_ENTRY : public LGB_ENTRY

View file

@ -29,6 +29,7 @@ bool ignoreModels = false;
std::string gamePath( "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" ); std::string gamePath( "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
std::unordered_map< uint32_t, std::string > eobjNameMap; std::unordered_map< uint32_t, std::string > eobjNameMap;
std::unordered_map< uint16_t, std::string > zoneNameMap; std::unordered_map< uint16_t, std::string > zoneNameMap;
std::unordered_map< uint16_t, std::vector< std::pair< uint16_t, std::string > > > zoneInstanceMap;
uint32_t zoneId; uint32_t zoneId;
std::set< std::string > zoneDumpList; std::set< std::string > zoneDumpList;
@ -234,6 +235,7 @@ void writeEobjEntry( std::ofstream& out, LGB_ENTRY* pObj )
static std::string eobjStr( "\"EObj\", " ); static std::string eobjStr( "\"EObj\", " );
uint32_t id; uint32_t id;
uint32_t unknown = 0, unknown2 = 0;
std::string name; std::string name;
std::string typeStr; std::string typeStr;
@ -241,6 +243,7 @@ void writeEobjEntry( std::ofstream& out, LGB_ENTRY* pObj )
{ {
auto pEobj = reinterpret_cast< LGB_EOBJ_ENTRY* >( pObj ); auto pEobj = reinterpret_cast< LGB_EOBJ_ENTRY* >( pObj );
id = pEobj->header.eobjId; id = pEobj->header.eobjId;
unknown = pEobj->header.unknown;
name = eobjNameMap[id]; name = eobjNameMap[id];
typeStr = eobjStr; typeStr = eobjStr;
} }
@ -248,11 +251,13 @@ void writeEobjEntry( std::ofstream& out, LGB_ENTRY* pObj )
{ {
auto pMapRange = reinterpret_cast< LGB_MAPRANGE_ENTRY* >( pObj ); auto pMapRange = reinterpret_cast< LGB_MAPRANGE_ENTRY* >( pObj );
id = pMapRange->header.unknown; id = pMapRange->header.unknown;
unknown = pMapRange->header.unknown2;
unknown2 = pMapRange->header.unknown3;
typeStr = mapRangeStr; typeStr = mapRangeStr;
} }
std::string outStr( std::string outStr(
std::to_string( id ) + ", " + typeStr + "\"" + name + "\", " + std::to_string( id ) + ", " + typeStr + "\"" + name + "\", " + std::to_string( unknown ) + ", " + std::to_string( unknown2 ) + ", " +
std::to_string( pObj->header.translation.x ) + ", " + std::to_string( pObj->header.translation.y ) + ", " + std::to_string( pObj->header.translation.z ) + "\n" std::to_string( pObj->header.translation.x ) + ", " + std::to_string( pObj->header.translation.y ) + ", " + std::to_string( pObj->header.translation.z ) + "\n"
); );
out.write( outStr.c_str(), outStr.size() ); out.write( outStr.c_str(), outStr.size() );
@ -268,6 +273,18 @@ void loadAllInstanceContentEntries()
zoneNameToPath( "f1d1" ); zoneNameToPath( "f1d1" );
} }
std::ofstream out( "instancecontent.csv", std::ios::trunc );
if( out.good() )
{
out.close();
}
out.open( "instancecontent.csv", std::ios::app );
if( !out.good() )
{
throw std::runtime_error( "Unable to create instancecontent.csv!" );
}
std::cout << "[Info] Writing instancecontent.csv\n";
for( auto& row : exdInstance.get_rows() ) for( auto& row : exdInstance.get_rows() )
{ {
auto id = row.first; auto id = row.first;
@ -276,12 +293,18 @@ void loadAllInstanceContentEntries()
auto name = *boost::get< std::string >( &fields.at( 3 ) ); auto name = *boost::get< std::string >( &fields.at( 3 ) );
if( name.empty() ) if( name.empty() )
continue; continue;
auto teri = *boost::get< uint32_t >( &fields.at( 7 ) ); auto teri = *boost::get< uint32_t >( &fields.at( 9 ) );
auto i = 0; auto i = 0;
while( ( i = name.find( ' ' ) ) != std::string::npos ) while( ( i = name.find( ' ' ) ) != std::string::npos )
name = name.replace( name.begin() + i, name.begin() + i + 1, { '_' } ); name = name.replace( name.begin() + i, name.begin() + i + 1, { '_' } );
std::string outStr(
std::to_string( id ) + ", \"" + name + "\", \"" + zoneNameMap[teri] + "\"," + std::to_string( teri ) + "\n"
);
out.write( outStr.c_str(), outStr.size() );
//zoneInstanceMap[zoneId].push_back( std::make_pair( id, name ) );
zoneDumpList.emplace( zoneNameMap[teri] ); zoneDumpList.emplace( zoneNameMap[teri] );
} }
out.close();
} }
void readFileToBuffer( const std::string& path, std::vector< char >& buf ) void readFileToBuffer( const std::string& path, std::vector< char >& buf )
@ -389,23 +412,25 @@ LABEL_DUMP:
if( !eobjOut.good() ) if( !eobjOut.good() )
throw std::string( "Unable to create " + zoneName + "_eobj.csv for eobj entries. Run as admin or check there isnt already a handle on the file." ).c_str(); throw std::string( "Unable to create " + zoneName + "_eobj.csv for eobj entries. Run as admin or check there isnt already a handle on the file." ).c_str();
for( ; ; ) if( !ignoreModels )
{ {
for( ; ; )
uint16_t trId = *(uint16_t*)&section1[offset1];
char someString[200];
sprintf( someString, "%str%04d.pcb", collisionFilePath.c_str(), trId );
stringList.push_back( std::string( someString ) );
//std::cout << someString << "\n";
offset1 += 0x20;
if( offset1 >= section1.size() )
{ {
break;
uint16_t trId = *(uint16_t*)&section1[offset1];
char someString[200];
sprintf( someString, "%str%04d.pcb", collisionFilePath.c_str(), trId );
stringList.push_back( std::string( someString ) );
//std::cout << someString << "\n";
offset1 += 0x20;
if( offset1 >= section1.size() )
{
break;
}
} }
} }
LGB_FILE bgLgb( &section[0], "bg" ); LGB_FILE bgLgb( &section[0], "bg" );
LGB_FILE planmapLgb( &section2[0], "planmap" ); LGB_FILE planmapLgb( &section2[0], "planmap" );
@ -603,10 +628,13 @@ LABEL_DUMP:
} }
}; };
for( const auto& fileName : stringList ) if( !ignoreModels )
{ {
loadPcbFile( fileName ); for( const auto& fileName : stringList )
pushVerts( pcbFiles[fileName], fileName ); {
loadPcbFile( fileName );
pushVerts( pcbFiles[fileName], fileName );
}
} }
std::cout << "[Info] " << ( ignoreModels ? "Dumping MapRange and EObj" : "Writing obj file " ) << "\n"; std::cout << "[Info] " << ( ignoreModels ? "Dumping MapRange and EObj" : "Writing obj file " ) << "\n";
@ -685,7 +713,7 @@ LABEL_DUMP:
if( pEntry->getType() == LgbEntryType::EventObject || pEntry->getType() == LgbEntryType::MapRange ) if( pEntry->getType() == LgbEntryType::EventObject || pEntry->getType() == LgbEntryType::MapRange )
{ {
writeEobjEntry( eobjOut, pEntry.get() ); writeEobjEntry( eobjOut, pEntry.get() );
//writeOutput( fileName, &pEventObj->header.scale, &pEventObj->header.rotation, &pEventObj->header.translation ); writeOutput( fileName, &pEntry->header.scale, &pEntry->header.rotation, &pEntry->header.translation );
} }
} }
} }