Core/Misc: Refactor some updatefield constant creation code to work around msvc internal compiler errors

This commit is contained in:
Shauren
2022-08-13 19:34:15 +02:00
parent 6d23e429c3
commit 1d5696a08b
2 changed files with 22 additions and 10 deletions

View File

@@ -726,7 +726,7 @@ namespace UF
{
};
template<typename T, std::size_t Size_>
template<typename T, std::size_t Size>
class UpdateFieldArrayBase : public UpdateFieldArrayBaseWithoutSize<T>
{
template<typename F, bool PublicSet>
@@ -740,7 +740,6 @@ namespace UF
public:
using value_type = T;
static constexpr std::size_t Size = Size_;
T const* begin() const
{
@@ -752,7 +751,7 @@ namespace UF
return std::end(_values);
}
constexpr std::size_t size() const
static constexpr std::size_t size()
{
return Size;
}
@@ -766,6 +765,19 @@ namespace UF
T _values[Size] = {};
};
// workaround functions for internal compiler errors in msvc 19.33.31629
template<typename T>
constexpr std::size_t size()
{
return T::size();
}
template<typename T>
constexpr std::size_t size_of_value_type()
{
return sizeof(typename T::value_type);
}
template<typename T, std::size_t Size, uint32 Bit, uint32 FirstElementBit>
class UpdateFieldArray : public UpdateFieldArrayBase<T, Size>
{

View File

@@ -124,13 +124,13 @@ typedef std::deque<Mail*> PlayerMails;
enum PlayerSkillsConstants
{
PLAYER_MAX_SKILLS = decltype(UF::SkillInfo::SkillLineID)::Size
PLAYER_MAX_SKILLS = UF::size<decltype(UF::SkillInfo::SkillLineID)>()
};
enum PlayerExplorationConstants
{
PLAYER_EXPLORED_ZONES_SIZE = decltype(UF::ActivePlayerData::ExploredZones)::Size,
PLAYER_EXPLORED_ZONES_BITS = sizeof(decltype(UF::ActivePlayerData::ExploredZones)::value_type) * 8
PLAYER_EXPLORED_ZONES_SIZE = UF::size<decltype(UF::ActivePlayerData::ExploredZones)>(),
PLAYER_EXPLORED_ZONES_BITS = UF::size_of_value_type<decltype(UF::ActivePlayerData::ExploredZones)>() * 8
};
enum SpellModType : uint8
@@ -586,13 +586,13 @@ typedef std::map<uint32, QuestSaveType> QuestStatusSaveMap;
// Size of client completed quests bit map
enum PlayerQuestCompletedConstants
{
QUESTS_COMPLETED_BITS_SIZE = decltype(UF::ActivePlayerData::QuestCompleted)::Size,
QUESTS_COMPLETED_BITS_PER_BLOCK = sizeof(decltype(UF::ActivePlayerData::QuestCompleted)::value_type) * 8
QUESTS_COMPLETED_BITS_SIZE = UF::size<decltype(UF::ActivePlayerData::QuestCompleted)>(),
QUESTS_COMPLETED_BITS_PER_BLOCK = UF::size_of_value_type<decltype(UF::ActivePlayerData::QuestCompleted)>() * 8
};
enum PlayerQuestLogConstants
{
MAX_QUEST_COUNTS = decltype(UF::QuestLog::ObjectiveProgress)::Size
MAX_QUEST_COUNTS = UF::size<decltype(UF::QuestLog::ObjectiveProgress)>()
};
enum QuestSlotStateMask
@@ -635,7 +635,7 @@ enum PlayerSlots
PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
};
static_assert(decltype(UF::ActivePlayerData::InvSlots)::Size == PLAYER_SLOT_END);
static_assert(UF::size<decltype(UF::ActivePlayerData::InvSlots)>() == PLAYER_SLOT_END);
#define INVENTORY_SLOT_BAG_0 255
#define INVENTORY_DEFAULT_SIZE 16