diff --git a/src/Linker/LinkerPaths.cpp b/src/Linker/LinkerPaths.cpp index 730f71c7..37631e49 100644 --- a/src/Linker/LinkerPaths.cpp +++ b/src/Linker/LinkerPaths.cpp @@ -56,8 +56,8 @@ namespace void CreateFromString(const std::string& templateString) { const auto templateStringLength = templateString.size(); - auto partStart = 0u; - for (auto i = 0u; i < templateStringLength; i++) + auto partStart = 0uz; + for (auto i = 0uz; i < templateStringLength; i++) { if (templateString[i] != '?') continue; diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp index 0382088e..e95b1d47 100644 --- a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp +++ b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp @@ -126,10 +126,10 @@ namespace bone.globalOffset[1] = model->baseMat[boneNum].trans[1]; bone.globalOffset[2] = model->baseMat[boneNum].trans[2]; bone.globalRotation = { - model->baseMat[boneNum].quat[0], - model->baseMat[boneNum].quat[1], - model->baseMat[boneNum].quat[2], - model->baseMat[boneNum].quat[3], + .x = model->baseMat[boneNum].quat[0], + .y = model->baseMat[boneNum].quat[1], + .z = model->baseMat[boneNum].quat[2], + .w = model->baseMat[boneNum].quat[3], }; if (boneNum < model->numRootBones) @@ -137,7 +137,7 @@ namespace bone.localOffset[0] = 0; bone.localOffset[1] = 0; bone.localOffset[2] = 0; - bone.localRotation = {0, 0, 0, 1}; + bone.localRotation = {.x = 0, .y = 0, .z = 0, .w = 1}; } else { @@ -145,10 +145,10 @@ namespace bone.localOffset[1] = model->trans[boneNum - model->numRootBones][1]; bone.localOffset[2] = model->trans[boneNum - model->numRootBones][2]; bone.localRotation = { - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]), - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]), - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]), - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]), + .x = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]), + .y = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]), + .z = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]), + .w = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]), }; } @@ -166,7 +166,7 @@ namespace void AddXModelMaterials(XModelCommon& out, DistinctMapper& materialMapper, const XModel* model) { - for (auto surfaceMaterialNum = 0; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++) + for (auto surfaceMaterialNum = 0u; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++) { Material* material = model->materialHandles[surfaceMaterialNum]; if (materialMapper.Add(material)) @@ -271,7 +271,7 @@ namespace const auto surfCount = model->lodInfo[lod].numsurfs; auto& weightCollection = out.m_bone_weight_data; - size_t weightOffset = 0u; + auto weightOffset = 0u; for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++) { @@ -285,7 +285,8 @@ namespace const auto& vertList = surface.vertList[vertListIndex]; const auto boneWeightOffset = weightOffset; - weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f}; + weightCollection.weights[weightOffset++] = + XModelBoneWeight{.boneIndex = static_cast(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f}; for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++) { @@ -303,7 +304,7 @@ namespace { const auto boneWeightOffset = weightOffset; const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat); - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f}; vertsBlendOffset += 1; @@ -319,8 +320,8 @@ namespace const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]); const auto boneWeight0 = 1.0f - boneWeight1; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1}; vertsBlendOffset += 3; @@ -338,9 +339,9 @@ namespace const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]); const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2}; vertsBlendOffset += 5; @@ -360,10 +361,10 @@ namespace const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]); const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex3, boneWeight3}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex3, .weight = boneWeight3}; vertsBlendOffset += 7; diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp index 3b9987e6..efb8dfd3 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp @@ -121,10 +121,10 @@ namespace bone.globalOffset[1] = model->baseMat[boneNum].trans[1]; bone.globalOffset[2] = model->baseMat[boneNum].trans[2]; bone.globalRotation = { - model->baseMat[boneNum].quat[0], - model->baseMat[boneNum].quat[1], - model->baseMat[boneNum].quat[2], - model->baseMat[boneNum].quat[3], + .x = model->baseMat[boneNum].quat[0], + .y = model->baseMat[boneNum].quat[1], + .z = model->baseMat[boneNum].quat[2], + .w = model->baseMat[boneNum].quat[3], }; if (boneNum < model->numRootBones) @@ -132,7 +132,7 @@ namespace bone.localOffset[0] = 0; bone.localOffset[1] = 0; bone.localOffset[2] = 0; - bone.localRotation = {0, 0, 0, 1}; + bone.localRotation = {.x = 0, .y = 0, .z = 0, .w = 1}; } else { @@ -140,10 +140,10 @@ namespace bone.localOffset[1] = model->trans[boneNum - model->numRootBones][1]; bone.localOffset[2] = model->trans[boneNum - model->numRootBones][2]; bone.localRotation = { - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]), - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]), - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]), - QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]), + .x = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]), + .y = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]), + .z = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]), + .w = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]), }; } @@ -161,7 +161,7 @@ namespace void AddXModelMaterials(XModelCommon& out, DistinctMapper& materialMapper, const XModel* model) { - for (auto surfaceMaterialNum = 0; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++) + for (auto surfaceMaterialNum = 0u; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++) { Material* material = model->materialHandles[surfaceMaterialNum]; if (materialMapper.Add(material)) @@ -254,7 +254,7 @@ namespace void AddXModelVertexBoneWeights(XModelCommon& out, const XModelSurfs* modelSurfs) { auto& weightCollection = out.m_bone_weight_data; - size_t weightOffset = 0u; + auto weightOffset = 0u; for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++) { @@ -268,11 +268,12 @@ namespace const auto& vertList = surface.vertList[vertListIndex]; const auto boneWeightOffset = weightOffset; - weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f}; + weightCollection.weights[weightOffset++] = + XModelBoneWeight{.boneIndex = static_cast(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f}; for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++) { - out.m_vertex_bone_weights.emplace_back(boneWeightOffset, 1); + out.m_vertex_bone_weights.emplace_back(boneWeightOffset, 1u); } handledVertices += vertList.vertCount; } @@ -286,7 +287,7 @@ namespace { const auto boneWeightOffset = weightOffset; const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat); - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f}; vertsBlendOffset += 1; @@ -302,8 +303,8 @@ namespace const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]); const auto boneWeight0 = 1.0f - boneWeight1; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1}; vertsBlendOffset += 3; @@ -321,9 +322,9 @@ namespace const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]); const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2}; vertsBlendOffset += 5; @@ -343,10 +344,10 @@ namespace const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]); const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2}; - weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex3, boneWeight3}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2}; + weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex3, .weight = boneWeight3}; vertsBlendOffset += 7; diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp index 63da316b..5d65da59 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp @@ -271,13 +271,13 @@ void MenuDumper::WriteStatementSkipInitialUnnecessaryParenthesis(const Statement void MenuDumper::WriteStatementNaive(const Statement_s* statement) const { - const auto entryCount = static_cast(statement->numEntries); + const auto entryCount = static_cast(statement->numEntries); const auto missingClosingParenthesis = statement->numEntries > 0 && statement->entries[0].type == EET_OPERATOR && statement->entries[0].data.op == OP_LEFTPAREN && FindStatementClosingParenthesis(statement, 0) >= static_cast(statement->numEntries); - for (auto i = 0u; i < entryCount; i++) + for (auto i = 0uz; i < entryCount; i++) { const auto& entry = statement->entries[i]; if (entry.type == EET_OPERAND) @@ -314,7 +314,7 @@ void MenuDumper::WriteStatementNaive(const Statement_s* statement) const const auto closingParenPos = FindStatementClosingParenthesis(statement, i); m_stream << "("; - if (closingParenPos - i + 1 >= 1) + if (closingParenPos - i + 1u >= 1u) { const auto& staticDvarEntry = statement->entries[i + 1]; if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp index 3b36a004..d96e3c0b 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp @@ -240,7 +240,7 @@ void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, size_t s void MenuDumper::WriteStatementNaive(const Statement_s* statement) const { const auto entryCount = static_cast(statement->numEntries); - for (auto i = 0u; i < entryCount; i++) + for (auto i = 0uz; i < entryCount; i++) { const auto& entry = statement->entries[i]; if (entry.type == EET_OPERAND) @@ -277,9 +277,9 @@ void MenuDumper::WriteStatementNaive(const Statement_s* statement) const const auto closingParenPos = FindStatementClosingParenthesis(statement, i); m_stream << "("; - if (closingParenPos - i + 1 >= 1) + if (closingParenPos - i + 1u >= 1u) { - const auto& staticDvarEntry = statement->entries[i + 1]; + const auto& staticDvarEntry = statement->entries[i + 1u]; if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) { if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 diff --git a/src/ObjWriting/XModel/Export/XModelBinWriter.cpp b/src/ObjWriting/XModel/Export/XModelBinWriter.cpp index 2387f937..f9370d32 100644 --- a/src/ObjWriting/XModel/Export/XModelBinWriter.cpp +++ b/src/ObjWriting/XModel/Export/XModelBinWriter.cpp @@ -297,12 +297,12 @@ class XModelBinWriter7 final : public XModelBinWriterBase void WriteFaces(const XModelCommon& xmodel) { - auto totalFaceCount = 0u; + auto totalFaceCount = 0uz; for (const auto& object : xmodel.m_objects) totalFaceCount += object.m_faces.size(); XModelBinWriterBase::Write(static_cast(XModelBinHash::FACE_COUNT)); - XModelBinWriterBase::Write(totalFaceCount); + XModelBinWriterBase::Write(static_cast(totalFaceCount)); auto objectIndex = 0u; for (const auto& object : xmodel.m_objects) diff --git a/src/ObjWriting/XModel/Export/XModelExportWriter.cpp b/src/ObjWriting/XModel/Export/XModelExportWriter.cpp index 8cb6419d..45f4a021 100644 --- a/src/ObjWriting/XModel/Export/XModelExportWriter.cpp +++ b/src/ObjWriting/XModel/Export/XModelExportWriter.cpp @@ -122,11 +122,11 @@ class XModelExportWriter6 final : public XModelExportWriterBase void WriteFaces(const XModelCommon& xmodel) const { - auto totalFaceCount = 0u; + auto totalFaceCount = 0uz; for (const auto& object : xmodel.m_objects) totalFaceCount += object.m_faces.size(); - m_stream << "NUMFACES " << totalFaceCount << "\n"; + m_stream << std::format("NUMFACES {}\n", totalFaceCount); auto objectIndex = 0u; for (const auto& object : xmodel.m_objects) diff --git a/src/ObjWriting/XModel/GenericXModelDumper.inc.h b/src/ObjWriting/XModel/GenericXModelDumper.inc.h index 9e44946e..07f4fd88 100644 --- a/src/ObjWriting/XModel/GenericXModelDumper.inc.h +++ b/src/ObjWriting/XModel/GenericXModelDumper.inc.h @@ -343,7 +343,7 @@ namespace GAME_NAMESPACE if (!surfs) return; - size_t weightOffset = 0u; + auto weightOffset = 0u; for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++) { diff --git a/src/ObjWriting/XModel/Gltf/GltfBinOutput.cpp b/src/ObjWriting/XModel/Gltf/GltfBinOutput.cpp index 7bce3561..f57356c5 100644 --- a/src/ObjWriting/XModel/Gltf/GltfBinOutput.cpp +++ b/src/ObjWriting/XModel/Gltf/GltfBinOutput.cpp @@ -64,7 +64,7 @@ void BinOutput::EmitJson(const nlohmann::json& json) const void BinOutput::EmitBuffer(const void* buffer, const size_t bufferSize) const { - const auto chunkLength = utils::Align(bufferSize, 4u); + const auto chunkLength = utils::Align(static_cast(bufferSize), 4u); Write(&chunkLength, sizeof(chunkLength)); Write(&CHUNK_MAGIC_BIN, sizeof(CHUNK_MAGIC_BIN)); diff --git a/src/ObjWriting/XModel/Gltf/GltfWriter.cpp b/src/ObjWriting/XModel/Gltf/GltfWriter.cpp index 18eaf323..6ac7dea7 100644 --- a/src/ObjWriting/XModel/Gltf/GltfWriter.cpp +++ b/src/ObjWriting/XModel/Gltf/GltfWriter.cpp @@ -74,7 +74,7 @@ namespace if (!gltf.nodes.has_value()) gltf.nodes.emplace(); - m_first_mesh_node = gltf.nodes->size(); + m_first_mesh_node = static_cast(gltf.nodes->size()); auto meshIndex = 0u; for (const auto& object : xmodel.m_objects) @@ -123,7 +123,7 @@ namespace rootNode.children->push_back(m_first_bone_node); - m_root_node = gltf.nodes->size(); + m_root_node = static_cast(gltf.nodes->size()); gltf.nodes->emplace_back(std::move(rootNode)); } @@ -211,12 +211,12 @@ namespace JsonImage image; image.uri = std::move(uri); - const auto imageIndex = gltf.images->size(); + const auto imageIndex = static_cast(gltf.images->size()); gltf.images->emplace_back(std::move(image)); JsonTexture texture; texture.source = imageIndex; - const auto textureIndex = gltf.textures->size(); + const auto textureIndex = static_cast(gltf.textures->size()); gltf.textures->emplace_back(texture); return textureIndex; @@ -231,7 +231,7 @@ namespace gltf.nodes.emplace(); const auto boneCount = common.m_bones.size(); - m_first_bone_node = gltf.nodes->size(); + m_first_bone_node = static_cast(gltf.nodes->size()); for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++) { JsonNode boneNode; @@ -319,12 +319,12 @@ namespace JsonBufferView vertexBufferView; vertexBufferView.buffer = 0u; vertexBufferView.byteOffset = bufferOffset; - vertexBufferView.byteStride = sizeof(GltfVertex); - vertexBufferView.byteLength = sizeof(GltfVertex) * xmodel.m_vertices.size(); + vertexBufferView.byteStride = static_cast(sizeof(GltfVertex)); + vertexBufferView.byteLength = static_cast(sizeof(GltfVertex) * xmodel.m_vertices.size()); vertexBufferView.target = JsonBufferViewTarget::ARRAY_BUFFER; bufferOffset += vertexBufferView.byteLength; - m_vertex_buffer_view = gltf.bufferViews->size(); + m_vertex_buffer_view = static_cast(gltf.bufferViews->size()); gltf.bufferViews->emplace_back(vertexBufferView); if (!xmodel.m_bone_weight_data.weights.empty()) @@ -332,40 +332,40 @@ namespace JsonBufferView jointsBufferView; jointsBufferView.buffer = 0u; jointsBufferView.byteOffset = bufferOffset; - jointsBufferView.byteLength = sizeof(uint8_t) * xmodel.m_vertices.size() * 4u; + jointsBufferView.byteLength = static_cast(sizeof(uint8_t) * xmodel.m_vertices.size() * 4u); jointsBufferView.target = JsonBufferViewTarget::ARRAY_BUFFER; bufferOffset += jointsBufferView.byteLength; - m_joints_buffer_view = gltf.bufferViews->size(); + m_joints_buffer_view = static_cast(gltf.bufferViews->size()); gltf.bufferViews->emplace_back(jointsBufferView); JsonBufferView weightsBufferView; weightsBufferView.buffer = 0u; weightsBufferView.byteOffset = bufferOffset; - weightsBufferView.byteLength = sizeof(float) * xmodel.m_vertices.size() * 4u; + weightsBufferView.byteLength = static_cast(sizeof(float) * xmodel.m_vertices.size() * 4u); weightsBufferView.target = JsonBufferViewTarget::ARRAY_BUFFER; bufferOffset += weightsBufferView.byteLength; - m_weights_buffer_view = gltf.bufferViews->size(); + m_weights_buffer_view = static_cast(gltf.bufferViews->size()); gltf.bufferViews->emplace_back(weightsBufferView); JsonBufferView inverseBindMatricesBufferView; inverseBindMatricesBufferView.buffer = 0u; inverseBindMatricesBufferView.byteOffset = bufferOffset; - inverseBindMatricesBufferView.byteLength = sizeof(float) * xmodel.m_bones.size() * 16u; + inverseBindMatricesBufferView.byteLength = static_cast(sizeof(float) * xmodel.m_bones.size() * 16u); bufferOffset += inverseBindMatricesBufferView.byteLength; - m_inverse_bind_matrices_buffer_view = gltf.bufferViews->size(); + m_inverse_bind_matrices_buffer_view = static_cast(gltf.bufferViews->size()); gltf.bufferViews->emplace_back(inverseBindMatricesBufferView); } - m_first_index_buffer_view = gltf.bufferViews->size(); + m_first_index_buffer_view = static_cast(gltf.bufferViews->size()); for (const auto& object : xmodel.m_objects) { JsonBufferView indicesBufferView; indicesBufferView.buffer = 0u; indicesBufferView.byteOffset = bufferOffset; - indicesBufferView.byteLength = sizeof(unsigned short) * object.m_faces.size() * 3u; + indicesBufferView.byteLength = static_cast(sizeof(unsigned short) * object.m_faces.size() * 3u); indicesBufferView.target = JsonBufferViewTarget::ELEMENT_ARRAY_BUFFER; bufferOffset += indicesBufferView.byteLength; @@ -380,29 +380,29 @@ namespace JsonAccessor positionAccessor; positionAccessor.bufferView = m_vertex_buffer_view; - positionAccessor.byteOffset = offsetof(GltfVertex, coordinates); + positionAccessor.byteOffset = static_cast(offsetof(GltfVertex, coordinates)); positionAccessor.componentType = JsonAccessorComponentType::FLOAT; - positionAccessor.count = xmodel.m_vertices.size(); + positionAccessor.count = static_cast(xmodel.m_vertices.size()); positionAccessor.type = JsonAccessorType::VEC3; - m_position_accessor = gltf.accessors->size(); + m_position_accessor = static_cast(gltf.accessors->size()); gltf.accessors->emplace_back(positionAccessor); JsonAccessor normalAccessor; normalAccessor.bufferView = m_vertex_buffer_view; - normalAccessor.byteOffset = offsetof(GltfVertex, normal); + normalAccessor.byteOffset = static_cast(offsetof(GltfVertex, normal)); normalAccessor.componentType = JsonAccessorComponentType::FLOAT; - normalAccessor.count = xmodel.m_vertices.size(); + normalAccessor.count = static_cast(xmodel.m_vertices.size()); normalAccessor.type = JsonAccessorType::VEC3; - m_normal_accessor = gltf.accessors->size(); + m_normal_accessor = static_cast(gltf.accessors->size()); gltf.accessors->emplace_back(normalAccessor); JsonAccessor uvAccessor; uvAccessor.bufferView = m_vertex_buffer_view; - uvAccessor.byteOffset = offsetof(GltfVertex, uv); + uvAccessor.byteOffset = static_cast(offsetof(GltfVertex, uv)); uvAccessor.componentType = JsonAccessorComponentType::FLOAT; - uvAccessor.count = xmodel.m_vertices.size(); + uvAccessor.count = static_cast(xmodel.m_vertices.size()); uvAccessor.type = JsonAccessorType::VEC2; - m_uv_accessor = gltf.accessors->size(); + m_uv_accessor = static_cast(gltf.accessors->size()); gltf.accessors->emplace_back(uvAccessor); if (!xmodel.m_bone_weight_data.weights.empty()) @@ -410,29 +410,29 @@ namespace JsonAccessor jointsAccessor; jointsAccessor.bufferView = m_joints_buffer_view; jointsAccessor.componentType = JsonAccessorComponentType::UNSIGNED_BYTE; - jointsAccessor.count = xmodel.m_vertices.size(); + jointsAccessor.count = static_cast(xmodel.m_vertices.size()); jointsAccessor.type = JsonAccessorType::VEC4; - m_joints_accessor = gltf.accessors->size(); + m_joints_accessor = static_cast(gltf.accessors->size()); gltf.accessors->emplace_back(jointsAccessor); JsonAccessor weightsAccessor; weightsAccessor.bufferView = m_weights_buffer_view; weightsAccessor.componentType = JsonAccessorComponentType::FLOAT; - weightsAccessor.count = xmodel.m_vertices.size(); + weightsAccessor.count = static_cast(xmodel.m_vertices.size()); weightsAccessor.type = JsonAccessorType::VEC4; - m_weights_accessor = gltf.accessors->size(); + m_weights_accessor = static_cast(gltf.accessors->size()); gltf.accessors->emplace_back(weightsAccessor); JsonAccessor inverseBindMatricesAccessor; inverseBindMatricesAccessor.bufferView = m_inverse_bind_matrices_buffer_view; inverseBindMatricesAccessor.componentType = JsonAccessorComponentType::FLOAT; - inverseBindMatricesAccessor.count = xmodel.m_bones.size(); + inverseBindMatricesAccessor.count = static_cast(xmodel.m_bones.size()); inverseBindMatricesAccessor.type = JsonAccessorType::MAT4; - m_inverse_bind_matrices_accessor = gltf.accessors->size(); + m_inverse_bind_matrices_accessor = static_cast(gltf.accessors->size()); gltf.accessors->emplace_back(inverseBindMatricesAccessor); } - m_first_index_accessor = gltf.accessors->size(); + m_first_index_accessor = static_cast(gltf.accessors->size()); for (auto i = 0u; i < xmodel.m_objects.size(); i++) { const auto& object = xmodel.m_objects[i]; @@ -440,7 +440,7 @@ namespace JsonAccessor indicesAccessor; indicesAccessor.bufferView = m_first_index_buffer_view + i; indicesAccessor.componentType = JsonAccessorComponentType::UNSIGNED_SHORT; - indicesAccessor.count = object.m_faces.size() * 3u; + indicesAccessor.count = static_cast(object.m_faces.size() * 3u); indicesAccessor.type = JsonAccessorType::SCALAR; gltf.accessors->emplace_back(indicesAccessor); @@ -452,7 +452,7 @@ namespace const auto expectedBufferSize = GetExpectedBufferSize(xmodel); bufferData.resize(expectedBufferSize); - auto currentBufferOffset = 0u; + auto currentBufferOffset = 0uz; float minPosition[3]{ std::numeric_limits::max(), @@ -576,7 +576,7 @@ namespace static size_t GetExpectedBufferSize(const XModelCommon& xmodel) { - auto result = 0u; + auto result = 0uz; result += xmodel.m_vertices.size() * sizeof(GltfVertex); @@ -603,7 +603,7 @@ namespace gltf.buffers.emplace(); JsonBuffer jsonBuffer; - jsonBuffer.byteLength = bufferData.size(); + jsonBuffer.byteLength = static_cast(bufferData.size()); if (!bufferData.empty()) jsonBuffer.uri = m_output->CreateBufferUri(bufferData.data(), bufferData.size()); diff --git a/src/ObjWriting/XModel/XModelDumper.cpp.template b/src/ObjWriting/XModel/XModelDumper.cpp.template index 2e6e00f5..eebab624 100644 --- a/src/ObjWriting/XModel/XModelDumper.cpp.template +++ b/src/ObjWriting/XModel/XModelDumper.cpp.template @@ -380,7 +380,7 @@ namespace return; auto& weightCollection = out.m_bone_weight_data; - size_t weightOffset = 0u; + auto weightOffset = 0u; for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++) { diff --git a/src/Unlinker/Unlinker.cpp b/src/Unlinker/Unlinker.cpp index d21c1e2f..c79d0d7b 100644 --- a/src/Unlinker/Unlinker.cpp +++ b/src/Unlinker/Unlinker.cpp @@ -106,7 +106,7 @@ private: ObjWriting::Configuration.AssetTypesToHandleBitfield = std::vector(assetTypeCount); std::vector handledSpecifiedAssets(m_args.m_specified_asset_types.size()); - for (auto i = 0; i < assetTypeCount; i++) + for (auto i = 0u; i < assetTypeCount; i++) { const auto assetTypeName = std::string(*context.m_zone.m_pools->GetAssetTypeName(i)); @@ -136,7 +136,7 @@ private: std::cerr << "Valid asset types are:\n"; auto first = true; - for (auto i = 0; i < assetTypeCount; i++) + for (auto i = 0u; i < assetTypeCount; i++) { const auto assetTypeName = std::string(*context.m_zone.m_pools->GetAssetTypeName(i)); diff --git a/src/Unlinker/UnlinkerArgs.cpp b/src/Unlinker/UnlinkerArgs.cpp index 18e66f32..08746e50 100644 --- a/src/Unlinker/UnlinkerArgs.cpp +++ b/src/Unlinker/UnlinkerArgs.cpp @@ -251,7 +251,7 @@ void UnlinkerArgs::AddSpecifiedAssetType(std::string value) void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input) { - auto currentPos = 0u; + auto currentPos = 0uz; size_t endPos; std::string lowerInput(input); diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h index 4ba9f1b8..8a3fd944 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h @@ -1,4 +1,5 @@ #pragma once + #include "Game/IW4/IW4.h" #include "Loading/ContentLoaderBase.h" #include "Loading/IContentLoadingEntryPoint.h" @@ -7,17 +8,18 @@ namespace IW4 { class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint { - XAsset* varXAsset; - ScriptStringList* varScriptStringList; + public: + ContentLoader(); + void Load(Zone* zone, IZoneInputStream* stream) override; + + private: void LoadScriptStringList(bool atStreamStart); void LoadXAsset(bool atStreamStart) const; void LoadXAssetArray(bool atStreamStart, size_t count); - public: - ContentLoader(); - - void Load(Zone* zone, IZoneInputStream* stream) override; + XAsset* varXAsset; + ScriptStringList* varScriptStringList; }; } // namespace IW4 diff --git a/src/ZoneLoading/Zone/Stream/IZoneInputStream.h b/src/ZoneLoading/Zone/Stream/IZoneInputStream.h index b1158e17..c363b759 100644 --- a/src/ZoneLoading/Zone/Stream/IZoneInputStream.h +++ b/src/ZoneLoading/Zone/Stream/IZoneInputStream.h @@ -25,7 +25,7 @@ public: LoadDataInBlock(const_cast(reinterpret_cast(dst)), sizeof(T)); } - template void Load(T* dst, const uint32_t count) + template void Load(T* dst, const size_t count) { LoadDataInBlock(const_cast(reinterpret_cast(dst)), count * sizeof(T)); } diff --git a/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.cpp b/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.cpp index 07abf230..1355fd9b 100644 --- a/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.cpp +++ b/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.cpp @@ -10,12 +10,6 @@ class OutputProcessorDeflate::Impl { - z_stream m_stream{}; - OutputProcessorDeflate* m_base; - - std::unique_ptr m_buffer; - size_t m_buffer_size; - public: Impl(OutputProcessorDeflate* baseClass, const size_t bufferSize) : m_buffer(std::make_unique(bufferSize)), @@ -29,7 +23,7 @@ public: m_stream.avail_in = 0; m_stream.next_in = Z_NULL; m_stream.next_out = m_buffer.get(); - m_stream.avail_out = m_buffer_size; + m_stream.avail_out = static_cast(m_buffer_size); const int ret = deflateInit(&m_stream, Z_DEFAULT_COMPRESSION); @@ -52,7 +46,7 @@ public: void Write(const void* buffer, const size_t length) { m_stream.next_in = static_cast(buffer); - m_stream.avail_in = length; + m_stream.avail_in = static_cast(length); while (m_stream.avail_in > 0) { @@ -60,7 +54,7 @@ public: { m_base->m_base_stream->Write(m_buffer.get(), m_buffer_size); m_stream.next_out = m_buffer.get(); - m_stream.avail_out = m_buffer_size; + m_stream.avail_out = static_cast(m_buffer_size); } const auto ret = deflate(&m_stream, Z_NO_FLUSH); @@ -79,7 +73,7 @@ public: { m_base->m_base_stream->Write(m_buffer.get(), m_buffer_size - m_stream.avail_out); m_stream.next_out = m_buffer.get(); - m_stream.avail_out = m_buffer_size; + m_stream.avail_out = static_cast(m_buffer_size); } const auto ret = deflate(&m_stream, Z_FINISH); @@ -96,14 +90,21 @@ public: { m_base->m_base_stream->Write(m_buffer.get(), m_buffer_size - m_stream.avail_out); m_stream.next_out = m_buffer.get(); - m_stream.avail_out = m_buffer_size; + m_stream.avail_out = static_cast(m_buffer_size); } } - _NODISCARD int64_t Pos() const + [[nodiscard]] int64_t Pos() const { return m_base->m_base_stream->Pos(); } + +private: + z_stream m_stream{}; + OutputProcessorDeflate* m_base; + + std::unique_ptr m_buffer; + size_t m_buffer_size; }; OutputProcessorDeflate::OutputProcessorDeflate() diff --git a/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.h b/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.h index 69a27b0f..c3ee5ce9 100644 --- a/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.h +++ b/src/ZoneWriting/Writing/Processor/OutputProcessorDeflate.h @@ -13,7 +13,7 @@ class OutputProcessorDeflate final : public OutputStreamProcessor public: OutputProcessorDeflate(); - OutputProcessorDeflate(size_t bufferSize); + explicit OutputProcessorDeflate(size_t bufferSize); ~OutputProcessorDeflate() override; OutputProcessorDeflate(const OutputProcessorDeflate& other) = delete; OutputProcessorDeflate(OutputProcessorDeflate&& other) noexcept = default; diff --git a/src/ZoneWriting/Writing/Steps/StepWriteZero.cpp b/src/ZoneWriting/Writing/Steps/StepWriteZero.cpp index 5fc42368..46bff10d 100644 --- a/src/ZoneWriting/Writing/Steps/StepWriteZero.cpp +++ b/src/ZoneWriting/Writing/Steps/StepWriteZero.cpp @@ -9,10 +9,10 @@ StepWriteZero::StepWriteZero(const size_t count) void StepWriteZero::PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream) { - const uint64_t num = 0; + constexpr uint64_t num = 0; size_t toWrite; - for (auto i = 0u; i < m_count; i += toWrite) + for (auto i = 0uz; i < m_count; i += toWrite) { toWrite = std::min(sizeof(uint64_t), m_count - i); stream->Write(&num, toWrite); diff --git a/src/ZoneWriting/Zone/Stream/IZoneOutputStream.h b/src/ZoneWriting/Zone/Stream/IZoneOutputStream.h index b1c890bc..43b795bd 100644 --- a/src/ZoneWriting/Zone/Stream/IZoneOutputStream.h +++ b/src/ZoneWriting/Zone/Stream/IZoneOutputStream.h @@ -43,7 +43,7 @@ public: return static_cast(WriteDataInBlock(reinterpret_cast(dst), sizeof(T))); } - template T* Write(T* dst, const uint32_t count) + template T* Write(T* dst, const size_t count) { return static_cast(WriteDataInBlock(reinterpret_cast(dst), count * sizeof(T))); } diff --git a/test/ObjCommonTestUtils/SearchPath/MockOutputPath.cpp b/test/ObjCommonTestUtils/SearchPath/MockOutputPath.cpp index 25993a48..93ddd6b0 100644 --- a/test/ObjCommonTestUtils/SearchPath/MockOutputPath.cpp +++ b/test/ObjCommonTestUtils/SearchPath/MockOutputPath.cpp @@ -66,7 +66,7 @@ namespace pos_type seekpos(const pos_type pos, std::ios_base::openmode) override { - if (pos > m_data.size()) + if (pos > static_cast(m_data.size())) m_data.resize(static_cast(pos)); m_pos = static_cast(pos);