CommonLibSSE (Parapets fork)
TESDataHandler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSSimpleList.h"
4 #include "RE/B/BSTArray.h"
5 #include "RE/B/BSTSingleton.h"
6 #include "RE/F/FormTypes.h"
7 #include "RE/N/NiTArray.h"
8 #include "RE/N/NiTList.h"
9 #include "RE/T/TESForm.h"
10 
11 namespace RE
12 {
13  class TESFile;
14  class TESRegionDataManager;
15  class TESRegionList;
16 
18  {
19  public:
20  // members
21  std::uint8_t pad0; // 0
22  };
23  static_assert(sizeof(TESObjectList) == 0x1);
24 
26  {
27  public:
28  TESFile* GetFileForID(std::uint32_t a_formID) const;
29  TESFile* GetNormalFile(std::uint32_t a_index) const;
30  TESFile* GetSmallFile(std::uint32_t a_index) const;
31 
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_rawFormID, stl::zstring a_modName);
45  template <class T>
46  T* LookupForm(FormID a_rawFormID, stl::zstring a_modName);
47 
49  std::optional<std::uint8_t> GetModIndex(stl::zstring a_modName);
50 
52  const TESFile* LookupLoadedModByIndex(std::uint8_t a_index);
53  std::optional<std::uint8_t> GetLoadedModIndex(stl::zstring a_modName);
54 
56  const TESFile* LookupLoadedLightModByIndex(std::uint16_t a_index);
57  std::optional<std::uint16_t> GetLoadedLightModIndex(stl::zstring a_modName);
58 
59  bool IsGeneratedID(FormID a_formID);
60 
62  template <class T>
64 
65  [[nodiscard]] const TESFileCollection* QCompiledFiles() const;
66  [[nodiscard]] std::span<const TESFile* const> QNormalFileList() const;
67  [[nodiscard]] std::span<const TESFile* const> QSmallFileList() const;
68 
69  // members
70  std::uint8_t pad001; // 001
71  std::uint16_t pad002; // 002
72  std::uint32_t pad004; // 004
79  FormID nextID; // D50
80  std::uint32_t padD54; // D54
83 #ifndef SKYRIMVR
85 #else
86  std::uint32_t loadedFileCount; // 0D70
87  std::uint32_t pad0D74; // 0D74
88  TESFile* loadedFiles[0xFF]; // 0D78
89 #endif
90  bool masterSave; // DA0
91  bool blockSave; // DA1
92  bool saveLoadGame; // DA2
93  bool autoSaving; // DA3
94  bool exportingPlugin; // DA4
95  bool clearingData; // DA5
96  bool hasDesiredFiles; // DA6
97  bool checkingModels; // DA7
98  bool loadingFiles; // DA8
99  bool dontRemoveIDs; // DA9
100  std::uint8_t unkDAA; // DAA
101  std::uint8_t padDAB; // DAB
102  std::uint32_t padDAC; // DAC
104  std::uint64_t unkDB8; // DB8
105  };
106 #ifndef SKYRIMVR
107  static_assert(sizeof(TESDataHandler) == 0xDC0);
108 #else
109  static_assert(sizeof(TESDataHandler) == 0x1590);
110 #endif
111 
112  template <class T>
113  T* TESDataHandler::LookupForm(FormID a_rawFormID, std::string_view a_modName)
114  {
115  auto form = LookupForm(a_rawFormID, a_modName);
116  if (!form) {
117  return 0;
118  }
119 
120  return form->Is(T::FORMTYPE) ? static_cast<T*>(form) : 0;
121  }
122 
123  template <class T>
125  {
126  return reinterpret_cast<BSTArray<T*>&>(GetFormArray(T::FORMTYPE));
127  }
128 }
Definition: BSSimpleList.h:10
Definition: BSTArray.h:377
Definition: NiTList.h:10
Definition: NiTArray.h:136
Definition: TESDataHandler.h:39
std::uint32_t padD54
Definition: TESDataHandler.h:80
TESRegionDataManager * regionDataManager
Definition: TESDataHandler.h:103
const TESFile * LookupModByName(stl::zstring a_modName)
std::optional< std::uint8_t > GetModIndex(stl::zstring a_modName)
TESForm * LookupForm(FormID a_rawFormID, stl::zstring a_modName)
std::uint32_t pad004
Definition: TESDataHandler.h:72
std::uint8_t unkDAA
Definition: TESDataHandler.h:100
FormID nextID
Definition: TESDataHandler.h:79
BSSimpleList< TESFile * > files
Definition: TESDataHandler.h:82
bool clearingData
Definition: TESDataHandler.h:95
const TESFile * LookupLoadedModByIndex(std::uint8_t a_index)
BSTArray< TESForm * > & GetFormArray(FormType a_formType)
bool loadingFiles
Definition: TESDataHandler.h:98
std::span< const TESFile *const > QNormalFileList() const
bool checkingModels
Definition: TESDataHandler.h:97
std::optional< std::uint16_t > GetLoadedLightModIndex(stl::zstring a_modName)
const TESFile * LookupLoadedLightModByName(stl::zstring a_modName)
NiTList< TESForm * > badForms
Definition: TESDataHandler.h:78
TESObjectList * objectList
Definition: TESDataHandler.h:73
T * LookupForm(FormID a_rawFormID, stl::zstring a_modName)
const TESFile * LookupLoadedLightModByIndex(std::uint16_t a_index)
BSTArray< T * > & GetFormArray()
Definition: TESDataHandler.h:124
bool blockSave
Definition: TESDataHandler.h:91
std::uint8_t pad001
Definition: TESDataHandler.h:70
bool masterSave
Definition: TESDataHandler.h:90
bool exportingPlugin
Definition: TESDataHandler.h:94
std::uint64_t unkDB8
Definition: TESDataHandler.h:104
std::uint32_t LoadScripts()
bool dontRemoveIDs
Definition: TESDataHandler.h:99
NiTPrimitiveArray< TESObjectCELL * > interiorCells
Definition: TESDataHandler.h:76
std::optional< std::uint8_t > GetLoadedModIndex(stl::zstring a_modName)
TESRegionList * regionList
Definition: TESDataHandler.h:75
const TESFileCollection * QCompiledFiles() const
std::span< const TESFile *const > QSmallFileList() const
bool hasDesiredFiles
Definition: TESDataHandler.h:96
NiTPrimitiveArray< BGSAddonNode * > addonNodes
Definition: TESDataHandler.h:77
TESFile * activeFile
Definition: TESDataHandler.h:81
std::uint32_t padDAC
Definition: TESDataHandler.h:102
TESFileCollection compiledFileCollection
Definition: TESDataHandler.h:84
static TESDataHandler * GetSingleton()
const TESFile * LookupLoadedModByName(stl::zstring a_modName)
bool saveLoadGame
Definition: TESDataHandler.h:92
bool autoSaving
Definition: TESDataHandler.h:93
std::uint16_t pad002
Definition: TESDataHandler.h:71
bool IsGeneratedID(FormID a_formID)
BSTArray< TESForm * > formArrays[stl::to_underlying(FormType::Max)]
Definition: TESDataHandler.h:74
std::uint8_t padDAB
Definition: TESDataHandler.h:101
Definition: TESFile.h:14
Definition: TESForm.h:34
Definition: TESRegionDataManager.h:18
Definition: TESRegionList.h:10
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 requires(std
Definition: PCH.h:676
basic_zstring< char > zstring
Definition: PCH.h:77
Definition: BSTSingleton.h:50
Definition: TESDataHandler.h:26
BSTArray< TESFile * > smallFiles
Definition: TESDataHandler.h:34
TESFile * GetNormalFile(std::uint32_t a_index) const
BSTArray< TESFile * > files
Definition: TESDataHandler.h:33
TESFile * GetSmallFile(std::uint32_t a_index) const
TESFile * GetFileForID(std::uint32_t a_formID) const
Definition: TESDataHandler.h:18
std::uint8_t pad0
Definition: TESDataHandler.h:21