1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 16:57:47 +00:00

bit of cleanup and sqpack fix

This commit is contained in:
NotAdam 2020-02-02 17:14:59 +11:00
parent 5b843c66dd
commit 39aa49f092

View file

@ -1,11 +1,19 @@
#include "SqPack.h" #include "SqPack.h"
namespace xiv { namespace xiv::dat {
namespace dat { enum PlatformId :
uint8_t
{
Win32,
PS3,
PS4
};
struct SqPackHeader struct SqPackHeader
{ {
char magic[0x8]; char magic[0x8];
uint32_t zero; PlatformId platformId;
uint8_t padding0[3];
uint32_t size; uint32_t size;
uint32_t version; uint32_t version;
uint32_t type; uint32_t type;
@ -17,50 +25,45 @@ namespace dat {
uint32_t type; uint32_t type;
}; };
} }
}
namespace xiv { namespace xiv::utils:: bparse
namespace utils { {
namespace bparse { template<>
template <> inline void reorder< xiv::dat::SqPackHeader >( xiv::dat::SqPackHeader& i_struct )
inline void reorder<xiv::dat::SqPackHeader>(xiv::dat::SqPackHeader& i_struct)
{ {
for (int32_t i = 0; i < 0x8; ++i) for( int32_t i = 0; i < 0x8; ++i )
{ {
xiv::utils::bparse::reorder(i_struct.magic[i]); xiv::utils::bparse::reorder( i_struct.magic[ i ] );
} }
xiv::utils::bparse::reorder(i_struct.zero); xiv::utils::bparse::reorder( i_struct.platformId );
xiv::utils::bparse::reorder(i_struct.size); xiv::utils::bparse::reorder( i_struct.size );
xiv::utils::bparse::reorder(i_struct.version); xiv::utils::bparse::reorder( i_struct.version );
xiv::utils::bparse::reorder(i_struct.type); xiv::utils::bparse::reorder( i_struct.type );
} }
template <> template<>
inline void reorder<xiv::dat::SqPackIndexHeader>(xiv::dat::SqPackIndexHeader& i_struct) inline void reorder< xiv::dat::SqPackIndexHeader >( xiv::dat::SqPackIndexHeader& i_struct )
{ {
xiv::utils::bparse::reorder(i_struct.size); xiv::utils::bparse::reorder( i_struct.size );
xiv::utils::bparse::reorder(i_struct.type); 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()
@ -73,4 +76,3 @@ namespace dat
} }
} }
}