#pragma once namespace RE { class BSDataBufferHeapAllocator; template class BSTDataBuffer { public: class Block { public: // members std::uint32_t size: 24; // 0:00 std::uint32_t id: 8; // 0:24 }; static_assert(sizeof(Block) == 0x4); [[nodiscard]] std::pair GetBlock(std::uint8_t a_id) const noexcept { if (!buffer) { return { nullptr, 0 }; } std::uint32_t offset = 0; const auto blocks = reinterpret_cast(buffer + size); for (std::uint32_t i = 0; i < N && blocks[i].id != 0xFFu; ++i) { if (blocks[i].id == a_id) { return { blocks + i, offset }; } else { offset += blocks[i].size; } } return { nullptr, 0 }; } template [[nodiscard]] std::span GetBuffer(std::uint8_t a_id) const noexcept { const auto [block, offset] = GetBlock(a_id); if (block) { return { reinterpret_cast(buffer + offset), block->size / sizeof(T) }; } else { return {}; } } // members std::byte* buffer; // 00 std::uint32_t size; // 08 }; extern template class BSTDataBuffer<1>; extern template class BSTDataBuffer<2>; }