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,6 +1,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <cstddef>
#include "DxgiFormat.h" #include "DxgiFormat.h"
enum class ImageFormatId enum class ImageFormatId

View File

@ -1,6 +1,8 @@
#include "Texture.h" #include "Texture.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstring>
// ============================================== // ==============================================
// ================= Texture ==================== // ================= Texture ====================

View File

@ -56,7 +56,7 @@ void TextureConverter::SetPixelFunctions(const unsigned inBitCount, const unsign
assert(false); assert(false);
m_read_pixel_func = [](const void* offset, unsigned bitCount) m_read_pixel_func = [](const void* offset, unsigned bitCount)
{ {
return 0ui64; return 0ull;
}; };
} }
break; break;

View File

@ -60,15 +60,15 @@ long Wrapper_Zlib_FileSeekRead(voidpf opaque, voidpf stream, const uLong offset,
switch (origin) switch (origin)
{ {
case ZLIB_FILEFUNC_SEEK_CUR: case ZLIB_FILEFUNC_SEEK_CUR:
file->seekg(offset, SEEK_CUR); file->seekg(offset, std::ios_base::cur);
break; break;
case ZLIB_FILEFUNC_SEEK_END: case ZLIB_FILEFUNC_SEEK_END:
file->seekg(offset, SEEK_END); file->seekg(offset, std::ios_base::end);
break; break;
case ZLIB_FILEFUNC_SEEK_SET: case ZLIB_FILEFUNC_SEEK_SET:
file->seekg(offset, SEEK_SET); file->seekg(offset, std::ios_base::beg);
break; break;
default: default:
@ -86,15 +86,15 @@ long Wrapper_Zlib_FileSeekWrite(voidpf opaque, voidpf stream, const uLong offset
switch (origin) switch (origin)
{ {
case ZLIB_FILEFUNC_SEEK_CUR: case ZLIB_FILEFUNC_SEEK_CUR:
file->seekp(offset, SEEK_CUR); file->seekp(offset, std::ios_base::cur);
break; break;
case ZLIB_FILEFUNC_SEEK_END: case ZLIB_FILEFUNC_SEEK_END:
file->seekp(offset, SEEK_END); file->seekp(offset, std::ios_base::end);
break; break;
case ZLIB_FILEFUNC_SEEK_SET: case ZLIB_FILEFUNC_SEEK_SET:
file->seekp(offset, SEEK_SET); file->seekp(offset, std::ios_base::beg);
break; break;
default: default:

View File

@ -2,6 +2,7 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <cstring>
const std::string InfoString::EMPTY_VALUE; const std::string InfoString::EMPTY_VALUE;
@ -146,7 +147,7 @@ void InfoStringFromStructConverterBase::FillFromStringBuffer(const std::string&
const size_t bufferSize) const size_t bufferSize)
{ {
const auto* str = reinterpret_cast<const char*>(reinterpret_cast<uintptr_t>(m_structure) + offset); const auto* str = reinterpret_cast<const char*>(reinterpret_cast<uintptr_t>(m_structure) + offset);
const auto strLen = strnlen_s(str, bufferSize); const auto strLen = strnlen(str, bufferSize);
m_info_string.SetValueForKey(key, std::string(str, strLen)); m_info_string.SetValueForKey(key, std::string(str, strLen));
} }

View File

@ -3,12 +3,12 @@
#pragma once #pragma once
#include <cassert> #include <cassert>
#include "Utils/ClassUtils.h"
#include <streambuf> #include <streambuf>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include "Utils/ClassUtils.h"
template <class Elem, class Traits> template <class Elem, class Traits>
class basic_objbuf : public std::basic_streambuf<Elem, Traits> class basic_objbuf : public std::basic_streambuf<Elem, Traits>
{ {
@ -50,7 +50,7 @@ public:
void swap(basic_objstream& right) noexcept void swap(basic_objstream& right) noexcept
{ {
if (this != _STD addressof(right)) if (this != std::addressof(right))
{ {
mybase::swap(right); mybase::swap(right);
m_ob = std::move(right.m_ob); m_ob = std::move(right.m_ob);
@ -115,7 +115,7 @@ public:
void swap(basic_iobjstream& right) noexcept void swap(basic_iobjstream& right) noexcept
{ {
if (this != _STD addressof(right)) if (this != std::addressof(right))
{ {
mybase::swap(right); mybase::swap(right);
m_ob = std::move(right.m_ob); m_ob = std::move(right.m_ob);
@ -180,7 +180,7 @@ public:
void swap(basic_oobjstream& right) noexcept void swap(basic_oobjstream& right) noexcept
{ {
if (this != _STD addressof(right)) if (this != std::addressof(right))
{ {
mybase::swap(right); mybase::swap(right);
m_ob = std::move(right.m_ob); m_ob = std::move(right.m_ob);

View File

@ -1,6 +1,9 @@
#include "IwiLoader.h" #include "IwiLoader.h"
#include "Image/IwiTypes.h"
#include <cassert> #include <cassert>
#include <type_traits>
#include "Image/IwiTypes.h"
IwiLoader::IwiLoader(MemoryManager* memoryManager) IwiLoader::IwiLoader(MemoryManager* memoryManager)
{ {
@ -56,8 +59,8 @@ Texture* IwiLoader::LoadIwi8(std::istream& stream) const
{ {
iwi8::IwiHeader header{}; iwi8::IwiHeader header{};
stream.read(reinterpret_cast<char*>(&header), sizeof header); stream.read(reinterpret_cast<char*>(&header), sizeof(header));
if (stream.gcount() != sizeof header) if (stream.gcount() != sizeof(header))
return nullptr; return nullptr;
const auto* format = GetFormat8(header.format); const auto* format = GetFormat8(header.format);
@ -95,7 +98,7 @@ Texture* IwiLoader::LoadIwi8(std::istream& stream) const
texture->Allocate(); texture->Allocate();
auto currentFileSize = sizeof iwi8::IwiHeader + sizeof IwiVersion; auto currentFileSize = sizeof(iwi8::IwiHeader) + sizeof(IwiVersion);
const auto mipMapCount = hasMipMaps ? texture->GetMipMapCount() : 1; const auto mipMapCount = hasMipMaps ? texture->GetMipMapCount() : 1;
for (auto currentMipLevel = mipMapCount - 1; currentMipLevel >= 0; currentMipLevel--) for (auto currentMipLevel = mipMapCount - 1; currentMipLevel >= 0; currentMipLevel--)
@ -103,7 +106,7 @@ Texture* IwiLoader::LoadIwi8(std::istream& stream) const
const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount(); const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
currentFileSize += sizeOfMipLevel; currentFileSize += sizeOfMipLevel;
if (currentMipLevel < static_cast<int>(_countof(iwi8::IwiHeader::fileSizeForPicmip)) if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi8::IwiHeader::fileSizeForPicmip)>::value)
&& currentFileSize != header.fileSizeForPicmip[currentMipLevel]) && currentFileSize != header.fileSizeForPicmip[currentMipLevel])
{ {
printf("Iwi has invalid file size for picmip %i\n", currentMipLevel); printf("Iwi has invalid file size for picmip %i\n", currentMipLevel);
@ -173,8 +176,8 @@ Texture* IwiLoader::LoadIwi27(std::istream& stream) const
{ {
iwi27::IwiHeader header{}; iwi27::IwiHeader header{};
stream.read(reinterpret_cast<char*>(&header), sizeof header); stream.read(reinterpret_cast<char*>(&header), sizeof(header));
if (stream.gcount() != sizeof header) if (stream.gcount() != sizeof(header))
return nullptr; return nullptr;
const auto* format = GetFormat27(header.format); const auto* format = GetFormat27(header.format);
@ -202,7 +205,7 @@ Texture* IwiLoader::LoadIwi27(std::istream& stream) const
texture->Allocate(); texture->Allocate();
auto currentFileSize = sizeof iwi27::IwiHeader + sizeof IwiVersion; auto currentFileSize = sizeof(iwi27::IwiHeader) + sizeof(IwiVersion);
const auto mipMapCount = hasMipMaps ? texture->GetMipMapCount() : 1; const auto mipMapCount = hasMipMaps ? texture->GetMipMapCount() : 1;
for (auto currentMipLevel = mipMapCount - 1; currentMipLevel >= 0; currentMipLevel--) for (auto currentMipLevel = mipMapCount - 1; currentMipLevel >= 0; currentMipLevel--)
@ -210,7 +213,7 @@ Texture* IwiLoader::LoadIwi27(std::istream& stream) const
const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount(); const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
currentFileSize += sizeOfMipLevel; currentFileSize += sizeOfMipLevel;
if (currentMipLevel < static_cast<int>(_countof(iwi27::IwiHeader::fileSizeForPicmip)) if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi27::IwiHeader::fileSizeForPicmip)>::value)
&& currentFileSize != header.fileSizeForPicmip[currentMipLevel]) && currentFileSize != header.fileSizeForPicmip[currentMipLevel])
{ {
printf("Iwi has invalid file size for picmip %i\n", currentMipLevel); printf("Iwi has invalid file size for picmip %i\n", currentMipLevel);
@ -236,8 +239,8 @@ Texture* IwiLoader::LoadIwi(std::istream& stream)
{ {
IwiVersion iwiVersion{}; IwiVersion iwiVersion{};
stream.read(reinterpret_cast<char*>(&iwiVersion), sizeof iwiVersion); stream.read(reinterpret_cast<char*>(&iwiVersion), sizeof(iwiVersion));
if (stream.gcount() != sizeof iwiVersion) if (stream.gcount() != sizeof(iwiVersion))
return nullptr; return nullptr;
if (iwiVersion.tag[0] != 'I' if (iwiVersion.tag[0] != 'I'

View File

@ -10,7 +10,7 @@ const std::string& IPakLoadException::DetailedMessage() const
return m_message; return m_message;
} }
char const* IPakLoadException::what() const char const* IPakLoadException::what() const noexcept
{ {
return "There was an error when trying to load an ipak file."; return "There was an error when trying to load an ipak file.";
} }

View File

@ -10,5 +10,5 @@ public:
explicit IPakLoadException(std::string message); explicit IPakLoadException(std::string message);
const std::string& DetailedMessage() const; const std::string& DetailedMessage() const;
char const* what() const override; char const* what() const noexcept override;
}; };

View File

@ -1,6 +1,7 @@
#include "IPakEntryReadStream.h" #include "IPakEntryReadStream.h"
#include <cassert> #include <cassert>
#include <cstring>
#include <minilzo.h> #include <minilzo.h>
@ -72,8 +73,8 @@ bool IPakEntryReadStream::SetChunkBufferWindow(const int64_t startPos, size_t ch
if (m_buffer_start_pos != startPos) if (m_buffer_start_pos != startPos)
{ {
const auto moveEnd = endPos < m_buffer_end_pos ? endPos : m_buffer_end_pos; const auto moveEnd = endPos < m_buffer_end_pos ? endPos : m_buffer_end_pos;
memmove_s(m_chunk_buffer, IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ, &m_chunk_buffer[startPos - m_buffer_start_pos], assert(IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ >= static_cast<size_t>(moveEnd - startPos));
static_cast<size_t>(moveEnd - startPos)); memmove(m_chunk_buffer, &m_chunk_buffer[startPos - m_buffer_start_pos], static_cast<size_t>(moveEnd - startPos));
m_buffer_start_pos = startPos; m_buffer_start_pos = startPos;
} }
@ -93,10 +94,8 @@ bool IPakEntryReadStream::SetChunkBufferWindow(const int64_t startPos, size_t ch
if (endPos > m_buffer_start_pos && endPos <= m_buffer_end_pos) if (endPos > m_buffer_start_pos && endPos <= m_buffer_end_pos)
{ {
memmove_s(&m_chunk_buffer[m_buffer_start_pos - startPos], assert(IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ - static_cast<size_t>(m_buffer_start_pos - startPos) >= static_cast<size_t>(endPos - m_buffer_start_pos));
IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ - static_cast<size_t>(m_buffer_start_pos - startPos), memmove(&m_chunk_buffer[m_buffer_start_pos - startPos], m_chunk_buffer, static_cast<size_t>(endPos - m_buffer_start_pos));
m_chunk_buffer,
static_cast<size_t>(endPos - m_buffer_start_pos));
const auto readChunkCount = ReadChunks(m_chunk_buffer, const auto readChunkCount = ReadChunks(m_chunk_buffer,
startPos, startPos,
@ -151,8 +150,7 @@ bool IPakEntryReadStream::AdjustChunkBufferWindowForBlockHeader(IPakDataBlockHea
commandsSize += blockHeader->_commands[commandIndex].size; commandsSize += blockHeader->_commands[commandIndex].size;
} }
const size_t requiredChunkCount = AlignForward<size_t>( const size_t requiredChunkCount = AlignForward<size_t>(blockOffsetInChunk + sizeof(IPakDataBlockHeader) + commandsSize, IPAK_CHUNK_SIZE) / IPAK_CHUNK_SIZE;
blockOffsetInChunk + sizeof IPakDataBlockHeader + commandsSize, IPAK_CHUNK_SIZE) / IPAK_CHUNK_SIZE;
const size_t amountOfReadChunks = static_cast<size_t>(m_buffer_end_pos - m_buffer_start_pos) / IPAK_CHUNK_SIZE; const size_t amountOfReadChunks = static_cast<size_t>(m_buffer_end_pos - m_buffer_start_pos) / IPAK_CHUNK_SIZE;
@ -177,7 +175,7 @@ bool IPakEntryReadStream::NextBlock()
if (m_pos >= m_end_pos) if (m_pos >= m_end_pos)
return false; return false;
m_pos = AlignForward<int64_t>(m_pos, sizeof IPakDataBlockHeader); m_pos = AlignForward<int64_t>(m_pos, sizeof(IPakDataBlockHeader));
const auto chunkStartPos = AlignBackwards<int64_t>(m_pos, IPAK_CHUNK_SIZE); const auto chunkStartPos = AlignBackwards<int64_t>(m_pos, IPAK_CHUNK_SIZE);
const auto blockOffsetInChunk = static_cast<size_t>(m_pos - chunkStartPos); const auto blockOffsetInChunk = static_cast<size_t>(m_pos - chunkStartPos);
@ -200,7 +198,7 @@ bool IPakEntryReadStream::NextBlock()
if (!AdjustChunkBufferWindowForBlockHeader(m_current_block, blockOffsetInChunk)) if (!AdjustChunkBufferWindowForBlockHeader(m_current_block, blockOffsetInChunk))
return false; return false;
m_pos += sizeof IPakDataBlockHeader; m_pos += sizeof(IPakDataBlockHeader);
m_next_command = 0; m_next_command = 0;
return true; return true;
@ -212,7 +210,7 @@ bool IPakEntryReadStream::ProcessCommand(const size_t commandSize, const int com
{ {
if (compressed == 1) if (compressed == 1)
{ {
lzo_uint outputSize = sizeof m_decompress_buffer; lzo_uint outputSize = sizeof(m_decompress_buffer);
const auto result = lzo1x_decompress_safe(&m_chunk_buffer[m_pos - m_buffer_start_pos], commandSize, const auto result = lzo1x_decompress_safe(&m_chunk_buffer[m_pos - m_buffer_start_pos], commandSize,
m_decompress_buffer, &outputSize, nullptr); m_decompress_buffer, &outputSize, nullptr);
@ -336,8 +334,8 @@ std::streamsize IPakEntryReadStream::xsgetn(char* ptr, const std::streamsize cou
if (sizeToRead > 0) if (sizeToRead > 0)
{ {
memcpy_s(&destBuffer[countRead], static_cast<rsize_t>(count - countRead), assert(static_cast<size_t>(count - countRead) >= static_cast<size_t>(sizeToRead));
&m_current_command_buffer[m_current_command_offset], static_cast<rsize_t>(sizeToRead)); memcpy(&destBuffer[countRead], &m_current_command_buffer[m_current_command_offset], static_cast<size_t>(sizeToRead));
countRead += sizeToRead; countRead += sizeToRead;
m_current_command_offset += sizeToRead; m_current_command_offset += sizeToRead;
m_file_offset += sizeToRead; m_file_offset += sizeToRead;

View File

@ -16,24 +16,24 @@ std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfo<L
void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, std::ostream& stream) void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, std::ostream& stream)
{ {
const auto riffMasterChunkSize = sizeof WAV_CHUNK_ID_RIFF const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF)
+ sizeof uint32_t + sizeof(uint32_t)
+ sizeof WAV_WAVE_ID + sizeof(WAV_WAVE_ID)
+ sizeof WavChunkHeader + sizeof(WavChunkHeader)
+ sizeof WavFormatChunkPcm + sizeof(WavFormatChunkPcm)
+ sizeof WavChunkHeader + sizeof(WavChunkHeader)
+ sizeof asset->sound.info.data_len; + sizeof(asset->sound.info.data_len);
stream.write(reinterpret_cast<const char*>(&WAV_CHUNK_ID_RIFF), sizeof WAV_CHUNK_ID_RIFF); stream.write(reinterpret_cast<const char*>(&WAV_CHUNK_ID_RIFF), sizeof(WAV_CHUNK_ID_RIFF));
stream.write(reinterpret_cast<const char*>(&riffMasterChunkSize), sizeof riffMasterChunkSize); stream.write(reinterpret_cast<const char*>(&riffMasterChunkSize), sizeof(riffMasterChunkSize));
stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof WAV_WAVE_ID); stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof(WAV_WAVE_ID));
const WavChunkHeader formatChunkHeader const WavChunkHeader formatChunkHeader
{ {
WAV_CHUNK_ID_FMT, WAV_CHUNK_ID_FMT,
sizeof WavFormatChunkPcm sizeof(WavFormatChunkPcm)
}; };
stream.write(reinterpret_cast<const char*>(&formatChunkHeader), sizeof formatChunkHeader); stream.write(reinterpret_cast<const char*>(&formatChunkHeader), sizeof(formatChunkHeader));
WavFormatChunkPcm formatChunk WavFormatChunkPcm formatChunk
{ {
@ -44,14 +44,14 @@ void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, st
static_cast<uint16_t>(asset->sound.info.block_size), static_cast<uint16_t>(asset->sound.info.block_size),
static_cast<uint16_t>(asset->sound.info.bits) static_cast<uint16_t>(asset->sound.info.bits)
}; };
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof formatChunk); stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
const WavChunkHeader dataChunkHeader const WavChunkHeader dataChunkHeader
{ {
WAV_CHUNK_ID_DATA, WAV_CHUNK_ID_DATA,
asset->sound.info.data_len asset->sound.info.data_len
}; };
stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof dataChunkHeader); stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
stream.write(asset->sound.data, asset->sound.info.data_len); stream.write(asset->sound.data, asset->sound.info.data_len);
} }

View File

@ -1,6 +1,7 @@
#include "AssetDumperRawFile.h" #include "AssetDumperRawFile.h"
#include <zlib.h> #include <zlib.h>
#include <stdexcept>
using namespace IW4; using namespace IW4;
@ -31,7 +32,7 @@ void AssetDumperRawFile::DumpAsset(Zone* zone, XAssetInfo<RawFile>* asset, std::
if (ret != Z_OK) if (ret != Z_OK)
{ {
throw std::exception("Initializing inflate failed"); throw std::runtime_error("Initializing inflate failed");
} }
zs.next_in = reinterpret_cast<const Bytef*>(rawFile->data.compressedBuffer); zs.next_in = reinterpret_cast<const Bytef*>(rawFile->data.compressedBuffer);

View File

@ -2,6 +2,7 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <type_traits>
#include "Game/IW4/InfoStringIW4.h" #include "Game/IW4/InfoStringIW4.h"
@ -182,13 +183,13 @@ namespace IW4
switch (static_cast<VehicleFieldType>(field.iFieldType)) switch (static_cast<VehicleFieldType>(field.iFieldType))
{ {
case VFT_TYPE: case VFT_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleClassNames, _countof(s_vehicleClassNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleClassNames, std::extent<decltype(s_vehicleClassNames)>::value);
break; break;
case VFT_AXLE_STEERING: case VFT_AXLE_STEERING:
case VFT_AXLE_POWER: case VFT_AXLE_POWER:
case VFT_AXLE_BRAKING: case VFT_AXLE_BRAKING:
FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleAxleTypeNames, _countof(s_vehicleAxleTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleAxleTypeNames, std::extent<decltype(s_vehicleAxleTypeNames)>::value);
break; break;
case VFT_TROPHY_TAGS: case VFT_TROPHY_TAGS:
@ -197,7 +198,7 @@ namespace IW4
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < _countof(VehicleDef::trophyTags); i++) for (auto i = 0u; i < std::extent<decltype(VehicleDef::trophyTags)>::value; i++)
{ {
const auto& str = m_get_scr_string(trophyTags[i]); const auto& str = m_get_scr_string(trophyTags[i]);
if (!str.empty()) if (!str.empty())
@ -242,7 +243,7 @@ std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo<Vehic
void AssetDumperVehicle::DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream) void AssetDumperVehicle::DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
{ {
InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, _countof(vehicle_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent<decltype(vehicle_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -1,7 +1,9 @@
#include "AssetDumperWeapon.h" #include "AssetDumperWeapon.h"
#include <cassert> #include <cassert>
#include <cstring>
#include <sstream> #include <sstream>
#include <type_traits>
#include "Game/IW4/InfoStringIW4.h" #include "Game/IW4/InfoStringIW4.h"
@ -866,47 +868,47 @@ namespace IW4
switch (static_cast<weapFieldType_t>(field.iFieldType)) switch (static_cast<weapFieldType_t>(field.iFieldType))
{ {
case WFT_WEAPONTYPE: case WFT_WEAPONTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, _countof(szWeapTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, std::extent<decltype(szWeapTypeNames)>::value);
break; break;
case WFT_WEAPONCLASS: case WFT_WEAPONCLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, _countof(szWeapClassNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, std::extent<decltype(szWeapClassNames)>::value);
break; break;
case WFT_OVERLAYRETICLE: case WFT_OVERLAYRETICLE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, _countof(szWeapOverlayReticleNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent<decltype(szWeapOverlayReticleNames)>::value);
break; break;
case WFT_PENETRATE_TYPE: case WFT_PENETRATE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, _countof(penetrateTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent<decltype(penetrateTypeNames)>::value);
break; break;
case WFT_IMPACT_TYPE: case WFT_IMPACT_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, _countof(impactTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, std::extent<decltype(impactTypeNames)>::value);
break; break;
case WFT_STANCE: case WFT_STANCE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, _countof(szWeapStanceNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, std::extent<decltype(szWeapStanceNames)>::value);
break; break;
case WFT_PROJ_EXPLOSION: case WFT_PROJ_EXPLOSION:
FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, _countof(szProjectileExplosionNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, std::extent<decltype(szProjectileExplosionNames)>::value);
break; break;
case WFT_OFFHAND_CLASS: case WFT_OFFHAND_CLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, _countof(offhandClassNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, std::extent<decltype(offhandClassNames)>::value);
break; break;
case WFT_ANIMTYPE: case WFT_ANIMTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, _countof(playerAnimTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, std::extent<decltype(playerAnimTypeNames)>::value);
break; break;
case WFT_ACTIVE_RETICLE_TYPE: case WFT_ACTIVE_RETICLE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, _countof(activeReticleNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, std::extent<decltype(activeReticleNames)>::value);
break; break;
case WFT_GUIDED_MISSILE_TYPE: case WFT_GUIDED_MISSILE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, _countof(guidedMissileNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, std::extent<decltype(guidedMissileNames)>::value);
break; break;
case WFT_BOUNCE_SOUND: case WFT_BOUNCE_SOUND:
@ -934,23 +936,23 @@ namespace IW4
} }
case WFT_STICKINESS: case WFT_STICKINESS:
FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, _countof(stickinessNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, std::extent<decltype(stickinessNames)>::value);
break; break;
case WFT_OVERLAYINTERFACE: case WFT_OVERLAYINTERFACE:
FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, _countof(overlayInterfaceNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, std::extent<decltype(overlayInterfaceNames)>::value);
break; break;
case WFT_INVENTORYTYPE: case WFT_INVENTORYTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, _countof(szWeapInventoryTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, std::extent<decltype(szWeapInventoryTypeNames)>::value);
break; break;
case WFT_FIRETYPE: case WFT_FIRETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, _countof(szWeapFireTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent<decltype(szWeapFireTypeNames)>::value);
break; break;
case WFT_AMMOCOUNTER_CLIPTYPE: case WFT_AMMOCOUNTER_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, _countof(ammoCounterClipNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, std::extent<decltype(ammoCounterClipNames)>::value);
break; break;
case WFT_ICONRATIO_HUD: case WFT_ICONRATIO_HUD:
@ -958,7 +960,7 @@ namespace IW4
case WFT_ICONRATIO_AMMOCOUNTER: case WFT_ICONRATIO_AMMOCOUNTER:
case WFT_ICONRATIO_KILL: case WFT_ICONRATIO_KILL:
case WFT_ICONRATIO_DPAD: case WFT_ICONRATIO_DPAD:
FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames, _countof(weapIconRatioNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames, std::extent<decltype(weapIconRatioNames)>::value);
break; break;
case WFT_HIDETAGS: case WFT_HIDETAGS:
@ -967,7 +969,7 @@ namespace IW4
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < _countof(WeaponFullDef::hideTags); i++) for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::hideTags)>::value; i++)
{ {
const auto& str = m_get_scr_string(hideTags[i]); const auto& str = m_get_scr_string(hideTags[i]);
if (!str.empty()) if (!str.empty())
@ -988,11 +990,11 @@ namespace IW4
case WFT_NOTETRACKSOUNDMAP: case WFT_NOTETRACKSOUNDMAP:
{ {
const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
const auto* values = &keys[_countof(WeaponFullDef::notetrackSoundMapKeys)]; const auto* values = &keys[std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value];
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++) for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value; i++)
{ {
const auto& key = m_get_scr_string(keys[i]); const auto& key = m_get_scr_string(keys[i]);
const auto& value = m_get_scr_string(values[i]); const auto& value = m_get_scr_string(values[i]);
@ -1017,11 +1019,11 @@ namespace IW4
case WFT_NOTETRACKRUMBLEMAP: case WFT_NOTETRACKRUMBLEMAP:
{ {
const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
const auto* values = &keys[_countof(WeaponFullDef::notetrackRumbleMapKeys)]; const auto* values = &keys[std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value];
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < _countof(WeaponFullDef::notetrackRumbleMapKeys); i++) for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value; i++)
{ {
const auto& key = m_get_scr_string(keys[i]); const auto& key = m_get_scr_string(keys[i]);
const auto& value = m_get_scr_string(values[i]); const auto& value = m_get_scr_string(values[i]);
@ -1070,84 +1072,92 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul
if (weapon->hideTags) if (weapon->hideTags)
{ {
memcpy_s(fullDef->hideTags, sizeof WeaponFullDef::hideTags, weapon->hideTags, sizeof(scr_string_t) * _countof(WeaponFullDef::hideTags)); assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value);
memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value);
fullDef->weapCompleteDef.hideTags = fullDef->hideTags; fullDef->weapCompleteDef.hideTags = fullDef->hideTags;
} }
if (weapon->szXAnims) if (weapon->szXAnims)
{ {
memcpy_s(fullDef->szXAnims, sizeof WeaponFullDef::szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); assert(sizeof(WeaponFullDef::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS);
memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS);
fullDef->weapCompleteDef.szXAnims = fullDef->szXAnims; fullDef->weapCompleteDef.szXAnims = fullDef->szXAnims;
} }
if (fullDef->weapDef.gunXModel) if (fullDef->weapDef.gunXModel)
{ {
memcpy_s(fullDef->gunXModel, sizeof WeaponFullDef::gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * _countof(WeaponFullDef::gunXModel)); assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value);
memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value);
fullDef->weapDef.gunXModel = fullDef->gunXModel; fullDef->weapDef.gunXModel = fullDef->gunXModel;
} }
if (fullDef->weapDef.szXAnimsRightHanded) if (fullDef->weapDef.szXAnimsRightHanded)
{ {
memcpy_s(fullDef->szXAnimsRightHanded, sizeof WeaponFullDef::szXAnimsRightHanded, fullDef->weapDef.szXAnimsRightHanded, sizeof(void*) * NUM_WEAP_ANIMS); assert(sizeof(WeaponFullDef::szXAnimsRightHanded) >= sizeof(void*) * NUM_WEAP_ANIMS);
memcpy(fullDef->szXAnimsRightHanded, fullDef->weapDef.szXAnimsRightHanded, sizeof(void*) * NUM_WEAP_ANIMS);
fullDef->weapDef.szXAnimsRightHanded = fullDef->szXAnimsRightHanded; fullDef->weapDef.szXAnimsRightHanded = fullDef->szXAnimsRightHanded;
} }
if (fullDef->weapDef.szXAnimsLeftHanded) if (fullDef->weapDef.szXAnimsLeftHanded)
{ {
memcpy_s(fullDef->szXAnimsLeftHanded, sizeof WeaponFullDef::szXAnimsLeftHanded, fullDef->weapDef.szXAnimsLeftHanded, sizeof(void*) * NUM_WEAP_ANIMS); assert(sizeof(WeaponFullDef::szXAnimsLeftHanded) >= sizeof(void*) * NUM_WEAP_ANIMS);
memcpy(fullDef->szXAnimsLeftHanded, fullDef->weapDef.szXAnimsLeftHanded, sizeof(void*) * NUM_WEAP_ANIMS);
fullDef->weapDef.szXAnimsLeftHanded = fullDef->szXAnimsLeftHanded; fullDef->weapDef.szXAnimsLeftHanded = fullDef->szXAnimsLeftHanded;
} }
if (fullDef->weapDef.notetrackSoundMapKeys) if (fullDef->weapDef.notetrackSoundMapKeys)
{ {
memcpy_s(fullDef->notetrackSoundMapKeys, sizeof WeaponFullDef::notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapKeys)); memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys;
} }
if (fullDef->weapDef.notetrackSoundMapValues) if (fullDef->weapDef.notetrackSoundMapValues)
{ {
memcpy_s(fullDef->notetrackSoundMapValues, sizeof WeaponFullDef::notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapKeys)); memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues;
} }
if (fullDef->weapDef.notetrackRumbleMapKeys) if (fullDef->weapDef.notetrackRumbleMapKeys)
{ {
memcpy_s(fullDef->notetrackRumbleMapKeys, sizeof WeaponFullDef::notetrackRumbleMapKeys, fullDef->weapDef.notetrackRumbleMapKeys, assert(sizeof(WeaponFullDef::notetrackRumbleMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackRumbleMapKeys)); memcpy(fullDef->notetrackRumbleMapKeys, fullDef->weapDef.notetrackRumbleMapKeys, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys; fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys;
} }
if (fullDef->weapDef.notetrackRumbleMapValues) if (fullDef->weapDef.notetrackRumbleMapValues)
{ {
memcpy_s(fullDef->notetrackRumbleMapValues, sizeof WeaponFullDef::notetrackRumbleMapValues, fullDef->weapDef.notetrackRumbleMapValues, assert(sizeof(WeaponFullDef::notetrackRumbleMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackRumbleMapKeys)); memcpy(fullDef->notetrackRumbleMapValues, fullDef->weapDef.notetrackRumbleMapValues, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues; fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues;
} }
if (fullDef->weapDef.worldModel) if (fullDef->weapDef.worldModel)
{ {
memcpy_s(fullDef->worldModel, sizeof WeaponFullDef::worldModel, fullDef->weapDef.worldModel, sizeof(void*) * _countof(WeaponFullDef::worldModel)); assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value);
memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value);
fullDef->weapDef.worldModel = fullDef->worldModel; fullDef->weapDef.worldModel = fullDef->worldModel;
} }
if (fullDef->weapDef.parallelBounce) if (fullDef->weapDef.parallelBounce)
{ {
memcpy_s(fullDef->parallelBounce, sizeof WeaponFullDef::parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * _countof(WeaponFullDef::parallelBounce)); assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * std::extent<decltype(WeaponFullDef::parallelBounce)>::value);
memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent<decltype(WeaponFullDef::parallelBounce)>::value);
fullDef->weapDef.parallelBounce = fullDef->parallelBounce; fullDef->weapDef.parallelBounce = fullDef->parallelBounce;
} }
if (fullDef->weapDef.perpendicularBounce) if (fullDef->weapDef.perpendicularBounce)
{ {
memcpy_s(fullDef->perpendicularBounce, sizeof WeaponFullDef::perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * _countof(WeaponFullDef::perpendicularBounce)); assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * std::extent<decltype(WeaponFullDef::perpendicularBounce)>::value);
memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * std::extent<decltype(WeaponFullDef::perpendicularBounce)>::value);
fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce;
} }
if (fullDef->weapDef.locationDamageMultipliers) if (fullDef->weapDef.locationDamageMultipliers)
{ {
memcpy_s(fullDef->locationDamageMultipliers, sizeof WeaponFullDef::locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * std::extent<decltype(WeaponFullDef::locationDamageMultipliers)>::value);
sizeof(float) * _countof(WeaponFullDef::locationDamageMultipliers)); memcpy(fullDef->locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * std::extent<decltype(WeaponFullDef::locationDamageMultipliers)>::value);
fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers;
} }
} }
@ -1165,10 +1175,10 @@ std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo<Weapon
void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream) void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
{ {
auto* fullDef = new WeaponFullDef; auto* fullDef = new WeaponFullDef;
memset(fullDef, 0, sizeof WeaponFullDef); memset(fullDef, 0, sizeof(WeaponFullDef));
CopyToFullDef(asset->Asset(), fullDef); CopyToFullDef(asset->Asset(), fullDef);
InfoStringFromWeaponConverter converter(fullDef, weapon_fields, _countof(weapon_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -1,6 +1,7 @@
#include "AssetDumperPhysConstraints.h" #include "AssetDumperPhysConstraints.h"
#include <cassert> #include <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
@ -110,7 +111,7 @@ namespace T6
switch (static_cast<constraintsFieldType_t>(field.iFieldType)) switch (static_cast<constraintsFieldType_t>(field.iFieldType))
{ {
case CFT_TYPE: case CFT_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, s_constraintTypeNames, _countof(s_constraintTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, s_constraintTypeNames, std::extent<decltype(s_constraintTypeNames)>::value);
break; break;
case CFT_NUM: case CFT_NUM:
@ -142,7 +143,7 @@ void AssetDumperPhysConstraints::DumpAsset(Zone* zone, XAssetInfo<PhysConstraint
{ {
assert(asset->Asset()->count <= 4); assert(asset->Asset()->count <= 4);
InfoStringFromPhysConstraintsConverter converter(asset->Asset(), phys_constraints_fields, _countof(phys_constraints_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromPhysConstraintsConverter converter(asset->Asset(), phys_constraints_fields, std::extent<decltype(phys_constraints_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -3,6 +3,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
#include <type_traits>
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
@ -54,7 +55,7 @@ void AssetDumperPhysPreset::CopyToPhysPresetInfo(const PhysPreset* physPreset, P
physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f); physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f);
physPresetInfo->bounce = physPreset->bounce; physPresetInfo->bounce = physPreset->bounce;
if(isinf(physPreset->friction)) if(std::isinf(physPreset->friction))
{ {
physPresetInfo->isFrictionInfinity = 1; physPresetInfo->isFrictionInfinity = 1;
physPresetInfo->friction = 0; physPresetInfo->friction = 0;
@ -91,7 +92,7 @@ void AssetDumperPhysPreset::DumpAsset(Zone* zone, XAssetInfo<PhysPreset>* asset,
auto* physPresetInfo = new PhysPresetInfo; auto* physPresetInfo = new PhysPresetInfo;
CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); CopyToPhysPresetInfo(asset->Asset(), physPresetInfo);
InfoStringFromPhysPresetConverter converter(physPresetInfo, physpreset_fields, _countof(physpreset_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromPhysPresetConverter converter(physPresetInfo, physpreset_fields, std::extent<decltype(physpreset_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())
@ -109,9 +110,9 @@ void AssetDumperPhysPreset::DumpAsset(Zone* zone, XAssetInfo<PhysPreset>* asset,
//void AssetDumperPhysPreset::CheckFields() //void AssetDumperPhysPreset::CheckFields()
//{ //{
// assert(_countof(physpreset_fields) == _countof(fields222)); // assert(std::extent<decltype(physpreset_fields)>::value == std::extent<decltype(fields222)>::value);
// //
// for(auto i = 0u; i < _countof(physpreset_fields); i++) // for(auto i = 0u; i < std::extent<decltype(physpreset_fields)>::value; i++)
// { // {
// if(physpreset_fields[i].iOffset != fields222[i].iOffset) // if(physpreset_fields[i].iOffset != fields222[i].iOffset)
// { // {

View File

@ -1,6 +1,7 @@
#include "AssetDumperTracer.h" #include "AssetDumperTracer.h"
#include <cassert> #include <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
@ -57,7 +58,7 @@ namespace T6
switch (static_cast<tracerFieldType_t>(field.iFieldType)) switch (static_cast<tracerFieldType_t>(field.iFieldType))
{ {
case TFT_TRACERTYPE: case TFT_TRACERTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, tracerTypeNames, _countof(tracerTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, tracerTypeNames, std::extent<decltype(tracerTypeNames)>::value);
break; break;
case TFT_NUM_FIELD_TYPES: case TFT_NUM_FIELD_TYPES:
@ -87,7 +88,7 @@ std::string AssetDumperTracer::GetFileNameForAsset(Zone* zone, XAssetInfo<Tracer
void AssetDumperTracer::DumpAsset(Zone* zone, XAssetInfo<TracerDef>* asset, std::ostream& stream) void AssetDumperTracer::DumpAsset(Zone* zone, XAssetInfo<TracerDef>* asset, std::ostream& stream)
{ {
InfoStringFromTracerConverter converter(asset->Asset(), tracer_fields, _countof(tracer_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromTracerConverter converter(asset->Asset(), tracer_fields, std::extent<decltype(tracer_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())
@ -100,21 +101,3 @@ void AssetDumperTracer::DumpAsset(Zone* zone, XAssetInfo<TracerDef>* asset, std:
const auto stringValue = infoString.ToString("TRACER"); const auto stringValue = infoString.ToString("TRACER");
stream.write(stringValue.c_str(), stringValue.size()); stream.write(stringValue.c_str(), stringValue.size());
} }
//void AssetDumperTracer::CheckFields()
//{
// assert(_countof(tracer_fields) == _countof(fields222));
//
// for(auto i = 0u; i < _countof(tracer_fields); i++)
// {
// if(tracer_fields[i].iOffset != fields222[i].iOffset)
// {
// std::string error = "Error in field: " + std::string(tracer_fields[i].szName);
// MessageBoxA(NULL, error.c_str(), "", 0);
// exit(0);
// }
// }
//
// MessageBoxA(NULL, "No error", "", 0);
// exit(0);
//}

View File

@ -1,6 +1,7 @@
#include "AssetDumperVehicle.h" #include "AssetDumperVehicle.h"
#include <cassert> #include <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
@ -606,15 +607,15 @@ namespace T6
switch (static_cast<VehicleFieldType>(field.iFieldType)) switch (static_cast<VehicleFieldType>(field.iFieldType))
{ {
case VFT_TYPE: case VFT_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleClassNames, _countof(s_vehicleClassNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleClassNames, std::extent<decltype(s_vehicleClassNames)>::value);
break; break;
case VFT_CAMERAMODE: case VFT_CAMERAMODE:
FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleCameraModes, _countof(s_vehicleCameraModes)); FillFromEnumInt(std::string(field.szName), field.iOffset, s_vehicleCameraModes, std::extent<decltype(s_vehicleCameraModes)>::value);
break; break;
case VFT_TRACTION_TYPE: case VFT_TRACTION_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, s_tractionTypeNames, _countof(s_tractionTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, s_tractionTypeNames, std::extent<decltype(s_tractionTypeNames)>::value);
break; break;
case VFT_MPH_TO_INCHES_PER_SECOND: case VFT_MPH_TO_INCHES_PER_SECOND:
@ -682,7 +683,7 @@ std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo<Vehic
void AssetDumperVehicle::DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream) void AssetDumperVehicle::DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
{ {
InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, _countof(vehicle_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent<decltype(vehicle_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -2,6 +2,8 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <type_traits>
#include <cstring>
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
@ -1293,58 +1295,56 @@ namespace T6
switch (static_cast<weapFieldType_t>(field.iFieldType)) switch (static_cast<weapFieldType_t>(field.iFieldType))
{ {
case WFT_WEAPONTYPE: case WFT_WEAPONTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, _countof(szWeapTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, std::extent<decltype(szWeapTypeNames)>::value);
break; break;
case WFT_WEAPONCLASS: case WFT_WEAPONCLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, _countof(szWeapClassNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, std::extent<decltype(szWeapClassNames)>::value);
break; break;
case WFT_OVERLAYRETICLE: case WFT_OVERLAYRETICLE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent<decltype(szWeapOverlayReticleNames)>::value);
_countof(szWeapOverlayReticleNames));
break; break;
case WFT_PENETRATE_TYPE: case WFT_PENETRATE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent<decltype(penetrateTypeNames)>::value);
_countof(penetrateTypeNames));
break; break;
case WFT_IMPACT_TYPE: case WFT_IMPACT_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, _countof(impactTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, std::extent<decltype(impactTypeNames)>::value);
break; break;
case WFT_STANCE: case WFT_STANCE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames,
_countof(szWeapStanceNames)); std::extent<decltype(szWeapStanceNames)>::value);
break; break;
case WFT_PROJ_EXPLOSION: case WFT_PROJ_EXPLOSION:
FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames,
_countof(szProjectileExplosionNames)); std::extent<decltype(szProjectileExplosionNames)>::value);
break; break;
case WFT_OFFHAND_CLASS: case WFT_OFFHAND_CLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames,
_countof(offhandClassNames)); std::extent<decltype(offhandClassNames)>::value);
break; break;
case WFT_OFFHAND_SLOT: case WFT_OFFHAND_SLOT:
FillFromEnumInt(std::string(field.szName), field.iOffset, offhandSlotNames, _countof(offhandSlotNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, offhandSlotNames, std::extent<decltype(offhandSlotNames)>::value);
break; break;
case WFT_ANIMTYPE: case WFT_ANIMTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames,
_countof(playerAnimTypeNames)); std::extent<decltype(playerAnimTypeNames)>::value);
break; break;
case WFT_ACTIVE_RETICLE_TYPE: case WFT_ACTIVE_RETICLE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames,
_countof(activeReticleNames)); std::extent<decltype(activeReticleNames)>::value);
break; break;
case WFT_GUIDED_MISSILE_TYPE: case WFT_GUIDED_MISSILE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames,
_countof(guidedMissileNames)); std::extent<decltype(guidedMissileNames)>::value);
break; break;
case WFT_BOUNCE_SOUND: case WFT_BOUNCE_SOUND:
@ -1373,36 +1373,36 @@ namespace T6
} }
case WFT_STICKINESS: case WFT_STICKINESS:
FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, _countof(stickinessNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, std::extent<decltype(stickinessNames)>::value);
break; break;
case WFT_ROTATETYPE: case WFT_ROTATETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, rotateTypeNames, _countof(rotateTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, rotateTypeNames, std::extent<decltype(rotateTypeNames)>::value);
break; break;
case WFT_OVERLAYINTERFACE: case WFT_OVERLAYINTERFACE:
FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames,
_countof(overlayInterfaceNames)); std::extent<decltype(overlayInterfaceNames)>::value);
break; break;
case WFT_INVENTORYTYPE: case WFT_INVENTORYTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames,
_countof(szWeapInventoryTypeNames)); std::extent<decltype(szWeapInventoryTypeNames)>::value);
break; break;
case WFT_FIRETYPE: case WFT_FIRETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames,
_countof(szWeapFireTypeNames)); std::extent<decltype(szWeapFireTypeNames)>::value);
break; break;
case WFT_CLIPTYPE: case WFT_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames, FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames,
_countof(szWeapClipTypeNames)); std::extent<decltype(szWeapClipTypeNames)>::value);
break; break;
case WFT_AMMOCOUNTER_CLIPTYPE: case WFT_AMMOCOUNTER_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames,
_countof(ammoCounterClipNames)); std::extent<decltype(ammoCounterClipNames)>::value);
break; break;
case WFT_ICONRATIO_HUD: case WFT_ICONRATIO_HUD:
@ -1411,11 +1411,11 @@ namespace T6
case WFT_ICONRATIO_DPAD: case WFT_ICONRATIO_DPAD:
case WFT_ICONRATIO_INDICATOR: case WFT_ICONRATIO_INDICATOR:
FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames, FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames,
_countof(weapIconRatioNames)); std::extent<decltype(weapIconRatioNames)>::value);
break; break;
case WFT_BARRELTYPE: case WFT_BARRELTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, barrelTypeNames, _countof(barrelTypeNames)); FillFromEnumInt(std::string(field.szName), field.iOffset, barrelTypeNames, std::extent<decltype(barrelTypeNames)>::value);
break; break;
case WFT_HIDETAGS: case WFT_HIDETAGS:
@ -1424,7 +1424,7 @@ namespace T6
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < _countof(WeaponFullDef::hideTags); i++) for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::hideTags)>::value; i++)
{ {
const auto& str = m_get_scr_string(hideTags[i]); const auto& str = m_get_scr_string(hideTags[i]);
if (!str.empty()) if (!str.empty())
@ -1449,11 +1449,11 @@ namespace T6
case WFT_NOTETRACKSOUNDMAP: case WFT_NOTETRACKSOUNDMAP:
{ {
const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
const auto* values = &keys[_countof(WeaponFullDef::notetrackSoundMapKeys)]; const auto* values = &keys[std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value];
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++) for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value; i++)
{ {
const auto& key = m_get_scr_string(keys[i]); const auto& key = m_get_scr_string(keys[i]);
const auto& value = m_get_scr_string(values[i]); const auto& value = m_get_scr_string(values[i]);
@ -1514,99 +1514,112 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
if (weapon->attachments) if (weapon->attachments)
{ {
memcpy_s(fullDef->attachments, sizeof WeaponFullDef::attachments, weapon->attachments, sizeof(void*) * _countof(WeaponFullDef::attachments)); assert(sizeof(WeaponFullDef::attachments) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachments)>::value);
memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachments)>::value);
fullDef->weapVariantDef.attachments = fullDef->attachments; fullDef->weapVariantDef.attachments = fullDef->attachments;
} }
if (weapon->attachmentUniques) if (weapon->attachmentUniques)
{ {
memcpy_s(fullDef->attachmentUniques, sizeof WeaponFullDef::attachmentUniques, weapon->attachmentUniques, sizeof(void*) * _countof(WeaponFullDef::attachmentUniques)); assert(sizeof(WeaponFullDef::attachmentUniques) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachmentUniques)>::value);
memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachmentUniques)>::value);
fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques; fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques;
} }
if (fullDef->weapDef.gunXModel) if (fullDef->weapDef.gunXModel)
{ {
memcpy_s(fullDef->gunXModel, sizeof WeaponFullDef::gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * _countof(WeaponFullDef::gunXModel)); assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value);
memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value);
fullDef->weapDef.gunXModel = fullDef->gunXModel; fullDef->weapDef.gunXModel = fullDef->gunXModel;
} }
if (weapon->szXAnims) if (weapon->szXAnims)
{ {
memcpy_s(fullDef->szXAnims, sizeof WeaponFullDef::szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); assert(sizeof(WeaponFullDef::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS);
memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS);
fullDef->weapVariantDef.szXAnims = fullDef->szXAnims; fullDef->weapVariantDef.szXAnims = fullDef->szXAnims;
} }
if (weapon->hideTags) if (weapon->hideTags)
{ {
memcpy_s(fullDef->hideTags, sizeof WeaponFullDef::hideTags, weapon->hideTags, sizeof(scr_string_t) * _countof(WeaponFullDef::hideTags)); assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value);
memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value);
fullDef->weapVariantDef.hideTags = fullDef->hideTags; fullDef->weapVariantDef.hideTags = fullDef->hideTags;
} }
if (fullDef->weapDef.notetrackSoundMapKeys) if (fullDef->weapDef.notetrackSoundMapKeys)
{ {
memcpy_s(fullDef->notetrackSoundMapKeys, sizeof WeaponFullDef::notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapKeys)); memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys;
} }
if (fullDef->weapDef.notetrackSoundMapValues) if (fullDef->weapDef.notetrackSoundMapValues)
{ {
memcpy_s(fullDef->notetrackSoundMapValues, sizeof WeaponFullDef::notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value);
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapValues)); memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value);
fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues;
} }
if (fullDef->weapDef.worldModel) if (fullDef->weapDef.worldModel)
{ {
memcpy_s(fullDef->worldModel, sizeof WeaponFullDef::worldModel, fullDef->weapDef.worldModel, sizeof(void*) * _countof(WeaponFullDef::worldModel)); assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value);
memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value);
fullDef->weapDef.worldModel = fullDef->worldModel; fullDef->weapDef.worldModel = fullDef->worldModel;
} }
if (weapon->attachViewModel) if (weapon->attachViewModel)
{ {
memcpy_s(fullDef->attachViewModel, sizeof WeaponFullDef::attachViewModel, weapon->attachViewModel, sizeof(void*) * _countof(WeaponFullDef::attachViewModel)); assert(sizeof(WeaponFullDef::attachViewModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModel)>::value);
memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModel)>::value);
fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel; fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel;
} }
if (weapon->attachWorldModel) if (weapon->attachWorldModel)
{ {
memcpy_s(fullDef->attachWorldModel, sizeof WeaponFullDef::attachWorldModel, weapon->attachWorldModel, sizeof(void*) * _countof(WeaponFullDef::attachWorldModel)); assert(sizeof(WeaponFullDef::attachWorldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModel)>::value);
memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModel)>::value);
fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel; fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel;
} }
if (weapon->attachViewModelTag) if (weapon->attachViewModelTag)
{ {
memcpy_s(fullDef->attachViewModelTag, sizeof WeaponFullDef::attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * _countof(WeaponFullDef::attachViewModelTag)); assert(sizeof(WeaponFullDef::attachViewModelTag) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModelTag)>::value);
memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModelTag)>::value);
fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag; fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag;
} }
if (weapon->attachWorldModelTag) if (weapon->attachWorldModelTag)
{ {
memcpy_s(fullDef->attachWorldModelTag, sizeof WeaponFullDef::attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * _countof(WeaponFullDef::attachWorldModelTag)); assert(sizeof(WeaponFullDef::attachWorldModelTag) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModelTag)>::value);
memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModelTag)>::value);
fullDef->weapVariantDef.attachWorldModelTag = fullDef->attachWorldModelTag; fullDef->weapVariantDef.attachWorldModelTag = fullDef->attachWorldModelTag;
} }
if (fullDef->weapDef.parallelBounce) if (fullDef->weapDef.parallelBounce)
{ {
memcpy_s(fullDef->parallelBounce, sizeof WeaponFullDef::parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * SURF_TYPE_NUM); assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * SURF_TYPE_NUM);
memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * SURF_TYPE_NUM);
fullDef->weapDef.parallelBounce = fullDef->parallelBounce; fullDef->weapDef.parallelBounce = fullDef->parallelBounce;
} }
if (fullDef->weapDef.perpendicularBounce) if (fullDef->weapDef.perpendicularBounce)
{ {
memcpy_s(fullDef->perpendicularBounce, sizeof WeaponFullDef::perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * SURF_TYPE_NUM); assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * SURF_TYPE_NUM);
memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * SURF_TYPE_NUM);
fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce;
} }
if (fullDef->weapDef.locationDamageMultipliers) if (fullDef->weapDef.locationDamageMultipliers)
{ {
memcpy_s(fullDef->locationDamageMultipliers, sizeof WeaponFullDef::locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * HITLOC_NUM); assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * HITLOC_NUM);
memcpy(fullDef->locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * HITLOC_NUM);
fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers;
} }
if (fullDef->weapDef.weaponCamo && fullDef->weapDef.weaponCamo->name) if (fullDef->weapDef.weaponCamo && fullDef->weapDef.weaponCamo->name)
{ {
strcpy_s(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name); strncpy(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name, std::extent<decltype(WeaponFullDef::weaponCamo)>::value);
} }
} }
@ -1623,10 +1636,10 @@ std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo<Weapon
void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponVariantDef>* asset, std::ostream& stream) void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponVariantDef>* asset, std::ostream& stream)
{ {
auto* fullDef = new WeaponFullDef; auto* fullDef = new WeaponFullDef;
memset(fullDef, 0, sizeof WeaponFullDef); memset(fullDef, 0, sizeof(WeaponFullDef));
CopyToFullDef(asset->Asset(), fullDef); CopyToFullDef(asset->Asset(), fullDef);
InfoStringFromWeaponConverter converter(fullDef, weapon_fields, _countof(weapon_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -1,6 +1,7 @@
#include "AssetDumperZBarrier.h" #include "AssetDumperZBarrier.h"
#include <cassert> #include <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
@ -185,7 +186,7 @@ std::string AssetDumperZBarrier::GetFileNameForAsset(Zone* zone, XAssetInfo<ZBar
void AssetDumperZBarrier::DumpAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset, std::ostream& stream) void AssetDumperZBarrier::DumpAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset, std::ostream& stream)
{ {
InfoStringFromZBarrierConverter converter(asset->Asset(), zbarrier_fields, _countof(zbarrier_fields), [asset](const scr_string_t scrStr) -> std::string InfoStringFromZBarrierConverter converter(asset->Asset(), zbarrier_fields, std::extent<decltype(zbarrier_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())
@ -201,9 +202,9 @@ void AssetDumperZBarrier::DumpAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset,
//void AssetDumperZBarrier::CheckFields() //void AssetDumperZBarrier::CheckFields()
//{ //{
// assert(_countof(zbarrier_fields) == _countof(fields222)); // assert(std::extent<decltype(zbarrier_fields)>::value == std::extent<decltype(fields222)>::value);
// //
// for(auto i = 0u; i < _countof(zbarrier_fields); i++) // for(auto i = 0u; i < std::extent<decltype(zbarrier_fields)>::value; i++)
// { // {
// if(zbarrier_fields[i].iOffset != fields222[i].iOffset) // if(zbarrier_fields[i].iOffset != fields222[i].iOffset)
// { // {

View File

@ -61,7 +61,7 @@ void IwiWriter::WriteVersion(std::ostream& stream)
version.tag[2] = 'i'; version.tag[2] = 'i';
version.version = 27; version.version = 27;
stream.write(reinterpret_cast<char*>(&version), sizeof IwiVersion); stream.write(reinterpret_cast<char*>(&version), sizeof(IwiVersion));
} }
void IwiWriter::FillHeader2D(IwiHeader* header, Texture2D* texture) void IwiWriter::FillHeader2D(IwiHeader* header, Texture2D* texture)
@ -105,7 +105,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
for (auto& i : header.maxGlossForMip) for (auto& i : header.maxGlossForMip)
i = 0; i = 0;
auto currentFileSize = sizeof IwiVersion + sizeof IwiHeader; auto currentFileSize = sizeof(IwiVersion) + sizeof(IwiHeader);
const auto textureMipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1; const auto textureMipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--) for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--)
@ -113,7 +113,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
const auto mipLevelSize = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount(); const auto mipLevelSize = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
currentFileSize += mipLevelSize; currentFileSize += mipLevelSize;
if (currentMipLevel < static_cast<int>(_countof(iwi27::IwiHeader::fileSizeForPicmip))) if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi27::IwiHeader::fileSizeForPicmip)>::value))
header.fileSizeForPicmip[currentMipLevel] = currentFileSize; header.fileSizeForPicmip[currentMipLevel] = currentFileSize;
} }
@ -135,7 +135,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
return; return;
} }
stream.write(reinterpret_cast<char*>(&header), sizeof IwiHeader); stream.write(reinterpret_cast<char*>(&header), sizeof(IwiHeader));
for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--) for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--)
{ {

View File

@ -48,21 +48,21 @@ void IwiWriter::WriteVersion(std::ostream& stream)
version.tag[2] = 'i'; version.tag[2] = 'i';
version.version = 8; version.version = 8;
stream.write(reinterpret_cast<char*>(&version), sizeof IwiVersion); stream.write(reinterpret_cast<char*>(&version), sizeof(IwiVersion));
} }
void IwiWriter::FillHeader2D(IwiHeader* header, Texture2D* texture) void IwiWriter::FillHeader2D(IwiHeader* header, Texture2D* texture)
{ {
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth()); header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight()); header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
header->dimensions[2] = 1ui16; header->dimensions[2] = 1u;
} }
void IwiWriter::FillHeaderCube(IwiHeader* header, TextureCube* texture) void IwiWriter::FillHeaderCube(IwiHeader* header, TextureCube* texture)
{ {
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth()); header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight()); header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
header->dimensions[2] = 1ui16; header->dimensions[2] = 1u;
header->flags |= IMG_FLAG_MAPTYPE_CUBE; header->flags |= IMG_FLAG_MAPTYPE_CUBE;
} }
@ -98,7 +98,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
if (!texture->HasMipMaps()) if (!texture->HasMipMaps())
header.flags |= IMG_FLAG_NOMIPMAPS; header.flags |= IMG_FLAG_NOMIPMAPS;
auto currentFileSize = sizeof IwiVersion + sizeof IwiHeader; auto currentFileSize = sizeof(IwiVersion) + sizeof(IwiHeader);
const auto textureMipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1; const auto textureMipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--) for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--)
@ -106,7 +106,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
const auto mipLevelSize = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount(); const auto mipLevelSize = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
currentFileSize += mipLevelSize; currentFileSize += mipLevelSize;
if (currentMipLevel < static_cast<int>(_countof(iwi27::IwiHeader::fileSizeForPicmip))) if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi27::IwiHeader::fileSizeForPicmip)>::value))
header.fileSizeForPicmip[currentMipLevel] = currentFileSize; header.fileSizeForPicmip[currentMipLevel] = currentFileSize;
} }
@ -128,7 +128,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
return; return;
} }
stream.write(reinterpret_cast<char*>(&header), sizeof IwiHeader); stream.write(reinterpret_cast<char*>(&header), sizeof(IwiHeader));
for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--) for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--)
{ {

View File

@ -1,8 +1,11 @@
#include "UnlinkerArgs.h" #include "UnlinkerArgs.h"
#include <regex>
#include <type_traits>
#include "Utils/Arguments/UsageInformation.h" #include "Utils/Arguments/UsageInformation.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "ObjWriting.h" #include "ObjWriting.h"
#include <regex>
const CommandLineOption* const OPTION_HELP = CommandLineOption::Builder::Create() const CommandLineOption* const OPTION_HELP = CommandLineOption::Builder::Create()
.WithShortName("?") .WithShortName("?")
@ -64,7 +67,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]
}; };
UnlinkerArgs::UnlinkerArgs() UnlinkerArgs::UnlinkerArgs()
: m_argument_parser(COMMAND_LINE_OPTIONS, _countof(COMMAND_LINE_OPTIONS)) : m_argument_parser(COMMAND_LINE_OPTIONS, std::extent<decltype(COMMAND_LINE_OPTIONS)>::value)
{ {
m_task = ProcessingTask::DUMP; m_task = ProcessingTask::DUMP;
m_output_folder = "./%zoneName%"; m_output_folder = "./%zoneName%";

View File

@ -18,6 +18,10 @@ namespace std
typedef short int16_t; typedef short int16_t;
typedef int int32_t; typedef int int32_t;
typedef long long int64_t; typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
} }
#define __int8 char #define __int8 char

