Fixed odr violation from trying to separate constexpr functions into declaration and definition in separate files. Modified code gen to be in line with current code.

This commit is contained in:
2022-10-24 20:37:40 +11:00
parent 188b462e68
commit 0048df1875
5 changed files with 192 additions and 144 deletions

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" },
@@ -16,12 +14,6 @@ static constexpr std::pair<GroupType, std::string_view> group_type_name_map_buil
{GroupType::CellPersistentChildren, "Cell Persistent Children"},
{GroupType::CellTemporaryChildren , "Cell Temporary Children" },
};
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")},
@@ -93,16 +85,6 @@ static constexpr std::pair<RecordType, FourCC> record_type_fourcc_map_builtin[]
{RecordType::WEAP, FourCC("WEAP")}, {RecordType::WOOP, FourCC("WOOP")},
{RecordType::WRLD, FourCC("WRLD")}, {RecordType::WTHR, FourCC("WTHR")},
};
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" },
@@ -242,12 +224,6 @@ static constexpr std::pair<RecordType, std::string_view> record_type_name_map_bu
{RecordType::WRLD, "Worldspace" },
{RecordType::WTHR, "Weather" },
};
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" },
@@ -418,12 +394,6 @@ static constexpr std::pair<Flag, std::string_view> flag_description_map_builtin[
{{RecordType::WEAP, 2}, "Non-Playable" },
{{RecordType::WRLD, 19}, "Can't Wait" },
};
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" },
@@ -604,11 +574,47 @@ static constexpr std::pair<RefrFlag, std::string_view> refr_flag_description_map
{{RecordType::WEAP, 30}, "No Respawn" },
{{RecordType::WEAP, 31}, "Multibound" },
};
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);
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);
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);
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);
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);
[[nodiscard]] constexpr std::optional<std::string_view> refr_flag_to_description(RefrFlag refr_flag) noexcept
[[nodiscard]] std::optional<std::string_view> esxr::group_type_to_name(GroupType group_type) noexcept
{
return utility::soa_first_to_second(refr_flag_description_map, refr_flag);
return utility::soa_first_to_second(group_type_name_map, group_type);
}
[[nodiscard]] std::optional<FourCC> esxr::record_type_to_fourcc(RecordType record_type) noexcept
{
return utility::soa_first_to_second(record_type_fourcc_map, record_type);
}
[[nodiscard]] std::optional<RecordType> esxr::fourcc_to_record_type(FourCC fourcc) noexcept
{
return utility::soa_second_to_first(record_type_fourcc_map, fourcc);
}
[[nodiscard]] std::optional<std::string_view> esxr::record_type_to_name(RecordType record_type) noexcept
{
return utility::soa_first_to_second(record_type_name_map, record_type);
}
[[nodiscard]] std::optional<std::string_view> esxr::flag_to_description(Flag flag) noexcept
{
return utility::soa_first_to_second(flag_description_map, flag);
}
[[nodiscard]] std::optional<std::string_view> esxr::refr_flag_to_description(RefrFlag refr_flag) noexcept
{
return utility::soa_first_to_second(refr_flag_description_map, refr_flag);
}