CommonLibSSE NG
Loading...
Searching...
No Matches
ExtraDataList.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/B/BSAtomic.h"
4#include "RE/B/BSExtraData.h"
7#include "RE/E/ExtraFlags.h"
9#include "RE/F/FormTypes.h"
10#include "RE/M/MemoryManager.h"
11#include "RE/S/SoulLevels.h"
12
13namespace RE
14{
15 class InventoryChanges;
16 class TESBoundObject;
17
19 {
20 public:
22 {
23 public:
24 [[nodiscard]] bool HasType(std::uint32_t a_type) const;
25 void MarkType(std::uint32_t a_type, bool a_cleared);
26
27 // members
28 std::uint8_t bits[0x18]; // 00
29 };
30 static_assert(sizeof(PresenceBitfield) == 0x18);
31
32 [[nodiscard]] BSExtraData*& GetData() noexcept;
33
34 [[nodiscard]] const BSExtraData*& GetData() const noexcept;
35
36 [[nodiscard]] PresenceBitfield*& GetPresence() noexcept;
37
38 [[nodiscard]] const PresenceBitfield*& GetPresence() const noexcept;
39
40#ifndef ENABLE_SKYRIM_AE
41 ~BaseExtraList(); // 00, virtual on AE 1.6.629 and later.
42
43 // members
44 BSExtraData* data = nullptr; // 00, 08
45 PresenceBitfield* presence = nullptr; // 08, 10
46#endif
47 };
48#ifndef ENABLE_SKYRIM_AE
49 static_assert(sizeof(BaseExtraList) == 0x10);
50#endif
51
53 {
54 public:
55 template <class T>
57 {
58 public:
59 using difference_type = std::ptrdiff_t;
60 using value_type = T;
63 using iterator_category = std::forward_iterator_tag;
64
65 constexpr iterator_base() noexcept :
66 _cur(nullptr)
67 {}
68
69 constexpr iterator_base(pointer a_node) noexcept :
70 _cur(a_node)
71 {}
72
73 constexpr iterator_base(const iterator_base& a_rhs) noexcept :
74 _cur(a_rhs._cur)
75 {}
76
77 constexpr iterator_base(iterator_base&& a_rhs) noexcept :
78 _cur(std::move(a_rhs._cur))
79 {
80 a_rhs._cur = nullptr;
81 }
82
83 ~iterator_base() = default;
84
85 constexpr iterator_base& operator=(const iterator_base& a_rhs) noexcept
86 {
87 if (this != std::addressof(a_rhs)) {
88 _cur = a_rhs._cur;
89 }
90 return *this;
91 }
92
93 constexpr iterator_base& operator=(iterator_base&& a_rhs) noexcept
94 {
95 if (this != std::addressof(a_rhs)) {
96 _cur = a_rhs._cur;
97 a_rhs._cur = nullptr;
98 }
99 return *this;
100 }
101
102 [[nodiscard]] constexpr reference operator*() const noexcept { return *_cur; }
103 [[nodiscard]] constexpr pointer operator->() const noexcept { return _cur; }
104
105 [[nodiscard]] constexpr friend bool operator==(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return a_lhs._cur == a_rhs._cur; }
106 [[nodiscard]] constexpr friend bool operator!=(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return !(a_lhs == a_rhs); }
107
108 // prefix
109 constexpr iterator_base& operator++() noexcept
110 {
111 assert(_cur != nullptr);
112 _cur = _cur->next;
113 return *this;
114 }
115
116 // postfix
117 [[nodiscard]] constexpr iterator_base operator++(int) noexcept
118 {
119 iterator_base tmp{ *this };
120 ++(*this);
121 return tmp;
122 }
123
124 inline friend void swap(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept
125 {
126 std::swap(a_lhs._cur, a_rhs._cur);
127 }
128
129 private:
130 pointer _cur;
131 };
132
135
138
140
147
149 const BSExtraData* GetByType(ExtraDataType a_type) const;
150
151 template <class T>
152 inline T* GetByType()
153 {
154 return static_cast<T*>(GetByType(T::EXTRADATATYPE));
155 }
156
157 template <class T>
158 inline const T* GetByType() const
159 {
160 return static_cast<const T*>(GetByType(T::EXTRADATATYPE));
161 }
162
163 bool HasType(ExtraDataType a_type) const;
164
165 template <class T>
166 inline bool HasType() const
167 {
168 return HasType(T::EXTRADATATYPE);
169 }
170
171 bool Remove(ExtraDataType a_type, BSExtraData* a_toRemove);
172
173 template <class T>
174 inline bool Remove(T* a_toRemove)
175 {
176 return Remove(T::EXTRADATATYPE, a_toRemove);
177 }
178
180
183 std::int32_t GetCount() const;
184 const char* GetDisplayName(TESBoundObject* a_baseObject);
191 void SetCount(std::uint16_t a_count);
193 void SetExtraFlags(ExtraFlags::Flag a_flags, bool a_enable);
195 void SetOwner(TESForm* a_owner);
196
197 private:
198 [[nodiscard]] BSExtraData* GetByTypeImpl(ExtraDataType a_type) const;
199 void MarkType(std::uint32_t a_type, bool a_cleared);
200 void MarkType(ExtraDataType a_type, bool a_cleared);
201 [[nodiscard]] BSReadWriteLock& GetLock() const noexcept;
202
203 // members
204 BaseExtraList _extraData; // 00
205#ifndef ENABLE_SKYRIM_AE
206 mutable BSReadWriteLock _lock; // 10, 18; offset 18 only for AE versions .629 and later.
207#endif
208 };
209}
Definition BGSEncounterZone.h:43
Definition BGSKeyword.h:10
Definition BSExtraData.h:9
Definition BSAtomic.h:69
Definition ExtraDataList.h:19
PresenceBitfield *& GetPresence() noexcept
BSExtraData *& GetData() noexcept
PresenceBitfield * presence
Definition ExtraDataList.h:45
BSExtraData * data
Definition ExtraDataList.h:44
Definition ExtraDataList.h:57
constexpr reference operator*() const noexcept
Definition ExtraDataList.h:102
value_type & reference
Definition ExtraDataList.h:62
constexpr iterator_base & operator++() noexcept
Definition ExtraDataList.h:109
constexpr iterator_base & operator=(iterator_base &&a_rhs) noexcept
Definition ExtraDataList.h:93
constexpr iterator_base & operator=(const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:85
value_type * pointer
Definition ExtraDataList.h:61
std::ptrdiff_t difference_type
Definition ExtraDataList.h:59
constexpr friend bool operator!=(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:106
constexpr iterator_base() noexcept
Definition ExtraDataList.h:65
constexpr iterator_base(iterator_base &&a_rhs) noexcept
Definition ExtraDataList.h:77
friend void swap(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:124
std::forward_iterator_tag iterator_category
Definition ExtraDataList.h:63
constexpr iterator_base operator++(int) noexcept
Definition ExtraDataList.h:117
constexpr friend bool operator==(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:105
T value_type
Definition ExtraDataList.h:60
constexpr iterator_base(const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:73
constexpr pointer operator->() const noexcept
Definition ExtraDataList.h:103
constexpr iterator_base(pointer a_node) noexcept
Definition ExtraDataList.h:69
Definition ExtraDataList.h:53
void SetEncounterZone(BGSEncounterZone *a_zone)
const_iterator cbegin() const
BSExtraData * Add(BSExtraData *a_toAdd)
const_iterator end() const
TESForm * GetOwner()
bool HasType() const
Definition ExtraDataList.h:166
BSExtraData * GetByType(ExtraDataType a_type)
iterator begin()
ObjectRefHandle GetAshPileRef()
void SetOwner(TESForm *a_owner)
const_iterator cend() const
TESObjectREFR * GetLinkedRef(BGSKeyword *a_keyword)
bool RemoveByType(ExtraDataType a_type)
const T * GetByType() const
Definition ExtraDataList.h:158
const_iterator begin() const
SOUL_LEVEL GetSoulLevel() const
bool HasType(ExtraDataType a_type) const
T * GetByType()
Definition ExtraDataList.h:152
ObjectRefHandle GetTeleportLinkedDoor()
bool Remove(T *a_toRemove)
Definition ExtraDataList.h:174
void SetCount(std::uint16_t a_count)
const BSExtraData * GetByType(ExtraDataType a_type) const
const char * GetDisplayName(TESBoundObject *a_baseObject)
ExtraTextDisplayData * GetExtraTextDisplayData()
bool Remove(ExtraDataType a_type, BSExtraData *a_toRemove)
std::int32_t GetCount() const
BGSEncounterZone * GetEncounterZone()
void SetInventoryChanges(InventoryChanges *a_changes)
void SetExtraFlags(ExtraFlags::Flag a_flags, bool a_enable)
Flag
Definition ExtraFlags.h:15
Definition ExtraTextDisplayData.h:14
Definition InventoryChanges.h:16
Definition TESBoundObject.h:24
Definition TESForm.h:35
Definition TESObjectREFR.h:112
Definition AbsorbEffect.h:6
SOUL_LEVEL
Definition SoulLevels.h:6
ExtraDataType
Definition ExtraDataTypes.h:173
Definition ExtraDataList.h:22
bool HasType(std::uint32_t a_type) const
void MarkType(std::uint32_t a_type, bool a_cleared)
std::uint8_t bits[0x18]
Definition ExtraDataList.h:28