View File

@ -1,7 +1,7 @@
ZoneCommon = {} ZoneCommon = {}
function ZoneCommon:include() function ZoneCommon:include()
if References:include("ZoneCommon") then if References:include(self:name()) then
Utils:include() Utils:include()
ObjCommon:include() ObjCommon:include()
includedirs { includedirs {
@ -11,12 +11,10 @@ function ZoneCommon:include()
end end
function ZoneCommon:link() function ZoneCommon:link()
if References:link("ZoneCommon") then if References:link(self:name()) then
links(self:name())
Utils:link() Utils:link()
ObjCommon:link() ObjCommon:link()
links {
"ZoneCommon"
}
end end
end end
@ -24,11 +22,15 @@ function ZoneCommon:use()
end end
function ZoneCommon:name()
return "ZoneCommon"
end
function ZoneCommon:project() function ZoneCommon:project()
References:reset() References:reset()
local folder = ProjectFolder(); local folder = ProjectFolder();
project "ZoneCommon" project(self:name())
targetdir(TargetDirectoryLib) targetdir(TargetDirectoryLib)
location "%{wks.location}/src/%{prj.name}" location "%{wks.location}/src/%{prj.name}"
kind "StaticLib" kind "StaticLib"
@ -40,4 +42,6 @@ function ZoneCommon:project()
} }
self:include() self:include()
Utils:link()
end end

