CommonLibSSE (Parapets fork)
TESFile.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSSimpleList.h"
4 #include "RE/B/BSString.h"
5 #include "RE/F/FORM.h"
6 #include "RE/F/FormTypes.h"
7 
8 namespace RE
9 {
10  class BSFile;
11  struct TESBitArrayFile;
12 
13  class TESFile
14  {
15  public:
16  enum class Error
17  {
18  kNone = 0,
19  kNotFound = 1,
20  kNoFile = 2,
21  kNoForm = 3,
22  kNoChunk = 4,
23  kNoID = 5,
24  kBadFile = 6,
25  kBadID = 7,
26  kFormOpen = 8,
27  kFileOpen = 9,
28  kWriteFailure = 10,
29  kInvalidFile = 11,
30  kFileInUse = 12,
31  kCreateFailure = 13
32  };
33 
34  enum class RecordFlag
35  {
36  kNone = 0,
37  kMaster = 1 << 0,
38  kAltered = 1 << 1,
39  kChecked = 1 << 2,
40  kActive = 1 << 3,
41  kOptimizedFile = 1 << 4,
42  kTempIDOwner = 1 << 5,
43  kDelocalized = 1 << 7,
44  kPrecalcDataOnly = 1 << 8,
45  kSmallFile = 1 << 9
46  };
47 
48  TESFile* Duplicate(std::uint32_t a_cacheSize = 0x4000);
49  [[nodiscard]] std::uint8_t GetCompileIndex() const noexcept { return compileIndex; }
50  std::uint32_t GetCurrentSubRecordType();
51  [[nodiscard]] constexpr std::uint32_t GetCurrentSubRecordSize() const noexcept { return actualChunkSize; }
52  [[nodiscard]] constexpr std::uint32_t GetCurrentChunkID() const noexcept { return currentchunkID; }
53  [[nodiscard]] stl::zstring GetFilename() const noexcept { return { fileName }; }
55  [[nodiscard]] std::uint16_t GetSmallFileCompileIndex() const noexcept { return smallFileCompileIndex; }
56  [[nodiscard]] constexpr std::uint32_t GetPartialIndex() const noexcept { return !IsLight() ? compileIndex : (0xFE000 | smallFileCompileIndex); };
57  [[nodiscard]] constexpr bool IsLight() const noexcept { return recordFlags.all(RecordFlag::kSmallFile); };
58  [[nodiscard]] constexpr bool IsLocalized() const noexcept { return recordFlags.all(RecordFlag::kDelocalized); }
59  void ReadData(void* a_buf, std::uint32_t a_size);
60  bool Seek(std::uint32_t a_offset);
62 
63  // members
65  std::uint32_t pad004; // 004
67  void* threadSafeFileMap; // 010 - NiTPointerMap<std::uint32_t, TESFile*>* - size == 0x20
68  std::uint64_t unk018; // 018
69  std::uint64_t unk020; // 020
70  std::uint8_t unk028; // 028
71  std::uint8_t unk029; // 029
72  std::uint16_t pad02A; // 02A
73  std::uint32_t pad02C; // 02C
74  BSFile* lockedFile; // 030
75  BSFile* file; // 038
76  TESBitArrayFile* formUserDataBitArray; // 040
77  TESBitArrayFile* formVersionBitArray; // 048
78  TESBitArrayFile* formIDBitArray; // 050
79  char fileName[WinAPI::MAX_PATH]; // 058
80  char path[WinAPI::MAX_PATH]; // 15C
81  char* buffer; // 260
82  std::uint32_t bufferAllocSize; // 268
83  std::uint32_t firstCellOffset; // 26C
84  std::uint32_t currCellOffset; // 270
85  std::uint32_t unk274; // 274
87  std::uint32_t currRefOffset; // 280
88  FORM currentform; // 284
89  std::uint32_t currentchunkID; // 29C
90  std::uint32_t actualChunkSize; // 2A0
91  std::uint32_t filesize; // 2A4
92  std::uint32_t fileOffset; // 2A8
93  std::uint32_t formoffset; // 2AC
94  std::uint32_t chunkoffset; // 2B0
95  FORM saveform; // 2B4
96  std::uint32_t saveFormOffset; // 2CC
97  std::uint64_t saveChunkOffset; // 2D0
98  std::uint64_t unk2D8; // 2D8
99  std::uint64_t unk2E0; // 2E0
100  std::uint8_t unk2E8; // 2E8
101  bool isBigEndian; // 2E9
102  std::uint8_t unk2EA; // 2EA
103  std::uint8_t pad2EB; // 2EB
105  float unk42C; // 42C
106  std::uint32_t unk430; // 430
107  std::uint32_t flags; // 434
109  std::uint32_t pad43C; // 43C
112  std::uint32_t masterCount; // 460
113  std::uint32_t pad464; // 464
114  TESFile** masterPtrs; // 468
116  std::uint8_t compileIndex; // 478
117  std::uint8_t pad479; // 479
118  std::uint16_t smallFileCompileIndex; // 47A
119  std::uint32_t pad47C; // 47C
123  std::uint32_t decompressedFormBufferSize; // 4A8
124  std::uint32_t pad4AC; // 4AC
126  std::uint32_t reservedDecompressionBufferSize; // 4B8
127  std::uint32_t pad4BC; // 4BC
128  void* unk4C0; // 4C0
129  };
130  static_assert(sizeof(TESFile) == 0x4C8);
131 }
Definition: BSFile.h:8
Definition: TESFile.h:14
void ReadData(void *a_buf, std::uint32_t a_size)
std::uint64_t unk020
Definition: TESFile.h:69
constexpr std::uint32_t GetCurrentChunkID() const noexcept
Definition: TESFile.h:52
void * reservedDecompressionBuffer
Definition: TESFile.h:125
std::uint64_t unk2D8
Definition: TESFile.h:98
std::uint8_t unk028
Definition: TESFile.h:70
TESBitArrayFile * formIDBitArray
Definition: TESFile.h:78
std::uint32_t currentchunkID
Definition: TESFile.h:89
RecordFlag
Definition: TESFile.h:35
char fileName[WinAPI::MAX_PATH]
Definition: TESFile.h:79
std::uint32_t pad02C
Definition: TESFile.h:73
bool SeekNextSubrecord()
constexpr bool IsLight() const noexcept
Definition: TESFile.h:57
stl::enumeration< Error, std::uint32_t > lastError
Definition: TESFile.h:64
void * unk4C0
Definition: TESFile.h:128
std::uint32_t pad004
Definition: TESFile.h:65
TESBitArrayFile * formUserDataBitArray
Definition: TESFile.h:76
std::uint32_t unk430
Definition: TESFile.h:106
constexpr bool IsLocalized() const noexcept
Definition: TESFile.h:58
BSFile * file
Definition: TESFile.h:75
BSString summary
Definition: TESFile.h:121
BSFile * lockedFile
Definition: TESFile.h:74
FORM saveform
Definition: TESFile.h:95
FormType GetFormType()
std::uint32_t flags
Definition: TESFile.h:107
stl::enumeration< RecordFlag, std::uint32_t > recordFlags
Definition: TESFile.h:108
std::uint32_t fileOffset
Definition: TESFile.h:92
std::uint32_t decompressedFormBufferSize
Definition: TESFile.h:123
std::uint32_t pad464
Definition: TESFile.h:113
BSSimpleList< const char * > masters
Definition: TESFile.h:110
bool isBigEndian
Definition: TESFile.h:101
FORM currentform
Definition: TESFile.h:88
std::uint64_t unk018
Definition: TESFile.h:68
constexpr std::uint32_t GetPartialIndex() const noexcept
Definition: TESFile.h:56
std::uint64_t saveChunkOffset
Definition: TESFile.h:97
std::uint32_t formoffset
Definition: TESFile.h:93
WinAPI::FILETIME deletedFormTime
Definition: TESFile.h:115
std::uint32_t pad4BC
Definition: TESFile.h:127
std::uint16_t pad02A
Definition: TESFile.h:72
Error
Definition: TESFile.h:17
std::uint32_t currRefOffset
Definition: TESFile.h:87
std::uint32_t firstCellOffset
Definition: TESFile.h:83
constexpr std::uint32_t GetCurrentSubRecordSize() const noexcept
Definition: TESFile.h:51
TESFile * threadSafeParent
Definition: TESFile.h:66
TESObjectCELL * currCell
Definition: TESFile.h:86
std::uint8_t unk029
Definition: TESFile.h:71
std::uint32_t pad4AC
Definition: TESFile.h:124
std::uint32_t saveFormOffset
Definition: TESFile.h:96
char * decompressedFormBuffer
Definition: TESFile.h:122
std::uint8_t pad2EB
Definition: TESFile.h:103
std::uint8_t GetCompileIndex() const noexcept
Definition: TESFile.h:49
std::uint32_t bufferAllocSize
Definition: TESFile.h:82
char path[WinAPI::MAX_PATH]
Definition: TESFile.h:80
std::uint32_t pad43C
Definition: TESFile.h:109
BSString createdBy
Definition: TESFile.h:120
char * buffer
Definition: TESFile.h:81
void * threadSafeFileMap
Definition: TESFile.h:67
std::uint32_t reservedDecompressionBufferSize
Definition: TESFile.h:126
std::uint8_t compileIndex
Definition: TESFile.h:116
std::uint32_t masterCount
Definition: TESFile.h:112
std::uint32_t actualChunkSize
Definition: TESFile.h:90
std::uint16_t GetSmallFileCompileIndex() const noexcept
Definition: TESFile.h:55
std::uint32_t pad47C
Definition: TESFile.h:119
std::uint64_t unk2E0
Definition: TESFile.h:99
stl::zstring GetFilename() const noexcept
Definition: TESFile.h:53
std::uint8_t pad479
Definition: TESFile.h:117
std::uint32_t GetCurrentSubRecordType()
std::uint32_t currCellOffset
Definition: TESFile.h:84
WinAPI::WIN32_FIND_DATAA fileData
Definition: TESFile.h:104
TESFile ** masterPtrs
Definition: TESFile.h:114
float unk42C
Definition: TESFile.h:105
std::uint16_t smallFileCompileIndex
Definition: TESFile.h:118
BSSimpleList< std::uint64_t * > mastersData
Definition: TESFile.h:111
TESBitArrayFile * formVersionBitArray
Definition: TESFile.h:77
std::uint8_t unk2E8
Definition: TESFile.h:100
std::uint32_t unk274
Definition: TESFile.h:85
std::uint8_t unk2EA
Definition: TESFile.h:102
bool Seek(std::uint32_t a_offset)
TESFile * Duplicate(std::uint32_t a_cacheSize=0x4000)
std::uint32_t filesize
Definition: TESFile.h:91
std::uint32_t chunkoffset
Definition: TESFile.h:94
Definition: TESObjectCELL.h:102
constexpr bool all(Args... a_args) const noexcept requires(std
Definition: PCH.h:329
Definition: AbsorbEffect.h:6
FormType
Definition: FormTypes.h:139
constexpr auto MAX_PATH
Definition: WinAPI.h:9
basic_zstring< char > zstring
Definition: PCH.h:77
Definition: FORM.h:6
Definition: WinAPI.h:27
Definition: WinAPI.h:43