Skip to content

Commit 47317a4

Browse files
committed
feat: ExtraDataList & BGSInventoryList
- from perchik71
1 parent c84949a commit 47317a4

3 files changed

Lines changed: 113 additions & 30 deletions

File tree

include/RE/B/BGSInventoryList.h

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,33 @@ namespace RE
3333
return a_lhs == a_rhs;
3434
}
3535

36-
void FindAndWriteStackDataForItem(
36+
inline void AddItem2(TESBoundObject* a_object, std::uint32_t a_count, ExtraDataList* a_extra, std::uint16_t a_flags = 0) noexcept
37+
{
38+
using func_t = void(*)(BGSInventoryList*, TESBoundObject*, std::uint32_t, ExtraDataList*, std::uint16_t);
39+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::AddItem2 };
40+
func(this, a_object, a_count, a_extra, a_flags);
41+
}
42+
43+
inline void AddItem2(TESBoundObject* a_object, std::uint32_t a_count, std::uint16_t a_flags = 0) noexcept
44+
{
45+
AddItem2(a_object, a_count, new ExtraDataList(), a_flags);
46+
}
47+
48+
inline void BuildFromContainer(const TESContainer* a_container)
49+
{
50+
using func_t = decltype(&BGSInventoryList::BuildFromContainer);
51+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::BuildFromContainer };
52+
func(this, a_container);
53+
}
54+
55+
inline void Clear() noexcept
56+
{
57+
using func_t = decltype(&BGSInventoryList::Clear);
58+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::Clear };
59+
func(this);
60+
}
61+
62+
inline void FindAndWriteStackDataForItem(
3763
TESBoundObject* a_object,
3864
BGSInventoryItem::StackDataCompareFunctor& a_compareFunc,
3965
BGSInventoryItem::StackDataWriteFunctor& a_writeFunc,
@@ -45,8 +71,15 @@ namespace RE
4571
return func(this, a_object, a_compareFunc, a_writeFunc, a_objCompFn, a_alwaysContinue);
4672
}
4773

74+
[[nodiscard]] inline std::uint32_t FindItemIndex(TESBoundObject* a_object) const noexcept
75+
{
76+
using func_t = decltype(&BGSInventoryList::FindItemIndex);
77+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::FindItemIndex };
78+
return func(this, a_object);
79+
}
80+
4881
// DOES NOT LOCK
49-
void ForEachStack(
82+
inline void ForEachStack(
5083
std::function<bool(BGSInventoryItem&)> a_filter, // return true to iterate stacks
5184
std::function<bool(BGSInventoryItem&, BGSInventoryItem::Stack&)> a_continue // return false to return control from function
5285
)
@@ -62,11 +95,30 @@ namespace RE
6295
}
6396
}
6497

65-
void BuildFromContainer(const TESContainer* a_container)
98+
[[nodiscard]] inline std::uint32_t GetItemCount(TESBoundObject* a_object) const noexcept
6699
{
67-
using func_t = decltype(&BGSInventoryList::BuildFromContainer);
68-
static REL::Relocation<func_t> func{ ID::BGSInventoryList::BuildFromContainer };
69-
return func(this, a_container);
100+
using func_t = decltype(&BGSInventoryList::GetItemCount);
101+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::GetItemCount };
102+
return func(this, a_object);
103+
}
104+
105+
[[nodiscard]] inline std::uint32_t GetQuestItemCount(TESBoundObject* a_object) const noexcept
106+
{
107+
using func_t = decltype(&BGSInventoryList::GetQuestItemCount);
108+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::GetQuestItemCount };
109+
return func(this, a_object);
110+
}
111+
112+
inline void RemoveItem1(TESBoundObject* a_object, std::uint32_t a_stackID, std::uint32_t a_count, bool a_manualMerge = false) noexcept
113+
{
114+
using func_t = void(*)(BGSInventoryList*, TESBoundObject*, std::uint32_t, std::uint32_t, bool);
115+
static REL::Relocation<func_t> func{ ID::BGSInventoryList::RemoveItem1 };
116+
func(this, a_object, a_stackID, a_count, a_manualMerge);
117+
}
118+
119+
inline void RemoveItem1(TESBoundObject* a_object, std::uint32_t a_count, bool a_manualMerge = false) noexcept
120+
{
121+
RemoveItem1(a_object, 0, a_count, a_manualMerge);
70122
}
71123

72124
// members
@@ -80,7 +132,7 @@ namespace RE
80132
{
81133
using func_t = decltype(&BGSInventoryList::ctor);
82134
static REL::Relocation<func_t> func{ ID::BGSInventoryList::ctor };
83-
return func(this, a_container, a_owner);
135+
func(this, a_container, a_owner);
84136
}
85137
};
86138
static_assert(sizeof(BGSInventoryList) == 0x80);

