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
#include <cstdint>
#include <cstddef>
#include "DxgiFormat.h"
enum class ImageFormatId

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@
#include <cassert>
#include <sstream>
#include <cstring>
const std::string InfoString::EMPTY_VALUE;
@ -146,7 +147,7 @@ void InfoStringFromStructConverterBase::FillFromStringBuffer(const std::string&
const size_t bufferSize)
{
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));
}

View File

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

View File

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

View File

@ -10,7 +10,7 @@ const std::string& IPakLoadException::DetailedMessage() const
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.";
}

View File

@ -10,5 +10,5 @@ public:
explicit IPakLoadException(std::string message);
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 <cassert>
#include <cstring>
#include <minilzo.h>
@ -72,8 +73,8 @@ bool IPakEntryReadStream::SetChunkBufferWindow(const int64_t startPos, size_t ch
if (m_buffer_start_pos != startPos)
{
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],
static_cast<size_t>(moveEnd - startPos));
assert(IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ >= 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;
}
@ -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)
{
memmove_s(&m_chunk_buffer[m_buffer_start_pos - startPos],
IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ - static_cast<size_t>(m_buffer_start_pos - startPos),
m_chunk_buffer,
static_cast<size_t>(endPos - m_buffer_start_pos));
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));
memmove(&m_chunk_buffer[m_buffer_start_pos - startPos], m_chunk_buffer, static_cast<size_t>(endPos - m_buffer_start_pos));
const auto readChunkCount = ReadChunks(m_chunk_buffer,
startPos,
@ -151,8 +150,7 @@ bool IPakEntryReadStream::AdjustChunkBufferWindowForBlockHeader(IPakDataBlockHea
commandsSize += blockHeader->_commands[commandIndex].size;
}
const size_t requiredChunkCount = AlignForward<size_t>(
blockOffsetInChunk + sizeof IPakDataBlockHeader + commandsSize, IPAK_CHUNK_SIZE) / IPAK_CHUNK_SIZE;
const size_t requiredChunkCount = AlignForward<size_t>(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;
@ -177,7 +175,7 @@ bool IPakEntryReadStream::NextBlock()
if (m_pos >= m_end_pos)
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 blockOffsetInChunk = static_cast<size_t>(m_pos - chunkStartPos);
@ -200,7 +198,7 @@ bool IPakEntryReadStream::NextBlock()
if (!AdjustChunkBufferWindowForBlockHeader(m_current_block, blockOffsetInChunk))
return false;
m_pos += sizeof IPakDataBlockHeader;
m_pos += sizeof(IPakDataBlockHeader);
m_next_command = 0;
return true;
@ -212,7 +210,7 @@ bool IPakEntryReadStream::ProcessCommand(const size_t commandSize, const int com
{
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,
m_decompress_buffer, &outputSize, nullptr);
@ -336,8 +334,8 @@ std::streamsize IPakEntryReadStream::xsgetn(char* ptr, const std::streamsize cou
if (sizeToRead > 0)
{
memcpy_s(&destBuffer[countRead], static_cast<rsize_t>(count - countRead),
&m_current_command_buffer[m_current_command_offset], static_cast<rsize_t>(sizeToRead));
assert(static_cast<size_t>(count - countRead) >= static_cast<size_t>(sizeToRead));
memcpy(&destBuffer[countRead], &m_current_command_buffer[m_current_command_offset], static_cast<size_t>(sizeToRead));
countRead += sizeToRead;
m_current_command_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)
{
const auto riffMasterChunkSize = sizeof WAV_CHUNK_ID_RIFF
+ sizeof uint32_t
+ sizeof WAV_WAVE_ID
+ sizeof WavChunkHeader
+ sizeof WavFormatChunkPcm
+ sizeof WavChunkHeader
+ sizeof asset->sound.info.data_len;
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF)
+ sizeof(uint32_t)
+ sizeof(WAV_WAVE_ID)
+ sizeof(WavChunkHeader)
+ sizeof(WavFormatChunkPcm)
+ sizeof(WavChunkHeader)
+ 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*>(&riffMasterChunkSize), sizeof riffMasterChunkSize);
stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof WAV_WAVE_ID);
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*>(&WAV_WAVE_ID), sizeof(WAV_WAVE_ID));
const WavChunkHeader formatChunkHeader
{
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
{
@ -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.bits)
};
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof formatChunk);
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
const WavChunkHeader dataChunkHeader
{
WAV_CHUNK_ID_DATA,
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);
}

View File

