Fixed namespacing issues. Added spaceship to Flag and RefrFlag. Codegen needs to be updated to reflect changes.

This commit is contained in:
2022-10-24 16:28:42 +11:00
parent ab6eae3d1c
commit 188b462e68
3 changed files with 54 additions and 50 deletions

View File

@@ -75,11 +75,13 @@ struct VCInfo : utility::Store<uint16_t> { };
struct Flag {
RecordType type;
unsigned bit;
friend constexpr auto operator<=>(const Flag &, const Flag &) noexcept = default;
};
struct RefrFlag {
RecordType refr_type;
unsigned bit;
friend constexpr auto operator<=>(const RefrFlag &, const RefrFlag &) noexcept = default;
};
struct GroupHeader {
@@ -152,12 +154,13 @@ private:
// Free functions
//
[[nodiscard]] constexpr std::optional<std::string_view> esxr_lut::group_type_to_name(GroupType group_type) noexcept;
[[nodiscard]] constexpr std::optional<FourCC> esxr_lut::record_type_to_fourcc(RecordType record_type) noexcept;
[[nodiscard]] constexpr std::optional<RecordType> esxr_lut::fourcc_to_record_type(FourCC fourcc) noexcept;
[[nodiscard]] constexpr std::optional<std::string_view> esxr_lut::record_type_to_name(RecordType record_type) noexcept;
[[nodiscard]] constexpr std::optional<std::string_view> esxr_lut::flag_to_description(Flag flag) noexcept;
[[nodiscard]] constexpr std::optional<std::string_view> esxr_lut::refr_flag_to_description(RefrFlag refr_flag) noexcept;
[[nodiscard]] extern constexpr std::optional<std::string_view> group_type_to_name(GroupType group_type) noexcept;
[[nodiscard]] extern constexpr std::optional<FourCC> record_type_to_fourcc(RecordType record_type) noexcept;
[[nodiscard]] extern constexpr std::optional<RecordType> fourcc_to_record_type(FourCC fourcc) noexcept;
[[nodiscard]] extern constexpr std::optional<std::string_view> record_type_to_name(RecordType record_type) noexcept;
[[nodiscard]] extern constexpr std::optional<std::string_view> flag_to_description(Flag flag) noexcept;
[[nodiscard]] extern constexpr std::optional<std::string_view> refr_flag_to_description(RefrFlag refr_flag) noexcept;
}
#endif

View File

@@ -2,8 +2,6 @@
using namespace esxr;
namespace esxr_lut {
static constexpr std::pair<GroupType, std::string_view> group_type_name_map_builtin[] {
{GroupType::Top , "Top Type" },
{GroupType::WorldChildren , "World Children" },
@@ -18,10 +16,6 @@ static constexpr std::pair<GroupType, std::string_view> group_type_name_map_buil
};
static constexpr auto group_type_name_map_std = utility::array_builtin_to_std(group_type_name_map_builtin);
static constexpr auto group_type_name_map = utility::map_to_soa(group_type_name_map_std);
[[nodiscard]] constexpr std::optional<std::string_view> group_type_to_name(GroupType group_type) noexcept
{
return utility::soa_first_to_second(group_type_name_map, group_type);
}
static constexpr std::pair<RecordType, FourCC> record_type_fourcc_map_builtin[] {
{RecordType::AACT, FourCC("AACT")}, {RecordType::ACHR, FourCC("ACHR")},
@@ -95,14 +89,6 @@ static constexpr std::pair<RecordType, FourCC> record_type_fourcc_map_builtin[]
};
static constexpr auto record_type_fourcc_map_std = utility::array_builtin_to_std(record_type_fourcc_map_builtin);
static constexpr auto record_type_fourcc_map = utility::map_to_soa(record_type_fourcc_map_std);
[[nodiscard]] constexpr std::optional<FourCC> record_type_to_fourcc(RecordType record_type) noexcept
{
return utility::soa_first_to_second(record_type_fourcc_map, record_type);
}
[[nodiscard]] constexpr std::optional<RecordType> fourcc_to_record_type(FourCC fourcc) noexcept
{
return utility::soa_second_to_first(record_type_fourcc_map, fourcc);
}
static constexpr std::pair<RecordType, std::string_view> record_type_name_map_builtin[] {
{RecordType::AACT, "Action" },
@@ -244,10 +230,6 @@ static constexpr std::pair<RecordType, std::string_view> record_type_name_map_bu
};
static constexpr auto record_type_name_map_std = utility::array_builtin_to_std(record_type_name_map_builtin);
static constexpr auto record_type_name_map = utility::map_to_soa(record_type_name_map_std);
[[nodiscard]] constexpr std::optional<std::string_view> record_type_to_name(RecordType record_type) noexcept
{
return utility::soa_first_to_second(record_type_name_map, record_type);
}
static constexpr std::pair<Flag, std::string_view> flag_description_map_builtin[] {
{{RecordType::ACHR, 9}, "Starts Dead" },
@@ -420,10 +402,6 @@ static constexpr std::pair<Flag, std::string_view> flag_description_map_builtin[
};
static constexpr auto flag_description_map_std = utility::array_builtin_to_std(flag_description_map_builtin);
static constexpr auto flag_description_map = utility::map_to_soa(flag_description_map_std);
[[nodiscard]] constexpr std::optional<std::string_view> flag_to_description(Flag flag) noexcept
{
return utility::soa_first_to_second(flag_description_map, flag);
}
static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map_builtin[] {
{{RecordType::ACTI, 9}, "Hidden From Local Map" },
@@ -606,6 +584,29 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
};
static constexpr auto refr_flag_description_map_std = utility::array_builtin_to_std(refr_flag_description_map_builtin);
static constexpr auto refr_flag_description_map = utility::map_to_soa(refr_flag_description_map_std);
namespace esxr {
[[nodiscard]] constexpr std::optional<std::string_view> group_type_to_name(GroupType group_type) noexcept
{
return utility::soa_first_to_second(group_type_name_map, group_type);
}
[[nodiscard]] constexpr std::optional<FourCC> record_type_to_fourcc(RecordType record_type) noexcept
{
return utility::soa_first_to_second(record_type_fourcc_map, record_type);
}
[[nodiscard]] constexpr std::optional<RecordType> fourcc_to_record_type(FourCC fourcc) noexcept
{
return utility::soa_second_to_first(record_type_fourcc_map, fourcc);
}
[[nodiscard]] constexpr std::optional<std::string_view> record_type_to_name(RecordType record_type) noexcept
{
return utility::soa_first_to_second(record_type_name_map, record_type);
}
[[nodiscard]] constexpr std::optional<std::string_view> flag_to_description(Flag flag) noexcept
{
return utility::soa_first_to_second(flag_description_map, flag);
}
[[nodiscard]] constexpr std::optional<std::string_view> refr_flag_to_description(RefrFlag refr_flag) noexcept
{
return utility::soa_first_to_second(refr_flag_description_map, refr_flag);

View File

@@ -3,5 +3,5 @@
int main()
{
std::cout << "Test" << std::endl;
std::cout << esxr::flag_to_description({ esxr::RecordType::TES4, 0 }).value() << std::endl;
}