include/RE/E/ExtraDataList.h

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,35 @@ namespace RE
3030
public:
3131
F4_HEAP_REDEFINE_NEW(ExtraDataList);
3232

33+
using ComparisonQualifier = bool (*)(const BSExtraData*);
34+
3335
enum class CLEAR_FOR
3436
{
3537
kContainer = 0x0,
3638
kReference = 0x1
3739
};
3840

39-
void AddExtra(BSExtraData* a_extra)
41+
ExtraDataList()
42+
{
43+
using func_t = void(*)(ExtraDataList*);
44+
static REL::Relocation<func_t> func{ ID::ExtraDataList::Ctor };
45+
func(this);
46+
}
47+
48+
inline void AddExtra(BSExtraData* a_extra)
4049
{
4150
const BSAutoWriteLock l{ extraRWLock };
4251
extraData.AddExtra(a_extra);
4352
}
4453

45-
TBO_InstanceData* CreateInstanceData(TESBoundObject* a_object, bool a_generateName)
54+
inline void CopyList(const ExtraDataList* a_copy) noexcept
55+
{
56+
using func_t = decltype(&ExtraDataList::CopyList);
57+
static REL::Relocation<func_t> func{ ID::ExtraDataList::CopyList };
58+
func(this, a_copy);
59+
}
60+
61+
inline TBO_InstanceData* CreateInstanceData(TESBoundObject* a_object, bool a_generateName)
4662
{
4763
using func_t = decltype(&ExtraDataList::CreateInstanceData);
4864
static REL::Relocation<func_t> func{ ID::ExtraDataList::CreateInstanceData };
@@ -87,90 +103,96 @@ namespace RE
87103
}
88104

89105
template <detail::ExtraDataListConstraint T>
90-
std::unique_ptr<T> RemoveExtra()
106+
inline std::unique_ptr<T> RemoveExtra()
91107
{
92108
return std::unique_ptr<T>{ static_cast<T*>(RemoveExtra(T::TYPE).release()) };
93109
}
94110

95-
bool SetBendableSplineInfo(float* a_thickness, float* a_slack, NiPoint3* a_halfExtents = nullptr, bool* a_detachedEnd = nullptr)
111+
inline bool SetBendableSplineInfo(float* a_thickness, float* a_slack, NiPoint3* a_halfExtents = nullptr, bool* a_detachedEnd = nullptr)
96112
{
97113
using func_t = decltype(&ExtraDataList::SetBendableSplineInfo);
98114
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetBendableSplineInfo };
99115
return func(this, a_thickness, a_slack, a_halfExtents, a_detachedEnd);
100116
}
101117

102-
void SetDisplayNameFromInstanceData(BGSObjectInstanceExtra* a_instExtra, TESBoundObject* a_object, const BSTSmartPointer<TBO_InstanceData>& a_data)
118+
inline void SetCount(std::int16_t a_count) noexcept
119+
{
120+
using func_t = decltype(&ExtraDataList::SetCount);
121+
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetCount };
122+
func(this, a_count);
123+
}
124+
125+
inline void SetDisplayNameFromInstanceData(BGSObjectInstanceExtra* a_instExtra, TESBoundObject* a_object, const BSTSmartPointer<TBO_InstanceData>& a_data)
103126
{
104127
using func_t = decltype(&ExtraDataList::SetDisplayNameFromInstanceData);
105128
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetDisplayNameFromInstanceData };
106-
return func(this, a_instExtra, a_object, a_data);
129+
func(this, a_instExtra, a_object, a_data);
107130
}
108131

109-
void SetOverrideName(const char* a_name)
132+
inline void SetOverrideName(const char* a_name)
110133
{
111134
using func_t = decltype(&ExtraDataList::SetOverrideName);
112135
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetOverrideName };
113-
return func(this, a_name);
136+
func(this, a_name);
114137
}
115138

116-
void SetStartingWorldOrCell(TESForm* a_form)
139+
inline void SetStartingWorldOrCell(TESForm* a_form)
117140
{
118141
using func_t = decltype(&ExtraDataList::SetStartingWorldOrCell);
119142
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetStartingWorldOrCell };
120-
return func(this, a_form);
143+
func(this, a_form);
121144
}
122145

123-
float GetHealthPerc()
146+
inline float GetHealthPerc()
124147
{
125148
using func_t = decltype(&ExtraDataList::GetHealthPerc);
126149
static REL::Relocation<func_t> func{ ID::ExtraDataList::GetHealthPerc };
127150
return func(this);
128151
}
129152