@ -1,6 +1,7 @@
#include "AssetDumperRawFile.h"
#include <zlib.h>
#include <stdexcept>
using namespace IW4;
@ -31,7 +32,7 @@ void AssetDumperRawFile::DumpAsset(Zone* zone, XAssetInfo<RawFile>* asset, std::
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);

View File

@ -2,6 +2,7 @@
#include <cassert>
#include <sstream>
#include <type_traits>
#include "Game/IW4/InfoStringIW4.h"
@ -182,13 +183,13 @@ namespace IW4
switch (static_cast<VehicleFieldType>(field.iFieldType))
{
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;
case VFT_AXLE_STEERING:
case VFT_AXLE_POWER:
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;
case VFT_TROPHY_TAGS:
@ -197,7 +198,7 @@ namespace IW4
std::stringstream ss;
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]);
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)
{
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());
if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -1,7 +1,9 @@
#include "AssetDumperWeapon.h"
#include <cassert>
#include <cstring>
#include <sstream>
#include <type_traits>
#include "Game/IW4/InfoStringIW4.h"
@ -866,47 +868,47 @@ namespace IW4
switch (static_cast<weapFieldType_t>(field.iFieldType))
{
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
case WFT_BOUNCE_SOUND:
@ -934,23 +936,23 @@ namespace IW4
}
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;
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;
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;
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;
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;
case WFT_ICONRATIO_HUD:
@ -958,7 +960,7 @@ namespace IW4
case WFT_ICONRATIO_AMMOCOUNTER:
case WFT_ICONRATIO_KILL:
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;
case WFT_HIDETAGS:
@ -967,7 +969,7 @@ namespace IW4
std::stringstream ss;
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]);
if (!str.empty())
@ -988,11 +990,11 @@ namespace IW4
case WFT_NOTETRACKSOUNDMAP:
{
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;
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& value = m_get_scr_string(values[i]);
@ -1017,11 +1019,11 @@ namespace IW4
case WFT_NOTETRACKRUMBLEMAP:
{
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;
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& value = m_get_scr_string(values[i]);
@ -1070,84 +1072,92 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul
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;
}
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;
}
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;
}
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;
}
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;
}
if (fullDef->weapDef.notetrackSoundMapKeys)
{
memcpy_s(fullDef->notetrackSoundMapKeys, sizeof WeaponFullDef::notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys,
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapKeys));
assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys;
}
if (fullDef->weapDef.notetrackSoundMapValues)
{
memcpy_s(fullDef->notetrackSoundMapValues, sizeof WeaponFullDef::notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues,
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapKeys));
assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues;
}
if (fullDef->weapDef.notetrackRumbleMapKeys)
{
memcpy_s(fullDef->notetrackRumbleMapKeys, sizeof WeaponFullDef::notetrackRumbleMapKeys, fullDef->weapDef.notetrackRumbleMapKeys,
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackRumbleMapKeys));
assert(sizeof(WeaponFullDef::notetrackRumbleMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
memcpy(fullDef->notetrackRumbleMapKeys, fullDef->weapDef.notetrackRumbleMapKeys, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys;
}
if (fullDef->weapDef.notetrackRumbleMapValues)
{
memcpy_s(fullDef->notetrackRumbleMapValues, sizeof WeaponFullDef::notetrackRumbleMapValues, fullDef->weapDef.notetrackRumbleMapValues,
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackRumbleMapKeys));
assert(sizeof(WeaponFullDef::notetrackRumbleMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
memcpy(fullDef->notetrackRumbleMapValues, fullDef->weapDef.notetrackRumbleMapValues, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackRumbleMapKeys)>::value);
fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues;
}
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;
}
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;
}
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;
}
if (fullDef->weapDef.locationDamageMultipliers)
{
memcpy_s(fullDef->locationDamageMultipliers, sizeof WeaponFullDef::locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers,
sizeof(float) * _countof(WeaponFullDef::locationDamageMultipliers));
assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * std::extent<decltype(WeaponFullDef::locationDamageMultipliers)>::value);
memcpy(fullDef->locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * std::extent<decltype(WeaponFullDef::locationDamageMultipliers)>::value);
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)
{
auto* fullDef = new WeaponFullDef;
memset(fullDef, 0, sizeof WeaponFullDef);
memset(fullDef, 0, sizeof(WeaponFullDef));
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());
if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -1,6 +1,7 @@
#include "AssetDumperPhysConstraints.h"
#include <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h"
@ -110,7 +111,7 @@ namespace T6
switch (static_cast<constraintsFieldType_t>(field.iFieldType))
{
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;
case CFT_NUM:
@ -142,7 +143,7 @@ void AssetDumperPhysConstraints::DumpAsset(Zone* zone, XAssetInfo<PhysConstraint
{
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());
if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -3,6 +3,7 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <type_traits>
#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->bounce = physPreset->bounce;
if(isinf(physPreset->friction))
if(std::isinf(physPreset->friction))
{
physPresetInfo->isFrictionInfinity = 1;
physPresetInfo->friction = 0;
@ -91,7 +92,7 @@ void AssetDumperPhysPreset::DumpAsset(Zone* zone, XAssetInfo<PhysPreset>* asset,
auto* physPresetInfo = new 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());
if (scrStr >= asset->m_zone->m_script_strings.size())
@ -109,9 +110,9 @@ void AssetDumperPhysPreset::DumpAsset(Zone* zone, XAssetInfo<PhysPreset>* asset,
//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)
// {

View File

@ -1,6 +1,7 @@
#include "AssetDumperTracer.h"
#include <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h"
@ -57,7 +58,7 @@ namespace T6
switch (static_cast<tracerFieldType_t>(field.iFieldType))
{
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;
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)
{
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());
if (scrStr >= asset->m_zone->m_script_strings.size())
@ -99,22 +100,4 @@ void AssetDumperTracer::DumpAsset(Zone* zone, XAssetInfo<TracerDef>* asset, std:
const auto infoString = converter.Convert();
const auto stringValue = infoString.ToString("TRACER");
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 <cassert>
#include <type_traits>
#include "Game/T6/InfoStringT6.h"
@ -606,15 +607,15 @@ namespace T6
switch (static_cast<VehicleFieldType>(field.iFieldType))
{
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;
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;
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;
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)
{
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());
if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -2,6 +2,8 @@
#include <cassert>
#include <sstream>
#include <type_traits>
#include <cstring>
#include "Game/T6/InfoStringT6.h"
@ -1293,58 +1295,56 @@ namespace T6
switch (static_cast<weapFieldType_t>(field.iFieldType))
{
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;
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;
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;
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;
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;
case WFT_STANCE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames,
_countof(szWeapStanceNames));
std::extent<decltype(szWeapStanceNames)>::value);
break;
case WFT_PROJ_EXPLOSION:
FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames,
_countof(szProjectileExplosionNames));
std::extent<decltype(szProjectileExplosionNames)>::value);
break;
case WFT_OFFHAND_CLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames,
_countof(offhandClassNames));
std::extent<decltype(offhandClassNames)>::value);
break;
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;
case WFT_ANIMTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames,
_countof(playerAnimTypeNames));
std::extent<decltype(playerAnimTypeNames)>::value);
break;
case WFT_ACTIVE_RETICLE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames,
_countof(activeReticleNames));
std::extent<decltype(activeReticleNames)>::value);
break;
case WFT_GUIDED_MISSILE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames,
_countof(guidedMissileNames));
std::extent<decltype(guidedMissileNames)>::value);
break;
case WFT_BOUNCE_SOUND:
@ -1373,36 +1373,36 @@ namespace T6
}
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;
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;
case WFT_OVERLAYINTERFACE:
FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames,
_countof(overlayInterfaceNames));
std::extent<decltype(overlayInterfaceNames)>::value);
break;
case WFT_INVENTORYTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames,
_countof(szWeapInventoryTypeNames));
std::extent<decltype(szWeapInventoryTypeNames)>::value);
break;
case WFT_FIRETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames,
_countof(szWeapFireTypeNames));
std::extent<decltype(szWeapFireTypeNames)>::value);
break;
case WFT_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames,
_countof(szWeapClipTypeNames));
std::extent<decltype(szWeapClipTypeNames)>::value);
break;
case WFT_AMMOCOUNTER_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames,
_countof(ammoCounterClipNames));
std::extent<decltype(ammoCounterClipNames)>::value);
break;
case WFT_ICONRATIO_HUD:
@ -1411,11 +1411,11 @@ namespace T6
case WFT_ICONRATIO_DPAD:
case WFT_ICONRATIO_INDICATOR:
FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames,
_countof(weapIconRatioNames));
std::extent<decltype(weapIconRatioNames)>::value);
break;
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;
case WFT_HIDETAGS:
@ -1424,7 +1424,7 @@ namespace T6
std::stringstream ss;
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]);
if (!str.empty())
@ -1449,11 +1449,11 @@ namespace T6
case WFT_NOTETRACKSOUNDMAP:
{
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;
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& value = m_get_scr_string(values[i]);
@ -1514,99 +1514,112 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
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;
}
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;
}
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;
}
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;
}
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;
}
if (fullDef->weapDef.notetrackSoundMapKeys)
{
memcpy_s(fullDef->notetrackSoundMapKeys, sizeof WeaponFullDef::notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys,
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapKeys));
assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys;
}
if (fullDef->weapDef.notetrackSoundMapValues)
{
memcpy_s(fullDef->notetrackSoundMapValues, sizeof WeaponFullDef::notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues,
sizeof(scr_string_t) * _countof(WeaponFullDef::notetrackSoundMapValues));
assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value);
memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value);
fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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)
{
auto* fullDef = new WeaponFullDef;
memset(fullDef, 0, sizeof WeaponFullDef);
memset(fullDef, 0, sizeof(WeaponFullDef));
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());
if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -1,6 +1,7 @@
#include "AssetDumperZBarrier.h"
#include <cassert>
#include <type_traits>
#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)
{
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());
if (scrStr >= asset->m_zone->m_script_strings.size())
@ -201,9 +202,9 @@ void AssetDumperZBarrier::DumpAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset,
//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)
// {