View File

@ -1,7 +1,10 @@
#include "GameAssetPoolIW4.h" #include "GameAssetPoolIW4.h"
#include <cassert>
#include <type_traits>
#include "Pool/AssetPoolStatic.h" #include "Pool/AssetPoolStatic.h"
#include "Pool/AssetPoolDynamic.h" #include "Pool/AssetPoolDynamic.h"
#include <cassert>
using namespace IW4; using namespace IW4;
@ -101,7 +104,7 @@ GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT); assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT);
m_phys_preset = nullptr; m_phys_preset = nullptr;
m_phys_collmap = nullptr; m_phys_collmap = nullptr;
@ -382,7 +385,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
const std::string& GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetType) const const std::string& GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetType) const
{ {
if (assetType >= 0 && assetType < static_cast<int>(_countof(ASSET_TYPE_NAMES))) if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -1,4 +1,7 @@
#include "GameIW4.h" #include "GameIW4.h"
#include <algorithm>
#include "IW4.h" #include "IW4.h"
using namespace IW4; using namespace IW4;

View File

@ -18,7 +18,7 @@
#define tdef_align(x) __declspec(align(x)) #define tdef_align(x) __declspec(align(x))
#else #else
#define type_align(x) __attribute__((__aligned__(x))) #define type_align(x) __attribute__((__aligned__(x)))
#define tdef_align(x) __attribute__((__aligned__(x))) #define tdef_align(x) /*__attribute__((__aligned__(x)))*/
#endif #endif
#endif #endif
@ -214,18 +214,18 @@ namespace IW4
struct cbrushside_t struct cbrushside_t
{ {
cplane_s* plane; cplane_s* plane;
unsigned __int16 materialNum; uint16_t materialNum;
char firstAdjacentSideOffset; char firstAdjacentSideOffset;
char edgeCount; char edgeCount;
}; };
struct cbrushWrapper_t struct cbrushWrapper_t
{ {
unsigned __int16 numsides; uint16_t numsides;
unsigned __int16 glassPieceIndex; uint16_t glassPieceIndex;
cbrushside_t* sides; cbrushside_t* sides;
cbrushedge_t* baseAdjacentSide; cbrushedge_t* baseAdjacentSide;
__int16 axialMaterialNum[2][3]; int16_t axialMaterialNum[2][3];
char firstAdjacentSideOffsets[2][3]; char firstAdjacentSideOffsets[2][3];
char edgeCount[2][3]; char edgeCount[2][3];
}; };
@ -265,13 +265,13 @@ namespace IW4
union XAnimIndices union XAnimIndices
{ {
char* _1; char* _1;
unsigned __int16* _2; uint16_t* _2;
void* data; void* data;
}; };
struct XAnimNotifyInfo struct XAnimNotifyInfo
{ {
unsigned __int16 name; uint16_t name;
float time; float time;
}; };
@ -287,7 +287,7 @@ namespace IW4
union XAnimDynamicIndicesTrans union XAnimDynamicIndicesTrans
{ {
char _1[1]; char _1[1];
unsigned __int16 _2[1]; uint16_t _2[1];
}; };
struct alignas(4) XAnimPartTransFrames struct alignas(4) XAnimPartTransFrames
@ -306,7 +306,7 @@ namespace IW4
struct XAnimPartTrans struct XAnimPartTrans
{ {
unsigned __int16 size; uint16_t size;
char smallTrans; char smallTrans;
XAnimPartTransData u; XAnimPartTransData u;
}; };
@ -314,7 +314,7 @@ namespace IW4
union XAnimDynamicIndicesQuat2 union XAnimDynamicIndicesQuat2
{ {
char _1[1]; char _1[1];
unsigned __int16 _2[1]; uint16_t _2[1];
}; };
typedef tdef_align(4) short XQuat2[2]; typedef tdef_align(4) short XQuat2[2];
@ -328,19 +328,19 @@ namespace IW4
union XAnimDeltaPartQuatData2 union XAnimDeltaPartQuatData2
{ {
XAnimDeltaPartQuatDataFrames2 frames; XAnimDeltaPartQuatDataFrames2 frames;
__int16 frame0[2]; int16_t frame0[2];
}; };
struct XAnimDeltaPartQuat2 struct XAnimDeltaPartQuat2
{ {
unsigned __int16 size; uint16_t size;
XAnimDeltaPartQuatData2 u; XAnimDeltaPartQuatData2 u;
}; };
union XAnimDynamicIndicesQuat union XAnimDynamicIndicesQuat
{ {
char _1[1]; char _1[1];
unsigned __int16 _2[1]; uint16_t _2[1];
}; };
typedef tdef_align(4) short XQuat[4]; typedef tdef_align(4) short XQuat[4];
@ -354,12 +354,12 @@ namespace IW4
union XAnimDeltaPartQuatData union XAnimDeltaPartQuatData
{ {
XAnimDeltaPartQuatDataFrames frames; XAnimDeltaPartQuatDataFrames frames;
__int16 frame0[4]; int16_t frame0[4];
}; };
struct XAnimDeltaPartQuat struct XAnimDeltaPartQuat
{ {
unsigned __int16 size; uint16_t size;
XAnimDeltaPartQuatData u; XAnimDeltaPartQuatData u;
}; };
@ -373,12 +373,12 @@ namespace IW4
struct XAnimParts struct XAnimParts
{ {
const char* name; const char* name;
unsigned __int16 dataByteCount; uint16_t dataByteCount;
unsigned __int16 dataShortCount; uint16_t dataShortCount;
unsigned __int16 dataIntCount; uint16_t dataIntCount;
unsigned __int16 randomDataByteCount; uint16_t randomDataByteCount;
unsigned __int16 randomDataIntCount; uint16_t randomDataIntCount;
unsigned __int16 numframes; uint16_t numframes;
char flags; char flags;
unsigned char boneCount[10]; unsigned char boneCount[10];
char notifyCount; char notifyCount;
@ -388,11 +388,11 @@ namespace IW4
unsigned int indexCount; unsigned int indexCount;
float framerate; float framerate;
float frequency; float frequency;
unsigned __int16* names; uint16_t* names;
char* dataByte; char* dataByte;
__int16* dataShort; int16_t* dataShort;
int* dataInt; int* dataInt;
__int16* randomDataShort; int16_t* randomDataShort;
char* randomDataByte; char* randomDataByte;
int* randomDataInt; int* randomDataInt;
XAnimIndices indices; XAnimIndices indices;
@ -402,8 +402,8 @@ namespace IW4
struct XSurfaceVertexInfo struct XSurfaceVertexInfo
{ {
__int16 vertCount[4]; int16_t vertCount[4];
unsigned __int16* vertsBlend; uint16_t* vertsBlend;
}; };
union GfxColor union GfxColor
@ -435,20 +435,20 @@ namespace IW4
struct XSurfaceCollisionAabb struct XSurfaceCollisionAabb
{ {
unsigned __int16 mins[3]; uint16_t mins[3];
unsigned __int16 maxs[3]; uint16_t maxs[3];
}; };
struct alignas(16) XSurfaceCollisionNode struct alignas(16) XSurfaceCollisionNode
{ {
XSurfaceCollisionAabb aabb; XSurfaceCollisionAabb aabb;
unsigned __int16 childBeginIndex; uint16_t childBeginIndex;
unsigned __int16 childCount; uint16_t childCount;
}; };
struct XSurfaceCollisionLeaf struct XSurfaceCollisionLeaf
{ {
unsigned __int16 triangleBeginIndex; uint16_t triangleBeginIndex;
}; };
struct XSurfaceCollisionTree struct XSurfaceCollisionTree
@ -463,24 +463,24 @@ namespace IW4
struct XRigidVertList struct XRigidVertList
{ {
unsigned __int16 boneOffset; uint16_t boneOffset;
unsigned __int16 vertCount; uint16_t vertCount;
unsigned __int16 triOffset; uint16_t triOffset;
unsigned __int16 triCount; uint16_t triCount;
XSurfaceCollisionTree* collisionTree; XSurfaceCollisionTree* collisionTree;
}; };
typedef tdef_align(16) unsigned __int16 r_index16_t; typedef tdef_align(16) uint16_t r_index16_t;
struct XSurface struct XSurface
{ {
char tileMode; char tileMode;
bool deformed; bool deformed;
unsigned __int16 vertCount; uint16_t vertCount;
unsigned __int16 triCount; uint16_t triCount;
char zoneHandle; char zoneHandle;
unsigned __int16 baseTriIndex; uint16_t baseTriIndex;
unsigned __int16 baseVertIndex; uint16_t baseVertIndex;
r_index16_t (*triIndices)[3]; r_index16_t (*triIndices)[3];
XSurfaceVertexInfo vertInfo; XSurfaceVertexInfo vertInfo;
GfxPackedVertex* verts0; GfxPackedVertex* verts0;
@ -493,15 +493,15 @@ namespace IW4
{ {
const char* name; const char* name;
XSurface* surfs; XSurface* surfs;
unsigned __int16 numsurfs; uint16_t numsurfs;
int partBits[6]; int partBits[6];
}; };
struct XModelLodInfo struct XModelLodInfo
{ {
float dist; float dist;
unsigned __int16 numsurfs; uint16_t numsurfs;
unsigned __int16 surfIndex; uint16_t surfIndex;
XModelSurfs* modelSurfs; XModelSurfs* modelSurfs;
int partBits[6]; int partBits[6];
XSurface* surfs; XSurface* surfs;
@ -550,9 +550,9 @@ namespace IW4
char lodRampType; char lodRampType;
float scale; float scale;
unsigned int noScalePartBits[6]; unsigned int noScalePartBits[6];
unsigned __int16* boneNames; uint16_t* boneNames;
char* parentList; char* parentList;
__int16(*quats)[4]; int16_t(*quats)[4];
float(*trans)[3]; float(*trans)[3];
char* partClassification; char* partClassification;
DObjAnimMat* baseMat; DObjAnimMat* baseMat;
@ -632,23 +632,23 @@ namespace IW4
struct GfxDrawSurfFields struct GfxDrawSurfFields
{ {
unsigned __int64 objectId : 16; uint64_t objectId : 16;
unsigned __int64 reflectionProbeIndex : 8; uint64_t reflectionProbeIndex : 8;
unsigned __int64 hasGfxEntIndex : 1; uint64_t hasGfxEntIndex : 1;
unsigned __int64 customIndex : 5; uint64_t customIndex : 5;
unsigned __int64 materialSortedIndex : 12; uint64_t materialSortedIndex : 12;
unsigned __int64 prepass : 2; uint64_t prepass : 2;
unsigned __int64 useHeroLighting : 1; uint64_t useHeroLighting : 1;
unsigned __int64 sceneLightIndex : 8; uint64_t sceneLightIndex : 8;
unsigned __int64 surfType : 4; uint64_t surfType : 4;
unsigned __int64 primarySortKey : 6; uint64_t primarySortKey : 6;
unsigned __int64 unused : 1; uint64_t unused : 1;
}; };
union GfxDrawSurf union GfxDrawSurf
{ {
GfxDrawSurfFields fields; GfxDrawSurfFields fields;
unsigned __int64 packed; uint64_t packed;
}; };
struct MaterialInfo struct MaterialInfo
@ -660,7 +660,7 @@ namespace IW4
char textureAtlasColumnCount; char textureAtlasColumnCount;
GfxDrawSurf drawSurf; GfxDrawSurf drawSurf;
unsigned int surfaceTypeBits; unsigned int surfaceTypeBits;
unsigned __int16 hashIndex; uint16_t hashIndex;
}; };
struct Material struct Material
@ -735,9 +735,9 @@ namespace IW4
bool noPicmip; bool noPicmip;
char track; char track;
CardMemory cardMemory; CardMemory cardMemory;
unsigned __int16 width; uint16_t width;
unsigned __int16 height; uint16_t height;
unsigned __int16 depth; uint16_t depth;
bool delayLoadPixels; bool delayLoadPixels;
const char* name; const char* name;
}; };
@ -745,15 +745,15 @@ namespace IW4
struct GfxPixelShaderLoadDef struct GfxPixelShaderLoadDef
{ {
unsigned int* program; unsigned int* program;
unsigned __int16 programSize; uint16_t programSize;
unsigned __int16 loadForRenderer; uint16_t loadForRenderer;
}; };
struct GfxVertexShaderLoadDef struct GfxVertexShaderLoadDef
{ {
unsigned int* program; unsigned int* program;
unsigned __int16 programSize; uint16_t programSize;
unsigned __int16 loadForRenderer; uint16_t loadForRenderer;
}; };
struct MaterialStreamRouting struct MaterialStreamRouting
@ -802,7 +802,7 @@ namespace IW4
struct MaterialArgumentCodeConst struct MaterialArgumentCodeConst
{ {
unsigned __int16 index; uint16_t index;
char firstRow; char firstRow;
char rowCount; char rowCount;
}; };
@ -832,8 +832,8 @@ namespace IW4
struct MaterialShaderArgument struct MaterialShaderArgument
{ {
unsigned __int16 type; uint16_t type;
unsigned __int16 dest; uint16_t dest;
MaterialArgumentDef u; MaterialArgumentDef u;
}; };
@ -852,8 +852,8 @@ namespace IW4
struct MaterialTechnique struct MaterialTechnique
{ {
const char* name; const char* name;
unsigned __int16 flags; uint16_t flags;
unsigned __int16 passCount; uint16_t passCount;
MaterialPass passArray[1]; MaterialPass passArray[1];
}; };
@ -1013,7 +1013,7 @@ namespace IW4
struct SndCurve struct SndCurve
{ {
const char* filename; const char* filename;
unsigned __int16 knotCount; uint16_t knotCount;
float knots[16][2]; float knots[16][2];
}; };
@ -1499,7 +1499,7 @@ namespace IW4
char loopCount; char loopCount;
char colIndexBits; char colIndexBits;
char rowIndexBits; char rowIndexBits;
__int16 entryCount; int16_t entryCount;
}; };
struct FxElemVec3Range struct FxElemVec3Range
@ -1579,7 +1579,7 @@ namespace IW4
int vertCount; int vertCount;
FxTrailVertex* verts; FxTrailVertex* verts;
int indCount; int indCount;
unsigned __int16* inds; uint16_t* inds;
}; };
struct FxSparkFountainDef struct FxSparkFountainDef
@ -1672,7 +1672,7 @@ namespace IW4
struct Glyph struct Glyph
{ {
unsigned __int16 letter; uint16_t letter;
char x0; char x0;
char y0; char y0;
char dx; char dx;
@ -1779,7 +1779,7 @@ namespace IW4
struct alignas(4) StructuredDataEnumEntry struct alignas(4) StructuredDataEnumEntry
{ {
const char* string; const char* string;
unsigned __int16 index; uint16_t index;
}; };
struct StructuredDataEnum struct StructuredDataEnum
@ -1859,16 +1859,16 @@ namespace IW4
struct TriggerModel struct TriggerModel
{ {
int contents; int contents;
unsigned __int16 hullCount; uint16_t hullCount;
unsigned __int16 firstHull; uint16_t firstHull;
}; };
struct TriggerHull struct TriggerHull
{ {
Bounds bounds; Bounds bounds;
int contents; int contents;
unsigned __int16 slabCount; uint16_t slabCount;
unsigned __int16 firstSlab; uint16_t firstSlab;
}; };
struct TriggerSlab struct TriggerSlab
@ -1892,7 +1892,7 @@ namespace IW4
{ {
const char* name; const char* name;
float origin[3]; float origin[3];
unsigned __int16 triggerIndex; uint16_t triggerIndex;
char sunPrimaryLightIndex; char sunPrimaryLightIndex;
}; };
@ -1934,7 +1934,7 @@ namespace IW4
struct cNode_t struct cNode_t
{ {
cplane_s* plane; cplane_s* plane;
__int16 children[2]; int16_t children[2];
}; };
struct cLeafBrushNodeLeaf_t struct cLeafBrushNodeLeaf_t
@ -1946,7 +1946,7 @@ namespace IW4
{ {
float dist; float dist;
float range; float range;
unsigned __int16 childOffset[2]; uint16_t childOffset[2];
}; };
union cLeafBrushNodeData_t union cLeafBrushNodeData_t
@ -1958,7 +1958,7 @@ namespace IW4
struct cLeafBrushNode_s struct cLeafBrushNode_s
{ {
char axis; char axis;
__int16 leafBrushCount; int16_t leafBrushCount;
int contents; int contents;
cLeafBrushNodeData_t data; cLeafBrushNodeData_t data;
}; };
@ -1990,16 +1990,16 @@ namespace IW4
struct alignas(16) CollisionAabbTree struct alignas(16) CollisionAabbTree
{ {
float midPoint[3]; float midPoint[3];
unsigned __int16 materialIndex; uint16_t materialIndex;
unsigned __int16 childCount; uint16_t childCount;
float halfSize[3]; float halfSize[3];
CollisionAabbTreeIndex u; CollisionAabbTreeIndex u;
}; };
struct cLeaf_t struct cLeaf_t
{ {
unsigned __int16 firstCollAabbIndex; uint16_t firstCollAabbIndex;
unsigned __int16 collAabbCount; uint16_t collAabbCount;
int brushContents; int brushContents;
int terrainContents; int terrainContents;
Bounds bounds; Bounds bounds;
@ -2015,11 +2015,11 @@ namespace IW4
struct cbrush_t struct cbrush_t
{ {
unsigned __int16 numsides; uint16_t numsides;
unsigned __int16 glassPieceIndex; uint16_t glassPieceIndex;
cbrushside_t* sides; cbrushside_t* sides;
char* baseAdjacentSide; char* baseAdjacentSide;
__int16 axialMaterialNum[2][3]; int16_t axialMaterialNum[2][3];
char firstAdjacentSideOffsets[2][3]; char firstAdjacentSideOffsets[2][3];
char edgeCount[2][3]; char edgeCount[2][3];
}; };
@ -2027,8 +2027,8 @@ namespace IW4
struct SModelAabbNode struct SModelAabbNode
{ {
Bounds bounds; Bounds bounds;
unsigned __int16 firstChild; uint16_t firstChild;
unsigned __int16 childCount; uint16_t childCount;
}; };
struct GfxPlacement struct GfxPlacement
@ -2050,8 +2050,8 @@ namespace IW4
DynEntityType type; DynEntityType type;
GfxPlacement pose; GfxPlacement pose;
XModel* xModel; XModel* xModel;
unsigned __int16 brushModel; uint16_t brushModel;
unsigned __int16 physicsBrushModel; uint16_t physicsBrushModel;
FxEffectDef* destroyFx; FxEffectDef* destroyFx;
PhysPreset* physPreset; PhysPreset* physPreset;
int health; int health;
@ -2068,15 +2068,15 @@ namespace IW4
struct DynEntityClient struct DynEntityClient
{ {
int physObjId; int physObjId;
unsigned __int16 flags; uint16_t flags;
unsigned __int16 lightingHandle; uint16_t lightingHandle;
int health; int health;
}; };
struct DynEntityColl struct DynEntityColl
{ {
unsigned __int16 sector; uint16_t sector;
unsigned __int16 nextEntInSector; uint16_t nextEntInSector;
float linkMins[2]; float linkMins[2];
float linkMaxs[2]; float linkMaxs[2];
}; };
@ -2111,7 +2111,7 @@ namespace IW4
unsigned int vertCount; unsigned int vertCount;
vec3_t* verts; vec3_t* verts;
int triCount; int triCount;
unsigned __int16* triIndices; uint16_t* triIndices;
char* triEdgeIsWalkable; char* triEdgeIsWalkable;
int borderCount; int borderCount;
CollisionBorder* borders; CollisionBorder* borders;
@ -2121,14 +2121,14 @@ namespace IW4
CollisionAabbTree* aabbTrees; CollisionAabbTree* aabbTrees;
unsigned int numSubModels; unsigned int numSubModels;
cmodel_t* cmodels; cmodel_t* cmodels;
unsigned __int16 numBrushes; uint16_t numBrushes;
cbrush_array_t* brushes; cbrush_array_t* brushes;
BoundsArray* brushBounds; BoundsArray* brushBounds;
int* brushContents; int* brushContents;
MapEnts* mapEnts; MapEnts* mapEnts;
unsigned __int16 smodelNodeCount; uint16_t smodelNodeCount;
SModelAabbNode* smodelNodes; SModelAabbNode* smodelNodes;
unsigned __int16 dynEntCount[2]; uint16_t dynEntCount[2];
DynEntityDef* dynEntDefList[2]; DynEntityDef* dynEntDefList[2];
DynEntityPose* dynEntPoseList[2]; DynEntityPose* dynEntPoseList[2];
DynEntityClient* dynEntClientList[2]; DynEntityClient* dynEntClientList[2];
@ -2194,7 +2194,7 @@ namespace IW4
struct pathlink_s struct pathlink_s
{ {
float fDist; float fDist;
unsigned __int16 nodeNum; uint16_t nodeNum;
char disconnectCount; char disconnectCount;
char negotiationLink; char negotiationLink;
char flags; char flags;
@ -2219,12 +2219,12 @@ namespace IW4
struct pathnode_constant_t struct pathnode_constant_t
{ {
nodeType type; nodeType type;
unsigned __int16 spawnflags; uint16_t spawnflags;
unsigned __int16 targetname; uint16_t targetname;
unsigned __int16 script_linkName; uint16_t script_linkName;
unsigned __int16 script_noteworthy; uint16_t script_noteworthy;
unsigned __int16 target; uint16_t target;
unsigned __int16 animscript; uint16_t animscript;
int animscriptfunc; int animscriptfunc;
float vOrigin[3]; float vOrigin[3];
float fAngle; float fAngle;
@ -2235,8 +2235,8 @@ namespace IW4
float minUseDistSq; float minUseDistSq;
PathNodeErrorCode error; PathNodeErrorCode error;
}; };
__int16 wOverlapNode[2]; int16_t wOverlapNode[2];
unsigned __int16 totalLinkCount; uint16_t totalLinkCount;
pathlink_s* Links; pathlink_s* Links;
}; };
@ -2247,9 +2247,9 @@ namespace IW4
int iValidTime[3]; int iValidTime[3];
int dangerousNodeTime[3]; int dangerousNodeTime[3];
int inPlayerLOSTime; int inPlayerLOSTime;
__int16 wLinkCount; int16_t wLinkCount;
__int16 wOverlapCount; int16_t wOverlapCount;
__int16 turretEntNumber; int16_t turretEntNumber;
char userCount; char userCount;
bool hasBadPlaceLink; bool hasBadPlaceLink;
}; };
@ -2285,7 +2285,7 @@ namespace IW4
struct pathnode_tree_nodes_t struct pathnode_tree_nodes_t
{ {
int nodeCount; int nodeCount;
unsigned __int16* nodes; uint16_t* nodes;
}; };
struct pathnode_tree_t; struct pathnode_tree_t;
@ -2309,8 +2309,8 @@ namespace IW4
pathnode_t* nodes; pathnode_t* nodes;
pathbasenode_t* basenodes; pathbasenode_t* basenodes;
unsigned int chainNodeCount; unsigned int chainNodeCount;
unsigned __int16* chainNodeForNode; uint16_t* chainNodeForNode;
unsigned __int16* nodeForChainNode; uint16_t* nodeForChainNode;
int visBytes; int visBytes;
char* pathVis; char* pathVis;
int nodeTreeCount; int nodeTreeCount;
@ -2361,8 +2361,8 @@ namespace IW4
struct G_GlassPiece struct G_GlassPiece
{ {
unsigned __int16 damageTaken; uint16_t damageTaken;
unsigned __int16 collapseTime; uint16_t collapseTime;
int lastStateChangeTime; int lastStateChangeTime;
char impactDir; char impactDir;
char impactPos[2]; char impactPos[2];
@ -2371,17 +2371,17 @@ namespace IW4
struct G_GlassName struct G_GlassName
{ {
char* nameStr; char* nameStr;
unsigned __int16 name; uint16_t name;
unsigned __int16 pieceCount; uint16_t pieceCount;
unsigned __int16* pieceIndices; uint16_t* pieceIndices;
}; };
struct G_GlassData struct G_GlassData
{ {
G_GlassPiece* glassPieces; G_GlassPiece* glassPieces;
unsigned int pieceCount; unsigned int pieceCount;
unsigned __int16 damageToWeaken; uint16_t damageToWeaken;
unsigned __int16 damageToDestroy; uint16_t damageToDestroy;
unsigned int glassNameCount; unsigned int glassNameCount;
G_GlassName* glassNames; G_GlassName* glassNames;
char pad[108]; char pad[108];
@ -2431,15 +2431,15 @@ namespace IW4
{ {
float texCoordOrigin[2]; float texCoordOrigin[2];
unsigned int supportMask; unsigned int supportMask;
unsigned __int16 initIndex; uint16_t initIndex;
unsigned __int16 geoDataStart; uint16_t geoDataStart;
char defIndex; char defIndex;
char pad[5]; char pad[5];
char vertCount; char vertCount;
char holeDataCount; char holeDataCount;
char crackDataCount; char crackDataCount;
char fanDataCount; char fanDataCount;
unsigned __int16 flags; uint16_t flags;
float areaX2; float areaX2;
}; };
@ -2454,20 +2454,20 @@ namespace IW4
struct FxGlassVertex struct FxGlassVertex
{ {
__int16 x; int16_t x;
__int16 y; int16_t y;
}; };
struct FxGlassHoleHeader struct FxGlassHoleHeader
{ {
unsigned __int16 uniqueVertCount; uint16_t uniqueVertCount;
char touchVert; char touchVert;
char pad[1]; char pad[1];
}; };
struct FxGlassCrackHeader struct FxGlassCrackHeader
{ {
unsigned __int16 uniqueVertCount; uint16_t uniqueVertCount;
char beginVertIndex; char beginVertIndex;
char endVertIndex; char endVertIndex;
}; };
@ -2478,7 +2478,7 @@ namespace IW4
FxGlassHoleHeader hole; FxGlassHoleHeader hole;
FxGlassCrackHeader crack; FxGlassCrackHeader crack;
char asBytes[4]; char asBytes[4];
__int16 anonymous[2]; int16_t anonymous[2];
}; };
struct FxGlassInitPieceState struct FxGlassInitPieceState
@ -2518,7 +2518,7 @@ namespace IW4
raw_byte16* visData; raw_byte16* visData;
vec3_t* linkOrg; vec3_t* linkOrg;
raw_float16* halfThickness; raw_float16* halfThickness;
unsigned __int16* lightingHandles; uint16_t* lightingHandles;
FxGlassInitPieceState* initPieceStates; FxGlassInitPieceState* initPieceStates;
FxGlassGeometryData* initGeoData; FxGlassGeometryData* initGeoData;
bool needToCompactData; bool needToCompactData;
@ -2545,7 +2545,7 @@ namespace IW4
{ {
int cellCount; int cellCount;
cplane_s* planes; cplane_s* planes;
unsigned __int16* nodes; uint16_t* nodes;
raw_uint* sceneEntCellBits; raw_uint* sceneEntCellBits;
}; };
@ -2559,12 +2559,12 @@ namespace IW4
struct GfxAabbTree struct GfxAabbTree
{ {
Bounds bounds; Bounds bounds;
unsigned __int16 childCount; uint16_t childCount;
unsigned __int16 surfaceCount; uint16_t surfaceCount;
unsigned __int16 startSurfIndex; uint16_t startSurfIndex;
unsigned __int16 surfaceCountNoDecal; uint16_t surfaceCountNoDecal;
unsigned __int16 startSurfIndexNoDecal; uint16_t startSurfIndexNoDecal;
unsigned __int16 smodelIndexCount; uint16_t smodelIndexCount;
StaticModelIndex* smodelIndexes; StaticModelIndex* smodelIndexes;
int childrenOffset; int childrenOffset;
}; };
@ -2596,7 +2596,7 @@ namespace IW4
GfxPortalWritable writable; GfxPortalWritable writable;
DpvsPlane plane; DpvsPlane plane;
vec3_t* vertices; vec3_t* vertices;
unsigned __int16 cellIndex; uint16_t cellIndex;
char vertexCount; char vertexCount;
float hullAxis[2][3]; float hullAxis[2][3];
}; };
@ -2666,7 +2666,7 @@ namespace IW4
struct alignas(4) GfxLightGridEntry struct alignas(4) GfxLightGridEntry
{ {
unsigned __int16 colorsIndex; uint16_t colorsIndex;
char primaryLightIndex; char primaryLightIndex;
char needsTrace; char needsTrace;
}; };
@ -2680,11 +2680,11 @@ namespace IW4
{ {
bool hasLightRegions; bool hasLightRegions;
unsigned int lastSunPrimaryLightIndex; unsigned int lastSunPrimaryLightIndex;
unsigned __int16 mins[3]; uint16_t mins[3];
unsigned __int16 maxs[3]; uint16_t maxs[3];
unsigned int rowAxis; unsigned int rowAxis;
unsigned int colAxis; unsigned int colAxis;
unsigned __int16* rowDataStart; uint16_t* rowDataStart;
unsigned int rawRowDataSize; unsigned int rawRowDataSize;
char* rawRowData; char* rawRowData;
unsigned int entryCount; unsigned int entryCount;
@ -2703,9 +2703,9 @@ namespace IW4
GfxBrushModelWritable writable; GfxBrushModelWritable writable;
Bounds bounds; Bounds bounds;
float radius; float radius;
unsigned __int16 surfaceCount; uint16_t surfaceCount;
unsigned __int16 startSurfIndex; uint16_t startSurfIndex;
unsigned __int16 surfaceCountNoDecal; uint16_t surfaceCountNoDecal;
}; };
struct MaterialMemory struct MaterialMemory
@ -2744,32 +2744,32 @@ namespace IW4
{ {
char hasGfxEntIndex; char hasGfxEntIndex;
char lod; char lod;
unsigned __int16 surfId; uint16_t surfId;
}; };
struct GfxSceneDynModel struct GfxSceneDynModel
{ {
XModelDrawInfo info; XModelDrawInfo info;
unsigned __int16 dynEntId; uint16_t dynEntId;
}; };
struct BModelDrawInfo struct BModelDrawInfo
{ {
unsigned __int16 surfId; uint16_t surfId;
}; };
struct alignas(4) GfxSceneDynBrush struct alignas(4) GfxSceneDynBrush
{ {
BModelDrawInfo info; BModelDrawInfo info;
unsigned __int16 dynEntId; uint16_t dynEntId;
}; };
struct GfxShadowGeometry struct GfxShadowGeometry
{ {
unsigned __int16 surfaceCount; uint16_t surfaceCount;
unsigned __int16 smodelCount; uint16_t smodelCount;
unsigned __int16* sortedSurfIndex; uint16_t* sortedSurfIndex;
unsigned __int16* smodelIndex; uint16_t* smodelIndex;
}; };
struct GfxLightRegionAxis struct GfxLightRegionAxis
@ -2804,14 +2804,14 @@ namespace IW4
{ {
GfxPackedPlacement placement; GfxPackedPlacement placement;
XModel* model; XModel* model;
unsigned __int16 cullDist; uint16_t cullDist;
unsigned __int16 lightingHandle; uint16_t lightingHandle;
char reflectionProbeIndex; char reflectionProbeIndex;
char primaryLightIndex; char primaryLightIndex;
char flags; char flags;
char firstMtlSkinIndex; char firstMtlSkinIndex;
GfxColor groundLighting; GfxColor groundLighting;
unsigned __int16 cacheId[4]; uint16_t cacheId[4];
}; };
struct GfxStaticModelInst struct GfxStaticModelInst
@ -2824,8 +2824,8 @@ namespace IW4
{ {
unsigned int vertexLayerData; unsigned int vertexLayerData;
unsigned int firstVertex; unsigned int firstVertex;
unsigned __int16 vertexCount; uint16_t vertexCount;
unsigned __int16 triCount; uint16_t triCount;
unsigned int baseIndex; unsigned int baseIndex;
}; };
@ -2872,7 +2872,7 @@ namespace IW4
unsigned int surfaceVisDataCount; unsigned int surfaceVisDataCount;
char* smodelVisData[3]; char* smodelVisData[3];
char* surfaceVisData[3]; char* surfaceVisData[3];
unsigned __int16* sortedSurfIndex; uint16_t* sortedSurfIndex;
GfxStaticModelInst* smodelInsts; GfxStaticModelInst* smodelInsts;
GfxSurface* surfaces; GfxSurface* surfaces;
GfxSurfaceBounds* surfacesBounds; GfxSurfaceBounds* surfacesBounds;
@ -3262,10 +3262,10 @@ namespace IW4
const char** szXAnimsRightHanded; const char** szXAnimsRightHanded;
const char** szXAnimsLeftHanded; const char** szXAnimsLeftHanded;
const char* szModeName; const char* szModeName;
unsigned __int16* notetrackSoundMapKeys; uint16_t* notetrackSoundMapKeys;
unsigned __int16* notetrackSoundMapValues; uint16_t* notetrackSoundMapValues;
unsigned __int16* notetrackRumbleMapKeys; uint16_t* notetrackRumbleMapKeys;
unsigned __int16* notetrackRumbleMapValues; uint16_t* notetrackRumbleMapValues;
int playerAnimType; int playerAnimType;
weapType_t weapType; weapType_t weapType;
weapClass_t weapClass; weapClass_t weapClass;
@ -3565,7 +3565,7 @@ namespace IW4
const char* accuracyGraphName1; const char* accuracyGraphName1;
vec2_t* originalAccuracyGraphKnots0; vec2_t* originalAccuracyGraphKnots0;
vec2_t* originalAccuracyGraphKnots1; vec2_t* originalAccuracyGraphKnots1;
unsigned __int16 originalAccuracyGraphKnotCount[2]; uint16_t originalAccuracyGraphKnotCount[2];
int iPositionReloadTransTime; int iPositionReloadTransTime;
float leftArc; float leftArc;
float rightArc; float rightArc;
@ -3687,7 +3687,7 @@ namespace IW4
const char* szInternalName; const char* szInternalName;
WeaponDef* weapDef; WeaponDef* weapDef;
const char* szDisplayName; const char* szDisplayName;
unsigned __int16* hideTags; uint16_t* hideTags;
const char** szXAnims; const char** szXAnims;
float fAdsZoomFov; float fAdsZoomFov;
int iAdsTransInTime; int iAdsTransInTime;
@ -3709,7 +3709,7 @@ namespace IW4
int ammoDropStockMax; int ammoDropStockMax;
float adsDofStart; float adsDofStart;
float adsDofEnd; float adsDofEnd;
unsigned __int16 accuracyGraphKnotCount[2]; uint16_t accuracyGraphKnotCount[2];
vec2_t* accuracyGraphKnots[2]; vec2_t* accuracyGraphKnots[2];
bool motionTracker; bool motionTracker;
bool enhanced; bool enhanced;
@ -3720,15 +3720,15 @@ namespace IW4
{ {
WeaponCompleteDef weapCompleteDef; WeaponCompleteDef weapCompleteDef;
WeaponDef weapDef; WeaponDef weapDef;
unsigned __int16 hideTags[32]; uint16_t hideTags[32];
const char* szXAnims[37]; const char* szXAnims[37];
XModel* gunXModel[16]; XModel* gunXModel[16];
const char* szXAnimsRightHanded[37]; const char* szXAnimsRightHanded[37];
const char* szXAnimsLeftHanded[37]; const char* szXAnimsLeftHanded[37];
unsigned __int16 notetrackSoundMapKeys[16]; uint16_t notetrackSoundMapKeys[16];
unsigned __int16 notetrackSoundMapValues[16]; uint16_t notetrackSoundMapValues[16];
unsigned __int16 notetrackRumbleMapKeys[16]; uint16_t notetrackRumbleMapKeys[16];
unsigned __int16 notetrackRumbleMapValues[16]; uint16_t notetrackRumbleMapValues[16];
XModel* worldModel[16]; XModel* worldModel[16];
float parallelBounce[31]; float parallelBounce[31];
float perpendicularBounce[31]; float perpendicularBounce[31];
@ -3877,7 +3877,7 @@ namespace IW4
float trophyInactiveRadius; float trophyInactiveRadius;
int trophyAmmoCount; int trophyAmmoCount;
float trophyReloadTime; float trophyReloadTime;
unsigned __int16 trophyTags[4]; uint16_t trophyTags[4];
Material* compassFriendlyIcon; Material* compassFriendlyIcon;
Material* compassEnemyIcon; Material* compassEnemyIcon;
int compassIconWidth; int compassIconWidth;

View File

@ -1,7 +1,10 @@
#include "GameAssetPoolT6.h" #include "GameAssetPoolT6.h"
#include <cassert>
#include <type_traits>
#include "Pool/AssetPoolStatic.h" #include "Pool/AssetPoolStatic.h"
#include "Pool/AssetPoolDynamic.h" #include "Pool/AssetPoolDynamic.h"
#include <cassert>
using namespace T6; using namespace T6;
@ -74,7 +77,7 @@ GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT); assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT);
m_phys_preset = nullptr; m_phys_preset = nullptr;
m_phys_constraints = nullptr; m_phys_constraints = nullptr;
@ -477,7 +480,7 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, std::strin
const std::string& GameAssetPoolT6::GetAssetTypeName(const asset_type_t assetType) const const std::string& GameAssetPoolT6::GetAssetTypeName(const asset_type_t assetType) const
{ {
if (assetType >= 0 && assetType < static_cast<int>(_countof(ASSET_TYPE_NAMES))) if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -1,4 +1,7 @@
#include "GameT6.h" #include "GameT6.h"
#include <algorithm>
#include "T6.h" #include "T6.h"
using namespace T6; using namespace T6;

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ public:
for(auto* entry : m_assets) for(auto* entry : m_assets)
{ {
delete entry->m_ptr; delete entry->Asset();
delete entry; delete entry;
} }

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include <cstring>
#include <stdexcept>
#include "GlobalAssetPool.h" #include "GlobalAssetPool.h"
#include "AssetPool.h" #include "AssetPool.h"
#include "XAssetInfo.h" #include "XAssetInfo.h"
#include <cstring>
template <typename T> template <typename T>
class AssetPoolStatic final : public AssetPool<T> class AssetPoolStatic final : public AssetPool<T>
{ {
@ -85,7 +86,7 @@ public:
{ {
if(m_free == nullptr) if(m_free == nullptr)
{ {
throw std::exception("Could not add asset to static asset pool: capacity exhausted."); throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted.");
} }
AssetPoolEntry* poolSlot = m_free; AssetPoolEntry* poolSlot = m_free;

View File

@ -7,14 +7,14 @@ struct ZoneHeader
uint32_t m_version; uint32_t m_version;
}; };
#ifdef _WIN64 #ifdef ARCH_x64
typedef uint32_t scr_string_t; typedef uint32_t scr_string_t;
typedef uint64_t xchunk_size_t; typedef uint64_t xchunk_size_t;
typedef uint64_t xblock_size_t; typedef uint64_t xblock_size_t;
typedef uint64_t zone_pointer_t; typedef uint64_t zone_pointer_t;
constexpr uint16_t SCR_STRING_MAX = UINT32_MAX; constexpr uint16_t SCR_STRING_MAX = UINT32_MAX;
#elif _WIN32 #elif ARCH_x86
typedef uint16_t scr_string_t; typedef uint16_t scr_string_t;
typedef uint32_t xchunk_size_t; typedef uint32_t xchunk_size_t;
typedef uint32_t xblock_size_t; typedef uint32_t xblock_size_t;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,18 @@
#include "ZoneLoaderFactoryT6.h" #include "ZoneLoaderFactoryT6.h"
#include <cassert>
#include <cstring>
#include "Game/T6/T6.h" #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/StepVerifyMagic.h"
#include "Loading/Steps/StepSkipBytes.h" #include "Loading/Steps/StepSkipBytes.h"
#include "Loading/Steps/StepVerifyFileName.h" #include "Loading/Steps/StepVerifyFileName.h"
@ -8,18 +20,7 @@
#include "Loading/Steps/StepVerifySignature.h" #include "Loading/Steps/StepVerifySignature.h"
#include "Loading/Steps/StepAddProcessor.h" #include "Loading/Steps/StepAddProcessor.h"
#include "Loading/Steps/StepAllocXBlocks.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 "Loading/Steps/StepLoadZoneContent.h"
#include "ContentLoaderT6.h"
#include "Game/T6/GameAssetPoolT6.h"
#include "Game/T6/GameT6.h"
#include "Game/GameLanguage.h"
using namespace T6; using namespace T6;

View File

@ -1,5 +1,7 @@
#include "AssetLoader.h" #include "AssetLoader.h"
#include <cassert> #include <cassert>
#include <algorithm>
AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream) AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream)
: ContentLoaderBase(zone, stream), : ContentLoaderBase(zone, stream),

View File

@ -1,4 +1,6 @@
#pragma once #pragma once
#include "Zone/ZoneTypes.h"
#include "Pool/XAssetInfo.h" #include "Pool/XAssetInfo.h"
#include "ContentLoaderBase.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."; 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."; return "Invalid Zone. XBlock overflowed.";
} }

View File

@ -10,5 +10,5 @@ public:
explicit BlockOverflowException(XBlock* block); explicit BlockOverflowException(XBlock* block);
std::string DetailedMessage() override; 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"; return "Zone has invalid chunk size";
} }

View File

@ -11,5 +11,5 @@ public:
InvalidChunkSizeException(size_t size, size_t max); InvalidChunkSizeException(size_t size, size_t max);
std::string DetailedMessage() override; 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"; 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"; return "Zone has invalid or unsupported compression. Inflate failed";
} }

View File

@ -5,5 +5,5 @@ class InvalidCompressionException final : public LoadingException
{ {
public: public:
std::string DetailedMessage() override; 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 + "'"; 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"; 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); InvalidFileNameException(std::string& actualFileName, std::string& expectedFileName);
std::string DetailedMessage() override; 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."; 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."; return "Loaded fastfile has an invalid hash.";
} }

View File

@ -5,5 +5,5 @@ class InvalidHashException final : public LoadingException
{ {
public: public:
std::string DetailedMessage() override; 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) + "'"; 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."; return "Encountered invalid magic when loading.";
} }

View File

@ -9,5 +9,5 @@ public:
explicit InvalidMagicException(const char* expectedMagic); explicit InvalidMagicException(const char* expectedMagic);
std::string DetailedMessage() override; 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); 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"; return "Zone referenced invalid block";
} }

View File

@ -10,5 +10,5 @@ public:
explicit InvalidOffsetBlockException(block_t referencedBlock); explicit InvalidOffsetBlockException(block_t referencedBlock);
std::string DetailedMessage() override; 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); + " 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"; return "Zone referenced offset of block that is out of bounds";
} }

