mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
fix s3, fix health + backpack bug on 1.11, change replciation, fix 7.20 & 12.61, fix backpack on >S9, probably some other stuff i forgot
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
#pragma once
|
|
|
|
template <int NumElements>
|
|
class TInlineAllocator
|
|
{
|
|
private:
|
|
template <int Size, int Alignment>
|
|
struct alignas(Alignment) TAlignedBytes
|
|
{
|
|
unsigned char Pad[Size];
|
|
};
|
|
|
|
template <typename ElementType>
|
|
struct TTypeCompatibleBytes : public TAlignedBytes<sizeof(ElementType), alignof(ElementType)>
|
|
{
|
|
};
|
|
|
|
public:
|
|
template <typename ElementType>
|
|
class ForElementType
|
|
{
|
|
friend class TBitArray;
|
|
|
|
private:
|
|
TTypeCompatibleBytes<ElementType> InlineData[NumElements];
|
|
|
|
ElementType* SecondaryData;
|
|
|
|
public:
|
|
|
|
FORCEINLINE int32 NumInlineBytes() const
|
|
{
|
|
return sizeof(ElementType) * NumElements;
|
|
}
|
|
FORCEINLINE int32 NumInlineBits() const
|
|
{
|
|
return NumInlineBytes() * 8;
|
|
}
|
|
|
|
FORCEINLINE ElementType& operator[](int32 Index)
|
|
{
|
|
return *(ElementType*)(&InlineData[Index]);
|
|
}
|
|
FORCEINLINE const ElementType& operator[](int32 Index) const
|
|
{
|
|
return *(ElementType*)(&InlineData[Index]);
|
|
}
|
|
|
|
FORCEINLINE void operator=(void* InElements)
|
|
{
|
|
SecondaryData = InElements;
|
|
}
|
|
|
|
FORCEINLINE ElementType& GetInlineElement(int32 Index)
|
|
{
|
|
return *(ElementType*)(&InlineData[Index]);
|
|
}
|
|
FORCEINLINE const ElementType& GetInlineElement(int32 Index) const
|
|
{
|
|
return *(ElementType*)(&InlineData[Index]);
|
|
}
|
|
FORCEINLINE ElementType& GetSecondaryElement(int32 Index)
|
|
{
|
|
return SecondaryData[Index];
|
|
}
|
|
FORCEINLINE const ElementType& GetSecondaryElement(int32 Index) const
|
|
{
|
|
return SecondaryData[Index];
|
|
}
|
|
};
|
|
}; |