View File

@ -61,7 +61,7 @@ void IwiWriter::WriteVersion(std::ostream& stream)
version.tag[2] = 'i';
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)
@ -105,7 +105,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
for (auto& i : header.maxGlossForMip)
i = 0;
auto currentFileSize = sizeof IwiVersion + sizeof IwiHeader;
auto currentFileSize = sizeof(IwiVersion) + sizeof(IwiHeader);
const auto textureMipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
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();
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;
}
@ -135,7 +135,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
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--)
{

View File

@ -48,21 +48,21 @@ void IwiWriter::WriteVersion(std::ostream& stream)
version.tag[2] = 'i';
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)
{
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
header->dimensions[2] = 1ui16;
header->dimensions[2] = 1u;
}
void IwiWriter::FillHeaderCube(IwiHeader* header, TextureCube* texture)
{
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
header->dimensions[2] = 1ui16;
header->dimensions[2] = 1u;
header->flags |= IMG_FLAG_MAPTYPE_CUBE;
}
@ -98,7 +98,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
if (!texture->HasMipMaps())
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;
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();
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;
}
@ -128,7 +128,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture)
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--)
{

View File

@ -1,8 +1,11 @@
#include "UnlinkerArgs.h"
#include <regex>
#include <type_traits>
#include "Utils/Arguments/UsageInformation.h"
#include "ObjLoading.h"
#include "ObjWriting.h"
#include <regex>
const CommandLineOption* const OPTION_HELP = CommandLineOption::Builder::Create()
.WithShortName("?")
@ -64,7 +67,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]
};
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_output_folder = "./%zoneName%";

View File

@ -18,6 +18,10 @@ namespace std
typedef short int16_t;
typedef int int32_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

View File

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

View File

@ -1,7 +1,10 @@
#include "GameAssetPoolIW4.h"
#include <cassert>
#include <type_traits>
#include "Pool/AssetPoolStatic.h"
#include "Pool/AssetPoolDynamic.h"
#include <cassert>
using namespace IW4;
@ -101,7 +104,7 @@ GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
: ZoneAssetPools(zone),
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_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
{
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_INVALID;

View File

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

View File

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

View File

@ -1,7 +1,10 @@
#include "GameAssetPoolT6.h"
#include <cassert>
#include <type_traits>
#include "Pool/AssetPoolStatic.h"
#include "Pool/AssetPoolDynamic.h"
#include <cassert>
using namespace T6;
@ -74,7 +77,7 @@ GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
: ZoneAssetPools(zone),
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_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
{
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_INVALID;

View File

@ -1,4 +1,7 @@
#include "GameT6.h"
#include <algorithm>
#include "T6.h"
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)
{
delete entry->m_ptr;
delete entry->Asset();
delete entry;
}

View File

@ -1,11 +1,12 @@
#pragma once
#include <cstring>
#include <stdexcept>
#include "GlobalAssetPool.h"
#include "AssetPool.h"
#include "XAssetInfo.h"
#include <cstring>
template <typename T>
class AssetPoolStatic final : public AssetPool<T>
{
@ -85,7 +86,7 @@ public:
{
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ std::string BlockOverflowException::DetailedMessage()
return "XBlock " + m_block->m_name + " overflowed while trying to load zone.";
}
char const* BlockOverflowException::what() const
char const* BlockOverflowException::what() const noexcept
{
return "Invalid Zone. XBlock overflowed.";
}

View File

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

View File

@ -24,7 +24,7 @@ std::string InvalidChunkSizeException::DetailedMessage()
}
}
char const* InvalidChunkSizeException::what() const
char const* InvalidChunkSizeException::what() const noexcept
{
return "Zone has invalid chunk size";
}

View File

@ -11,5 +11,5 @@ public:
InvalidChunkSizeException(size_t size, size_t max);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -5,7 +5,7 @@ std::string InvalidCompressionException::DetailedMessage()
return "Zone has invalid or unsupported compression. Inflate failed";
}
char const* InvalidCompressionException::what() const
char const* InvalidCompressionException::what() const noexcept
{
return "Zone has invalid or unsupported compression. Inflate failed";
}

View File

@ -5,5 +5,5 @@ class InvalidCompressionException final : public LoadingException
{
public:
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -11,7 +11,7 @@ std::string InvalidFileNameException::DetailedMessage()
return "Name verification failed: The fastfile was created as '" + m_expected_file_name + "' but loaded as '" + m_actual_file_name + "'";
}
char const* InvalidFileNameException::what() const
char const* InvalidFileNameException::what() const noexcept
{
return "The filename when created and when loaded does not match";
}

View File

@ -10,5 +10,5 @@ public:
InvalidFileNameException(std::string& actualFileName, std::string& expectedFileName);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -5,7 +5,7 @@ std::string InvalidHashException::DetailedMessage()
return "Loaded fastfile has an invalid hash.";
}
char const* InvalidHashException::what() const
char const* InvalidHashException::what() const noexcept
{
return "Loaded fastfile has an invalid hash.";
}

View File

@ -5,5 +5,5 @@ class InvalidHashException final : public LoadingException
{
public:
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -10,7 +10,7 @@ std::string InvalidMagicException::DetailedMessage()
return "Expected magic '" + std::string(m_expected_magic) + "'";
}
char const* InvalidMagicException::what() const
char const* InvalidMagicException::what() const noexcept
{
return "Encountered invalid magic when loading.";
}

View File

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

View File

@ -10,7 +10,7 @@ std::string InvalidOffsetBlockException::DetailedMessage()
return "Zone tried to reference invalid block " + std::to_string(m_referenced_block);
}
char const* InvalidOffsetBlockException::what() const
char const* InvalidOffsetBlockException::what() const noexcept
{
return "Zone referenced invalid block";
}

View File

@ -10,5 +10,5 @@ public:
explicit InvalidOffsetBlockException(block_t referencedBlock);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -12,7 +12,7 @@ std::string InvalidOffsetBlockOffsetException::DetailedMessage()
+ " which is larger than its size " + std::to_string(m_referenced_block->m_buffer_size);
}
char const* InvalidOffsetBlockOffsetException::what() const
char const* InvalidOffsetBlockOffsetException::what() const noexcept
{
return "Zone referenced offset of block that is out of bounds";
}

View File

@ -11,5 +11,5 @@ public:
InvalidOffsetBlockOffsetException(XBlock* block, size_t referencedOffset);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -5,7 +5,7 @@ std::string InvalidSignatureException::DetailedMessage()
return "Loaded fastfile has an invalid signature.";
}
char const* InvalidSignatureException::what() const
char const* InvalidSignatureException::what() const noexcept
{
return "Loaded fastfile has an invalid signature.";
}

View File

@ -5,5 +5,5 @@ class InvalidSignatureException final : public LoadingException
{
public:
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -11,7 +11,7 @@ std::string InvalidVersionException::DetailedMessage()
return "Expected version " + std::to_string(m_expected_version) + " but encountered version " + std::to_string(m_actual_version);
}
char const* InvalidVersionException::what() const
char const* InvalidVersionException::what() const noexcept
{
return "Encountered invalid version when loading.";
}

View File

@ -10,5 +10,5 @@ public:
InvalidVersionException(unsigned int expectedVersion, unsigned int actualVersion);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -11,7 +11,7 @@ std::string InvalidXBlockSizeException::DetailedMessage()
return "Zone uses more XBlock memory than allowed: " + std::to_string(m_size) + " (max is " + std::to_string(m_max) + ")";
}
char const* InvalidXBlockSizeException::what() const
char const* InvalidXBlockSizeException::what() const noexcept
{
return "Zone has invalid block size";
}

View File