View File

@ -11,5 +11,5 @@ public:
InvalidOffsetBlockOffsetException(XBlock* block, size_t referencedOffset); InvalidOffsetBlockOffsetException(XBlock* block, size_t referencedOffset);
std::string DetailedMessage() override; 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."; 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."; return "Loaded fastfile has an invalid signature.";
} }

View File

@ -5,5 +5,5 @@ class InvalidSignatureException final : public LoadingException
{ {
public: public:
std::string DetailedMessage() override; 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); 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."; return "Encountered invalid version when loading.";
} }

View File

@ -10,5 +10,5 @@ public:
InvalidVersionException(unsigned int expectedVersion, unsigned int actualVersion); InvalidVersionException(unsigned int expectedVersion, unsigned int actualVersion);
std::string DetailedMessage() override; 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) + ")"; 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"; return "Zone has invalid block size";
} }

View File

@ -10,5 +10,5 @@ public:
InvalidXBlockSizeException(uint64_t size, uint64_t max); InvalidXBlockSizeException(uint64_t size, uint64_t max);
std::string DetailedMessage() override; 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 + "."; 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."; return "Invalid Zone. Out of XBlock bounds.";
} }

View File

@ -10,5 +10,5 @@ public:
explicit OutOfBlockBoundsException(XBlock* block); explicit OutOfBlockBoundsException(XBlock* block);
std::string DetailedMessage() override; 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."; 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."; return "Loaded fastfile has too many authed groups.";
} }

View File

@ -5,5 +5,5 @@ class TooManyAuthedGroupsException final : public LoadingException
{ {
public: public:
std::string DetailedMessage() override; 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"; return "Unexpected end of file";
} }
char const* UnexpectedEndOfFileException::what() const char const* UnexpectedEndOfFileException::what() const noexcept
{ {
return "Unexpected end of file"; return "Unexpected end of file";
} }

View File

@ -7,5 +7,5 @@ public:
UnexpectedEndOfFileException(); UnexpectedEndOfFileException();
std::string DetailedMessage() override; 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."; 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."; return "Zone has unsupported asset type.";
} }

View File

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

View File

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

View File

@ -2,7 +2,7 @@
#include <cassert> #include <cassert>
#include <memory> #include <memory>
#include <cstring>
#include "Game/IW4/IW4.h" #include "Game/IW4/IW4.h"
#include "Loading/Exception/InvalidHashException.h" #include "Loading/Exception/InvalidHashException.h"
@ -80,8 +80,7 @@ public:
m_hash_function->GetHashSize()) != 0) m_hash_function->GetHashSize()) != 0)
throw InvalidHashException(); throw InvalidHashException();
memcpy_s(m_chunk_hashes_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_chunk_buffer.get(), m_authed_chunk_count * m_hash_function->GetHashSize());
m_current_chunk_in_group++; m_current_chunk_in_group++;
} }
@ -122,8 +121,8 @@ public:
if (sizeToWrite > m_current_chunk_size - m_current_chunk_offset) if (sizeToWrite > m_current_chunk_size - m_current_chunk_offset)
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, assert(length - loadedSize >= sizeToWrite);
&m_chunk_buffer[m_current_chunk_offset], sizeToWrite); memcpy(&static_cast<uint8_t*>(buffer)[loadedSize], &m_chunk_buffer[m_current_chunk_offset], sizeToWrite);
loadedSize += sizeToWrite; loadedSize += sizeToWrite;
m_current_chunk_offset += sizeToWrite; m_current_chunk_offset += sizeToWrite;
} }

View File

@ -1,6 +1,7 @@
#include "ProcessorCaptureData.h" #include "ProcessorCaptureData.h"
#include <cassert> #include <cassert>
#include <cstring>
ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize) ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize)
: m_data(std::make_unique<uint8_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; dataToCapture = length;
size_t loadedSize = m_base_stream->Load(&m_data[m_captured_data_size], dataToCapture); 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; m_captured_data_size += loadedSize;

View File

@ -1,6 +1,6 @@
#include "ProcessorInflate.h" #include "ProcessorInflate.h"
#include <exception> #include <stdexcept>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include <zlib.h> #include <zlib.h>
@ -33,7 +33,7 @@ public:
if (ret != Z_OK) 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 <mutex>
#include <condition_variable> #include <condition_variable>
#include <cassert> #include <cassert>
#include <cstring>
class DBLoadStream class DBLoadStream
{ {
@ -294,14 +295,15 @@ public:
if (sizeToRead > bytesLeftInCurrentChunk) 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; loadedSize += bytesLeftInCurrentChunk;
NextStream(); NextStream();
} }
else 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; loadedSize += sizeToRead;
m_current_chunk_offset += sizeToRead; m_current_chunk_offset += sizeToRead;

View File

@ -1,7 +1,10 @@
#include "ChunkProcessorInflate.h" #include "ChunkProcessorInflate.h"
#include <stdexcept>
#include "zlib.h" #include "zlib.h"
#include "zutil.h" #include "zutil.h"
#include <exception>
#include "Loading/Exception/InvalidCompressionException.h" #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) 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); int ret = inflateInit2(&stream, -DEF_WBITS);
if(ret != Z_OK) if(ret != Z_OK)
{ {
throw std::exception("Initializing inflate failed."); throw std::runtime_error("Initializing inflate failed.");
} }
stream.avail_in = inputLength; stream.avail_in = inputLength;

View File

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

View File

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

View File

@ -1,17 +1,20 @@
#include "StepVerifyMagic.h" #include "StepVerifyMagic.h"
#include <cstring>
#include "Loading/Exception/InvalidMagicException.h" #include "Loading/Exception/InvalidMagicException.h"
StepVerifyMagic::StepVerifyMagic(const char* magic) StepVerifyMagic::StepVerifyMagic(const char* magic)
{ {
m_magic = magic; m_magic = magic;
m_magic_len = strlen(m_magic);
} }
void StepVerifyMagic::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) void StepVerifyMagic::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
{ {
const size_t magicLength = strlen(m_magic);
char currentCharacter; char currentCharacter;
for(unsigned i = 0; i < magicLength; i++) for(unsigned i = 0; i < m_magic_len; i++)
{ {
stream->Load(&currentCharacter, sizeof(char)); stream->Load(&currentCharacter, sizeof(char));

View File

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

View File

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

View File

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

View File

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