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