mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-12 21:47:45 +00:00
loads of datreader cleanup/consistency fixes
This commit is contained in:
parent
b7ddb054f4
commit
5f18c43dd6
27 changed files with 1727 additions and 1734 deletions
65
deps/datReader/Dat.cpp
vendored
65
deps/datReader/Dat.cpp
vendored
|
@ -4,14 +4,11 @@
|
||||||
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const uint32_t model_section_count = 0xB;
|
const uint32_t model_section_count = 0xB;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
struct DatFileHeader
|
struct DatFileHeader
|
||||||
{
|
{
|
||||||
|
@ -63,15 +60,9 @@ namespace dat
|
||||||
uint32_t block_id;
|
uint32_t block_id;
|
||||||
uint32_t block_count;
|
uint32_t block_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::bparse
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace bparse
|
|
||||||
{
|
{
|
||||||
template<>
|
template<>
|
||||||
inline void reorder< xiv::dat::DatFileHeader >( xiv::dat::DatFileHeader& i_struct )
|
inline void reorder< xiv::dat::DatFileHeader >( xiv::dat::DatFileHeader& i_struct )
|
||||||
|
@ -79,7 +70,10 @@ namespace bparse
|
||||||
xiv::utils::bparse::reorder( i_struct.size );
|
xiv::utils::bparse::reorder( i_struct.size );
|
||||||
xiv::utils::bparse::reorder( i_struct.entry_type );
|
xiv::utils::bparse::reorder( i_struct.entry_type );
|
||||||
xiv::utils::bparse::reorder( i_struct.total_uncompressed_size );
|
xiv::utils::bparse::reorder( i_struct.total_uncompressed_size );
|
||||||
for (int32_t i = 0; i < 0x2; ++i) { xiv::utils::bparse::reorder(i_struct.unknown[i]); }
|
for( int32_t i = 0; i < 0x2; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.unknown[ i ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -87,7 +81,10 @@ namespace bparse
|
||||||
{
|
{
|
||||||
xiv::utils::bparse::reorder( i_struct.offset );
|
xiv::utils::bparse::reorder( i_struct.offset );
|
||||||
xiv::utils::bparse::reorder( i_struct.size );
|
xiv::utils::bparse::reorder( i_struct.size );
|
||||||
for (int32_t i = 0; i < 0x4; ++i) { xiv::utils::bparse::reorder(i_struct.unknown[i]); }
|
for( int32_t i = 0; i < 0x4; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.unknown[ i ] );
|
||||||
|
}
|
||||||
xiv::utils::bparse::reorder( i_struct.block_hash );
|
xiv::utils::bparse::reorder( i_struct.block_hash );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,12 +109,30 @@ namespace bparse
|
||||||
inline void reorder< xiv::dat::DatMdlFileBlockInfos >( xiv::dat::DatMdlFileBlockInfos& i_struct )
|
inline void reorder< xiv::dat::DatMdlFileBlockInfos >( xiv::dat::DatMdlFileBlockInfos& i_struct )
|
||||||
{
|
{
|
||||||
xiv::utils::bparse::reorder( i_struct.unknown1 );
|
xiv::utils::bparse::reorder( i_struct.unknown1 );
|
||||||
for (auto i = 0; i < ::model_section_count; ++i) { xiv::utils::bparse::reorder(i_struct.uncompressed_sizes[i]); }
|
for( auto i = 0; i < ::model_section_count; ++i )
|
||||||
for (auto i = 0; i < ::model_section_count; ++i) { xiv::utils::bparse::reorder(i_struct.compressed_sizes[i]); }
|
{
|
||||||
for (auto i = 0; i < ::model_section_count; ++i) { xiv::utils::bparse::reorder(i_struct.offsets[i]); }
|
xiv::utils::bparse::reorder( i_struct.uncompressed_sizes[ i ] );
|
||||||
for (auto i = 0; i < ::model_section_count; ++i) { xiv::utils::bparse::reorder(i_struct.block_ids[i]); }
|
}
|
||||||
for (auto i = 0; i < ::model_section_count; ++i) { xiv::utils::bparse::reorder(i_struct.block_counts[i]); }
|
for( auto i = 0; i < ::model_section_count; ++i )
|
||||||
for (auto i = 0; i < 0x2; ++i) { xiv::utils::bparse::reorder(i_struct.unknown2[i]); }
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.compressed_sizes[ i ] );
|
||||||
|
}
|
||||||
|
for( auto i = 0; i < ::model_section_count; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.offsets[ i ] );
|
||||||
|
}
|
||||||
|
for( auto i = 0; i < ::model_section_count; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.block_ids[ i ] );
|
||||||
|
}
|
||||||
|
for( auto i = 0; i < ::model_section_count; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.block_counts[ i ] );
|
||||||
|
}
|
||||||
|
for( auto i = 0; i < 0x2; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.unknown2[ i ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -130,14 +145,10 @@ namespace bparse
|
||||||
xiv::utils::bparse::reorder( i_struct.block_count );
|
xiv::utils::bparse::reorder( i_struct.block_count );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using xiv::utils::bparse::extract;
|
using xiv::utils::bparse::extract;
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Dat::Dat( const std::filesystem::path& i_path, uint32_t i_nb ) :
|
Dat::Dat( const std::filesystem::path& i_path, uint32_t i_nb ) :
|
||||||
|
@ -266,7 +277,8 @@ std::unique_ptr<File> Dat::getFile( uint32_t i_offset )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid entry_type: " + std::to_string(static_cast<uint32_t>(file_header.entry_type)));
|
throw std::runtime_error(
|
||||||
|
"Invalid entry_type: " + std::to_string( static_cast<uint32_t>(file_header.entry_type) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,4 +320,3 @@ uint32_t Dat::getNum() const
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
5
deps/datReader/Dat.h
vendored
5
deps/datReader/Dat.h
vendored
|
@ -7,9 +7,7 @@
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
|
@ -39,7 +37,6 @@ protected:
|
||||||
uint32_t m_num;
|
uint32_t m_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_DAT_DAT_H
|
#endif // XIV_DAT_DAT_H
|
||||||
|
|
6
deps/datReader/DatCat.cpp
vendored
6
deps/datReader/DatCat.cpp
vendored
|
@ -26,7 +26,7 @@ Cat::Cat( const std::filesystem::path& basePath, uint32_t catNum, const std::str
|
||||||
// For all dat files linked to this index, create it: XX0000.win32.datX
|
// For all dat files linked to this index, create it: XX0000.win32.datX
|
||||||
for( uint32_t i = 0; i < getIndex().getDatCount(); ++i )
|
for( uint32_t i = 0; i < getIndex().getDatCount(); ++i )
|
||||||
{
|
{
|
||||||
m_dats.emplace_back( std::unique_ptr<Dat>( new Dat( basePath / "ffxiv" / ( prefix + ".dat" + std::to_string( i ) ), i ) ) );
|
m_dats.emplace_back( std::make_unique< Dat >(basePath / "ffxiv" / ( prefix + ".dat" + std::to_string( i ) ), i ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,12 @@ Cat::Cat( const std::filesystem::path& basePath, uint32_t catNum, const std::str
|
||||||
m_chunk( chunk )
|
m_chunk( chunk )
|
||||||
{
|
{
|
||||||
// Creates the index: XX0000.win32.index
|
// Creates the index: XX0000.win32.index
|
||||||
m_index = std::unique_ptr<Index>( new Index( basePath / GameData::buildDatStr( "ex" + std::to_string( exNum ), catNum, exNum, chunk, "win32", "index" ) ) );
|
m_index = std::make_unique< Index >( basePath / GameData::buildDatStr( "ex" + std::to_string( exNum ), catNum, exNum, chunk, "win32", "index" ) );
|
||||||
|
|
||||||
// For all dat files linked to this index, create it: XX0000.win32.datX
|
// For all dat files linked to this index, create it: XX0000.win32.datX
|
||||||
for( uint32_t i = 0; i < getIndex().getDatCount(); ++i )
|
for( uint32_t i = 0; i < getIndex().getDatCount(); ++i )
|
||||||
{
|
{
|
||||||
m_dats.emplace_back( std::unique_ptr<Dat>( new Dat( basePath / GameData::buildDatStr( "ex" + std::to_string( exNum ), catNum, exNum, chunk, "win32", "dat" + std::to_string( i ) ), i ) ) );
|
m_dats.emplace_back( std::make_unique< Dat >( basePath / GameData::buildDatStr( "ex" + std::to_string( exNum ), catNum, exNum, chunk, "win32", "dat" + std::to_string( i ) ), i ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
deps/datReader/DatCat.h
vendored
12
deps/datReader/DatCat.h
vendored
|
@ -5,11 +5,13 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace xiv {
|
namespace xiv::dat
|
||||||
namespace dat {
|
{
|
||||||
|
|
||||||
class Index;
|
class Index;
|
||||||
|
|
||||||
class Dat;
|
class Dat;
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
|
|
||||||
// A category represents an .index and its associated .datX
|
// A category represents an .index and its associated .datX
|
||||||
|
@ -26,7 +28,9 @@ public:
|
||||||
// name: The name of the category, empty if not known
|
// name: The name of the category, empty if not known
|
||||||
// exNum: The number of the expansion to load from
|
// exNum: The number of the expansion to load from
|
||||||
// chunk: The chunk to load from
|
// chunk: The chunk to load from
|
||||||
Cat( const std::filesystem::path& basePath, uint32_t catNum, const std::string& name, uint32_t exNum, uint32_t chunk );
|
Cat( const std::filesystem::path& basePath, uint32_t catNum, const std::string& name, uint32_t exNum,
|
||||||
|
uint32_t chunk );
|
||||||
|
|
||||||
~Cat();
|
~Cat();
|
||||||
|
|
||||||
// Returns .index of the category
|
// Returns .index of the category
|
||||||
|
@ -37,6 +41,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
bool doesFileExist( uint32_t dir_hash, uint32_t filename_hash ) const;
|
bool doesFileExist( uint32_t dir_hash, uint32_t filename_hash ) const;
|
||||||
|
|
||||||
bool doesDirExist( uint32_t dir_hash ) const;
|
bool doesDirExist( uint32_t dir_hash ) const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +63,6 @@ protected:
|
||||||
std::vector< std::unique_ptr< Dat>> m_dats;
|
std::vector< std::unique_ptr< Dat>> m_dats;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_DAT_CAT_H
|
#endif // XIV_DAT_CAT_H
|
||||||
|
|
39
deps/datReader/Exd.cpp
vendored
39
deps/datReader/Exd.cpp
vendored
|
@ -8,11 +8,8 @@
|
||||||
using xiv::utils::bparse::extract;
|
using xiv::utils::bparse::extract;
|
||||||
|
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd
|
||||||
{
|
{
|
||||||
namespace exd
|
|
||||||
{
|
|
||||||
|
|
||||||
struct ExdHeader
|
struct ExdHeader
|
||||||
{
|
{
|
||||||
char magic[0x4];
|
char magic[0x4];
|
||||||
|
@ -26,27 +23,36 @@ namespace xiv
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::bparse {
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::exd::ExdHeader >( xiv::exd::ExdHeader& i_struct )
|
||||||
{
|
{
|
||||||
namespace utils
|
for( int32_t i = 0; i < 0x4; ++i )
|
||||||
{
|
{
|
||||||
namespace bparse
|
xiv::utils::bparse::reorder( i_struct.magic[ i ] );
|
||||||
{
|
|
||||||
template <> inline void reorder<xiv::exd::ExdHeader>( xiv::exd::ExdHeader& i_struct ) { for( int32_t i = 0; i < 0x4; ++i ) { xiv::utils::bparse::reorder( i_struct.magic[i] ); } i_struct.unknown = xiv::utils::bparse::byteswap( i_struct.unknown ); xiv::utils::bparse::reorder( i_struct.unknown ); i_struct.unknown2 = xiv::utils::bparse::byteswap( i_struct.unknown2 ); xiv::utils::bparse::reorder( i_struct.unknown2 ); i_struct.index_size = xiv::utils::bparse::byteswap( i_struct.index_size ); xiv::utils::bparse::reorder( i_struct.index_size ); }
|
|
||||||
template <> inline void reorder<xiv::exd::ExdRecordIndex>( xiv::exd::ExdRecordIndex& i_struct ) { i_struct.id = xiv::utils::bparse::byteswap( i_struct.id ); xiv::utils::bparse::reorder( i_struct.id ); i_struct.offset = xiv::utils::bparse::byteswap( i_struct.offset ); xiv::utils::bparse::reorder( i_struct.offset ); }
|
|
||||||
}
|
}
|
||||||
|
i_struct.unknown = xiv::utils::bparse::byteswap( i_struct.unknown );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.unknown );
|
||||||
|
i_struct.unknown2 = xiv::utils::bparse::byteswap( i_struct.unknown2 );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.unknown2 );
|
||||||
|
i_struct.index_size = xiv::utils::bparse::byteswap( i_struct.index_size );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.index_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::exd::ExdRecordIndex >( xiv::exd::ExdRecordIndex& i_struct )
|
||||||
|
{
|
||||||
|
i_struct.id = xiv::utils::bparse::byteswap( i_struct.id );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.id );
|
||||||
|
i_struct.offset = xiv::utils::bparse::byteswap( i_struct.offset );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.offset );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd
|
||||||
{
|
{
|
||||||
namespace exd
|
|
||||||
{
|
|
||||||
|
|
||||||
Exd::Exd( std::shared_ptr< Exh > i_exh, const std::vector< std::shared_ptr< dat::File>>& i_files )
|
Exd::Exd( std::shared_ptr< Exh > i_exh, const std::vector< std::shared_ptr< dat::File>>& i_files )
|
||||||
{
|
{
|
||||||
_exh = i_exh;
|
_exh = i_exh;
|
||||||
|
@ -376,5 +382,4 @@ namespace xiv
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
12
deps/datReader/Exd.h
vendored
12
deps/datReader/Exd.h
vendored
|
@ -8,9 +8,7 @@
|
||||||
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd
|
||||||
{
|
|
||||||
namespace exd
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Exh;
|
class Exh;
|
||||||
|
@ -40,8 +38,12 @@ class Exd
|
||||||
public:
|
public:
|
||||||
// i_exh: the header
|
// i_exh: the header
|
||||||
// i_files: the multiple exd files
|
// i_files: the multiple exd files
|
||||||
Exd() {}
|
Exd()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Exd( std::shared_ptr< Exh > i_exh, const std::vector< std::shared_ptr< dat::File>>& i_files );
|
Exd( std::shared_ptr< Exh > i_exh, const std::vector< std::shared_ptr< dat::File>>& i_files );
|
||||||
|
|
||||||
~Exd();
|
~Exd();
|
||||||
|
|
||||||
// Get a row by its id
|
// Get a row by its id
|
||||||
|
@ -49,6 +51,7 @@ public:
|
||||||
|
|
||||||
// Get a row by its id and sub-row
|
// Get a row by its id and sub-row
|
||||||
const std::vector< Field > get_row( uint32_t id, uint32_t subRow );
|
const std::vector< Field > get_row( uint32_t id, uint32_t subRow );
|
||||||
|
|
||||||
// Get all rows
|
// Get all rows
|
||||||
const std::map< uint32_t, std::vector< Field>>& get_rows();
|
const std::map< uint32_t, std::vector< Field>>& get_rows();
|
||||||
|
|
||||||
|
@ -60,7 +63,6 @@ protected:
|
||||||
std::map< uint32_t, ExdCacheEntry > _idCache;
|
std::map< uint32_t, ExdCacheEntry > _idCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_EXD_EXD_H
|
#endif // XIV_EXD_EXD_H
|
||||||
|
|
17
deps/datReader/ExdCat.cpp
vendored
17
deps/datReader/ExdCat.cpp
vendored
|
@ -11,19 +11,18 @@ namespace
|
||||||
{
|
{
|
||||||
// Suffix of the filenames given a language
|
// Suffix of the filenames given a language
|
||||||
std::map<xiv::exd::Language, std::string> language_map =
|
std::map<xiv::exd::Language, std::string> language_map =
|
||||||
{{xiv::exd::Language::none, ""},
|
{
|
||||||
|
{xiv::exd::Language::none, ""},
|
||||||
{xiv::exd::Language::ja, "_ja"},
|
{xiv::exd::Language::ja, "_ja"},
|
||||||
{xiv::exd::Language::en, "_en"},
|
{xiv::exd::Language::en, "_en"},
|
||||||
{xiv::exd::Language::de, "_de"},
|
{xiv::exd::Language::de, "_de"},
|
||||||
{xiv::exd::Language::fr, "_fr"},
|
{xiv::exd::Language::fr, "_fr"},
|
||||||
{xiv::exd::Language::chs, "_chs"}};
|
{xiv::exd::Language::chs, "_chs"}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd
|
||||||
{
|
{
|
||||||
namespace exd
|
|
||||||
{
|
|
||||||
|
|
||||||
Cat::Cat( dat::GameData& i_game_data, const std::string& i_name ) :
|
Cat::Cat( dat::GameData& i_game_data, const std::string& i_name ) :
|
||||||
_name( i_name )
|
_name( i_name )
|
||||||
{
|
{
|
||||||
|
@ -44,10 +43,11 @@ namespace xiv
|
||||||
std::vector< std::shared_ptr< dat::File>> files;
|
std::vector< std::shared_ptr< dat::File>> files;
|
||||||
for( auto& exd_def: _header->get_exd_defs() )
|
for( auto& exd_def: _header->get_exd_defs() )
|
||||||
{
|
{
|
||||||
files.emplace_back( i_game_data.getFile("exd/" + i_name + "_" + std::to_string(exd_def.start_id) + language_map.at(language) + ".exd") );
|
files.emplace_back( i_game_data.getFile(
|
||||||
|
"exd/" + i_name + "_" + std::to_string( exd_def.start_id ) + language_map.at( language ) + ".exd" ) );
|
||||||
}
|
}
|
||||||
// Instantiate the data for this language
|
// Instantiate the data for this language
|
||||||
_data[language] = std::unique_ptr<Exd>(new Exd(_header, files));
|
_data[ language ] = std::make_unique< Exd >( _header, files );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,4 +79,3 @@ namespace xiv
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
10
deps/datReader/ExdData.cpp
vendored
10
deps/datReader/ExdData.cpp
vendored
|
@ -7,10 +7,7 @@
|
||||||
|
|
||||||
#include "ExdCat.h"
|
#include "ExdCat.h"
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd {
|
||||||
{
|
|
||||||
namespace exd
|
|
||||||
{
|
|
||||||
|
|
||||||
ExdData::ExdData( dat::GameData& i_game_data ) try :
|
ExdData::ExdData( dat::GameData& i_game_data ) try :
|
||||||
_game_data( i_game_data )
|
_game_data( i_game_data )
|
||||||
|
@ -42,7 +39,7 @@ ExdData::ExdData(dat::GameData& i_game_data) try :
|
||||||
// instantiate the creation mutex for this category
|
// instantiate the creation mutex for this category
|
||||||
_cat_names.push_back( category );
|
_cat_names.push_back( category );
|
||||||
_cats[ category ] = std::unique_ptr< Cat >();
|
_cats[ category ] = std::unique_ptr< Cat >();
|
||||||
_cat_creation_mutexes[category] = std::unique_ptr<std::mutex>(new std::mutex());
|
_cat_creation_mutexes[ category ] = std::make_unique< std::mutex >();
|
||||||
|
|
||||||
std::getline( stream, line );
|
std::getline( stream, line );
|
||||||
}
|
}
|
||||||
|
@ -92,9 +89,8 @@ void ExdData::create_category(const std::string& i_cat_name)
|
||||||
// Maybe after unlocking it has already been created, so check (most likely if it blocked)
|
// Maybe after unlocking it has already been created, so check (most likely if it blocked)
|
||||||
if( !_cats[ i_cat_name ] )
|
if( !_cats[ i_cat_name ] )
|
||||||
{
|
{
|
||||||
_cats[i_cat_name] = std::unique_ptr<Cat>(new Cat(_game_data, i_cat_name));
|
_cats[ i_cat_name ] = std::make_unique< Cat >( _game_data, i_cat_name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
6
deps/datReader/Exh.cpp
vendored
6
deps/datReader/Exh.cpp
vendored
|
@ -7,10 +7,9 @@
|
||||||
|
|
||||||
using xiv::utils::bparse::extract;
|
using xiv::utils::bparse::extract;
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd
|
||||||
{
|
|
||||||
namespace exd
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Exh::Exh( const dat::File& i_file )
|
Exh::Exh( const dat::File& i_file )
|
||||||
{
|
{
|
||||||
// Get a stream from the file
|
// Get a stream from the file
|
||||||
|
@ -74,4 +73,3 @@ const std::vector<ExhMember>& Exh::get_exh_members() const
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
66
deps/datReader/Exh.h
vendored
66
deps/datReader/Exh.h
vendored
|
@ -5,11 +5,10 @@
|
||||||
|
|
||||||
#include "bparse.h"
|
#include "bparse.h"
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::exd
|
||||||
{
|
{
|
||||||
namespace exd
|
enum class DataType :
|
||||||
{
|
uint16_t
|
||||||
enum class DataType : uint16_t
|
|
||||||
{
|
{
|
||||||
string = 0,
|
string = 0,
|
||||||
boolean = 1,
|
boolean = 1,
|
||||||
|
@ -47,32 +46,60 @@ namespace xiv
|
||||||
uint32_t start_id;
|
uint32_t start_id;
|
||||||
uint32_t count_id;
|
uint32_t count_id;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace xiv::utils::bparse {
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::exd::ExhHeader >( xiv::exd::ExhHeader& i_struct )
|
||||||
|
{
|
||||||
|
for( int32_t i = 0; i < 0x4; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.magic[ i ] );
|
||||||
|
}
|
||||||
|
i_struct.unknown = xiv::utils::bparse::byteswap( i_struct.unknown );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.unknown );
|
||||||
|
i_struct.data_offset = xiv::utils::bparse::byteswap( i_struct.data_offset );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.data_offset );
|
||||||
|
i_struct.field_count = xiv::utils::bparse::byteswap( i_struct.field_count );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.field_count );
|
||||||
|
i_struct.exd_count = xiv::utils::bparse::byteswap( i_struct.exd_count );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.exd_count );
|
||||||
|
i_struct.language_count = xiv::utils::bparse::byteswap( i_struct.language_count );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.language_count );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::exd::ExhMember >( xiv::exd::ExhMember& i_struct )
|
||||||
|
{
|
||||||
|
i_struct.type = xiv::utils::bparse::byteswap( i_struct.type );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.type );
|
||||||
|
i_struct.offset = xiv::utils::bparse::byteswap( i_struct.offset );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::exd::ExhExdDef >( xiv::exd::ExhExdDef& i_struct )
|
||||||
|
{
|
||||||
|
i_struct.start_id = xiv::utils::bparse::byteswap( i_struct.start_id );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.start_id );
|
||||||
|
i_struct.count_id = xiv::utils::bparse::byteswap( i_struct.count_id );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.count_id );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv
|
||||||
{
|
{
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace bparse
|
|
||||||
{
|
|
||||||
template <> inline void reorder<xiv::exd::ExhHeader>( xiv::exd::ExhHeader& i_struct ) { for( int32_t i = 0; i < 0x4; ++i ) { xiv::utils::bparse::reorder( i_struct.magic[i] ); } i_struct.unknown = xiv::utils::bparse::byteswap( i_struct.unknown ); xiv::utils::bparse::reorder( i_struct.unknown ); i_struct.data_offset = xiv::utils::bparse::byteswap( i_struct.data_offset ); xiv::utils::bparse::reorder( i_struct.data_offset ); i_struct.field_count = xiv::utils::bparse::byteswap( i_struct.field_count ); xiv::utils::bparse::reorder( i_struct.field_count ); i_struct.exd_count = xiv::utils::bparse::byteswap( i_struct.exd_count ); xiv::utils::bparse::reorder( i_struct.exd_count ); i_struct.language_count = xiv::utils::bparse::byteswap( i_struct.language_count ); xiv::utils::bparse::reorder( i_struct.language_count ); }
|
|
||||||
template <> inline void reorder<xiv::exd::ExhMember>( xiv::exd::ExhMember& i_struct ) { i_struct.type = xiv::utils::bparse::byteswap( i_struct.type ); xiv::utils::bparse::reorder( i_struct.type ); i_struct.offset = xiv::utils::bparse::byteswap( i_struct.offset ); xiv::utils::bparse::reorder( i_struct.offset ); }
|
|
||||||
template <> inline void reorder<xiv::exd::ExhExdDef>( xiv::exd::ExhExdDef& i_struct ) { i_struct.start_id = xiv::utils::bparse::byteswap( i_struct.start_id ); xiv::utils::bparse::reorder( i_struct.start_id ); i_struct.count_id = xiv::utils::bparse::byteswap( i_struct.count_id ); xiv::utils::bparse::reorder( i_struct.count_id ); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace xiv
|
|
||||||
{
|
|
||||||
namespace dat
|
namespace dat
|
||||||
{
|
{
|
||||||
class File;
|
class File;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace exd
|
namespace exd
|
||||||
{
|
{
|
||||||
|
|
||||||
enum Language : uint16_t;
|
enum Language :
|
||||||
|
uint16_t;
|
||||||
|
|
||||||
// Header file for exd data
|
// Header file for exd data
|
||||||
class Exh
|
class Exh
|
||||||
|
@ -80,12 +107,17 @@ namespace xiv
|
||||||
public:
|
public:
|
||||||
// The header file
|
// The header file
|
||||||
Exh( const dat::File& i_file );
|
Exh( const dat::File& i_file );
|
||||||
|
|
||||||
~Exh();
|
~Exh();
|
||||||
|
|
||||||
const ExhHeader& get_header() const;
|
const ExhHeader& get_header() const;
|
||||||
|
|
||||||
const std::vector< ExhExdDef >& get_exd_defs() const;
|
const std::vector< ExhExdDef >& get_exd_defs() const;
|
||||||
|
|
||||||
const std::vector< Language >& get_languages() const;
|
const std::vector< Language >& get_languages() const;
|
||||||
|
|
||||||
const std::map< uint32_t, ExhMember >& get_members() const;
|
const std::map< uint32_t, ExhMember >& get_members() const;
|
||||||
|
|
||||||
const std::vector< ExhMember >& get_exh_members() const;
|
const std::vector< ExhMember >& get_exh_members() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
5
deps/datReader/File.cpp
vendored
5
deps/datReader/File.cpp
vendored
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
File::File() :
|
File::File() :
|
||||||
|
@ -42,4 +40,3 @@ void File::exportToFile(const std::filesystem::path& i_path) const
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
20
deps/datReader/File.h
vendored
20
deps/datReader/File.h
vendored
|
@ -7,25 +7,16 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "bparse.h"
|
#include "bparse.h"
|
||||||
|
|
||||||
|
namespace xiv::dat
|
||||||
namespace xiv
|
|
||||||
{
|
{
|
||||||
namespace dat
|
enum class FileType :
|
||||||
{
|
uint32_t
|
||||||
enum class FileType : uint32_t
|
|
||||||
{
|
{
|
||||||
empty = 1,
|
empty = 1,
|
||||||
standard = 2,
|
standard = 2,
|
||||||
model = 3,
|
model = 3,
|
||||||
texture = 4,
|
texture = 4,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace xiv
|
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
|
||||||
|
|
||||||
class Dat;
|
class Dat;
|
||||||
|
|
||||||
|
@ -33,14 +24,17 @@ namespace xiv
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
friend class Dat;
|
friend class Dat;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
File();
|
File();
|
||||||
|
|
||||||
~File();
|
~File();
|
||||||
|
|
||||||
FileType get_type() const;
|
FileType get_type() const;
|
||||||
|
|
||||||
// Getters functions for the data in the file
|
// Getters functions for the data in the file
|
||||||
const std::vector< std::vector< char>>& get_data_sections() const;
|
const std::vector< std::vector< char>>& get_data_sections() const;
|
||||||
|
|
||||||
std::vector< std::vector< char>>& access_data_sections();
|
std::vector< std::vector< char>>& access_data_sections();
|
||||||
|
|
||||||
void exportToFile( const std::filesystem::path& i_path ) const;
|
void exportToFile( const std::filesystem::path& i_path ) const;
|
||||||
|
@ -49,8 +43,6 @@ namespace xiv
|
||||||
FileType _type;
|
FileType _type;
|
||||||
std::vector< std::vector< char>> _data_sections;
|
std::vector< std::vector< char>> _data_sections;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_DAT_FILE_H
|
#endif // XIV_DAT_FILE_H
|
||||||
|
|
33
deps/datReader/GameData.cpp
vendored
33
deps/datReader/GameData.cpp
vendored
|
@ -11,8 +11,7 @@
|
||||||
#include "DatCat.h"
|
#include "DatCat.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
// Relation between category number and category name
|
// Relation between category number and category name
|
||||||
// These names are taken straight from the exe, it helps resolve dispatching when getting files by path
|
// These names are taken straight from the exe, it helps resolve dispatching when getting files by path
|
||||||
|
|
||||||
|
@ -48,11 +47,8 @@ namespace
|
||||||
{ 0x0C, "music" } };
|
{ 0x0C, "music" } };
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
{
|
||||||
namespace dat
|
|
||||||
{
|
|
||||||
|
|
||||||
GameData::GameData( const std::filesystem::path& path ) try :
|
GameData::GameData( const std::filesystem::path& path ) try :
|
||||||
m_path( path )
|
m_path( path )
|
||||||
{
|
{
|
||||||
|
@ -66,14 +62,17 @@ GameData::GameData(const std::filesystem::path& path) try :
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Determine which expansions are available
|
// Determine which expansions are available
|
||||||
while( std::filesystem::exists( std::filesystem::path( m_path.string() + sep + "ex" + std::to_string( maxExLevel + 1 ) + sep + "ex" + std::to_string( maxExLevel + 1 ) + ".ver" ) ) )
|
while( std::filesystem::exists( std::filesystem::path(
|
||||||
|
m_path.string() + sep + "ex" + std::to_string( maxExLevel + 1 ) + sep + "ex" + std::to_string( maxExLevel + 1 ) +
|
||||||
|
".ver" ) ) )
|
||||||
{
|
{
|
||||||
maxExLevel++;
|
maxExLevel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Iterate over the files in path
|
// Iterate over the files in path
|
||||||
for( auto it = std::filesystem::directory_iterator( m_path.string() + "//ffxiv" ); it != std::filesystem::directory_iterator(); ++it )
|
for( auto it = std::filesystem::directory_iterator( m_path.string() + "//ffxiv" );
|
||||||
|
it != std::filesystem::directory_iterator(); ++it )
|
||||||
{
|
{
|
||||||
// Get the filename of the current element
|
// Get the filename of the current element
|
||||||
auto filename = it->path().filename().string();
|
auto filename = it->path().filename().string();
|
||||||
|
@ -92,12 +91,13 @@ GameData::GameData(const std::filesystem::path& path) try :
|
||||||
// instantiate the creation mutex for this category
|
// instantiate the creation mutex for this category
|
||||||
m_catNums.push_back( cat_nb );
|
m_catNums.push_back( cat_nb );
|
||||||
m_cats[ cat_nb ] = std::unique_ptr< Cat >();
|
m_cats[ cat_nb ] = std::unique_ptr< Cat >();
|
||||||
m_catCreationMutexes[cat_nb] = std::unique_ptr<std::mutex>( new std::mutex() );
|
m_catCreationMutexes[ cat_nb ] = std::make_unique< std::mutex >();
|
||||||
|
|
||||||
// Check for expansion
|
// Check for expansion
|
||||||
for( int exNum = 1; exNum <= maxExLevel; exNum++ )
|
for( int exNum = 1; exNum <= maxExLevel; exNum++ )
|
||||||
{
|
{
|
||||||
const std::string path = m_path.string() + sep + buildDatStr( "ex" + std::to_string( exNum ), cat_nb, exNum, 0, "win32", "index" );
|
const std::string path =
|
||||||
|
m_path.string() + sep + buildDatStr( "ex" + std::to_string( exNum ), cat_nb, exNum, 0, "win32", "index" );
|
||||||
|
|
||||||
if( std::filesystem::exists( std::filesystem::path( path ) ) )
|
if( std::filesystem::exists( std::filesystem::path( path ) ) )
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,9 @@ GameData::GameData(const std::filesystem::path& path) try :
|
||||||
|
|
||||||
for( int chunkTest = 0; chunkTest < 256; chunkTest++ )
|
for( int chunkTest = 0; chunkTest < 256; chunkTest++ )
|
||||||
{
|
{
|
||||||
if( std::filesystem::exists( m_path.string() + sep + buildDatStr( "ex" + std::to_string( exNum ), cat_nb, exNum, chunkTest, "win32", "index" ) ) )
|
if( std::filesystem::exists( m_path.string() + sep +
|
||||||
|
buildDatStr( "ex" + std::to_string( exNum ), cat_nb, exNum, chunkTest, "win32",
|
||||||
|
"index" ) ) )
|
||||||
{
|
{
|
||||||
m_exCats[ cat_nb ].exNumToChunkMap[ exNum ].chunkToCatMap[ chunkTest ] = std::unique_ptr< Cat >();
|
m_exCats[ cat_nb ].exNumToChunkMap[ exNum ].chunkToCatMap[ chunkTest ] = std::unique_ptr< Cat >();
|
||||||
chunkCount++;
|
chunkCount++;
|
||||||
|
@ -130,7 +132,8 @@ GameData::~GameData()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string GameData::buildDatStr( const std::string folder, const int cat, const int exNum, const int chunk, const std::string platform, const std::string type )
|
const std::string GameData::buildDatStr( const std::string folder, const int cat, const int exNum, const int chunk,
|
||||||
|
const std::string platform, const std::string type )
|
||||||
{
|
{
|
||||||
char dat[1024];
|
char dat[1024];
|
||||||
sprintf( dat, "%s/%02x%02x%02x.%s.%s", folder.c_str(), cat, exNum, chunk, platform.c_str(), type.c_str() );
|
sprintf( dat, "%s/%02x%02x%02x.%s.%s", folder.c_str(), cat, exNum, chunk, platform.c_str(), type.c_str() );
|
||||||
|
@ -290,7 +293,7 @@ void GameData::createCategory(uint32_t catNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually creates the category
|
// Actually creates the category
|
||||||
m_cats[catNum] = std::unique_ptr<Cat>( new Cat( m_path, catNum, catName ) );
|
m_cats[ catNum ] = std::make_unique< Cat >( m_path, catNum, catName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,11 +315,11 @@ void GameData::createExCategory( uint32_t catNum )
|
||||||
for( auto const& chunk : m_exCats[ catNum ].exNumToChunkMap[ ex.first ].chunkToCatMap )
|
for( auto const& chunk : m_exCats[ catNum ].exNumToChunkMap[ ex.first ].chunkToCatMap )
|
||||||
{
|
{
|
||||||
// Actually creates the category
|
// Actually creates the category
|
||||||
m_exCats[catNum].exNumToChunkMap[ex.first].chunkToCatMap[chunk.first] = std::unique_ptr<Cat>( new Cat( m_path, catNum, catName, ex.first, chunk.first ) );
|
m_exCats[ catNum ].exNumToChunkMap[ ex.first ].chunkToCatMap[ chunk.first ] = std::unique_ptr< Cat >(
|
||||||
|
new Cat( m_path, catNum, catName, ex.first, chunk.first ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
22
deps/datReader/GameData.h
vendored
22
deps/datReader/GameData.h
vendored
|
@ -7,12 +7,11 @@
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Cat;
|
class Cat;
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
|
|
||||||
// Interface to all the datfiles - Main entry point
|
// Interface to all the datfiles - Main entry point
|
||||||
|
@ -22,15 +21,19 @@ class GameData
|
||||||
public:
|
public:
|
||||||
// This should be the path in which the .index/.datX files are located
|
// This should be the path in which the .index/.datX files are located
|
||||||
GameData( const std::filesystem::path& path );
|
GameData( const std::filesystem::path& path );
|
||||||
|
|
||||||
~GameData();
|
~GameData();
|
||||||
|
|
||||||
static const std::string buildDatStr( const std::string folder, const int cat, const int exNum, const int chunk, const std::string platform, const std::string type );
|
static const std::string
|
||||||
|
buildDatStr( const std::string folder, const int cat, const int exNum, const int chunk, const std::string platform,
|
||||||
|
const std::string type );
|
||||||
|
|
||||||
// Returns all the scanned category number available in the path
|
// Returns all the scanned category number available in the path
|
||||||
const std::vector< uint32_t >& getCatNumbers() const;
|
const std::vector< uint32_t >& getCatNumbers() const;
|
||||||
|
|
||||||
// Return a specific category by its number (see getCatNumbers() for loops)
|
// Return a specific category by its number (see getCatNumbers() for loops)
|
||||||
const Cat& getCategory( uint32_t catNum );
|
const Cat& getCategory( uint32_t catNum );
|
||||||
|
|
||||||
// Return a specific category by it's name (e.g.: "exd"/"game_script"/ etc...)
|
// Return a specific category by it's name (e.g.: "exd"/"game_script"/ etc...)
|
||||||
const Cat& getCategory( const std::string& catName );
|
const Cat& getCategory( const std::string& catName );
|
||||||
|
|
||||||
|
@ -71,14 +74,19 @@ protected:
|
||||||
|
|
||||||
// Map of all EX categories and their chunks, "CatNum - (ExNum - (ChunkNum - Cat))"
|
// Map of all EX categories and their chunks, "CatNum - (ExNum - (ChunkNum - Cat))"
|
||||||
// Map of all EX categories and their chunks, "CatNum - (ExNum - (ChunkNum - Cat))"
|
// Map of all EX categories and their chunks, "CatNum - (ExNum - (ChunkNum - Cat))"
|
||||||
using ChunkToCatMap = struct { std::unordered_map< uint32_t, std::unique_ptr< Cat > > chunkToCatMap; };
|
using ChunkToCatMap = struct
|
||||||
using ExNumToChunkMap = struct { std::unordered_map< uint32_t, ChunkToCatMap > exNumToChunkMap; };
|
{
|
||||||
|
std::unordered_map< uint32_t, std::unique_ptr< Cat > > chunkToCatMap;
|
||||||
|
};
|
||||||
|
using ExNumToChunkMap = struct
|
||||||
|
{
|
||||||
|
std::unordered_map< uint32_t, ChunkToCatMap > exNumToChunkMap;
|
||||||
|
};
|
||||||
using CatNumToExNumMap = std::unordered_map< uint32_t, ExNumToChunkMap >;
|
using CatNumToExNumMap = std::unordered_map< uint32_t, ExNumToChunkMap >;
|
||||||
CatNumToExNumMap m_exCats;
|
CatNumToExNumMap m_exCats;
|
||||||
std::unordered_map< uint32_t, std::unique_ptr< std::mutex>> m_catCreationMutexes;
|
std::unordered_map< uint32_t, std::unique_ptr< std::mutex>> m_catCreationMutexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_DAT_GAMEDATA_H
|
#endif // XIV_DAT_GAMEDATA_H
|
||||||
|
|
18
deps/datReader/Index.cpp
vendored
18
deps/datReader/Index.cpp
vendored
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
#include "bparse.h"
|
#include "bparse.h"
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
struct IndexBlockRecord
|
struct IndexBlockRecord
|
||||||
{
|
{
|
||||||
|
@ -21,13 +19,8 @@ namespace dat
|
||||||
uint32_t padding;
|
uint32_t padding;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::bparse
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace bparse
|
|
||||||
{
|
{
|
||||||
template<>
|
template<>
|
||||||
inline void reorder< xiv::dat::IndexBlockRecord >( xiv::dat::IndexBlockRecord& i_struct )
|
inline void reorder< xiv::dat::IndexBlockRecord >( xiv::dat::IndexBlockRecord& i_struct )
|
||||||
|
@ -46,14 +39,10 @@ namespace bparse
|
||||||
xiv::utils::bparse::reorder( i_struct.padding );
|
xiv::utils::bparse::reorder( i_struct.padding );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using xiv::utils::bparse::extract;
|
using xiv::utils::bparse::extract;
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Index::Index( const std::filesystem::path& path ) :
|
Index::Index( const std::filesystem::path& path ) :
|
||||||
|
@ -164,4 +153,3 @@ void Index::isIndexBlockValid( const IndexBlockRecord& i_index_block_record )
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
12
deps/datReader/Index.h
vendored
12
deps/datReader/Index.h
vendored
|
@ -7,16 +7,18 @@
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace xiv {
|
namespace xiv::dat
|
||||||
namespace dat {
|
{
|
||||||
|
|
||||||
struct IndexBlockRecord;
|
struct IndexBlockRecord;
|
||||||
|
|
||||||
class Index : public SqPack
|
class Index :
|
||||||
|
public SqPack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Full path to the index file
|
// Full path to the index file
|
||||||
Index( const std::filesystem::path& i_path );
|
Index( const std::filesystem::path& i_path );
|
||||||
|
|
||||||
virtual ~Index();
|
virtual ~Index();
|
||||||
|
|
||||||
// An entry in the hash table, representing a file in a given dat
|
// An entry in the hash table, representing a file in a given dat
|
||||||
|
@ -36,12 +38,15 @@ public:
|
||||||
uint32_t getDatCount() const;
|
uint32_t getDatCount() const;
|
||||||
|
|
||||||
bool doesFileExist( uint32_t dir_hash, uint32_t filename_hash ) const;
|
bool doesFileExist( uint32_t dir_hash, uint32_t filename_hash ) const;
|
||||||
|
|
||||||
bool doesDirExist( uint32_t dir_hash ) const;
|
bool doesDirExist( uint32_t dir_hash ) const;
|
||||||
|
|
||||||
// Returns the whole HashTable
|
// Returns the whole HashTable
|
||||||
const HashTable& getHashTable() const;
|
const HashTable& getHashTable() const;
|
||||||
|
|
||||||
// Returns the hash table for a specific dir
|
// Returns the hash table for a specific dir
|
||||||
const DirHashTable& getDirHashTable( uint32_t dir_hash ) const;
|
const DirHashTable& getDirHashTable( uint32_t dir_hash ) const;
|
||||||
|
|
||||||
// Returns the HashTableEntry for a given file given its hashes
|
// Returns the HashTableEntry for a given file given its hashes
|
||||||
const HashTableEntry& getHashTableEntry( uint32_t dir_hash, uint32_t filename_hash ) const;
|
const HashTableEntry& getHashTableEntry( uint32_t dir_hash, uint32_t filename_hash ) const;
|
||||||
|
|
||||||
|
@ -53,7 +58,6 @@ protected:
|
||||||
HashTable m_hashTable;
|
HashTable m_hashTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_DAT_INDEX_H
|
#endif // XIV_DAT_INDEX_H
|
||||||
|
|
24
deps/datReader/SqPack.h
vendored
24
deps/datReader/SqPack.h
vendored
|
@ -8,23 +8,19 @@
|
||||||
#include "bparse.h"
|
#include "bparse.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
{
|
||||||
namespace dat
|
|
||||||
{
|
|
||||||
|
|
||||||
struct SqPackBlockHash
|
struct SqPackBlockHash
|
||||||
{
|
{
|
||||||
uint8_t hash[0x14];
|
uint8_t hash[0x14];
|
||||||
uint32_t padding[0xB];
|
uint32_t padding[0xB];
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
namespace xiv::utils::bparse
|
||||||
}
|
{
|
||||||
namespace xiv {
|
template<>
|
||||||
namespace utils {
|
inline void reorder< xiv::dat::SqPackBlockHash >( xiv::dat::SqPackBlockHash& i_struct )
|
||||||
namespace bparse {
|
|
||||||
template <> inline void reorder<xiv::dat::SqPackBlockHash>( xiv::dat::SqPackBlockHash& i_struct )
|
|
||||||
{
|
{
|
||||||
for( auto i = 0; i < 0x14; ++i )
|
for( auto i = 0; i < 0x14; ++i )
|
||||||
{
|
{
|
||||||
|
@ -35,13 +31,9 @@ namespace xiv {
|
||||||
xiv::utils::bparse::reorder( i_struct.padding[ i ] );
|
xiv::utils::bparse::reorder( i_struct.padding[ i ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class SqPack
|
class SqPack
|
||||||
|
@ -50,6 +42,7 @@ class SqPack
|
||||||
public:
|
public:
|
||||||
// Full path to the sqpack file
|
// Full path to the sqpack file
|
||||||
SqPack( const std::filesystem::path& i_path );
|
SqPack( const std::filesystem::path& i_path );
|
||||||
|
|
||||||
virtual ~SqPack();
|
virtual ~SqPack();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -61,6 +54,5 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif // XIV_DAT_SQPACK_H
|
#endif // XIV_DAT_SQPACK_H
|
||||||
|
|
16
deps/datReader/bparse.h
vendored
16
deps/datReader/bparse.h
vendored
|
@ -6,11 +6,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::bparse
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace bparse
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// Internal macro for byteswapping
|
// Internal macro for byteswapping
|
||||||
|
@ -40,7 +36,10 @@ void read(std::istream& i_stream, StructType& i_struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
// By default a type does not need reordering
|
// By default a type does not need reordering
|
||||||
template <typename StructType> void reorder(StructType& i_struct) {}
|
template< typename StructType >
|
||||||
|
void reorder( StructType& i_struct )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// "Overload" for passed struct as arg
|
// "Overload" for passed struct as arg
|
||||||
template< typename StructType >
|
template< typename StructType >
|
||||||
|
@ -84,7 +83,8 @@ StructType extract(std::istream& i_stream, const std::string& i_name, bool i_is_
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename StructType >
|
template< typename StructType >
|
||||||
void extract(std::istream& i_stream, const std::string& i_name, uint32_t i_size, std::vector<StructType>& o_structs, bool i_is_le = true)
|
void extract( std::istream& i_stream, const std::string& i_name, uint32_t i_size, std::vector< StructType >& o_structs,
|
||||||
|
bool i_is_le = true )
|
||||||
{
|
{
|
||||||
o_structs.reserve( i_size );
|
o_structs.reserve( i_size );
|
||||||
for( uint32_t i = 0; i < i_size; ++i )
|
for( uint32_t i = 0; i < i_size; ++i )
|
||||||
|
@ -96,8 +96,6 @@ void extract(std::istream& i_stream, const std::string& i_name, uint32_t i_size,
|
||||||
// For cstrings
|
// For cstrings
|
||||||
std::string extract_cstring( std::istream& i_stream, const std::string& i_name );
|
std::string extract_cstring( std::istream& i_stream, const std::string& i_name );
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_UTILS_BPARSE_H
|
#endif // XIV_UTILS_BPARSE_H
|
||||||
|
|
8
deps/datReader/conv.cpp
vendored
8
deps/datReader/conv.cpp
vendored
|
@ -1,8 +1,8 @@
|
||||||
#include "conv.h"
|
#include "conv.h"
|
||||||
|
|
||||||
namespace xiv {
|
namespace xiv::utils::conv
|
||||||
namespace utils {
|
{
|
||||||
namespace conv {
|
|
||||||
float half2float( const uint16_t i_value )
|
float half2float( const uint16_t i_value )
|
||||||
{
|
{
|
||||||
uint32_t t1;
|
uint32_t t1;
|
||||||
|
@ -30,6 +30,4 @@ namespace conv {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
8
deps/datReader/conv.h
vendored
8
deps/datReader/conv.h
vendored
|
@ -5,13 +5,11 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace xiv {
|
namespace xiv::utils::conv
|
||||||
namespace utils {
|
{
|
||||||
namespace conv {
|
|
||||||
float half2float( const uint16_t i_value );
|
float half2float( const uint16_t i_value );
|
||||||
|
|
||||||
float ubyte2float( const uint8_t i_value );
|
float ubyte2float( const uint8_t i_value );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // XIV_UTILS_CONV_H
|
#endif // XIV_UTILS_CONV_H
|
||||||
|
|
11
deps/datReader/crc32.cpp
vendored
11
deps/datReader/crc32.cpp
vendored
|
@ -65,11 +65,7 @@ namespace internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::crc32
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace crc32
|
|
||||||
{
|
{
|
||||||
|
|
||||||
uint32_t compute( const std::string& i_input, uint32_t init_crc )
|
uint32_t compute( const std::string& i_input, uint32_t init_crc )
|
||||||
|
@ -130,7 +126,8 @@ void generate_hashes_1(std::string& i_format, const uint32_t i_first_index, std:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_hashes_2(std::string& i_format, const uint32_t i_first_index, const uint32_t i_second_index, std::vector<uint32_t>& o_hashes)
|
void generate_hashes_2( std::string& i_format, const uint32_t i_first_index, const uint32_t i_second_index,
|
||||||
|
std::vector< uint32_t >& o_hashes )
|
||||||
{
|
{
|
||||||
char* str = const_cast<char*>(i_format.data());
|
char* str = const_cast<char*>(i_format.data());
|
||||||
const uint32_t str_size = i_format.size();
|
const uint32_t str_size = i_format.size();
|
||||||
|
@ -176,5 +173,3 @@ void generate_hashes_2(std::string& i_format, const uint32_t i_first_index, cons
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
11
deps/datReader/crc32.h
vendored
11
deps/datReader/crc32.h
vendored
|
@ -5,9 +5,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace xiv {
|
namespace xiv::utils::crc32
|
||||||
namespace utils {
|
{
|
||||||
namespace crc32 {
|
|
||||||
|
|
||||||
// Normal crc32 computation from a given intial crc value, use zlib.crc32 instead, the final XOR 0xFFFFFFFF is not done
|
// Normal crc32 computation from a given intial crc value, use zlib.crc32 instead, the final XOR 0xFFFFFFFF is not done
|
||||||
uint32_t compute( const std::string& i_input, uint32_t init_crc = 0xFFFFFFFF );
|
uint32_t compute( const std::string& i_input, uint32_t init_crc = 0xFFFFFFFF );
|
||||||
|
@ -17,10 +16,10 @@ namespace crc32 {
|
||||||
uint32_t rev_compute( const std::string& i_input, uint32_t init_crc = 0 );
|
uint32_t rev_compute( const std::string& i_input, uint32_t init_crc = 0 );
|
||||||
|
|
||||||
void generate_hashes_1( std::string& i_format, const uint32_t i_first_index, std::vector< uint32_t >& o_hashes );
|
void generate_hashes_1( std::string& i_format, const uint32_t i_first_index, std::vector< uint32_t >& o_hashes );
|
||||||
void generate_hashes_2( std::string& i_format, const uint32_t i_first_index, const uint32_t i_second_index, std::vector< uint32_t >& o_hashes );
|
|
||||||
|
|
||||||
}
|
void generate_hashes_2( std::string& i_format, const uint32_t i_first_index, const uint32_t i_second_index,
|
||||||
}
|
std::vector< uint32_t >& o_hashes );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_UTILS_CRC32_H
|
#endif // XIV_UTILS_CRC32_H
|
||||||
|
|
8
deps/datReader/stream.cpp
vendored
8
deps/datReader/stream.cpp
vendored
|
@ -4,13 +4,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::stream
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace stream
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
12
deps/datReader/stream.h
vendored
12
deps/datReader/stream.h
vendored
|
@ -5,14 +5,11 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::stream
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace stream
|
|
||||||
{
|
{
|
||||||
template< typename CharT, typename TraitsT = std::char_traits< CharT > >
|
template< typename CharT, typename TraitsT = std::char_traits< CharT > >
|
||||||
class vectorwrapbuf : public std::basic_streambuf<CharT, TraitsT>
|
class vectorwrapbuf :
|
||||||
|
public std::basic_streambuf< CharT, TraitsT >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vectorwrapbuf( std::vector< CharT >& vec )
|
vectorwrapbuf( std::vector< CharT >& vec )
|
||||||
|
@ -21,7 +18,4 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // XIV_UTILS_STREAM_H
|
#endif // XIV_UTILS_STREAM_H
|
||||||
|
|
8
deps/datReader/zlib.cpp
vendored
8
deps/datReader/zlib.cpp
vendored
|
@ -4,11 +4,7 @@
|
||||||
#include <zlib/zlib.h>
|
#include <zlib/zlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::zlib
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace zlib
|
|
||||||
{
|
{
|
||||||
|
|
||||||
void compress( const std::vector< char >& in, std::vector< char >& out )
|
void compress( const std::vector< char >& in, std::vector< char >& out )
|
||||||
|
@ -61,5 +57,3 @@ void no_header_decompress(uint8_t* in, uint32_t in_size, uint8_t* out, uint32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
9
deps/datReader/zlib.h
vendored
9
deps/datReader/zlib.h
vendored
|
@ -4,18 +4,13 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::utils::zlib
|
||||||
{
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace zlib
|
|
||||||
{
|
{
|
||||||
|
|
||||||
void compress( const std::vector< char >& in, std::vector< char >& out );
|
void compress( const std::vector< char >& in, std::vector< char >& out );
|
||||||
|
|
||||||
void no_header_decompress( uint8_t* in, uint32_t in_size, uint8_t* out, uint32_t out_size );
|
void no_header_decompress( uint8_t* in, uint32_t in_size, uint8_t* out, uint32_t out_size );
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XIV_UTILS_ZLIB_H
|
#endif // XIV_UTILS_ZLIB_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue