Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomAttributeTableReader.cs
Go to the documentation of this file.
2
4
5internal readonly struct CustomAttributeTableReader
6{
7 internal readonly int NumberOfRows;
8
9 private readonly bool _IsHasCustomAttributeRefSizeSmall;
10
12
13 private readonly bool _IsBlobHeapRefSizeSmall;
14
15 private readonly int _ParentOffset;
16
17 private readonly int _TypeOffset;
18
19 private readonly int _ValueOffset;
20
21 internal readonly int RowSize;
22
23 internal readonly MemoryBlock Block;
24
25 internal readonly int[]? PtrTable;
26
27 internal CustomAttributeTableReader(int numberOfRows, bool declaredSorted, int hasCustomAttributeRefSize, int customAttributeTypeRefSize, int blobHeapRefSize, MemoryBlock containingBlock, int containingBlockOffset)
28 {
29 NumberOfRows = numberOfRows;
30 _IsHasCustomAttributeRefSizeSmall = hasCustomAttributeRefSize == 2;
31 _IsCustomAttributeTypeRefSizeSmall = customAttributeTypeRefSize == 2;
32 _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
33 _ParentOffset = 0;
34 _TypeOffset = _ParentOffset + hasCustomAttributeRefSize;
35 _ValueOffset = _TypeOffset + customAttributeTypeRefSize;
36 RowSize = _ValueOffset + blobHeapRefSize;
37 Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, RowSize * numberOfRows);
38 PtrTable = null;
39 if (!declaredSorted && !CheckSorted())
40 {
42 }
43 }
44
50
56
62
63 internal void GetAttributeRange(EntityHandle parentHandle, out int firstImplRowId, out int lastImplRowId)
64 {
65 int startRowNumber;
66 int endRowNumber;
67 if (PtrTable != null)
68 {
70 }
71 else
72 {
74 }
75 if (startRowNumber == -1)
76 {
77 firstImplRowId = 1;
78 lastImplRowId = 0;
79 }
80 else
81 {
82 firstImplRowId = startRowNumber + 1;
83 lastImplRowId = endRowNumber + 1;
84 }
85 }
86
91}
static EntityHandle ConvertToHandle(uint customAttributeType)
static EntityHandle ConvertToHandle(uint hasCustomAttribute)
unsafe MemoryBlock GetMemoryBlockAt(int offset, int length)
bool IsOrderedByReferenceAscending(int rowSize, int referenceOffset, bool isReferenceSmall)
int PeekHeapReference(int offset, bool smallRefSize)
int[] BuildPtrTable(int numberOfRows, int rowSize, int referenceOffset, bool isReferenceSmall)
void BinarySearchReferenceRange(int rowCount, int rowSize, int referenceOffset, uint referenceValue, bool isReferenceSmall, out int startRowNumber, out int endRowNumber)
uint PeekTaggedReference(int offset, bool smallRefSize)
static BlobHandle FromOffset(int heapOffset)
Definition BlobHandle.cs:34
CustomAttributeTableReader(int numberOfRows, bool declaredSorted, int hasCustomAttributeRefSize, int customAttributeTypeRefSize, int blobHeapRefSize, MemoryBlock containingBlock, int containingBlockOffset)
void GetAttributeRange(EntityHandle parentHandle, out int firstImplRowId, out int lastImplRowId)