mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
Fix more gcc compilation issues
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#include "AssetLoader.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
|
@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/ZoneTypes.h"
|
||||
#include "Pool/XAssetInfo.h"
|
||||
#include "ContentLoaderBase.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@ std::string BlockOverflowException::DetailedMessage()
|
||||
return "XBlock " + m_block->m_name + " overflowed while trying to load zone.";
|
||||
}
|
||||
|
||||
char const* BlockOverflowException::what() const
|
||||
char const* BlockOverflowException::what() const noexcept
|
||||
{
|
||||
return "Invalid Zone. XBlock overflowed.";
|
||||
}
|
@ -10,5 +10,5 @@ public:
|
||||
explicit BlockOverflowException(XBlock* block);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ std::string InvalidChunkSizeException::DetailedMessage()
|
||||
}
|
||||
}
|
||||
|
||||
char const* InvalidChunkSizeException::what() const
|
||||
char const* InvalidChunkSizeException::what() const noexcept
|
||||
{
|
||||
return "Zone has invalid chunk size";
|
||||
}
|
@ -11,5 +11,5 @@ public:
|
||||
InvalidChunkSizeException(size_t size, size_t max);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ std::string InvalidCompressionException::DetailedMessage()
|
||||
return "Zone has invalid or unsupported compression. Inflate failed";
|
||||
}
|
||||
|
||||
char const* InvalidCompressionException::what() const
|
||||
char const* InvalidCompressionException::what() const noexcept
|
||||
{
|
||||
return "Zone has invalid or unsupported compression. Inflate failed";
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ class InvalidCompressionException final : public LoadingException
|
||||
{
|
||||
public:
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ std::string InvalidFileNameException::DetailedMessage()
|
||||
return "Name verification failed: The fastfile was created as '" + m_expected_file_name + "' but loaded as '" + m_actual_file_name + "'";
|
||||
}
|
||||
|
||||
char const* InvalidFileNameException::what() const
|
||||
char const* InvalidFileNameException::what() const noexcept
|
||||
{
|
||||
return "The filename when created and when loaded does not match";
|
||||
}
|
@ -10,5 +10,5 @@ public:
|
||||
InvalidFileNameException(std::string& actualFileName, std::string& expectedFileName);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ std::string InvalidHashException::DetailedMessage()
|
||||
return "Loaded fastfile has an invalid hash.";
|
||||
}
|
||||
|
||||
char const* InvalidHashException::what() const
|
||||
char const* InvalidHashException::what() const noexcept
|
||||
{
|
||||
return "Loaded fastfile has an invalid hash.";
|
||||
}
|
@ -5,5 +5,5 @@ class InvalidHashException final : public LoadingException
|
||||
{
|
||||
public:
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ std::string InvalidMagicException::DetailedMessage()
|
||||
return "Expected magic '" + std::string(m_expected_magic) + "'";
|
||||
}
|
||||
|
||||
char const* InvalidMagicException::what() const
|
||||
char const* InvalidMagicException::what() const noexcept
|
||||
{
|
||||
return "Encountered invalid magic when loading.";
|
||||
}
|
@ -9,5 +9,5 @@ public:
|
||||
explicit InvalidMagicException(const char* expectedMagic);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ std::string InvalidOffsetBlockException::DetailedMessage()
|
||||
return "Zone tried to reference invalid block " + std::to_string(m_referenced_block);
|
||||
}
|
||||
|
||||
char const* InvalidOffsetBlockException::what() const
|
||||
char const* InvalidOffsetBlockException::what() const noexcept
|
||||
{
|
||||
return "Zone referenced invalid block";
|
||||
}
|
@ -10,5 +10,5 @@ public:
|
||||
explicit InvalidOffsetBlockException(block_t referencedBlock);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ std::string InvalidOffsetBlockOffsetException::DetailedMessage()
|
||||
+ " which is larger than its size " + std::to_string(m_referenced_block->m_buffer_size);
|
||||
}
|
||||
|
||||
char const* InvalidOffsetBlockOffsetException::what() const
|
||||
char const* InvalidOffsetBlockOffsetException::what() const noexcept
|
||||
{
|
||||
return "Zone referenced offset of block that is out of bounds";
|
||||
}
|
@ -11,5 +11,5 @@ public:
|
||||
InvalidOffsetBlockOffsetException(XBlock* block, size_t referencedOffset);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ std::string InvalidSignatureException::DetailedMessage()
|
||||
return "Loaded fastfile has an invalid signature.";
|
||||
}
|
||||
|
||||
char const* InvalidSignatureException::what() const
|
||||
char const* InvalidSignatureException::what() const noexcept
|
||||
{
|
||||
return "Loaded fastfile has an invalid signature.";
|
||||
}
|
@ -5,5 +5,5 @@ class InvalidSignatureException final : public LoadingException
|
||||
{
|
||||
public:
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ std::string InvalidVersionException::DetailedMessage()
|
||||
return "Expected version " + std::to_string(m_expected_version) + " but encountered version " + std::to_string(m_actual_version);
|
||||
}
|
||||
|
||||
char const* InvalidVersionException::what() const
|
||||
char const* InvalidVersionException::what() const noexcept
|
||||
{
|
||||
return "Encountered invalid version when loading.";
|
||||
}
|
@ -10,5 +10,5 @@ public:
|
||||
InvalidVersionException(unsigned int expectedVersion, unsigned int actualVersion);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ std::string InvalidXBlockSizeException::DetailedMessage()
|
||||
return "Zone uses more XBlock memory than allowed: " + std::to_string(m_size) + " (max is " + std::to_string(m_max) + ")";
|
||||
}
|
||||
|
||||
char const* InvalidXBlockSizeException::what() const
|
||||
char const* InvalidXBlockSizeException::what() const noexcept
|
||||
{
|
||||
return "Zone has invalid block size";
|
||||
}
|
@ -10,5 +10,5 @@ public:
|
||||
InvalidXBlockSizeException(uint64_t size, uint64_t max);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ std::string OutOfBlockBoundsException::DetailedMessage()
|
||||
return "Tried to load to location out of bounds from current XBlock " + m_block->m_name + ".";
|
||||
}
|
||||
|
||||
char const* OutOfBlockBoundsException::what() const
|
||||
char const* OutOfBlockBoundsException::what() const noexcept
|
||||
{
|
||||
return "Invalid Zone. Out of XBlock bounds.";
|
||||
}
|
@ -10,5 +10,5 @@ public:
|
||||
explicit OutOfBlockBoundsException(XBlock* block);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ std::string TooManyAuthedGroupsException::DetailedMessage()
|
||||
return "Loaded fastfile has too many authed groups.";
|
||||
}
|
||||
|
||||
char const* TooManyAuthedGroupsException::what() const
|
||||
char const* TooManyAuthedGroupsException::what() const noexcept
|
||||
{
|
||||
return "Loaded fastfile has too many authed groups.";
|
||||
}
|
@ -5,5 +5,5 @@ class TooManyAuthedGroupsException final : public LoadingException
|
||||
{
|
||||
public:
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ std::string UnexpectedEndOfFileException::DetailedMessage()
|
||||
return "Unexpected end of file";
|
||||
}
|
||||
|
||||
char const* UnexpectedEndOfFileException::what() const
|
||||
char const* UnexpectedEndOfFileException::what() const noexcept
|
||||
{
|
||||
return "Unexpected end of file";
|
||||
}
|
@ -7,5 +7,5 @@ public:
|
||||
UnexpectedEndOfFileException();
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ std::string UnsupportedAssetTypeException::DetailedMessage()
|
||||
return "Zone has an unsupported asset type " + std::to_string(m_asset_type) + " and therefore cannot be loaded.";
|
||||
}
|
||||
|
||||
char const* UnsupportedAssetTypeException::what() const
|
||||
char const* UnsupportedAssetTypeException::what() const noexcept
|
||||
{
|
||||
return "Zone has unsupported asset type.";
|
||||
}
|
@ -9,5 +9,5 @@ public:
|
||||
explicit UnsupportedAssetTypeException(int assetType);
|
||||
|
||||
std::string DetailedMessage() override;
|
||||
char const* what() const override;
|
||||
char const* what() const noexcept override;
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
class ILoadingStream
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/Exception/InvalidHashException.h"
|
||||
@ -80,8 +80,7 @@ public:
|
||||
m_hash_function->GetHashSize()) != 0)
|
||||
throw InvalidHashException();
|
||||
|
||||
memcpy_s(m_chunk_hashes_buffer.get(), m_authed_chunk_count * m_hash_function->GetHashSize(),
|
||||
m_chunk_buffer.get(), m_authed_chunk_count * m_hash_function->GetHashSize());
|
||||
memcpy(m_chunk_hashes_buffer.get(), m_chunk_buffer.get(), m_authed_chunk_count * m_hash_function->GetHashSize());
|
||||
|
||||
m_current_chunk_in_group++;
|
||||
}
|
||||
@ -122,8 +121,8 @@ public:
|
||||
if (sizeToWrite > m_current_chunk_size - m_current_chunk_offset)
|
||||
sizeToWrite = m_current_chunk_size - m_current_chunk_offset;
|
||||
|
||||
memcpy_s(&static_cast<uint8_t*>(buffer)[loadedSize], length - loadedSize,
|
||||
&m_chunk_buffer[m_current_chunk_offset], sizeToWrite);
|
||||
assert(length - loadedSize >= sizeToWrite);
|
||||
memcpy(&static_cast<uint8_t*>(buffer)[loadedSize], &m_chunk_buffer[m_current_chunk_offset], sizeToWrite);
|
||||
loadedSize += sizeToWrite;
|
||||
m_current_chunk_offset += sizeToWrite;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "ProcessorCaptureData.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize)
|
||||
: m_data(std::make_unique<uint8_t[]>(captureSize)),
|
||||
@ -23,7 +24,8 @@ size_t ProcessorCaptureData::Load(void* buffer, const size_t length)
|
||||
dataToCapture = length;
|
||||
|
||||
size_t loadedSize = m_base_stream->Load(&m_data[m_captured_data_size], dataToCapture);
|
||||
memcpy_s(buffer, length, &m_data[m_captured_data_size], loadedSize);
|
||||
assert(length >= loadedSize);
|
||||
memcpy(buffer, &m_data[m_captured_data_size], loadedSize);
|
||||
|
||||
m_captured_data_size += loadedSize;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ProcessorInflate.h"
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <zlib.h>
|
||||
@ -33,7 +33,7 @@ public:
|
||||
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
throw std::exception("Initializing inflate failed");
|
||||
throw std::runtime_error("Initializing inflate failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
class DBLoadStream
|
||||
{
|
||||
@ -294,14 +295,15 @@ public:
|
||||
|
||||
if (sizeToRead > bytesLeftInCurrentChunk)
|
||||
{
|
||||
memcpy_s(bufferPos, sizeToRead, &m_current_chunk[m_current_chunk_offset], bytesLeftInCurrentChunk);
|
||||
assert(sizeToRead >= bytesLeftInCurrentChunk);
|
||||
memcpy(bufferPos, &m_current_chunk[m_current_chunk_offset], bytesLeftInCurrentChunk);
|
||||
loadedSize += bytesLeftInCurrentChunk;
|
||||
|
||||
NextStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy_s(bufferPos, sizeToRead, &m_current_chunk[m_current_chunk_offset], sizeToRead);
|
||||
memcpy(bufferPos, &m_current_chunk[m_current_chunk_offset], sizeToRead);
|
||||
loadedSize += sizeToRead;
|
||||
m_current_chunk_offset += sizeToRead;
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include "ChunkProcessorInflate.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "zlib.h"
|
||||
#include "zutil.h"
|
||||
#include <exception>
|
||||
|
||||
#include "Loading/Exception/InvalidCompressionException.h"
|
||||
|
||||
size_t ChunkProcessorInflate::Process(int streamNumber, const uint8_t* input, const size_t inputLength, uint8_t* output, const size_t outputBufferSize)
|
||||
@ -14,7 +17,7 @@ size_t ChunkProcessorInflate::Process(int streamNumber, const uint8_t* input, co
|
||||
int ret = inflateInit2(&stream, -DEF_WBITS);
|
||||
if(ret != Z_OK)
|
||||
{
|
||||
throw std::exception("Initializing inflate failed.");
|
||||
throw std::runtime_error("Initializing inflate failed.");
|
||||
}
|
||||
|
||||
stream.avail_in = inputLength;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
class IXChunkProcessor
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "StepVerifyHash.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
#include "Loading/Exception/InvalidHashException.h"
|
||||
|
||||
|
@ -1,17 +1,20 @@
|
||||
#include "StepVerifyMagic.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Loading/Exception/InvalidMagicException.h"
|
||||
|
||||
StepVerifyMagic::StepVerifyMagic(const char* magic)
|
||||
{
|
||||
m_magic = magic;
|
||||
m_magic_len = strlen(m_magic);
|
||||
}
|
||||
|
||||
void StepVerifyMagic::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
{
|
||||
const size_t magicLength = strlen(m_magic);
|
||||
char currentCharacter;
|
||||
|
||||
for(unsigned i = 0; i < magicLength; i++)
|
||||
for(unsigned i = 0; i < m_magic_len; i++)
|
||||
{
|
||||
stream->Load(¤tCharacter, sizeof(char));
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
class StepVerifyMagic final : public ILoadingStep
|
||||
{
|
||||
const char* m_magic;
|
||||
size_t m_magic_len;
|
||||
|
||||
public:
|
||||
explicit StepVerifyMagic(const char* magic);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "ILoadingStream.h"
|
||||
|
||||
class StreamProcessor : public ILoadingStream
|
||||
|
Reference in New Issue
Block a user