130-
void SetHealthPerc(float a_healthPerc)
153+
inline void SetHealthPerc(float a_healthPerc)
131154
{
132155
using func_t = decltype(&ExtraDataList::SetHealthPerc);
133156
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetHealthPerc };
134-
return func(this, a_healthPerc);
157+
func(this, a_healthPerc);
135158
}
136159

137-
bool ClearFavorite()
160+
inline bool ClearFavorite()
138161
{
139162
using func_t = decltype(&ExtraDataList::ClearFavorite);
140163
static REL::Relocation<func_t> func{ ID::ExtraDataList::ClearFavorite };
141164
return func(this);
142165
}
143166

144-
bool IsFavorite()
167+
inline bool IsFavorite()
145168
{
146169
using func_t = decltype(&ExtraDataList::IsFavorite);
147170
static REL::Relocation<func_t> func{ ID::ExtraDataList::IsFavorite };
148171
return func(this);
149172
}
150173

151-
bool IsDamaged()
174+
inline bool IsDamaged()
152175
{
153176
using func_t = decltype(&ExtraDataList::IsDamaged);
154177
static REL::Relocation<func_t> func{ ID::ExtraDataList::IsDamaged };
155178
return func(this);
156179
}
157180

158-
typedef bool (*ComparisonQualifier)(const BSExtraData*);
159-
bool CompareList(const ExtraDataList* a_compare, ComparisonQualifier a_qualifier)
181+
inline bool CompareList(const ExtraDataList* a_compare, ComparisonQualifier a_qualifier)
160182
{
161183
using func_t = decltype(&ExtraDataList::CompareList);
162184
static REL::Relocation<func_t> func{ ID::ExtraDataList::CompareList };
163185
return func(this, a_compare, a_qualifier);
164186
}
165187

166-
void SetFavorite(char a_quickKeyIndex)
188+
inline void SetFavorite(char a_quickKeyIndex)
167189
{
168190
using func_t = decltype(&ExtraDataList::SetFavorite);
169191
static REL::Relocation<func_t> func{ ID::ExtraDataList::SetFavorite };
170-
return func(this, a_quickKeyIndex);
192+
func(this, a_quickKeyIndex);
171193
}
172194

173-
BGSPrimitive* GetPrimitive()
195+
inline BGSPrimitive* GetPrimitive()
174196
{
175197
using func_t = decltype(&ExtraDataList::GetPrimitive);
176198
static REL::Relocation<func_t> func{ ID::ExtraDataList::GetPrimitive };

include/RE/IDs.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,16 @@ namespace RE::ID
235235

236236
namespace BGSInventoryList
237237
{
238-
inline constexpr REL::ID FindAndWriteStackDataForItem{ 2194179 };
238+
inline constexpr REL::ID AddItem1{ 2194159 };
239+
inline constexpr REL::ID AddItem2{ 2194160 };
239240
inline constexpr REL::ID BuildFromContainer{ 2194158 };
241+
inline constexpr REL::ID Clear{ 2194162 };
240242
inline constexpr REL::ID ctor{ 2194153 };
241-
inline constexpr REL::ID AddItem{ 2194159 };
243+
inline constexpr REL::ID FindAndWriteStackDataForItem{ 2194179 };
244+
inline constexpr REL::ID FindItemIndex{ 2194165 };
245+
inline constexpr REL::ID GetItemCount{ 2194163 };
246+
inline constexpr REL::ID GetQuestItemCount{ 2194164 };
247+
inline constexpr REL::ID RemoveItem1{ 2194169 };
242248
}
243249

244250
namespace BGSKeyword
@@ -1002,9 +1008,12 @@ namespace RE::ID
10021008

10031009
namespace ExtraDataList
10041010
{
1011+
inline constexpr REL::ID CopyList{ 2190094 };
10051012
inline constexpr REL::ID CreateInstanceData{ 2190185 };
1013+
inline constexpr REL::ID Ctor{ 2190088 };
10061014
inline constexpr REL::ID GetLegendaryMod{ 2190180 };
10071015
inline constexpr REL::ID SetBendableSplineInfo{ 2190623 };
1016+
inline constexpr REL::ID SetCount{ 2190125 };
10081017
inline constexpr REL::ID SetDisplayNameFromInstanceData{ 2190179 };
10091018
inline constexpr REL::ID SetOverrideName{ 2190167 };
10101019
inline constexpr REL::ID SetStartingWorldOrCell{ 2190506 };

0 commit comments

Comments
 (0)