Fix more gcc compilation issues

This commit is contained in:
Jan
2021-03-03 09:12:27 -08:00
parent a15fd17dfe
commit 1a45cf2107
84 changed files with 786 additions and 713 deletions

View File

@ -1,5 +1,7 @@
#include "gfximage_actions.h"
#include <cassert>
#include <cstring>
using namespace IW4;

View File

@ -1,5 +1,7 @@
#include "loadedsound_actions.h"
#include <cstring>
using namespace IW4;
Actions_LoadedSound::Actions_LoadedSound(Zone* zone)

View File

@ -1,17 +1,12 @@
#include "ZoneLoaderFactoryIW4.h"
#include <cassert>
#include <cstring>
#include <type_traits>
#include "Game/IW4/IW4.h"
#include "Loading/Steps/StepVerifyMagic.h"
#include "Loading/Steps/StepSkipBytes.h"
#include "Loading/Steps/StepVerifyFileName.h"
#include "Loading/Steps/StepLoadSignature.h"
#include "Loading/Steps/StepVerifySignature.h"
#include "Loading/Steps/StepAddProcessor.h"
#include "Loading/Steps/StepAllocXBlocks.h"
#include "Utils/ClassUtils.h"
#include <cassert>
#include "Loading/Steps/StepLoadZoneContent.h"
#include "ContentLoaderIW4.h"
#include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/GameIW4.h"
@ -19,10 +14,19 @@
#include "Loading/Processor/ProcessorAuthedBlocks.h"
#include "Loading/Processor/ProcessorCaptureData.h"
#include "Loading/Processor/ProcessorInflate.h"
#include "Loading/Steps/StepVerifyMagic.h"
#include "Loading/Steps/StepSkipBytes.h"
#include "Loading/Steps/StepVerifyFileName.h"
#include "Loading/Steps/StepLoadSignature.h"
#include "Loading/Steps/StepVerifySignature.h"
#include "Loading/Steps/StepAddProcessor.h"
#include "Loading/Steps/StepAllocXBlocks.h"
#include "Loading/Steps/StepLoadZoneContent.h"
#include "Loading/Steps/StepLoadHash.h"
#include "Loading/Steps/StepRemoveProcessor.h"
#include "Loading/Steps/StepVerifyHash.h"
using namespace IW4;
const std::string ZoneLoaderFactory::MAGIC_SIGNED_INFINITY_WARD = "IWff0100";
@ -176,8 +180,7 @@ class ZoneLoaderFactory::Impl
zoneLoader->AddLoadingStep(new StepVerifyFileName(fileName, sizeof IW4::DB_AuthSubHeader::fastfileName));
zoneLoader->AddLoadingStep(new StepSkipBytes(4)); // Skip reserved
auto* masterBlockHashes = new StepLoadHash(sizeof IW4::DB_AuthHash::bytes,
_countof(IW4::DB_AuthSubHeader::masterBlockHashes));
auto* masterBlockHashes = new StepLoadHash(sizeof IW4::DB_AuthHash::bytes, std::extent<decltype(IW4::DB_AuthSubHeader::masterBlockHashes)>::value);
zoneLoader->AddLoadingStep(masterBlockHashes);
zoneLoader->AddLoadingStep(new StepRemoveProcessor(subHeaderCapture));
@ -188,9 +191,8 @@ class ZoneLoaderFactory::Impl
zoneLoader->AddLoadingStep(new StepSkipBytes(AUTHED_CHUNK_SIZE - sizeof(IW4::DB_AuthHeader)));
zoneLoader->AddLoadingStep(new StepAddProcessor(new ProcessorAuthedBlocks(
AUTHED_CHUNK_COUNT_PER_GROUP, AUTHED_CHUNK_SIZE, _countof(IW4::DB_AuthSubHeader::masterBlockHashes),
std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()),
masterBlockHashes)));
AUTHED_CHUNK_COUNT_PER_GROUP, AUTHED_CHUNK_SIZE, std::extent<decltype(IW4::DB_AuthSubHeader::masterBlockHashes)>::value,
std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), masterBlockHashes)));
}
public:

View File

@ -1,5 +1,7 @@
#include "gfximage_actions.h"
#include <cassert>
#include <cstring>
using namespace T6;

View File

@ -1,6 +1,18 @@
#include "ZoneLoaderFactoryT6.h"
#include <cassert>
#include <cstring>
#include "Game/T6/T6.h"
#include "Utils/ClassUtils.h"
#include "ContentLoaderT6.h"
#include "Game/T6/GameAssetPoolT6.h"
#include "Game/GameLanguage.h"
#include "Game/T6/GameT6.h"
#include "Loading/Processor/ProcessorXChunks.h"
#include "Loading/Processor/XChunks/ChunkProcessorSalsa20.h"
#include "Loading/Processor/XChunks/ChunkProcessorInflate.h"
#include "Loading/Steps/StepVerifyMagic.h"
#include "Loading/Steps/StepSkipBytes.h"
#include "Loading/Steps/StepVerifyFileName.h"
@ -8,18 +20,7 @@
#include "Loading/Steps/StepVerifySignature.h"
#include "Loading/Steps/StepAddProcessor.h"
#include "Loading/Steps/StepAllocXBlocks.h"
#include "Loading/Processor/ProcessorXChunks.h"
#include "Loading/Processor/XChunks/ChunkProcessorSalsa20.h"
#include "Loading/Processor/XChunks/ChunkProcessorInflate.h"
#include "Utils/ClassUtils.h"
#include <cassert>
#include "Loading/Steps/StepLoadZoneContent.h"
#include "ContentLoaderT6.h"
#include "Game/T6/GameAssetPoolT6.h"
#include "Game/T6/GameT6.h"
#include "Game/GameLanguage.h"
using namespace T6;

View File

@ -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),

View File

@ -1,4 +1,6 @@
#pragma once
#include "Zone/ZoneTypes.h"
#include "Pool/XAssetInfo.h"
#include "ContentLoaderBase.h"

View File

@ -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.";
}

View File

@ -10,5 +10,5 @@ public:
explicit BlockOverflowException(XBlock* block);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -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";
}

View File

@ -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;
};

View File

@ -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";
}

View File

@ -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;
};

View File

@ -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";
}

View File

@ -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;
};

View File

@ -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.";
}

View File

@ -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;
};

View File

@ -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.";
}

View File

@ -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;
};

View File

@ -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";
}

View File

@ -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;
};

View File

@ -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";
}

View File

@ -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;
};

View File

@ -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.";
}

View File

@ -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;
};

View File

@ -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.";
}

View File

@ -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;
};

View File

@ -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";
}

View File

@ -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;
};

View File

@ -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.";
}

View File

@ -10,5 +10,5 @@ public:
explicit OutOfBlockBoundsException(XBlock* block);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -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.";
}

View File

@ -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;
};

View File

@ -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";
}

View File

@ -7,5 +7,5 @@ public:
UnexpectedEndOfFileException();
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -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.";
}

View File

@ -9,5 +9,5 @@ public:
explicit UnsupportedAssetTypeException(int assetType);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <cstddef>
class ILoadingStream
{

View File

@ -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;
}

View File

@ -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;

View File

@ -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");
}
}

View File

@ -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;

View File

@ -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;

View File

@ -1,5 +1,7 @@
#pragma once
#include <cstdint>
#include <cstddef>
class IXChunkProcessor
{

View File

@ -1,6 +1,7 @@
#include "StepVerifyHash.h"
#include <memory>
#include <cstring>
#include "Loading/Exception/InvalidHashException.h"

View File

@ -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(&currentCharacter, sizeof(char));

View File

@ -5,6 +5,7 @@
class StepVerifyMagic final : public ILoadingStep
{
const char* m_magic;
size_t m_magic_len;
public:
explicit StepVerifyMagic(const char* magic);

View File

@ -1,4 +1,5 @@
#pragma once
#include "ILoadingStream.h"
class StreamProcessor : public ILoadingStream

View File

@ -1,7 +1,9 @@
#pragma once
#include "Zone/Stream/IZoneStream.h"
#include <cstdint>
#include <cstddef>
#include "Zone/Stream/IZoneStream.h"
class IZoneInputStream : public IZoneStream
{

View File

@ -1,9 +1,11 @@
#include "XBlockInputStream.h"
#include <cassert>
#include <cstring>
#include "Loading/Exception/BlockOverflowException.h"
#include "Loading/Exception/InvalidOffsetBlockException.h"
#include "Loading/Exception/InvalidOffsetBlockOffsetException.h"
#include <cassert>
#include "Loading/Exception/OutOfBlockBoundsException.h"
XBlockInputStream::XBlockInputStream(std::vector<XBlock*>& blocks, ILoadingStream* stream, const int blockBitCount,