mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
updated pcb_reader to read territorytype from ffxivexplorer export
This commit is contained in:
parent
5913be0a31
commit
bd00132e43
2 changed files with 53 additions and 47 deletions
|
@ -5,10 +5,12 @@ compile with STANDALONE defined to compile without boost and sapphire dependenci
|
||||||
usage:
|
usage:
|
||||||
- regular
|
- regular
|
||||||
- compile with root sapphire dir cmakelists
|
- compile with root sapphire dir cmakelists
|
||||||
- sapphire/src/tools/bin/pcb_reader2 "<path/to/game/sqpack/ffxiv>" <territory>
|
- sapphire/src/tools/bin/pcb_reader2 <territory> "<path/to/game/sqpack/ffxiv>"
|
||||||
- standalone
|
- standalone
|
||||||
- compile main.cpp with STANDALONE defined in build arg
|
- compile main.cpp with STANDALONE defined in build arg
|
||||||
- download ffxivexplorer <http://ffxivexplorer.fragmenterworks.com/>
|
- download ffxivexplorer <http://ffxivexplorer.fragmenterworks.com/>
|
||||||
|
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/0a0000.dat
|
||||||
|
- exd/territorytype.exh > `File > Export` and copy `territorytype.exh.csv` from exproted directory to `pcb_reader.exe` directory
|
||||||
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/020000.dat
|
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/020000.dat
|
||||||
- ctrl click the following:
|
- ctrl click the following:
|
||||||
- `bg/ffxiv/[REGION]/common/collision`
|
- `bg/ffxiv/[REGION]/common/collision`
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include "pcb.h"
|
#include "pcb.h"
|
||||||
#include "lgb.h"
|
#include "lgb.h"
|
||||||
|
@ -84,39 +85,38 @@ int parseBlockEntry( char* data, std::vector<PCB_BLOCK_ENTRY>& entries, int gOff
|
||||||
|
|
||||||
std::string zoneNameToPath( const std::string& name )
|
std::string zoneNameToPath( const std::string& name )
|
||||||
{
|
{
|
||||||
char teri = name[0];
|
std::string path;
|
||||||
char region = name[1];
|
auto inFile = std::ifstream( "territorytype.exh.csv" );
|
||||||
char type = name[2];
|
if( inFile.good() )
|
||||||
char zone = name[3];
|
|
||||||
static std::map< char, std::string > teriMap
|
|
||||||
{
|
{
|
||||||
{ 'r', "roc" },
|
std::string line;
|
||||||
{ 'w', "wil" },
|
std::regex re("(\\d+),\"(.*)\",\"(.*)\",.*");
|
||||||
{ 'l', "lak" },
|
while( std::getline( inFile, line ) )
|
||||||
{ 'o', "ocn" },
|
{
|
||||||
{ 'f', "fst" },
|
std::smatch match;
|
||||||
{ 'a', "air" },
|
if( std::regex_match( line, match, re ) )
|
||||||
{ 's', "sea" },
|
{
|
||||||
{ 'z', "zon" }
|
if( name == match[2].str() )
|
||||||
};
|
{
|
||||||
|
path = match[3].str();
|
||||||
static std::map< char, std::string > typeMap
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !path.empty() )
|
||||||
{
|
{
|
||||||
{ 'f', "fld" },
|
//path = path.substr( path.find_first_of( "/" ) + 1, path.size() - path.find_first_of( "/" ));
|
||||||
{ 't', "twn" },
|
//path = std::string( "ffxiv/" ) + path;
|
||||||
{ 'd', "dun" },
|
path = std::string( "bg" ) + path.substr( 0, path.find( "/level/" ) );
|
||||||
{ 'b', "bah" },
|
std::cout << "[Info] " << "Found path for " << name << ": " << path << std::endl;
|
||||||
{ 'i', "ind" },
|
}
|
||||||
{ 'e', "evt" },
|
else
|
||||||
};
|
{
|
||||||
std::string ret;
|
throw std::runtime_error( "Unable to find path for " + name +
|
||||||
const auto& teriRet = teriMap[teri];
|
".\n\tPlease open 0a0000.win32.index with FFXIV Explorer and extract territorytype.exh as CSV\n\tand copy territorytype.exh.csv into pcb_reader.exe directory" );
|
||||||
const auto& typeRet = typeMap[type];
|
}
|
||||||
ret += teriRet + "_";
|
return path;
|
||||||
ret += teri;
|
|
||||||
ret += region;
|
|
||||||
ret += "/" + typeRet + "/" + name;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void readFileToBuffer( const std::string& path, std::vector< char >& buf )
|
void readFileToBuffer( const std::string& path, std::vector< char >& buf )
|
||||||
|
@ -141,24 +141,25 @@ int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
auto startTime = std::chrono::system_clock::now();
|
auto startTime = std::chrono::system_clock::now();
|
||||||
|
|
||||||
std::string gamePath = "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv";
|
// todo: support expansions
|
||||||
|
std::string gamePath = "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv";
|
||||||
std::string zoneName = "r1f1";
|
std::string zoneName = "r1f1";
|
||||||
|
|
||||||
if( argc > 1 )
|
if( argc > 1 )
|
||||||
{
|
{
|
||||||
gamePath = argv[1];
|
zoneName = argv[1];
|
||||||
if( argc > 2 )
|
if( argc > 2 )
|
||||||
{
|
{
|
||||||
zoneName = argv[2];
|
gamePath = argv[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto& zonePath = zoneNameToPath( zoneName );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string listPcbPath( "bg/ffxiv/" + zonePath + "/collision/list.pcb" );
|
const auto& zonePath = zoneNameToPath( zoneName );
|
||||||
std::string bgLgbPath( "bg/ffxiv/" + zonePath + "/level/bg.lgb" );
|
std::string listPcbPath( zonePath + "/collision/list.pcb" );
|
||||||
std::string collisionFilePath( "bg/ffxiv/" + zonePath + "/collision/" );
|
std::string bgLgbPath( zonePath + "/level/bg.lgb" );
|
||||||
|
std::string collisionFilePath( zonePath + "/collision/" );
|
||||||
std::vector< char > section;
|
std::vector< char > section;
|
||||||
std::vector< char > section1;
|
std::vector< char > section1;
|
||||||
|
|
||||||
|
@ -274,7 +275,7 @@ int main( int argc, char* argv[] )
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cout << "Unable to load collision mesh " << fileName << "\n\tError:\n\t" << e.what() << "\n";
|
std::cout << "[Error] " << "Unable to load collision mesh " << fileName << "\n\tError:\n\t" << e.what() << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -301,7 +302,7 @@ int main( int argc, char* argv[] )
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cout << "Unable to load SGB " << fileName << "\n\tError:\n\t" << e.what() << "\n";
|
std::cout << "[Error] " << "Unable to load SGB " << fileName << "\n\tError:\n\t" << e.what() << "\n";
|
||||||
sgbFiles.insert( std::make_pair( fileName, sgbFile ) );
|
sgbFiles.insert( std::make_pair( fileName, sgbFile ) );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -394,8 +395,8 @@ int main( int argc, char* argv[] )
|
||||||
loadPcbFile( fileName );
|
loadPcbFile( fileName );
|
||||||
pushVerts( pcbFiles[fileName], fileName );
|
pushVerts( pcbFiles[fileName], fileName );
|
||||||
}
|
}
|
||||||
std::cout << "Writing obj file " << "\n";
|
std::cout << "[Info] " << "Writing obj file " << "\n";
|
||||||
std::cout << bgLgb.groups.size() << " groups " << "\n";
|
std::cout << "[Info] " << bgLgb.groups.size() << " groups " << "\n";
|
||||||
uint32_t totalGroups = 0;
|
uint32_t totalGroups = 0;
|
||||||
uint32_t totalGroupEntries = 0;
|
uint32_t totalGroupEntries = 0;
|
||||||
for( const auto& group : bgLgb.groups )
|
for( const auto& group : bgLgb.groups )
|
||||||
|
@ -467,15 +468,18 @@ int main( int argc, char* argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "\n\nLoaded " << pcbFiles.size() << " PCB Files \n";
|
std::cout << "\n[Info] " << "Loaded " << pcbFiles.size() << " PCB Files \n";
|
||||||
std::cout << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n";
|
std::cout << "[Info] " << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n";
|
||||||
}
|
}
|
||||||
std::cout << "Finished exporting " << zoneName << " in " <<
|
std::cout << "[Success] " << "Finished exporting " << zoneName << " in " <<
|
||||||
std::chrono::duration_cast< std::chrono::seconds >( std::chrono::system_clock::now() - startTime ).count() << " seconds\n";
|
std::chrono::duration_cast< std::chrono::seconds >( std::chrono::system_clock::now() - startTime ).count() << " seconds\n";
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << "[Error] " << e.what() << std::endl;
|
||||||
|
std::cout << "[Error] " << "Unable to extract collision data.\n\tIf using standalone ensure your working directory folder layout is \n\tbg/[ffxiv|ex1|ex2]/teri/type/zone/[level|collision]" << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "[Info] " << "Usage: pcb_reader2 territory \"path/to/game/sqpack/ffxiv\" " << std::endl;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue