CommonLibSSE NG
Loading...
Searching...
No Matches
TESDataHandler.h
Go to the documentation of this file.
1#pragma once
2
4#include "RE/B/BSTArray.h"
5#include "RE/B/BSTList.h"
6#include "RE/B/BSTSingleton.h"
7#include "RE/F/FormTypes.h"
8#include "RE/N/NiTArray.h"
9#include "RE/N/NiTList.h"
10#include "RE/T/TESForm.h"
11
12namespace RE
13{
14 class BGSPrimitive;
15 class InventoryChanges;
16 class NiPoint3;
17 class TESFile;
18 class TESRegionDataManager;
19 class TESRegionList;
20
22 {
23 public:
24 // members
25 std::uint8_t pad0; // 0
26 };
27 static_assert(sizeof(TESObjectList) == 0x1);
28
30 {
31 public:
32 // members
35 };
36 static_assert(sizeof(TESFileCollection) == 0x30);
37
38 class TESDataHandler : public BSTSingletonSDM<TESDataHandler>
39 {
40 public:
42
43 std::uint32_t LoadScripts();
44 TESForm* LookupForm(FormID a_localFormID, std::string_view a_modName);
45 TESForm* LookupFormRaw(FormID a_rawFormID, std::string_view a_modName);
46 template <class T>
47 T* LookupForm(FormID a_localFormID, std::string_view a_modName);
48 template <class T>
49 T* LookupFormRaw(FormID a_rawFormID, std::string_view a_modName);
50 FormID LookupFormID(FormID a_localFormID, std::string_view a_modName);
51 FormID LookupFormIDRaw(FormID a_rawFormID, std::string_view a_modName);
52
53 const TESFile* LookupModByName(std::string_view a_modName);
54 std::optional<std::uint8_t> GetModIndex(std::string_view a_modName);
55
56 const TESFile* LookupLoadedModByName(std::string_view a_modName);
57 const TESFile* LookupLoadedModByIndex(std::uint8_t a_index);
58 std::optional<std::uint8_t> GetLoadedModIndex(std::string_view a_modName);
59
60 const TESFile* LookupLoadedLightModByName(std::string_view a_modName);
61 const TESFile* LookupLoadedLightModByIndex(std::uint16_t a_index);
62 std::optional<std::uint16_t> GetLoadedLightModIndex(std::string_view a_modName);
63
64 bool IsGeneratedID(FormID a_formID);
65
67 template <class T>
69
70 ObjectRefHandle CreateReferenceAtLocation(TESBoundObject* a_base, const NiPoint3& a_location, const NiPoint3& a_rotation, TESObjectCELL* a_targetCell, TESWorldSpace* a_selfWorldSpace, TESObjectREFR* a_alreadyCreatedRef, BGSPrimitive* a_primitive, const ObjectRefHandle& a_linkedRoomRefHandle, bool a_forcePersist, bool a_arg11);
71
73 {
74#define RUNTIME_DATA_CONTENT \
75 bool masterSave; \
76 bool blockSave; \
77 bool saveLoadGame; \
78 bool autoSaving; \
79 bool exportingPlugin; \
80 bool clearingData; \
81 bool hasDesiredFiles; \
82 bool checkingModels; \
83 bool loadingFiles; \
84 bool dontRemoveIDs;
85
87 };
88
89 [[nodiscard]] inline RUNTIME_DATA& GetGeometryRuntimeData() noexcept
90 {
91 return REL::RelocateMember<RUNTIME_DATA>(this, 0xDA0, 0x1570);
92 }
93
94 [[nodiscard]] inline const RUNTIME_DATA& GetGeometryRuntimeData() const noexcept
95 {
96 return REL::RelocateMember<RUNTIME_DATA>(this, 0xDA0, 0x1570);
97 }
98
99 [[nodiscard]] inline TESFile** GetLoadedMods() noexcept {
101 return &REL::RelocateMember<TESFile*>(this, 0x0, 0xD78);
102 } else {
103 return REL::RelocateMember<TESFileCollection>(this, 0xD70, 0).files.data();
104 }
105 }
106
107 [[nodiscard]] inline const TESFile* const * GetLoadedMods() const noexcept {
109 return &REL::RelocateMember<const TESFile*>(this, 0x0, 0xD78);
110 } else {
111 return REL::RelocateMember<const TESFileCollection>(this, 0xD70, 0).files.data();
112 }
113 }
114
115 [[nodiscard]] inline std::uint8_t GetLoadedModCount() const noexcept {
117 return static_cast<std::uint8_t>(REL::RelocateMember<std::uint32_t>(this, 0x0, 0xD70));
118 } else {
119 return static_cast<std::uint8_t>(REL::RelocateMember<const TESFileCollection>(this, 0xD70, 0).files.size());
120 }
121 }
122
123 [[nodiscard]] inline TESFile** GetLoadedLightMods() noexcept {
125 return nullptr;
126 } else {
127 return REL::RelocateMember<TESFileCollection>(this, 0xD70, 0).smallFiles.data();
128 }
129 }
130
131 [[nodiscard]] inline const TESFile* const * GetLoadedLightMods() const noexcept {
133 return nullptr;
134 } else {
135 return REL::RelocateMember<const TESFileCollection>(this, 0xD70, 0).smallFiles.data();
136 }
137 }
138
139 [[nodiscard]] inline std::uint8_t GetLoadedLightModCount() const noexcept {
141 return 0;
142 } else {
143 return static_cast<std::uint8_t>(REL::RelocateMember<const TESFileCollection>(this, 0xD70, 0).smallFiles.size());
144 }
145 }
146
147 [[nodiscard]] inline TESRegionDataManager* GetRegionDataManager() noexcept {
148 return REL::RelocateMember<TESRegionDataManager*>(this, 0xDB0, 0x1580);
149 }
150
151 [[nodiscard]] inline const TESRegionDataManager* GetRegionDataManager() const noexcept {
152 return REL::RelocateMember<TESRegionDataManager*>(this, 0xDB0, 0x1580);
153 }
154
155 [[nodiscard]] inline InventoryChanges* GetMerchantInventory() noexcept {
156 return REL::RelocateMember<InventoryChanges*>(this, 0xDB8, 0x1588);
157 }
158
159 [[nodiscard]] inline const InventoryChanges* GetMerchantInventory() const noexcept {
160 return REL::RelocateMember<InventoryChanges*>(this, 0xDB8, 0x1588);
161 }
162
163 // members
164 std::uint8_t pad001; // 001
165 std::uint16_t pad002; // 002
166 std::uint32_t pad004; // 004
174 std::uint32_t padD54; // D54
177#ifndef ENABLE_SKYRIM_VR
180 std::uint8_t unkDAA; // DAA
181 std::uint8_t padDAB; // DAB
182 std::uint32_t padDAC; // DAC
185#elif !defined(ENABLE_SKYRIM_AE) && !defined(ENABLE_SKYRIM_SE)
186 std::uint32_t loadedModCount; // D70
187 std::uint32_t pad14; // D74
188 TESFile* loadedMods[0xFF]; // D78
190 std::uint8_t pad157B[5]; // 157B
193#endif
194 };
195
196 template <class T>
197 T* TESDataHandler::LookupForm(FormID a_localFormID, std::string_view a_modName)
198 {
199 auto form = LookupForm(a_localFormID, a_modName);
200 if (!form) {
201 return 0;
202 }
203
204 return form->Is(T::FORMTYPE) ? static_cast<T*>(form) : 0;
205 }
206
207 template <class T>
208 T* TESDataHandler::LookupFormRaw(FormID a_rawFormID, std::string_view a_modName)
209 {
210 auto form = LookupFormRaw(a_rawFormID, a_modName);
211 if (!form) {
212 return 0;
213 }
214
215 return form->Is(T::FORMTYPE) ? static_cast<T*>(form) : 0;
216 }
217
218 template <class T>
220 {
221 return reinterpret_cast<BSTArray<T*>&>(GetFormArray(T::FORMTYPE));
222 }
223}
#define RUNTIME_DATA_CONTENT
Definition Actor.h:633
#define SKYRIM_REL_CONSTEXPR
Definition Relocation.h:105
Definition BSTList.h:10
Definition BSTArray.h:377
Definition InventoryChanges.h:16
Definition NiPoint3.h:6
Definition NiTList.h:10
Definition NiTArray.h:136
Definition TESBoundObject.h:24
Definition TESDataHandler.h:39
std::uint32_t padD54
Definition TESDataHandler.h:174
RUNTIME_DATA & GetGeometryRuntimeData() noexcept
Definition TESDataHandler.h:89
TESRegionDataManager * regionDataManager
Definition TESDataHandler.h:183
const TESRegionDataManager * GetRegionDataManager() const noexcept
Definition TESDataHandler.h:151
FormID LookupFormIDRaw(FormID a_rawFormID, std::string_view a_modName)
std::uint32_t pad004
Definition TESDataHandler.h:166
FormID nextID
Definition TESDataHandler.h:173
BSSimpleList< TESFile * > files
Definition TESDataHandler.h:176
static TESDataHandler * GetSingleton()
std::optional< std::uint8_t > GetModIndex(std::string_view a_modName)
const TESFile * LookupLoadedModByName(std::string_view a_modName)
const TESFile *const * GetLoadedMods() const noexcept
Definition TESDataHandler.h:107
const TESFile * LookupModByName(std::string_view a_modName)
InventoryChanges * merchantInventory
Definition TESDataHandler.h:184
TESRegionDataManager * GetRegionDataManager() noexcept
Definition TESDataHandler.h:147
const TESFile * LookupLoadedModByIndex(std::uint8_t a_index)
std::uint8_t GetLoadedModCount() const noexcept
Definition TESDataHandler.h:115
NiTList< TESForm * > badForms
Definition TESDataHandler.h:172
TESObjectList * objectList
Definition TESDataHandler.h:167
const RUNTIME_DATA & GetGeometryRuntimeData() const noexcept
Definition TESDataHandler.h:94
BSTArray< T * > & GetFormArray()
Definition TESDataHandler.h:219
const TESFile * LookupLoadedLightModByIndex(std::uint16_t a_index)
TESFile ** GetLoadedMods() noexcept
Definition TESDataHandler.h:99
std::uint8_t pad001
Definition TESDataHandler.h:164
std::optional< std::uint16_t > GetLoadedLightModIndex(std::string_view a_modName)
const InventoryChanges * GetMerchantInventory() const noexcept
Definition TESDataHandler.h:159
const TESFile *const * GetLoadedLightMods() const noexcept
Definition TESDataHandler.h:131
std::uint32_t LoadScripts()
TESFile ** GetLoadedLightMods() noexcept
Definition TESDataHandler.h:123
NiTPrimitiveArray< TESObjectCELL * > interiorCells
Definition TESDataHandler.h:170
BSTArray< TESForm * > & GetFormArray(FormType a_formType)
std::optional< std::uint8_t > GetLoadedModIndex(std::string_view a_modName)
TESRegionList * regionList
Definition TESDataHandler.h:169
TESForm * LookupFormRaw(FormID a_rawFormID, std::string_view a_modName)
TESForm * LookupForm(FormID a_localFormID, std::string_view a_modName)
NiTPrimitiveArray< BGSAddonNode * > addonNodes
Definition TESDataHandler.h:171
TESFile * activeFile
Definition TESDataHandler.h:175
RUNTIME_DATA_CONTENT std::uint8_t unkDAA
Definition TESDataHandler.h:180
const TESFile * LookupLoadedLightModByName(std::string_view a_modName)
InventoryChanges * GetMerchantInventory() noexcept
Definition TESDataHandler.h:155
std::uint32_t padDAC
Definition TESDataHandler.h:182
TESFileCollection compiledFileCollection
Definition TESDataHandler.h:178
FormID LookupFormID(FormID a_localFormID, std::string_view a_modName)
ObjectRefHandle CreateReferenceAtLocation(TESBoundObject *a_base, const NiPoint3 &a_location, const NiPoint3 &a_rotation, TESObjectCELL *a_targetCell, TESWorldSpace *a_selfWorldSpace, TESObjectREFR *a_alreadyCreatedRef, BGSPrimitive *a_primitive, const ObjectRefHandle &a_linkedRoomRefHandle, bool a_forcePersist, bool a_arg11)
std::uint8_t GetLoadedLightModCount() const noexcept
Definition TESDataHandler.h:139
std::uint16_t pad002
Definition TESDataHandler.h:165
bool IsGeneratedID(FormID a_formID)
BSTArray< TESForm * > formArrays[stl::to_underlying(FormType::Max)]
Definition TESDataHandler.h:168
std::uint8_t padDAB
Definition TESDataHandler.h:181
Definition TESFile.h:15
Definition TESForm.h:35
Definition TESObjectCELL.h:116
Definition TESObjectREFR.h:112
Definition TESRegionDataManager.h:18
Definition TESRegionList.h:10
Definition TESWorldSpace.h:118
static SKYRIM_REL_VR bool IsVR() noexcept
Definition Relocation.h:821
Definition AbsorbEffect.h:6
FormType
Definition FormTypes.h:139
std::uint32_t FormID
Definition BSCoreTypes.h:5
constexpr auto to_underlying(Enum a_val) noexcept
Definition PCH.h:728
Definition BSTSingleton.h:50
Definition TESDataHandler.h:73
Definition TESDataHandler.h:30
BSTArray< TESFile * > smallFiles
Definition TESDataHandler.h:34
BSTArray< TESFile * > files
Definition TESDataHandler.h:33
Definition TESDataHandler.h:22
std::uint8_t pad0
Definition TESDataHandler.h:25