mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-01-24 08:53:04 +00:00
Reformat code with clang format
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#include "ProcessorAuthedBlocks.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/Exception/InvalidHashException.h"
|
||||
#include "Loading/Exception/TooManyAuthedGroupsException.h"
|
||||
#include "Loading/Exception/UnexpectedEndOfFileException.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
class ProcessorAuthedBlocks::Impl
|
||||
{
|
||||
ProcessorAuthedBlocks* const m_base;
|
||||
@@ -30,7 +30,9 @@ class ProcessorAuthedBlocks::Impl
|
||||
size_t m_current_chunk_size;
|
||||
|
||||
public:
|
||||
Impl(ProcessorAuthedBlocks* base, const unsigned authedChunkCount, const size_t chunkSize,
|
||||
Impl(ProcessorAuthedBlocks* base,
|
||||
const unsigned authedChunkCount,
|
||||
const size_t chunkSize,
|
||||
const unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction,
|
||||
IHashProvider* masterBlockHashProvider)
|
||||
@@ -76,8 +78,7 @@ public:
|
||||
m_master_block_hash_provider->GetHash(m_current_group - 1, &masterBlockHash, &masterBlockHashSize);
|
||||
|
||||
if (masterBlockHashSize != m_hash_function->GetHashSize()
|
||||
|| std::memcmp(m_current_chunk_hash_buffer.get(), masterBlockHash,
|
||||
m_hash_function->GetHashSize()) != 0)
|
||||
|| std::memcmp(m_current_chunk_hash_buffer.get(), masterBlockHash, m_hash_function->GetHashSize()) != 0)
|
||||
throw InvalidHashException();
|
||||
|
||||
memcpy(m_chunk_hashes_buffer.get(), m_chunk_buffer.get(), m_authed_chunk_count * m_hash_function->GetHashSize());
|
||||
@@ -88,7 +89,8 @@ public:
|
||||
{
|
||||
if (std::memcmp(m_current_chunk_hash_buffer.get(),
|
||||
&m_chunk_hashes_buffer[(m_current_chunk_in_group - 1) * m_hash_function->GetHashSize()],
|
||||
m_hash_function->GetHashSize()) != 0)
|
||||
m_hash_function->GetHashSize())
|
||||
!= 0)
|
||||
throw InvalidHashException();
|
||||
|
||||
if (++m_current_chunk_in_group > m_authed_chunk_count)
|
||||
@@ -136,12 +138,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
ProcessorAuthedBlocks::ProcessorAuthedBlocks(const unsigned authedChunkCount, const size_t chunkSize,
|
||||
ProcessorAuthedBlocks::ProcessorAuthedBlocks(const unsigned authedChunkCount,
|
||||
const size_t chunkSize,
|
||||
const unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction,
|
||||
IHashProvider* masterBlockHashProvider)
|
||||
: m_impl(new Impl(this, authedChunkCount, chunkSize, maxMasterBlockCount, std::move(hashFunction),
|
||||
masterBlockHashProvider))
|
||||
: m_impl(new Impl(this, authedChunkCount, chunkSize, maxMasterBlockCount, std::move(hashFunction), masterBlockHashProvider))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "Crypto.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Loading/IHashProvider.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ProcessorAuthedBlocks final : public StreamProcessor
|
||||
{
|
||||
@@ -11,8 +11,11 @@ class ProcessorAuthedBlocks final : public StreamProcessor
|
||||
Impl* m_impl;
|
||||
|
||||
public:
|
||||
ProcessorAuthedBlocks(unsigned authedChunkCount, size_t chunkSize, unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction, IHashProvider* masterBlockHashProvider);
|
||||
ProcessorAuthedBlocks(unsigned authedChunkCount,
|
||||
size_t chunkSize,
|
||||
unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction,
|
||||
IHashProvider* masterBlockHashProvider);
|
||||
~ProcessorAuthedBlocks() override;
|
||||
ProcessorAuthedBlocks(const ProcessorAuthedBlocks& other) = delete;
|
||||
ProcessorAuthedBlocks(ProcessorAuthedBlocks&& other) noexcept = default;
|
||||
|
||||
@@ -10,8 +10,7 @@ ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize)
|
||||
{
|
||||
}
|
||||
|
||||
ProcessorCaptureData::~ProcessorCaptureData()
|
||||
= default;
|
||||
ProcessorCaptureData::~ProcessorCaptureData() = default;
|
||||
|
||||
size_t ProcessorCaptureData::Load(void* buffer, const size_t length)
|
||||
{
|
||||
@@ -29,7 +28,7 @@ size_t ProcessorCaptureData::Load(void* buffer, const size_t length)
|
||||
|
||||
m_captured_data_size += loadedSize;
|
||||
|
||||
if(length > dataToCapture)
|
||||
if (length > dataToCapture)
|
||||
loadedSize += m_base_stream->Load(&static_cast<uint8_t*>(buffer)[dataToCapture], length - dataToCapture);
|
||||
|
||||
return loadedSize;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ProcessorCaptureData final : public StreamProcessor, public ICapturedDataProvider
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> m_data;
|
||||
|
||||
@@ -24,7 +24,7 @@ size_t ProcessorIW4xDecryption::Load(void* buffer, const size_t length)
|
||||
const auto readLen = m_base_stream->Load(buffer, length);
|
||||
|
||||
auto* charBuffer = static_cast<uint8_t*>(buffer);
|
||||
for(auto i = 0u; i < readLen; i++)
|
||||
for (auto i = 0u; i < readLen; i++)
|
||||
{
|
||||
auto value = charBuffer[i];
|
||||
value ^= m_last_byte;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "ProcessorInflate.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include "Loading/Exception/InvalidCompressionException.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <zlib.h>
|
||||
#include <zutil.h>
|
||||
|
||||
#include "Loading/Exception/InvalidCompressionException.h"
|
||||
|
||||
class ProcessorInflate::Impl
|
||||
{
|
||||
z_stream m_stream{};
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
auto ret = inflate(&m_stream, Z_SYNC_FLUSH);
|
||||
|
||||
if(ret < 0)
|
||||
if (ret < 0)
|
||||
throw InvalidCompressionException();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,17 @@ ProcessorStreamCipher::~ProcessorStreamCipher()
|
||||
m_cipher = nullptr;
|
||||
}
|
||||
|
||||
|
||||
size_t ProcessorStreamCipher::Load(void* buffer, const size_t length)
|
||||
{
|
||||
if(m_base_stream != nullptr)
|
||||
if (m_base_stream != nullptr)
|
||||
{
|
||||
const size_t readSize = m_base_stream->Load(buffer, length);
|
||||
|
||||
if(readSize > 0)
|
||||
if (readSize > 0)
|
||||
m_cipher->Process(buffer, buffer, readSize);
|
||||
|
||||
return readSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Crypto.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
|
||||
class ProcessorStreamCipher final : public StreamProcessor
|
||||
{
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#include "ProcessorXChunks.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
#include "Loading/Exception/InvalidChunkSizeException.h"
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include "Loading/Exception/InvalidChunkSizeException.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <condition_variable>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class DBLoadStream
|
||||
{
|
||||
@@ -59,15 +60,15 @@ class DBLoadStream
|
||||
}
|
||||
|
||||
public:
|
||||
DBLoadStream(const int streamIndex, const size_t chunkSize,
|
||||
std::vector<std::unique_ptr<IXChunkProcessor>>& chunkProcessors) : m_processors(chunkProcessors)
|
||||
DBLoadStream(const int streamIndex, const size_t chunkSize, std::vector<std::unique_ptr<IXChunkProcessor>>& chunkProcessors)
|
||||
: m_processors(chunkProcessors)
|
||||
{
|
||||
m_index = streamIndex;
|
||||
m_chunk_size = chunkSize;
|
||||
|
||||
for(auto& buffer : m_buffers)
|
||||
for (auto& buffer : m_buffers)
|
||||
buffer = std::make_unique<uint8_t[]>(chunkSize);
|
||||
|
||||
|
||||
m_input_buffer = m_buffers[0].get();
|
||||
m_output_buffer = m_buffers[1].get();
|
||||
|
||||
@@ -246,8 +247,8 @@ public:
|
||||
m_eof_stream = 0;
|
||||
}
|
||||
|
||||
ProcessorXChunksImpl(ProcessorXChunks* base, const int numStreams, const size_t xChunkSize,
|
||||
const size_t vanillaBufferSize) : ProcessorXChunksImpl(base, numStreams, xChunkSize)
|
||||
ProcessorXChunksImpl(ProcessorXChunks* base, const int numStreams, const size_t xChunkSize, const size_t vanillaBufferSize)
|
||||
: ProcessorXChunksImpl(base, numStreams, xChunkSize)
|
||||
{
|
||||
m_vanilla_buffer_size = vanillaBufferSize;
|
||||
}
|
||||
@@ -334,4 +335,4 @@ size_t ProcessorXChunks::Load(void* buffer, const size_t length)
|
||||
int64_t ProcessorXChunks::Pos()
|
||||
{
|
||||
return m_impl->Pos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Zone/XChunk/IXChunkProcessor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ProcessorXChunks : public StreamProcessor
|
||||
{
|
||||
class ProcessorXChunksImpl;
|
||||
|
||||
Reference in New Issue
Block a user