diff --git a/src/Common/Utils/TypeAlignment.h b/src/Common/Utils/TypeAlignment.h index 58733124..e3eabcd4 100644 --- a/src/Common/Utils/TypeAlignment.h +++ b/src/Common/Utils/TypeAlignment.h @@ -27,9 +27,9 @@ #define gcc_align(x) #else #ifdef _MSVC_LANG -#define type_align(x) __declspec(align(x)) -#define tdef_align(x) __declspec(align(x)) -#define memb_align(x) __declspec(align(x)) +#define type_align(x) /* __declspec(align(x)) */ +#define tdef_align(x) /* __declspec(align(x)) */ +#define memb_align(x) /* __declspec(align(x)) */ #define gcc_align(x) #else #define type_align(x) __attribute__((__aligned__(x))) diff --git a/src/ObjCommon/Csv/CsvHeaderRow.cpp b/src/ObjCommon/Csv/CsvHeaderRow.cpp index bb17aa46..d1d99479 100644 --- a/src/ObjCommon/Csv/CsvHeaderRow.cpp +++ b/src/ObjCommon/Csv/CsvHeaderRow.cpp @@ -21,7 +21,7 @@ bool CsvHeaderRow::RequireIndexForHeader(const std::string& headerName, unsigned if (existingHeader == m_header_row.end()) return false; - out = std::distance(m_header_row.begin(), existingHeader); + out = static_cast(std::distance(m_header_row.begin(), existingHeader)); return true; } diff --git a/src/ObjCommon/Csv/CsvHeaderRow.h b/src/ObjCommon/Csv/CsvHeaderRow.h index e3ab3f65..dad12ecb 100644 --- a/src/ObjCommon/Csv/CsvHeaderRow.h +++ b/src/ObjCommon/Csv/CsvHeaderRow.h @@ -13,7 +13,7 @@ public: bool Read(const CsvInputStream& inputStream); - const std::string& HeaderNameForColumn(unsigned columnIndex) const; + [[nodiscard]] const std::string& HeaderNameForColumn(unsigned columnIndex) const; bool RequireIndexForHeader(const std::string& headerName, unsigned& out) const; [[nodiscard]] std::optional GetIndexForHeader(const std::string& headerName) const; diff --git a/src/ObjCommon/StructuredDataDef/CommonStructuredDataEnum.cpp b/src/ObjCommon/StructuredDataDef/CommonStructuredDataEnum.cpp index 6a62a01f..82e745f8 100644 --- a/src/ObjCommon/StructuredDataDef/CommonStructuredDataEnum.cpp +++ b/src/ObjCommon/StructuredDataDef/CommonStructuredDataEnum.cpp @@ -42,14 +42,14 @@ uint32_t CommonStructuredDataEnum::CalculateChecksum(const uint32_t initialValue { auto checksum = initialValue; - checksum = crc32(checksum, reinterpret_cast(m_name.c_str()), m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(m_name.c_str()), static_cast(m_name.size() + 1u)); const auto littleEndianElementCount = endianness::ToLittleEndian(ElementCount()); checksum = crc32(checksum, reinterpret_cast(&littleEndianElementCount), sizeof(littleEndianElementCount)); for (const auto& entry : m_entries) { - checksum = crc32(checksum, reinterpret_cast(entry.m_name.c_str()), entry.m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(entry.m_name.c_str()), static_cast(entry.m_name.size() + 1)); const auto littleEndianValue = endianness::ToLittleEndian(entry.m_value); checksum = crc32(checksum, reinterpret_cast(&littleEndianValue), sizeof(littleEndianValue)); diff --git a/src/ObjCommon/StructuredDataDef/CommonStructuredDataStruct.cpp b/src/ObjCommon/StructuredDataDef/CommonStructuredDataStruct.cpp index 31b61ac1..7c81d451 100644 --- a/src/ObjCommon/StructuredDataDef/CommonStructuredDataStruct.cpp +++ b/src/ObjCommon/StructuredDataDef/CommonStructuredDataStruct.cpp @@ -41,10 +41,10 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat { auto checksum = initialValue; - checksum = crc32(checksum, reinterpret_cast(m_name.c_str()), m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(m_name.c_str()), static_cast(m_name.size() + 1u)); for (const auto& property : m_properties) { - checksum = crc32(checksum, reinterpret_cast(property.m_name.c_str()), property.m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(property.m_name.c_str()), static_cast(property.m_name.size() + 1u)); const auto littleEndianOffset = endianness::ToLittleEndian(property.m_offset_in_bits); checksum = crc32(checksum, reinterpret_cast(&littleEndianOffset), sizeof(littleEndianOffset)); @@ -68,7 +68,7 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat if (currentType.m_info.type_index < def.m_enums.size()) { const auto& _enum = *def.m_enums[currentType.m_info.type_index]; - checksum = crc32(checksum, reinterpret_cast(_enum.m_name.c_str()), _enum.m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(_enum.m_name.c_str()), static_cast(_enum.m_name.size() + 1u)); currentType = CommonStructuredDataType(CommonStructuredDataTypeCategory::UNKNOWN); } break; @@ -76,7 +76,7 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat if (currentType.m_info.type_index < def.m_structs.size()) { const auto& _struct = *def.m_structs[currentType.m_info.type_index]; - checksum = crc32(checksum, reinterpret_cast(_struct.m_name.c_str()), _struct.m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(_struct.m_name.c_str()), static_cast(_struct.m_name.size() + 1u)); currentType = CommonStructuredDataType(CommonStructuredDataTypeCategory::UNKNOWN); } break; @@ -99,7 +99,7 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat if (enumedArray.m_enum_index < def.m_enums.size()) { const auto& _enum = *def.m_enums[enumedArray.m_enum_index]; - checksum = crc32(checksum, reinterpret_cast(_enum.m_name.c_str()), _enum.m_name.size() + 1); + checksum = crc32(checksum, reinterpret_cast(_enum.m_name.c_str()), static_cast(_enum.m_name.size() + 1u)); } currentType = enumedArray.m_array_type; } diff --git a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp index 8cba6771..22da77ce 100644 --- a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp +++ b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp @@ -6,7 +6,6 @@ #include #include -#include using namespace T6; @@ -42,7 +41,7 @@ namespace auto* gameKvps = m_memory.Alloc(); gameKvps->name = m_memory.Dup(m_zone.m_name.c_str()); - gameKvps->numVariables = commonKvps.size(); + gameKvps->numVariables = static_cast(commonKvps.size()); gameKvps->keyValuePairs = m_memory.Alloc(commonKvps.size()); const auto namespaceHash = Common::Com_HashKey(m_zone.m_name.c_str(), 64); diff --git a/src/ObjCompiling/Image/IPak/IPakCreator.cpp b/src/ObjCompiling/Image/IPak/IPakCreator.cpp index 365edd51..64134b2b 100644 --- a/src/ObjCompiling/Image/IPak/IPakCreator.cpp +++ b/src/ObjCompiling/Image/IPak/IPakCreator.cpp @@ -1,7 +1,6 @@ #include "IPakCreator.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/GameT6.h" #include "GitVersion.h" #include "ObjContainer/IPak/IPakTypes.h" #include "Utils/Alignment.h" @@ -23,7 +22,7 @@ namespace static constexpr char BRANDING[] = "Created with OpenAssetTools " GIT_VERSION; static constexpr auto SECTION_COUNT = 3; // Index + Data + Branding - inline static const std::string PAD_DATA = std::string(256, '\xA7'); + inline static const auto PAD_DATA = std::string(256, '\xA7'); public: IPakWriter(std::ostream& stream, ISearchPath& searchPath, const std::vector& images) @@ -70,8 +69,8 @@ namespace void Write(const void* data, const size_t dataSize) { - m_stream.write(static_cast(data), dataSize); - m_current_offset += dataSize; + m_stream.write(static_cast(data), static_cast(dataSize)); + m_current_offset += static_cast(dataSize); } void Pad(const size_t paddingSize) @@ -100,27 +99,30 @@ namespace { GoTo(0); - const IPakHeader header{ipak_consts::IPAK_MAGIC, ipak_consts::IPAK_VERSION, static_cast(m_total_size), SECTION_COUNT}; + const IPakHeader header{.magic = ipak_consts::IPAK_MAGIC, + .version = ipak_consts::IPAK_VERSION, + .size = static_cast(m_total_size), + .sectionCount = SECTION_COUNT}; const IPakSection dataSection{ - ipak_consts::IPAK_DATA_SECTION, - static_cast(m_data_section_offset), - static_cast(m_data_section_size), - static_cast(m_index_entries.size()), + .type = ipak_consts::IPAK_DATA_SECTION, + .offset = static_cast(m_data_section_offset), + .size = static_cast(m_data_section_size), + .itemCount = static_cast(m_index_entries.size()), }; const IPakSection indexSection{ - ipak_consts::IPAK_INDEX_SECTION, - static_cast(m_index_section_offset), - static_cast(sizeof(IPakIndexEntry) * m_index_entries.size()), - static_cast(m_index_entries.size()), + .type = ipak_consts::IPAK_INDEX_SECTION, + .offset = static_cast(m_index_section_offset), + .size = static_cast(sizeof(IPakIndexEntry) * m_index_entries.size()), + .itemCount = static_cast(m_index_entries.size()), }; const IPakSection brandingSection{ - ipak_consts::IPAK_BRANDING_SECTION, - static_cast(m_branding_section_offset), - std::extent_v, - 1, + .type = ipak_consts::IPAK_BRANDING_SECTION, + .offset = static_cast(m_branding_section_offset), + .size = std::extent_v, + .itemCount = 1, }; Write(&header, sizeof(header)); @@ -147,7 +149,7 @@ namespace imageSize = static_cast(openFile.m_length); auto imageData = std::make_unique(imageSize); - openFile.m_stream->read(imageData.get(), imageSize); + openFile.m_stream->read(imageData.get(), static_cast(imageSize)); return imageData; } @@ -177,7 +179,7 @@ namespace IPakDataBlockHeader skipBlockHeader{}; skipBlockHeader.countAndOffset.count = 1; skipBlockHeader.commands[0].compressed = ipak_consts::IPAK_COMMAND_SKIP; - skipBlockHeader.commands[0].size = sizeToSkip - sizeof(IPakDataBlockHeader); + skipBlockHeader.commands[0].size = static_cast(sizeToSkip - sizeof(IPakDataBlockHeader)); Write(&skipBlockHeader, sizeof(skipBlockHeader)); } @@ -199,12 +201,12 @@ namespace m_current_block.countAndOffset.offset = static_cast(m_file_offset); // Reserve space to later write actual block header data - GoTo(m_current_offset + sizeof(IPakDataBlockHeader)); + GoTo(static_cast(m_current_offset + sizeof(IPakDataBlockHeader))); } void WriteChunkData(const void* data, const size_t dataSize) { - auto dataOffset = 0u; + auto dataOffset = 0uz; while (dataOffset < dataSize) { if (m_current_block.countAndOffset.count >= std::extent_v) @@ -225,7 +227,7 @@ namespace continue; } - const auto commandSize = std::min(std::min(remainingSize, ipak_consts::IPAK_COMMAND_DEFAULT_SIZE), remainingChunkBufferWindowSize); + const auto commandSize = std::min({remainingSize, ipak_consts::IPAK_COMMAND_DEFAULT_SIZE, remainingChunkBufferWindowSize}); auto writeUncompressed = true; if (USE_IPAK_COMPRESSION) @@ -254,7 +256,7 @@ namespace Write(&static_cast(data)[dataOffset], commandSize); const auto currentCommand = m_current_block.countAndOffset.count; - m_current_block.commands[currentCommand].size = commandSize; + m_current_block.commands[currentCommand].size = static_cast(commandSize); m_current_block.commands[currentCommand].compressed = ipak_consts::IPAK_COMMAND_UNCOMPRESSED; m_current_block.countAndOffset.count = currentCommand + 1u; } @@ -281,7 +283,7 @@ namespace return; const auto nameHash = T6::Common::R_HashString(imageName.c_str(), 0); - const auto dataHash = static_cast(crc32(0u, reinterpret_cast(imageData.get()), imageSize)); + const auto dataHash = static_cast(crc32(0u, reinterpret_cast(imageData.get()), static_cast(imageSize))); StartNewFile(); const auto startOffset = m_current_block_header_offset; @@ -294,7 +296,7 @@ namespace WriteChunkData(imageData.get(), imageSize); const auto writtenImageSize = static_cast(m_current_offset - startOffset); - indexEntry.size = writtenImageSize; + indexEntry.size = static_cast(writtenImageSize); m_index_entries.emplace_back(indexEntry); } diff --git a/src/ObjImage/Image/DdsLoader.cpp b/src/ObjImage/Image/DdsLoader.cpp index f61a439b..6fbd617b 100644 --- a/src/ObjImage/Image/DdsLoader.cpp +++ b/src/ObjImage/Image/DdsLoader.cpp @@ -14,16 +14,28 @@ namespace dds { static constexpr auto DDS_MAGIC = FileUtils::MakeMagic32('D', 'D', 'S', ' '); - std::istream& m_stream; + public: + explicit DdsLoaderInternal(std::istream& stream) + : m_stream(stream), + m_texture_type(TextureType::T_2D), + m_has_mip_maps(false), + m_width(0u), + m_height(0u), + m_depth(0u), + m_format(nullptr) + { + } - TextureType m_texture_type; - bool m_has_mip_maps; - size_t m_width; - size_t m_height; - size_t m_depth; - const ImageFormat* m_format; + std::unique_ptr LoadDds() + { + if (!ReadMagic() || !ReadHeader()) + return nullptr; - _NODISCARD bool ReadMagic() const + return ReadTextureData(); + } + + private: + [[nodiscard]] bool ReadMagic() const { uint32_t magic; m_stream.read(reinterpret_cast(&magic), sizeof(magic)); @@ -42,7 +54,7 @@ namespace dds return true; } - _NODISCARD bool ReadDxt10Header() + [[nodiscard]] bool ReadDxt10Header() { DDS_HEADER_DXT10 headerDx10{}; m_stream.read(reinterpret_cast(&headerDx10), sizeof(headerDx10)); @@ -86,7 +98,7 @@ namespace dds return false; } - _NODISCARD bool ReadPixelFormatFourCc(DDS_PIXELFORMAT& pf) + [[nodiscard]] bool ReadPixelFormatFourCc(DDS_PIXELFORMAT& pf) { switch (pf.dwFourCC) { @@ -132,7 +144,7 @@ namespace dds } } - _NODISCARD bool ReadPixelFormatUnsigned(DDS_PIXELFORMAT& pf) + [[nodiscard]] bool ReadPixelFormatUnsigned(DDS_PIXELFORMAT& pf) { unsigned rOffset, rSize, gOffset, gSize, bOffset, bSize, aOffset, aSize; @@ -163,7 +175,7 @@ namespace dds return false; } - _NODISCARD bool ReadPixelFormat(DDS_PIXELFORMAT& pf) + [[nodiscard]] bool ReadPixelFormat(DDS_PIXELFORMAT& pf) { if (pf.dwFlags & DDPF_FOURCC) return ReadPixelFormatFourCc(pf); @@ -200,7 +212,7 @@ namespace dds return ReadPixelFormat(header.ddspf); } - _NODISCARD std::unique_ptr ReadTextureData() const + [[nodiscard]] std::unique_ptr ReadTextureData() const { std::unique_ptr result; @@ -229,7 +241,7 @@ namespace dds for (auto mipLevel = 0; mipLevel < mipMapCount; mipLevel++) { - const auto mipSize = result->GetSizeOfMipLevel(mipLevel); + const auto mipSize = static_cast(result->GetSizeOfMipLevel(mipLevel)); for (auto face = 0; face < faceCount; face++) { @@ -246,25 +258,14 @@ namespace dds return result; } - public: - explicit DdsLoaderInternal(std::istream& stream) - : m_stream(stream), - m_texture_type(TextureType::T_2D), - m_has_mip_maps(false), - m_width(0u), - m_height(0u), - m_depth(0u), - m_format(nullptr) - { - } + std::istream& m_stream; - std::unique_ptr LoadDds() - { - if (!ReadMagic() || !ReadHeader()) - return nullptr; - - return ReadTextureData(); - } + TextureType m_texture_type; + bool m_has_mip_maps; + unsigned m_width; + unsigned m_height; + unsigned m_depth; + const ImageFormat* m_format; }; std::unique_ptr LoadDds(std::istream& stream) diff --git a/src/ObjImage/Image/DdsWriter.cpp b/src/ObjImage/Image/DdsWriter.cpp index 324dad40..93e88da0 100644 --- a/src/ObjImage/Image/DdsWriter.cpp +++ b/src/ObjImage/Image/DdsWriter.cpp @@ -55,7 +55,7 @@ public: { const auto* buffer = m_texture->GetBufferForMipLevel(mipLevel); const auto mipLevelSize = m_texture->GetSizeOfMipLevel(mipLevel) * m_texture->GetFaceCount(); - m_stream.write(reinterpret_cast(buffer), mipLevelSize); + m_stream.write(reinterpret_cast(buffer), static_cast(mipLevelSize)); } } @@ -153,7 +153,7 @@ public: header.dwHeight = m_texture->GetHeight(); header.dwWidth = m_texture->GetWidth(); header.dwDepth = m_texture->GetDepth(); - header.dwPitchOrLinearSize = m_texture->GetFormat()->GetPitch(0, m_texture->GetWidth()); + header.dwPitchOrLinearSize = static_cast(m_texture->GetFormat()->GetPitch(0, m_texture->GetWidth())); header.dwMipMapCount = m_texture->HasMipMaps() ? m_texture->GetMipMapCount() : 1; PopulatePixelFormat(header.ddspf); diff --git a/src/ObjImage/Image/Dx12TextureLoader.cpp b/src/ObjImage/Image/Dx12TextureLoader.cpp index 5402a4a8..4e1fe3c0 100644 --- a/src/ObjImage/Image/Dx12TextureLoader.cpp +++ b/src/ObjImage/Image/Dx12TextureLoader.cpp @@ -14,7 +14,7 @@ Dx12TextureLoader::Dx12TextureLoader() const ImageFormat* Dx12TextureLoader::GetFormatForDx12Format() const { - for (auto i : ImageFormat::ALL_FORMATS) + for (const auto* i : ImageFormat::ALL_FORMATS) { if (i->GetDxgiFormat() == m_format) return i; @@ -41,19 +41,19 @@ Dx12TextureLoader& Dx12TextureLoader::HasMipMaps(const bool hasMipMaps) return *this; } -Dx12TextureLoader& Dx12TextureLoader::Width(const size_t width) +Dx12TextureLoader& Dx12TextureLoader::Width(const unsigned width) { m_width = width; return *this; } -Dx12TextureLoader& Dx12TextureLoader::Height(const size_t height) +Dx12TextureLoader& Dx12TextureLoader::Height(const unsigned height) { m_height = height; return *this; } -Dx12TextureLoader& Dx12TextureLoader::Depth(const size_t depth) +Dx12TextureLoader& Dx12TextureLoader::Depth(const unsigned depth) { m_depth = depth; return *this; diff --git a/src/ObjImage/Image/Dx12TextureLoader.h b/src/ObjImage/Image/Dx12TextureLoader.h index 9309f9e4..128d2b69 100644 --- a/src/ObjImage/Image/Dx12TextureLoader.h +++ b/src/ObjImage/Image/Dx12TextureLoader.h @@ -2,8 +2,6 @@ #include "Image/DxgiFormat.h" #include "Image/Texture.h" -#include "Utils/ClassUtils.h" -#include "Utils/MemoryManager.h" #include #include @@ -16,21 +14,21 @@ public: Dx12TextureLoader& Format(oat::DXGI_FORMAT format); Dx12TextureLoader& Type(TextureType textureType); Dx12TextureLoader& HasMipMaps(bool hasMipMaps); - Dx12TextureLoader& Width(size_t width); - Dx12TextureLoader& Height(size_t height); - Dx12TextureLoader& Depth(size_t depth); + Dx12TextureLoader& Width(unsigned width); + Dx12TextureLoader& Height(unsigned height); + Dx12TextureLoader& Depth(unsigned depth); std::unique_ptr LoadTexture(const void* data); private: - _NODISCARD const ImageFormat* GetFormatForDx12Format() const; + [[nodiscard]] const ImageFormat* GetFormatForDx12Format() const; static std::unordered_map m_conversion_table; oat::DXGI_FORMAT m_format; TextureType m_type; bool m_has_mip_maps; - size_t m_width; - size_t m_height; - size_t m_depth; + unsigned m_width; + unsigned m_height; + unsigned m_depth; }; diff --git a/src/ObjImage/Image/Dx9TextureLoader.cpp b/src/ObjImage/Image/Dx9TextureLoader.cpp index 7c3ba93b..9d319bd0 100644 --- a/src/ObjImage/Image/Dx9TextureLoader.cpp +++ b/src/ObjImage/Image/Dx9TextureLoader.cpp @@ -41,19 +41,19 @@ Dx9TextureLoader& Dx9TextureLoader::HasMipMaps(const bool hasMipMaps) return *this; } -Dx9TextureLoader& Dx9TextureLoader::Width(const size_t width) +Dx9TextureLoader& Dx9TextureLoader::Width(const unsigned width) { m_width = width; return *this; } -Dx9TextureLoader& Dx9TextureLoader::Height(const size_t height) +Dx9TextureLoader& Dx9TextureLoader::Height(const unsigned height) { m_height = height; return *this; } -Dx9TextureLoader& Dx9TextureLoader::Depth(const size_t depth) +Dx9TextureLoader& Dx9TextureLoader::Depth(const unsigned depth) { m_depth = depth; return *this; diff --git a/src/ObjImage/Image/Dx9TextureLoader.h b/src/ObjImage/Image/Dx9TextureLoader.h index 5baa5266..212714d4 100644 --- a/src/ObjImage/Image/Dx9TextureLoader.h +++ b/src/ObjImage/Image/Dx9TextureLoader.h @@ -2,11 +2,8 @@ #include "Image/D3DFormat.h" #include "Image/Texture.h" -#include "Utils/ClassUtils.h" -#include "Utils/MemoryManager.h" #include -#include class Dx9TextureLoader { @@ -16,19 +13,19 @@ public: Dx9TextureLoader& Format(oat::D3DFORMAT format); Dx9TextureLoader& Type(TextureType textureType); Dx9TextureLoader& HasMipMaps(bool hasMipMaps); - Dx9TextureLoader& Width(size_t width); - Dx9TextureLoader& Height(size_t height); - Dx9TextureLoader& Depth(size_t depth); + Dx9TextureLoader& Width(unsigned width); + Dx9TextureLoader& Height(unsigned height); + Dx9TextureLoader& Depth(unsigned depth); std::unique_ptr LoadTexture(const void* data); private: - _NODISCARD const ImageFormat* GetFormatForDx9Format() const; + [[nodiscard]] const ImageFormat* GetFormatForDx9Format() const; oat::D3DFORMAT m_format; TextureType m_type; bool m_has_mip_maps; - size_t m_width; - size_t m_height; - size_t m_depth; + unsigned m_width; + unsigned m_height; + unsigned m_depth; }; diff --git a/src/ObjImage/Image/ImageFormat.h b/src/ObjImage/Image/ImageFormat.h index bcd825c7..b87f6ac5 100644 --- a/src/ObjImage/Image/ImageFormat.h +++ b/src/ObjImage/Image/ImageFormat.h @@ -48,13 +48,13 @@ protected: public: virtual ~ImageFormat() = default; - ImageFormatId GetId() const; - oat::D3DFORMAT GetD3DFormat() const; - oat::DXGI_FORMAT GetDxgiFormat() const; + [[nodiscard]] ImageFormatId GetId() const; + [[nodiscard]] oat::D3DFORMAT GetD3DFormat() const; + [[nodiscard]] oat::DXGI_FORMAT GetDxgiFormat() const; - virtual ImageFormatType GetType() const = 0; - virtual size_t GetPitch(unsigned mipLevel, unsigned width) const = 0; - virtual size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const = 0; + [[nodiscard]] virtual ImageFormatType GetType() const = 0; + [[nodiscard]] virtual size_t GetPitch(unsigned mipLevel, unsigned width) const = 0; + [[nodiscard]] virtual size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const = 0; static const ImageFormatUnsigned FORMAT_R8_G8_B8; static const ImageFormatUnsigned FORMAT_B8_G8_R8_X8; @@ -98,14 +98,14 @@ public: unsigned aOffset, unsigned aSize); - ImageFormatType GetType() const override; - size_t GetPitch(unsigned mipLevel, unsigned width) const override; - size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override; + [[nodiscard]] ImageFormatType GetType() const override; + [[nodiscard]] size_t GetPitch(unsigned mipLevel, unsigned width) const override; + [[nodiscard]] size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override; - bool HasR() const; - bool HasG() const; - bool HasB() const; - bool HasA() const; + [[nodiscard]] bool HasR() const; + [[nodiscard]] bool HasG() const; + [[nodiscard]] bool HasB() const; + [[nodiscard]] bool HasA() const; }; class ImageFormatBlockCompressed final : public ImageFormat @@ -116,7 +116,7 @@ public: ImageFormatBlockCompressed(ImageFormatId id, oat::D3DFORMAT d3dFormat, oat::DXGI_FORMAT dxgiFormat, unsigned blockSize, unsigned bitsPerBlock); - ImageFormatType GetType() const override; - size_t GetPitch(unsigned mipLevel, unsigned width) const override; - size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override; + [[nodiscard]] ImageFormatType GetType() const override; + [[nodiscard]] size_t GetPitch(unsigned mipLevel, unsigned width) const override; + [[nodiscard]] size_t GetSizeOfMipLevel(unsigned mipLevel, unsigned width, unsigned height, unsigned depth) const override; }; diff --git a/src/ObjImage/Image/IwiWriter13.cpp b/src/ObjImage/Image/IwiWriter13.cpp index b354b6bf..4401fdd6 100644 --- a/src/ObjImage/Image/IwiWriter13.cpp +++ b/src/ObjImage/Image/IwiWriter13.cpp @@ -110,7 +110,7 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture) currentFileSize += mipLevelSize; if (currentMipLevel < static_cast(std::extent_v)) - header.fileSizeForPicmip[currentMipLevel] = currentFileSize; + header.fileSizeForPicmip[currentMipLevel] = static_cast(currentFileSize); } if (const auto* texture2D = dynamic_cast(texture)) diff --git a/src/ObjImage/Image/IwiWriter27.cpp b/src/ObjImage/Image/IwiWriter27.cpp index 06dbfd9f..8509fabf 100644 --- a/src/ObjImage/Image/IwiWriter27.cpp +++ b/src/ObjImage/Image/IwiWriter27.cpp @@ -113,7 +113,7 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture) currentFileSize += mipLevelSize; if (currentMipLevel < static_cast(std::extent_v)) - header.fileSizeForPicmip[currentMipLevel] = currentFileSize; + header.fileSizeForPicmip[currentMipLevel] = static_cast(currentFileSize); } if (const auto* texture2D = dynamic_cast(texture)) diff --git a/src/ObjImage/Image/IwiWriter6.cpp b/src/ObjImage/Image/IwiWriter6.cpp index af6102de..9c91c6be 100644 --- a/src/ObjImage/Image/IwiWriter6.cpp +++ b/src/ObjImage/Image/IwiWriter6.cpp @@ -105,7 +105,7 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture) currentFileSize += mipLevelSize; if (currentMipLevel < static_cast(std::extent_v)) - header.fileSizeForPicmip[currentMipLevel] = currentFileSize; + header.fileSizeForPicmip[currentMipLevel] = static_cast(currentFileSize); } if (const auto* texture2D = dynamic_cast(texture)) diff --git a/src/ObjImage/Image/IwiWriter8.cpp b/src/ObjImage/Image/IwiWriter8.cpp index c062bd04..7cad5095 100644 --- a/src/ObjImage/Image/IwiWriter8.cpp +++ b/src/ObjImage/Image/IwiWriter8.cpp @@ -105,7 +105,7 @@ void IwiWriter::DumpImage(std::ostream& stream, const Texture* texture) currentFileSize += mipLevelSize; if (currentMipLevel < static_cast(std::extent_v)) - header.fileSizeForPicmip[currentMipLevel] = currentFileSize; + header.fileSizeForPicmip[currentMipLevel] = static_cast(currentFileSize); } if (const auto* texture2D = dynamic_cast(texture))