CommonLibVR
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"
9#include "RE/N/NiTArray.h"
10#include "RE/N/NiTList.h"
11#include "RE/T/TESForm.h"
12
13namespace RE
14{
15 class BGSPrimitive;
16 class InventoryChanges;
17 class NiPoint3;
18 class TESFile;
19 class TESRegionDataManager;
20 class TESRegionList;
21
23 {
24 public:
25 // members
26 std::uint8_t pad0; // 0
27 };
28 static_assert(sizeof(TESObjectList) == 0x1);
29
31 {
32 public:
33 // members
36 };
37 static_assert(sizeof(TESFileCollection) == 0x30);
38
39 class TESDataHandler : public BSTSingletonSDM<TESDataHandler>
40 {
41 public:
42 inline static RE::TESFileCollection* VRcompiledFileCollection = nullptr; // used by SkyrimVRESL to store pointer to VR version
43 static TESDataHandler* GetSingleton(bool a_VRESL = true);
44
46
47 std::uint32_t LoadScripts();
48 TESForm* LookupForm(FormID a_rawFormID, std::string_view a_modName);
49 template <class T>
50 T* LookupForm(FormID a_rawFormID, std::string_view a_modName);
51 FormID LookupFormID(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
72 // members
73 std::uint8_t pad001; // 001
74 std::uint16_t pad002; // 002
75 std::uint32_t pad004; // 004
77 BSTArray<TESForm*> formArrays[std::to_underlying(FormType::Max)]; // 010
82 FormID nextID; // D50
83 std::uint32_t padD54; // D54
86#ifndef SKYRIMVR
87 TESFileCollection compiledFileCollection; // D70 broken in SKYRIMVR, iterate over files/loadedMods instead
88 bool masterSave; // DA0
89 bool blockSave; // DA1
90 bool saveLoadGame; // DA2
91 bool autoSaving; // DA3
92 bool exportingPlugin; // DA4
93 bool clearingData; // DA5
94 bool hasDesiredFiles; // DA6
95 bool checkingModels; // DA7
96 bool loadingFiles; // DA8
97 bool dontRemoveIDs; // DA9
98 std::uint8_t unkDAA; // DAA
99 std::uint8_t padDAB; // DAB
100 std::uint32_t padDAC; // DAC
103#else
104 std::uint32_t loadedModCount; // D70 this should be avoided if SkyrimVRESL is available
105 std::uint32_t pad14; // D74
106 TESFile* loadedMods[0xFF]; // D78 this should be avoided if SkyrimVRESL is available
107 bool masterSave; // 1570
108 bool blockSave; // 1571
109 bool saveLoadGame; // 1572
110 bool autoSaving; // 1574
111 bool exportingPlugin; // 1575
112 bool clearingData; // 1576 - init'd to 1
113 bool hasDesiredFiles; // 1577
114 bool checkingModels; // 1578
115 bool loadingFiles; // 1579
116 bool dontRemoveIDs; // 157A
117 std::uint8_t pad157B[5]; // 157B
120#endif
121 private:
123 };
124#ifndef SKYRIMVR
125 static_assert(sizeof(TESDataHandler) == 0xDC0);
126#else
127 static_assert(sizeof(TESDataHandler) == 0x1590);
128#endif
129 template <class T>
130 T* TESDataHandler::LookupForm(FormID a_rawFormID, std::string_view a_modName)
131 {
132 auto form = LookupForm(a_rawFormID, a_modName);
133 if (!form) {
134 return 0;
135 }
136
137 return form->Is(T::FORMTYPE) ? static_cast<T*>(form) : 0;
138 }
139
140 template <class T>
142 {
143 return reinterpret_cast<BSTArray<T*>&>(GetFormArray(T::FORMTYPE));
144 }
145}
#define KEEP_FOR_RE()
Definition PCH.h:517
Definition BSTList.h:10
Definition BSTArray.h:378
Definition InventoryChanges.h:16
Definition NiPoint3.h:6
Definition NiTList.h:10
Definition NiTArray.h:136
Definition TESBoundObject.h:26
Definition TESDataHandler.h:40
std::uint32_t padD54
Definition TESDataHandler.h:83
TESRegionDataManager * regionDataManager
Definition TESDataHandler.h:101
static TESDataHandler * GetSingleton(bool a_VRESL=true)
BSTArray< TESForm * > formArrays[std::to_underlying(FormType::Max)]
Definition TESDataHandler.h:77
std::uint32_t pad004
Definition TESDataHandler.h:75
std::uint8_t unkDAA
Definition TESDataHandler.h:98
FormID nextID
Definition TESDataHandler.h:82
BSSimpleList< TESFile * > files
Definition TESDataHandler.h:85
bool clearingData
Definition TESDataHandler.h:93
TESForm * LookupForm(FormID a_rawFormID, std::string_view a_modName)
std::optional< std::uint8_t > GetModIndex(std::string_view a_modName)
bool AddFormToDataHandler(TESForm *a_form)
const TESFile * LookupLoadedModByName(std::string_view a_modName)
const TESFile * LookupModByName(std::string_view a_modName)
bool loadingFiles
Definition TESDataHandler.h:96
InventoryChanges * merchantInventory
Definition TESDataHandler.h:102
bool checkingModels
Definition TESDataHandler.h:95
const TESFile * LookupLoadedModByIndex(std::uint8_t a_index)
NiTList< TESForm * > badForms
Definition TESDataHandler.h:81
TESObjectList * objectList
Definition TESDataHandler.h:76
BSTArray< T * > & GetFormArray()
Definition TESDataHandler.h:141
const TESFile * LookupLoadedLightModByIndex(std::uint16_t a_index)
bool blockSave
Definition TESDataHandler.h:89
std::uint8_t pad001
Definition TESDataHandler.h:73
std::optional< std::uint16_t > GetLoadedLightModIndex(std::string_view a_modName)
bool masterSave
Definition TESDataHandler.h:88
bool exportingPlugin
Definition TESDataHandler.h:92
std::uint32_t LoadScripts()
bool dontRemoveIDs
Definition TESDataHandler.h:97
NiTPrimitiveArray< TESObjectCELL * > interiorCells
Definition TESDataHandler.h:79
BSTArray< TESForm * > & GetFormArray(FormType a_formType)
std::optional< std::uint8_t > GetLoadedModIndex(std::string_view a_modName)
TESRegionList * regionList
Definition TESDataHandler.h:78
bool hasDesiredFiles
Definition TESDataHandler.h:94
NiTPrimitiveArray< BGSAddonNode * > addonNodes
Definition TESDataHandler.h:80
TESFile * activeFile
Definition TESDataHandler.h:84
const TESFile * LookupLoadedLightModByName(std::string_view a_modName)
std::uint32_t padDAC
Definition TESDataHandler.h:100
static RE::TESFileCollection * VRcompiledFileCollection
Definition TESDataHandler.h:42
TESFileCollection compiledFileCollection
Definition TESDataHandler.h:87
bool saveLoadGame
Definition TESDataHandler.h:90
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)
bool autoSaving
Definition TESDataHandler.h:91
std::uint16_t pad002
Definition TESDataHandler.h:74
FormID LookupFormID(FormID a_rawFormID, std::string_view a_modName)
bool IsGeneratedID(FormID a_formID)
std::uint8_t padDAB
Definition TESDataHandler.h:99
Definition TESFile.h:17
Definition TESForm.h:40
Definition TESObjectCELL.h:119
Definition TESObjectREFR.h:114
Definition TESRegionDataManager.h:18
Definition TESRegionList.h:10
Definition TESWorldSpace.h:120
Definition AbsorbEffect.h:6
FormType
Definition FormTypes.h:139
std::uint32_t FormID
Definition BSCoreTypes.h:5
Definition BSTSingleton.h:50
Definition TESDataHandler.h:31
BSTArray< TESFile * > smallFiles
Definition TESDataHandler.h:35
BSTArray< TESFile * > files
Definition TESDataHandler.h:34
Definition TESDataHandler.h:23
std::uint8_t pad0
Definition TESDataHandler.h:26