2021-11-27 00:53:57 +01:00
|
|
|
#pragma once
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "bparse.h"
|
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
namespace xiv::exd
|
2018-10-24 23:31:26 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
enum class DataType : uint16_t
|
2020-02-10 14:05:04 +11:00
|
|
|
{
|
|
|
|
string = 0,
|
|
|
|
boolean = 1,
|
|
|
|
int8 = 2,
|
|
|
|
uint8 = 3,
|
|
|
|
int16 = 4,
|
|
|
|
uint16 = 5,
|
|
|
|
int32 = 6,
|
|
|
|
uint32 = 7,
|
|
|
|
float32 = 9,
|
|
|
|
uint64 = 11,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExhHeader
|
|
|
|
{
|
|
|
|
char magic[0x4];
|
|
|
|
uint16_t unknown;
|
|
|
|
uint16_t data_offset;
|
|
|
|
uint16_t field_count;
|
|
|
|
uint16_t exd_count;
|
|
|
|
uint16_t language_count;
|
|
|
|
uint16_t unknown1;
|
|
|
|
uint8_t u2;
|
|
|
|
uint8_t variant;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExhMember
|
|
|
|
{
|
|
|
|
DataType type;
|
|
|
|
uint16_t offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExhExdDef
|
|
|
|
{
|
|
|
|
uint32_t start_id;
|
|
|
|
uint32_t count_id;
|
|
|
|
};
|
2018-10-24 23:31:26 +11:00
|
|
|
};
|
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
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 )
|
2018-10-24 23:31:26 +11:00
|
|
|
{
|
2020-02-10 14:05:04 +11:00
|
|
|
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 );
|
|
|
|
}
|
2018-10-24 23:31:26 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace xiv
|
|
|
|
{
|
2020-02-10 14:05:04 +11:00
|
|
|
|
|
|
|
namespace dat
|
|
|
|
{
|
|
|
|
class File;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace exd
|
|
|
|
{
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
enum Language : uint16_t;
|
2020-02-10 14:05:04 +11:00
|
|
|
|
|
|
|
// Header file for exd data
|
|
|
|
class Exh
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// The header file
|
|
|
|
Exh( const dat::File& i_file );
|
|
|
|
|
|
|
|
~Exh();
|
|
|
|
|
|
|
|
const ExhHeader& get_header() const;
|
|
|
|
|
|
|
|
const std::vector< ExhExdDef >& get_exd_defs() const;
|
|
|
|
|
|
|
|
const std::vector< Language >& get_languages() const;
|
|
|
|
|
|
|
|
const std::map< uint32_t, ExhMember >& get_members() const;
|
|
|
|
|
|
|
|
const std::vector< ExhMember >& get_exh_members() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ExhHeader _header;
|
|
|
|
// Members of the datastruct ordered(indexed) by offset
|
|
|
|
std::map< uint32_t, ExhMember > _members;
|
|
|
|
std::vector< ExhMember > _exh_defs;
|
|
|
|
std::vector< ExhExdDef > _exd_defs;
|
|
|
|
std::vector< Language > _languages;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2018-10-24 23:31:26 +11:00
|
|
|
}
|
|
|
|
|