@ -10,5 +10,5 @@ public:
InvalidXBlockSizeException(uint64_t size, uint64_t max);
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -10,7 +10,7 @@ std::string OutOfBlockBoundsException::DetailedMessage()
return "Tried to load to location out of bounds from current XBlock " + m_block->m_name + ".";
}
char const* OutOfBlockBoundsException::what() const
char const* OutOfBlockBoundsException::what() const noexcept
{
return "Invalid Zone. Out of XBlock bounds.";
}

View File

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

View File

@ -5,7 +5,7 @@ std::string TooManyAuthedGroupsException::DetailedMessage()
return "Loaded fastfile has too many authed groups.";
}
char const* TooManyAuthedGroupsException::what() const
char const* TooManyAuthedGroupsException::what() const noexcept
{
return "Loaded fastfile has too many authed groups.";
}

View File

@ -5,5 +5,5 @@ class TooManyAuthedGroupsException final : public LoadingException
{
public:
std::string DetailedMessage() override;
char const* what() const override;
char const* what() const noexcept override;
};

View File

@ -7,7 +7,7 @@ std::string UnexpectedEndOfFileException::DetailedMessage()
return "Unexpected end of file";
}
char const* UnexpectedEndOfFileException::what() const
char const* UnexpectedEndOfFileException::what() const noexcept
{
return "Unexpected end of file";
}

View File

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

View File

@ -10,7 +10,7 @@ std::string UnsupportedAssetTypeException::DetailedMessage()
return "Zone has an unsupported asset type " + std::to_string(m_asset_type) + " and therefore cannot be loaded.";
}
char const* UnsupportedAssetTypeException::what() const
char const* UnsupportedAssetTypeException::what() const noexcept
{
return "Zone has unsupported asset type.";
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
#include "ProcessorCaptureData.h"
#include <cassert>
#include <cstring>
ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize)
: m_data(std::make_unique<uint8_t[]>(captureSize)),
@ -23,7 +24,8 @@ size_t ProcessorCaptureData::Load(void* buffer, const size_t length)
dataToCapture = length;
size_t loadedSize = m_base_stream->Load(&m_data[m_captured_data_size], dataToCapture);
memcpy_s(buffer, length, &m_data[m_captured_data_size], loadedSize);
assert(length >= loadedSize);
memcpy(buffer, &m_data[m_captured_data_size], loadedSize);
m_captured_data_size += loadedSize;

View File

@ -1,6 +1,6 @@
#include "ProcessorInflate.h"
#include <exception>
#include <stdexcept>
#include <cstdint>
#include <memory>
#include <zlib.h>
@ -33,7 +33,7 @@ public:
if (ret != Z_OK)
{
throw std::exception("Initializing inflate failed");
throw std::runtime_error("Initializing inflate failed");
}
}

View File

@ -7,6 +7,7 @@
#include <mutex>
#include <condition_variable>
#include <cassert>
#include <cstring>
class DBLoadStream
{
@ -294,14 +295,15 @@ public:
if (sizeToRead > bytesLeftInCurrentChunk)
{
memcpy_s(bufferPos, sizeToRead, &m_current_chunk[m_current_chunk_offset], bytesLeftInCurrentChunk);
assert(sizeToRead >= bytesLeftInCurrentChunk);
memcpy(bufferPos, &m_current_chunk[m_current_chunk_offset], bytesLeftInCurrentChunk);
loadedSize += bytesLeftInCurrentChunk;
NextStream();
}
else
{
memcpy_s(bufferPos, sizeToRead, &m_current_chunk[m_current_chunk_offset], sizeToRead);
memcpy(bufferPos, &m_current_chunk[m_current_chunk_offset], sizeToRead);
loadedSize += sizeToRead;
m_current_chunk_offset += sizeToRead;

View File

@ -1,7 +1,10 @@
#include "ChunkProcessorInflate.h"
#include <stdexcept>
#include "zlib.h"
#include "zutil.h"
#include <exception>
#include "Loading/Exception/InvalidCompressionException.h"
size_t ChunkProcessorInflate::Process(int streamNumber, const uint8_t* input, const size_t inputLength, uint8_t* output, const size_t outputBufferSize)
@ -14,7 +17,7 @@ size_t ChunkProcessorInflate::Process(int streamNumber, const uint8_t* input, co
int ret = inflateInit2(&stream, -DEF_WBITS);
if(ret != Z_OK)
{
throw std::exception("Initializing inflate failed.");
throw std::runtime_error("Initializing inflate failed.");
}
stream.avail_in = inputLength;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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