mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-30 16:17:46 +00:00
Merge pull request #166 from takhlaq/pcb_standalone
added -DSTANDALONE compile option for pcb_reader for compiling without xivdat/boost deps
This commit is contained in:
commit
3a11e3e8f3
2 changed files with 97 additions and 25 deletions
24
src/tools/pcb_reader/README.md
Normal file
24
src/tools/pcb_reader/README.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
collision data exporter for sapphire
|
||||
|
||||
compile with STANDALONE defined to compile without boost and sapphire dependencies
|
||||
|
||||
usage:
|
||||
- regular
|
||||
- compile with root sapphire dir cmakelists
|
||||
- sapphire/src/tools/bin/pcb_reader2 "<path/to/game/sqpack/ffxiv>" <territory>
|
||||
- standalone
|
||||
- compile main.cpp with STANDALONE defined in build arg
|
||||
- download ffxivexplorer <http://ffxivexplorer.fragmenterworks.com/>
|
||||
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/020000.dat
|
||||
- ctrl click the following:
|
||||
- `bg/ffxiv/[REGION]/common/collision`
|
||||
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/common/collision/`
|
||||
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/collision/`
|
||||
- `bg/ffxiv/region/shared/[for_bg|for_hou]/`
|
||||
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/ZONE/level/`
|
||||
- `bg/ffxiv/[REGION]/[dun|fld|twn|etc..]/ZONE/collision/`
|
||||
- `bgcommon/world/sys/shared/for_bg/`
|
||||
and `File > Export Raw` to pcb_reader exe dir (common and shared files are optional but you will be missing a lot of objects if you skip them)
|
||||
- note: at this time ffxivexplorer is still missing some hashes, though any tool which can export the exds should work fine
|
||||
- main "" <territory>
|
||||
|
|
@ -1,21 +1,23 @@
|
|||
#include <stdio.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
|
||||
#include "pcb.h"
|
||||
#include "lgb.h"
|
||||
#include "sgb.h"
|
||||
|
||||
#ifndef STANDALONE
|
||||
#include <GameData.h>
|
||||
#include <File.h>
|
||||
#include <DatCat.h>
|
||||
#include <ExdData.h>
|
||||
#include <ExdCat.h>
|
||||
#include <Exd.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <chrono>
|
||||
//#include <boost/algorithm/string.hpp>
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
@ -117,6 +119,24 @@ std::string zoneNameToPath( const std::string& name )
|
|||
return ret;
|
||||
}
|
||||
|
||||
void readFileToBuffer( const std::string& path, std::vector< char >& buf )
|
||||
{
|
||||
auto inFile = std::ifstream( path, std::ios::binary );
|
||||
if( inFile.good() )
|
||||
{
|
||||
inFile.seekg( 0, inFile.end );
|
||||
int32_t fileSize = inFile.tellg();
|
||||
buf.resize( fileSize );
|
||||
inFile.seekg( 0, inFile.beg );
|
||||
inFile.read( &buf[0], fileSize );
|
||||
inFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error( "Unable to open " + path );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
auto startTime = std::chrono::system_clock::now();
|
||||
|
@ -136,21 +156,35 @@ int main( int argc, char* argv[] )
|
|||
|
||||
try
|
||||
{
|
||||
std::string listPcbPath( "bg/ffxiv/" + zonePath + "/collision/list.pcb" );
|
||||
std::string bgLgbPath( "bg/ffxiv/" + zonePath + "/level/bg.lgb" );
|
||||
std::string collisionFilePath( "bg/ffxiv/" + zonePath + "/collision/" );
|
||||
std::vector< char > section;
|
||||
std::vector< char > section1;
|
||||
|
||||
#ifndef STANDALONE
|
||||
xiv::dat::GameData data1( gamePath );
|
||||
xiv::exd::ExdData eData( data1 );
|
||||
|
||||
const xiv::dat::Cat& test = data1.get_category( "bg" );
|
||||
|
||||
auto test_file = data1.get_file( "bg/ffxiv/" + zonePath + "/level/bg.lgb" );
|
||||
auto section = test_file->access_data_sections().at( 0 );
|
||||
auto test_file = data1.get_file( bgLgbPath );
|
||||
section = test_file->access_data_sections().at( 0 );
|
||||
|
||||
auto test_file1 = data1.get_file( listPcbPath );
|
||||
section1 = test_file1->access_data_sections().at( 0 );
|
||||
#else
|
||||
{
|
||||
readFileToBuffer( bgLgbPath, section );
|
||||
readFileToBuffer( listPcbPath, section1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t list_offset = *( uint32_t* )§ion[0x18];
|
||||
int32_t size = *( uint32_t* )§ion[4];
|
||||
|
||||
std::vector< std::string > stringList;
|
||||
|
||||
auto test_file1 = data1.get_file( "bg/ffxiv/" + zonePath + "/collision/list.pcb" );
|
||||
auto section1 = test_file1->access_data_sections().at( 0 );
|
||||
std::string path = "bg/ffxiv/" + zonePath + "/collision/";
|
||||
uint32_t offset1 = 0x20;
|
||||
for( ; ; )
|
||||
{
|
||||
|
@ -158,7 +192,7 @@ int main( int argc, char* argv[] )
|
|||
uint16_t trId = *(uint16_t*)§ion1[offset1];
|
||||
|
||||
char someString[200];
|
||||
sprintf( someString, "%str%04d.pcb", path.c_str(), trId );
|
||||
sprintf( someString, "%str%04d.pcb", collisionFilePath.c_str(), trId );
|
||||
stringList.push_back( std::string( someString ) );
|
||||
//std::cout << someString << "\n";
|
||||
offset1 += 0x20;
|
||||
|
@ -198,11 +232,17 @@ int main( int argc, char* argv[] )
|
|||
{
|
||||
try
|
||||
{
|
||||
char* dataSection = nullptr;
|
||||
//std::cout << fileName << " ";
|
||||
#ifndef STANDALONE
|
||||
auto file = data1.get_file( fileName );
|
||||
auto sections = file->get_data_sections();
|
||||
auto dataSection = §ions.at( 0 )[0];
|
||||
|
||||
dataSection = §ions.at( 0 )[0];
|
||||
#else
|
||||
std::vector< char > buf;
|
||||
readFileToBuffer( fileName, buf );
|
||||
dataSection = &buf[0];
|
||||
#endif
|
||||
//std::cout << sections.size() << "\n";
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
@ -244,9 +284,17 @@ int main( int argc, char* argv[] )
|
|||
SGB_FILE sgbFile;
|
||||
try
|
||||
{
|
||||
char* dataSection = nullptr;
|
||||
//std::cout << fileName << " ";
|
||||
#ifndef STANDALONE
|
||||
auto file = data1.get_file( fileName );
|
||||
auto sections = file->get_data_sections();
|
||||
auto dataSection = §ions.at( 0 )[0];
|
||||
dataSection = §ions.at( 0 )[0];
|
||||
#else
|
||||
std::vector< char > buf;
|
||||
readFileToBuffer( fileName, buf );
|
||||
dataSection = &buf[0];
|
||||
#endif
|
||||
sgbFile = SGB_FILE( &dataSection[0] );
|
||||
sgbFiles.insert( std::make_pair( fileName, sgbFile ) );
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue