mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57:44 +00:00
bit of cleanup and sqpack fix
This commit is contained in:
parent
5b843c66dd
commit
39aa49f092
1 changed files with 62 additions and 60 deletions
122
deps/datReader/SqPack.cpp
vendored
122
deps/datReader/SqPack.cpp
vendored
|
@ -1,76 +1,78 @@
|
||||||
#include "SqPack.h"
|
#include "SqPack.h"
|
||||||
|
|
||||||
namespace xiv {
|
namespace xiv::dat {
|
||||||
namespace dat {
|
enum PlatformId :
|
||||||
struct SqPackHeader
|
uint8_t
|
||||||
{
|
{
|
||||||
char magic[0x8];
|
Win32,
|
||||||
uint32_t zero;
|
PS3,
|
||||||
uint32_t size;
|
PS4
|
||||||
uint32_t version;
|
};
|
||||||
uint32_t type;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SqPackIndexHeader
|
struct SqPackHeader
|
||||||
{
|
{
|
||||||
uint32_t size;
|
char magic[0x8];
|
||||||
uint32_t type;
|
PlatformId platformId;
|
||||||
};
|
uint8_t padding0[3];
|
||||||
}
|
uint32_t size;
|
||||||
}
|
uint32_t version;
|
||||||
namespace xiv {
|
uint32_t type;
|
||||||
namespace utils {
|
};
|
||||||
namespace bparse {
|
|
||||||
template <>
|
|
||||||
inline void reorder<xiv::dat::SqPackHeader>(xiv::dat::SqPackHeader& i_struct)
|
|
||||||
{
|
|
||||||
for (int32_t i = 0; i < 0x8; ++i)
|
|
||||||
{
|
|
||||||
xiv::utils::bparse::reorder(i_struct.magic[i]);
|
|
||||||
}
|
|
||||||
xiv::utils::bparse::reorder(i_struct.zero);
|
|
||||||
xiv::utils::bparse::reorder(i_struct.size);
|
|
||||||
xiv::utils::bparse::reorder(i_struct.version);
|
|
||||||
xiv::utils::bparse::reorder(i_struct.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
struct SqPackIndexHeader
|
||||||
inline void reorder<xiv::dat::SqPackIndexHeader>(xiv::dat::SqPackIndexHeader& i_struct)
|
{
|
||||||
{
|
uint32_t size;
|
||||||
xiv::utils::bparse::reorder(i_struct.size);
|
uint32_t type;
|
||||||
xiv::utils::bparse::reorder(i_struct.type);
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace xiv::utils:: bparse
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::dat::SqPackHeader >( xiv::dat::SqPackHeader& i_struct )
|
||||||
|
{
|
||||||
|
for( int32_t i = 0; i < 0x8; ++i )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.magic[ i ] );
|
||||||
|
}
|
||||||
|
xiv::utils::bparse::reorder( i_struct.platformId );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.size );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.version );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.type );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void reorder< xiv::dat::SqPackIndexHeader >( xiv::dat::SqPackIndexHeader& i_struct )
|
||||||
|
{
|
||||||
|
xiv::utils::bparse::reorder( i_struct.size );
|
||||||
|
xiv::utils::bparse::reorder( i_struct.type );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
using xiv::utils::bparse::extract;
|
using xiv::utils::bparse::extract;
|
||||||
|
|
||||||
namespace xiv
|
namespace xiv::dat
|
||||||
{
|
|
||||||
namespace dat
|
|
||||||
{
|
{
|
||||||
|
|
||||||
SqPack::SqPack( const std::experimental::filesystem::path& path ) :
|
// Open the file
|
||||||
// Open the file
|
SqPack::SqPack( const std::experimental::filesystem::path& path ) :
|
||||||
m_handle( path.string(), std::ios_base::in | std::ios_base::binary )
|
m_handle( path.string(), std::ios_base::in | std::ios_base::binary )
|
||||||
{
|
{
|
||||||
// Extract the header
|
// Extract the header
|
||||||
extract<SqPackHeader>( m_handle );
|
extract< SqPackHeader >( m_handle );
|
||||||
|
|
||||||
// Skip until the IndexHeader the extract it
|
// Skip until the IndexHeader the extract it
|
||||||
m_handle.seekg( 0x400 );
|
m_handle.seekg( 0x400 );
|
||||||
extract<SqPackIndexHeader>( m_handle );
|
extract< SqPackIndexHeader >( m_handle );
|
||||||
}
|
}
|
||||||
|
|
||||||
SqPack::~SqPack()
|
SqPack::~SqPack()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqPack::isBlockValid( uint32_t i_offset, uint32_t i_size, const SqPackBlockHash& i_block_hash )
|
void SqPack::isBlockValid( uint32_t i_offset, uint32_t i_size, const SqPackBlockHash& i_block_hash )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue