Removed constructor from FourCC, made free function. Modified codegen to match, and fixed a small formatting issue. Created UnknownHeader for use in a single read approach.

This commit is contained in:
2022-10-27 11:13:10 +11:00
parent 50074b6f0d
commit 93a0bad14d
8 changed files with 387 additions and 245 deletions

View File

@@ -1,5 +1,5 @@
#ifndef ESX_READER_H
#define ESX_READER_H
#ifndef ESX_READER_HPP
#define ESX_READER_HPP
#include <memory>
#include <variant>
@@ -62,24 +62,11 @@ enum class RecordType {
WEAP, WOOP, WRLD, WTHR,
};
//
// Type aliases
//
using Node = std::variant<GroupNode, RecordNode>;
//
// Aggregate types
//
#pragma warning( push )
#pragma warning( disable : 4514 )
struct FourCC : utility::Store<uint32_t> {
constexpr FourCC() noexcept = default;
explicit constexpr FourCC(const char(&str)[5]) noexcept : Store{ utility::fourcc_lit_to_val(str) } { }
};
#pragma warning( pop )
struct FourCC : utility::Store<uint32_t> { };
struct FormID : utility::Store<uint32_t> { };
struct Timestamp : utility::Store<uint16_t> { };
struct VCInfo : utility::Store<uint16_t> { };
@@ -96,6 +83,11 @@ struct RefrFlag {
friend constexpr auto operator<=>(const RefrFlag &, const RefrFlag &) noexcept = default;
};
struct UnknownHeader {
FourCC type;
std::array<char, 20> reserved;
};
struct GroupHeader {
struct Coord {
int16_t y, x;
@@ -121,7 +113,7 @@ struct GroupHeader {
ParentDialogue parent_dialogue;
};
RecordType grup;
FourCC grup;
uint32_t size;
GroupLabel label;
GroupType type;
@@ -134,7 +126,7 @@ struct RecordHeader {
struct Flags : utility::Store<uint32_t> { };
struct Version : utility::Store<uint16_t> { };
RecordType type;
FourCC type;
uint32_t size;
Flags flags;
FormID formid;
@@ -152,19 +144,20 @@ template <typename T, size_t N>
concept packed = sizeof(T) == N;
template <typename T>
concept is_header = std::is_same_v<T, GroupHeader> || std::is_same_v<T, RecordHeader>;
concept header = std::is_same_v<T, GroupHeader> || std::is_same_v<T, RecordHeader> || std::is_same_v<T, UnknownHeader>;
template <typename T>
concept packed_header = is_header<T> && packed<T, static_cast<std::size_t>(header_size)>;
concept packed_header = header<T> && packed<T, static_cast<std::size_t>(header_size)>;
template <typename T>
concept directly_readable_header = packed_header<T> && same_endianness;
//
// Classes
//
using Node = std::variant<GroupNode, RecordNode>;
class GroupNode {
private:
GroupHeader m_header;
@@ -188,7 +181,15 @@ private:
[[nodiscard]] std::optional<std::string_view> flag_to_description(Flag flag) noexcept;
[[nodiscard]] std::optional<std::string_view> refr_flag_to_description(RefrFlag refr_flag) noexcept;
void read_header(std::ifstream &in, directly_readable_header auto &out)
// Convert a compatible C string to a FourCC (e.g. "LITR")
constexpr FourCC fourcc_from_cstr(const char(&a)[5]) noexcept
{
char temp[4] = { a[0], a[1], a[2], a[3] };
return std::bit_cast<FourCC, char[4]>(temp);
}
inline void read_header(std::ifstream &in, directly_readable_header auto &out)
{
auto char_ptr = reinterpret_cast<char *>(&out);
in.read(char_ptr, header_size);
@@ -196,4 +197,4 @@ void read_header(std::ifstream &in, directly_readable_header auto &out)
}
#endif
#endif // ESX_READER_HPP

View File

@@ -16,74 +16,142 @@ static constexpr std::pair<GroupType, std::string_view> group_type_name_map_buil
};
static constexpr std::pair<RecordType, FourCC> record_type_fourcc_map_builtin[] {
{RecordType::AACT, FourCC("AACT")}, {RecordType::ACHR, FourCC("ACHR")},
{RecordType::ACTI, FourCC("ACTI")}, {RecordType::ADDN, FourCC("ADDN")},
{RecordType::ALCH, FourCC("ALCH")}, {RecordType::AMMO, FourCC("AMMO")},
{RecordType::ANIO, FourCC("ANIO")}, {RecordType::APPA, FourCC("APPA")},
{RecordType::ARMA, FourCC("ARMA")}, {RecordType::ARMO, FourCC("ARMO")},
{RecordType::ARTO, FourCC("ARTO")}, {RecordType::ASPC, FourCC("ASPC")},
{RecordType::ASTP, FourCC("ASTP")}, {RecordType::AVIF, FourCC("AVIF")},
{RecordType::BOOK, FourCC("BOOK")}, {RecordType::BPTD, FourCC("BPTD")},
{RecordType::CAMS, FourCC("CAMS")}, {RecordType::CELL, FourCC("CELL")},
{RecordType::CLAS, FourCC("CLAS")}, {RecordType::CLDC, FourCC("CLDC")},
{RecordType::CLFM, FourCC("CLFM")}, {RecordType::CLMT, FourCC("CLMT")},
{RecordType::COBJ, FourCC("COBJ")}, {RecordType::COLL, FourCC("COLL")},
{RecordType::CONT, FourCC("CONT")}, {RecordType::CPTH, FourCC("CPTH")},
{RecordType::CSTY, FourCC("CSTY")}, {RecordType::DEBR, FourCC("DEBR")},
{RecordType::DIAL, FourCC("DIAL")}, {RecordType::DLBR, FourCC("DLBR")},
{RecordType::DLVW, FourCC("DLVW")}, {RecordType::DOBJ, FourCC("DOBJ")},
{RecordType::DOOR, FourCC("DOOR")}, {RecordType::DUAL, FourCC("DUAL")},
{RecordType::ECZN, FourCC("ECZN")}, {RecordType::EFSH, FourCC("EFSH")},
{RecordType::ENCH, FourCC("ENCH")}, {RecordType::EQUP, FourCC("EQUP")},
{RecordType::EXPL, FourCC("EXPL")}, {RecordType::EYES, FourCC("EYES")},
{RecordType::FACT, FourCC("FACT")}, {RecordType::FLOR, FourCC("FLOR")},
{RecordType::FLST, FourCC("FLST")}, {RecordType::FSTP, FourCC("FSTP")},
{RecordType::FSTS, FourCC("FSTS")}, {RecordType::FURN, FourCC("FURN")},
{RecordType::GLOB, FourCC("GLOB")}, {RecordType::GMST, FourCC("GMST")},
{RecordType::GRAS, FourCC("GRAS")}, {RecordType::GRUP, FourCC("GRUP")},
{RecordType::HAIR, FourCC("HAIR")}, {RecordType::HAZD, FourCC("HAZD")},
{RecordType::HDPT, FourCC("HDPT")}, {RecordType::IDLE, FourCC("IDLE")},
{RecordType::IDLM, FourCC("IDLM")}, {RecordType::IMAD, FourCC("IMAD")},
{RecordType::IMGS, FourCC("IMGS")}, {RecordType::INFO, FourCC("INFO")},
{RecordType::INGR, FourCC("INGR")}, {RecordType::IPCT, FourCC("IPCT")},
{RecordType::IPDS, FourCC("IPDS")}, {RecordType::KEYM, FourCC("KEYM")},
{RecordType::KYWD, FourCC("KYWD")}, {RecordType::LAND, FourCC("LAND")},
{RecordType::LCRT, FourCC("LCRT")}, {RecordType::LCTN, FourCC("LCTN")},
{RecordType::LENS, FourCC("LENS")}, {RecordType::LGTM, FourCC("LGTM")},
{RecordType::LIGH, FourCC("LIGH")}, {RecordType::LSCR, FourCC("LSCR")},
{RecordType::LTEX, FourCC("LTEX")}, {RecordType::LVLI, FourCC("LVLI")},
{RecordType::LVLN, FourCC("LVLN")}, {RecordType::LVSP, FourCC("LVSP")},
{RecordType::MATO, FourCC("MATO")}, {RecordType::MATT, FourCC("MATT")},
{RecordType::MESG, FourCC("MESG")}, {RecordType::MGEF, FourCC("MGEF")},
{RecordType::MISC, FourCC("MISC")}, {RecordType::MOVT, FourCC("MOVT")},
{RecordType::MSTT, FourCC("MSTT")}, {RecordType::MUSC, FourCC("MUSC")},
{RecordType::MUST, FourCC("MUST")}, {RecordType::NAVI, FourCC("NAVI")},
{RecordType::NAVM, FourCC("NAVM")}, {RecordType::NOTE, FourCC("NOTE")},
{RecordType::NPC_, FourCC("NPC_")}, {RecordType::OTFT, FourCC("OTFT")},
{RecordType::PACK, FourCC("PACK")}, {RecordType::PARW, FourCC("PARW")},
{RecordType::PBAR, FourCC("PBAR")}, {RecordType::PBEA, FourCC("PBEA")},
{RecordType::PCON, FourCC("PCON")}, {RecordType::PERK, FourCC("PERK")},
{RecordType::PFLA, FourCC("PFLA")}, {RecordType::PGRE, FourCC("PGRE")},
{RecordType::PHZD, FourCC("PHZD")}, {RecordType::PLYR, FourCC("PLYR")},
{RecordType::PMIS, FourCC("PMIS")}, {RecordType::PROJ, FourCC("PROJ")},
{RecordType::PWAT, FourCC("PWAT")}, {RecordType::QUST, FourCC("QUST")},
{RecordType::RACE, FourCC("RACE")}, {RecordType::REFR, FourCC("REFR")},
{RecordType::REGN, FourCC("REGN")}, {RecordType::RELA, FourCC("RELA")},
{RecordType::REVB, FourCC("REVB")}, {RecordType::RFCT, FourCC("RFCT")},
{RecordType::RGDL, FourCC("RGDL")}, {RecordType::SCEN, FourCC("SCEN")},
{RecordType::SCOL, FourCC("SCOL")}, {RecordType::SCPT, FourCC("SCPT")},
{RecordType::SCRL, FourCC("SCRL")}, {RecordType::SHOU, FourCC("SHOU")},
{RecordType::SLGM, FourCC("SLGM")}, {RecordType::SMBN, FourCC("SMBN")},
{RecordType::SMEN, FourCC("SMEN")}, {RecordType::SMQN, FourCC("SMQN")},
{RecordType::SNCT, FourCC("SNCT")}, {RecordType::SNDR, FourCC("SNDR")},
{RecordType::SOPM, FourCC("SOPM")}, {RecordType::SOUN, FourCC("SOUN")},
{RecordType::SPEL, FourCC("SPEL")}, {RecordType::SPGD, FourCC("SPGD")},
{RecordType::STAT, FourCC("STAT")}, {RecordType::TACT, FourCC("TACT")},
{RecordType::TES4, FourCC("TES4")}, {RecordType::TREE, FourCC("TREE")},
{RecordType::TXST, FourCC("TXST")}, {RecordType::VOLI, FourCC("VOLI")},
{RecordType::VTYP, FourCC("VTYP")}, {RecordType::WATR, FourCC("WATR")},
{RecordType::WEAP, FourCC("WEAP")}, {RecordType::WOOP, FourCC("WOOP")},
{RecordType::WRLD, FourCC("WRLD")}, {RecordType::WTHR, FourCC("WTHR")},
{RecordType::AACT, fourcc_from_cstr("AACT")},
{RecordType::ACHR, fourcc_from_cstr("ACHR")},
{RecordType::ACTI, fourcc_from_cstr("ACTI")},
{RecordType::ADDN, fourcc_from_cstr("ADDN")},
{RecordType::ALCH, fourcc_from_cstr("ALCH")},
{RecordType::AMMO, fourcc_from_cstr("AMMO")},
{RecordType::ANIO, fourcc_from_cstr("ANIO")},
{RecordType::APPA, fourcc_from_cstr("APPA")},
{RecordType::ARMA, fourcc_from_cstr("ARMA")},
{RecordType::ARMO, fourcc_from_cstr("ARMO")},
{RecordType::ARTO, fourcc_from_cstr("ARTO")},
{RecordType::ASPC, fourcc_from_cstr("ASPC")},
{RecordType::ASTP, fourcc_from_cstr("ASTP")},
{RecordType::AVIF, fourcc_from_cstr("AVIF")},
{RecordType::BOOK, fourcc_from_cstr("BOOK")},
{RecordType::BPTD, fourcc_from_cstr("BPTD")},
{RecordType::CAMS, fourcc_from_cstr("CAMS")},
{RecordType::CELL, fourcc_from_cstr("CELL")},
{RecordType::CLAS, fourcc_from_cstr("CLAS")},
{RecordType::CLDC, fourcc_from_cstr("CLDC")},
{RecordType::CLFM, fourcc_from_cstr("CLFM")},
{RecordType::CLMT, fourcc_from_cstr("CLMT")},
{RecordType::COBJ, fourcc_from_cstr("COBJ")},
{RecordType::COLL, fourcc_from_cstr("COLL")},
{RecordType::CONT, fourcc_from_cstr("CONT")},
{RecordType::CPTH, fourcc_from_cstr("CPTH")},
{RecordType::CSTY, fourcc_from_cstr("CSTY")},
{RecordType::DEBR, fourcc_from_cstr("DEBR")},
{RecordType::DIAL, fourcc_from_cstr("DIAL")},
{RecordType::DLBR, fourcc_from_cstr("DLBR")},
{RecordType::DLVW, fourcc_from_cstr("DLVW")},
{RecordType::DOBJ, fourcc_from_cstr("DOBJ")},
{RecordType::DOOR, fourcc_from_cstr("DOOR")},
{RecordType::DUAL, fourcc_from_cstr("DUAL")},
{RecordType::ECZN, fourcc_from_cstr("ECZN")},
{RecordType::EFSH, fourcc_from_cstr("EFSH")},
{RecordType::ENCH, fourcc_from_cstr("ENCH")},
{RecordType::EQUP, fourcc_from_cstr("EQUP")},
{RecordType::EXPL, fourcc_from_cstr("EXPL")},
{RecordType::EYES, fourcc_from_cstr("EYES")},
{RecordType::FACT, fourcc_from_cstr("FACT")},
{RecordType::FLOR, fourcc_from_cstr("FLOR")},
{RecordType::FLST, fourcc_from_cstr("FLST")},
{RecordType::FSTP, fourcc_from_cstr("FSTP")},
{RecordType::FSTS, fourcc_from_cstr("FSTS")},
{RecordType::FURN, fourcc_from_cstr("FURN")},
{RecordType::GLOB, fourcc_from_cstr("GLOB")},
{RecordType::GMST, fourcc_from_cstr("GMST")},
{RecordType::GRAS, fourcc_from_cstr("GRAS")},
{RecordType::GRUP, fourcc_from_cstr("GRUP")},
{RecordType::HAIR, fourcc_from_cstr("HAIR")},
{RecordType::HAZD, fourcc_from_cstr("HAZD")},
{RecordType::HDPT, fourcc_from_cstr("HDPT")},
{RecordType::IDLE, fourcc_from_cstr("IDLE")},
{RecordType::IDLM, fourcc_from_cstr("IDLM")},
{RecordType::IMAD, fourcc_from_cstr("IMAD")},
{RecordType::IMGS, fourcc_from_cstr("IMGS")},
{RecordType::INFO, fourcc_from_cstr("INFO")},
{RecordType::INGR, fourcc_from_cstr("INGR")},
{RecordType::IPCT, fourcc_from_cstr("IPCT")},
{RecordType::IPDS, fourcc_from_cstr("IPDS")},
{RecordType::KEYM, fourcc_from_cstr("KEYM")},
{RecordType::KYWD, fourcc_from_cstr("KYWD")},
{RecordType::LAND, fourcc_from_cstr("LAND")},
{RecordType::LCRT, fourcc_from_cstr("LCRT")},
{RecordType::LCTN, fourcc_from_cstr("LCTN")},
{RecordType::LENS, fourcc_from_cstr("LENS")},
{RecordType::LGTM, fourcc_from_cstr("LGTM")},
{RecordType::LIGH, fourcc_from_cstr("LIGH")},
{RecordType::LSCR, fourcc_from_cstr("LSCR")},
{RecordType::LTEX, fourcc_from_cstr("LTEX")},
{RecordType::LVLI, fourcc_from_cstr("LVLI")},
{RecordType::LVLN, fourcc_from_cstr("LVLN")},
{RecordType::LVSP, fourcc_from_cstr("LVSP")},
{RecordType::MATO, fourcc_from_cstr("MATO")},
{RecordType::MATT, fourcc_from_cstr("MATT")},
{RecordType::MESG, fourcc_from_cstr("MESG")},
{RecordType::MGEF, fourcc_from_cstr("MGEF")},
{RecordType::MISC, fourcc_from_cstr("MISC")},
{RecordType::MOVT, fourcc_from_cstr("MOVT")},
{RecordType::MSTT, fourcc_from_cstr("MSTT")},
{RecordType::MUSC, fourcc_from_cstr("MUSC")},
{RecordType::MUST, fourcc_from_cstr("MUST")},
{RecordType::NAVI, fourcc_from_cstr("NAVI")},
{RecordType::NAVM, fourcc_from_cstr("NAVM")},
{RecordType::NOTE, fourcc_from_cstr("NOTE")},
{RecordType::NPC_, fourcc_from_cstr("NPC_")},
{RecordType::OTFT, fourcc_from_cstr("OTFT")},
{RecordType::PACK, fourcc_from_cstr("PACK")},
{RecordType::PARW, fourcc_from_cstr("PARW")},
{RecordType::PBAR, fourcc_from_cstr("PBAR")},
{RecordType::PBEA, fourcc_from_cstr("PBEA")},
{RecordType::PCON, fourcc_from_cstr("PCON")},
{RecordType::PERK, fourcc_from_cstr("PERK")},
{RecordType::PFLA, fourcc_from_cstr("PFLA")},
{RecordType::PGRE, fourcc_from_cstr("PGRE")},
{RecordType::PHZD, fourcc_from_cstr("PHZD")},
{RecordType::PLYR, fourcc_from_cstr("PLYR")},
{RecordType::PMIS, fourcc_from_cstr("PMIS")},
{RecordType::PROJ, fourcc_from_cstr("PROJ")},
{RecordType::PWAT, fourcc_from_cstr("PWAT")},
{RecordType::QUST, fourcc_from_cstr("QUST")},
{RecordType::RACE, fourcc_from_cstr("RACE")},
{RecordType::REFR, fourcc_from_cstr("REFR")},
{RecordType::REGN, fourcc_from_cstr("REGN")},
{RecordType::RELA, fourcc_from_cstr("RELA")},
{RecordType::REVB, fourcc_from_cstr("REVB")},
{RecordType::RFCT, fourcc_from_cstr("RFCT")},
{RecordType::RGDL, fourcc_from_cstr("RGDL")},
{RecordType::SCEN, fourcc_from_cstr("SCEN")},
{RecordType::SCOL, fourcc_from_cstr("SCOL")},
{RecordType::SCPT, fourcc_from_cstr("SCPT")},
{RecordType::SCRL, fourcc_from_cstr("SCRL")},
{RecordType::SHOU, fourcc_from_cstr("SHOU")},
{RecordType::SLGM, fourcc_from_cstr("SLGM")},
{RecordType::SMBN, fourcc_from_cstr("SMBN")},
{RecordType::SMEN, fourcc_from_cstr("SMEN")},
{RecordType::SMQN, fourcc_from_cstr("SMQN")},
{RecordType::SNCT, fourcc_from_cstr("SNCT")},
{RecordType::SNDR, fourcc_from_cstr("SNDR")},
{RecordType::SOPM, fourcc_from_cstr("SOPM")},
{RecordType::SOUN, fourcc_from_cstr("SOUN")},
{RecordType::SPEL, fourcc_from_cstr("SPEL")},
{RecordType::SPGD, fourcc_from_cstr("SPGD")},
{RecordType::STAT, fourcc_from_cstr("STAT")},
{RecordType::TACT, fourcc_from_cstr("TACT")},
{RecordType::TES4, fourcc_from_cstr("TES4")},
{RecordType::TREE, fourcc_from_cstr("TREE")},
{RecordType::TXST, fourcc_from_cstr("TXST")},
{RecordType::VOLI, fourcc_from_cstr("VOLI")},
{RecordType::VTYP, fourcc_from_cstr("VTYP")},
{RecordType::WATR, fourcc_from_cstr("WATR")},
{RecordType::WEAP, fourcc_from_cstr("WEAP")},
{RecordType::WOOP, fourcc_from_cstr("WOOP")},
{RecordType::WRLD, fourcc_from_cstr("WRLD")},
{RecordType::WTHR, fourcc_from_cstr("WTHR")},
};
static constexpr std::pair<RecordType, std::string_view> record_type_name_map_builtin[] {
@@ -405,14 +473,14 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::ACTI, 26}, "Filter (Collision Geometry)" },
{{RecordType::ACTI, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::ACTI, 28}, "Reflected By Auto Water" },
{{RecordType::ACTI, 29}, "Don''t Havok Settle" },
{{RecordType::ACTI, 29}, "Don't Havok Settle" },
{{RecordType::ACTI, 30}, "No Respawn" },
{{RecordType::ACTI, 31}, "Multibound" },
{{RecordType::ADDN, 10}, "Persistent" },
{{RecordType::ADDN, 11}, "Initially Disabled" },
{{RecordType::ADDN, 16}, "Is Full LOD" },
{{RecordType::ADDN, 28}, "Reflected By Auto Water" },
{{RecordType::ADDN, 29}, "Don''t Havok Settle" },
{{RecordType::ADDN, 29}, "Don't Havok Settle" },
{{RecordType::ADDN, 30}, "No Respawn" },
{{RecordType::ADDN, 31}, "Multibound" },
{{RecordType::ALCH, 10}, "Persistent" },
@@ -420,7 +488,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::ALCH, 16}, "Is Full LOD" },
{{RecordType::ALCH, 25}, "No AI Acquire" },
{{RecordType::ALCH, 28}, "Reflected By Auto Water" },
{{RecordType::ALCH, 29}, "Don''t Havok Settle" },
{{RecordType::ALCH, 29}, "Don't Havok Settle" },
{{RecordType::ALCH, 30}, "No Respawn" },
{{RecordType::ALCH, 31}, "Multibound" },
{{RecordType::AMMO, 10}, "Persistent" },
@@ -428,7 +496,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::AMMO, 16}, "Is Full LOD" },
{{RecordType::AMMO, 25}, "No AI Acquire" },
{{RecordType::AMMO, 28}, "Reflected By Auto Water" },
{{RecordType::AMMO, 29}, "Don''t Havok Settle" },
{{RecordType::AMMO, 29}, "Don't Havok Settle" },
{{RecordType::AMMO, 30}, "No Respawn" },
{{RecordType::AMMO, 31}, "Multibound" },
{{RecordType::ARMO, 10}, "Persistent" },
@@ -436,7 +504,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::ARMO, 16}, "Is Full LOD" },
{{RecordType::ARMO, 25}, "No AI Acquire" },
{{RecordType::ARMO, 28}, "Reflected By Auto Water" },
{{RecordType::ARMO, 29}, "Don''t Havok Settle" },
{{RecordType::ARMO, 29}, "Don't Havok Settle" },
{{RecordType::ARMO, 30}, "No Respawn" },
{{RecordType::ARMO, 31}, "Multibound" },
{{RecordType::BOOK, 10}, "Persistent" },
@@ -444,7 +512,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::BOOK, 16}, "Is Full LOD" },
{{RecordType::BOOK, 25}, "No AI Acquire" },
{{RecordType::BOOK, 28}, "Reflected By Auto Water" },
{{RecordType::BOOK, 29}, "Don''t Havok Settle" },
{{RecordType::BOOK, 29}, "Don't Havok Settle" },
{{RecordType::BOOK, 30}, "No Respawn" },
{{RecordType::BOOK, 31}, "Multibound" },
{{RecordType::CONT, 10}, "Persistent" },
@@ -454,7 +522,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::CONT, 26}, "Filter (Collision Geometry)" },
{{RecordType::CONT, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::CONT, 28}, "Reflected By Auto Water" },
{{RecordType::CONT, 29}, "Don''t Havok Settle" },
{{RecordType::CONT, 29}, "Don't Havok Settle" },
{{RecordType::CONT, 30}, "Ground" },
{{RecordType::CONT, 31}, "Multibound" },
{{RecordType::DOOR, 6}, "Hidden From Local Map" },
@@ -465,7 +533,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::DOOR, 26}, "Filter (Collision Geometry)" },
{{RecordType::DOOR, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::DOOR, 28}, "Reflected By Auto Water" },
{{RecordType::DOOR, 29}, "Don''t Havok Settle" },
{{RecordType::DOOR, 29}, "Don't Havok Settle" },
{{RecordType::DOOR, 30}, "No Respawn" },
{{RecordType::DOOR, 31}, "Multibound" },
{{RecordType::FLOR, 9}, "Hidden From Local Map" },
@@ -477,7 +545,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::FLOR, 26}, "Filter (Collision Geometry)" },
{{RecordType::FLOR, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::FLOR, 28}, "Reflected By Auto Water" },
{{RecordType::FLOR, 29}, "Don''t Havok Settle" },
{{RecordType::FLOR, 29}, "Don't Havok Settle" },
{{RecordType::FLOR, 30}, "No Respawn" },
{{RecordType::FLOR, 31}, "Multibound" },
{{RecordType::INGR, 10}, "Persistent" },
@@ -485,7 +553,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::INGR, 16}, "Is Full LOD" },
{{RecordType::INGR, 25}, "No AI Acquire" },
{{RecordType::INGR, 28}, "Reflected By Auto Water" },
{{RecordType::INGR, 29}, "Don''t Havok Settle" },
{{RecordType::INGR, 29}, "Don't Havok Settle" },
{{RecordType::INGR, 30}, "No Respawn" },
{{RecordType::INGR, 31}, "Multibound" },
{{RecordType::KEYM, 10}, "Persistent" },
@@ -493,18 +561,18 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::KEYM, 16}, "Is Full LOD" },
{{RecordType::KEYM, 25}, "No AI Acquire" },
{{RecordType::KEYM, 28}, "Reflected By Auto Water" },
{{RecordType::KEYM, 29}, "Don''t Havok Settle" },
{{RecordType::KEYM, 29}, "Don't Havok Settle" },
{{RecordType::KEYM, 30}, "No Respawn" },
{{RecordType::KEYM, 31}, "Multibound" },
{{RecordType::LIGH, 8}, "Doesn''t Light Water" },
{{RecordType::LIGH, 8}, "Doesn't Light Water" },
{{RecordType::LIGH, 9}, "Casts Shadows" },
{{RecordType::LIGH, 10}, "Persistent" },
{{RecordType::LIGH, 11}, "Initially Disabled" },
{{RecordType::LIGH, 16}, "Never Fades" },
{{RecordType::LIGH, 17}, "Doesn''t Light Landscape" },
{{RecordType::LIGH, 17}, "Doesn't Light Landscape" },
{{RecordType::LIGH, 25}, "No AI Acquire" },
{{RecordType::LIGH, 28}, "Reflected By Auto Water" },
{{RecordType::LIGH, 29}, "Don''t Havok Settle" },
{{RecordType::LIGH, 29}, "Don't Havok Settle" },
{{RecordType::LIGH, 30}, "No Respawn" },
{{RecordType::LIGH, 31}, "Multibound" },
{{RecordType::MISC, 10}, "Persistent" },
@@ -512,7 +580,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::MISC, 16}, "Is Full LOD" },
{{RecordType::MISC, 25}, "No AI Acquire" },
{{RecordType::MISC, 28}, "Reflected By Auto Water" },
{{RecordType::MISC, 29}, "Don''t Havok Settle" },
{{RecordType::MISC, 29}, "Don't Havok Settle" },
{{RecordType::MISC, 30}, "No Respawn" },
{{RecordType::MISC, 31}, "Multibound" },
{{RecordType::MSTT, 9}, "Motion Blur" },
@@ -522,7 +590,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::MSTT, 26}, "Filter (Collision Geometry)" },
{{RecordType::MSTT, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::MSTT, 28}, "Reflected By Auto Water" },
{{RecordType::MSTT, 29}, "Don''t Havok Settle" },
{{RecordType::MSTT, 29}, "Don't Havok Settle" },
{{RecordType::MSTT, 30}, "No Respawn" },
{{RecordType::MSTT, 31}, "Multibound" },
{{RecordType::SCRL, 10}, "Persistent" },
@@ -530,7 +598,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::SCRL, 16}, "Is Full LOD" },
{{RecordType::SCRL, 25}, "No AI Acquire" },
{{RecordType::SCRL, 28}, "Reflected By Auto Water" },
{{RecordType::SCRL, 29}, "Don''t Havok Settle" },
{{RecordType::SCRL, 29}, "Don't Havok Settle" },
{{RecordType::SCRL, 30}, "No Respawn" },
{{RecordType::SCRL, 31}, "Multibound" },
{{RecordType::SLGM, 10}, "Persistent" },
@@ -538,7 +606,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::SLGM, 16}, "Is Full LOD" },
{{RecordType::SLGM, 25}, "No AI Acquire" },
{{RecordType::SLGM, 28}, "Reflected By Auto Water" },
{{RecordType::SLGM, 29}, "Don''t Havok Settle" },
{{RecordType::SLGM, 29}, "Don't Havok Settle" },
{{RecordType::SLGM, 30}, "No Respawn" },
{{RecordType::SLGM, 31}, "Multibound" },
{{RecordType::STAT, 9}, "Hidden From Local Map" },
@@ -550,7 +618,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::STAT, 26}, "Filter (Collision Geometry)" },
{{RecordType::STAT, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::STAT, 28}, "Reflected By Auto Water" },
{{RecordType::STAT, 29}, "Don''t Havok Settle" },
{{RecordType::STAT, 29}, "Don't Havok Settle" },
{{RecordType::STAT, 30}, "No Respawn" },
{{RecordType::STAT, 31}, "Multibound" },
{{RecordType::TREE, 9}, "Hidden From Local Map" },
@@ -562,7 +630,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::TREE, 26}, "Filter (Collision Geometry)" },
{{RecordType::TREE, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::TREE, 28}, "Reflected By Auto Water" },
{{RecordType::TREE, 29}, "Don''t Havok Settle" },
{{RecordType::TREE, 29}, "Don't Havok Settle" },
{{RecordType::TREE, 30}, "No Respawn" },
{{RecordType::TREE, 31}, "Multibound" },
{{RecordType::WEAP, 10}, "Persistent" },
@@ -570,7 +638,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::WEAP, 16}, "Is Full LOD" },
{{RecordType::WEAP, 25}, "No AI Acquire" },
{{RecordType::WEAP, 28}, "Reflected By Auto Water" },
{{RecordType::WEAP, 29}, "Don''t Havok Settle" },
{{RecordType::WEAP, 29}, "Don't Havok Settle" },
{{RecordType::WEAP, 30}, "No Respawn" },
{{RecordType::WEAP, 31}, "Multibound" },
};

View File

@@ -24,7 +24,7 @@ static constexpr auto esm_name = "Skyrim.esm";
int main()
{
auto esm_fs = open_esm();
esxr::RecordHeader header{};
esxr::UnknownHeader header{};
esxr::read_header(esm_fs, header);
return static_cast<int>(header.type);
return static_cast<int>(esxr::fourcc_to_record_type(header.type).value());
}

View File

@@ -1,4 +1,5 @@
#pragma once
#ifndef UTILITY_HPP
#define UTILITY_HPP
#include <array>
#include <optional>
@@ -6,6 +7,14 @@
namespace utility {
// iterator distance as size type, provided iterator must be dereferencable
template <typename T>
T::size_type index_of(const T &container, typename T::const_iterator &iter)
{
auto distance = std::distance(std::cbegin(container), iter);
return static_cast<T::size_type>(distance);
}
// This is a base class for a generic store for some value that can be represented by
// type T but should not be type checked as type T, but rather some more constrained class.
template <class T>
@@ -15,13 +24,6 @@ struct Store {
friend constexpr auto operator<=>(const Store &, const Store &) noexcept = default;
};
// Convert a fourcc literal (e.g. "LITR") to a uint32_t
constexpr uint32_t fourcc_lit_to_val(const char(&a)[5]) noexcept
{
char temp[4] = { a[0], a[1], a[2], a[3] };
return std::bit_cast<uint32_t, char[4]>(temp);
}
// Convert a builtin array to a std::array
template <typename T, std::size_t N>
constexpr std::array<T, N> array_builtin_to_std(const T(&builtin)[N]) noexcept
@@ -50,8 +52,8 @@ constexpr std::optional<Second> soa_first_to_second(const std::pair<std::array<F
auto lhs = std::find(soa.first.cbegin(), soa.first.cend(), first);
if (lhs == soa.first.cend())
return {};
auto index = std::distance(soa.first.cbegin(), lhs);
return { soa.second[static_cast<size_t>(index)] };
auto index = index_of(soa.first, lhs);
return { soa.second[index] };
}
template <typename First, typename Second, std::size_t N>
@@ -60,8 +62,8 @@ constexpr std::optional<First> soa_second_to_first(const std::pair<std::array<Fi
auto lhs = std::find(soa.second.cbegin(), soa.second.cend(), second);
if (lhs == soa.second.cend())
return {};
auto index = std::distance(soa.second.cbegin(), lhs);
return { soa.first[static_cast<size_t>(index)] };
auto index = index_of(soa.second, lhs);
return { soa.first[index] };
}
// Used to inspect type sizes and values at compile time. Example:
@@ -79,3 +81,4 @@ class TD;
}
#endif // UTILITY_HPP

View File

@@ -16,74 +16,142 @@ static constexpr std::pair<GroupType, std::string_view> group_type_name_map_buil
};
static constexpr std::pair<RecordType, FourCC> record_type_fourcc_map_builtin[] {
{RecordType::AACT, FourCC("AACT")}, {RecordType::ACHR, FourCC("ACHR")},
{RecordType::ACTI, FourCC("ACTI")}, {RecordType::ADDN, FourCC("ADDN")},
{RecordType::ALCH, FourCC("ALCH")}, {RecordType::AMMO, FourCC("AMMO")},
{RecordType::ANIO, FourCC("ANIO")}, {RecordType::APPA, FourCC("APPA")},
{RecordType::ARMA, FourCC("ARMA")}, {RecordType::ARMO, FourCC("ARMO")},
{RecordType::ARTO, FourCC("ARTO")}, {RecordType::ASPC, FourCC("ASPC")},
{RecordType::ASTP, FourCC("ASTP")}, {RecordType::AVIF, FourCC("AVIF")},
{RecordType::BOOK, FourCC("BOOK")}, {RecordType::BPTD, FourCC("BPTD")},
{RecordType::CAMS, FourCC("CAMS")}, {RecordType::CELL, FourCC("CELL")},
{RecordType::CLAS, FourCC("CLAS")}, {RecordType::CLDC, FourCC("CLDC")},
{RecordType::CLFM, FourCC("CLFM")}, {RecordType::CLMT, FourCC("CLMT")},
{RecordType::COBJ, FourCC("COBJ")}, {RecordType::COLL, FourCC("COLL")},
{RecordType::CONT, FourCC("CONT")}, {RecordType::CPTH, FourCC("CPTH")},
{RecordType::CSTY, FourCC("CSTY")}, {RecordType::DEBR, FourCC("DEBR")},
{RecordType::DIAL, FourCC("DIAL")}, {RecordType::DLBR, FourCC("DLBR")},
{RecordType::DLVW, FourCC("DLVW")}, {RecordType::DOBJ, FourCC("DOBJ")},
{RecordType::DOOR, FourCC("DOOR")}, {RecordType::DUAL, FourCC("DUAL")},
{RecordType::ECZN, FourCC("ECZN")}, {RecordType::EFSH, FourCC("EFSH")},
{RecordType::ENCH, FourCC("ENCH")}, {RecordType::EQUP, FourCC("EQUP")},
{RecordType::EXPL, FourCC("EXPL")}, {RecordType::EYES, FourCC("EYES")},
{RecordType::FACT, FourCC("FACT")}, {RecordType::FLOR, FourCC("FLOR")},
{RecordType::FLST, FourCC("FLST")}, {RecordType::FSTP, FourCC("FSTP")},
{RecordType::FSTS, FourCC("FSTS")}, {RecordType::FURN, FourCC("FURN")},
{RecordType::GLOB, FourCC("GLOB")}, {RecordType::GMST, FourCC("GMST")},
{RecordType::GRAS, FourCC("GRAS")}, {RecordType::GRUP, FourCC("GRUP")},
{RecordType::HAIR, FourCC("HAIR")}, {RecordType::HAZD, FourCC("HAZD")},
{RecordType::HDPT, FourCC("HDPT")}, {RecordType::IDLE, FourCC("IDLE")},
{RecordType::IDLM, FourCC("IDLM")}, {RecordType::IMAD, FourCC("IMAD")},
{RecordType::IMGS, FourCC("IMGS")}, {RecordType::INFO, FourCC("INFO")},
{RecordType::INGR, FourCC("INGR")}, {RecordType::IPCT, FourCC("IPCT")},
{RecordType::IPDS, FourCC("IPDS")}, {RecordType::KEYM, FourCC("KEYM")},
{RecordType::KYWD, FourCC("KYWD")}, {RecordType::LAND, FourCC("LAND")},
{RecordType::LCRT, FourCC("LCRT")}, {RecordType::LCTN, FourCC("LCTN")},
{RecordType::LENS, FourCC("LENS")}, {RecordType::LGTM, FourCC("LGTM")},
{RecordType::LIGH, FourCC("LIGH")}, {RecordType::LSCR, FourCC("LSCR")},
{RecordType::LTEX, FourCC("LTEX")}, {RecordType::LVLI, FourCC("LVLI")},
{RecordType::LVLN, FourCC("LVLN")}, {RecordType::LVSP, FourCC("LVSP")},
{RecordType::MATO, FourCC("MATO")}, {RecordType::MATT, FourCC("MATT")},
{RecordType::MESG, FourCC("MESG")}, {RecordType::MGEF, FourCC("MGEF")},
{RecordType::MISC, FourCC("MISC")}, {RecordType::MOVT, FourCC("MOVT")},
{RecordType::MSTT, FourCC("MSTT")}, {RecordType::MUSC, FourCC("MUSC")},
{RecordType::MUST, FourCC("MUST")}, {RecordType::NAVI, FourCC("NAVI")},
{RecordType::NAVM, FourCC("NAVM")}, {RecordType::NOTE, FourCC("NOTE")},
{RecordType::NPC_, FourCC("NPC_")}, {RecordType::OTFT, FourCC("OTFT")},
{RecordType::PACK, FourCC("PACK")}, {RecordType::PARW, FourCC("PARW")},
{RecordType::PBAR, FourCC("PBAR")}, {RecordType::PBEA, FourCC("PBEA")},
{RecordType::PCON, FourCC("PCON")}, {RecordType::PERK, FourCC("PERK")},
{RecordType::PFLA, FourCC("PFLA")}, {RecordType::PGRE, FourCC("PGRE")},
{RecordType::PHZD, FourCC("PHZD")}, {RecordType::PLYR, FourCC("PLYR")},
{RecordType::PMIS, FourCC("PMIS")}, {RecordType::PROJ, FourCC("PROJ")},
{RecordType::PWAT, FourCC("PWAT")}, {RecordType::QUST, FourCC("QUST")},
{RecordType::RACE, FourCC("RACE")}, {RecordType::REFR, FourCC("REFR")},
{RecordType::REGN, FourCC("REGN")}, {RecordType::RELA, FourCC("RELA")},
{RecordType::REVB, FourCC("REVB")}, {RecordType::RFCT, FourCC("RFCT")},
{RecordType::RGDL, FourCC("RGDL")}, {RecordType::SCEN, FourCC("SCEN")},
{RecordType::SCOL, FourCC("SCOL")}, {RecordType::SCPT, FourCC("SCPT")},
{RecordType::SCRL, FourCC("SCRL")}, {RecordType::SHOU, FourCC("SHOU")},
{RecordType::SLGM, FourCC("SLGM")}, {RecordType::SMBN, FourCC("SMBN")},
{RecordType::SMEN, FourCC("SMEN")}, {RecordType::SMQN, FourCC("SMQN")},
{RecordType::SNCT, FourCC("SNCT")}, {RecordType::SNDR, FourCC("SNDR")},
{RecordType::SOPM, FourCC("SOPM")}, {RecordType::SOUN, FourCC("SOUN")},
{RecordType::SPEL, FourCC("SPEL")}, {RecordType::SPGD, FourCC("SPGD")},
{RecordType::STAT, FourCC("STAT")}, {RecordType::TACT, FourCC("TACT")},
{RecordType::TES4, FourCC("TES4")}, {RecordType::TREE, FourCC("TREE")},
{RecordType::TXST, FourCC("TXST")}, {RecordType::VOLI, FourCC("VOLI")},
{RecordType::VTYP, FourCC("VTYP")}, {RecordType::WATR, FourCC("WATR")},
{RecordType::WEAP, FourCC("WEAP")}, {RecordType::WOOP, FourCC("WOOP")},
{RecordType::WRLD, FourCC("WRLD")}, {RecordType::WTHR, FourCC("WTHR")},
{RecordType::AACT, fourcc_from_cstr("AACT")},
{RecordType::ACHR, fourcc_from_cstr("ACHR")},
{RecordType::ACTI, fourcc_from_cstr("ACTI")},
{RecordType::ADDN, fourcc_from_cstr("ADDN")},
{RecordType::ALCH, fourcc_from_cstr("ALCH")},
{RecordType::AMMO, fourcc_from_cstr("AMMO")},
{RecordType::ANIO, fourcc_from_cstr("ANIO")},
{RecordType::APPA, fourcc_from_cstr("APPA")},
{RecordType::ARMA, fourcc_from_cstr("ARMA")},
{RecordType::ARMO, fourcc_from_cstr("ARMO")},
{RecordType::ARTO, fourcc_from_cstr("ARTO")},
{RecordType::ASPC, fourcc_from_cstr("ASPC")},
{RecordType::ASTP, fourcc_from_cstr("ASTP")},
{RecordType::AVIF, fourcc_from_cstr("AVIF")},
{RecordType::BOOK, fourcc_from_cstr("BOOK")},
{RecordType::BPTD, fourcc_from_cstr("BPTD")},
{RecordType::CAMS, fourcc_from_cstr("CAMS")},
{RecordType::CELL, fourcc_from_cstr("CELL")},
{RecordType::CLAS, fourcc_from_cstr("CLAS")},
{RecordType::CLDC, fourcc_from_cstr("CLDC")},
{RecordType::CLFM, fourcc_from_cstr("CLFM")},
{RecordType::CLMT, fourcc_from_cstr("CLMT")},
{RecordType::COBJ, fourcc_from_cstr("COBJ")},
{RecordType::COLL, fourcc_from_cstr("COLL")},
{RecordType::CONT, fourcc_from_cstr("CONT")},
{RecordType::CPTH, fourcc_from_cstr("CPTH")},
{RecordType::CSTY, fourcc_from_cstr("CSTY")},
{RecordType::DEBR, fourcc_from_cstr("DEBR")},
{RecordType::DIAL, fourcc_from_cstr("DIAL")},
{RecordType::DLBR, fourcc_from_cstr("DLBR")},
{RecordType::DLVW, fourcc_from_cstr("DLVW")},
{RecordType::DOBJ, fourcc_from_cstr("DOBJ")},
{RecordType::DOOR, fourcc_from_cstr("DOOR")},
{RecordType::DUAL, fourcc_from_cstr("DUAL")},
{RecordType::ECZN, fourcc_from_cstr("ECZN")},
{RecordType::EFSH, fourcc_from_cstr("EFSH")},
{RecordType::ENCH, fourcc_from_cstr("ENCH")},
{RecordType::EQUP, fourcc_from_cstr("EQUP")},
{RecordType::EXPL, fourcc_from_cstr("EXPL")},
{RecordType::EYES, fourcc_from_cstr("EYES")},
{RecordType::FACT, fourcc_from_cstr("FACT")},
{RecordType::FLOR, fourcc_from_cstr("FLOR")},
{RecordType::FLST, fourcc_from_cstr("FLST")},
{RecordType::FSTP, fourcc_from_cstr("FSTP")},
{RecordType::FSTS, fourcc_from_cstr("FSTS")},
{RecordType::FURN, fourcc_from_cstr("FURN")},
{RecordType::GLOB, fourcc_from_cstr("GLOB")},
{RecordType::GMST, fourcc_from_cstr("GMST")},
{RecordType::GRAS, fourcc_from_cstr("GRAS")},
{RecordType::GRUP, fourcc_from_cstr("GRUP")},
{RecordType::HAIR, fourcc_from_cstr("HAIR")},
{RecordType::HAZD, fourcc_from_cstr("HAZD")},
{RecordType::HDPT, fourcc_from_cstr("HDPT")},
{RecordType::IDLE, fourcc_from_cstr("IDLE")},
{RecordType::IDLM, fourcc_from_cstr("IDLM")},
{RecordType::IMAD, fourcc_from_cstr("IMAD")},
{RecordType::IMGS, fourcc_from_cstr("IMGS")},
{RecordType::INFO, fourcc_from_cstr("INFO")},
{RecordType::INGR, fourcc_from_cstr("INGR")},
{RecordType::IPCT, fourcc_from_cstr("IPCT")},
{RecordType::IPDS, fourcc_from_cstr("IPDS")},
{RecordType::KEYM, fourcc_from_cstr("KEYM")},
{RecordType::KYWD, fourcc_from_cstr("KYWD")},
{RecordType::LAND, fourcc_from_cstr("LAND")},
{RecordType::LCRT, fourcc_from_cstr("LCRT")},
{RecordType::LCTN, fourcc_from_cstr("LCTN")},
{RecordType::LENS, fourcc_from_cstr("LENS")},
{RecordType::LGTM, fourcc_from_cstr("LGTM")},
{RecordType::LIGH, fourcc_from_cstr("LIGH")},
{RecordType::LSCR, fourcc_from_cstr("LSCR")},
{RecordType::LTEX, fourcc_from_cstr("LTEX")},
{RecordType::LVLI, fourcc_from_cstr("LVLI")},
{RecordType::LVLN, fourcc_from_cstr("LVLN")},
{RecordType::LVSP, fourcc_from_cstr("LVSP")},
{RecordType::MATO, fourcc_from_cstr("MATO")},
{RecordType::MATT, fourcc_from_cstr("MATT")},
{RecordType::MESG, fourcc_from_cstr("MESG")},
{RecordType::MGEF, fourcc_from_cstr("MGEF")},
{RecordType::MISC, fourcc_from_cstr("MISC")},
{RecordType::MOVT, fourcc_from_cstr("MOVT")},
{RecordType::MSTT, fourcc_from_cstr("MSTT")},
{RecordType::MUSC, fourcc_from_cstr("MUSC")},
{RecordType::MUST, fourcc_from_cstr("MUST")},
{RecordType::NAVI, fourcc_from_cstr("NAVI")},
{RecordType::NAVM, fourcc_from_cstr("NAVM")},
{RecordType::NOTE, fourcc_from_cstr("NOTE")},
{RecordType::NPC_, fourcc_from_cstr("NPC_")},
{RecordType::OTFT, fourcc_from_cstr("OTFT")},
{RecordType::PACK, fourcc_from_cstr("PACK")},
{RecordType::PARW, fourcc_from_cstr("PARW")},
{RecordType::PBAR, fourcc_from_cstr("PBAR")},
{RecordType::PBEA, fourcc_from_cstr("PBEA")},
{RecordType::PCON, fourcc_from_cstr("PCON")},
{RecordType::PERK, fourcc_from_cstr("PERK")},
{RecordType::PFLA, fourcc_from_cstr("PFLA")},
{RecordType::PGRE, fourcc_from_cstr("PGRE")},
{RecordType::PHZD, fourcc_from_cstr("PHZD")},
{RecordType::PLYR, fourcc_from_cstr("PLYR")},
{RecordType::PMIS, fourcc_from_cstr("PMIS")},
{RecordType::PROJ, fourcc_from_cstr("PROJ")},
{RecordType::PWAT, fourcc_from_cstr("PWAT")},
{RecordType::QUST, fourcc_from_cstr("QUST")},
{RecordType::RACE, fourcc_from_cstr("RACE")},
{RecordType::REFR, fourcc_from_cstr("REFR")},
{RecordType::REGN, fourcc_from_cstr("REGN")},
{RecordType::RELA, fourcc_from_cstr("RELA")},
{RecordType::REVB, fourcc_from_cstr("REVB")},
{RecordType::RFCT, fourcc_from_cstr("RFCT")},
{RecordType::RGDL, fourcc_from_cstr("RGDL")},
{RecordType::SCEN, fourcc_from_cstr("SCEN")},
{RecordType::SCOL, fourcc_from_cstr("SCOL")},
{RecordType::SCPT, fourcc_from_cstr("SCPT")},
{RecordType::SCRL, fourcc_from_cstr("SCRL")},
{RecordType::SHOU, fourcc_from_cstr("SHOU")},
{RecordType::SLGM, fourcc_from_cstr("SLGM")},
{RecordType::SMBN, fourcc_from_cstr("SMBN")},
{RecordType::SMEN, fourcc_from_cstr("SMEN")},
{RecordType::SMQN, fourcc_from_cstr("SMQN")},
{RecordType::SNCT, fourcc_from_cstr("SNCT")},
{RecordType::SNDR, fourcc_from_cstr("SNDR")},
{RecordType::SOPM, fourcc_from_cstr("SOPM")},
{RecordType::SOUN, fourcc_from_cstr("SOUN")},
{RecordType::SPEL, fourcc_from_cstr("SPEL")},
{RecordType::SPGD, fourcc_from_cstr("SPGD")},
{RecordType::STAT, fourcc_from_cstr("STAT")},
{RecordType::TACT, fourcc_from_cstr("TACT")},
{RecordType::TES4, fourcc_from_cstr("TES4")},
{RecordType::TREE, fourcc_from_cstr("TREE")},
{RecordType::TXST, fourcc_from_cstr("TXST")},
{RecordType::VOLI, fourcc_from_cstr("VOLI")},
{RecordType::VTYP, fourcc_from_cstr("VTYP")},
{RecordType::WATR, fourcc_from_cstr("WATR")},
{RecordType::WEAP, fourcc_from_cstr("WEAP")},
{RecordType::WOOP, fourcc_from_cstr("WOOP")},
{RecordType::WRLD, fourcc_from_cstr("WRLD")},
{RecordType::WTHR, fourcc_from_cstr("WTHR")},
};
static constexpr std::pair<RecordType, std::string_view> record_type_name_map_builtin[] {
@@ -405,14 +473,14 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::ACTI, 26}, "Filter (Collision Geometry)" },
{{RecordType::ACTI, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::ACTI, 28}, "Reflected By Auto Water" },
{{RecordType::ACTI, 29}, "Don''t Havok Settle" },
{{RecordType::ACTI, 29}, "Don't Havok Settle" },
{{RecordType::ACTI, 30}, "No Respawn" },
{{RecordType::ACTI, 31}, "Multibound" },
{{RecordType::ADDN, 10}, "Persistent" },
{{RecordType::ADDN, 11}, "Initially Disabled" },
{{RecordType::ADDN, 16}, "Is Full LOD" },
{{RecordType::ADDN, 28}, "Reflected By Auto Water" },
{{RecordType::ADDN, 29}, "Don''t Havok Settle" },
{{RecordType::ADDN, 29}, "Don't Havok Settle" },
{{RecordType::ADDN, 30}, "No Respawn" },
{{RecordType::ADDN, 31}, "Multibound" },
{{RecordType::ALCH, 10}, "Persistent" },
@@ -420,7 +488,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::ALCH, 16}, "Is Full LOD" },
{{RecordType::ALCH, 25}, "No AI Acquire" },
{{RecordType::ALCH, 28}, "Reflected By Auto Water" },
{{RecordType::ALCH, 29}, "Don''t Havok Settle" },
{{RecordType::ALCH, 29}, "Don't Havok Settle" },
{{RecordType::ALCH, 30}, "No Respawn" },
{{RecordType::ALCH, 31}, "Multibound" },
{{RecordType::AMMO, 10}, "Persistent" },
@@ -428,7 +496,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::AMMO, 16}, "Is Full LOD" },
{{RecordType::AMMO, 25}, "No AI Acquire" },
{{RecordType::AMMO, 28}, "Reflected By Auto Water" },
{{RecordType::AMMO, 29}, "Don''t Havok Settle" },
{{RecordType::AMMO, 29}, "Don't Havok Settle" },
{{RecordType::AMMO, 30}, "No Respawn" },
{{RecordType::AMMO, 31}, "Multibound" },
{{RecordType::ARMO, 10}, "Persistent" },
@@ -436,7 +504,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::ARMO, 16}, "Is Full LOD" },
{{RecordType::ARMO, 25}, "No AI Acquire" },
{{RecordType::ARMO, 28}, "Reflected By Auto Water" },
{{RecordType::ARMO, 29}, "Don''t Havok Settle" },
{{RecordType::ARMO, 29}, "Don't Havok Settle" },
{{RecordType::ARMO, 30}, "No Respawn" },
{{RecordType::ARMO, 31}, "Multibound" },
{{RecordType::BOOK, 10}, "Persistent" },
@@ -444,7 +512,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::BOOK, 16}, "Is Full LOD" },
{{RecordType::BOOK, 25}, "No AI Acquire" },
{{RecordType::BOOK, 28}, "Reflected By Auto Water" },
{{RecordType::BOOK, 29}, "Don''t Havok Settle" },
{{RecordType::BOOK, 29}, "Don't Havok Settle" },
{{RecordType::BOOK, 30}, "No Respawn" },
{{RecordType::BOOK, 31}, "Multibound" },
{{RecordType::CONT, 10}, "Persistent" },
@@ -454,7 +522,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::CONT, 26}, "Filter (Collision Geometry)" },
{{RecordType::CONT, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::CONT, 28}, "Reflected By Auto Water" },
{{RecordType::CONT, 29}, "Don''t Havok Settle" },
{{RecordType::CONT, 29}, "Don't Havok Settle" },
{{RecordType::CONT, 30}, "Ground" },
{{RecordType::CONT, 31}, "Multibound" },
{{RecordType::DOOR, 6}, "Hidden From Local Map" },
@@ -465,7 +533,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::DOOR, 26}, "Filter (Collision Geometry)" },
{{RecordType::DOOR, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::DOOR, 28}, "Reflected By Auto Water" },
{{RecordType::DOOR, 29}, "Don''t Havok Settle" },
{{RecordType::DOOR, 29}, "Don't Havok Settle" },
{{RecordType::DOOR, 30}, "No Respawn" },
{{RecordType::DOOR, 31}, "Multibound" },
{{RecordType::FLOR, 9}, "Hidden From Local Map" },
@@ -477,7 +545,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::FLOR, 26}, "Filter (Collision Geometry)" },
{{RecordType::FLOR, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::FLOR, 28}, "Reflected By Auto Water" },
{{RecordType::FLOR, 29}, "Don''t Havok Settle" },
{{RecordType::FLOR, 29}, "Don't Havok Settle" },
{{RecordType::FLOR, 30}, "No Respawn" },
{{RecordType::FLOR, 31}, "Multibound" },
{{RecordType::INGR, 10}, "Persistent" },
@@ -485,7 +553,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::INGR, 16}, "Is Full LOD" },
{{RecordType::INGR, 25}, "No AI Acquire" },
{{RecordType::INGR, 28}, "Reflected By Auto Water" },
{{RecordType::INGR, 29}, "Don''t Havok Settle" },
{{RecordType::INGR, 29}, "Don't Havok Settle" },
{{RecordType::INGR, 30}, "No Respawn" },
{{RecordType::INGR, 31}, "Multibound" },
{{RecordType::KEYM, 10}, "Persistent" },
@@ -493,18 +561,18 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::KEYM, 16}, "Is Full LOD" },
{{RecordType::KEYM, 25}, "No AI Acquire" },
{{RecordType::KEYM, 28}, "Reflected By Auto Water" },
{{RecordType::KEYM, 29}, "Don''t Havok Settle" },
{{RecordType::KEYM, 29}, "Don't Havok Settle" },
{{RecordType::KEYM, 30}, "No Respawn" },
{{RecordType::KEYM, 31}, "Multibound" },
{{RecordType::LIGH, 8}, "Doesn''t Light Water" },
{{RecordType::LIGH, 8}, "Doesn't Light Water" },
{{RecordType::LIGH, 9}, "Casts Shadows" },
{{RecordType::LIGH, 10}, "Persistent" },
{{RecordType::LIGH, 11}, "Initially Disabled" },
{{RecordType::LIGH, 16}, "Never Fades" },
{{RecordType::LIGH, 17}, "Doesn''t Light Landscape" },
{{RecordType::LIGH, 17}, "Doesn't Light Landscape" },
{{RecordType::LIGH, 25}, "No AI Acquire" },
{{RecordType::LIGH, 28}, "Reflected By Auto Water" },
{{RecordType::LIGH, 29}, "Don''t Havok Settle" },
{{RecordType::LIGH, 29}, "Don't Havok Settle" },
{{RecordType::LIGH, 30}, "No Respawn" },
{{RecordType::LIGH, 31}, "Multibound" },
{{RecordType::MISC, 10}, "Persistent" },
@@ -512,7 +580,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::MISC, 16}, "Is Full LOD" },
{{RecordType::MISC, 25}, "No AI Acquire" },
{{RecordType::MISC, 28}, "Reflected By Auto Water" },
{{RecordType::MISC, 29}, "Don''t Havok Settle" },
{{RecordType::MISC, 29}, "Don't Havok Settle" },
{{RecordType::MISC, 30}, "No Respawn" },
{{RecordType::MISC, 31}, "Multibound" },
{{RecordType::MSTT, 9}, "Motion Blur" },
@@ -522,7 +590,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::MSTT, 26}, "Filter (Collision Geometry)" },
{{RecordType::MSTT, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::MSTT, 28}, "Reflected By Auto Water" },
{{RecordType::MSTT, 29}, "Don''t Havok Settle" },
{{RecordType::MSTT, 29}, "Don't Havok Settle" },
{{RecordType::MSTT, 30}, "No Respawn" },
{{RecordType::MSTT, 31}, "Multibound" },
{{RecordType::SCRL, 10}, "Persistent" },
@@ -530,7 +598,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::SCRL, 16}, "Is Full LOD" },
{{RecordType::SCRL, 25}, "No AI Acquire" },
{{RecordType::SCRL, 28}, "Reflected By Auto Water" },
{{RecordType::SCRL, 29}, "Don''t Havok Settle" },
{{RecordType::SCRL, 29}, "Don't Havok Settle" },
{{RecordType::SCRL, 30}, "No Respawn" },
{{RecordType::SCRL, 31}, "Multibound" },
{{RecordType::SLGM, 10}, "Persistent" },
@@ -538,7 +606,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::SLGM, 16}, "Is Full LOD" },
{{RecordType::SLGM, 25}, "No AI Acquire" },
{{RecordType::SLGM, 28}, "Reflected By Auto Water" },
{{RecordType::SLGM, 29}, "Don''t Havok Settle" },
{{RecordType::SLGM, 29}, "Don't Havok Settle" },
{{RecordType::SLGM, 30}, "No Respawn" },
{{RecordType::SLGM, 31}, "Multibound" },
{{RecordType::STAT, 9}, "Hidden From Local Map" },
@@ -550,7 +618,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::STAT, 26}, "Filter (Collision Geometry)" },
{{RecordType::STAT, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::STAT, 28}, "Reflected By Auto Water" },
{{RecordType::STAT, 29}, "Don''t Havok Settle" },
{{RecordType::STAT, 29}, "Don't Havok Settle" },
{{RecordType::STAT, 30}, "No Respawn" },
{{RecordType::STAT, 31}, "Multibound" },
{{RecordType::TREE, 9}, "Hidden From Local Map" },
@@ -562,7 +630,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::TREE, 26}, "Filter (Collision Geometry)" },
{{RecordType::TREE, 27}, "Bounding Box (Collision Geometry)"},
{{RecordType::TREE, 28}, "Reflected By Auto Water" },
{{RecordType::TREE, 29}, "Don''t Havok Settle" },
{{RecordType::TREE, 29}, "Don't Havok Settle" },
{{RecordType::TREE, 30}, "No Respawn" },
{{RecordType::TREE, 31}, "Multibound" },
{{RecordType::WEAP, 10}, "Persistent" },
@@ -570,7 +638,7 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::WEAP, 16}, "Is Full LOD" },
{{RecordType::WEAP, 25}, "No AI Acquire" },
{{RecordType::WEAP, 28}, "Reflected By Auto Water" },
{{RecordType::WEAP, 29}, "Don''t Havok Settle" },
{{RecordType::WEAP, 29}, "Don't Havok Settle" },
{{RecordType::WEAP, 30}, "No Respawn" },
{{RecordType::WEAP, 31}, "Multibound" },
};

View File

@@ -164,7 +164,7 @@ record_fourcc_map = Map(
first_name = "record_type",
second_name = "fourcc",
reverse = True,
formats = ["RecordType::{0}", ", FourCC(\"{0}\")"],
formats = ["RecordType::{0}", ", fourcc_from_cstr(\"{0}\")"],
data = [(x['fourcc'], ) for x in record_data]
)
flag_desc_map = Map(

View File

@@ -66,7 +66,9 @@ for index, flist in enumerate(flag_lists):
for line in flist.strip().split('\n'):
match = re_flag_line.match(line).groups()
assert len(match) == 2, "Could not parse flag line."
flags += [Flag(int(match[0]), match[1])]
# fix pascal '' in string literal oddity
desc = match[1].replace("''", "'")
flags += [Flag(int(match[0]), desc)]
index_to_flag_list[index] = flags
# create list of records

View File

@@ -40,7 +40,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -73,7 +73,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -110,7 +110,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -147,7 +147,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -184,7 +184,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -221,7 +221,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -266,7 +266,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -315,7 +315,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -368,7 +368,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -405,7 +405,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -442,7 +442,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -459,7 +459,7 @@
"flags": [
{
"bit": 8,
"description": "Doesn''t Light Water"
"description": "Doesn't Light Water"
},
{
"bit": 9,
@@ -479,7 +479,7 @@
},
{
"bit": 17,
"description": "Doesn''t Light Landscape"
"description": "Doesn't Light Landscape"
},
{
"bit": 25,
@@ -491,7 +491,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -528,7 +528,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -573,7 +573,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -610,7 +610,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -647,7 +647,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -700,7 +700,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -753,7 +753,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,
@@ -790,7 +790,7 @@
},
{
"bit": 29,
"description": "Don''t Havok Settle"
"description": "Don't Havok Settle"
},
{
"bit": 30,