diff --git a/src/ObjLoading/ObjContainer/IPak/IPak.cpp b/src/ObjLoading/ObjContainer/IPak/IPak.cpp index 1f87d471..fd8dc343 100644 --- a/src/ObjLoading/ObjContainer/IPak/IPak.cpp +++ b/src/ObjLoading/ObjContainer/IPak/IPak.cpp @@ -46,8 +46,8 @@ class IPak::Impl : public ObjContainerReferenceable for (unsigned itemIndex = 0; itemIndex < m_index_section->itemCount; itemIndex++) { - m_stream->read(reinterpret_cast(&indexEntry), sizeof indexEntry); - if (m_stream->gcount() != sizeof indexEntry) + m_stream->read(reinterpret_cast(&indexEntry), sizeof(indexEntry)); + if (m_stream->gcount() != sizeof(indexEntry)) { printf("Unexpected eof when trying to load index entry %u.\n", itemIndex); return false; @@ -99,7 +99,7 @@ class IPak::Impl : public ObjContainerReferenceable IPakHeader header{}; m_stream->read(reinterpret_cast(&header), sizeof(header)); - if (m_stream->gcount() != sizeof header) + if (m_stream->gcount() != sizeof(header)) { printf("Unexpected eof when trying to load header.\n"); return false; diff --git a/src/ObjLoading/ObjContainer/IWD/IWD.cpp b/src/ObjLoading/ObjContainer/IWD/IWD.cpp index 55be6e2a..7c046cfc 100644 --- a/src/ObjLoading/ObjContainer/IWD/IWD.cpp +++ b/src/ObjLoading/ObjContainer/IWD/IWD.cpp @@ -126,7 +126,7 @@ protected: while (skipAmount > 0) { char temp[1024]; - const auto toRead = skipAmount > sizeof temp ? sizeof temp : static_cast(skipAmount); + const auto toRead = skipAmount > sizeof(temp) ? sizeof(temp) : static_cast(skipAmount); unzReadCurrentFile(m_container, temp, toRead); skipAmount -= toRead; } @@ -216,7 +216,7 @@ public: { unz_file_info64 info; char fileNameBuffer[256]; - unzGetCurrentFileInfo64(m_unz_file, &info, fileNameBuffer, sizeof fileNameBuffer, nullptr, 0, nullptr, 0); + unzGetCurrentFileInfo64(m_unz_file, &info, fileNameBuffer, sizeof(fileNameBuffer), nullptr, 0, nullptr, 0); std::string fileName(fileNameBuffer); std::filesystem::path path(fileName); diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp index 559c4c4e..4eca53a6 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp @@ -44,7 +44,7 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo 0) { zs.next_out = buffer; - zs.avail_out = sizeof buffer; + zs.avail_out = sizeof(buffer); ret = inflate(&zs, Z_SYNC_FLUSH); if (ret < 0) @@ -54,7 +54,7 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo(buffer), sizeof buffer - zs.avail_out); + stream.write(reinterpret_cast(buffer), sizeof(buffer) - zs.avail_out); } inflateEnd(&zs); diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp index 922057e8..17e5af95 100644 --- a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp @@ -44,7 +44,7 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo 0) { zs.next_out = buffer; - zs.avail_out = sizeof buffer; + zs.avail_out = sizeof(buffer); ret = inflate(&zs, Z_SYNC_FLUSH); if (ret < 0) @@ -54,7 +54,7 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo(buffer), sizeof buffer - zs.avail_out); + stream.write(reinterpret_cast(buffer), sizeof(buffer) - zs.avail_out); } inflateEnd(&zs); diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.cpp index 1bba8ebb..a3281733 100644 --- a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.cpp @@ -59,7 +59,7 @@ void AssetDumperRawFile::DumpGsc(AssetDumpingContext& context, XAssetInfo 0) { zs.next_out = buffer; - zs.avail_out = sizeof buffer; + zs.avail_out = sizeof(buffer); ret = inflate(&zs, Z_SYNC_FLUSH); if (ret < 0) @@ -69,7 +69,7 @@ void AssetDumperRawFile::DumpGsc(AssetDumpingContext& context, XAssetInfo= outLen) { diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp index 6a9ebd3c..d8ab18bb 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp @@ -55,7 +55,7 @@ void AssetDumperRawFile::DumpAnimtree(AssetDumpingContext& context, XAssetInfo 0) { zs.next_out = buffer; - zs.avail_out = sizeof buffer; + zs.avail_out = sizeof(buffer); ret = inflate(&zs, Z_SYNC_FLUSH); if (ret < 0) @@ -65,7 +65,7 @@ void AssetDumperRawFile::DumpAnimtree(AssetDumpingContext& context, XAssetInfo(buffer), inflateOutSize); } diff --git a/src/ObjWriting/Image/DdsWriter.cpp b/src/ObjWriting/Image/DdsWriter.cpp index 308499c7..5ecf0ec4 100644 --- a/src/ObjWriting/Image/DdsWriter.cpp +++ b/src/ObjWriting/Image/DdsWriter.cpp @@ -95,7 +95,7 @@ class DdsWriterInternal void PopulateDdsHeader(DDS_HEADER& header) { - header.dwSize = sizeof header; + header.dwSize = sizeof(header); header.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; if (m_texture->HasMipMaps()) @@ -201,14 +201,14 @@ public: constexpr auto magic = MakeFourCc('D', 'D', 'S', ' '); - m_stream.write(reinterpret_cast(&magic), sizeof magic); - m_stream.write(reinterpret_cast(&header), sizeof header); + m_stream.write(reinterpret_cast(&magic), sizeof(magic)); + m_stream.write(reinterpret_cast(&header), sizeof(header)); if (m_use_dx10_extension) { DDS_HEADER_DXT10 dxt10{}; PopulateDxt10Header(dxt10); - m_stream.write(reinterpret_cast(&dxt10), sizeof dxt10); + m_stream.write(reinterpret_cast(&dxt10), sizeof(dxt10)); } const auto mipCount = m_texture->HasMipMaps() ? m_texture->GetMipMapCount() : 1; diff --git a/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp b/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp index 045ef2bb..e6dfea2b 100644 --- a/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp +++ b/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp @@ -146,7 +146,7 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); XAssetList assetList{}; - m_stream->LoadDataRaw(&assetList, sizeof assetList); + m_stream->LoadDataRaw(&assetList, sizeof(assetList)); varScriptStringList = &assetList.stringList; LoadScriptStringList(false); diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp index 209edc7e..49eecd4c 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp @@ -166,7 +166,7 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); XAssetList assetList{}; - m_stream->LoadDataRaw(&assetList, sizeof assetList); + m_stream->LoadDataRaw(&assetList, sizeof(assetList)); varScriptStringList = &assetList.stringList; LoadScriptStringList(false); diff --git a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp index b8421aef..7b0163c3 100644 --- a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp @@ -130,11 +130,11 @@ class ZoneLoaderFactory::Impl zoneLoader->AddLoadingStep(std::make_unique(ZoneConstants::MAGIC_AUTH_HEADER)); zoneLoader->AddLoadingStep(std::make_unique(4)); // Skip reserved - auto subHeaderHash = std::make_unique(sizeof DB_AuthHash::bytes, 1); + auto subHeaderHash = std::make_unique(sizeof(DB_AuthHash::bytes), 1); auto* subHeaderHashPtr = subHeaderHash.get(); zoneLoader->AddLoadingStep(std::move(subHeaderHash)); - auto subHeaderHashSignature = std::make_unique(sizeof DB_AuthSignature::bytes); + auto subHeaderHashSignature = std::make_unique(sizeof(DB_AuthSignature::bytes)); auto* subHeaderHashSignaturePtr = subHeaderHashSignature.get(); zoneLoader->AddLoadingStep(std::move(subHeaderHashSignature)); @@ -147,7 +147,7 @@ class ZoneLoaderFactory::Impl zoneLoader->AddLoadingStep(std::make_unique(fileName, sizeof(DB_AuthSubHeader::fastfileName))); zoneLoader->AddLoadingStep(std::make_unique(4)); // Skip reserved - auto masterBlockHashes = std::make_unique(sizeof DB_AuthHash::bytes, std::extent_v); + auto masterBlockHashes = std::make_unique(sizeof(DB_AuthHash::bytes), std::extent_v); auto* masterBlockHashesPtr = masterBlockHashes.get(); zoneLoader->AddLoadingStep(std::move(masterBlockHashes)); diff --git a/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp b/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp index 7eca7251..97dbf4d7 100644 --- a/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp +++ b/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp @@ -175,7 +175,7 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); XAssetList assetList{}; - m_stream->LoadDataRaw(&assetList, sizeof assetList); + m_stream->LoadDataRaw(&assetList, sizeof(assetList)); varScriptStringList = &assetList.stringList; LoadScriptStringList(false); diff --git a/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp b/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp index 505ca3a0..f2202fd5 100644 --- a/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp +++ b/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp @@ -114,11 +114,11 @@ class ZoneLoaderFactory::Impl zoneLoader->AddLoadingStep(std::make_unique(ZoneConstants::MAGIC_AUTH_HEADER)); zoneLoader->AddLoadingStep(std::make_unique(4)); // Skip reserved - auto subHeaderHash = std::make_unique(sizeof DB_AuthHash::bytes, 1); + auto subHeaderHash = std::make_unique(sizeof(DB_AuthHash::bytes), 1); auto* subHeaderHashPtr = subHeaderHash.get(); zoneLoader->AddLoadingStep(std::move(subHeaderHash)); - auto subHeaderHashSignature = std::make_unique(sizeof DB_AuthSignature::bytes); + auto subHeaderHashSignature = std::make_unique(sizeof(DB_AuthSignature::bytes)); auto* subHeaderHashSignaturePtr = subHeaderHashSignature.get(); zoneLoader->AddLoadingStep(std::move(subHeaderHashSignature)); @@ -131,7 +131,7 @@ class ZoneLoaderFactory::Impl zoneLoader->AddLoadingStep(std::make_unique(fileName, sizeof(DB_AuthSubHeader::fastfileName))); zoneLoader->AddLoadingStep(std::make_unique(4)); // Skip reserved - auto masterBlockHashes = std::make_unique(sizeof DB_AuthHash::bytes, std::extent_v); + auto masterBlockHashes = std::make_unique(sizeof(DB_AuthHash::bytes), std::extent_v); auto* masterBlockHashesPtr = masterBlockHashes.get(); zoneLoader->AddLoadingStep(std::move(masterBlockHashes)); diff --git a/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp b/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp index 5a174a97..921de0d4 100644 --- a/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp +++ b/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp @@ -159,7 +159,7 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); XAssetList assetList{}; - m_stream->LoadDataRaw(&assetList, sizeof assetList); + m_stream->LoadDataRaw(&assetList, sizeof(assetList)); varScriptStringList = &assetList.stringList; LoadScriptStringList(false); diff --git a/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp b/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp index 7c82bee6..106b8c09 100644 --- a/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp +++ b/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp @@ -188,7 +188,7 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); XAssetList assetList{}; - m_stream->LoadDataRaw(&assetList, sizeof assetList); + m_stream->LoadDataRaw(&assetList, sizeof(assetList)); varScriptStringList = &assetList.stringList; LoadScriptStringList(false); diff --git a/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp b/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp index 11553fe0..1a48ff01 100644 --- a/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp +++ b/src/ZoneLoading/Loading/Processor/ProcessorXChunks.cpp @@ -150,16 +150,16 @@ class ProcessorXChunks::ProcessorXChunksImpl xchunk_size_t chunkSize; if (m_vanilla_buffer_size > 0) { - if (m_vanilla_buffer_offset + sizeof chunkSize > m_vanilla_buffer_size) + if (m_vanilla_buffer_offset + sizeof(chunkSize) > m_vanilla_buffer_size) { m_base->m_base_stream->Load(&chunkSize, m_vanilla_buffer_size - m_vanilla_buffer_offset); m_vanilla_buffer_offset = 0; } - m_vanilla_buffer_offset = (m_vanilla_buffer_offset + sizeof chunkSize) % m_vanilla_buffer_size; + m_vanilla_buffer_offset = (m_vanilla_buffer_offset + sizeof(chunkSize)) % m_vanilla_buffer_size; } - const size_t readSize = m_base->m_base_stream->Load(&chunkSize, sizeof chunkSize); + const size_t readSize = m_base->m_base_stream->Load(&chunkSize, sizeof(chunkSize)); if (readSize == 0) { diff --git a/src/ZoneLoading/ZoneLoading.cpp b/src/ZoneLoading/ZoneLoading.cpp index 6842cb1f..8aed7c3b 100644 --- a/src/ZoneLoading/ZoneLoading.cpp +++ b/src/ZoneLoading/ZoneLoading.cpp @@ -33,8 +33,8 @@ std::unique_ptr ZoneLoading::LoadZone(const std::string& path) } ZoneHeader header{}; - file.read(reinterpret_cast(&header), sizeof header); - if (file.gcount() != sizeof header) + file.read(reinterpret_cast(&header), sizeof(header)); + if (file.gcount() != sizeof(header)) { std::cout << "Failed to read zone header from file '" << path << "'.\n"; return nullptr;