2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-04 02:01:51 +00:00

refactor: implement base x64 fastfile loading for iw4

This commit is contained in:
Jan
2025-05-03 17:31:17 +01:00
parent 78d8fba6f8
commit 03ccede91c
43 changed files with 1025 additions and 331 deletions

View File

@ -1,34 +1,23 @@
#include "XBlock.h"
#include <cassert>
XBlock::XBlock(const std::string& name, const int index, const Type type)
XBlock::XBlock(std::string name, const unsigned index, const XBlockType type)
: m_name(std::move(name)),
m_index(index),
m_type(type),
m_buffer_size(0u)
{
m_name = name;
m_index = index;
m_type = type;
m_buffer = nullptr;
m_buffer_size = 0;
}
XBlock::~XBlock()
{
delete[] m_buffer;
m_buffer = nullptr;
}
void XBlock::Alloc(const size_t blockSize)
{
delete[] m_buffer;
if (blockSize > 0)
{
m_buffer = new uint8_t[blockSize];
m_buffer = std::make_unique<uint8_t[]>(blockSize);
m_buffer_size = blockSize;
}
else
{
m_buffer = nullptr;
m_buffer.reset();
m_buffer_size = 0;
}
}

View File

@ -1,27 +1,29 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
enum class XBlockType : std::uint8_t
{
BLOCK_TYPE_TEMP,
BLOCK_TYPE_RUNTIME,
BLOCK_TYPE_DELAY,
BLOCK_TYPE_NORMAL
};
class XBlock
{
public:
enum class Type
{
BLOCK_TYPE_TEMP,
BLOCK_TYPE_RUNTIME,
BLOCK_TYPE_DELAY,
BLOCK_TYPE_NORMAL
};
XBlock(std::string name, unsigned index, XBlockType type);
void Alloc(size_t blockSize);
std::string m_name;
unsigned m_index;
Type m_type;
XBlockType m_type;
uint8_t* m_buffer;
std::unique_ptr<uint8_t[]> m_buffer;
size_t m_buffer_size;
XBlock(const std::string& name, int index, Type type);
~XBlock();
void Alloc(size_t blockSize);
};