mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Replace duplicate CHUNK_ENCODING_* with SawyerEncoding::*
This commit is contained in:
@@ -45,14 +45,14 @@ namespace OpenRCT2::SawyerCoding
|
||||
{
|
||||
switch (chunkHeader.encoding)
|
||||
{
|
||||
case CHUNK_ENCODING_NONE:
|
||||
case SawyerEncoding::none:
|
||||
std::memcpy(dst_file, &chunkHeader, sizeof(ChunkHeader));
|
||||
dst_file += sizeof(ChunkHeader);
|
||||
std::memcpy(dst_file, buffer, chunkHeader.length);
|
||||
// fwrite(&chunkHeader, sizeof(ChunkHeader), 1, file);
|
||||
// fwrite(buffer, 1, chunkHeader.length, file);
|
||||
break;
|
||||
case CHUNK_ENCODING_RLE:
|
||||
case SawyerEncoding::rle:
|
||||
{
|
||||
auto encode_buffer = std::make_unique<uint8_t[]>(0x600000);
|
||||
chunkHeader.length = static_cast<uint32_t>(EncodeChunkRLE(buffer, encode_buffer.get(), chunkHeader.length));
|
||||
@@ -61,7 +61,7 @@ namespace OpenRCT2::SawyerCoding
|
||||
std::memcpy(dst_file, encode_buffer.get(), chunkHeader.length);
|
||||
}
|
||||
break;
|
||||
case CHUNK_ENCODING_RLECOMPRESSED:
|
||||
case SawyerEncoding::rleCompressed:
|
||||
{
|
||||
auto encode_buffer = std::make_unique<uint8_t[]>(chunkHeader.length * 2);
|
||||
auto encode_buffer2 = std::make_unique<uint8_t[]>(0x600000);
|
||||
@@ -73,7 +73,7 @@ namespace OpenRCT2::SawyerCoding
|
||||
std::memcpy(dst_file, encode_buffer2.get(), chunkHeader.length);
|
||||
}
|
||||
break;
|
||||
case CHUNK_ENCODING_ROTATE:
|
||||
case SawyerEncoding::rotate:
|
||||
{
|
||||
auto encode_buffer = std::make_unique<uint8_t[]>(chunkHeader.length);
|
||||
std::memcpy(encode_buffer.get(), buffer, chunkHeader.length);
|
||||
|
||||
@@ -9,20 +9,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../rct12/SawyerChunk.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
// TODO: make enum class in SawyerCoding namespace
|
||||
enum
|
||||
{
|
||||
CHUNK_ENCODING_NONE,
|
||||
CHUNK_ENCODING_RLE,
|
||||
CHUNK_ENCODING_RLECOMPRESSED,
|
||||
CHUNK_ENCODING_ROTATE
|
||||
};
|
||||
|
||||
// TODO: make enum class in SawyerCoding namespace
|
||||
enum
|
||||
{
|
||||
@@ -43,7 +36,7 @@ namespace OpenRCT2::SawyerCoding
|
||||
#pragma pack(push, 1)
|
||||
struct ChunkHeader
|
||||
{
|
||||
uint8_t encoding;
|
||||
SawyerEncoding encoding;
|
||||
uint32_t length;
|
||||
};
|
||||
static_assert(sizeof(ChunkHeader) == 5);
|
||||
|
||||
@@ -475,10 +475,10 @@ private:
|
||||
}
|
||||
|
||||
// 0x0098DA2C
|
||||
static constexpr std::array<int32_t, 11> kLegacyObjectEntryGroupEncoding = {
|
||||
CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE,
|
||||
CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE,
|
||||
CHUNK_ENCODING_RLE, CHUNK_ENCODING_RLE, CHUNK_ENCODING_ROTATE,
|
||||
static constexpr std::array<SawyerEncoding, 11> kLegacyObjectEntryGroupEncoding = {
|
||||
SawyerEncoding::rle, SawyerEncoding::rle, SawyerEncoding::rle, SawyerEncoding::rle,
|
||||
SawyerEncoding::rle, SawyerEncoding::rle, SawyerEncoding::rle, SawyerEncoding::rle,
|
||||
SawyerEncoding::rle, SawyerEncoding::rle, SawyerEncoding::rotate,
|
||||
};
|
||||
|
||||
static void SaveObject(
|
||||
|
||||
@@ -58,10 +58,10 @@ namespace OpenRCT2
|
||||
|
||||
switch (header.encoding)
|
||||
{
|
||||
case CHUNK_ENCODING_NONE:
|
||||
case CHUNK_ENCODING_RLE:
|
||||
case CHUNK_ENCODING_RLECOMPRESSED:
|
||||
case CHUNK_ENCODING_ROTATE:
|
||||
case SawyerEncoding::none:
|
||||
case SawyerEncoding::rle:
|
||||
case SawyerEncoding::rleCompressed:
|
||||
case SawyerEncoding::rotate:
|
||||
{
|
||||
auto compressedData = std::make_unique<uint8_t[]>(header.length);
|
||||
if (_stream->TryRead(compressedData.get(), header.length) != header.length)
|
||||
@@ -108,7 +108,7 @@ namespace OpenRCT2
|
||||
throw SawyerChunkException(kExceptionMessageCorruptChunkSize);
|
||||
}
|
||||
|
||||
SawyerCoding::ChunkHeader header{ CHUNK_ENCODING_RLE, compressedDataLength };
|
||||
SawyerCoding::ChunkHeader header{ SawyerEncoding::rle, compressedDataLength };
|
||||
auto buffer = DecodeChunk(compressedData.get(), header);
|
||||
if (buffer.GetLength() == 0)
|
||||
{
|
||||
@@ -266,16 +266,16 @@ namespace OpenRCT2
|
||||
|
||||
switch (header.encoding)
|
||||
{
|
||||
case CHUNK_ENCODING_NONE:
|
||||
case SawyerEncoding::none:
|
||||
buf.Write(src, header.length);
|
||||
break;
|
||||
case CHUNK_ENCODING_RLE:
|
||||
case SawyerEncoding::rle:
|
||||
buf = DecodeChunkRLE(src, header.length);
|
||||
break;
|
||||
case CHUNK_ENCODING_RLECOMPRESSED:
|
||||
case SawyerEncoding::rleCompressed:
|
||||
buf = DecodeChunkRLERepeat(src, header.length);
|
||||
break;
|
||||
case CHUNK_ENCODING_ROTATE:
|
||||
case SawyerEncoding::rotate:
|
||||
buf = DecodeChunkRotate(src, header.length);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRCT2
|
||||
void SawyerChunkWriter::WriteChunk(const void* src, size_t length, SawyerEncoding encoding)
|
||||
{
|
||||
SawyerCoding::ChunkHeader header;
|
||||
header.encoding = static_cast<uint8_t>(encoding);
|
||||
header.encoding = encoding;
|
||||
header.length = static_cast<uint32_t>(length);
|
||||
|
||||
auto data = std::make_unique<uint8_t[]>(MAX_COMPRESSED_CHUNK_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user