From e98ec7b2d3ea994924ef7c6def8c33b54f4a881a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 14 Nov 2025 00:18:35 +0100 Subject: [PATCH] Refactor string checks and variable declarations (#6392) * Refactor string checks and variable declarations * Change string check from contains to find * Fix syntax error in mesh node creation loop --- code/AssetLib/3DS/3DSConverter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp index cb0e1888e..439eea943 100644 --- a/code/AssetLib/3DS/3DSConverter.cpp +++ b/code/AssetLib/3DS/3DSConverter.cpp @@ -178,7 +178,7 @@ void CopyTexture(aiMaterial &mat, Texture &texture, aiTextureType type) { mat.AddProperty(&texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type, 0)); // Setup the texture mapping mode - int mapMode = static_cast(texture.mMapMode); + auto mapMode = static_cast(texture.mMapMode); mat.AddProperty(&mapMode, 1, AI_MATKEY_MAPPINGMODE_U(type, 0)); mat.AddProperty(&mapMode, 1, AI_MATKEY_MAPPINGMODE_V(type, 0)); @@ -333,7 +333,8 @@ void Discreet3DSImporter::ConvertMeshes(aiScene *pcOut) { for (auto i = mScene->mMeshes.begin(); i != mScene->mMeshes.end(); ++i) { std::unique_ptr[]> aiSplit(new std::vector[mScene->mMaterials.size()]); - name.length = ASSIMP_itoa10(name.data, num++); + name.length = ASSIMP_itoa10(name.data, num); + ++num; unsigned int iNum = 0; for (std::vector::const_iterator a = (*i).mFaceMaterials.begin(); @@ -477,7 +478,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene *pcSOut, aiNode *pcOut, D3DS::N // Setup the name of the node // First instance keeps its name otherwise something might break, all others will be postfixed with their instance number if (pcIn->mInstanceNumber > 1) { - char tmp[12]; + char tmp[12] = {'\0'}; ASSIMP_itoa10(tmp, pcIn->mInstanceNumber); std::string tempStr = pcIn->mName + "_inst_"; tempStr += tmp; @@ -704,7 +705,8 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene *pcOut) { // Build dummy nodes for all meshes unsigned int a = 0; for (unsigned int i = 0; i < pcOut->mNumMeshes; ++i, ++a) { - aiNode *pcNode = pcOut->mRootNode->mChildren[a] = new aiNode(); + pcOut->mRootNode->mChildren[a] = new aiNode(); + auto *pcNode = pcOut->mRootNode->mChildren[a]; pcNode->mParent = pcOut->mRootNode; pcNode->mMeshes = new unsigned int[1]; pcNode->mMeshes[0] = i;