diff --git a/src/ObjCommon/Image/ImageFormat.h b/src/ObjCommon/Image/ImageFormat.h index 05501f79..e49cb97f 100644 --- a/src/ObjCommon/Image/ImageFormat.h +++ b/src/ObjCommon/Image/ImageFormat.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "DxgiFormat.h" enum class ImageFormatId diff --git a/src/ObjCommon/Image/Texture.cpp b/src/ObjCommon/Image/Texture.cpp index 31d25d05..79de6811 100644 --- a/src/ObjCommon/Image/Texture.cpp +++ b/src/ObjCommon/Image/Texture.cpp @@ -1,6 +1,8 @@ #include "Texture.h" + #include #include +#include // ============================================== // ================= Texture ==================== diff --git a/src/ObjCommon/Image/TextureConverter.cpp b/src/ObjCommon/Image/TextureConverter.cpp index 5157492f..7a9cf0e1 100644 --- a/src/ObjCommon/Image/TextureConverter.cpp +++ b/src/ObjCommon/Image/TextureConverter.cpp @@ -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; diff --git a/src/ObjCommon/Utils/FileToZlibWrapper.cpp b/src/ObjCommon/Utils/FileToZlibWrapper.cpp index 02eebde9..60bf8525 100644 --- a/src/ObjCommon/Utils/FileToZlibWrapper.cpp +++ b/src/ObjCommon/Utils/FileToZlibWrapper.cpp @@ -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: diff --git a/src/ObjCommon/Utils/InfoString.cpp b/src/ObjCommon/Utils/InfoString.cpp index 45f3a114..8147e209 100644 --- a/src/ObjCommon/Utils/InfoString.cpp +++ b/src/ObjCommon/Utils/InfoString.cpp @@ -2,6 +2,7 @@ #include #include +#include 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(reinterpret_cast(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)); } diff --git a/src/ObjCommon/Utils/ObjStream.h b/src/ObjCommon/Utils/ObjStream.h index 9393fc1a..acb672ab 100644 --- a/src/ObjCommon/Utils/ObjStream.h +++ b/src/ObjCommon/Utils/ObjStream.h @@ -3,12 +3,12 @@ #pragma once #include - -#include "Utils/ClassUtils.h" #include #include #include +#include "Utils/ClassUtils.h" + template class basic_objbuf : public std::basic_streambuf { @@ -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); diff --git a/src/ObjLoading/Image/IwiLoader.cpp b/src/ObjLoading/Image/IwiLoader.cpp index 87acf744..38a9d8e0 100644 --- a/src/ObjLoading/Image/IwiLoader.cpp +++ b/src/ObjLoading/Image/IwiLoader.cpp @@ -1,6 +1,9 @@ #include "IwiLoader.h" -#include "Image/IwiTypes.h" + #include +#include + +#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(&header), sizeof header); - if (stream.gcount() != sizeof header) + stream.read(reinterpret_cast(&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(_countof(iwi8::IwiHeader::fileSizeForPicmip)) + if (currentMipLevel < static_cast(std::extent::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(&header), sizeof header); - if (stream.gcount() != sizeof header) + stream.read(reinterpret_cast(&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(_countof(iwi27::IwiHeader::fileSizeForPicmip)) + if (currentMipLevel < static_cast(std::extent::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(&iwiVersion), sizeof iwiVersion); - if (stream.gcount() != sizeof iwiVersion) + stream.read(reinterpret_cast(&iwiVersion), sizeof(iwiVersion)); + if (stream.gcount() != sizeof(iwiVersion)) return nullptr; if (iwiVersion.tag[0] != 'I' diff --git a/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.cpp b/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.cpp index a1512633..5d74b767 100644 --- a/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.cpp +++ b/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.h b/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.h index d6110410..ab899daa 100644 --- a/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.h +++ b/src/ObjLoading/ObjContainer/IPak/Exception/IPakLoadException.h @@ -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; }; diff --git a/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp b/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp index 075723de..a5512f23 100644 --- a/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp +++ b/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp @@ -1,6 +1,7 @@ #include "IPakEntryReadStream.h" #include +#include #include @@ -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(moveEnd - startPos)); + assert(IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ >= static_cast(moveEnd - startPos)); + memmove(m_chunk_buffer, &m_chunk_buffer[startPos - m_buffer_start_pos], static_cast(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(m_buffer_start_pos - startPos), - m_chunk_buffer, - static_cast(endPos - m_buffer_start_pos)); + assert(IPAK_CHUNK_SIZE * IPAK_CHUNK_COUNT_PER_READ - static_cast(m_buffer_start_pos - startPos) >= static_cast(endPos - m_buffer_start_pos)); + memmove(&m_chunk_buffer[m_buffer_start_pos - startPos], m_chunk_buffer, static_cast(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( - blockOffsetInChunk + sizeof IPakDataBlockHeader + commandsSize, IPAK_CHUNK_SIZE) / IPAK_CHUNK_SIZE; + const size_t requiredChunkCount = AlignForward(blockOffsetInChunk + sizeof(IPakDataBlockHeader) + commandsSize, IPAK_CHUNK_SIZE) / IPAK_CHUNK_SIZE; const size_t amountOfReadChunks = static_cast(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(m_pos, sizeof IPakDataBlockHeader); + m_pos = AlignForward(m_pos, sizeof(IPakDataBlockHeader)); const auto chunkStartPos = AlignBackwards(m_pos, IPAK_CHUNK_SIZE); const auto blockOffsetInChunk = static_cast(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(count - countRead), - &m_current_command_buffer[m_current_command_offset], static_cast(sizeToRead)); + assert(static_cast(count - countRead) >= static_cast(sizeToRead)); + memcpy(&destBuffer[countRead], &m_current_command_buffer[m_current_command_offset], static_cast(sizeToRead)); countRead += sizeToRead; m_current_command_offset += sizeToRead; m_file_offset += sizeToRead; diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp index 9a5f18c9..3078158e 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp @@ -16,24 +16,24 @@ std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfosound.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(&WAV_CHUNK_ID_RIFF), sizeof WAV_CHUNK_ID_RIFF); - stream.write(reinterpret_cast(&riffMasterChunkSize), sizeof riffMasterChunkSize); - stream.write(reinterpret_cast(&WAV_WAVE_ID), sizeof WAV_WAVE_ID); + stream.write(reinterpret_cast(&WAV_CHUNK_ID_RIFF), sizeof(WAV_CHUNK_ID_RIFF)); + stream.write(reinterpret_cast(&riffMasterChunkSize), sizeof(riffMasterChunkSize)); + stream.write(reinterpret_cast(&WAV_WAVE_ID), sizeof(WAV_WAVE_ID)); const WavChunkHeader formatChunkHeader { WAV_CHUNK_ID_FMT, - sizeof WavFormatChunkPcm + sizeof(WavFormatChunkPcm) }; - stream.write(reinterpret_cast(&formatChunkHeader), sizeof formatChunkHeader); + stream.write(reinterpret_cast(&formatChunkHeader), sizeof(formatChunkHeader)); WavFormatChunkPcm formatChunk { @@ -44,14 +44,14 @@ void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, st static_cast(asset->sound.info.block_size), static_cast(asset->sound.info.bits) }; - stream.write(reinterpret_cast(&formatChunk), sizeof formatChunk); + stream.write(reinterpret_cast(&formatChunk), sizeof(formatChunk)); const WavChunkHeader dataChunkHeader { WAV_CHUNK_ID_DATA, asset->sound.info.data_len }; - stream.write(reinterpret_cast(&dataChunkHeader), sizeof dataChunkHeader); + stream.write(reinterpret_cast(&dataChunkHeader), sizeof(dataChunkHeader)); stream.write(asset->sound.data, asset->sound.info.data_len); } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp index e1bdd422..3d2262f4 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp @@ -1,6 +1,7 @@ #include "AssetDumperRawFile.h" #include +#include using namespace IW4; @@ -31,7 +32,7 @@ void AssetDumperRawFile::DumpAsset(Zone* zone, XAssetInfo* asset, std:: if (ret != Z_OK) { - throw std::exception("Initializing inflate failed"); + throw std::runtime_error("Initializing inflate failed"); } zs.next_in = reinterpret_cast(rawFile->data.compressedBuffer); diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp index 86cb015c..5d17d35c 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "Game/IW4/InfoStringIW4.h" @@ -182,13 +183,13 @@ namespace IW4 switch (static_cast(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::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::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::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* 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::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()) diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp index 425a23da..2bc196e3 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp @@ -1,7 +1,9 @@ #include "AssetDumperWeapon.h" #include +#include #include +#include #include "Game/IW4/InfoStringIW4.h" @@ -866,47 +868,47 @@ namespace IW4 switch (static_cast(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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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(reinterpret_cast(m_structure) + field.iOffset); - const auto* values = &keys[_countof(WeaponFullDef::notetrackSoundMapKeys)]; + const auto* values = &keys[std::extent::value]; std::stringstream ss; bool first = true; - for (auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++) + for (auto i = 0u; i < std::extent::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(reinterpret_cast(m_structure) + field.iOffset); - const auto* values = &keys[_countof(WeaponFullDef::notetrackRumbleMapKeys)]; + const auto* values = &keys[std::extent::value]; std::stringstream ss; bool first = true; - for (auto i = 0u; i < _countof(WeaponFullDef::notetrackRumbleMapKeys); i++) + for (auto i = 0u; i < std::extent::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::value); + memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->notetrackRumbleMapKeys, fullDef->weapDef.notetrackRumbleMapKeys, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->notetrackRumbleMapValues, fullDef->weapDef.notetrackRumbleMapValues, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent::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::value); + memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * std::extent::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::value); + memcpy(fullDef->locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * std::extent::value); fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; } } @@ -1165,10 +1175,10 @@ std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo* 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::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()) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp index 81fb7499..bc752313 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp @@ -1,6 +1,7 @@ #include "AssetDumperPhysConstraints.h" #include +#include #include "Game/T6/InfoStringT6.h" @@ -110,7 +111,7 @@ namespace T6 switch (static_cast(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::value); break; case CFT_NUM: @@ -142,7 +143,7 @@ void AssetDumperPhysConstraints::DumpAsset(Zone* zone, XAssetInfoAsset()->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::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()) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp index 2d747dea..029022cc 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #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* 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::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* asset, //void AssetDumperPhysPreset::CheckFields() //{ -// assert(_countof(physpreset_fields) == _countof(fields222)); +// assert(std::extent::value == std::extent::value); // -// for(auto i = 0u; i < _countof(physpreset_fields); i++) +// for(auto i = 0u; i < std::extent::value; i++) // { // if(physpreset_fields[i].iOffset != fields222[i].iOffset) // { diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp index 42bfde7b..17d66e17 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp @@ -1,6 +1,7 @@ #include "AssetDumperTracer.h" #include +#include #include "Game/T6/InfoStringT6.h" @@ -57,7 +58,7 @@ namespace T6 switch (static_cast(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::value); break; case TFT_NUM_FIELD_TYPES: @@ -87,7 +88,7 @@ std::string AssetDumperTracer::GetFileNameForAsset(Zone* zone, XAssetInfo* 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::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* 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); -//} \ No newline at end of file +} \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp index 3c1ea563..0698a929 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp @@ -1,6 +1,7 @@ #include "AssetDumperVehicle.h" #include +#include #include "Game/T6/InfoStringT6.h" @@ -606,15 +607,15 @@ namespace T6 switch (static_cast(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::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::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::value); break; case VFT_MPH_TO_INCHES_PER_SECOND: @@ -682,7 +683,7 @@ std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo* 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::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()) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp index af93bd22..e744da83 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include "Game/T6/InfoStringT6.h" @@ -1293,58 +1295,56 @@ namespace T6 switch (static_cast(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::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::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::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::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::value); break; case WFT_STANCE: FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, - _countof(szWeapStanceNames)); + std::extent::value); break; case WFT_PROJ_EXPLOSION: FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, - _countof(szProjectileExplosionNames)); + std::extent::value); break; case WFT_OFFHAND_CLASS: FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, - _countof(offhandClassNames)); + std::extent::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::value); break; case WFT_ANIMTYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, - _countof(playerAnimTypeNames)); + std::extent::value); break; case WFT_ACTIVE_RETICLE_TYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, - _countof(activeReticleNames)); + std::extent::value); break; case WFT_GUIDED_MISSILE_TYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, - _countof(guidedMissileNames)); + std::extent::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::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::value); break; case WFT_OVERLAYINTERFACE: FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, - _countof(overlayInterfaceNames)); + std::extent::value); break; case WFT_INVENTORYTYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, - _countof(szWeapInventoryTypeNames)); + std::extent::value); break; case WFT_FIRETYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, - _countof(szWeapFireTypeNames)); + std::extent::value); break; case WFT_CLIPTYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames, - _countof(szWeapClipTypeNames)); + std::extent::value); break; case WFT_AMMOCOUNTER_CLIPTYPE: FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, - _countof(ammoCounterClipNames)); + std::extent::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::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::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::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(reinterpret_cast(m_structure) + field.iOffset); - const auto* values = &keys[_countof(WeaponFullDef::notetrackSoundMapKeys)]; + const auto* values = &keys[std::extent::value]; std::stringstream ss; bool first = true; - for (auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++) + for (auto i = 0u; i < std::extent::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::value); + memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, sizeof(scr_string_t) * std::extent::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::value); + memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent::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::value); + memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent::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::value); } } @@ -1623,10 +1636,10 @@ std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo* 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::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()) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp index 276ea319..7f8bea81 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp @@ -1,6 +1,7 @@ #include "AssetDumperZBarrier.h" #include +#include #include "Game/T6/InfoStringT6.h" @@ -185,7 +186,7 @@ std::string AssetDumperZBarrier::GetFileNameForAsset(Zone* zone, XAssetInfo* 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::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* asset, //void AssetDumperZBarrier::CheckFields() //{ -// assert(_countof(zbarrier_fields) == _countof(fields222)); +// assert(std::extent::value == std::extent::value); // -// for(auto i = 0u; i < _countof(zbarrier_fields); i++) +// for(auto i = 0u; i < std::extent::value; i++) // { // if(zbarrier_fields[i].iOffset != fields222[i].iOffset) // { diff --git a/src/ObjWriting/Image/IwiWriter27.cpp b/src/ObjWriting/Image/IwiWriter27.cpp index c318f846..f10fd8a3 100644 --- a/src/ObjWriting/Image/IwiWriter27.cpp +++ b/src/ObjWriting/Image/IwiWriter27.cpp @@ -61,7 +61,7 @@ void IwiWriter::WriteVersion(std::ostream& stream) version.tag[2] = 'i'; version.version = 27; - stream.write(reinterpret_cast(&version), sizeof IwiVersion); + stream.write(reinterpret_cast(&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(_countof(iwi27::IwiHeader::fileSizeForPicmip))) + if (currentMipLevel < static_cast(std::extent::value)) header.fileSizeForPicmip[currentMipLevel] = currentFileSize; } @@ -135,7 +135,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture) return; } - stream.write(reinterpret_cast(&header), sizeof IwiHeader); + stream.write(reinterpret_cast(&header), sizeof(IwiHeader)); for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--) { diff --git a/src/ObjWriting/Image/IwiWriter8.cpp b/src/ObjWriting/Image/IwiWriter8.cpp index 8378de20..6d36def7 100644 --- a/src/ObjWriting/Image/IwiWriter8.cpp +++ b/src/ObjWriting/Image/IwiWriter8.cpp @@ -48,21 +48,21 @@ void IwiWriter::WriteVersion(std::ostream& stream) version.tag[2] = 'i'; version.version = 8; - stream.write(reinterpret_cast(&version), sizeof IwiVersion); + stream.write(reinterpret_cast(&version), sizeof(IwiVersion)); } void IwiWriter::FillHeader2D(IwiHeader* header, Texture2D* texture) { header->dimensions[0] = static_cast(texture->GetWidth()); header->dimensions[1] = static_cast(texture->GetHeight()); - header->dimensions[2] = 1ui16; + header->dimensions[2] = 1u; } void IwiWriter::FillHeaderCube(IwiHeader* header, TextureCube* texture) { header->dimensions[0] = static_cast(texture->GetWidth()); header->dimensions[1] = static_cast(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(_countof(iwi27::IwiHeader::fileSizeForPicmip))) + if (currentMipLevel < static_cast(std::extent::value)) header.fileSizeForPicmip[currentMipLevel] = currentFileSize; } @@ -128,7 +128,7 @@ void IwiWriter::DumpImage(std::ostream& stream, Texture* texture) return; } - stream.write(reinterpret_cast(&header), sizeof IwiHeader); + stream.write(reinterpret_cast(&header), sizeof(IwiHeader)); for (auto currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--) { diff --git a/src/Unlinker/UnlinkerArgs.cpp b/src/Unlinker/UnlinkerArgs.cpp index 6091ab27..395da9b4 100644 --- a/src/Unlinker/UnlinkerArgs.cpp +++ b/src/Unlinker/UnlinkerArgs.cpp @@ -1,8 +1,11 @@ #include "UnlinkerArgs.h" + +#include +#include + #include "Utils/Arguments/UsageInformation.h" #include "ObjLoading.h" #include "ObjWriting.h" -#include 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::value) { m_task = ProcessingTask::DUMP; m_output_folder = "./%zoneName%"; diff --git a/src/ZoneCode/Game/Common.h b/src/ZoneCode/Game/Common.h index 1f35d05c..dd9fe65f 100644 --- a/src/ZoneCode/Game/Common.h +++ b/src/ZoneCode/Game/Common.h @@ -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 diff --git a/src/ZoneCommon.lua b/src/ZoneCommon.lua index 3ae750b1..d8d82ddb 100644 --- a/src/ZoneCommon.lua +++ b/src/ZoneCommon.lua @@ -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 diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index 9cae165a..875bf1a7 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -1,7 +1,10 @@ #include "GameAssetPoolIW4.h" + +#include +#include + #include "Pool/AssetPoolStatic.h" #include "Pool/AssetPoolDynamic.h" -#include 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::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(_countof(ASSET_TYPE_NAMES))) + if (assetType >= 0 && assetType < static_cast(std::extent::value)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/IW4/GameIW4.cpp b/src/ZoneCommon/Game/IW4/GameIW4.cpp index b71e5c8a..c642edc2 100644 --- a/src/ZoneCommon/Game/IW4/GameIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameIW4.cpp @@ -1,4 +1,7 @@ #include "GameIW4.h" + +#include + #include "IW4.h" using namespace IW4; diff --git a/src/ZoneCommon/Game/IW4/IW4_Assets.h b/src/ZoneCommon/Game/IW4/IW4_Assets.h index dfada37b..bf56677b 100644 --- a/src/ZoneCommon/Game/IW4/IW4_Assets.h +++ b/src/ZoneCommon/Game/IW4/IW4_Assets.h @@ -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; diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp index 52cb529e..c6c8dd0c 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp @@ -1,7 +1,10 @@ #include "GameAssetPoolT6.h" + +#include +#include + #include "Pool/AssetPoolStatic.h" #include "Pool/AssetPoolDynamic.h" -#include 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::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(_countof(ASSET_TYPE_NAMES))) + if (assetType >= 0 && assetType < static_cast(std::extent::value)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/T6/GameT6.cpp b/src/ZoneCommon/Game/T6/GameT6.cpp index ff4bb25e..d1e2cd8b 100644 --- a/src/ZoneCommon/Game/T6/GameT6.cpp +++ b/src/ZoneCommon/Game/T6/GameT6.cpp @@ -1,4 +1,7 @@ #include "GameT6.h" + +#include + #include "T6.h" using namespace T6; diff --git a/src/ZoneCommon/Game/T6/T6_Assets.h b/src/ZoneCommon/Game/T6/T6_Assets.h index 8c662a6c..781f1bf2 100644 --- a/src/ZoneCommon/Game/T6/T6_Assets.h +++ b/src/ZoneCommon/Game/T6/T6_Assets.h @@ -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 @@ -477,15 +477,15 @@ namespace T6 struct PhysConstraint { - unsigned __int16 targetname; + uint16_t targetname; ConstraintType type; AttachPointType attach_point_type1; int target_index1; - unsigned __int16 target_ent1; + uint16_t target_ent1; const char* target_bone1; AttachPointType attach_point_type2; int target_index2; - unsigned __int16 target_ent2; + uint16_t target_ent2; const char* target_bone2; vec3_t offset; vec3_t pos; @@ -531,7 +531,7 @@ namespace T6 union XAnimIndices { char* _1; - unsigned __int16* _2; + uint16_t* _2; void* data; }; @@ -539,12 +539,12 @@ namespace T6 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; bool bLoop; bool bDelta; bool bDelta3D; @@ -560,11 +560,11 @@ namespace T6 float frequency; float primedLength; float loopEntryTime; - 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; @@ -576,8 +576,8 @@ namespace T6 struct XModelLodInfo { float dist; - unsigned __int16 numsurfs; - unsigned __int16 surfIndex; + uint16_t numsurfs; + uint16_t surfIndex; int partBits[5]; }; @@ -589,9 +589,9 @@ namespace T6 unsigned char numRootBones; unsigned char numsurfs; char lodRampType; - unsigned __int16* boneNames; + uint16_t* boneNames; char* parentList; - __int16 (*quats)[4]; + int16_t (*quats)[4]; float (*trans)[4]; char* partClassification; DObjAnimMat* baseMat; @@ -605,8 +605,8 @@ namespace T6 float radius; vec3_t mins; vec3_t maxs; - __int16 numLods; - __int16 collLod; + int16_t numLods; + int16_t collLod; float* himipInvSqRadii; int memUsage; int flags; @@ -622,22 +622,22 @@ namespace T6 struct GfxDrawSurfFields { - unsigned __int64 objectId : 16; - unsigned __int64 customIndex : 9; - unsigned __int64 reflectionProbeIndex : 5; - unsigned __int64 dlightMask : 2; - unsigned __int64 materialSortedIndex : 12; - unsigned __int64 primaryLightIndex : 8; - unsigned __int64 surfType : 4; - unsigned __int64 prepass : 2; - unsigned __int64 primarySortKey : 6; + uint64_t objectId : 16; + uint64_t customIndex : 9; + uint64_t reflectionProbeIndex : 5; + uint64_t dlightMask : 2; + uint64_t materialSortedIndex : 12; + uint64_t primaryLightIndex : 8; + uint64_t surfType : 4; + uint64_t prepass : 2; + uint64_t primarySortKey : 6; }; union GfxDrawSurf { GfxDrawSurfFields fields; - unsigned __int64 packed; + uint64_t packed; }; @@ -652,7 +652,7 @@ namespace T6 GfxDrawSurf drawSurf; unsigned int surfaceTypeBits; unsigned int layeredSurfaceTypes; - unsigned __int16 hashIndex; + uint16_t hashIndex; int surfaceFlags; int contents; }; @@ -752,15 +752,15 @@ namespace T6 { unsigned int levelCountAndSize; unsigned int hash; - unsigned __int16 width; - unsigned __int16 height; - unsigned __int32 offset : 32; - unsigned __int32 size : 28; - unsigned __int32 ipakIndex : 4; - unsigned __int32 adjacentLeft : 15; - unsigned __int32 adjacentRight : 15; - unsigned __int32 compressed : 1; - unsigned __int32 valid : 1; + uint16_t width; + uint16_t height; + uint32_t offset : 32; + uint32_t size : 28; + uint32_t ipakIndex : 4; + uint32_t adjacentLeft : 15; + uint32_t adjacentRight : 15; + uint32_t compressed : 1; + uint32_t valid : 1; }; @@ -775,9 +775,9 @@ namespace T6 bool noPicmip; char track; CardMemory cardMemory; - unsigned __int16 width; - unsigned __int16 height; - unsigned __int16 depth; + uint16_t width; + uint16_t height; + uint16_t depth; char levelCount; char streaming; unsigned int baseSize; @@ -801,9 +801,9 @@ namespace T6 unsigned int entryCount; unsigned int dependencyCount; unsigned int pad32; - __int64 fileSize; - __int64 entryOffset; - __int64 checksumOffset; + int64_t fileSize; + int64_t entryOffset; + int64_t checksumOffset; char checksumChecksum[16]; char dependencies[512]; char padding[1464]; @@ -903,8 +903,8 @@ namespace T6 unsigned int numBrushVerts; vec3_t* brushVerts; unsigned int nuinds; - unsigned __int16* uinds; - unsigned __int16 numBrushes; + uint16_t* uinds; + uint16_t numBrushes; cbrush_array_t* brushes; BoundsArray* brushBounds; int* brushContents; @@ -913,14 +913,14 @@ namespace T6 struct alignas(4) cLeaf_s { - unsigned __int16 firstCollAabbIndex; - unsigned __int16 collAabbCount; + uint16_t firstCollAabbIndex; + uint16_t collAabbCount; int brushContents; int terrainContents; vec3_t mins; vec3_t maxs; int leafBrushNode; - __int16 cluster; + int16_t cluster; }; @@ -949,7 +949,7 @@ namespace T6 unsigned int vertCount; vec3_t* verts; int triCount; - unsigned __int16 (*triIndices)[3]; + uint16_t (*triIndices)[3]; char* triEdgeIsWalkable; // Saved as 1 bit per edge rounded up to the next 4 bytes int partitionCount; CollisionPartition* partitions; @@ -964,8 +964,8 @@ namespace T6 MapEnts* mapEnts; cbrush_t* box_brush; cmodel_t box_model; - unsigned __int16 originalDynEntCount; - unsigned __int16 dynEntCount[4]; + uint16_t originalDynEntCount; + uint16_t dynEntCount[4]; DynEntityDef* dynEntDefList[2]; DynEntityPose* dynEntPoseList[2]; DynEntityClient* dynEntClientList[2]; @@ -1119,7 +1119,7 @@ namespace T6 { int cellCount; cplane_s* planes; - unsigned __int16* nodes; + uint16_t* nodes; unsigned int* sceneEntCellBits; }; @@ -1153,7 +1153,7 @@ namespace T6 unsigned int vertexDataSize1; GfxWorldVertexData1 vd1; int indexCount; - unsigned __int16* indices; + uint16_t* indices; void/*ID3D11Buffer*/* indexBuffer; }; @@ -1163,12 +1163,12 @@ namespace T6 struct GfxLightGrid { unsigned int sunPrimaryLightIndex; - unsigned __int16 mins[3]; - unsigned __int16 maxs[3]; + uint16_t mins[3]; + uint16_t maxs[3]; float offset; unsigned int rowAxis; unsigned int colAxis; - unsigned __int16* rowDataStart; + uint16_t* rowDataStart; unsigned int rawRowDataSize; aligned_byte_pointer* rawRowData; unsigned int entryCount; @@ -1229,7 +1229,7 @@ namespace T6 raw_byte128* surfaceVisData[3]; raw_byte128* smodelVisDataCameraSaved; raw_byte128* surfaceVisDataCameraSaved; - unsigned __int16* sortedSurfIndex; + uint16_t* sortedSurfIndex; GfxStaticModelInst* smodelInsts; GfxSurface* surfaces; GfxStaticModelDrawInst* smodelDrawInsts; @@ -1460,8 +1460,8 @@ namespace T6 GenericEventHandler* onEvent; ItemKeyHandler* onKey; ExpressionStatement visibleExp; - unsigned __int64 showBits; - unsigned __int64 hideBits; + uint64_t showBits; + uint64_t hideBits; const char* allowedBinding; const char* soundName; int imageTrack; @@ -1665,7 +1665,7 @@ namespace T6 unsigned int altWeaponIndex; const char* szDualWieldWeaponName; unsigned int dualWieldWeaponIndex; - unsigned __int16* hideTags; + uint16_t* hideTags; XModel* viewModel; XModel* viewModelAdditional; XModel* viewModelADS; @@ -1779,14 +1779,14 @@ namespace T6 }; - const struct FxEffectDef + struct FxEffectDef { const char* name; - unsigned __int16 flags; + uint16_t flags; char efPriority; - __int16 elemDefCountLooping; - __int16 elemDefCountOneShot; - __int16 elemDefCountEmission; + int16_t elemDefCountLooping; + int16_t elemDefCountOneShot; + int16_t elemDefCountEmission; int totalSize; int msecLoopingLife; int msecNonLoopingLife; @@ -1821,7 +1821,7 @@ namespace T6 int columnCount; int rowCount; StringTableCell* values; - __int16* cellIndex; + int16_t* cellIndex; }; @@ -1944,8 +1944,8 @@ namespace T6 int unlockPLevel; int unclassifyAt; int sortKey; - unsigned __int16 iconType; - unsigned __int16 category; + uint16_t iconType; + uint16_t category; }; @@ -1958,7 +1958,7 @@ namespace T6 int unlockPLevel; int unclassifyAt; int sortKey; - unsigned __int16 bgCategory; + uint16_t bgCategory; int mtxIndex; }; @@ -1979,7 +1979,7 @@ namespace T6 int backgroundCount; EmblemBackground* backgrounds; int backgroundLookupCount; - __int16* backgroundLookup; + int16_t* backgroundLookup; }; @@ -2229,7 +2229,7 @@ namespace T6 struct VehicleDef { const char* name; - __int16 type; + int16_t type; int remoteControl; int bulletDamage; int armorPiercingDamage; @@ -2237,7 +2237,7 @@ namespace T6 int projectileDamage; int projectileSplashDamage; int heavyExplosiveDamage; - __int16 cameraMode; + int16_t cameraMode; int autoRecenterOnAccel; int thirdPersonDriver; int thirdPersonUseVehicleRoll; @@ -2303,7 +2303,7 @@ namespace T6 int turretClampPlayerView; int turretLockTurretToPlayerView; const char* gunnerWeapon[4]; - unsigned __int16 gunnerWeaponIndex[4]; + uint16_t gunnerWeaponIndex[4]; float gunnerRotRate; vec2_t gunnerRestAngles[4]; view_limits_t passengerViewLimits[6]; @@ -2318,12 +2318,12 @@ namespace T6 const char* animSet; int scriptedAnimationEntry; float mantleAngles[4]; - unsigned __int16 extraWheelTags[4]; - unsigned __int16 driverHideTag; + uint16_t extraWheelTags[4]; + uint16_t driverHideTag; XModel* attachmentModels[4]; - unsigned __int16 attachmentTags[4]; + uint16_t attachmentTags[4]; XModel* deathAttachmentModels[4]; - unsigned __int16 deathAttachmentTags[4]; + uint16_t deathAttachmentTags[4]; float tracerOffset[2]; XModel* model; XModel* viewModel; @@ -2334,14 +2334,14 @@ namespace T6 int oneExhaust; FxEffectDef* treadFx[32]; FxEffectDef* deathFx; - unsigned __int16 deathFxTag; + uint16_t deathFxTag; const char* deathFxSound; FxEffectDef* lightFx[4]; - unsigned __int16 lightFxTag[4]; + uint16_t lightFxTag[4]; FxEffectDef* friendlyLightFx; - unsigned __int16 friendlyLightFxTag; + uint16_t friendlyLightFxTag; FxEffectDef* enemyLightFx; - unsigned __int16 enemyLightFxTag; + uint16_t enemyLightFxTag; float radiusDamageMin; float radiusDamageMax; float radiusDamageRadius; @@ -2554,8 +2554,8 @@ namespace T6 unsigned int pauseAndRepeatRepSound; float minPause; float maxPause; - unsigned __int16 zombieBoardTearStateName; - unsigned __int16 zombieBoardTearSubStateName; + uint16_t zombieBoardTearStateName; + uint16_t zombieBoardTearSubStateName; unsigned int numRepsToPullProBoard; }; @@ -2579,8 +2579,8 @@ namespace T6 unsigned int autoHideOpenPieces; unsigned int taunts; unsigned int reachThroughAttacks; - unsigned __int16 zombieTauntAnimState; - unsigned __int16 zombieReachThroughAnimState; + uint16_t zombieTauntAnimState; + uint16_t zombieReachThroughAnimState; int numAttackSlots; float attackSpotHorzOffset; ZBarrierBoard boards[6]; @@ -2596,7 +2596,7 @@ namespace T6 struct DestructibleStage { - unsigned __int16 showBone; + uint16_t showBone; float breakHealth; float maxTime; unsigned int flags; @@ -2624,14 +2624,14 @@ namespace T6 const char* damageSound; FxEffectDef* burnEffect; const char* burnSound; - unsigned __int16 enableLabel; + uint16_t enableLabel; int hideBones[5]; }; struct XAnimNotifyInfo { - unsigned __int16 name; + uint16_t name; float time; }; @@ -2654,8 +2654,8 @@ namespace T6 struct XSurfaceVertexInfo { - __int16 vertCount[4]; - unsigned __int16* vertsBlend; + int16_t vertCount[4]; + uint16_t* vertsBlend; float* tensionData; }; @@ -2666,10 +2666,10 @@ namespace T6 { char tileMode; unsigned char vertListCount; - unsigned __int16 flags; - unsigned __int16 vertCount; - unsigned __int16 triCount; - unsigned __int16 baseVertIndex; + uint16_t flags; + uint16_t vertCount; + uint16_t triCount; + uint16_t baseVertIndex; r_index16_t (*triIndices)[3]; XSurfaceVertexInfo vertInfo; GfxPackedVertex* verts0; @@ -2772,8 +2772,8 @@ namespace T6 struct MaterialTechnique { const char* name; - unsigned __int16 flags; - unsigned __int16 passCount; + uint16_t flags; + uint16_t passCount; MaterialPass passArray[1]; }; @@ -2808,8 +2808,8 @@ namespace T6 struct alignas(4) SndIndexEntry { - unsigned __int16 value; - unsigned __int16 next; + uint16_t value; + uint16_t next; }; @@ -2911,7 +2911,7 @@ namespace T6 { float dist; float range; - unsigned __int16 childOffset[2]; + uint16_t childOffset[2]; }; @@ -2925,7 +2925,7 @@ namespace T6 struct cLeafBrushNode_s { char axis; - __int16 leafBrushCount; + int16_t leafBrushCount; int contents; cLeafBrushNodeData_t data; }; @@ -2954,7 +2954,7 @@ namespace T6 struct cStaticModelWritable { - unsigned __int16 nextModelInWorldSector; + uint16_t nextModelInWorldSector; }; @@ -2973,11 +2973,11 @@ namespace T6 struct cNode_t { cplane_s* plane; - __int16 children[2]; + int16_t children[2]; }; - const struct CollisionPartition + struct CollisionPartition { char triCount; int firstTri; @@ -2996,8 +2996,8 @@ namespace T6 struct alignas(16) CollisionAabbTree { vec3_t origin; - unsigned __int16 materialIndex; - unsigned __int16 childCount; + uint16_t materialIndex; + uint16_t childCount; vec3_t halfSize; CollisionAabbTreeIndex u; }; @@ -3025,18 +3025,18 @@ namespace T6 GfxPlacement pose; XModel* xModel; XModel* destroyedxModel; - unsigned __int16 brushModel; - unsigned __int16 physicsBrushModel; + uint16_t brushModel; + uint16_t physicsBrushModel; FxEffectDef* destroyFx; unsigned int destroySound; XModelPieces* destroyPieces; PhysPreset* physPreset; - __int16 physConstraints[4]; + int16_t physConstraints[4]; int health; int flags; int contents; - unsigned __int16 targetname; - unsigned __int16 target; + uint16_t targetname; + uint16_t target; }; @@ -3050,26 +3050,26 @@ namespace T6 struct DynEntityClient { int physObjId; - unsigned __int16 flags; - unsigned __int16 lightingHandle; + uint16_t flags; + uint16_t lightingHandle; int health; - unsigned __int16 burnTime; - unsigned __int16 fadeTime; + uint16_t burnTime; + uint16_t fadeTime; int physicsStartTime; }; struct DynEntityServer { - unsigned __int16 flags; + uint16_t flags; int health; }; struct DynEntityColl { - unsigned __int16 sector; - unsigned __int16 nextEntInSector; + uint16_t sector; + uint16_t nextEntInSector; vec3_t linkMins; vec3_t linkMaxs; int contents; @@ -3147,7 +3147,7 @@ namespace T6 int m_frame; int m_stable_count; int m_static_rope; - unsigned __int16 m_lightingHandle; + uint16_t m_lightingHandle; }; @@ -3157,7 +3157,7 @@ namespace T6 char canUseShadowMap; char exponent; char priority; - __int16 cullDist; + int16_t cullDist; char useCookie; char shadowmapVolume; vec3_t color; @@ -3215,27 +3215,27 @@ namespace T6 { nodeType type; int spawnflags; - unsigned __int16 targetname; - unsigned __int16 script_linkName; - unsigned __int16 script_noteworthy; - unsigned __int16 target; - unsigned __int16 animscript; + uint16_t targetname; + uint16_t script_linkName; + uint16_t script_noteworthy; + uint16_t target; + uint16_t animscript; int animscriptfunc; vec3_t vOrigin; float fAngle; vec2_t forward; float fRadius; float minUseDistSq; - __int16 wOverlapNode[2]; - unsigned __int16 totalLinkCount; + int16_t wOverlapNode[2]; + uint16_t totalLinkCount; pathlink_s* Links; }; struct SentientHandle { - unsigned __int16 number; - unsigned __int16 infoIndex; + uint16_t number; + uint16_t infoIndex; }; @@ -3246,10 +3246,10 @@ namespace T6 int iValidTime[3]; int dangerousNodeTime[3]; int inPlayerLOSTime; - __int16 wLinkCount; - __int16 wOverlapCount; - __int16 turretEntNumber; - __int16 userCount; + int16_t wLinkCount; + int16_t wOverlapCount; + int16_t turretEntNumber; + int16_t userCount; bool hasBadPlaceLink; }; @@ -3289,7 +3289,7 @@ namespace T6 struct pathnode_tree_nodes_t { int nodeCount; - unsigned __int16* nodes; + uint16_t* nodes; }; @@ -3311,8 +3311,8 @@ namespace T6 struct TriggerModel { int contents; - unsigned __int16 hullCount; - unsigned __int16 firstHull; + uint16_t hullCount; + uint16_t firstHull; }; @@ -3320,8 +3320,8 @@ namespace T6 { Bounds bounds; int contents; - unsigned __int16 slabCount; - unsigned __int16 firstSlab; + uint16_t slabCount; + uint16_t firstSlab; }; @@ -3338,12 +3338,12 @@ namespace T6 vec4_t mins; vec4_t maxs; float maxStreamingDistance; - unsigned __int16 firstItem; - unsigned __int16 itemCount; - unsigned __int16 firstChild; - unsigned __int16 childCount; - unsigned __int16 smodelCount; - unsigned __int16 surfaceCount; + uint16_t firstItem; + uint16_t itemCount; + uint16_t firstChild; + uint16_t childCount; + uint16_t smodelCount; + uint16_t surfaceCount; }; @@ -3362,7 +3362,7 @@ namespace T6 char type; char canUseShadowMap; char shadowmapVolume; - __int16 cullDist; + int16_t cullDist; vec3_t color; vec3_t dir; vec3_t origin; @@ -3437,12 +3437,12 @@ namespace T6 struct GfxWorldFogModifierVolume { unsigned int control; - unsigned __int16 minX; - unsigned __int16 minY; - unsigned __int16 minZ; - unsigned __int16 maxX; - unsigned __int16 maxY; - unsigned __int16 maxZ; + uint16_t minX; + uint16_t minY; + uint16_t minZ; + uint16_t maxX; + uint16_t maxY; + uint16_t maxZ; unsigned int controlEx; float transitionTime; float depthScale; @@ -3510,7 +3510,7 @@ namespace T6 struct alignas(4) GfxLightGridEntry { - unsigned __int16 colorsIndex; + uint16_t colorsIndex; char primaryLightIndex; char visibility; }; @@ -3524,7 +3524,7 @@ namespace T6 struct GfxCompressedLightGridCoeffs { - unsigned __int16 coeffs[9][3]; + uint16_t coeffs[9][3]; }; @@ -3533,7 +3533,7 @@ namespace T6 vec3_t mins; vec3_t maxs; vec3_t lightingOrigin; - unsigned __int16 colorsIndex; + uint16_t colorsIndex; char primaryLightIndex; char visibility; }; @@ -3570,7 +3570,7 @@ namespace T6 { char state; char lod; - unsigned __int16 surfId; + uint16_t surfId; }; unsigned int packed; @@ -3580,7 +3580,7 @@ namespace T6 struct GfxSceneDynModel { XModelDrawInfo info; - unsigned __int16 dynEntId; + uint16_t dynEntId; char primaryLightIndex; char reflectionProbeIndex; }; @@ -3588,27 +3588,27 @@ namespace T6 struct BModelDrawInfo { - unsigned __int16 surfId; + uint16_t surfId; }; struct alignas(4) GfxSceneDynBrush { BModelDrawInfo info; - unsigned __int16 dynEntId; + uint16_t dynEntId; }; union __m128 { float m128_f32[4]; - unsigned __int64 m128_u64[2]; + uint64_t m128_u64[2]; char m128_i8[16]; - __int16 m128_i16[8]; + int16_t m128_i16[8]; int m128_i32[4]; - __int64 m128_i64[2]; + int64_t m128_i64[2]; char m128_u8[16]; - unsigned __int16 m128_u16[8]; + uint16_t m128_u16[8]; unsigned int m128_u32[4]; }; @@ -3648,10 +3648,10 @@ namespace T6 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; }; @@ -3678,8 +3678,8 @@ namespace T6 int vertexDataOffset1; int firstVertex; float himipRadiusInvSq; - unsigned __int16 vertexCount; - unsigned __int16 triCount; + uint16_t vertexCount; + uint16_t triCount; int baseIndex; }; @@ -3706,9 +3706,9 @@ namespace T6 struct GfxLightingSHQuantized { - unsigned __int16 V0[4]; - unsigned __int16 V1[4]; - unsigned __int16 V2[4]; + uint16_t V0[4]; + uint16_t V1[4]; + uint16_t V2[4]; }; @@ -3716,7 +3716,7 @@ namespace T6 { unsigned int* lmapVertexColors; void/*ID3D11Buffer*/* lmapVertexColorsVB; - unsigned __int16 numLmapVertexColors; + uint16_t numLmapVertexColors; }; @@ -3727,8 +3727,8 @@ namespace T6 XModel* model; int flags; float invScaleSq; - unsigned __int16 lightingHandle; - unsigned __int16 colorsIndex; + uint16_t lightingHandle; + uint16_t colorsIndex; GfxLightingSHQuantized lightingSH; char primaryLightIndex; char visibility; @@ -3777,7 +3777,7 @@ namespace T6 struct Glyph { - unsigned __int16 letter; + uint16_t letter; char x0; char y0; char dx; @@ -3792,8 +3792,8 @@ namespace T6 struct KerningPairs { - unsigned __int16 wFirst; - unsigned __int16 wSecond; + uint16_t wFirst; + uint16_t wSecond; int iKernAmount; }; @@ -3950,8 +3950,8 @@ namespace T6 menuDef_t* parent; rectData_s* rectExpData; ExpressionStatement visibleExp; - unsigned __int64 showBits; - unsigned __int64 hideBits; + uint64_t showBits; + uint64_t hideBits; ExpressionStatement forecolorAExp; int ui3dWindowId; GenericEventHandler* onEvent; @@ -4201,8 +4201,8 @@ namespace T6 XModel** gunXModel; // covered XModel* handXModel; // covered const char* szModeName; // covered - unsigned __int16* notetrackSoundMapKeys; // covered - unsigned __int16* notetrackSoundMapValues; // covered + uint16_t* notetrackSoundMapKeys; // covered + uint16_t* notetrackSoundMapValues; // covered int playerAnimType; // covered weapType_t weapType; weapClass_t weapClass; @@ -4393,7 +4393,7 @@ namespace T6 int playerDamage; int iMeleeDamage; int iDamageType; - unsigned __int16 explosionTag; + uint16_t explosionTag; int iFireDelay; int iMeleeDelay; int meleeChargeDelay; @@ -4927,7 +4927,7 @@ namespace T6 WeaponAttachment** attachments; WeaponAttachmentUnique** attachmentUniques; const char** szXAnims; - unsigned __int16* hideTags; + uint16_t* hideTags; XModel** attachViewModel; XModel** attachWorldModel; const char** attachViewModelTag; @@ -5000,9 +5000,9 @@ namespace T6 WeaponAttachmentUnique* attachmentUniques[95]; XModel* gunXModel[16]; const char* szXAnims[88]; - unsigned __int16 hideTags[32]; - unsigned __int16 notetrackSoundMapKeys[20]; - unsigned __int16 notetrackSoundMapValues[20]; + uint16_t hideTags[32]; + uint16_t notetrackSoundMapKeys[20]; + uint16_t notetrackSoundMapValues[20]; XModel* worldModel[16]; XModel* attachViewModel[8]; XModel* attachWorldModel[8]; @@ -5049,8 +5049,8 @@ namespace T6 unsigned int id; int parentIndex; SndMenuCategory category; - unsigned __int16 attenuationSp; - unsigned __int16 attenuationMp; + uint16_t attenuationSp; + uint16_t attenuationMp; }; @@ -5218,7 +5218,7 @@ namespace T6 char loopCount; char colIndexBits; char rowIndexBits; - unsigned __int16 entryCountAndIndexRange; + uint16_t entryCountAndIndexRange; }; @@ -5296,7 +5296,7 @@ namespace T6 }; - const struct FxElemDef + struct FxElemDef { int flags; FxSpawnDef spawn; @@ -5336,10 +5336,10 @@ namespace T6 char sortOrder; char lightingFrac; char unused[2]; - unsigned __int16 alphaFadeTimeMsec; - unsigned __int16 maxWindStrength; - unsigned __int16 spawnIntervalAtMaxWind; - unsigned __int16 lifespanAtMaxWind; + uint16_t alphaFadeTimeMsec; + uint16_t maxWindStrength; + uint16_t spawnIntervalAtMaxWind; + uint16_t lifespanAtMaxWind; FxElemDefUnion u; FxElemSpawnSound spawnSound; vec2_t billboardPivot; @@ -5414,7 +5414,7 @@ namespace T6 struct Glass { unsigned int numCellIndices; - unsigned __int16 cellIndices[6]; + uint16_t cellIndices[6]; GlassDef* glassDef; unsigned int index; unsigned int brushModel; @@ -5485,7 +5485,7 @@ namespace T6 }; typedef char ByteVec[3]; - typedef tdef_align(4) unsigned __int16 UShortVec[3]; + typedef tdef_align(4) uint16_t UShortVec[3]; union XAnimDynamicFrames { @@ -5497,7 +5497,7 @@ namespace T6 union XAnimDynamicIndicesTrans { char _1[1]; - unsigned __int16 _2[1]; + uint16_t _2[1]; }; @@ -5519,7 +5519,7 @@ namespace T6 struct XAnimPartTrans { - unsigned __int16 size; + uint16_t size; char smallTrans; XAnimPartTransData u; }; @@ -5527,10 +5527,10 @@ namespace T6 union XAnimDynamicIndicesDeltaQuat2 { char _1[1]; - unsigned __int16 _2[1]; + uint16_t _2[1]; }; - typedef tdef_align(4) __int16 XQuat2[2]; + typedef tdef_align(4) int16_t XQuat2[2]; struct alignas(4) XAnimDeltaPartQuatDataFrames2 { @@ -5548,17 +5548,17 @@ namespace T6 struct XAnimDeltaPartQuat2 { - unsigned __int16 size; + uint16_t size; XAnimDeltaPartQuatData2 u; }; union XAnimDynamicIndicesDeltaQuat { char _1[1]; - unsigned __int16 _2[1]; + uint16_t _2[1]; }; - typedef tdef_align(4) __int16 XQuat[4]; + typedef tdef_align(4) int16_t XQuat[4]; struct alignas(4) XAnimDeltaPartQuatDataFrames { @@ -5576,7 +5576,7 @@ namespace T6 struct XAnimDeltaPartQuat { - unsigned __int16 size; + uint16_t size; XAnimDeltaPartQuatData u; }; @@ -5613,10 +5613,10 @@ namespace T6 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; }; @@ -5683,7 +5683,7 @@ namespace T6 union MaterialArgumentLocation { - unsigned __int16 offset; + uint16_t offset; struct { @@ -5695,7 +5695,7 @@ namespace T6 struct MaterialArgumentCodeConst { - unsigned __int16 index; + uint16_t index; char firstRow; char rowCount; }; @@ -5727,10 +5727,10 @@ namespace T6 struct MaterialShaderArgument { - unsigned __int16 type; + uint16_t type; MaterialArgumentLocation location; - unsigned __int16 size; - unsigned __int16 buffer; + uint16_t size; + uint16_t buffer; MaterialArgumentDef u; }; @@ -5750,23 +5750,23 @@ namespace T6 unsigned int contextValue; unsigned int stopOnPlay; unsigned int futzPatch; - unsigned __int16 fluxTime; - unsigned __int16 startDelay; - unsigned __int16 reverbSend; - unsigned __int16 centerSend; - unsigned __int16 volMin; - unsigned __int16 volMax; - unsigned __int16 pitchMin; - unsigned __int16 pitchMax; - unsigned __int16 distMin; - unsigned __int16 distMax; - unsigned __int16 distReverbMax; - unsigned __int16 envelopMin; - unsigned __int16 envelopMax; - unsigned __int16 envelopPercentage; - __int16 fadeIn; - __int16 fadeOut; - __int16 dopplerScale; + uint16_t fluxTime; + uint16_t startDelay; + uint16_t reverbSend; + uint16_t centerSend; + uint16_t volMin; + uint16_t volMax; + uint16_t pitchMin; + uint16_t pitchMax; + uint16_t distMin; + uint16_t distMax; + uint16_t distReverbMax; + uint16_t envelopMin; + uint16_t envelopMax; + uint16_t envelopPercentage; + int16_t fadeIn; + int16_t fadeOut; + int16_t dopplerScale; char minPriorityThreshold; char maxPriorityThreshold; char probability; @@ -5783,7 +5783,7 @@ namespace T6 struct alignas(4) pathlink_s { float fDist; - unsigned __int16 nodeNum; + uint16_t nodeNum; char disconnectCount; char negotiationLink; char flags; @@ -5795,11 +5795,11 @@ namespace T6 { vec3_t mins; vec3_t maxs; - unsigned __int16 childCount; - unsigned __int16 surfaceCount; - unsigned __int16 startSurfIndex; - unsigned __int16 smodelIndexCount; - unsigned __int16* smodelIndexes; + uint16_t childCount; + uint16_t surfaceCount; + uint16_t startSurfIndex; + uint16_t smodelIndexCount; + uint16_t* smodelIndexes; int childrenOffset; }; @@ -5856,7 +5856,7 @@ namespace T6 int numVerts; int numTris; SSkinVert* verts; - unsigned __int16* tris; + uint16_t* tris; }; @@ -5871,7 +5871,7 @@ namespace T6 struct half { - unsigned __int16 v; + uint16_t v; }; @@ -5885,7 +5885,7 @@ namespace T6 half w; }; - // unsigned __int64 v; + // uint64_t v; }; @@ -5955,8 +5955,8 @@ namespace T6 bool enabled; int integer; unsigned int unsignedInt; - __int64 integer64; - unsigned __int64 unsignedInt64; + int64_t integer64; + uint64_t unsignedInt64; float value; vec4_t vector; const char* string; @@ -5980,8 +5980,8 @@ namespace T6 struct { - __int64 min; - __int64 max; + int64_t min; + int64_t max; } integer64; struct @@ -6245,8 +6245,8 @@ namespace T6 struct WeaponCamoMaterial { - unsigned __int16 replaceFlags; - unsigned __int16 numBaseMaterials; + uint16_t replaceFlags; + uint16_t numBaseMaterials; Material** baseMaterials; Material** camoMaterials; float shaderConsts[8]; @@ -6267,7 +6267,7 @@ namespace T6 }; - const struct FxElemVelStateSample + struct FxElemVelStateSample { FxElemVelStateInFrame local; FxElemVelStateInFrame world; @@ -6284,7 +6284,7 @@ namespace T6 }; - const struct FxElemVisStateSample + struct FxElemVisStateSample { FxElemVisualState base; FxElemVisualState amplitude; @@ -6305,7 +6305,7 @@ namespace T6 int vertCount; FxTrailVertex* verts; int indCount; - unsigned __int16* inds; + uint16_t* inds; }; @@ -6524,22 +6524,22 @@ namespace T6 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; }; diff --git a/src/ZoneCommon/Pool/AssetPoolDynamic.h b/src/ZoneCommon/Pool/AssetPoolDynamic.h index b13f7465..71f0e505 100644 --- a/src/ZoneCommon/Pool/AssetPoolDynamic.h +++ b/src/ZoneCommon/Pool/AssetPoolDynamic.h @@ -32,7 +32,7 @@ public: for(auto* entry : m_assets) { - delete entry->m_ptr; + delete entry->Asset(); delete entry; } diff --git a/src/ZoneCommon/Pool/AssetPoolStatic.h b/src/ZoneCommon/Pool/AssetPoolStatic.h index 04a41e32..9fe7b18e 100644 --- a/src/ZoneCommon/Pool/AssetPoolStatic.h +++ b/src/ZoneCommon/Pool/AssetPoolStatic.h @@ -1,11 +1,12 @@ #pragma once +#include +#include + #include "GlobalAssetPool.h" #include "AssetPool.h" #include "XAssetInfo.h" -#include - template class AssetPoolStatic final : public AssetPool { @@ -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; diff --git a/src/ZoneCommon/Zone/ZoneTypes.h b/src/ZoneCommon/Zone/ZoneTypes.h index 8566a5e8..a52d0f39 100644 --- a/src/ZoneCommon/Zone/ZoneTypes.h +++ b/src/ZoneCommon/Zone/ZoneTypes.h @@ -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; diff --git a/src/ZoneLoading/Game/IW4/XAssets/gfximage/gfximage_actions.cpp b/src/ZoneLoading/Game/IW4/XAssets/gfximage/gfximage_actions.cpp index 8b7789ee..a4e7d317 100644 --- a/src/ZoneLoading/Game/IW4/XAssets/gfximage/gfximage_actions.cpp +++ b/src/ZoneLoading/Game/IW4/XAssets/gfximage/gfximage_actions.cpp @@ -1,5 +1,7 @@ #include "gfximage_actions.h" + #include +#include using namespace IW4; diff --git a/src/ZoneLoading/Game/IW4/XAssets/loadedsound/loadedsound_actions.cpp b/src/ZoneLoading/Game/IW4/XAssets/loadedsound/loadedsound_actions.cpp index b12f56c9..92efcff4 100644 --- a/src/ZoneLoading/Game/IW4/XAssets/loadedsound/loadedsound_actions.cpp +++ b/src/ZoneLoading/Game/IW4/XAssets/loadedsound/loadedsound_actions.cpp @@ -1,5 +1,7 @@ #include "loadedsound_actions.h" +#include + using namespace IW4; Actions_LoadedSound::Actions_LoadedSound(Zone* zone) diff --git a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp index 43e1ab7a..ddbd6116 100644 --- a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp @@ -1,17 +1,12 @@ #include "ZoneLoaderFactoryIW4.h" + +#include +#include +#include + #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 -#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::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(Crypto::CreateSHA256()), - masterBlockHashes))); + AUTHED_CHUNK_COUNT_PER_GROUP, AUTHED_CHUNK_SIZE, std::extent::value, + std::unique_ptr(Crypto::CreateSHA256()), masterBlockHashes))); } public: diff --git a/src/ZoneLoading/Game/T6/XAssets/gfximage/gfximage_actions.cpp b/src/ZoneLoading/Game/T6/XAssets/gfximage/gfximage_actions.cpp index 9535a187..9b73dbe5 100644 --- a/src/ZoneLoading/Game/T6/XAssets/gfximage/gfximage_actions.cpp +++ b/src/ZoneLoading/Game/T6/XAssets/gfximage/gfximage_actions.cpp @@ -1,5 +1,7 @@ #include "gfximage_actions.h" + #include +#include using namespace T6; diff --git a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp index 2875d78d..4cdf87e2 100644 --- a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp +++ b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp @@ -1,6 +1,18 @@ #include "ZoneLoaderFactoryT6.h" + +#include +#include + #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 #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; diff --git a/src/ZoneLoading/Loading/AssetLoader.cpp b/src/ZoneLoading/Loading/AssetLoader.cpp index de1db403..d1fd3853 100644 --- a/src/ZoneLoading/Loading/AssetLoader.cpp +++ b/src/ZoneLoading/Loading/AssetLoader.cpp @@ -1,5 +1,7 @@ #include "AssetLoader.h" + #include +#include AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream) : ContentLoaderBase(zone, stream), diff --git a/src/ZoneLoading/Loading/AssetLoader.h b/src/ZoneLoading/Loading/AssetLoader.h index b8410a63..55f35a02 100644 --- a/src/ZoneLoading/Loading/AssetLoader.h +++ b/src/ZoneLoading/Loading/AssetLoader.h @@ -1,4 +1,6 @@ #pragma once + +#include "Zone/ZoneTypes.h" #include "Pool/XAssetInfo.h" #include "ContentLoaderBase.h" diff --git a/src/ZoneLoading/Loading/Exception/BlockOverflowException.cpp b/src/ZoneLoading/Loading/Exception/BlockOverflowException.cpp index 79cdbd8d..779e77e5 100644 --- a/src/ZoneLoading/Loading/Exception/BlockOverflowException.cpp +++ b/src/ZoneLoading/Loading/Exception/BlockOverflowException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/BlockOverflowException.h b/src/ZoneLoading/Loading/Exception/BlockOverflowException.h index 4bdfc736..294d36ce 100644 --- a/src/ZoneLoading/Loading/Exception/BlockOverflowException.h +++ b/src/ZoneLoading/Loading/Exception/BlockOverflowException.h @@ -10,5 +10,5 @@ public: explicit BlockOverflowException(XBlock* block); std::string DetailedMessage() override; - char const* what() const override; + char const* what() const noexcept override; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.cpp b/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.cpp index a40b5d3c..ea6959b4 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.cpp @@ -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"; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.h b/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.h index 48f04850..76d1ad29 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidChunkSizeException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidCompressionException.cpp b/src/ZoneLoading/Loading/Exception/InvalidCompressionException.cpp index d2b40965..de1ab4db 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidCompressionException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidCompressionException.cpp @@ -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"; } diff --git a/src/ZoneLoading/Loading/Exception/InvalidCompressionException.h b/src/ZoneLoading/Loading/Exception/InvalidCompressionException.h index ba64834e..364d52bd 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidCompressionException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidCompressionException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidFileNameException.cpp b/src/ZoneLoading/Loading/Exception/InvalidFileNameException.cpp index 97bdc158..ac82d25a 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidFileNameException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidFileNameException.cpp @@ -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"; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidFileNameException.h b/src/ZoneLoading/Loading/Exception/InvalidFileNameException.h index 7c6eff2d..89c51f24 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidFileNameException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidFileNameException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidHashException.cpp b/src/ZoneLoading/Loading/Exception/InvalidHashException.cpp index 327ddbef..ffab2c8c 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidHashException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidHashException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidHashException.h b/src/ZoneLoading/Loading/Exception/InvalidHashException.h index 07de0764..17d0ed4b 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidHashException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidHashException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidMagicException.cpp b/src/ZoneLoading/Loading/Exception/InvalidMagicException.cpp index 01d2213f..22395ed0 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidMagicException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidMagicException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidMagicException.h b/src/ZoneLoading/Loading/Exception/InvalidMagicException.h index 1cfc6154..ab2d7910 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidMagicException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidMagicException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.cpp b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.cpp index 09dfe983..fbe4114d 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.cpp @@ -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"; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.h b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.h index 221e306e..0a571894 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.cpp b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.cpp index 545b4505..58ab1dbc 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.cpp @@ -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"; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.h b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.h index b9a94a00..b93eeaa2 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidOffsetBlockOffsetException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidSignatureException.cpp b/src/ZoneLoading/Loading/Exception/InvalidSignatureException.cpp index af8221d2..429d4ecb 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidSignatureException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidSignatureException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidSignatureException.h b/src/ZoneLoading/Loading/Exception/InvalidSignatureException.h index d4aae448..7940dcba 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidSignatureException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidSignatureException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidVersionException.cpp b/src/ZoneLoading/Loading/Exception/InvalidVersionException.cpp index ddadd5e5..6aabdc59 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidVersionException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidVersionException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidVersionException.h b/src/ZoneLoading/Loading/Exception/InvalidVersionException.h index fa3d8640..35664144 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidVersionException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidVersionException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.cpp b/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.cpp index b63e60b3..4ca598b8 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.cpp +++ b/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.cpp @@ -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"; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.h b/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.h index 731de18f..aa198787 100644 --- a/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.h +++ b/src/ZoneLoading/Loading/Exception/InvalidXBlockSizeException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.cpp b/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.cpp index df6595da..3b020eb1 100644 --- a/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.cpp +++ b/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.h b/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.h index 7cf92f75..ab2e4bb9 100644 --- a/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.h +++ b/src/ZoneLoading/Loading/Exception/OutOfBlockBoundsException.h @@ -10,5 +10,5 @@ public: explicit OutOfBlockBoundsException(XBlock* block); std::string DetailedMessage() override; - char const* what() const override; + char const* what() const noexcept override; }; diff --git a/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.cpp b/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.cpp index 168829f6..3f580b36 100644 --- a/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.cpp +++ b/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.h b/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.h index 9a2b2cf2..389e2b00 100644 --- a/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.h +++ b/src/ZoneLoading/Loading/Exception/TooManyAuthedGroupsException.h @@ -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; }; diff --git a/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.cpp b/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.cpp index 4eb483f6..c860eacf 100644 --- a/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.cpp +++ b/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.cpp @@ -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"; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.h b/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.h index c850e605..d0f1d7bb 100644 --- a/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.h +++ b/src/ZoneLoading/Loading/Exception/UnexpectedEndOfFileException.h @@ -7,5 +7,5 @@ public: UnexpectedEndOfFileException(); std::string DetailedMessage() override; - char const* what() const override; + char const* what() const noexcept override; }; diff --git a/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.cpp b/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.cpp index 38b29a3d..20f68d15 100644 --- a/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.cpp +++ b/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.cpp @@ -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."; } \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.h b/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.h index 3b079651..4f262c5b 100644 --- a/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.h +++ b/src/ZoneLoading/Loading/Exception/UnsupportedAssetTypeException.h @@ -9,5 +9,5 @@ public: explicit UnsupportedAssetTypeException(int assetType); std::string DetailedMessage() override; - char const* what() const override; + char const* what() const noexcept override; }; diff --git a/src/ZoneLoading/Loading/ILoadingStream.h b/src/ZoneLoading/Loading/ILoadingStream.h index 65cd4ba5..95f7b1c4 100644 --- a/src/ZoneLoading/Loading/ILoadingStream.h +++ b/src/ZoneLoading/Loading/ILoadingStream.h @@ -1,6 +1,7 @@ #pragma once #include +#include class ILoadingStream { diff --git a/src/ZoneLoading/Loading/Processor/ProcessorAuthedBlocks.cpp b/src/ZoneLoading/Loading/Processor/ProcessorAuthedBlocks.cpp index 5b690f79..144fda65 100644 --- a/src/ZoneLoading/Loading/Processor/ProcessorAuthedBlocks.cpp +++ b/src/ZoneLoading/Loading/Processor/ProcessorAuthedBlocks.cpp @@ -2,7 +2,7 @@ #include #include - +#include #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(buffer)[loadedSize], length - loadedSize, - &m_chunk_buffer[m_current_chunk_offset], sizeToWrite); + assert(length - loadedSize >= sizeToWrite); + memcpy(&static_cast(buffer)[loadedSize], &m_chunk_buffer[m_current_chunk_offset], sizeToWrite); loadedSize += sizeToWrite; m_current_chunk_offset += sizeToWrite; } diff --git a/src/ZoneLoading/Loading/Processor/ProcessorCaptureData.cpp b/src/ZoneLoading/Loading/Processor/ProcessorCaptureData.cpp index 1eae5253..8168d804 100644 --- a/src/ZoneLoading/Loading/Processor/ProcessorCaptureData.cpp +++ b/src/ZoneLoading/Loading/Processor/ProcessorCaptureData.cpp @@ -1,6 +1,7 @@ #include "ProcessorCaptureData.h" #include +#include ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize) : m_data(std::make_unique(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; diff --git a/src/ZoneLoading/Loading/Processor/ProcessorInflate.cpp b/src/ZoneLoading/Loading/Processor/ProcessorInflate.cpp index f82bd50a..1b2c23f4 100644 --- a/src/ZoneLoading/Loading/Processor/ProcessorInflate.cpp +++ b/src/ZoneLoading/Loading/Processor/ProcessorInflate.cpp @@ -1,6 +1,6 @@ #include "ProcessorInflate.h" -#include +#include #include #include #include @@ -33,7 +33,7 @@ public: if (ret != Z_OK) { - throw std::exception("Initializing inflate failed"); + throw std::runtime_error("Initializing inflate failed"); } } diff --git a/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp b/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp index ecfb89ca..9c1f9772 100644 --- a/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp +++ b/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp @@ -7,6 +7,7 @@ #include #include #include +#include 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; diff --git a/src/ZoneLoading/Loading/Processor/XChunks/ChunkProcessorInflate.cpp b/src/ZoneLoading/Loading/Processor/XChunks/ChunkProcessorInflate.cpp index c1f4df35..2f33d262 100644 --- a/src/ZoneLoading/Loading/Processor/XChunks/ChunkProcessorInflate.cpp +++ b/src/ZoneLoading/Loading/Processor/XChunks/ChunkProcessorInflate.cpp @@ -1,7 +1,10 @@ #include "ChunkProcessorInflate.h" + +#include + #include "zlib.h" #include "zutil.h" -#include + #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; diff --git a/src/ZoneLoading/Loading/Processor/XChunks/IXChunkProcessor.h b/src/ZoneLoading/Loading/Processor/XChunks/IXChunkProcessor.h index ce341667..7eb164de 100644 --- a/src/ZoneLoading/Loading/Processor/XChunks/IXChunkProcessor.h +++ b/src/ZoneLoading/Loading/Processor/XChunks/IXChunkProcessor.h @@ -1,5 +1,7 @@ #pragma once + #include +#include class IXChunkProcessor { diff --git a/src/ZoneLoading/Loading/Steps/StepVerifyHash.cpp b/src/ZoneLoading/Loading/Steps/StepVerifyHash.cpp index 7f100dac..55936d08 100644 --- a/src/ZoneLoading/Loading/Steps/StepVerifyHash.cpp +++ b/src/ZoneLoading/Loading/Steps/StepVerifyHash.cpp @@ -1,6 +1,7 @@ #include "StepVerifyHash.h" #include +#include #include "Loading/Exception/InvalidHashException.h" diff --git a/src/ZoneLoading/Loading/Steps/StepVerifyMagic.cpp b/src/ZoneLoading/Loading/Steps/StepVerifyMagic.cpp index a56615b9..4e9b13cd 100644 --- a/src/ZoneLoading/Loading/Steps/StepVerifyMagic.cpp +++ b/src/ZoneLoading/Loading/Steps/StepVerifyMagic.cpp @@ -1,17 +1,20 @@ #include "StepVerifyMagic.h" + +#include + #include "Loading/Exception/InvalidMagicException.h" StepVerifyMagic::StepVerifyMagic(const char* magic) { m_magic = magic; + m_magic_len = strlen(m_magic); } void StepVerifyMagic::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) { - const size_t magicLength = strlen(m_magic); char currentCharacter; - for(unsigned i = 0; i < magicLength; i++) + for(unsigned i = 0; i < m_magic_len; i++) { stream->Load(¤tCharacter, sizeof(char)); diff --git a/src/ZoneLoading/Loading/Steps/StepVerifyMagic.h b/src/ZoneLoading/Loading/Steps/StepVerifyMagic.h index 9127a2ae..3fa35bd8 100644 --- a/src/ZoneLoading/Loading/Steps/StepVerifyMagic.h +++ b/src/ZoneLoading/Loading/Steps/StepVerifyMagic.h @@ -5,6 +5,7 @@ class StepVerifyMagic final : public ILoadingStep { const char* m_magic; + size_t m_magic_len; public: explicit StepVerifyMagic(const char* magic); diff --git a/src/ZoneLoading/Loading/StreamProcessor.h b/src/ZoneLoading/Loading/StreamProcessor.h index a5014e22..d3702777 100644 --- a/src/ZoneLoading/Loading/StreamProcessor.h +++ b/src/ZoneLoading/Loading/StreamProcessor.h @@ -1,4 +1,5 @@ #pragma once + #include "ILoadingStream.h" class StreamProcessor : public ILoadingStream diff --git a/src/ZoneLoading/Zone/Stream/IZoneInputStream.h b/src/ZoneLoading/Zone/Stream/IZoneInputStream.h index bfb3f341..57c7886b 100644 --- a/src/ZoneLoading/Zone/Stream/IZoneInputStream.h +++ b/src/ZoneLoading/Zone/Stream/IZoneInputStream.h @@ -1,7 +1,9 @@ #pragma once -#include "Zone/Stream/IZoneStream.h" #include +#include + +#include "Zone/Stream/IZoneStream.h" class IZoneInputStream : public IZoneStream { diff --git a/src/ZoneLoading/Zone/Stream/Impl/XBlockInputStream.cpp b/src/ZoneLoading/Zone/Stream/Impl/XBlockInputStream.cpp index aa9588dd..c4b12d9f 100644 --- a/src/ZoneLoading/Zone/Stream/Impl/XBlockInputStream.cpp +++ b/src/ZoneLoading/Zone/Stream/Impl/XBlockInputStream.cpp @@ -1,9 +1,11 @@ #include "XBlockInputStream.h" + +#include +#include + #include "Loading/Exception/BlockOverflowException.h" #include "Loading/Exception/InvalidOffsetBlockException.h" #include "Loading/Exception/InvalidOffsetBlockOffsetException.h" - -#include #include "Loading/Exception/OutOfBlockBoundsException.h" XBlockInputStream::XBlockInputStream(std::vector& blocks, ILoadingStream* stream, const int blockBitCount,